@navaramap/three 0.0.0

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 (350) hide show
  1. package/LICENSE +8 -0
  2. package/dist/assets/atmosphere/README.md +1 -0
  3. package/dist/assets/atmosphere/higher_order_scattering.bin +0 -0
  4. package/dist/assets/atmosphere/higher_order_scattering.exr +0 -0
  5. package/dist/assets/atmosphere/irradiance.bin +0 -0
  6. package/dist/assets/atmosphere/irradiance.exr +0 -0
  7. package/dist/assets/atmosphere/scattering.bin +0 -0
  8. package/dist/assets/atmosphere/scattering.exr +0 -0
  9. package/dist/assets/atmosphere/single_mie_scattering.bin +0 -0
  10. package/dist/assets/atmosphere/single_mie_scattering.exr +0 -0
  11. package/dist/assets/atmosphere/stars.bin +0 -0
  12. package/dist/assets/atmosphere/transmittance.bin +0 -0
  13. package/dist/assets/atmosphere/transmittance.exr +0 -0
  14. package/dist/assets/cloud/README.md +1 -0
  15. package/dist/assets/cloud/local_weather.png +0 -0
  16. package/dist/assets/cloud/shape.bin +1 -0
  17. package/dist/assets/cloud/shape_detail.bin +1 -0
  18. package/dist/assets/cloud/turbulence.png +0 -0
  19. package/dist/assets/fontWorker-CEJEfRpb.js +2 -0
  20. package/dist/assets/fontWorker-CEJEfRpb.js.map +1 -0
  21. package/dist/assets/index-BUB-ijMO.js +12 -0
  22. package/dist/assets/index-BUB-ijMO.js.map +1 -0
  23. package/dist/assets/navara_wasm_font_worker_bg-665OLxjy.wasm +0 -0
  24. package/dist/assets/navara_wasm_worker_bg-BXhKC5bE.wasm +0 -0
  25. package/dist/assets/noise/README.md +1 -0
  26. package/dist/assets/noise/stbn.bin +0 -0
  27. package/dist/assets/water/README.md +3 -0
  28. package/dist/assets/water/waternormals.jpg +0 -0
  29. package/dist/index.d.ts +10114 -0
  30. package/dist/index.js +34481 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/index.umd.cjs +6345 -0
  33. package/dist/index.umd.cjs.map +1 -0
  34. package/package.json +95 -0
  35. package/src/Color.ts +111 -0
  36. package/src/ShadowMapViewers.ts +49 -0
  37. package/src/atmosphere.test.ts +76 -0
  38. package/src/atmosphere.ts +364 -0
  39. package/src/bufferView.ts +90 -0
  40. package/src/camera.ts +182 -0
  41. package/src/concurrency.ts +15 -0
  42. package/src/constants/assets.ts +30 -0
  43. package/src/constants/decoder.ts +7 -0
  44. package/src/constants/index.ts +2 -0
  45. package/src/core/BaseDesc.ts +142 -0
  46. package/src/core/BaseHandle.ts +126 -0
  47. package/src/core/DescRegistry.ts +88 -0
  48. package/src/core/EffectDesc.ts +343 -0
  49. package/src/core/EffectDescRegistry.ts +31 -0
  50. package/src/core/InstancedMeshDesc.ts +413 -0
  51. package/src/core/LightDesc.ts +216 -0
  52. package/src/core/LightDescRegistry.ts +32 -0
  53. package/src/core/MeshDesc.ts +457 -0
  54. package/src/core/MeshDescRegistry.ts +32 -0
  55. package/src/core/MeshDescWithSelectiveEffect.ts +129 -0
  56. package/src/core/Registries.ts +59 -0
  57. package/src/core/SelectiveEffectRegistry.ts +90 -0
  58. package/src/core/ViewContext.ts +235 -0
  59. package/src/core/errors.ts +16 -0
  60. package/src/core/index.ts +50 -0
  61. package/src/device.ts +414 -0
  62. package/src/effects/CustomEffectPass.ts +28 -0
  63. package/src/effects/copy.ts +10 -0
  64. package/src/effects/effect.ts +87 -0
  65. package/src/effects/index.ts +4 -0
  66. package/src/effects/render.ts +10 -0
  67. package/src/evaluations/FeatureEvaluator.ts +529 -0
  68. package/src/evaluations/index.ts +1 -0
  69. package/src/event/HillshadeContext.test.ts +232 -0
  70. package/src/event/HillshadeContext.ts +299 -0
  71. package/src/event/context.ts +279 -0
  72. package/src/event/feature.ts +357 -0
  73. package/src/event/featureEvent.ts +81 -0
  74. package/src/event/features/billboard.ts +30 -0
  75. package/src/event/features/model.ts +192 -0
  76. package/src/event/features/modelGpuBytes.test.ts +69 -0
  77. package/src/event/features/modelGpuBytes.ts +87 -0
  78. package/src/event/features/point.ts +25 -0
  79. package/src/event/features/polygon.ts +23 -0
  80. package/src/event/features/polygonOutline.ts +19 -0
  81. package/src/event/features/polyline.ts +19 -0
  82. package/src/event/features/text.ts +71 -0
  83. package/src/event/hillshade.test.ts +842 -0
  84. package/src/event/hillshade.ts +588 -0
  85. package/src/event/index.ts +700 -0
  86. package/src/event/loaders.ts +53 -0
  87. package/src/event/tile.ts +19 -0
  88. package/src/event/worker.ts +999 -0
  89. package/src/event/workerTaskSettlement.test.ts +243 -0
  90. package/src/event/workerTaskSettlement.ts +128 -0
  91. package/src/inMemoryBufferStore.test.ts +60 -0
  92. package/src/inMemoryBufferStore.ts +67 -0
  93. package/src/index.iife.ts +11 -0
  94. package/src/index.ts +2556 -0
  95. package/src/input.ts +144 -0
  96. package/src/layer.ts +183 -0
  97. package/src/layers/effect/FinalCopyEffectDesc.ts +29 -0
  98. package/src/layers/effect/MRTPassEffectDesc.ts +105 -0
  99. package/src/layers/effect/README.md +9 -0
  100. package/src/layers/effect/SelectiveEffectDesc.ts +113 -0
  101. package/src/layers/effect/SkyEnvMapEffectDesc.ts +58 -0
  102. package/src/layers/effect/TransparentPassEffectDesc.ts +62 -0
  103. package/src/layers/effect/index.ts +5 -0
  104. package/src/layers/index.ts +1 -0
  105. package/src/layersManager.ts +63 -0
  106. package/src/light.ts +15 -0
  107. package/src/loaders/AbortableImageLoader.ts +203 -0
  108. package/src/loaders/AbortableTextureLoader.ts +74 -0
  109. package/src/loaders/index.ts +5 -0
  110. package/src/material/enhancer/DESIGN.md +300 -0
  111. package/src/material/enhancer/MaterialEnhancer.ts +112 -0
  112. package/src/material/enhancer/ShaderReplacer.test.ts +114 -0
  113. package/src/material/enhancer/ShaderReplacer.ts +97 -0
  114. package/src/material/enhancer/batchTexture.ts +8 -0
  115. package/src/material/enhancer/index.ts +46 -0
  116. package/src/material/enhancer/instancedSprite/index.ts +7 -0
  117. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/index.test.ts +214 -0
  118. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/index.ts +134 -0
  119. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/markers.ts +21 -0
  120. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/material.ts +32 -0
  121. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/mutates.test.ts +277 -0
  122. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/mutates.ts +151 -0
  123. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/shader.test.ts +114 -0
  124. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/shader.ts +49 -0
  125. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/state.test.ts +82 -0
  126. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/state.ts +80 -0
  127. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/types.ts +146 -0
  128. package/src/material/enhancer/instancedSprite/instancedSpriteMaterialEnhancer.ts +105 -0
  129. package/src/material/enhancer/model/index.ts +25 -0
  130. package/src/material/enhancer/model/modelBaseEnhancer/index.test.ts +74 -0
  131. package/src/material/enhancer/model/modelBaseEnhancer/index.ts +110 -0
  132. package/src/material/enhancer/model/modelBaseEnhancer/markers.ts +27 -0
  133. package/src/material/enhancer/model/modelBaseEnhancer/material.test.ts +66 -0
  134. package/src/material/enhancer/model/modelBaseEnhancer/material.ts +44 -0
  135. package/src/material/enhancer/model/modelBaseEnhancer/mutates.test.ts +84 -0
  136. package/src/material/enhancer/model/modelBaseEnhancer/mutates.ts +47 -0
  137. package/src/material/enhancer/model/modelBaseEnhancer/shader.test.ts +24 -0
  138. package/src/material/enhancer/model/modelBaseEnhancer/shader.ts +162 -0
  139. package/src/material/enhancer/model/modelBaseEnhancer/state.test.ts +103 -0
  140. package/src/material/enhancer/model/modelBaseEnhancer/state.ts +52 -0
  141. package/src/material/enhancer/model/modelBaseEnhancer/types.ts +89 -0
  142. package/src/material/enhancer/model/modelMaterialEnhancer.ts +91 -0
  143. package/src/material/enhancer/model/modelWaterEnhancer/index.test.ts +71 -0
  144. package/src/material/enhancer/model/modelWaterEnhancer/index.ts +175 -0
  145. package/src/material/enhancer/model/modelWaterEnhancer/material.test.ts +48 -0
  146. package/src/material/enhancer/model/modelWaterEnhancer/material.ts +25 -0
  147. package/src/material/enhancer/model/modelWaterEnhancer/mutates.test.ts +89 -0
  148. package/src/material/enhancer/model/modelWaterEnhancer/mutates.ts +89 -0
  149. package/src/material/enhancer/model/modelWaterEnhancer/shader.test.ts +34 -0
  150. package/src/material/enhancer/model/modelWaterEnhancer/shader.ts +111 -0
  151. package/src/material/enhancer/model/modelWaterEnhancer/state.test.ts +105 -0
  152. package/src/material/enhancer/model/modelWaterEnhancer/state.ts +59 -0
  153. package/src/material/enhancer/model/modelWaterEnhancer/types.ts +141 -0
  154. package/src/material/enhancer/model/pntsEnhancer/index.test.ts +96 -0
  155. package/src/material/enhancer/model/pntsEnhancer/index.ts +82 -0
  156. package/src/material/enhancer/model/pntsEnhancer/markers.ts +6 -0
  157. package/src/material/enhancer/model/pntsEnhancer/material.test.ts +37 -0
  158. package/src/material/enhancer/model/pntsEnhancer/material.ts +21 -0
  159. package/src/material/enhancer/model/pntsEnhancer/mutates.test.ts +80 -0
  160. package/src/material/enhancer/model/pntsEnhancer/mutates.ts +29 -0
  161. package/src/material/enhancer/model/pntsEnhancer/shader.test.ts +32 -0
  162. package/src/material/enhancer/model/pntsEnhancer/shader.ts +56 -0
  163. package/src/material/enhancer/model/pntsEnhancer/state.test.ts +87 -0
  164. package/src/material/enhancer/model/pntsEnhancer/state.ts +29 -0
  165. package/src/material/enhancer/model/pntsEnhancer/types.ts +38 -0
  166. package/src/material/enhancer/polygon/index.ts +22 -0
  167. package/src/material/enhancer/polygon/polygonBaseEnhancer/index.test.ts +101 -0
  168. package/src/material/enhancer/polygon/polygonBaseEnhancer/index.ts +130 -0
  169. package/src/material/enhancer/polygon/polygonBaseEnhancer/markers.ts +23 -0
  170. package/src/material/enhancer/polygon/polygonBaseEnhancer/material.test.ts +19 -0
  171. package/src/material/enhancer/polygon/polygonBaseEnhancer/material.ts +38 -0
  172. package/src/material/enhancer/polygon/polygonBaseEnhancer/mutates.test.ts +75 -0
  173. package/src/material/enhancer/polygon/polygonBaseEnhancer/mutates.ts +122 -0
  174. package/src/material/enhancer/polygon/polygonBaseEnhancer/shader.test.ts +25 -0
  175. package/src/material/enhancer/polygon/polygonBaseEnhancer/shader.ts +249 -0
  176. package/src/material/enhancer/polygon/polygonBaseEnhancer/state.test.ts +102 -0
  177. package/src/material/enhancer/polygon/polygonBaseEnhancer/state.ts +92 -0
  178. package/src/material/enhancer/polygon/polygonBaseEnhancer/types.ts +150 -0
  179. package/src/material/enhancer/polygon/polygonMaterialEnhancer.ts +97 -0
  180. package/src/material/enhancer/polygon/polygonWaterEnhancer/index.test.ts +72 -0
  181. package/src/material/enhancer/polygon/polygonWaterEnhancer/index.ts +164 -0
  182. package/src/material/enhancer/polygon/polygonWaterEnhancer/material.test.ts +48 -0
  183. package/src/material/enhancer/polygon/polygonWaterEnhancer/material.ts +35 -0
  184. package/src/material/enhancer/polygon/polygonWaterEnhancer/mutates.ts +61 -0
  185. package/src/material/enhancer/polygon/polygonWaterEnhancer/shader.test.ts +34 -0
  186. package/src/material/enhancer/polygon/polygonWaterEnhancer/shader.ts +96 -0
  187. package/src/material/enhancer/polygon/polygonWaterEnhancer/state.test.ts +98 -0
  188. package/src/material/enhancer/polygon/polygonWaterEnhancer/state.ts +57 -0
  189. package/src/material/enhancer/polygon/polygonWaterEnhancer/types.ts +115 -0
  190. package/src/material/enhancer/polyline/index.ts +7 -0
  191. package/src/material/enhancer/polyline/polylineBaseEnhancer/index.test.ts +157 -0
  192. package/src/material/enhancer/polyline/polylineBaseEnhancer/index.ts +154 -0
  193. package/src/material/enhancer/polyline/polylineBaseEnhancer/markers.ts +19 -0
  194. package/src/material/enhancer/polyline/polylineBaseEnhancer/material.test.ts +42 -0
  195. package/src/material/enhancer/polyline/polylineBaseEnhancer/material.ts +38 -0
  196. package/src/material/enhancer/polyline/polylineBaseEnhancer/mutates.test.ts +120 -0
  197. package/src/material/enhancer/polyline/polylineBaseEnhancer/mutates.ts +169 -0
  198. package/src/material/enhancer/polyline/polylineBaseEnhancer/shader.test.ts +67 -0
  199. package/src/material/enhancer/polyline/polylineBaseEnhancer/shader.ts +75 -0
  200. package/src/material/enhancer/polyline/polylineBaseEnhancer/state.test.ts +55 -0
  201. package/src/material/enhancer/polyline/polylineBaseEnhancer/state.ts +91 -0
  202. package/src/material/enhancer/polyline/polylineBaseEnhancer/types.ts +170 -0
  203. package/src/material/enhancer/polyline/polylineMaterialEnhancer.ts +102 -0
  204. package/src/material/enhancer/sdfText/index.ts +7 -0
  205. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/index.ts +125 -0
  206. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/markers.ts +19 -0
  207. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/material.test.ts +35 -0
  208. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/material.ts +32 -0
  209. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/mutates.test.ts +381 -0
  210. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/mutates.ts +232 -0
  211. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/shader.ts +36 -0
  212. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/state.test.ts +118 -0
  213. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/state.ts +107 -0
  214. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/types.ts +184 -0
  215. package/src/material/enhancer/sdfText/sdfTextMaterialEnhancer.ts +100 -0
  216. package/src/material/enhancer/shadowMap/index.ts +7 -0
  217. package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/index.ts +97 -0
  218. package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/markers.ts +10 -0
  219. package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/material.ts +31 -0
  220. package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/mutates.ts +8 -0
  221. package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/shader.test.ts +17 -0
  222. package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/shader.ts +53 -0
  223. package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/state.ts +17 -0
  224. package/src/material/enhancer/shadowMap/shadowMapDepthEnhancer/types.ts +26 -0
  225. package/src/material/enhancer/test-utils/shaderCompatibility.ts +124 -0
  226. package/src/material/enhancer/tileComposite/compose.test.ts +95 -0
  227. package/src/material/enhancer/tileComposite/compose.ts +112 -0
  228. package/src/material/enhancer/tileComposite/index.ts +23 -0
  229. package/src/material/enhancer/tileComposite/tileCompositeBaseEnhancer/index.ts +11 -0
  230. package/src/material/enhancer/tileComposite/tileCompositeBaseEnhancer/mutates.ts +132 -0
  231. package/src/material/enhancer/tileComposite/tileCompositeBaseEnhancer/shader.ts +245 -0
  232. package/src/material/enhancer/tileComposite/tileCompositeBaseEnhancer/types.ts +43 -0
  233. package/src/material/enhancer/tileComposite/tileElevationHeatmapEnhancer/index.ts +29 -0
  234. package/src/material/enhancer/tileComposite/tileElevationHeatmapEnhancer/mutates.ts +68 -0
  235. package/src/material/enhancer/tileComposite/tileElevationHeatmapEnhancer/shader.ts +24 -0
  236. package/src/material/enhancer/tileComposite/tileHillshadeEnhancer/index.ts +29 -0
  237. package/src/material/enhancer/tileComposite/tileHillshadeEnhancer/mutates.ts +34 -0
  238. package/src/material/enhancer/tileComposite/tileHillshadeEnhancer/shader.ts +36 -0
  239. package/src/material/enhancer/tileComposite/tileWaterEnhancer/index.ts +23 -0
  240. package/src/material/enhancer/tileComposite/tileWaterEnhancer/mutates.ts +23 -0
  241. package/src/material/enhancer/tileComposite/tileWaterEnhancer/shader.ts +8 -0
  242. package/src/material/enhancer/tileComposite/tileWatermaskEnhancer/index.ts +23 -0
  243. package/src/material/enhancer/tileComposite/tileWatermaskEnhancer/mutates.ts +34 -0
  244. package/src/material/enhancer/tileComposite/tileWatermaskEnhancer/shader.ts +13 -0
  245. package/src/material/enhancer/tileComposite/types.ts +58 -0
  246. package/src/material/index.ts +3 -0
  247. package/src/material/macro/index.ts +1 -0
  248. package/src/material/macro/tileShader.test.ts +136 -0
  249. package/src/material/macro/tileShader.ts +287 -0
  250. package/src/material/overrideMaterialsForMRT.ts +439 -0
  251. package/src/material/selectiveEffectMaterialSetup.test.ts +52 -0
  252. package/src/material/selectiveEffectMaterialSetup.ts +53 -0
  253. package/src/material/types/index.ts +1 -0
  254. package/src/material/types/uniform.ts +1 -0
  255. package/src/mesh/DrapedMesh.ts +101 -0
  256. package/src/mesh/batchTexture.test.ts +646 -0
  257. package/src/mesh/batchTexture.ts +437 -0
  258. package/src/mesh/batchedFeature.ts +186 -0
  259. package/src/mesh/batchedSdfText.ts +484 -0
  260. package/src/mesh/featureMesh.ts +43 -0
  261. package/src/mesh/index.ts +16 -0
  262. package/src/mesh/instanced.ts +117 -0
  263. package/src/mesh/model.ts +483 -0
  264. package/src/mesh/pickableMesh.ts +55 -0
  265. package/src/mesh/pickableMeshWrapper.ts +529 -0
  266. package/src/mesh/polygon.ts +699 -0
  267. package/src/mesh/polygonOutline.ts +393 -0
  268. package/src/mesh/polyline.ts +523 -0
  269. package/src/mesh/releaseGeometryArrays.ts +57 -0
  270. package/src/mesh/rtcRteHelper.ts +211 -0
  271. package/src/mesh/sdfText.test.ts +200 -0
  272. package/src/mesh/sdfText.ts +1019 -0
  273. package/src/mesh/sprite/billboardAtlas.test.ts +177 -0
  274. package/src/mesh/sprite/billboardAtlas.ts +210 -0
  275. package/src/mesh/sprite/billboardAtlasImageLoader.ts +29 -0
  276. package/src/mesh/sprite/index.ts +1 -0
  277. package/src/mesh/sprite/instancedSprite.ts +694 -0
  278. package/src/mesh/tile.test.ts +393 -0
  279. package/src/mesh/tile.ts +1790 -0
  280. package/src/object3DEvent.ts +6 -0
  281. package/src/orchestrators/RenderPassOrchestrator.ts +147 -0
  282. package/src/orchestrators/index.ts +1 -0
  283. package/src/passes/AllDepthCopyPass.ts +165 -0
  284. package/src/passes/CustomRenderPass.ts +279 -0
  285. package/src/passes/NormalCopyPass.ts +125 -0
  286. package/src/passes/RenderTargetCopyPass.ts +91 -0
  287. package/src/passes/SkyEnvMapPass.ts +58 -0
  288. package/src/passes/index.ts +5 -0
  289. package/src/pick/pickHelper.ts +273 -0
  290. package/src/pick/pickTerrain.ts +254 -0
  291. package/src/plugins/AttributionPlugin/AttributionPlugin.test.ts +210 -0
  292. package/src/plugins/AttributionPlugin/attribution.test.ts +225 -0
  293. package/src/plugins/AttributionPlugin/attribution.ts +355 -0
  294. package/src/plugins/AttributionPlugin/attributionStyles.ts +163 -0
  295. package/src/plugins/AttributionPlugin/index.ts +702 -0
  296. package/src/plugins/index.ts +1 -0
  297. package/src/quality.ts +1 -0
  298. package/src/renderOrder.ts +3 -0
  299. package/src/scene.test.ts +164 -0
  300. package/src/scene.ts +127 -0
  301. package/src/shaders/index.ts +1 -0
  302. package/src/solar.test.ts +81 -0
  303. package/src/solar.ts +101 -0
  304. package/src/source.ts +80 -0
  305. package/src/stats.ts +102 -0
  306. package/src/tasks/computeVertexNormalsAsync.ts +15 -0
  307. package/src/tasks/constructPolygonBatchedFeature.ts +34 -0
  308. package/src/tasks/constructPolylineBatchedFeature.ts +27 -0
  309. package/src/tasks/constructQuantizedMeshTerrainMesh.ts +24 -0
  310. package/src/tasks/constructTerrainMesh.ts +25 -0
  311. package/src/tasks/getImageDataFromBlob.ts +13 -0
  312. package/src/tasks/getImageDataFromImageBitmap.ts +12 -0
  313. package/src/tasks/parseMvtTile.ts +22 -0
  314. package/src/tasks/queueTask.ts +19 -0
  315. package/src/tasks/toCreasedNormalsAsync.ts +18 -0
  316. package/src/tasks/upsampleQuantizedMeshTerrainMesh.ts +44 -0
  317. package/src/tasks/upsampleTerrainMesh.ts +39 -0
  318. package/src/texture.ts +19 -0
  319. package/src/textures.ts +13 -0
  320. package/src/tileTexture/CompositeShader.snapshot.test.ts +59 -0
  321. package/src/tileTexture/CompositeShader.test.ts +168 -0
  322. package/src/tileTexture/CompositeShader.ts +53 -0
  323. package/src/tileTexture/SlotPlanner.test.ts +105 -0
  324. package/src/tileTexture/SlotPlanner.ts +102 -0
  325. package/src/tileTexture/TileTextureCache.test.ts +227 -0
  326. package/src/tileTexture/TileTextureCache.ts +192 -0
  327. package/src/tileTexture/TileTextureCompositor.test.ts +260 -0
  328. package/src/tileTexture/TileTextureCompositor.ts +421 -0
  329. package/src/tileTexture/__snapshots__/CompositeShader.snapshot.test.ts.snap +2649 -0
  330. package/src/tileTexture/index.ts +8 -0
  331. package/src/tileTexture/types.ts +150 -0
  332. package/src/type/index.ts +261 -0
  333. package/src/uniforms.ts +20 -0
  334. package/src/utils/arraysEqual.ts +9 -0
  335. package/src/utils/blendModes.ts +80 -0
  336. package/src/utils/geometry.ts +53 -0
  337. package/src/utils/hillshadeNormalMapGenerator.ts +193 -0
  338. package/src/utils/index.ts +8 -0
  339. package/src/utils/object.test.ts +14 -0
  340. package/src/utils/object.ts +7 -0
  341. package/src/utils/replacer.test.ts +42 -0
  342. package/src/utils/replacer.ts +89 -0
  343. package/src/utils/screen.ts +29 -0
  344. package/src/utils/textureFragmentIndex.test.ts +224 -0
  345. package/src/utils/textureFragmentIndex.ts +97 -0
  346. package/src/utils/worker.ts +3 -0
  347. package/src/vite-env.d.ts +2 -0
  348. package/src/worker/index.ts +13 -0
  349. package/src/worker/tasks/computeVertexNormals.ts +15 -0
  350. package/src/worker/tasks/toCreasedNormals.ts +22 -0
@@ -0,0 +1,529 @@
1
+ import {
2
+ type ExtractProperties,
3
+ type FeatureSetId,
4
+ type LayerId,
5
+ } from "@navaramap/core";
6
+ import type {
7
+ ModelMaterial as NavaraModelMaterial,
8
+ PointMaterial,
9
+ PolygonMaterial,
10
+ PolylineMaterial,
11
+ TextMaterial,
12
+ } from "@navaramap/engine";
13
+ import { BufferGeometry, Mesh, Object3D } from "three";
14
+ import type { NormalBufferAttributes } from "three";
15
+
16
+ import { Color } from "../Color";
17
+ import type { FeatureHandler } from "../event";
18
+ import {
19
+ InstancedMesh,
20
+ isFeatureMesh,
21
+ ModelMesh,
22
+ type ModelMaterial,
23
+ BatchedFeatureMesh,
24
+ type ModelBatchedAttributeName,
25
+ type BatchedAttributeName,
26
+ InstancedSpriteMesh,
27
+ BatchedSdfTextMesh,
28
+ } from "../mesh";
29
+
30
+ type AvailableMaterialProperty = ExtractProperties<
31
+ PointMaterial &
32
+ PolylineMaterial &
33
+ PolygonMaterial &
34
+ NavaraModelMaterial &
35
+ TextMaterial
36
+ >;
37
+
38
+ /**
39
+ * Material properties that can be evaluated and modified per-feature.
40
+ */
41
+ export type EvaluatableMaterialProperty = {
42
+ /** Feature color expression from layer configuration. */
43
+ color: AvailableMaterialProperty["color"];
44
+ /** Feature visibility expression from layer configuration. */
45
+ show: AvailableMaterialProperty["show"];
46
+ /** Extruded height expression from layer configuration (for polygons). */
47
+ extrudedHeight: AvailableMaterialProperty["extrudedHeight"];
48
+ /** Height expression from layer configuration. */
49
+ height: AvailableMaterialProperty["height"];
50
+ /** Text content expression from layer configuration (for text). */
51
+ text: AvailableMaterialProperty["text"];
52
+ /** Line width expression from layer configuration (for polylines). */
53
+ width: AvailableMaterialProperty["width"];
54
+ /** Point/text size expression from layer configuration (for points/text). */
55
+ size: AvailableMaterialProperty["size"];
56
+ /** Opacity expression from layer configuration (for polygons/points/text where supported). */
57
+ opacity: AvailableMaterialProperty["opacity"];
58
+ /** Image URL for billboards; packed into a shared per-mesh texture atlas. */
59
+ image: string;
60
+ };
61
+
62
+ type EvaluatableMaterialPropertyKey = keyof EvaluatableMaterialProperty;
63
+
64
+ type EvaluatedMaterialProperty = {
65
+ color: Color;
66
+ show: boolean;
67
+ extrudedHeight: number;
68
+ height: number;
69
+ text: string;
70
+ width: number;
71
+ size: number;
72
+ opacity: number;
73
+ image: string | null;
74
+ };
75
+
76
+ /**
77
+ * The evaluated values that can be returned from the evaluate callback.
78
+ * All properties are optional - only return the ones you want to modify.
79
+ */
80
+ export type EvaluatedValue = {
81
+ /** The evaluated color for this feature. */
82
+ [K in EvaluatableMaterialPropertyKey]: EvaluatedMaterialProperty[K];
83
+ };
84
+
85
+ /**
86
+ * Information about a feature batch, passed to evaluation callbacks.
87
+ */
88
+ export type FeatureInfo = {
89
+ batchId: number;
90
+ properties: Record<string, unknown> | undefined;
91
+ layerId: LayerId | undefined;
92
+ };
93
+
94
+ /**
95
+ * Callback function type for feature evaluator operations.
96
+ */
97
+ export type FeatureEvaluatorCallback = (
98
+ info: FeatureInfo,
99
+ ) => Partial<EvaluatedValue>;
100
+
101
+ /**
102
+ * Provides access to feature data and allows dynamic styling of features based on their properties.
103
+ * Received through the `featureCreated` and `featureUpdated` events on a Layer.
104
+ *
105
+ * Use this class to:
106
+ * - Read feature properties from the data source
107
+ * - Dynamically style features based on their properties
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Style 3D Tiles buildings by height
112
+ * layer.on("featureUpdated", (evaluator) => {
113
+ * evaluator.evaluate(({ properties }) => {
114
+ * const measuredHeight = properties?.["height"] as number;
115
+ *
116
+ * // Color and visibility based on building height
117
+ * const color = (() => {
118
+ * if (measuredHeight < 30) return new Color().setStyle("#00ff00");
119
+ * if (measuredHeight < 60) return new Color().setStyle("#ffff00");
120
+ * if (measuredHeight < 90) return new Color().setStyle("#ff00ff");
121
+ * return new Color().setStyle("#ff0000");
122
+ * })();
123
+ *
124
+ * return {
125
+ * color,
126
+ * show: measuredHeight >= 30, // Hide small buildings
127
+ * };
128
+ * });
129
+ * });
130
+ *
131
+ * // Style GeoJSON polygons with extrusion based on properties
132
+ * layer.on("featureUpdated", (evaluator) => {
133
+ * evaluator.evaluate(({ properties }) => {
134
+ * const height = (properties?.["height"] as number) ?? 0;
135
+ * const extrudedHeight = (properties?.["extrudedHeight"] as number) ?? 0;
136
+ *
137
+ * return {
138
+ * height,
139
+ * extrudedHeight,
140
+ * };
141
+ * });
142
+ * });
143
+ *
144
+ * // Re-evaluate styles
145
+ * const onChange = () => {
146
+ * layer.forceUpdate(); // Triggers featureUpdated events
147
+ * };
148
+ * ```
149
+ */
150
+ export class FeatureEvaluator {
151
+ private handler: FeatureHandler;
152
+ private layerId: LayerId;
153
+ private featureSetId: FeatureSetId;
154
+ private cachedBatchedProperties?: Map<
155
+ number,
156
+ Record<string, unknown> | undefined
157
+ >;
158
+ private filterCacheKey?: string;
159
+ private cachedFilteredProperties?: Map<
160
+ number,
161
+ Record<string, unknown> | undefined
162
+ >;
163
+ private batchIds: number[] = [];
164
+
165
+ /**
166
+ * The underlying Three.js object representing this feature.
167
+ * Can be used for advanced manipulation, but prefer using `evaluate()` for styling.
168
+ */
169
+ // TODO: Need to support TSL if we export it.
170
+ private obj: Object3D;
171
+
172
+ constructor(
173
+ handler: FeatureHandler,
174
+ layerId: LayerId,
175
+ featureSetId: FeatureSetId,
176
+ obj: Object3D,
177
+ ) {
178
+ this.handler = handler;
179
+ this.layerId = layerId;
180
+ this.featureSetId = featureSetId;
181
+ this.obj = obj;
182
+ }
183
+
184
+ /**
185
+ * Gets the unique identifier of this feature set.
186
+ */
187
+ get id() {
188
+ return this.featureSetId;
189
+ }
190
+
191
+ /**
192
+ * Reads the properties of this feature from the data source.
193
+ * The callback is invoked for each batch within this feature.
194
+ *
195
+ * @param f - Callback function that receives feature info for each batch
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * // Log all properties
200
+ * evaluator.readFeatureProperties(({ batchId, properties }) => {
201
+ * console.log(`Batch ${batchId}:`, properties);
202
+ * });
203
+ *
204
+ * // Access nested JSON attributes (common in MVT/PLATEAU data)
205
+ * evaluator.readFeatureProperties(({ properties }) => {
206
+ * const attributes = JSON.parse((properties?.["attributes"] as string) ?? "{}");
207
+ * const minHeight = attributes["minHeight"];
208
+ * const maxHeight = attributes["maxHeight"];
209
+ * });
210
+ * ```
211
+ */
212
+ readFeatureProperties(f: (info: FeatureInfo, batchIndex: number) => void) {
213
+ if (this.cachedBatchedProperties) {
214
+ for (const [batchIdx, properties] of this.cachedBatchedProperties) {
215
+ f(
216
+ {
217
+ layerId: this.layerId,
218
+ batchId: this.batchIds[batchIdx],
219
+ properties,
220
+ },
221
+ batchIdx,
222
+ );
223
+ }
224
+ } else {
225
+ this.cachedBatchedProperties = new Map();
226
+ this.handler.readAllBatchedProperties(
227
+ this.featureSetId,
228
+ (
229
+ batchIdx: number,
230
+ batchId: number,
231
+ properties: Record<string, unknown> | undefined,
232
+ ) => {
233
+ this.cachedBatchedProperties?.set(batchIdx, properties);
234
+ this.batchIds[batchIdx] = batchId;
235
+ f(
236
+ {
237
+ layerId: this.layerId,
238
+ batchId,
239
+ properties,
240
+ },
241
+ batchIdx,
242
+ );
243
+ },
244
+ );
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Reads only the specified root properties of this feature.
250
+ * This is more efficient than `readFeatureProperties` when only a few properties are needed.
251
+ *
252
+ * @param keys - Array of property key names to read
253
+ * @param f - Callback function that receives feature info for each batch
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * evaluator.readFilteredFeatureProperties(["height", "name"], ({ batchId, properties }) => {
258
+ * const { height, name } = properties;
259
+ * });
260
+ * ```
261
+ */
262
+ readFilteredFeatureProperties(
263
+ keys: string[],
264
+ f: (info: FeatureInfo, batchIndex: number) => void,
265
+ ) {
266
+ const cacheKey = keys.join("|");
267
+ if (this.filterCacheKey === cacheKey && this.cachedFilteredProperties) {
268
+ for (const [batchIndex, filtered] of this.cachedFilteredProperties) {
269
+ f(
270
+ {
271
+ layerId: this.layerId,
272
+ batchId: this.batchIds[batchIndex],
273
+ properties: filtered,
274
+ },
275
+ batchIndex,
276
+ );
277
+ }
278
+ } else {
279
+ this.cachedFilteredProperties = new Map();
280
+ this.filterCacheKey = cacheKey;
281
+
282
+ this.handler.readFilteredBatchedProperties(
283
+ this.featureSetId,
284
+ keys,
285
+ (batchIndex: number, batchId: number, filtered?: unknown[]) => {
286
+ const properties: Record<string, unknown> = {};
287
+ for (let i = 0; i < keys.length; i++) {
288
+ properties[keys[i]] = filtered?.[i];
289
+ }
290
+ this.cachedFilteredProperties?.set(batchIndex, properties);
291
+ this.batchIds[batchIndex] = batchId;
292
+ f({ layerId: this.layerId, batchId, properties }, batchIndex);
293
+ },
294
+ );
295
+ }
296
+ }
297
+
298
+ /**
299
+ * Evaluates and applies dynamic styles to features based on their properties.
300
+ * The callback is invoked for each batch (sub-feature) within this feature.
301
+ *
302
+ * Supported style properties:
303
+ * - `color` - Feature color (use `new Color()`)
304
+ * - `show` - Feature visibility (boolean)
305
+ * - `height` - Feature height in meters
306
+ * - `extrudedHeight` - Extrusion height for polygons in meters
307
+ * - `text` - Label text content (for text/label features)
308
+ * - `width` - Line width in pixels (for polylines)
309
+ * - `size` - Feature size in pixels (for points/text)
310
+ * - `opacity` - Feature opacity 0-1
311
+ * - `image` - Image URL (for billboards); loaded once per distinct URL and
312
+ * packed into the layer's texture atlas. Return `null` to clear a
313
+ * previous per-feature image and revert to the material's default `url`;
314
+ * omit the key to leave it unchanged.
315
+ *
316
+ * Note: Evaluated styles override the layer's default styles.
317
+ *
318
+ * @param f Callback function that receives feature info, returns style values
319
+ * @param options.filters - Root property's keys that get only the matched property values.
320
+ *
321
+ * @example
322
+ * ```typescript
323
+ * // Color MVT features based on a category property
324
+ * evaluator.evaluate(({ properties }) => {
325
+ * const category = properties?.["category"] as string;
326
+ *
327
+ * const color = (() => {
328
+ * if (category === "A") return "#0000ff";
329
+ * if (category === "B") return "#00ff00";
330
+ * return "#ff0000";
331
+ * })();
332
+ *
333
+ * return {
334
+ * color: new Color().setStyle(color),
335
+ * };
336
+ * });
337
+ *
338
+ * // Filter and style text labels
339
+ * evaluator.evaluate(({ properties }) => {
340
+ * const text = properties?.["name"] as string;
341
+ *
342
+ * return {
343
+ * text,
344
+ * show: !!text,
345
+ * };
346
+ * });
347
+ * ```
348
+ */
349
+ evaluate(
350
+ f: FeatureEvaluatorCallback,
351
+ options?: {
352
+ filters?: string[];
353
+ },
354
+ ) {
355
+ const evaluate = (info: FeatureInfo, batchIndex: number) => {
356
+ const evaluated = f(info);
357
+ this.applyEvaluatedValues(batchIndex, info.batchId, evaluated);
358
+ };
359
+
360
+ if (options?.filters) {
361
+ this.readFilteredFeatureProperties(options.filters, evaluate);
362
+ } else {
363
+ this.readFeatureProperties(evaluate);
364
+ }
365
+ }
366
+
367
+ private applyEvaluatedValues(
368
+ batchIndex: number,
369
+ batchId: number,
370
+ evaluated: Partial<EvaluatedValue>,
371
+ ) {
372
+ const obj = this.obj;
373
+
374
+ if (obj instanceof InstancedSpriteMesh) {
375
+ if (evaluated.color != null) {
376
+ obj.setFeatureColorByBatchId(batchId, evaluated.color.raw);
377
+ }
378
+ if (evaluated.show != null) {
379
+ obj.setFeatureShowByBatchId(batchId, evaluated.show);
380
+ }
381
+ if (evaluated.height != null) {
382
+ obj.setFeatureHeightByBatchId(batchId, evaluated.height);
383
+ }
384
+ if (evaluated.size != null) {
385
+ obj.setFeatureSizeByBatchId(batchId, evaluated.size);
386
+ }
387
+ if (evaluated.opacity != null) {
388
+ obj.setFeatureOpacityByBatchId(batchId, evaluated.opacity);
389
+ }
390
+ if ("image" in evaluated) {
391
+ // Async by nature (the image may need fetching); the atlas dedupes
392
+ // loads by URL so evaluating many features costs one fetch per image.
393
+ // A nullish url clears the override back to the material default.
394
+ void obj.setFeatureImageByBatchId(batchId, evaluated.image);
395
+ }
396
+ return;
397
+ }
398
+
399
+ if (obj instanceof InstancedMesh) {
400
+ if (evaluated.color != null) {
401
+ obj.setFeatureColorByBatchIndex(batchIndex, evaluated.color.raw);
402
+ }
403
+ if (evaluated.show != null) {
404
+ obj.setFeatureShowByBatchIndex(batchIndex, evaluated.show);
405
+ }
406
+ if (evaluated.height != null) {
407
+ obj.setFeatureHeightByBatchIndex(batchIndex, evaluated.height);
408
+ }
409
+ if (evaluated.text != null && obj instanceof BatchedSdfTextMesh) {
410
+ obj.setTextByBatchIndex(batchIndex, evaluated.text);
411
+ }
412
+ if (evaluated.size != null && obj instanceof BatchedSdfTextMesh) {
413
+ obj.setFeatureSizeByBatchIndex(batchIndex, evaluated.size);
414
+ }
415
+ if (evaluated.opacity != null && obj instanceof BatchedSdfTextMesh) {
416
+ obj.setFeatureOpacityByBatchIndex(batchIndex, evaluated.opacity);
417
+ }
418
+ return;
419
+ }
420
+
421
+ if (obj instanceof BatchedFeatureMesh) {
422
+ obj._initBatchDataTexture();
423
+ this.apply(obj, undefined, batchIndex, evaluated);
424
+ return;
425
+ }
426
+
427
+ if (obj instanceof ModelMesh) {
428
+ obj.traverse((m) => {
429
+ if (!(m instanceof Mesh)) return;
430
+ obj._initBatchDataTexture(m);
431
+ this.apply(m, obj, batchIndex, evaluated);
432
+ });
433
+ }
434
+ }
435
+
436
+ private apply(
437
+ m: Mesh | BatchedFeatureMesh,
438
+ parent: ModelMesh | undefined,
439
+ batchIndex: number,
440
+ evaluated: Partial<EvaluatedValue>,
441
+ ) {
442
+ const batchIdAttr =
443
+ "geometry" in m ? m.geometry.getAttribute("_batchid") : undefined;
444
+
445
+ // Non-batched feature mesh path (e.g. GeoJSON polyline/polygon)
446
+ const featureMesh = (() => {
447
+ if (batchIdAttr) return;
448
+ if (parent) return isFeatureMesh(parent) ? parent : undefined;
449
+ return isFeatureMesh(m) ? m : undefined;
450
+ })();
451
+
452
+ if (featureMesh) {
453
+ if (evaluated.color != null) {
454
+ featureMesh._setFeatureColor(
455
+ evaluated.color.raw,
456
+ m.material as ModelMaterial,
457
+ );
458
+ }
459
+ if (evaluated.show != null) {
460
+ featureMesh._setFeatureShow(evaluated.show);
461
+ }
462
+ if (evaluated.extrudedHeight != null) {
463
+ featureMesh._setFeatureExtrudedHeight(evaluated.extrudedHeight);
464
+ }
465
+ if (evaluated.height != null) {
466
+ featureMesh._setFeatureHeight(evaluated.height);
467
+ }
468
+ if (evaluated.width != null) {
469
+ featureMesh._setFeatureWidth(evaluated.width);
470
+ }
471
+ if (evaluated.opacity != null) {
472
+ featureMesh._setFeatureOpacity(evaluated.opacity);
473
+ }
474
+ return;
475
+ }
476
+
477
+ // Batched mesh path
478
+ if (!batchIdAttr) return;
479
+
480
+ const mesh =
481
+ parent instanceof ModelMesh
482
+ ? parent
483
+ : m instanceof BatchedFeatureMesh
484
+ ? m
485
+ : undefined;
486
+ if (!mesh) return;
487
+
488
+ const updateBatchAttribute = (
489
+ attribute: ModelBatchedAttributeName | BatchedAttributeName,
490
+ value: number | number[] | boolean,
491
+ ) => {
492
+ if (mesh instanceof ModelMesh) {
493
+ mesh._updateBatchAttribute(
494
+ m as Mesh<BufferGeometry<NormalBufferAttributes>, ModelMaterial>,
495
+ batchIndex,
496
+ attribute as ModelBatchedAttributeName,
497
+ value,
498
+ );
499
+ } else {
500
+ mesh._updateBatchAttribute(
501
+ batchIndex,
502
+ attribute as BatchedAttributeName,
503
+ value,
504
+ );
505
+ }
506
+ };
507
+
508
+ if (evaluated.color != null) {
509
+ updateBatchAttribute("color", evaluated.color.toArray());
510
+ }
511
+ if (evaluated.show != null) {
512
+ updateBatchAttribute("show", evaluated.show);
513
+ }
514
+ if (evaluated.height != null) {
515
+ updateBatchAttribute("height", evaluated.height);
516
+ }
517
+ if (evaluated.extrudedHeight != null) {
518
+ updateBatchAttribute("extrudedHeight", evaluated.extrudedHeight);
519
+ }
520
+ if (evaluated.width != null) {
521
+ updateBatchAttribute("lineWidth", evaluated.width);
522
+ }
523
+ if (evaluated.opacity != null) {
524
+ updateBatchAttribute("opacity", evaluated.opacity);
525
+ }
526
+
527
+ // size is handled by InstancedSpriteMesh / BatchedSdfTextMesh paths above
528
+ }
529
+ }
@@ -0,0 +1 @@
1
+ export * from "./FeatureEvaluator";