@loaders.gl/raster 0.0.0-stage → 5.0.0-alpha.13

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 (379) hide show
  1. package/README.md +60 -2
  2. package/dist/geotiff/advanced.cjs +1955 -0
  3. package/dist/geotiff/advanced.cjs.map +7 -0
  4. package/dist/geotiff/advanced.d.ts +13 -0
  5. package/dist/geotiff/advanced.d.ts.map +1 -0
  6. package/dist/geotiff/advanced.js +12 -0
  7. package/dist/geotiff/advanced.js.map +1 -0
  8. package/dist/geotiff/bundled.d.ts +3 -0
  9. package/dist/geotiff/bundled.d.ts.map +1 -0
  10. package/dist/geotiff/bundled.js +5 -0
  11. package/dist/geotiff/bundled.js.map +1 -0
  12. package/dist/geotiff/discover-geotiff.d.ts +14 -0
  13. package/dist/geotiff/discover-geotiff.d.ts.map +1 -0
  14. package/dist/geotiff/discover-geotiff.js +63 -0
  15. package/dist/geotiff/discover-geotiff.js.map +1 -0
  16. package/dist/geotiff/geotiff-format.d.ts +21 -0
  17. package/dist/geotiff/geotiff-format.d.ts.map +1 -0
  18. package/dist/geotiff/geotiff-format.js +24 -0
  19. package/dist/geotiff/geotiff-format.js.map +1 -0
  20. package/dist/geotiff/geotiff-loader-types.d.ts +63 -0
  21. package/dist/geotiff/geotiff-loader-types.d.ts.map +1 -0
  22. package/dist/geotiff/geotiff-loader-types.js +26 -0
  23. package/dist/geotiff/geotiff-loader-types.js.map +1 -0
  24. package/dist/geotiff/geotiff-loader.d.ts +49 -0
  25. package/dist/geotiff/geotiff-loader.d.ts.map +1 -0
  26. package/dist/geotiff/geotiff-loader.js +70 -0
  27. package/dist/geotiff/geotiff-loader.js.map +1 -0
  28. package/dist/geotiff/geotiff-raster-loader-types.d.ts +37 -0
  29. package/dist/geotiff/geotiff-raster-loader-types.d.ts.map +1 -0
  30. package/dist/geotiff/geotiff-raster-loader-types.js +24 -0
  31. package/dist/geotiff/geotiff-raster-loader-types.js.map +1 -0
  32. package/dist/geotiff/geotiff-raster-loader.d.ts +22 -0
  33. package/dist/geotiff/geotiff-raster-loader.d.ts.map +1 -0
  34. package/dist/geotiff/geotiff-raster-loader.js +65 -0
  35. package/dist/geotiff/geotiff-raster-loader.js.map +1 -0
  36. package/dist/geotiff/geotiff-raster-types.d.ts +65 -0
  37. package/dist/geotiff/geotiff-raster-types.d.ts.map +1 -0
  38. package/dist/geotiff/geotiff-raster-types.js +5 -0
  39. package/dist/geotiff/geotiff-raster-types.js.map +1 -0
  40. package/dist/geotiff/geotiff-source-loader-types.d.ts +67 -0
  41. package/dist/geotiff/geotiff-source-loader-types.d.ts.map +1 -0
  42. package/dist/geotiff/geotiff-source-loader-types.js +43 -0
  43. package/dist/geotiff/geotiff-source-loader-types.js.map +1 -0
  44. package/dist/geotiff/geotiff-source-loader.d.ts +132 -0
  45. package/dist/geotiff/geotiff-source-loader.d.ts.map +1 -0
  46. package/dist/geotiff/geotiff-source-loader.js +1322 -0
  47. package/dist/geotiff/geotiff-source-loader.js.map +1 -0
  48. package/dist/geotiff/index.d.ts +3 -0
  49. package/dist/geotiff/index.d.ts.map +1 -0
  50. package/dist/geotiff/index.js +6 -0
  51. package/dist/geotiff/index.js.map +1 -0
  52. package/dist/geotiff/lib/load-geotiff.d.ts +28 -0
  53. package/dist/geotiff/lib/load-geotiff.d.ts.map +1 -0
  54. package/dist/geotiff/lib/load-geotiff.js +61 -0
  55. package/dist/geotiff/lib/load-geotiff.js.map +1 -0
  56. package/dist/geotiff/lib/ome/load-ome-tiff.d.ts +50 -0
  57. package/dist/geotiff/lib/ome/load-ome-tiff.d.ts.map +1 -0
  58. package/dist/geotiff/lib/ome/load-ome-tiff.js +42 -0
  59. package/dist/geotiff/lib/ome/load-ome-tiff.js.map +1 -0
  60. package/dist/geotiff/lib/ome/ome-indexers.d.ts +12 -0
  61. package/dist/geotiff/lib/ome/ome-indexers.d.ts.map +1 -0
  62. package/dist/geotiff/lib/ome/ome-indexers.js +109 -0
  63. package/dist/geotiff/lib/ome/ome-indexers.js.map +1 -0
  64. package/dist/geotiff/lib/ome/ome-utils.d.ts +32 -0
  65. package/dist/geotiff/lib/ome/ome-utils.d.ts.map +1 -0
  66. package/dist/geotiff/lib/ome/ome-utils.js +67 -0
  67. package/dist/geotiff/lib/ome/ome-utils.js.map +1 -0
  68. package/dist/geotiff/lib/ome/omexml.d.ts +49 -0
  69. package/dist/geotiff/lib/ome/omexml.d.ts.map +1 -0
  70. package/dist/geotiff/lib/ome/omexml.js +63 -0
  71. package/dist/geotiff/lib/ome/omexml.js.map +1 -0
  72. package/dist/geotiff/lib/ome/utils.d.ts +7 -0
  73. package/dist/geotiff/lib/ome/utils.d.ts.map +1 -0
  74. package/dist/geotiff/lib/ome/utils.js +29 -0
  75. package/dist/geotiff/lib/ome/utils.js.map +1 -0
  76. package/dist/geotiff/lib/tiff/decode-tiff-samples.d.ts +34 -0
  77. package/dist/geotiff/lib/tiff/decode-tiff-samples.d.ts.map +1 -0
  78. package/dist/geotiff/lib/tiff/decode-tiff-samples.js +150 -0
  79. package/dist/geotiff/lib/tiff/decode-tiff-samples.js.map +1 -0
  80. package/dist/geotiff/lib/tiff/geotiff-decoder-adapter.d.ts +4 -0
  81. package/dist/geotiff/lib/tiff/geotiff-decoder-adapter.d.ts.map +1 -0
  82. package/dist/geotiff/lib/tiff/geotiff-decoder-adapter.js +88 -0
  83. package/dist/geotiff/lib/tiff/geotiff-decoder-adapter.js.map +1 -0
  84. package/dist/geotiff/lib/tiff/geotiff-source-adapter.d.ts +4 -0
  85. package/dist/geotiff/lib/tiff/geotiff-source-adapter.d.ts.map +1 -0
  86. package/dist/geotiff/lib/tiff/geotiff-source-adapter.js +51 -0
  87. package/dist/geotiff/lib/tiff/geotiff-source-adapter.js.map +1 -0
  88. package/dist/geotiff/lib/tiff/plan-tiff-blocks.d.ts +10 -0
  89. package/dist/geotiff/lib/tiff/plan-tiff-blocks.d.ts.map +1 -0
  90. package/dist/geotiff/lib/tiff/plan-tiff-blocks.js +101 -0
  91. package/dist/geotiff/lib/tiff/plan-tiff-blocks.js.map +1 -0
  92. package/dist/geotiff/lib/tiff/read-tiff-directory.d.ts +8 -0
  93. package/dist/geotiff/lib/tiff/read-tiff-directory.d.ts.map +1 -0
  94. package/dist/geotiff/lib/tiff/read-tiff-directory.js +219 -0
  95. package/dist/geotiff/lib/tiff/read-tiff-directory.js.map +1 -0
  96. package/dist/geotiff/lib/tiff/tiff-gdal-metadata.d.ts +8 -0
  97. package/dist/geotiff/lib/tiff/tiff-gdal-metadata.d.ts.map +1 -0
  98. package/dist/geotiff/lib/tiff/tiff-gdal-metadata.js +50 -0
  99. package/dist/geotiff/lib/tiff/tiff-gdal-metadata.js.map +1 -0
  100. package/dist/geotiff/lib/tiff/tiff-metadata.d.ts +5 -0
  101. package/dist/geotiff/lib/tiff/tiff-metadata.d.ts.map +1 -0
  102. package/dist/geotiff/lib/tiff/tiff-metadata.js +188 -0
  103. package/dist/geotiff/lib/tiff/tiff-metadata.js.map +1 -0
  104. package/dist/geotiff/lib/tiff/tiff-numeric-decoder.d.ts +40 -0
  105. package/dist/geotiff/lib/tiff/tiff-numeric-decoder.d.ts.map +1 -0
  106. package/dist/geotiff/lib/tiff/tiff-numeric-decoder.js +40 -0
  107. package/dist/geotiff/lib/tiff/tiff-numeric-decoder.js.map +1 -0
  108. package/dist/geotiff/lib/tiff/tiff-source-decoder.d.ts +103 -0
  109. package/dist/geotiff/lib/tiff/tiff-source-decoder.d.ts.map +1 -0
  110. package/dist/geotiff/lib/tiff/tiff-source-decoder.js +5 -0
  111. package/dist/geotiff/lib/tiff/tiff-source-decoder.js.map +1 -0
  112. package/dist/geotiff/lib/tiff/tiff-types.d.ts +49 -0
  113. package/dist/geotiff/lib/tiff/tiff-types.d.ts.map +1 -0
  114. package/dist/geotiff/lib/tiff/tiff-types.js +5 -0
  115. package/dist/geotiff/lib/tiff/tiff-types.js.map +1 -0
  116. package/dist/geotiff/lib/tiff-pixel-source.d.ts +17 -0
  117. package/dist/geotiff/lib/tiff-pixel-source.d.ts.map +1 -0
  118. package/dist/geotiff/lib/tiff-pixel-source.js +71 -0
  119. package/dist/geotiff/lib/tiff-pixel-source.js.map +1 -0
  120. package/dist/geotiff/lib/utils/tiff-utils.d.ts +10 -0
  121. package/dist/geotiff/lib/utils/tiff-utils.d.ts.map +1 -0
  122. package/dist/geotiff/lib/utils/tiff-utils.js +41 -0
  123. package/dist/geotiff/lib/utils/tiff-utils.js.map +1 -0
  124. package/dist/geotiff/loaders.d.ts +30 -0
  125. package/dist/geotiff/loaders.d.ts.map +1 -0
  126. package/dist/geotiff/loaders.js +53 -0
  127. package/dist/geotiff/loaders.js.map +1 -0
  128. package/dist/geotiff/ometiff-source-loader-types.d.ts +67 -0
  129. package/dist/geotiff/ometiff-source-loader-types.d.ts.map +1 -0
  130. package/dist/geotiff/ometiff-source-loader-types.js +38 -0
  131. package/dist/geotiff/ometiff-source-loader-types.js.map +1 -0
  132. package/dist/geotiff/ometiff-source-loader.d.ts +152 -0
  133. package/dist/geotiff/ometiff-source-loader.d.ts.map +1 -0
  134. package/dist/geotiff/ometiff-source-loader.js +256 -0
  135. package/dist/geotiff/ometiff-source-loader.js.map +1 -0
  136. package/dist/geotiff/types.d.ts +75 -0
  137. package/dist/geotiff/types.d.ts.map +1 -0
  138. package/dist/geotiff/types.js +5 -0
  139. package/dist/geotiff/types.js.map +1 -0
  140. package/dist/geotiff/unbundled.d.ts +3 -0
  141. package/dist/geotiff/unbundled.d.ts.map +1 -0
  142. package/dist/geotiff/unbundled.js +5 -0
  143. package/dist/geotiff/unbundled.js.map +1 -0
  144. package/dist/index.cjs +523 -0
  145. package/dist/index.cjs.map +7 -0
  146. package/dist/index.d.ts +29 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +19 -0
  149. package/dist/index.js.map +1 -0
  150. package/dist/lerc/bundled.d.ts +3 -0
  151. package/dist/lerc/bundled.d.ts.map +1 -0
  152. package/dist/lerc/bundled.js +5 -0
  153. package/dist/lerc/bundled.js.map +1 -0
  154. package/dist/lerc/index.d.ts +6 -0
  155. package/dist/lerc/index.d.ts.map +1 -0
  156. package/dist/lerc/index.js +9 -0
  157. package/dist/lerc/index.js.map +1 -0
  158. package/dist/lerc/lerc-format.d.ts +11 -0
  159. package/dist/lerc/lerc-format.d.ts.map +1 -0
  160. package/dist/lerc/lerc-format.js +14 -0
  161. package/dist/lerc/lerc-format.js.map +1 -0
  162. package/dist/lerc/lerc-loader-types.d.ts +54 -0
  163. package/dist/lerc/lerc-loader-types.d.ts.map +1 -0
  164. package/dist/lerc/lerc-loader-types.js +31 -0
  165. package/dist/lerc/lerc-loader-types.js.map +1 -0
  166. package/dist/lerc/lerc-loader.d.ts +36 -0
  167. package/dist/lerc/lerc-loader.d.ts.map +1 -0
  168. package/dist/lerc/lerc-loader.js +22 -0
  169. package/dist/lerc/lerc-loader.js.map +1 -0
  170. package/dist/lerc/lerc-wasm-url.d.ts +3 -0
  171. package/dist/lerc/lerc-wasm-url.d.ts.map +1 -0
  172. package/dist/lerc/lerc-wasm-url.js +8 -0
  173. package/dist/lerc/lerc-wasm-url.js.map +1 -0
  174. package/dist/lerc/lib/parsers/lerc/lerc-types.d.ts +30 -0
  175. package/dist/lerc/lib/parsers/lerc/lerc-types.d.ts.map +1 -0
  176. package/dist/lerc/lib/parsers/lerc/lerc-types.js +5 -0
  177. package/dist/lerc/lib/parsers/lerc/lerc-types.js.map +1 -0
  178. package/dist/lerc/libs/lerc/LICENSE +101 -0
  179. package/dist/lerc/libs/lerc/NOTICE +23 -0
  180. package/dist/lerc/libs/lerc/lerc-wasm.wasm +0 -0
  181. package/dist/lerc/unbundled.d.ts +3 -0
  182. package/dist/lerc/unbundled.d.ts.map +1 -0
  183. package/dist/lerc/unbundled.js +5 -0
  184. package/dist/lerc/unbundled.js.map +1 -0
  185. package/dist/lerc/workers/lerc-worker.d.ts +2 -0
  186. package/dist/lerc/workers/lerc-worker.d.ts.map +1 -0
  187. package/dist/lerc/workers/lerc-worker.js +7 -0
  188. package/dist/lerc/workers/lerc-worker.js.map +1 -0
  189. package/dist/quantized-mesh-worker.js +17271 -0
  190. package/dist/quantized-mesh.d.ts +2 -0
  191. package/dist/quantized-mesh.d.ts.map +1 -0
  192. package/dist/quantized-mesh.js +5 -0
  193. package/dist/quantized-mesh.js.map +1 -0
  194. package/dist/terrain/bundled.d.ts +5 -0
  195. package/dist/terrain/bundled.d.ts.map +1 -0
  196. package/dist/terrain/bundled.js +6 -0
  197. package/dist/terrain/bundled.js.map +1 -0
  198. package/dist/terrain/heightmap.cjs +397 -0
  199. package/dist/terrain/heightmap.cjs.map +7 -0
  200. package/dist/terrain/heightmap.d.ts +8 -0
  201. package/dist/terrain/heightmap.d.ts.map +1 -0
  202. package/dist/terrain/heightmap.js +8 -0
  203. package/dist/terrain/heightmap.js.map +1 -0
  204. package/dist/terrain/index.cjs +1406 -0
  205. package/dist/terrain/index.cjs.map +7 -0
  206. package/dist/terrain/index.d.ts +18 -0
  207. package/dist/terrain/index.d.ts.map +1 -0
  208. package/dist/terrain/index.js +16 -0
  209. package/dist/terrain/index.js.map +1 -0
  210. package/dist/terrain/lib/decode-quantized-mesh.d.ts +59 -0
  211. package/dist/terrain/lib/decode-quantized-mesh.d.ts.map +1 -0
  212. package/dist/terrain/lib/decode-quantized-mesh.js +227 -0
  213. package/dist/terrain/lib/decode-quantized-mesh.js.map +1 -0
  214. package/dist/terrain/lib/decode-terrain-heightmap.d.ts +16 -0
  215. package/dist/terrain/lib/decode-terrain-heightmap.d.ts.map +1 -0
  216. package/dist/terrain/lib/decode-terrain-heightmap.js +52 -0
  217. package/dist/terrain/lib/decode-terrain-heightmap.js.map +1 -0
  218. package/dist/terrain/lib/delatin/index.d.ts +24 -0
  219. package/dist/terrain/lib/delatin/index.d.ts.map +1 -0
  220. package/dist/terrain/lib/delatin/index.js +409 -0
  221. package/dist/terrain/lib/delatin/index.js.map +1 -0
  222. package/dist/terrain/lib/helpers/skirt.d.ts +19 -0
  223. package/dist/terrain/lib/helpers/skirt.d.ts.map +1 -0
  224. package/dist/terrain/lib/helpers/skirt.js +127 -0
  225. package/dist/terrain/lib/helpers/skirt.js.map +1 -0
  226. package/dist/terrain/lib/parse-quantized-mesh.d.ts +15 -0
  227. package/dist/terrain/lib/parse-quantized-mesh.d.ts.map +1 -0
  228. package/dist/terrain/lib/parse-quantized-mesh.js +86 -0
  229. package/dist/terrain/lib/parse-quantized-mesh.js.map +1 -0
  230. package/dist/terrain/lib/parse-terrain.d.ts +32 -0
  231. package/dist/terrain/lib/parse-terrain.d.ts.map +1 -0
  232. package/dist/terrain/lib/parse-terrain.js +150 -0
  233. package/dist/terrain/lib/parse-terrain.js.map +1 -0
  234. package/dist/terrain/lib/terrain-contracts.d.ts +58 -0
  235. package/dist/terrain/lib/terrain-contracts.d.ts.map +1 -0
  236. package/dist/terrain/lib/terrain-contracts.js +5 -0
  237. package/dist/terrain/lib/terrain-contracts.js.map +1 -0
  238. package/dist/terrain/lib/terrain-height-field.d.ts +51 -0
  239. package/dist/terrain/lib/terrain-height-field.d.ts.map +1 -0
  240. package/dist/terrain/lib/terrain-height-field.js +260 -0
  241. package/dist/terrain/lib/terrain-height-field.js.map +1 -0
  242. package/dist/terrain/lib/terrain-height-grid.d.ts +14 -0
  243. package/dist/terrain/lib/terrain-height-grid.d.ts.map +1 -0
  244. package/dist/terrain/lib/terrain-height-grid.js +104 -0
  245. package/dist/terrain/lib/terrain-height-grid.js.map +1 -0
  246. package/dist/terrain/lib/terrain-heightmap-types.d.ts +30 -0
  247. package/dist/terrain/lib/terrain-heightmap-types.d.ts.map +1 -0
  248. package/dist/terrain/lib/terrain-heightmap-types.js +5 -0
  249. package/dist/terrain/lib/terrain-heightmap-types.js.map +1 -0
  250. package/dist/terrain/lib/terrain-neighborhood.d.ts +15 -0
  251. package/dist/terrain/lib/terrain-neighborhood.d.ts.map +1 -0
  252. package/dist/terrain/lib/terrain-neighborhood.js +58 -0
  253. package/dist/terrain/lib/terrain-neighborhood.js.map +1 -0
  254. package/dist/terrain/lib/utils/version.d.ts +2 -0
  255. package/dist/terrain/lib/utils/version.d.ts.map +1 -0
  256. package/dist/terrain/lib/utils/version.js +8 -0
  257. package/dist/terrain/lib/utils/version.js.map +1 -0
  258. package/dist/terrain/libs/README.md +10 -0
  259. package/dist/terrain/libs/martini-LICENSE +15 -0
  260. package/dist/terrain/libs/martini.d.mts +19 -0
  261. package/dist/terrain/libs/martini.mjs +164 -0
  262. package/dist/terrain/quantized-mesh-loader-types.d.ts +18 -0
  263. package/dist/terrain/quantized-mesh-loader-types.d.ts.map +1 -0
  264. package/dist/terrain/quantized-mesh-loader-types.js +26 -0
  265. package/dist/terrain/quantized-mesh-loader-types.js.map +1 -0
  266. package/dist/terrain/quantized-mesh-loader.d.ts +5 -0
  267. package/dist/terrain/quantized-mesh-loader.d.ts.map +1 -0
  268. package/dist/terrain/quantized-mesh-loader.js +31 -0
  269. package/dist/terrain/quantized-mesh-loader.js.map +1 -0
  270. package/dist/terrain/quantized-mesh-writer.d.ts +35 -0
  271. package/dist/terrain/quantized-mesh-writer.d.ts.map +1 -0
  272. package/dist/terrain/quantized-mesh-writer.js +251 -0
  273. package/dist/terrain/quantized-mesh-writer.js.map +1 -0
  274. package/dist/terrain/terrain-format.d.ts +22 -0
  275. package/dist/terrain/terrain-format.d.ts.map +1 -0
  276. package/dist/terrain/terrain-format.js +25 -0
  277. package/dist/terrain/terrain-format.js.map +1 -0
  278. package/dist/terrain/terrain-loader-types.d.ts +17 -0
  279. package/dist/terrain/terrain-loader-types.d.ts.map +1 -0
  280. package/dist/terrain/terrain-loader-types.js +33 -0
  281. package/dist/terrain/terrain-loader-types.js.map +1 -0
  282. package/dist/terrain/terrain-loader.d.ts +16 -0
  283. package/dist/terrain/terrain-loader.d.ts.map +1 -0
  284. package/dist/terrain/terrain-loader.js +58 -0
  285. package/dist/terrain/terrain-loader.js.map +1 -0
  286. package/dist/terrain/unbundled.d.ts +5 -0
  287. package/dist/terrain/unbundled.d.ts.map +1 -0
  288. package/dist/terrain/unbundled.js +6 -0
  289. package/dist/terrain/unbundled.js.map +1 -0
  290. package/dist/terrain/workers/quantized-mesh-worker.d.ts +2 -0
  291. package/dist/terrain/workers/quantized-mesh-worker.d.ts.map +1 -0
  292. package/dist/terrain/workers/quantized-mesh-worker.js +7 -0
  293. package/dist/terrain/workers/quantized-mesh-worker.js.map +1 -0
  294. package/dist/terrain/workers/terrain-worker.d.ts +2 -0
  295. package/dist/terrain/workers/terrain-worker.d.ts.map +1 -0
  296. package/dist/terrain/workers/terrain-worker.js +7 -0
  297. package/dist/terrain/workers/terrain-worker.js.map +1 -0
  298. package/dist/terrain-worker.js +18238 -0
  299. package/package.json +344 -4
  300. package/src/geotiff/advanced.ts +29 -0
  301. package/src/geotiff/bundled.ts +6 -0
  302. package/src/geotiff/discover-geotiff.ts +70 -0
  303. package/src/geotiff/geotiff-format.ts +27 -0
  304. package/src/geotiff/geotiff-loader-types.ts +50 -0
  305. package/src/geotiff/geotiff-loader.ts +107 -0
  306. package/src/geotiff/geotiff-raster-loader-types.ts +31 -0
  307. package/src/geotiff/geotiff-raster-loader.ts +85 -0
  308. package/src/geotiff/geotiff-raster-types.ts +72 -0
  309. package/src/geotiff/geotiff-source-loader-types.ts +55 -0
  310. package/src/geotiff/geotiff-source-loader.ts +1738 -0
  311. package/src/geotiff/index.ts +6 -0
  312. package/src/geotiff/lib/load-geotiff.ts +88 -0
  313. package/src/geotiff/lib/ome/load-ome-tiff.ts +55 -0
  314. package/src/geotiff/lib/ome/ome-indexers.ts +132 -0
  315. package/src/geotiff/lib/ome/ome-utils.ts +78 -0
  316. package/src/geotiff/lib/ome/omexml.ts +183 -0
  317. package/src/geotiff/lib/ome/utils.ts +43 -0
  318. package/src/geotiff/lib/tiff/decode-tiff-samples.ts +214 -0
  319. package/src/geotiff/lib/tiff/geotiff-decoder-adapter.ts +114 -0
  320. package/src/geotiff/lib/tiff/geotiff-source-adapter.ts +65 -0
  321. package/src/geotiff/lib/tiff/plan-tiff-blocks.ts +130 -0
  322. package/src/geotiff/lib/tiff/read-tiff-directory.ts +243 -0
  323. package/src/geotiff/lib/tiff/tiff-gdal-metadata.ts +59 -0
  324. package/src/geotiff/lib/tiff/tiff-metadata.ts +204 -0
  325. package/src/geotiff/lib/tiff/tiff-numeric-decoder.ts +87 -0
  326. package/src/geotiff/lib/tiff/tiff-source-decoder.ts +112 -0
  327. package/src/geotiff/lib/tiff/tiff-types.ts +56 -0
  328. package/src/geotiff/lib/tiff-pixel-source.ts +103 -0
  329. package/src/geotiff/lib/utils/Pool.ts.disabled +99 -0
  330. package/src/geotiff/lib/utils/decoder.worker.ts.disabled +21 -0
  331. package/src/geotiff/lib/utils/proxies.ts.disabled +96 -0
  332. package/src/geotiff/lib/utils/tiff-utils.ts +49 -0
  333. package/src/geotiff/loaders.ts +79 -0
  334. package/src/geotiff/ometiff-source-loader-types.ts +47 -0
  335. package/src/geotiff/ometiff-source-loader.ts +420 -0
  336. package/src/geotiff/types.ts +87 -0
  337. package/src/geotiff/unbundled.ts +6 -0
  338. package/src/index.ts +57 -0
  339. package/src/lerc/bundled.ts +6 -0
  340. package/src/lerc/index.ts +10 -0
  341. package/src/lerc/lerc-format.ts +16 -0
  342. package/src/lerc/lerc-loader-types.ts +51 -0
  343. package/src/lerc/lerc-loader.ts +41 -0
  344. package/src/lerc/lerc-wasm-url.ts +9 -0
  345. package/src/lerc/lib/parsers/lerc/lerc-types.ts +45 -0
  346. package/src/lerc/libs/lerc/LICENSE +101 -0
  347. package/src/lerc/libs/lerc/NOTICE +23 -0
  348. package/src/lerc/libs/lerc/lerc-wasm.wasm +0 -0
  349. package/src/lerc/unbundled.ts +6 -0
  350. package/src/lerc/workers/lerc-worker.ts +8 -0
  351. package/src/quantized-mesh.ts +5 -0
  352. package/src/terrain/bundled.ts +8 -0
  353. package/src/terrain/heightmap.ts +30 -0
  354. package/src/terrain/index.ts +41 -0
  355. package/src/terrain/lib/decode-quantized-mesh.ts +329 -0
  356. package/src/terrain/lib/decode-terrain-heightmap.ts +68 -0
  357. package/src/terrain/lib/delatin/index.ts +495 -0
  358. package/src/terrain/lib/helpers/skirt.ts +172 -0
  359. package/src/terrain/lib/parse-quantized-mesh.ts +122 -0
  360. package/src/terrain/lib/parse-terrain.ts +217 -0
  361. package/src/terrain/lib/terrain-contracts.ts +68 -0
  362. package/src/terrain/lib/terrain-height-field.ts +355 -0
  363. package/src/terrain/lib/terrain-height-grid.ts +157 -0
  364. package/src/terrain/lib/terrain-heightmap-types.ts +35 -0
  365. package/src/terrain/lib/terrain-neighborhood.ts +69 -0
  366. package/src/terrain/lib/utils/version.ts +8 -0
  367. package/src/terrain/libs/README.md +10 -0
  368. package/src/terrain/libs/martini-LICENSE +15 -0
  369. package/src/terrain/libs/martini.d.mts +19 -0
  370. package/src/terrain/libs/martini.mjs +164 -0
  371. package/src/terrain/quantized-mesh-loader-types.ts +44 -0
  372. package/src/terrain/quantized-mesh-loader.ts +46 -0
  373. package/src/terrain/quantized-mesh-writer.ts +380 -0
  374. package/src/terrain/terrain-format.ts +28 -0
  375. package/src/terrain/terrain-loader-types.ts +52 -0
  376. package/src/terrain/terrain-loader.ts +79 -0
  377. package/src/terrain/unbundled.ts +8 -0
  378. package/src/terrain/workers/quantized-mesh-worker.ts +8 -0
  379. package/src/terrain/workers/terrain-worker.ts +8 -0
@@ -0,0 +1,41 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/core/loader-utils';
6
+ import type {LERCData} from './lib/parsers/lerc/lerc-types';
7
+ import * as Lerc from 'lerc';
8
+ import {LERCLoader as LERCLoaderMetadata} from './lerc-loader-types';
9
+ import {LERC_WASM_URL} from './lerc-wasm-url';
10
+
11
+ const {preload: _LERCLoaderPreload, ...LERCLoaderMetadataWithoutPreload} = LERCLoaderMetadata;
12
+
13
+ /** LERC loader options */
14
+ export type LERCLoaderOptions = LoaderOptions & {
15
+ /** LERC loader options */
16
+ lerc?: {
17
+ /** The number of bytes to skip in the input byte stream. A valid Lerc file is expected at that position. */
18
+ inputOffset?: number;
19
+ /** It is recommended to use the returned mask instead of setting this value. */
20
+ noDataValue?: number;
21
+ /** (ndepth LERC2 only) If true, returned depth values are pixel-interleaved. */
22
+ returnInterleaved?: boolean;
23
+ };
24
+ };
25
+
26
+ /**
27
+ * Loader for the LERC raster format
28
+ */
29
+ export const LERCLoaderWithParser = {
30
+ ...LERCLoaderMetadataWithoutPreload,
31
+ parse: async (arrayBuffer: ArrayBuffer, options?: LERCLoaderOptions) =>
32
+ parseLERC(arrayBuffer, options)
33
+ } as const satisfies LoaderWithParser<LERCData, never, LERCLoaderOptions>;
34
+
35
+ async function parseLERC(arrayBuffer: ArrayBuffer, options?: LERCLoaderOptions): Promise<LERCData> {
36
+ // Load the WASM library
37
+ await Lerc.load({locateFile: () => LERC_WASM_URL});
38
+ // Perform the decode
39
+ const pixelBlock = Lerc.decode(arrayBuffer, options?.lerc);
40
+ return pixelBlock;
41
+ }
@@ -0,0 +1,9 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ /** URL of the vendored LERC WebAssembly binary. */
6
+ export const LERC_WASM_URL =
7
+ typeof __dirname !== 'undefined'
8
+ ? new URL('./libs/lerc/lerc-wasm.wasm', `file://${__dirname}/`).toString()
9
+ : new URL('./libs/lerc/lerc-wasm.wasm', import.meta.url).toString();
@@ -0,0 +1,45 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ /** Data returned by LERC loader */
6
+ export type LERCData = {
7
+ /** Width of decoded image */
8
+ width: number;
9
+ /** Height of decoded image */
10
+ height: number;
11
+ /** The type of pixels represented in the output */
12
+ pixelType: LercPixelType;
13
+ /** [statistics_band1, statistics_band2, …] Each element is a statistics object representing min and max values */
14
+ statistics: BandStats[];
15
+ /** [band1, band2, …] Each band is a typed array of width * height * depthCount */
16
+ pixels: TypedArray[];
17
+ /** Typed array with a size of width*height, or null if all pixels are valid */
18
+ mask: Uint8Array | null;
19
+ /** Depth count */
20
+ depthCount: number;
21
+ /** array [band1_mask, band2_mask, …] Each band is a Uint8Array of width * height * depthCount */
22
+ bandMasks?: Uint8Array[] | null;
23
+ };
24
+
25
+ export type LercPixelType = 'S8' | 'U8' | 'S16' | 'U16' | 'S32' | 'U32' | 'F32' | 'F64';
26
+
27
+ export interface BandStats {
28
+ minValue: number;
29
+ maxValue: number;
30
+ depthStats?: {
31
+ minValues: Float64Array;
32
+ maxValues: Float64Array;
33
+ };
34
+ }
35
+
36
+ export type TypedArray =
37
+ | Int8Array
38
+ | Uint8Array
39
+ | Uint8ClampedArray
40
+ | Int16Array
41
+ | Uint16Array
42
+ | Int32Array
43
+ | Uint32Array
44
+ | Float32Array
45
+ | Float64Array;
@@ -0,0 +1,101 @@
1
+ Apache License - 2.0
2
+
3
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
+
5
+ 1. Definitions.
6
+
7
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
8
+
9
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
10
+
11
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control
12
+ with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management
13
+ of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
14
+ ownership of such entity.
15
+
16
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
17
+
18
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source,
19
+ and configuration files.
20
+
21
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to
22
+ compiled object code, generated documentation, and conversions to other media types.
23
+
24
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice
25
+ that is included in or attached to the work (an example is provided in the Appendix below).
26
+
27
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the
28
+ editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes
29
+ of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of,
30
+ the Work and Derivative Works thereof.
31
+
32
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work
33
+ or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual
34
+ or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of
35
+ electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on
36
+ electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for
37
+ the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing
38
+ by the copyright owner as "Not a Contribution."
39
+
40
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and
41
+ subsequently incorporated within the Work.
42
+
43
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual,
44
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display,
45
+ publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
46
+
47
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide,
48
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell,
49
+ sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are
50
+ necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was
51
+ submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work
52
+ or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You
53
+ under this License for that Work shall terminate as of the date such litigation is filed.
54
+
55
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications,
56
+ and in Source or Object form, provided that You meet the following conditions:
57
+
58
+ 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
59
+
60
+ 2. You must cause any modified files to carry prominent notices stating that You changed the files; and
61
+
62
+ 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices
63
+ from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
64
+
65
+ 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a
66
+ readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the
67
+ Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the
68
+ Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever
69
+ such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License.
70
+ You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work,
71
+ provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to
72
+ Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your
73
+ modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with
74
+ the conditions stated in this License.
75
+
76
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You
77
+ to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above,
78
+ nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
79
+
80
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except
81
+ as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
82
+
83
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides
84
+ its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation,
85
+ any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
86
+ determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under
87
+ this License.
88
+
89
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required
90
+ by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages,
91
+ including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the
92
+ use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or
93
+ any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
94
+
95
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a
96
+ fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting
97
+ such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree
98
+ to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your
99
+ accepting any such warranty or additional liability.
100
+
101
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,23 @@
1
+
2
+ LERC
3
+ Copyright 2015-2026 Esri
4
+
5
+ This software embodiment is an implementation of
6
+
7
+ United States Patent 9,002,126, Limited Error Raster Compression (LERC).
8
+ Assignee: Esri.
9
+ Assignors/Inventors: Maurer, Thomas (Redlands, CA); Gao, Peng (Redlands, CA); Becker, Peter (Redlands, CA).
10
+
11
+ The right to practice this patent is hereby granted under the Apache V2.0 License Agreement,
12
+ Clause 3 - Grant of Patent License.
13
+
14
+ The license is available at
15
+ http://github.com/Esri/lerc/
16
+
17
+ For additional information, contact:
18
+
19
+ Environmental Systems Research Institute, Inc.
20
+ Attn: Contracts and Legal Department
21
+ 380 New York Street
22
+ Redlands, CA 92373
23
+ E-mail: contracts@esri.com
@@ -0,0 +1,6 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export type {LERCLoaderOptions} from './lerc-loader-types';
6
+ export {LERCLoader} from './lerc-loader-types';
@@ -0,0 +1,8 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {createLoaderWorker} from '@loaders.gl/core/loader-utils';
6
+ import {LERCLoaderWithParser} from '../lerc-loader';
7
+
8
+ createLoaderWorker(LERCLoaderWithParser);
@@ -0,0 +1,5 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export {QuantizedMeshLoaderWithParser} from './terrain/quantized-mesh-loader';
@@ -0,0 +1,8 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export type {TerrainLoaderOptions} from './terrain-loader-types';
6
+ export type {QuantizedMeshLoaderOptions} from './quantized-mesh-loader-types';
7
+ export {TerrainLoaderWithParser as TerrainLoader, parseTerrain} from './terrain-loader';
8
+ export {QuantizedMeshLoaderWithParser as QuantizedMeshLoader} from './quantized-mesh-loader';
@@ -0,0 +1,30 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export type {
6
+ ElevationDecoder,
7
+ TerrainHeightmap,
8
+ TerrainHeightmapImage
9
+ } from './lib/terrain-heightmap-types';
10
+ export {
11
+ decodeTerrainHeightmap,
12
+ TERRARIUM_ELEVATION_DECODER
13
+ } from './lib/decode-terrain-heightmap';
14
+
15
+ export type {
16
+ TerrainGridMetadata,
17
+ TerrainHeightGrid,
18
+ TerrainRay,
19
+ TerrainSurfaceHit,
20
+ TerrainSurfaceBounds,
21
+ TerrainSurface
22
+ } from './lib/terrain-contracts';
23
+ export {createTerrainHeightGrid, sampleTerrainHeightGrid} from './lib/terrain-height-grid';
24
+ export {TerrainHeightField} from './lib/terrain-height-field';
25
+ export type {
26
+ TerrainFieldBounds,
27
+ TerrainHeightFieldOptions,
28
+ TerrainHeightFieldStatistics
29
+ } from './lib/terrain-height-field';
30
+ export {sampleTerrainNeighborhood, resampleTerrainNodes} from './lib/terrain-neighborhood';
@@ -0,0 +1,41 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ export type {TerrainLoaderOptions} from './terrain-loader-types';
6
+ export type {
7
+ TerrainFieldBounds,
8
+ TerrainHeightFieldOptions,
9
+ TerrainHeightFieldStatistics
10
+ } from './lib/terrain-height-field';
11
+ export type {
12
+ TerrainGridMetadata,
13
+ TerrainHeightGrid,
14
+ TerrainRay,
15
+ TerrainSurfaceHit,
16
+ TerrainSurfaceBounds,
17
+ TerrainSurface
18
+ } from './lib/terrain-contracts';
19
+ export type {
20
+ ElevationDecoder,
21
+ TerrainHeightmap,
22
+ TerrainHeightmapImage
23
+ } from './lib/terrain-heightmap-types';
24
+ export type {QuantizedMeshLoaderOptions} from './quantized-mesh-loader-types';
25
+
26
+ export {TerrainFormat, QuantizedMeshFormat} from './terrain-format';
27
+ export {TerrainLoader} from './terrain-loader-types';
28
+
29
+ export {parseTerrain} from './terrain-loader';
30
+ export {TerrainLoaderWithParser} from './terrain-loader';
31
+ export {QuantizedMeshLoader} from './quantized-mesh-loader-types';
32
+ export {QuantizedMeshLoaderWithParser} from './quantized-mesh-loader';
33
+
34
+ export type {QuantizedMeshWriterOptions} from './quantized-mesh-writer';
35
+ export {QuantizedMeshWriter} from './quantized-mesh-writer';
36
+
37
+ // DEPRECATED EXPORTS
38
+ /** @deprecated Use TerrainLoader. */
39
+ export {TerrainLoader as TerrainWorkerLoader} from './terrain-loader-types';
40
+ /** @deprecated Use QuantizedMeshLoader. */
41
+ export {QuantizedMeshLoader as QuantizedMeshWorkerLoader} from './quantized-mesh-loader-types';
@@ -0,0 +1,329 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ // Copyright (C) 2018-2019 HERE Europe B.V.
6
+ //
7
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ // of this software and associated documentation files (the "Software"), to deal
9
+ // in the Software without restriction, including without limitation the rights
10
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ // copies of the Software, and to permit persons to whom the Software is
12
+ // furnished to do so, subject to the following conditions:
13
+ //
14
+ // The above copyright notice and this permission notice shall be included in
15
+ // all copies or substantial portions of the Software.
16
+ //
17
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ // SOFTWARE.
24
+
25
+ const QUANTIZED_MESH_HEADER = new Map([
26
+ ['centerX', Float64Array.BYTES_PER_ELEMENT],
27
+ ['centerY', Float64Array.BYTES_PER_ELEMENT],
28
+ ['centerZ', Float64Array.BYTES_PER_ELEMENT],
29
+
30
+ ['minHeight', Float32Array.BYTES_PER_ELEMENT],
31
+ ['maxHeight', Float32Array.BYTES_PER_ELEMENT],
32
+
33
+ ['boundingSphereCenterX', Float64Array.BYTES_PER_ELEMENT],
34
+ ['boundingSphereCenterY', Float64Array.BYTES_PER_ELEMENT],
35
+ ['boundingSphereCenterZ', Float64Array.BYTES_PER_ELEMENT],
36
+ ['boundingSphereRadius', Float64Array.BYTES_PER_ELEMENT],
37
+
38
+ ['horizonOcclusionPointX', Float64Array.BYTES_PER_ELEMENT],
39
+ ['horizonOcclusionPointY', Float64Array.BYTES_PER_ELEMENT],
40
+ ['horizonOcclusionPointZ', Float64Array.BYTES_PER_ELEMENT]
41
+ ]);
42
+
43
+ function decodeZigZag(value) {
44
+ return (value >> 1) ^ -(value & 1);
45
+ }
46
+
47
+ function decodeHeader(dataView) {
48
+ let position = 0;
49
+ const header = {};
50
+
51
+ for (const [key, bytesCount] of QUANTIZED_MESH_HEADER) {
52
+ const getter = bytesCount === 8 ? dataView.getFloat64 : dataView.getFloat32;
53
+
54
+ header[key] = getter.call(dataView, position, true);
55
+ position += bytesCount;
56
+ }
57
+
58
+ return {header, headerEndPosition: position};
59
+ }
60
+
61
+ function decodeVertexData(dataView, headerEndPosition) {
62
+ let position = headerEndPosition;
63
+ const elementsPerVertex = 3;
64
+ const vertexCount = dataView.getUint32(position, true);
65
+ const vertexData = new Uint16Array(vertexCount * elementsPerVertex);
66
+
67
+ position += Uint32Array.BYTES_PER_ELEMENT;
68
+
69
+ const bytesPerArrayElement = Uint16Array.BYTES_PER_ELEMENT;
70
+ const elementArrayLength = vertexCount * bytesPerArrayElement;
71
+ const uArrayStartPosition = position;
72
+ const vArrayStartPosition = uArrayStartPosition + elementArrayLength;
73
+ const heightArrayStartPosition = vArrayStartPosition + elementArrayLength;
74
+
75
+ let u = 0;
76
+ let v = 0;
77
+ let height = 0;
78
+
79
+ for (let i = 0; i < vertexCount; i++) {
80
+ u += decodeZigZag(dataView.getUint16(uArrayStartPosition + bytesPerArrayElement * i, true));
81
+ v += decodeZigZag(dataView.getUint16(vArrayStartPosition + bytesPerArrayElement * i, true));
82
+ height += decodeZigZag(
83
+ dataView.getUint16(heightArrayStartPosition + bytesPerArrayElement * i, true)
84
+ );
85
+
86
+ vertexData[i] = u;
87
+ vertexData[i + vertexCount] = v;
88
+ vertexData[i + vertexCount * 2] = height;
89
+ }
90
+
91
+ position += elementArrayLength * 3;
92
+
93
+ return {vertexData, vertexDataEndPosition: position};
94
+ }
95
+
96
+ function decodeIndex(buffer, position, indicesCount, bytesPerIndex, encoded = true) {
97
+ let indices;
98
+
99
+ if (bytesPerIndex === 2) {
100
+ indices = new Uint16Array(buffer, position, indicesCount);
101
+ } else {
102
+ indices = new Uint32Array(buffer, position, indicesCount);
103
+ }
104
+
105
+ if (!encoded) {
106
+ return indices;
107
+ }
108
+
109
+ let highest = 0;
110
+
111
+ for (let i = 0; i < indices.length; ++i) {
112
+ const code = indices[i];
113
+
114
+ indices[i] = highest - code;
115
+
116
+ if (code === 0) {
117
+ ++highest;
118
+ }
119
+ }
120
+
121
+ return indices;
122
+ }
123
+
124
+ function decodeTriangleIndices(dataView, vertexData, vertexDataEndPosition) {
125
+ let position = vertexDataEndPosition;
126
+ const elementsPerVertex = 3;
127
+ const vertexCount = vertexData.length / elementsPerVertex;
128
+ const bytesPerIndex =
129
+ vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;
130
+
131
+ if (position % bytesPerIndex !== 0) {
132
+ position += bytesPerIndex - (position % bytesPerIndex);
133
+ }
134
+
135
+ const triangleCount = dataView.getUint32(position, true);
136
+ position += Uint32Array.BYTES_PER_ELEMENT;
137
+
138
+ const triangleIndicesCount = triangleCount * 3;
139
+ const triangleIndices = decodeIndex(
140
+ dataView.buffer,
141
+ position,
142
+ triangleIndicesCount,
143
+ bytesPerIndex
144
+ );
145
+ position += triangleIndicesCount * bytesPerIndex;
146
+
147
+ return {
148
+ triangleIndicesEndPosition: position,
149
+ triangleIndices
150
+ };
151
+ }
152
+
153
+ function decodeEdgeIndices(dataView, vertexData, triangleIndicesEndPosition) {
154
+ let position = triangleIndicesEndPosition;
155
+ const elementsPerVertex = 3;
156
+ const vertexCount = vertexData.length / elementsPerVertex;
157
+ const bytesPerIndex =
158
+ vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;
159
+
160
+ const westVertexCount = dataView.getUint32(position, true);
161
+ position += Uint32Array.BYTES_PER_ELEMENT;
162
+
163
+ const westIndices = decodeIndex(dataView.buffer, position, westVertexCount, bytesPerIndex, false);
164
+ position += westVertexCount * bytesPerIndex;
165
+
166
+ const southVertexCount = dataView.getUint32(position, true);
167
+ position += Uint32Array.BYTES_PER_ELEMENT;
168
+
169
+ const southIndices = decodeIndex(
170
+ dataView.buffer,
171
+ position,
172
+ southVertexCount,
173
+ bytesPerIndex,
174
+ false
175
+ );
176
+ position += southVertexCount * bytesPerIndex;
177
+
178
+ const eastVertexCount = dataView.getUint32(position, true);
179
+ position += Uint32Array.BYTES_PER_ELEMENT;
180
+
181
+ const eastIndices = decodeIndex(dataView.buffer, position, eastVertexCount, bytesPerIndex, false);
182
+ position += eastVertexCount * bytesPerIndex;
183
+
184
+ const northVertexCount = dataView.getUint32(position, true);
185
+ position += Uint32Array.BYTES_PER_ELEMENT;
186
+
187
+ const northIndices = decodeIndex(
188
+ dataView.buffer,
189
+ position,
190
+ northVertexCount,
191
+ bytesPerIndex,
192
+ false
193
+ );
194
+ position += northVertexCount * bytesPerIndex;
195
+
196
+ return {
197
+ edgeIndicesEndPosition: position,
198
+ westIndices,
199
+ southIndices,
200
+ eastIndices,
201
+ northIndices
202
+ };
203
+ }
204
+
205
+ function decodeVertexNormalsExtension(extensionDataView) {
206
+ return new Uint8Array(
207
+ extensionDataView.buffer,
208
+ extensionDataView.byteOffset,
209
+ extensionDataView.byteLength
210
+ );
211
+ }
212
+
213
+ function decodeWaterMaskExtension(extensionDataView) {
214
+ return extensionDataView.buffer.slice(
215
+ extensionDataView.byteOffset,
216
+ extensionDataView.byteOffset + extensionDataView.byteLength
217
+ );
218
+ }
219
+
220
+ type Extensions = {
221
+ vertexNormals?: any;
222
+ waterMask?: any;
223
+ };
224
+
225
+ function decodeExtensions(dataView, indicesEndPosition) {
226
+ const extensions: Extensions = {};
227
+
228
+ if (dataView.byteLength <= indicesEndPosition) {
229
+ return {extensions, extensionsEndPosition: indicesEndPosition};
230
+ }
231
+
232
+ let position = indicesEndPosition;
233
+
234
+ while (position < dataView.byteLength) {
235
+ const extensionId = dataView.getUint8(position, true);
236
+ position += Uint8Array.BYTES_PER_ELEMENT;
237
+
238
+ const extensionLength = dataView.getUint32(position, true);
239
+ position += Uint32Array.BYTES_PER_ELEMENT;
240
+
241
+ const extensionView = new DataView(dataView.buffer, position, extensionLength);
242
+
243
+ switch (extensionId) {
244
+ case 1: {
245
+ extensions.vertexNormals = decodeVertexNormalsExtension(extensionView);
246
+
247
+ break;
248
+ }
249
+ case 2: {
250
+ extensions.waterMask = decodeWaterMaskExtension(extensionView);
251
+
252
+ break;
253
+ }
254
+ default: {
255
+ // console.warn(`Unknown extension with id ${extensionId}`)
256
+ }
257
+ }
258
+
259
+ position += extensionLength;
260
+ }
261
+
262
+ return {extensions, extensionsEndPosition: position};
263
+ }
264
+
265
+ export const DECODING_STEPS = {
266
+ header: 0,
267
+ vertices: 1,
268
+ triangleIndices: 2,
269
+ edgeIndices: 3,
270
+ extensions: 4
271
+ };
272
+
273
+ const DEFAULT_OPTIONS = {
274
+ maxDecodingStep: DECODING_STEPS.extensions
275
+ };
276
+
277
+ export default function decode(data, userOptions) {
278
+ const options = Object.assign({}, DEFAULT_OPTIONS, userOptions);
279
+ const view = new DataView(data);
280
+ const {header, headerEndPosition} = decodeHeader(view);
281
+
282
+ if (options.maxDecodingStep < DECODING_STEPS.vertices) {
283
+ return {header};
284
+ }
285
+
286
+ const {vertexData, vertexDataEndPosition} = decodeVertexData(view, headerEndPosition);
287
+
288
+ if (options.maxDecodingStep < DECODING_STEPS.triangleIndices) {
289
+ return {header, vertexData};
290
+ }
291
+
292
+ const {triangleIndices, triangleIndicesEndPosition} = decodeTriangleIndices(
293
+ view,
294
+ vertexData,
295
+ vertexDataEndPosition
296
+ );
297
+
298
+ if (options.maxDecodingStep < DECODING_STEPS.edgeIndices) {
299
+ return {header, vertexData, triangleIndices};
300
+ }
301
+
302
+ const {westIndices, southIndices, eastIndices, northIndices, edgeIndicesEndPosition} =
303
+ decodeEdgeIndices(view, vertexData, triangleIndicesEndPosition);
304
+
305
+ if (options.maxDecodingStep < DECODING_STEPS.extensions) {
306
+ return {
307
+ header,
308
+ vertexData,
309
+ triangleIndices,
310
+ westIndices,
311
+ northIndices,
312
+ eastIndices,
313
+ southIndices
314
+ };
315
+ }
316
+
317
+ const {extensions} = decodeExtensions(view, edgeIndicesEndPosition);
318
+
319
+ return {
320
+ header,
321
+ vertexData,
322
+ triangleIndices,
323
+ westIndices,
324
+ northIndices,
325
+ eastIndices,
326
+ southIndices,
327
+ extensions
328
+ };
329
+ }