@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,437 @@
1
+ import { Color, DataTexture, FloatType, Material, RGBAFormat } from "three";
2
+ import invariant from "tiny-invariant";
3
+
4
+ export const BATCH_TEXTURE_ROW = [
5
+ "COLOR_SHOW", // R=colorR, G=colorG, B=colorB, A=packed(show[1bit], opacity[7bit])
6
+ "HEIGHT", // R,G,B,A=height as RGBA
7
+ "EXTRUDED_HEIGHT", // R,G,B,A=extrudedHeight as RGBA
8
+ "LINE_WIDTH", // R,G,B,A=lineWidth as RGBA
9
+ "SIZE", // R,G,B,A=size as RGBA
10
+ ] as const;
11
+
12
+ export type BatchTextureRowKey = (typeof BATCH_TEXTURE_ROW)[number];
13
+
14
+ export type BatchTextureConfig = {
15
+ rows: BatchTextureRowKey[];
16
+ batchLength: number;
17
+ };
18
+
19
+ export const BATCHED_ATTRIBUTE_NAMES = [
20
+ "color", // R=colorR, G=colorG, B=colorB
21
+ "show", // Packed into alpha channel of color texel (bit 7)
22
+ "height", // R,G,B,A=Encoded height as RGBA
23
+ "extrudedHeight", // R,G,B,A=Encoded extruded height as RGBA
24
+ "lineWidth", // R,G,B,A=Encoded lineWidth as RGBA
25
+ "size", // R,G,B,A=Encoded size as RGBA
26
+ "opacity", // Packed into alpha channel of color texel (bits 0-6)
27
+ ] as const;
28
+
29
+ export type BatchedAttributeName = (typeof BATCHED_ATTRIBUTE_NAMES)[number];
30
+
31
+ export function encodeFloatToRGBA(
32
+ value: number,
33
+ ): [number, number, number, number] {
34
+ // Encode a float value to RGBA.
35
+ const floatView = new Float32Array(1);
36
+ floatView[0] = value;
37
+ const bytes = new Uint8Array(floatView.buffer);
38
+
39
+ // Normalize 0-255 value to 0-1 value.
40
+ return [bytes[0] / 255, bytes[1] / 255, bytes[2] / 255, bytes[3] / 255];
41
+ }
42
+
43
+ /**
44
+ * Pack show (1 bit) and opacity (7 bits) into a single byte.
45
+ *
46
+ * Bit layout:
47
+ * - Bit 7: show (0 = hidden, 1 = visible)
48
+ * - Bits 0-6: opacity (0-127, giving 128 precision levels)
49
+ *
50
+ * @param show - 0 (hidden) or 1 (visible)
51
+ * @param opacity - opacity value 0.0-1.0
52
+ * @returns normalized value 0.0-1.0 for texture storage
53
+ */
54
+ export function packShowOpacity(show: number, opacity: number): number {
55
+ const showBit = show > 0.5 ? 1 : 0;
56
+ const clampedOpacity = Math.max(0, Math.min(1, opacity));
57
+ const opacityBits = Math.round(clampedOpacity * 127) & 0x7f;
58
+ const packed = (showBit << 7) | opacityBits;
59
+ return packed / 255; // Normalize to 0-1 for texture
60
+ }
61
+
62
+ /**
63
+ * Unpack show and opacity from a packed byte value.
64
+ *
65
+ * @param packedNormalized - normalized packed value 0.0-1.0 from texture
66
+ * @returns { show: 0 or 1, opacity: 0.0-1.0 }
67
+ */
68
+ export function unpackShowOpacity(packedNormalized: number): {
69
+ show: number;
70
+ opacity: number;
71
+ } {
72
+ const packed = Math.max(0, Math.min(255, Math.round(packedNormalized * 255)));
73
+ const showBit = (packed >> 7) & 1;
74
+ const opacityBits = packed & 0x7f;
75
+ return {
76
+ show: showBit,
77
+ opacity: opacityBits / 127,
78
+ };
79
+ }
80
+
81
+ // Maximum batch texture width to stay within WebGL texture size limits (max 16384).
82
+ // Using 4096 as a safe default that balances memory layout with broad GPU support.
83
+ export const MAX_BATCH_TEXTURE_WIDTH = 4096;
84
+
85
+ /**
86
+ * Set batched texture rows to the material.
87
+ */
88
+ export function initBatchedMaterial(
89
+ material: Material,
90
+ config: BatchTextureConfig,
91
+ ): void {
92
+ material.userData.defines ??= {};
93
+
94
+ let idx = 0;
95
+ for (const row of config.rows) {
96
+ const defineKey = `BATCHED_TEXTURE_ROW_${row}`;
97
+ material.userData.defines[defineKey] = idx.toFixed(1);
98
+ idx++;
99
+ }
100
+
101
+ material.userData.defines.BATCHED_TEXTURE_ROW_COUNT =
102
+ config.rows.length.toFixed(1);
103
+
104
+ material.needsUpdate = true;
105
+ }
106
+
107
+ /**
108
+ * Allocate the batch data texture for a material.
109
+ *
110
+ * The texture size is fixed at initialization based on `config.batchLength` and
111
+ * is never resized afterwards. Dynamically increasing the batch count is not
112
+ * supported — callers must know the total number of batches up front.
113
+ */
114
+ export function initBatchDataTexture(
115
+ material: Material,
116
+ config: BatchTextureConfig,
117
+ ): void {
118
+ if (material.userData.batchDataTexture) return;
119
+
120
+ const rowCount = config.rows.length;
121
+ // Use a 2D texture layout: cap width to avoid exceeding WebGL max texture dimension.
122
+ // Batch IDs are mapped to 2D coordinates: col = batchId % texWidth, row = floor(batchId / texWidth).
123
+ const textureWidth = Math.min(config.batchLength, MAX_BATCH_TEXTURE_WIDTH);
124
+ const batchRows = Math.ceil(config.batchLength / textureWidth);
125
+ const textureHeight = batchRows * rowCount;
126
+ const data = new Float32Array(textureWidth * 4 * textureHeight);
127
+
128
+ // Initialize COLOR_SHOW alpha channel with packed show=material.visible, opacity=1 for all batch IDs
129
+ // (default is fully opaque, and visible/hidden based on material.visible)
130
+ const colorShowRowIndex = config.rows.indexOf("COLOR_SHOW");
131
+ if (colorShowRowIndex >= 0) {
132
+ const defaultPacked = packShowOpacity(material.visible ? 1 : 0, 1);
133
+ for (let batchId = 0; batchId < config.batchLength; batchId++) {
134
+ const baseIndex = batchBaseIndex(
135
+ textureWidth,
136
+ rowCount,
137
+ batchId,
138
+ colorShowRowIndex,
139
+ );
140
+ // R, G, B remain 0 (will be set when color is first written)
141
+ data[baseIndex + 3] = defaultPacked; // A = packed(show=material.visible, opacity=1)
142
+ }
143
+ }
144
+
145
+ // Initialize LINE_WIDTH row to -1.0 for all batch IDs (sentinel for "use default")
146
+ // Negative value indicates shader should fall back to minMaxHeightAndWidth.z
147
+ const lineWidthRowIndex = config.rows.indexOf("LINE_WIDTH");
148
+ if (lineWidthRowIndex >= 0) {
149
+ const encodedLineWidth = encodeFloatToRGBA(-1.0);
150
+ for (let batchId = 0; batchId < config.batchLength; batchId++) {
151
+ const baseIndex = batchBaseIndex(
152
+ textureWidth,
153
+ rowCount,
154
+ batchId,
155
+ lineWidthRowIndex,
156
+ );
157
+ data[baseIndex] = encodedLineWidth[0]; // R
158
+ data[baseIndex + 1] = encodedLineWidth[1]; // G
159
+ data[baseIndex + 2] = encodedLineWidth[2]; // B
160
+ data[baseIndex + 3] = encodedLineWidth[3]; // A
161
+ }
162
+ }
163
+
164
+ const texture = new DataTexture(
165
+ data,
166
+ textureWidth,
167
+ textureHeight,
168
+ RGBAFormat,
169
+ FloatType,
170
+ );
171
+ texture.needsUpdate = true;
172
+
173
+ material.userData.batchDataTexture = { value: texture };
174
+ material.userData.batchTextureConfig = config;
175
+
176
+ material.userData.defines ??= {};
177
+ material.userData.defines.USE_BATCH_TEXTURE = true;
178
+ material.needsUpdate = true;
179
+ }
180
+
181
+ export function getRowIndex(
182
+ material: Material,
183
+ row: BatchTextureRowKey,
184
+ ): number {
185
+ const config = material.userData.batchTextureConfig as
186
+ | BatchTextureConfig
187
+ | undefined;
188
+ invariant(config);
189
+
190
+ const rowIndex = config.rows.indexOf(row);
191
+ return rowIndex;
192
+ }
193
+
194
+ export function getBatchDataTexture(
195
+ material: Material,
196
+ ): DataTexture | undefined {
197
+ return material.userData.batchDataTexture?.value;
198
+ }
199
+
200
+ export type DefaultBatchAttributeValues = {
201
+ color: Color;
202
+ };
203
+
204
+ /**
205
+ * Compute the flat float-array index for a given batchId and attribute row
206
+ * in the 2D texture layout.
207
+ *
208
+ * Layout: batch IDs are arranged in a grid of width `texWidth`.
209
+ * Each "batch row" (ceil(batchLength / texWidth) groups) occupies `rowCount`
210
+ * physical texture rows (one per attribute row).
211
+ *
212
+ * Physical row = floor(batchId / texWidth) * rowCount + rowIndex
213
+ * Physical col = batchId % texWidth
214
+ * Flat index = (physicalRow * texWidth + physicalCol) * 4
215
+ */
216
+ export function batchBaseIndex(
217
+ texWidth: number,
218
+ rowCount: number,
219
+ batchId: number,
220
+ rowIndex: number,
221
+ ): number {
222
+ const col = batchId % texWidth;
223
+ const batchRow = Math.floor(batchId / texWidth);
224
+ const physicalRow = batchRow * rowCount + rowIndex;
225
+ return (physicalRow * texWidth + col) * 4;
226
+ }
227
+
228
+ export function updateBatchAttribute(
229
+ material: Material,
230
+ batchId: number,
231
+ attribute: BatchedAttributeName,
232
+ value: number | number[] | boolean,
233
+ defaultValues: DefaultBatchAttributeValues,
234
+ ): void {
235
+ const texture = getBatchDataTexture(material);
236
+ if (!texture) return;
237
+
238
+ const data = texture.image.data as Float32Array;
239
+ const texWidth = texture.image.width;
240
+ const config = material.userData.batchTextureConfig as
241
+ | BatchTextureConfig
242
+ | undefined;
243
+ const rowCount = config?.rows.length ?? BATCH_TEXTURE_ROW.length;
244
+
245
+ switch (attribute) {
246
+ case "color": {
247
+ if (!(value instanceof Array)) return;
248
+ if (material.userData.defines) {
249
+ material.vertexColors = true;
250
+ material.userData.defines.USE_BATCH_COLOR_SHOW = true;
251
+ material.needsUpdate = true;
252
+
253
+ // When enabling batchTexture color, set material.color to white
254
+ // so that it acts as a multiplier identity (white * any color = that color)
255
+ if ("color" in material) {
256
+ (material.color as Color).setHex(0xffffff);
257
+ }
258
+ if ("uniforms" in material && material.uniforms) {
259
+ const uniforms = material.uniforms as Record<string, any>;
260
+ if (uniforms.color?.value) {
261
+ uniforms.color.value.set(0xffffff);
262
+ }
263
+ }
264
+ }
265
+
266
+ material.userData._batchColorTouched = true;
267
+
268
+ const rowIndex = getRowIndex(material, "COLOR_SHOW");
269
+
270
+ const baseIndex = batchBaseIndex(texWidth, rowCount, batchId, rowIndex);
271
+ data[baseIndex] = value[0]; // R
272
+ data[baseIndex + 1] = value[1]; // G
273
+ data[baseIndex + 2] = value[2]; // B
274
+ // Only write default alpha if neither show nor opacity has been touched
275
+ if (
276
+ !material.userData._batchShowTouched &&
277
+ !material.userData._batchOpacityTouched
278
+ ) {
279
+ const defaultShow = material.visible ? 1 : 0;
280
+ data[baseIndex + 3] = packShowOpacity(defaultShow, 1.0);
281
+ }
282
+ break;
283
+ }
284
+ case "show": {
285
+ if (typeof value !== "boolean") return;
286
+
287
+ const rowIndex = getRowIndex(material, "COLOR_SHOW");
288
+ if (rowIndex < 0) return;
289
+
290
+ if (material.userData.defines) {
291
+ material.vertexColors = true;
292
+ material.userData.defines.USE_BATCH_COLOR_SHOW = true;
293
+ material.needsUpdate = true;
294
+ }
295
+
296
+ material.userData._batchShowTouched = true;
297
+
298
+ const baseIndex = batchBaseIndex(texWidth, rowCount, batchId, rowIndex);
299
+ if (!material.userData._batchColorTouched) {
300
+ const color = defaultValues.color;
301
+ data[baseIndex] = color.r; // R
302
+ data[baseIndex + 1] = color.g; // G
303
+ data[baseIndex + 2] = color.b; // B
304
+ }
305
+
306
+ // Read current packed value and extract opacity
307
+ const currentPacked = data[baseIndex + 3];
308
+ const { opacity } = unpackShowOpacity(currentPacked);
309
+
310
+ // Update show bit, preserve opacity
311
+ const newShow = value ? 1 : 0;
312
+ data[baseIndex + 3] = packShowOpacity(newShow, opacity);
313
+ break;
314
+ }
315
+ case "height": {
316
+ if (typeof value !== "number") return;
317
+
318
+ const rowIndex = getRowIndex(material, "HEIGHT");
319
+ if (rowIndex < 0) return;
320
+
321
+ if (material.userData.defines) {
322
+ material.userData.defines.USE_BATCH_HEIGHT = true;
323
+ material.needsUpdate = true;
324
+ }
325
+
326
+ // Encode the height to RGBA
327
+ const sanitizedValue = Number.isFinite(value) ? value : 0.0;
328
+ const encodedHeight = encodeFloatToRGBA(sanitizedValue);
329
+
330
+ // Store as RGBA
331
+ const baseIndex = batchBaseIndex(texWidth, rowCount, batchId, rowIndex);
332
+ data[baseIndex] = encodedHeight[0]; // R
333
+ data[baseIndex + 1] = encodedHeight[1]; // G
334
+ data[baseIndex + 2] = encodedHeight[2]; // B
335
+ data[baseIndex + 3] = encodedHeight[3]; // A
336
+ break;
337
+ }
338
+ case "extrudedHeight": {
339
+ if (typeof value !== "number") return;
340
+
341
+ const rowIndex = getRowIndex(material, "EXTRUDED_HEIGHT");
342
+ if (rowIndex < 0) return;
343
+
344
+ if (material.userData.defines) {
345
+ material.userData.defines.USE_BATCH_EXTRUDED_HEIGHT = true;
346
+ material.needsUpdate = true;
347
+ }
348
+
349
+ const sanitizedValue = Number.isFinite(value) ? value : 0.0;
350
+ const encodedHeight = encodeFloatToRGBA(sanitizedValue);
351
+
352
+ const baseIndex = batchBaseIndex(texWidth, rowCount, batchId, rowIndex);
353
+ data[baseIndex] = encodedHeight[0]; // R
354
+ data[baseIndex + 1] = encodedHeight[1]; // G
355
+ data[baseIndex + 2] = encodedHeight[2]; // B
356
+ data[baseIndex + 3] = encodedHeight[3]; // A
357
+ break;
358
+ }
359
+ case "lineWidth": {
360
+ if (typeof value !== "number") return;
361
+
362
+ const rowIndex = getRowIndex(material, "LINE_WIDTH");
363
+ if (rowIndex < 0) return;
364
+
365
+ if (material.userData.defines) {
366
+ material.userData.defines.USE_BATCH_LINE_WIDTH = true;
367
+ material.needsUpdate = true;
368
+ }
369
+
370
+ const sanitizedValue = Number.isFinite(value) ? value : -1.0;
371
+ const encodedLineWidth = encodeFloatToRGBA(sanitizedValue);
372
+
373
+ const baseIndex = batchBaseIndex(texWidth, rowCount, batchId, rowIndex);
374
+ data[baseIndex] = encodedLineWidth[0]; // R
375
+ data[baseIndex + 1] = encodedLineWidth[1]; // G
376
+ data[baseIndex + 2] = encodedLineWidth[2]; // B
377
+ data[baseIndex + 3] = encodedLineWidth[3]; // A
378
+ break;
379
+ }
380
+ case "size": {
381
+ if (typeof value !== "number") return;
382
+
383
+ const rowIndex = getRowIndex(material, "SIZE");
384
+ if (rowIndex < 0) return;
385
+
386
+ if (material.userData.defines) {
387
+ material.userData.defines.USE_BATCH_SIZE = true;
388
+ material.needsUpdate = true;
389
+ }
390
+
391
+ const sanitizedValue = Number.isFinite(value) ? value : 1.0;
392
+ const encodedSize = encodeFloatToRGBA(sanitizedValue);
393
+
394
+ const baseIndex = batchBaseIndex(texWidth, rowCount, batchId, rowIndex);
395
+ data[baseIndex] = encodedSize[0]; // R
396
+ data[baseIndex + 1] = encodedSize[1]; // G
397
+ data[baseIndex + 2] = encodedSize[2]; // B
398
+ data[baseIndex + 3] = encodedSize[3]; // A
399
+ break;
400
+ }
401
+ case "opacity": {
402
+ if (typeof value !== "number") return;
403
+ // Opacity is now bundled with show in COLOR_SHOW's alpha channel
404
+ const rowIndex = getRowIndex(material, "COLOR_SHOW");
405
+ if (rowIndex < 0) return;
406
+
407
+ if (material.userData.defines) {
408
+ material.vertexColors = true;
409
+ material.userData.defines.USE_BATCH_COLOR_SHOW = true;
410
+ material.needsUpdate = true;
411
+ }
412
+
413
+ material.userData._batchOpacityTouched = true;
414
+
415
+ const baseIndex = batchBaseIndex(texWidth, rowCount, batchId, rowIndex);
416
+ if (!material.userData._batchColorTouched) {
417
+ const color = defaultValues.color;
418
+ data[baseIndex] = color.r; // R
419
+ data[baseIndex + 1] = color.g; // G
420
+ data[baseIndex + 2] = color.b; // B
421
+ }
422
+
423
+ // Read current packed value and extract show bit
424
+ const currentPacked = data[baseIndex + 3];
425
+ const { show } = unpackShowOpacity(currentPacked);
426
+
427
+ // Update opacity, preserve show bit
428
+ const newOpacity = Number.isFinite(value)
429
+ ? Math.max(0, Math.min(1, value))
430
+ : 1.0;
431
+ data[baseIndex + 3] = packShowOpacity(show, newOpacity);
432
+ break;
433
+ }
434
+ }
435
+
436
+ texture.needsUpdate = true;
437
+ }
@@ -0,0 +1,186 @@
1
+ import { Unimplemented } from "@navaramap/core";
2
+ import {
3
+ BufferAttribute,
4
+ BufferGeometry,
5
+ Color,
6
+ Material,
7
+ Mesh,
8
+ Object3D,
9
+ type Vector2,
10
+ type NormalBufferAttributes,
11
+ } from "three";
12
+ import invariant from "tiny-invariant";
13
+
14
+ import type { CustomObject3DEventMap } from "../object3DEvent";
15
+
16
+ import {
17
+ BATCHED_ATTRIBUTE_NAMES,
18
+ getBatchDataTexture,
19
+ initBatchDataTexture,
20
+ initBatchedMaterial,
21
+ updateBatchAttribute,
22
+ type BatchedAttributeName,
23
+ type BatchTextureConfig,
24
+ type BatchTextureRowKey,
25
+ type DefaultBatchAttributeValues,
26
+ } from "./batchTexture";
27
+ import type { FeatureMesh } from "./featureMesh";
28
+ import { PickableMesh } from "./pickableMesh";
29
+
30
+ export type BatchedFeatureAttributes<
31
+ Attr extends NormalBufferAttributes = NormalBufferAttributes,
32
+ > = {
33
+ _batchid?: BufferAttribute;
34
+ } & Attr;
35
+
36
+ /**
37
+ * Batch texture rows per mesh type. A mesh's rows must only contain attributes
38
+ * its shaders declare receiver variables for: `updateBatchAttribute` turns a
39
+ * `USE_BATCH_*` define on whenever the row exists, and the shared
40
+ * `batch_texture_vertex` chunk then assigns to the receiver — an undeclared one
41
+ * (e.g. `addExtrudedHeight` in the polyline shaders) breaks shader compilation.
42
+ */
43
+ export const POLYGON_BATCH_TEXTURE_ROWS: BatchTextureRowKey[] = [
44
+ "COLOR_SHOW",
45
+ "HEIGHT",
46
+ "EXTRUDED_HEIGHT",
47
+ ];
48
+
49
+ export const POLYLINE_BATCH_TEXTURE_ROWS: BatchTextureRowKey[] = [
50
+ "COLOR_SHOW",
51
+ "HEIGHT",
52
+ "LINE_WIDTH",
53
+ ];
54
+
55
+ export class BatchedFeatureMesh<
56
+ Buf extends BufferGeometry<BatchedFeatureAttributes> =
57
+ BufferGeometry<BatchedFeatureAttributes>,
58
+ M extends Material = Material,
59
+ E extends CustomObject3DEventMap = CustomObject3DEventMap,
60
+ >
61
+ extends Mesh<Buf, M, E>
62
+ implements FeatureMesh, PickableMesh
63
+ {
64
+ batchLength?: number;
65
+ static _isBatchedAttributeName(v: string): v is BatchedAttributeName {
66
+ return BATCHED_ATTRIBUTE_NAMES.includes(v as BatchedAttributeName);
67
+ }
68
+
69
+ _setBatchIndex(
70
+ batchIndex: Float32Array | null | undefined,
71
+ size: number | null | undefined,
72
+ ) {
73
+ if (!batchIndex || !size) return;
74
+
75
+ // Align to B3DM attribute: https://github.com/CesiumGS/3d-tiles/blob/492adb06b00870d9ee99b8d97c261a466783034c/specification/TileFormats/Batched3DModel/README.adoc#binary-gltf
76
+ // TODO: However this need to be migrated to v1.1 in the future
77
+ this.geometry.setAttribute(
78
+ "_batchid",
79
+ new BufferAttribute(batchIndex, size),
80
+ );
81
+ }
82
+
83
+ /**
84
+ * Batch texture rows supported by this mesh type's shaders. Attributes
85
+ * without a row are silently ignored by `updateBatchAttribute`.
86
+ */
87
+ _getBatchTextureRows(): BatchTextureRowKey[] {
88
+ throw new Unimplemented();
89
+ }
90
+
91
+ _initBatchedMaterial() {
92
+ initBatchedMaterial(this.material, {
93
+ rows: this._getBatchTextureRows(),
94
+ batchLength: 0,
95
+ });
96
+ }
97
+
98
+ _initBatchDataTexture(): void {
99
+ invariant(this.batchLength != null);
100
+
101
+ const config: BatchTextureConfig = {
102
+ rows: this._getBatchTextureRows(),
103
+ batchLength: this.batchLength,
104
+ };
105
+
106
+ initBatchDataTexture(this.material, config);
107
+ }
108
+
109
+ _getBatchDataTexture() {
110
+ return getBatchDataTexture(this.material);
111
+ }
112
+
113
+ _updateBatchAttribute(
114
+ batchId: number,
115
+ attribute: BatchedAttributeName,
116
+ value: number | number[] | boolean,
117
+ ): void {
118
+ updateBatchAttribute(
119
+ this.material,
120
+ batchId,
121
+ attribute,
122
+ value,
123
+ this._getDefaultBatchAttributeValues(),
124
+ );
125
+
126
+ this.needsUpdate();
127
+ }
128
+
129
+ needsUpdate() {
130
+ this.dispatchEvent({ type: "needsUpdate" } as any); // Events aren't inferred well.
131
+ }
132
+
133
+ _getDefaultBatchAttributeValues(): DefaultBatchAttributeValues {
134
+ throw new Unimplemented();
135
+ }
136
+
137
+ _setFeatureColor(color: Color): void {
138
+ this._updateBatchAttribute(0, "color", color.toArray());
139
+ }
140
+
141
+ _getFeatureColor(): Color {
142
+ throw new Unimplemented();
143
+ }
144
+
145
+ _setFeatureShow(visible: boolean): void {
146
+ this._updateBatchAttribute(0, "show", visible);
147
+ }
148
+
149
+ _setFeatureExtrudedHeight(height: number): void {
150
+ this._updateBatchAttribute(0, "extrudedHeight", height);
151
+ }
152
+
153
+ _setFeatureHeight(height: number): void {
154
+ this._updateBatchAttribute(0, "height", height);
155
+ }
156
+
157
+ _setFeatureWidth(width: number): void {
158
+ this._updateBatchAttribute(0, "lineWidth", width);
159
+ }
160
+
161
+ _setFeatureOpacity(opacity: number): void {
162
+ this._updateBatchAttribute(0, "opacity", opacity);
163
+ }
164
+
165
+ _setFrustumCulled(_culled: boolean): void {
166
+ throw new Unimplemented();
167
+ }
168
+
169
+ onBeforePicking(_pickingCoord?: Vector2) {
170
+ this.material.userData.uPickable.value = 1.0;
171
+ this.needsUpdate();
172
+ }
173
+
174
+ onAfterPicking() {
175
+ this.material.userData.uPickable.value = 0.0;
176
+ this.needsUpdate();
177
+ }
178
+
179
+ getRenderable(): Object3D {
180
+ return this;
181
+ }
182
+
183
+ clone() {
184
+ return new BatchedFeatureMesh(this.geometry, this.material) as this;
185
+ }
186
+ }