@arcgis/core 5.2.0-next.33 → 5.2.0-next.34

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 (210) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{4e803d12486c8de4c901.js → 0087ad36f7d38fc7fe11.js} +18 -18
  3. package/assets/esri/core/workers/chunks/{39c994536ce6c1e5c956.js → 03350a56f840cffe5459.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{2628136bf9f47d238a24.js → 050aba7089318e1c7d53.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{dd5dddf7e422216d3806.js → 0a2f08298a3c932614f2.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{a844c4e031e77db11478.js → 0df978697328b6453c94.js} +1 -1
  7. package/assets/esri/core/workers/chunks/0f8fcbd0650b6a924f75.js +1 -0
  8. package/assets/esri/core/workers/chunks/{83ae56c7fa8d84865605.js → 0f976bfb7db98c2c0e05.js} +1 -1
  9. package/assets/esri/core/workers/chunks/10510f76f8538c2dfb84.js +1 -0
  10. package/assets/esri/core/workers/chunks/{3f63b14b53b5ca716e3a.js → 18c4c437ded8bfbd3305.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{b60f24a6c777301803f4.js → 1958facb000b6c16bfe4.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{1664434dc7a67c8ce453.js → 1ad5fcae6d6a9801cf58.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{390fda094fa8695d98cf.js → 22c447fcc9a28afeb6e3.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{7656900713e55036c3c1.js → 29542a3d7f3fa8d42380.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{1e386475937e02b3f523.js → 2b669473aa2c7cfb63c7.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{c8091e8fd7ca43a4490a.js → 2bb3494659609594c4ca.js} +1 -1
  17. package/assets/esri/core/workers/chunks/2c00f89030c7a4201033.js +2 -0
  18. package/assets/esri/core/workers/chunks/{b75a4753cea6544da8bb.js → 2c61bb25578f73ba49bc.js} +1 -1
  19. package/assets/esri/core/workers/chunks/2d92f0042facb55edcff.js +1 -0
  20. package/assets/esri/core/workers/chunks/2da797ae5af9d2ede42d.js +1 -0
  21. package/assets/esri/core/workers/chunks/{34eb22ee13df24271532.js → 2e495a28494c2351837b.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{a0b78cbeb0e53107d819.js → 367a3031abbeff0c0090.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{aba7a053015a9738d8a0.js → 368db1420b8520beae05.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{7832d94f35b79e27ee51.js → 37dc6a8495f1f44e2d45.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{92458803531fdfe1557a.js → 38a6a7c56c592f336a12.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{c63b315c6b76b4860fc5.js → 39ff5b2a05a90e1cb214.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{0a52373c4ba652e0ee0f.js → 3b914ca36e7e2b00cfe6.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{f6afc597eaf2afa9a4a0.js → 3dd8145ef89f32920177.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{b289c46ce2dc04d32e81.js → 3e8fa2a7a36881234479.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{4ecc345c3732f7fc130f.js → 42b1c526c4c9636a169d.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{9508fa53da5f92a0ab70.js → 4316b78fc36bfd893a90.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{5bf01e0eff8a78b65e9e.js → 4656a4bf430d7eed1465.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{43ef6dee2e1d9ed7885e.js → 472ec242cd3070e6acfe.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{1bbf5f5da5842b93f638.js → 4f08b69f4a33a114c5f7.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{c60b4f2dd5fccdf362a7.js → 514ab968c0d75062e6ab.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{ba1c4a8794ac55942e35.js → 51d7145f748b4865de7f.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{2f40193d1b2e534c5226.js → 570a4725b2a4a19c5148.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{1305690054214a9cf48d.js → 586ca90e46f5cbdfeece.js} +1 -1
  39. package/assets/esri/core/workers/chunks/595401947e74a0a67144.js +1 -0
  40. package/assets/esri/core/workers/chunks/{70cb825bb37f1977d2ab.js → 59c22bab85f9cdbb9948.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{b624796ff4a9d4c406bf.js → 61efc7f5fab1c2b1f764.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{c593539c2cce7a2b9d44.js → 6596b12bb286a0b45a68.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{bb1fad01d9f070e7d795.js → 661f50cb97604453f942.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{51a53011478e0cf96e0b.js → 6c02493a1c1deff49c7e.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{71f09e34d56c9fe5c307.js → 6d72a1bdc2664df62c4c.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{4ea325c829d3b82854b1.js → 7085b4c655a19694da04.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{9f3d37e5f42bf1529673.js → 71b672259bac2befd9c7.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{a536904fe6f3b16fdbdc.js → 757982a73174aa7ab0d1.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{d0321dd4b5b2d863eecd.js → 777b16b76db406c99c69.js} +1 -1
  50. package/assets/esri/core/workers/chunks/7a59d39010ed33b8fabb.js +1 -0
  51. package/assets/esri/core/workers/chunks/{32b5d2537feefe6e94a3.js → 7d65a8ec5e1f871b9321.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{fe42fa2144691b9186fd.js → 828b64624c76156a6416.js} +1 -1
  53. package/assets/esri/core/workers/chunks/857532de88f21e8c3466.js +1 -0
  54. package/assets/esri/core/workers/chunks/85a280ee915010a8da3c.js +1 -0
  55. package/assets/esri/core/workers/chunks/{3d1e5bfd88771d4a0bf6.js → 866950e9ab96aebc6b32.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{8c62e2dabd1f1e13d244.js → 86731e276b31453bc235.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{977e6f589bd266d6067d.js → 87c7092282214f5b78b8.js} +4 -4
  58. package/assets/esri/core/workers/chunks/{25932fa010f9a32475c1.js → 88ec63501fa2f6fdadca.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{af3b060fdfa3b6174340.js → 8aa5bbf9a9b09815725a.js} +1 -1
  60. package/assets/esri/core/workers/chunks/{2353fbc1ff4481dcfb1f.js → 8b68a69ab8fb1679e7b2.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{35b3ff25f5fe24fe15e2.js → 96860b6035e0b06672dd.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{e2f33945d838183a2192.js → 98685bd149dee1d6dc99.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{122892f365f5327d290c.js → 9de9cec5c644bc452294.js} +1 -1
  64. package/assets/esri/core/workers/chunks/a0f7e37d385fc68b138d.js +1 -0
  65. package/assets/esri/core/workers/chunks/{940ebb13618d38c6b459.js → a2a688dd2ed4565e01ff.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{47f21b65065558d583ca.js → a2e754df3215e8b00a8f.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{f59b76fde2cbd17f64b3.js → a3ae7c41832c7a8b0570.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{6dc60afb0c39bbb001a3.js → a3e86830460e52706a4d.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{c030a974a63155f450e9.js → a58b8903ae17acf117d6.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{c4a2ec2e5897300163ac.js → ab3d1c00ef514b61ce0b.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{b324bdb9c74fc3f956db.js → add79af151e3eb560599.js} +1 -1
  72. package/assets/esri/core/workers/chunks/{3b3f91a61e3f29af1fb2.js → ae5363956b4467208e04.js} +1 -1
  73. package/assets/esri/core/workers/chunks/{38b69fba9ae4ccbae6b7.js → afaf6874a645854c3357.js} +1 -1
  74. package/assets/esri/core/workers/chunks/{36913f0f944a9eb82cd3.js → b24b7411a73d1da87c30.js} +1 -1
  75. package/assets/esri/core/workers/chunks/b7d7bfcb089a3f1a38b6.js +1 -0
  76. package/assets/esri/core/workers/chunks/{a3393780655152102c45.js → b97b83159fec34f383af.js} +1 -1
  77. package/assets/esri/core/workers/chunks/{8ade399db21938822a7c.js → bec660ee2e7828f965e2.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{6b56971783bf4c31a563.js → c19fe4f31e4ef84bbcf6.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{5cccb8b06014ccef30f8.js → c228b058dd91bf0e1102.js} +1 -1
  80. package/assets/esri/core/workers/chunks/c2a02c33462bcdabd39d.js +1 -0
  81. package/assets/esri/core/workers/chunks/{cb30e8a66d6dcfebd439.js → cda2bae39135e5519d8c.js} +1 -1
  82. package/assets/esri/core/workers/chunks/{de83c177f8a1234a5b2e.js → cffef41791f0cfa6c26c.js} +1 -1
  83. package/assets/esri/core/workers/chunks/{70c94bcfa20453134037.js → d1928a8c86a8966e5582.js} +1 -1
  84. package/assets/esri/core/workers/chunks/{58e0e50b6c3abaa4798f.js → d26b1a9f47b4b2744c89.js} +1 -1
  85. package/assets/esri/core/workers/chunks/{2baee42e1797a709fe4b.js → d4a96f0402172787823a.js} +1 -1
  86. package/assets/esri/core/workers/chunks/d7e17df1c3675bf3633e.js +1 -0
  87. package/assets/esri/core/workers/chunks/dfae4440afe0ca7c5b25.js +1 -0
  88. package/assets/esri/core/workers/chunks/{bd260798b8de09a1eeb2.js → e3a4695c31d3f9d55213.js} +1 -1
  89. package/assets/esri/core/workers/chunks/{197b9f8483fad2258650.js → e6263e1983e703befe48.js} +1 -1
  90. package/assets/esri/core/workers/chunks/{6991ba1b204668e7d4da.js → e67a9f9298d63026e7f6.js} +1 -1
  91. package/assets/esri/core/workers/chunks/{6f240fe78b299e6c4fcc.js → eeee7421f64a52074ff4.js} +1 -1
  92. package/assets/esri/core/workers/chunks/{1e109a521ca8772fdf04.js → eef7e0bee19c4258ba55.js} +1 -1
  93. package/assets/esri/core/workers/chunks/{49a45083a9a155614c1c.js → ef32e454012f3b0e3f77.js} +1 -1
  94. package/assets/esri/core/workers/chunks/{83ce38342796bd6d73ce.js → f137e544076482e348ad.js} +1 -1
  95. package/assets/esri/core/workers/chunks/{e181d0f5562878b3dc01.js → f72f38e7609756a7f8ea.js} +1 -1
  96. package/assets/esri/core/workers/chunks/{ef5d11581a98fb333ad2.js → f83e3ad67b60744afd6d.js} +1 -1
  97. package/assets/esri/core/workers/chunks/{456b77b8f13933a75b68.js → fe8032905992e6574714.js} +3 -3
  98. package/assets/esri/core/workers/chunks/{2f02880a7f081eb210cd.js → fec9ce6ad634c904ffdf.js} +1 -1
  99. package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
  100. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
  101. package/chunks/GaussianSplatComposition.glsl.js +4 -4
  102. package/chunks/OITAddEmission.glsl.js +6 -0
  103. package/chunks/OITFilterOpaque.glsl.js +4 -0
  104. package/chunks/lerc-wasm.js +1 -1
  105. package/config.js +1 -1
  106. package/core/workers/workerFactory.js +1 -1
  107. package/form/elements/inputs/attachments/AttachmentInput.js +1 -1
  108. package/geometry/support/frustum.js +1 -1
  109. package/geometry/support/plane.js +1 -1
  110. package/kernel.js +1 -1
  111. package/layers/AnnotationFeatureLayer.d.ts +110 -67
  112. package/layers/CSVLayer.d.ts +144 -175
  113. package/layers/CatalogLayer.d.ts +129 -132
  114. package/layers/DimensionFeatureLayer.d.ts +106 -63
  115. package/layers/FeatureLayer.d.ts +77 -150
  116. package/layers/GeoJSONLayer.d.ts +111 -168
  117. package/layers/OrientedImageryLayer.d.ts +125 -79
  118. package/layers/ParquetLayer.d.ts +116 -75
  119. package/layers/SubtypeGroupLayer.d.ts +86 -111
  120. package/layers/WFSLayer.d.ts +157 -127
  121. package/layers/catalog/CatalogFootprintLayer.d.ts +142 -129
  122. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  123. package/layers/graphics/sources/support/QueryTask.js +1 -1
  124. package/layers/mixins/EditBusLayer.js +1 -1
  125. package/layers/pointCloudFilters/PointCloudBitfieldFilter.d.ts +1 -1
  126. package/layers/video/VideoController.js +1 -1
  127. package/package.json +2 -2
  128. package/support/revision.js +1 -1
  129. package/views/2d/engine/webgl/definitions.js +1 -1
  130. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  131. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  132. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  133. package/views/2d/input/MapViewInputManager.js +1 -1
  134. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  135. package/views/2d/layers/support/annodime/virtualFields.js +1 -1
  136. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  137. package/views/3d/input/SceneInputManager.js +1 -1
  138. package/views/3d/interactive/manipulators/RotateManipulator.js +1 -1
  139. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  140. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  141. package/views/3d/terrain/PatchRenderData.js +1 -1
  142. package/views/3d/webgl-engine/core/shaderLibrary/util/emissionFilter.glsl.js +2 -0
  143. package/views/3d/webgl-engine/effects/transparency/OITAddEmission.glsl.js +2 -0
  144. package/views/3d/webgl-engine/effects/transparency/OITAddEmissionTechnique.js +2 -0
  145. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  146. package/views/3d/webgl-engine/effects/transparency/OITFilterOpaque.glsl.js +2 -0
  147. package/views/3d/webgl-engine/effects/transparency/OITFilterOpaqueTechnique.js +2 -0
  148. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  149. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  150. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  151. package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
  152. package/views/3d/webgl-engine/lib/screenPolygonOverlapUtils.js +1 -1
  153. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  154. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  155. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  156. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  157. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  158. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  159. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  160. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  161. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  162. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  163. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  164. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  165. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  166. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  167. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  168. package/views/3d/webgl-engine/materials/intersectWithPolygonOffset.js +1 -1
  169. package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
  170. package/views/3d/webgl-engine/shaders/CheckerBoardTechniqueConfiguration.js +1 -1
  171. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  172. package/views/3d/webgl-engine/shaders/GaussianSplatComposition.glsl.js +1 -1
  173. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  174. package/views/3d/webgl-engine/shaders/ImageMaterialTechniqueConfiguration.js +1 -1
  175. package/views/3d/webgl-engine/shaders/LineMarkerTechniqueConfiguration.js +1 -1
  176. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +3 -3
  177. package/views/input/BrowserEventSource.js +1 -1
  178. package/views/input/handlers/PreventTouchSelection.js +2 -0
  179. package/views/layers/FeatureLikeLayerView.d.ts +9 -64
  180. package/views/layers/GraphicsLayerView.d.ts +1 -1
  181. package/views/layers/types.d.ts +8 -1
  182. package/widgets/BatchAttributeForm/VisibleElements.js +1 -1
  183. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  184. package/widgets/BatchAttributeForm.js +1 -1
  185. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  186. package/widgets/Editor/VisibleElements.d.ts +14 -1
  187. package/widgets/FeatureForm.js +1 -1
  188. package/assets/esri/core/workers/chunks/209460f8aae3f9f8c9b8.js +0 -1
  189. package/assets/esri/core/workers/chunks/4be31fcc5482a2526d2b.js +0 -1
  190. package/assets/esri/core/workers/chunks/58acc18b92533166135d.js +0 -1
  191. package/assets/esri/core/workers/chunks/6162f6735ea4622e54d8.js +0 -1
  192. package/assets/esri/core/workers/chunks/718d2d430c1a5a940b83.js +0 -1
  193. package/assets/esri/core/workers/chunks/a6379a8df8c08b729b9c.js +0 -1
  194. package/assets/esri/core/workers/chunks/b0253fe7b3529bc22270.js +0 -1
  195. package/assets/esri/core/workers/chunks/bd0829eb79efff5b7223.js +0 -1
  196. package/assets/esri/core/workers/chunks/c193b4a175a544c4fcd6.js +0 -1
  197. package/assets/esri/core/workers/chunks/d28169816c768d55aa09.js +0 -1
  198. package/assets/esri/core/workers/chunks/d7c0ab622caf495dbcef.js +0 -1
  199. package/assets/esri/core/workers/chunks/f10a339b16d84b650012.js +0 -2
  200. package/assets/esri/core/workers/chunks/f69d3ff8a69c1985bca3.js +0 -1
  201. package/assets/esri/core/workers/chunks/f847a4846c427f671455.js +0 -1
  202. package/chunks/OITBlendEmission.glsl.js +0 -6
  203. package/chunks/OITDimOpaque.glsl.js +0 -4
  204. package/views/2d/layers/support/annodime/fields.js +0 -2
  205. package/views/3d/webgl-engine/core/shaderLibrary/util/EmissionDimming.glsl.js +0 -2
  206. package/views/3d/webgl-engine/effects/transparency/OITBlendEmission.glsl.js +0 -2
  207. package/views/3d/webgl-engine/effects/transparency/OITBlendEmissionTechnique.js +0 -2
  208. package/views/3d/webgl-engine/effects/transparency/OITDimOpaque.glsl.js +0 -2
  209. package/views/3d/webgl-engine/effects/transparency/OITDimOpaqueTechnique.js +0 -2
  210. /package/assets/esri/core/workers/chunks/{f10a339b16d84b650012.js.LICENSE.txt → 2c00f89030c7a4201033.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import i from"../../../../../core/Error.js";import{deg2rad as n,rad2deg as t}from"../../../../../core/mathUtils.js";import{dist as e,set as s,equals as o,subtract as h,len as r,scale as l}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as m,create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isPolygon as d}from"../../../../../geometry/support/jsonTypeUtils.js";import a from"../../../../../layers/support/FieldsIndex.js";import{createRendererExpression as g}from"../../../../../support/ArcadeExpression.js";import{fromCIMHorizontalAlignment as u,fromCIMVerticalAlignment as c,fromCIMFontDecoration as x}from"../../../../../symbols/cim/utils.js";import P from"../../../arcade/callExpressionWithFeature.js";import{glyphSize as b,magicLabelLineHeight as f}from"../../../engine/webgl/definitions.js";import p from"../../../engine/webgl/Rect.js";import{shapeGlyphs as D}from"../../../engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as y,getLineWidth as L}from"../../graphics/graphicsUtils.js";import{initializeDimensionStyleDefaults as S}from"./dimensionStyleDefaults.js";import{DimensionRealFieldName as M,rectsOverlap as R,queryPointOnLine as T,angleFromXAxis as w,intersectLinesByPointsAndAngles as E,measureMarkerSymbolSize as k,translateRect as N,scaleRect as v,rotatePoint as A,rectsOverlapOnAxis as B}from"./dimensionUtils.js";import{getAttributeValue as F}from"./utils.js";class I{static async create(i,n,t,e){const s=e(i.textSymbol),o=new I(i,s);return await o.initialize(n,t),o}constructor(i,n){if(this._dimensionStyle=i,this._mosaicItems=n,this._textString=null,this._displayExtLines=!0,this._systemLength=0,this._dimensionAngleRad=0,this._dimensionLength=0,this._dimensionDirection=null,this._textSize=null,this._extAngleRad=Math.PI/2,this._compiledExpression=null,this._fieldsIndex=null,this._beginBaselinePoint=null,this._endBaselinePoint=null,this._dimensionLinePoint=null,this._beginDimensionPoint=null,this._endDimensionPoint=null,this._beginMarkerRect=null,this._endMarkerRect=null,this._textRect=null,this._textPoint=null,this._dimensionPolyline=null,this._dimensionExtensionLines=null,this._hasTextPoint=!1,this._doMarkersFit=!0,this._dimensionIsEvaluated=!1,null==i)throw new Error("dimension syle must be defined!");S(i)}async initialize(n,t){if(!this._dimensionStyle)return;const{attributes:e}=n;if("Expression"===(this._dimensionStyle.textOption??"None")){const{expression:e,expressionParserName:s}=this._dimensionStyle;if(e&&s){if(s&&"arcade"!==s.toLocaleLowerCase())throw new i("dimension-layer",`Unsupported expression parser (${s}) for dimension text.`);this._compiledExpression=await g(e,t),this._fieldsIndex=j(n)}}const s=Number(F(M.extAngle,e));this._extAngleRad=isNaN(s)?Math.PI/2:s,this._systemLength=Number(F("__SYSTEM_LENGTH__",e));const{geometry:o}=n;if(o&&!d(o))throw new i("dimension-layer","processed geometry must be a valid 'polygon'.");const h=o?.rings[0];if(!h||h.length<3)throw new i("dimension-layer","processed geometry must have at least 3 points.");this._hasTextPoint=0!==h[3][0]&&0!==h[3][1]&&void 0!==h[3][0]&&void 0!==h[3][1],this._hasTextPoint&&(this._textPoint=h[3]);const r=this._dimensionStyle.textSymbol;e.__DIMENSION_ANGLE__+=r?.angle??0}getTextString(i){return null==this._textString&&(this._textString=this._getDimensionText(i)),this._textString}get textSymbol(){return this._dimensionStyle.textSymbol??null}get beginBaselinePoint(){return this._beginBaselinePoint}get endBaselinePoint(){return this._endBaselinePoint}get beginDimensionPoint(){return this._beginDimensionPoint}get endDimensionPoint(){return this._endDimensionPoint}get textPoint(){return this._textPoint}get dimensionLine(){return this._dimensionPolyline}get extensionLines(){return this._displayExtLines?this._dimensionExtensionLines:null}evaluateWithGeometry(i,n){this._dimensionIsEvaluated||(this._computeDimensionLineInfo(i,n),this._evaluateDefaultPlacement(n),this._updateExtensionLines(n),this._updateTextPoint(n),this._offsetTextPoint(n),this._dimensionIsEvaluated=!0)}_updateTextPoint(i){if(this._hasTextPoint)return;const{textFit:n}=this._dimensionStyle;let t=!0;if(!this._doMarkersFit){if(this._hasTextPoint)return;if("None"===n||!this._beginMarkerRect||!this._endMarkerRect||!this._textRect)return void(t=!0);if((R(this._beginMarkerRect,this._textRect)||R(this._endMarkerRect,this._textRect))&&(t=!1),!t){const i=this._textRect.width/2,t=this._beginMarkerRect.width/2,e=this._endMarkerRect.width/2;"MoveBegin"===n?(this._textPoint=T(this._beginDimensionPoint,this._endDimensionPoint,-(i+t)),this._extendDimensionLineForMovedText("begin",t+this._textRect.width)):"MoveEnd"===n&&(this._textPoint=T(this._endDimensionPoint,this._beginDimensionPoint,-(i+e)),this._extendDimensionLineForMovedText("end",e+this._textRect.width))}}}_extendDimensionLineForMovedText(i,n){if(this._dimensionPolyline?.length)if("begin"===i){const i=T(this._beginDimensionPoint,this._endDimensionPoint,-n);this._dimensionPolyline[0]=[i,this._beginDimensionPoint]}else{const i=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+n);this._dimensionPolyline[1]=[i,this._endDimensionPoint]}}_offsetTextPoint(i){if(this._hasTextPoint)return;const n=this._textPoint;if(!n)return;const t=.5*this._textSize*i,e=-t*this._dimensionDirection[1],s=t*this._dimensionDirection[0];n[0]+=e,n[1]+=s}_updateExtensionLines(i){if(!(this._displayExtLines&&this._beginDimensionPoint&&this._dimensionLinePoint&&this._endDimensionPoint))return;const{extensionLineOvershot:n,extensionLineOffset:t}=this._dimensionStyle;let s=this._dimensionLinePoint,o=this._endDimensionPoint;null==n||isNaN(n)||0===n||(s=T(this._dimensionLinePoint,this._beginBaselinePoint,-n*i),o=T(this._endDimensionPoint,this._endBaselinePoint,-n*i));let h=this._beginBaselinePoint,r=this._endBaselinePoint;if(null!=t&&!isNaN(t)&&0!==t){const i=e(s,this._beginBaselinePoint),n=e(o,this._endBaselinePoint);h=T(s,this._beginBaselinePoint,i-t),r=T(o,this._endBaselinePoint,n-t)}this._dimensionExtensionLines=[[s,h],[o,r]]}_computeDimensionLineInfo(e,a){if(!e||!d(e)||e.rings[0].length<3)throw new i("DimensionLayerView: bad geometry","Dimension cann't be applied to an empty geometry!");const g=e.rings[0],u=m(g[0][0],g[0][1]),c=m(g[1][0],g[1][1]),x=m(g[2][0],g[2][1]);this._beginBaselinePoint=s(_(),u[0],u[1]),this._endBaselinePoint=s(_(),c[0],c[1]),this._dimensionLinePoint=x;let P=this._extAngleRad;if(o(u,x))this._beginDimensionPoint=s(_(),u[0],u[1]),this._endDimensionPoint=s(_(),c[0],c[1]),this._displayExtLines=!1;else{const e=w([c[0]-u[0],c[1]-u[1]]),o=t(P);o>=-1&&o<=1?P+=n(1):o>=179&&o<=181&&(P-=n(1));const h=E(x,e,c,e+P);if(!h)throw new i("DimensionLayerView: bad geometry","Failed to construct dimension extension lines!");this._beginDimensionPoint=s(_(),x[0],x[1]),this._endDimensionPoint=s(_(),h[0],h[1])}this._dimensionDirection=h(_(),this._endDimensionPoint,this._beginDimensionPoint),this._dimensionAngleRad=w(this._dimensionDirection),this._dimensionLength=r(this._dimensionDirection),this._dimensionDirection=l(this._dimensionDirection,this._dimensionDirection,1/this._dimensionLength),this._hasTextPoint||(this._textPoint=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2))}_evaluateDefaultPlacement(i){const{beginMarkerSymbol:n,endMarkerSymbol:t}=this._dimensionStyle,e=k(n,this._dimensionAngleRad),s=k(t,this._dimensionAngleRad+Math.PI),o=this._measureDimensionText(this._textString||"",this._textPoint,i);this._textRect=o;const h=i*((e?.width??0)/2),r=i*((s?.width??0)/2),l=e&&this._beginDimensionPoint?N(v(e,i),this._beginDimensionPoint[0],this._beginDimensionPoint[1]):null,m=s&&this._endDimensionPoint?N(v(s,i),this._endDimensionPoint[0],this._endDimensionPoint[1]):null;if(this._beginMarkerRect=l,this._endMarkerRect=m,this._doMarkersFit=this._checkMarkerFit(l,m,o,i),this._doMarkersFit){const i=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2);this._dimensionPolyline=[[i,this._beginDimensionPoint],[i,this._endDimensionPoint]]}else{const i=T(this._beginDimensionPoint,this._endDimensionPoint,-4*h),n=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+4*r);this._dimensionPolyline=[[i,this._beginDimensionPoint],[n,this._endDimensionPoint]]}}_checkMarkerFit(i,n,t,e){if(!i||!n)return!1;const{markerFit:s,markerOption:o,markerFitTolerance:h}=this._dimensionStyle;if("None"===s)return!0;let r=!0;const l=(i,n)=>R(i,n)||B(i,n,this._dimensionDirection);if("Tolerance"===s)h*e>=this._dimensionLength&&(r=!1);else{if(this._hasTextPoint&&"Both"!==o)return!0;this._hasTextPoint&&"Both"===o?l(i,n)&&(r=!1):(l(i,n)&&(r=!1),r&&t&&(l(t,i)||l(t,n))&&(r=!1))}return r}_measureDimensionText(i,n,t){if(null==this._textString||null==n||null==this._mosaicItems)return null;const e=[];for(const u of i)u.codePointAt(0),e.push(this._mosaicItems.glyphs[u.codePointAt(0)]);const s=this._dimensionStyle.textSymbol;if(!s)return null;const o=u(s.horizontalAlignment),h=c(s.verticalAlignment),r=x(s),l=y(s.height||10);this._textSize=l;const m=!0,_=s.angle||0,d=l/b,a=L(s.lineWidth),g=f*Math.max(.25,Math.min(l||1,4)),P={...this._mosaicItems,glyphs:e.filter(i=>null!=i)},S=D(P,{scale:d,angle:_,xOffset:0,yOffset:0,horizontalAlignment:o,verticalAlignment:h,decoration:r,lineHeight:g,useCIMAngleBehavior:m,maxLineWidth:a,hasBackground:!1}),M=n;if(!M)return null;const R=t,T=[S.bounds.blX,S.bounds.trY],w=[S.bounds.trX,S.bounds.trY],E=[S.bounds.blX,S.bounds.blY],k=[S.bounds.trX,S.bounds.blY];T[0]-=S.bounds.x,T[1]-=S.bounds.y,w[0]-=S.bounds.x,w[1]-=S.bounds.y,E[0]-=S.bounds.x,E[1]-=S.bounds.y,k[0]-=S.bounds.x,k[1]-=S.bounds.y,T[0]*=R,T[1]*=R,w[0]*=R,w[1]*=R,E[0]*=R,E[1]*=R,k[0]*=R,k[1]*=R,this._dimensionAngleRad&&(A(T,this._dimensionAngleRad),A(w,this._dimensionAngleRad),A(E,this._dimensionAngleRad),A(k,this._dimensionAngleRad)),T[0]+=M[0],T[1]+=M[1],w[0]+=M[0],w[1]+=M[1],E[0]+=M[0],E[1]+=M[1],k[0]+=M[0],k[1]+=M[1];const N=Math.min(T[0],w[0],E[0],k[0]),v=Math.min(T[1],w[1],E[1],k[1]),B=Math.max(T[0],w[0],E[0],k[0]),F=Math.max(T[1],w[1],E[1],k[1]);return new p(N,v,1.1*(B-N),1.1*(F-v))}_getDimensionText(i){const{attributes:n}=i;let t=null;const e=1===Number(F(M.useCustomLength,n));t=Number(F(e?M.customLength:M.dimLength,n)),(0===t||isNaN(t)||null==t)&&(t=this._systemLength);let s=this._getDimensionString(t,i);return"number"==typeof s&&(s=s.toString()),n.__COMPUTED_TEXT_STRING__=s,s||""}_getDimensionString(i,n){const{convertUnits:t,displayUnits:e,displayPrecision:s,prefix:o,suffix:h,textOption:r}=this._dimensionStyle;if("None"===r)return null;if("Expression"===r&&this._compiledExpression&&n)return P(this._compiledExpression,n,{},"esriGeometryPolyline",this._fieldsIndex);let l=(i=null==s||isNaN(s)?parseFloat(i.toString()):parseFloat(i.toFixed(s))).toString();return"Suffix"===r&&(o&&(l=`${o} ${l}`),h&&(l=`${l} ${h}`)),l}}function j(i){const{attributes:n}=i,t=Object.keys(M).map(i=>({name:i,alias:i,type:"string"==typeof n[i]?"esriFieldTypeString":"esriFieldTypeDouble"}));return new a(t)}export{I as default};
2
+ import i from"../../../../../core/Error.js";import n from"../../../../../core/Logger.js";import{deg2rad as t,rad2deg as e}from"../../../../../core/mathUtils.js";import{dist as s,set as o,equals as r,subtract as h,len as l,scale as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as _,create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isPolygon as a}from"../../../../../geometry/support/jsonTypeUtils.js";import g from"../../../../../layers/support/FieldsIndex.js";import{createRendererExpression as u}from"../../../../../support/ArcadeExpression.js";import{fromCIMHorizontalAlignment as c,fromCIMVerticalAlignment as x,fromCIMFontDecoration as P}from"../../../../../symbols/cim/utils.js";import p from"../../../arcade/callExpressionWithFeature.js";import{glyphSize as b,magicLabelLineHeight as f}from"../../../engine/webgl/definitions.js";import y from"../../../engine/webgl/Rect.js";import{shapeGlyphs as D}from"../../../engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as L,getLineWidth as S}from"../../graphics/graphicsUtils.js";import{initializeDimensionStyleDefaults as M}from"./dimensionStyleDefaults.js";import{DimensionRealFieldName as T,rectsOverlap as R,queryPointOnLine as w,angleFromXAxis as E,intersectLinesByPointsAndAngles as k,measureMarkerSymbolSize as N,translateRect as v,scaleRect as A,rotatePoint as B,rectsOverlapOnAxis as F}from"./dimensionUtils.js";import{getAttributeValue as I}from"./utils.js";class j{static async create(i,n,t,e){const s=e(i.textSymbol),o=new j(i,s);return await o.initialize(n,t),o}constructor(i,n){if(this._dimensionStyle=i,this._mosaicItems=n,this._textString=null,this._displayExtLines=!0,this._systemLength=0,this._dimensionAngleRad=0,this._dimensionLength=0,this._dimensionDirection=null,this._textSize=null,this._extAngleRad=Math.PI/2,this._compiledExpression=null,this._fieldsIndex=null,this._beginBaselinePoint=null,this._endBaselinePoint=null,this._dimensionLinePoint=null,this._beginDimensionPoint=null,this._endDimensionPoint=null,this._beginMarkerRect=null,this._endMarkerRect=null,this._textRect=null,this._textPoint=null,this._dimensionPolyline=null,this._dimensionExtensionLines=null,this._hasTextPoint=!1,this._doMarkersFit=!0,this._dimensionIsEvaluated=!1,null==i)throw new Error("dimension syle must be defined!");M(i)}async initialize(t,e){if(!this._dimensionStyle)return;const{attributes:s}=t;if("Expression"===(this._dimensionStyle.textOption??"None")){const{expression:s,expressionParserName:o}=this._dimensionStyle;s&&o&&"arcade"===o.toLowerCase()?(this._compiledExpression=await u(s,e),this._fieldsIndex=O(t)):n.getLogger("esri.layers.DimensionFeatureLayer").warn(new i("dimension-layer:unsupported-expression","Only Arcade expressions are supported",{expressionType:o,expression:s}))}const o=Number(I(T.extAngle,s));this._extAngleRad=isNaN(o)?Math.PI/2:o,this._systemLength=Number(I("__SYSTEM_LENGTH__",s));const{geometry:r}=t;if(r&&!a(r))throw new i("dimension-layer","processed geometry must be a valid 'polygon'.");const h=r?.rings[0];if(!h||h.length<3)throw new i("dimension-layer","processed geometry must have at least 3 points.");this._hasTextPoint=0!==h[3][0]&&0!==h[3][1]&&void 0!==h[3][0]&&void 0!==h[3][1],this._hasTextPoint&&(this._textPoint=h[3]);const l=this._dimensionStyle.textSymbol;s.__DIMENSION_ANGLE__+=l?.angle??0}getTextString(i){return null==this._textString&&(this._textString=this._getDimensionText(i)),this._textString}get textSymbol(){return this._dimensionStyle.textSymbol??null}get beginBaselinePoint(){return this._beginBaselinePoint}get endBaselinePoint(){return this._endBaselinePoint}get beginDimensionPoint(){return this._beginDimensionPoint}get endDimensionPoint(){return this._endDimensionPoint}get textPoint(){return this._textPoint}get dimensionLine(){return this._dimensionPolyline}get extensionLines(){return this._displayExtLines?this._dimensionExtensionLines:null}evaluateWithGeometry(i,n){this._dimensionIsEvaluated||(this._computeDimensionLineInfo(i,n),this._evaluateDefaultPlacement(n),this._updateExtensionLines(n),this._updateTextPoint(n),this._offsetTextPoint(n),this._dimensionIsEvaluated=!0)}_updateTextPoint(i){if(this._hasTextPoint)return;const{textFit:n}=this._dimensionStyle;let t=!0;if(!this._doMarkersFit){if(this._hasTextPoint)return;if("None"===n||!this._beginMarkerRect||!this._endMarkerRect||!this._textRect)return void(t=!0);if((R(this._beginMarkerRect,this._textRect)||R(this._endMarkerRect,this._textRect))&&(t=!1),!t){const i=this._textRect.width/2,t=this._beginMarkerRect.width/2,e=this._endMarkerRect.width/2;"MoveBegin"===n?(this._textPoint=w(this._beginDimensionPoint,this._endDimensionPoint,-(i+t)),this._extendDimensionLineForMovedText("begin",t+this._textRect.width)):"MoveEnd"===n&&(this._textPoint=w(this._endDimensionPoint,this._beginDimensionPoint,-(i+e)),this._extendDimensionLineForMovedText("end",e+this._textRect.width))}}}_extendDimensionLineForMovedText(i,n){if(this._dimensionPolyline?.length)if("begin"===i){const i=w(this._beginDimensionPoint,this._endDimensionPoint,-n);this._dimensionPolyline[0]=[i,this._beginDimensionPoint]}else{const i=w(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+n);this._dimensionPolyline[1]=[i,this._endDimensionPoint]}}_offsetTextPoint(i){if(this._hasTextPoint)return;const n=this._textPoint;if(!n)return;const t=.5*this._textSize*i,e=-t*this._dimensionDirection[1],s=t*this._dimensionDirection[0];n[0]+=e,n[1]+=s}_updateExtensionLines(i){if(!(this._displayExtLines&&this._beginDimensionPoint&&this._dimensionLinePoint&&this._endDimensionPoint))return;const{extensionLineOvershot:n,extensionLineOffset:t}=this._dimensionStyle;let e=this._dimensionLinePoint,o=this._endDimensionPoint;null==n||isNaN(n)||0===n||(e=w(this._dimensionLinePoint,this._beginBaselinePoint,-n*i),o=w(this._endDimensionPoint,this._endBaselinePoint,-n*i));let r=this._beginBaselinePoint,h=this._endBaselinePoint;if(null!=t&&!isNaN(t)&&0!==t){const i=s(e,this._beginBaselinePoint),n=s(o,this._endBaselinePoint);r=w(e,this._beginBaselinePoint,i-t),h=w(o,this._endBaselinePoint,n-t)}this._dimensionExtensionLines=[[e,r],[o,h]]}_computeDimensionLineInfo(n,s){if(!n||!a(n)||n.rings[0].length<3)throw new i("DimensionLayerView: bad geometry","Dimension cann't be applied to an empty geometry!");const g=n.rings[0],u=_(g[0][0],g[0][1]),c=_(g[1][0],g[1][1]),x=_(g[2][0],g[2][1]);this._beginBaselinePoint=o(d(),u[0],u[1]),this._endBaselinePoint=o(d(),c[0],c[1]),this._dimensionLinePoint=x;let P=this._extAngleRad;if(r(u,x))this._beginDimensionPoint=o(d(),u[0],u[1]),this._endDimensionPoint=o(d(),c[0],c[1]),this._displayExtLines=!1;else{const n=E([c[0]-u[0],c[1]-u[1]]),s=e(P);s>=-1&&s<=1?P+=t(1):s>=179&&s<=181&&(P-=t(1));const r=k(x,n,c,n+P);if(!r)throw new i("DimensionLayerView: bad geometry","Failed to construct dimension extension lines!");this._beginDimensionPoint=o(d(),x[0],x[1]),this._endDimensionPoint=o(d(),r[0],r[1])}this._dimensionDirection=h(d(),this._endDimensionPoint,this._beginDimensionPoint),this._dimensionAngleRad=E(this._dimensionDirection),this._dimensionLength=l(this._dimensionDirection),this._dimensionDirection=m(this._dimensionDirection,this._dimensionDirection,1/this._dimensionLength),this._hasTextPoint||(this._textPoint=w(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2))}_evaluateDefaultPlacement(i){const{beginMarkerSymbol:n,endMarkerSymbol:t}=this._dimensionStyle,e=N(n,this._dimensionAngleRad),s=N(t,this._dimensionAngleRad+Math.PI),o=this._measureDimensionText(this._textString||"",this._textPoint,i);this._textRect=o;const r=i*((e?.width??0)/2),h=i*((s?.width??0)/2),l=e&&this._beginDimensionPoint?v(A(e,i),this._beginDimensionPoint[0],this._beginDimensionPoint[1]):null,m=s&&this._endDimensionPoint?v(A(s,i),this._endDimensionPoint[0],this._endDimensionPoint[1]):null;if(this._beginMarkerRect=l,this._endMarkerRect=m,this._doMarkersFit=this._checkMarkerFit(l,m,o,i),this._doMarkersFit){const i=w(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2);this._dimensionPolyline=[[i,this._beginDimensionPoint],[i,this._endDimensionPoint]]}else{const i=w(this._beginDimensionPoint,this._endDimensionPoint,-4*r),n=w(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+4*h);this._dimensionPolyline=[[i,this._beginDimensionPoint],[n,this._endDimensionPoint]]}}_checkMarkerFit(i,n,t,e){if(!i||!n)return!1;const{markerFit:s,markerOption:o,markerFitTolerance:r}=this._dimensionStyle;if("None"===s)return!0;let h=!0;const l=(i,n)=>R(i,n)||F(i,n,this._dimensionDirection);if("Tolerance"===s)r*e>=this._dimensionLength&&(h=!1);else{if(this._hasTextPoint&&"Both"!==o)return!0;this._hasTextPoint&&"Both"===o?l(i,n)&&(h=!1):(l(i,n)&&(h=!1),h&&t&&(l(t,i)||l(t,n))&&(h=!1))}return h}_measureDimensionText(i,n,t){if(null==this._textString||null==n||null==this._mosaicItems)return null;const e=[];for(const c of i)c.codePointAt(0),e.push(this._mosaicItems.glyphs[c.codePointAt(0)]);const s=this._dimensionStyle.textSymbol;if(!s)return null;const o=c(s.horizontalAlignment),r=x(s.verticalAlignment),h=P(s),l=L(s.height||10);this._textSize=l;const m=!0,_=s.angle||0,d=l/b,a=S(s.lineWidth),g=f*Math.max(.25,Math.min(l||1,4)),u={...this._mosaicItems,glyphs:e.filter(i=>null!=i)},p=D(u,{scale:d,angle:_,xOffset:0,yOffset:0,horizontalAlignment:o,verticalAlignment:r,decoration:h,lineHeight:g,useCIMAngleBehavior:m,maxLineWidth:a,hasBackground:!1}),M=n;if(!M)return null;const T=t,R=[p.bounds.blX,p.bounds.trY],w=[p.bounds.trX,p.bounds.trY],E=[p.bounds.blX,p.bounds.blY],k=[p.bounds.trX,p.bounds.blY];R[0]-=p.bounds.x,R[1]-=p.bounds.y,w[0]-=p.bounds.x,w[1]-=p.bounds.y,E[0]-=p.bounds.x,E[1]-=p.bounds.y,k[0]-=p.bounds.x,k[1]-=p.bounds.y,R[0]*=T,R[1]*=T,w[0]*=T,w[1]*=T,E[0]*=T,E[1]*=T,k[0]*=T,k[1]*=T,this._dimensionAngleRad&&(B(R,this._dimensionAngleRad),B(w,this._dimensionAngleRad),B(E,this._dimensionAngleRad),B(k,this._dimensionAngleRad)),R[0]+=M[0],R[1]+=M[1],w[0]+=M[0],w[1]+=M[1],E[0]+=M[0],E[1]+=M[1],k[0]+=M[0],k[1]+=M[1];const N=Math.min(R[0],w[0],E[0],k[0]),v=Math.min(R[1],w[1],E[1],k[1]),A=Math.max(R[0],w[0],E[0],k[0]),F=Math.max(R[1],w[1],E[1],k[1]);return new y(N,v,1.1*(A-N),1.1*(F-v))}_getDimensionText(i){const{attributes:n}=i;let t=null;const e=1===Number(I(T.useCustomLength,n));t=Number(I(e?T.customLength:T.dimLength,n)),(0===t||isNaN(t)||null==t)&&(t=this._systemLength);let s=this._getDimensionString(t,i);return"number"==typeof s&&(s=s.toString()),n.__COMPUTED_TEXT_STRING__=s,s||""}_getDimensionString(i,n){const{convertUnits:t,displayUnits:e,displayPrecision:s,prefix:o,suffix:r,textOption:h}=this._dimensionStyle;if("None"===h)return null;if("Expression"===h&&this._compiledExpression&&n)return p(this._compiledExpression,n,{},"esriGeometryPolyline",this._fieldsIndex);let l=(i=null==s||isNaN(s)?parseFloat(i.toString()):parseFloat(i.toFixed(s))).toString();return"Suffix"===h&&(o&&(l=`${o} ${l}`),r&&(l=`${l} ${r}`)),l}}function O(i){const{attributes:n}=i,t=Object.keys(T).map(i=>({name:i,alias:i,type:"string"==typeof n[i]?"esriFieldTypeString":"esriFieldTypeDouble"}));return new g(t)}export{j as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{fixUnsupportedCIM as e}from"../../../../../symbols/cim/supportUtils.js";let t=0;class r{}class s extends r{constructor(e,t){super(),this.kind="feature";const r=`__virtual_fi_${e}`;this.realField={name:r,alias:r,type:t,editable:!1,nullable:!0}}addToFeature(e,t){const r=this.getValue(t);e.attributes[this.realField.name]=r}addToSymbol(e){const r=this.findTargetNode(e.symbol);let{primitiveName:s}=r;s||(t++,s=`primitive_${t}`,r.primitiveName=s);const i={type:"CIMPrimitiveOverride",primitiveName:s,propertyName:this.cimPropertyName,valueExpressionInfo:{type:"CIMExpressionInfo",expression:`return $feature.${this.realField.name};`}};e.primitiveOverrides=e.primitiveOverrides||[],e.primitiveOverrides.push(i)}}class i extends s{constructor(){super("text","esriFieldTypeString"),this.cimPropertyName="TextString"}findTargetNode(e){return e.symbolLayers[0].markerGraphics[0]}getValue(e){return e.graphic?e.graphic.text:e.text}}class n extends s{constructor(){super("color","esriFieldTypeString"),this.cimPropertyName="Color"}findTargetNode(e){return e.symbolLayers[0].markerGraphics[0].symbol.symbol.symbolLayers.find(e=>"CIMSolidFill"===e.type)}getValue(t){const r=t.color||"#000000";if(r.startsWith("#"))return r;if(r.startsWith("rgb"))return r;const s=JSON.parse(r),i=e(s);return`rgba(${i[0]}, ${i[1]}, ${i[2]}, ${i[3]/255})`}}class o extends s{constructor(){super("rotation","esriFieldTypeDouble"),this.cimPropertyName="Rotation"}findTargetNode(e){return e.symbolLayers[0]}getValue(e){return null!=e.textAngle?-e.textAngle:void 0}}class a extends s{constructor(){super("offsetX","esriFieldTypeDouble"),this.cimPropertyName="OffsetX"}findTargetNode(e){return e.symbolLayers[0]}getValue(e){return e.xOffset}}class l extends s{constructor(){super("offsetY","esriFieldTypeDouble"),this.cimPropertyName="OffsetY"}findTargetNode(e){return e.symbolLayers[0]}getValue(e){return e.yOffset}}class u extends r{constructor(){super(...arguments),this.kind="symbol"}addToSymbol(e,t){const r=this.getValue(t);if(null==r)return;this.findTargetNode(e)[this._fixCase(this.cimPropertyName)]=r}_fixCase(e){return this.cimPropertyName[0].toLocaleLowerCase()+e.slice(1)}}class c extends u{constructor(){super(...arguments),this.cimPropertyName="VerticalAlignment"}findTargetNode(e){return e}getValue(e){return null==e.verticalAlignment?null:["Top","Center","Baseline","Bottom"][e.verticalAlignment]}}class m extends u{constructor(){super(...arguments),this.cimPropertyName="HorizontalAlignment"}findTargetNode(e){return e}getValue(e){return null==e.horizontalAlignment?null:["Left","Right","Center","Justify"][e.horizontalAlignment]}}class d extends u{constructor(){super(...arguments),this.cimPropertyName="FontFamilyName"}findTargetNode(e){return e}getValue(e){return e.fontFamilyName}}class p extends u{constructor(){super(...arguments),this.cimPropertyName="FontStyleName"}findTargetNode(e){return e}getValue(e){return e.fontStyleName}}class y extends u{constructor(){super(...arguments),this.cimPropertyName="Height"}findTargetNode(e){return e}getValue(e){return e.size}}class g extends u{constructor(){super(...arguments),this.cimPropertyName="Underline"}findTargetNode(e){return e}getValue(e){return e.underline}}const f=new i,N=new n,h=new o,x=new a,T=new l,b=new y,v=new g,P=[f,N,h,x,T],F=[new m,new c,new d,new p,b,v];export{P as featureFields,F as symbolFields};
2
+ import{fixUnsupportedCIM as e}from"../../../../../symbols/cim/supportUtils.js";let t=0;class i{constructor(e,t,i,r){this.cimPropertyName=e,this.findTargetNode=i,this.getValue=r,this.realFieldName=`__virtual_fi_${t}`}addToFeature(e,t){const i=this.getValue(t);e.attributes[this.realFieldName]=i}addToSymbol(e){const i=this.findTargetNode(e.symbol);let{primitiveName:r}=i;r||(t++,r=`primitive_${t}`,i.primitiveName=r);const s={type:"CIMPrimitiveOverride",primitiveName:r,propertyName:this.cimPropertyName,valueExpressionInfo:{type:"CIMExpressionInfo",expression:`return $feature.${this.realFieldName};`}};e.primitiveOverrides=e.primitiveOverrides||[],e.primitiveOverrides.push(s)}}const r=new i("TextString","text",e=>e.symbolLayers[0].markerGraphics[0],e=>e.graphic?e.graphic.text:e.text),s=new i("Color","color",e=>e.symbolLayers[0].markerGraphics[0].symbol.symbol.symbolLayers.find(e=>"CIMSolidFill"===e.type),t=>{const i=t.color||"#000000";if(i.startsWith("#"))return i;if(i.startsWith("rgb"))return i;const r=JSON.parse(i),s=e(r);return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]/255})`}),o=new i("Rotation","rotation",e=>e.symbolLayers[0],e=>null!=e.textAngle?-e.textAngle:void 0),n=new i("OffsetX","offsetX",e=>e.symbolLayers[0],e=>e.xOffset),l=new i("OffsetY","offsetY",e=>e.symbolLayers[0],e=>e.yOffset);class a{constructor(e,t,i){this.cimPropertyName=e,this.findTargetNode=t,this.getValue=i}addToSymbol(e,t){const i=this.getValue(t);if(null==i)return;this.findTargetNode(e)[this._fixCase(this.cimPropertyName)]=i}_fixCase(e){return this.cimPropertyName[0].toLocaleLowerCase()+e.slice(1)}}const m=new a("VerticalAlignment",e=>e,e=>null==e.verticalAlignment?null:["Top","Center","Baseline","Bottom"][e.verticalAlignment]),y=[r,s,o,n,l],c=[new a("HorizontalAlignment",e=>e,e=>null==e.horizontalAlignment?null:["Left","Right","Center","Justify"][e.horizontalAlignment]),m,new a("FontFamilyName",e=>e,e=>e.fontFamilyName),new a("FontStyleName",e=>e,e=>e.fontStyleName),new a("Height",e=>e,e=>e.size),new a("Underline",e=>e,e=>e.underline)];export{y as featureFields,c as symbolFields};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../../analysis/LengthDimension.js";import i from"../../../../core/Accessor.js";import n from"../../../../core/Handles.js";import{destroyHandle as a,handlesGroup as s}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{equals as o}from"../../../../core/lang.js";import{mapCollection as r}from"../../../../core/mapCollectionUtils.js";import{releaseMaybe as p,destroyMaybe as l}from"../../../../core/maybe.js";import{memoize as u}from"../../../../core/memoize.js";import{ignoreAbortErrors as d}from"../../../../core/promiseUtils.js";import{watch as c,initial as m,sync as h,syncAndInitial as g,when as f}from"../../../../core/reactiveUtils.js";import{property as _,subclass as M}from"../../../../core/accessorSupport/decorators.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import S from"../../../../geometry/Point.js";import{clonePoint as C}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as w,applyConstraint as b,computeConstraint as P,constraintDependencies as O}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as D,LengthDimensionPointManipulator as H,pointManipulatorHandles as j,createOffsetManipulator as T,offsetManipulatorHandles as x,LineOfSightOrientationManipulator as G,headingManipulatorHandles as z,rotationManipulatorHandles as U,createMeasureTypeManipulator as R,measureTypeManipulatorHandles as I,updateOffsetManipulatorTransform as V,updateHeadingManipulatorTransform as A,updateRotationManipulatorTransform as E,updateMeasureTypeManipulatorTransform as k,unfocusedOffsetWidth as L,focusedOffsetWidth as F}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as q,arePointsVerticallyAligned as B,computationToGeometryDependencies as N,computeGeometryFromDimension as J}from"./lengthDimensionUtils.js";import{disabledPointColor as K,pointRadius as Q,getTransparentAccentColor as W,getContrastColor as X,initialOffsetPx as Y}from"./settings.js";import{getRotateHeadingTexture as Z}from"../images/Factory.js";import{SnappingVisualizer3D as $}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as tt}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as et}from"../../interactive/visualElements/VerticesVisualElement.js";import{Parameters as it,ImageMaterial as nt}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as at}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as st}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as ot}from"../../../interactive/coordinateHelper.js";import{EditGeometry as rt}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as pt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as lt}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as ut}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{acquire as dt}from"../../../interactive/snapping/SnappingManagerPool.js";import{SnappingOperation as ct}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as mt}from"../../../interactive/snapping/snappingUtils.js";let ht=class extends i{constructor(t){super(t),this._stagedDimension=null,this._snappingManagerResult=null,this._computationManipulators=new Map,this._computationHandles=new n,this._updatingHandles=new y,this._getSnappingContext=u(t=>new lt({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new pt(new rt("point",ot(!0,!1,this.view.spatialReference)),this.view.state.viewingMode),visualizer:new $}));const{view:e}=t;this._unfocusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(e),this._focusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(e),this._thinOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(e),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:at(2)}),this._constraintSnappingIndicator=new tt({view:e,attached:!0,width:1,renderOccluded:4,stipplePattern:at(5),isDecoration:!0});const i=K.toUnitRGBA();this._stagedStartIndicator=new et({view:e,attached:!1,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,color:i,size:2*Q,outlineSize:0,renderOccluded:4,isDecoration:!0})}initialize(){const{view:t}=this;this._snappingOperation=new ct({view:t});const e=W(t.effectiveTheme),i=X(t.effectiveTheme),n=!t.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._textureHandle=Z(t.stage.textures,{accentColor:e,contrastColor:i,preMultiplyAlpha:n});const s=new it(this._textureHandle.managedTexture,!1);s.writeDepth=!1,s.renderOccluded=16,s.isDecoration=!0,this._orientationManipulatorMaterial=new nt(s);const o=r(()=>this.analysisViewData.computations,({computation:t})=>this._createManipulators(t));this.addHandles([c(()=>({accentColor:W(t.effectiveTheme),contrastColor:X(t.effectiveTheme)}),({accentColor:e,contrastColor:i})=>{const a=this._textureHandle;this._textureHandle=Z(t.stage.textures,{accentColor:e,contrastColor:i,preMultiplyAlpha:n}),this._orientationManipulatorMaterial.setParameters({managedTexture:this._textureHandle.managedTexture}),a?.release();const s=e.toUnitRGBA();this._unfocusedOffsetManipulatorMaterial.setParameters({color:s}),this._focusedOffsetManipulatorMaterial.setParameters({color:s}),this._thinOffsetManipulatorMaterial.setParameters({color:s}),this._constraintSnappingIndicator.color=s},m),a(o),c(()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation}),({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=C(t,new S);this._applyPointUpdate(e,{endPoint:i})},h),c(()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}),(t,e)=>{const{stagedDimension:i,selectedComputation:n,firstGrabbedManipulator:a}=t;if(i===e?.stagedDimension&&a===e?.firstGrabbedManipulator){for(const s of[n,e?.selectedComputation])if(null!=s){const e=this._computationManipulators.get(s);null!=e&&this._updateManipulators(s,e,t)}}else for(const[s,o]of this._computationManipulators)this._updateManipulators(s,o,t)},g),c(()=>this.analysis.style.lineSize,t=>this._updateManipulatorStyle(t),m),c(()=>this.view.state.camera,()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)}),c(()=>{const t=this._stagedComputation;if(!t)return null;const e=t.elevationAlignedStartPoint,i=v();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null},t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1})]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),mt(this,()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);this._updatingHandles.consumePromise(d(this._snappingOperation.snapAgainNearPreviousMapPoint(this._ensureSnappingManager(),e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",n=this._computeConstraint(t);w(t,i,{constraint:n,view:this.view})}}})}destroy(){this._textureHandle=p(this._textureHandle),this._snappingOperation=l(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy()}get updating(){return this._updatingHandles.updating||!!this._snappingManager?.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager?.options}get _snappingManager(){return this._snappingManagerResult?.snappingManager}_ensureSnappingManager(){return this._snappingManagerResult||(this._snappingManagerResult=dt(this.view),this.addHandles(this._snappingManagerResult)),this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1)?.computation;return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[f(()=>this.analysisViewData.selectedComputation,t=>{t.previousConstraint=this._computeConstraint(t)},{...g,equals:o}),c(()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}},(t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:i,computation:n}=t;switch(n.previousConstraint){case 0:n.preConstraintProperties={measureType:"horizontal",orientation:0};break;case 1:n.preConstraintProperties={measureType:"vertical",orientation:0};break;case 2:n.preConstraintProperties={measureType:"direct",orientation:i};break;default:n.preConstraintProperties={measureType:e,orientation:i}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)},h)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[c(()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation}),({stagedComputation:e,activeComputation:i})=>{const n=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)n.attached=!0;else{const{start:e,end:a}=this._computationManipulators.get(i),s=()=>{n.attached=e.grabbing||a.grabbing};s(),this.addHandles([e.events.on("grab-changed",s),a.events.on("grab-changed",s)],t)}else n.attached=!1}),c(()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}},({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&2!==e?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1})]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this._updatingHandles.consumePromise(d(this._snappingOperation.snap({point:t},this._ensureSnappingManager(),i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:i}){let n=t;if("mouse"===i){const e=this._getSnappingContext(i);n=this._ensureSnappingManager().update({point:t,context:e})}const a=new e({startPoint:C(n,new S),endPoint:null,measureType:"horizontal"});return this._stagedDimension=a,this._resetSnappingState(),a}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let n=t;if("mouse"===e){const i=this._getSnappingContext(e);n=this._ensureSnappingManager().update({point:t,context:i})}const a=C(n,new S);this._applyPointUpdate(i,{endPoint:a}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._ensureSnappingManager().doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_createManipulators(t){const e=this._setupPointManipulator(t,{isStart:!0}),i=this._setupPointManipulator(t,{isStart:!1}),n=this._setupOffsetManipulator(t),a=this._setupHeadingManipulator(t),o=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,"direct"),p=this._setupMeasureTypeManipulator(t,"horizontal"),l=this._setupMeasureTypeManipulator(t,"vertical"),u=new D({start:e,end:i,offset:n,heading:a,rotation:o,direct:r,horizontal:p,vertical:l});this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values());const d=s(u.values().map(t=>t.events.on("focus-changed",()=>{u.values().some(t=>t.focused)&&this._resetSnappingState()})));return{manipulators:u,remove:()=>{d.remove(),this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of u.values())this.manipulators.remove(t)}}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([c(()=>t.geometry,()=>this._updateManipulators(t,e),{...g,equals:o})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:n}=t,a=new H(i,{metadata:n}),s=j(a,{isStart:e.isStart,createSnappingPipelineStep:t=>ut({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this._updatingHandles}),dimension:n,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(s,t),a}_setupOffsetManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),n=x(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=new G(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=z(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupRotationManipulator(t){const{view:e}=this,i=new G(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=U(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,n=R(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),a=I(n,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(a,t),n}_updateManipulators(t,e,i={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:n,selectedComputation:a,firstGrabbedManipulator:s}=i,{start:o,end:r,offset:p,heading:l,rotation:u}=e,d=a===t,c=q(t),{dimension:m}=t;for(const f of e.values()){const t=c&&null==n&&(null==s||f===s);f===p?(f.available=t,f.selected=d):f.available=t&&d}if(!c)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator(t=>t.available=!1):e.manipulatorForMeasureType(m.measureType).available=!1;for(const f of[l,u])"direct"===m.measureType&&0!==m.offset||(f.available=!1);B(t)?u.available=!1:l.available=!1;const{geometry:h}=t;o.renderLocation=h.directSegment.startRenderSpace,r.renderLocation=h.directSegment.endRenderSpace;const{renderCoordsHelper:g}=this.view;V(p,h,g),l.available&&A(l,t,g),u.available&&E(u,t,g),e.forEachMeasureTypeManipulator((e,i)=>{e.available&&k(e,t,i,g)})}_updateManipulatorStyle(t){const e=L(t),i=F(t),n={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:a,heading:s,rotation:o}of this._computationManipulators.values())a.radius=i/2,s.update(n),o.update(n);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,n=N(t);"startPoint"in e&&(n.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(n.elevationAlignedEndPoint=e.endPoint);const a=J(n,i.renderCoordsHelper);if(null==a)return;const s=this._computeConstraint({...n,geometry:a});b(t,e,{...n,constraint:s,unconstrainedGeometry:a,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,gt);const{state:e,renderCoordsHelper:i}=this.view,n=e.camera.computeScreenPixelSizeAt(gt);t.dimension.offset=Y*n*i.unitInMeters}_computeConstraint(t){return P(O(t,this._ensureSnappingManager().options),this.view)}_createOffsetManipulatorMaterial(t){return new st({width:1,renderOccluded:4,writeDepth:!1,polygonOffset:3,isDecoration:!0},t.state.isGlobal)}get test(){}};t([_({constructOnly:!0})],ht.prototype,"analysis",void 0),t([_({constructOnly:!0})],ht.prototype,"analysisViewData",void 0),t([_({constructOnly:!0})],ht.prototype,"manipulators",void 0),t([_({constructOnly:!0})],ht.prototype,"parentTool",void 0),t([_({constructOnly:!0,nonNullable:!0})],ht.prototype,"view",void 0),t([_({readOnly:!0})],ht.prototype,"updating",null),t([_()],ht.prototype,"firstGrabbedManipulator",null),t([_()],ht.prototype,"hasGrabbedManipulators",null),t([_()],ht.prototype,"snappingOptions",null),t([_()],ht.prototype,"_stagedDimension",void 0),t([_()],ht.prototype,"_snappingManager",null),t([_()],ht.prototype,"_activeComputation",null),t([_()],ht.prototype,"_stagedComputation",null),t([_()],ht.prototype,"_snappingManagerResult",void 0),ht=t([M("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ht);const gt=v();export{ht as LengthDimensionSubTool};
2
+ import{__decorate as t}from"tslib";import e from"../../../../analysis/LengthDimension.js";import i from"../../../../core/Accessor.js";import n from"../../../../core/Handles.js";import{destroyHandle as a,handlesGroup as s}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{equals as o}from"../../../../core/lang.js";import{mapCollection as r}from"../../../../core/mapCollectionUtils.js";import{releaseMaybe as p,destroyMaybe as l}from"../../../../core/maybe.js";import{memoize as u}from"../../../../core/memoize.js";import{ignoreAbortErrors as d}from"../../../../core/promiseUtils.js";import{watch as c,initial as m,sync as h,syncAndInitial as g,when as f}from"../../../../core/reactiveUtils.js";import{property as _,subclass as M}from"../../../../core/accessorSupport/decorators.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import S from"../../../../geometry/Point.js";import{clonePoint as C}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as w,applyConstraint as b,computeConstraint as P,constraintDependencies as O}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as D,LengthDimensionPointManipulator as H,pointManipulatorHandles as j,createOffsetManipulator as T,offsetManipulatorHandles as x,LineOfSightOrientationManipulator as G,headingManipulatorHandles as z,rotationManipulatorHandles as U,createMeasureTypeManipulator as R,measureTypeManipulatorHandles as I,updateOffsetManipulatorTransform as V,updateHeadingManipulatorTransform as A,updateRotationManipulatorTransform as E,updateMeasureTypeManipulatorTransform as k,unfocusedOffsetWidth as L,focusedOffsetWidth as F}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as q,arePointsVerticallyAligned as B,computationToGeometryDependencies as N,computeGeometryFromDimension as J}from"./lengthDimensionUtils.js";import{disabledPointColor as K,pointRadius as Q,getTransparentAccentColor as W,getContrastColor as X,initialOffsetPx as Y}from"./settings.js";import{getRotateHeadingTexture as Z}from"../images/Factory.js";import{SnappingVisualizer3D as $}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as tt}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as et}from"../../interactive/visualElements/VerticesVisualElement.js";import{Parameters as it,ImageMaterial as nt}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as at}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as st}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as ot}from"../../../interactive/coordinateHelper.js";import{EditGeometry as rt}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as pt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as lt}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as ut}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{acquire as dt}from"../../../interactive/snapping/SnappingManagerPool.js";import{SnappingOperation as ct}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as mt}from"../../../interactive/snapping/snappingUtils.js";let ht=class extends i{constructor(t){super(t),this._stagedDimension=null,this._snappingManagerResult=null,this._computationManipulators=new Map,this._computationHandles=new n,this._updatingHandles=new y,this._getSnappingContext=u(t=>new lt({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new pt(new rt("point",ot(!0,!1,this.view.spatialReference)),this.view.state.viewingMode),visualizer:new $}));const{view:e}=t;this._unfocusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(e),this._focusedOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(e),this._thinOffsetManipulatorMaterial=this._createOffsetManipulatorMaterial(e),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:at(2)}),this._constraintSnappingIndicator=new tt({view:e,attached:!0,width:1,renderOccluded:4,stipplePattern:at(5),isDecoration:!0});const i=K.toUnitRGBA();this._stagedStartIndicator=new et({view:e,attached:!1,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,color:i,size:2*Q,outlineSize:0,renderOccluded:4,isDecoration:!0})}initialize(){const{view:t}=this;this._snappingOperation=new ct({view:t});const e=W(t.effectiveTheme),i=X(t.effectiveTheme),n=!t.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._textureHandle=Z(t.stage.textures,{accentColor:e,contrastColor:i,preMultiplyAlpha:n});const s=new it(this._textureHandle.managedTexture,!1);s.renderOccluded=16,s.isDecoration=!0,this._orientationManipulatorMaterial=new nt(s);const o=r(()=>this.analysisViewData.computations,({computation:t})=>this._createManipulators(t));this.addHandles([c(()=>({accentColor:W(t.effectiveTheme),contrastColor:X(t.effectiveTheme)}),({accentColor:e,contrastColor:i})=>{const a=this._textureHandle;this._textureHandle=Z(t.stage.textures,{accentColor:e,contrastColor:i,preMultiplyAlpha:n}),this._orientationManipulatorMaterial.setParameters({managedTexture:this._textureHandle.managedTexture}),a?.release();const s=e.toUnitRGBA();this._unfocusedOffsetManipulatorMaterial.setParameters({color:s}),this._focusedOffsetManipulatorMaterial.setParameters({color:s}),this._thinOffsetManipulatorMaterial.setParameters({color:s}),this._constraintSnappingIndicator.color=s},m),a(o),c(()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation}),({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=C(t,new S);this._applyPointUpdate(e,{endPoint:i})},h),c(()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}),(t,e)=>{const{stagedDimension:i,selectedComputation:n,firstGrabbedManipulator:a}=t;if(i===e?.stagedDimension&&a===e?.firstGrabbedManipulator){for(const s of[n,e?.selectedComputation])if(null!=s){const e=this._computationManipulators.get(s);null!=e&&this._updateManipulators(s,e,t)}}else for(const[s,o]of this._computationManipulators)this._updateManipulators(s,o,t)},g),c(()=>this.analysis.style.lineSize,t=>this._updateManipulatorStyle(t),m),c(()=>this.view.state.camera,()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)}),c(()=>{const t=this._stagedComputation;if(!t)return null;const e=t.elevationAlignedStartPoint,i=v();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null},t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1})]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),mt(this,()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerInfo?.type??"mouse",e=this._getSnappingContext(t);this._updatingHandles.consumePromise(d(this._snappingOperation.snapAgainNearPreviousMapPoint(this._ensureSnappingManager(),e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",n=this._computeConstraint(t);w(t,i,{constraint:n,view:this.view})}}})}destroy(){this._textureHandle=p(this._textureHandle),this._snappingOperation=l(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy()}get updating(){return this._updatingHandles.updating||!!this._snappingManager?.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager?.options}get _snappingManager(){return this._snappingManagerResult?.snappingManager}_ensureSnappingManager(){return this._snappingManagerResult||(this._snappingManagerResult=dt(this.view),this.addHandles(this._snappingManagerResult)),this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1)?.computation;return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[f(()=>this.analysisViewData.selectedComputation,t=>{t.previousConstraint=this._computeConstraint(t)},{...g,equals:o}),c(()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}},(t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:i,computation:n}=t;switch(n.previousConstraint){case 0:n.preConstraintProperties={measureType:"horizontal",orientation:0};break;case 1:n.preConstraintProperties={measureType:"vertical",orientation:0};break;case 2:n.preConstraintProperties={measureType:"direct",orientation:i};break;default:n.preConstraintProperties={measureType:e,orientation:i}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)},h)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[c(()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation}),({stagedComputation:e,activeComputation:i})=>{const n=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)n.attached=!0;else{const{start:e,end:a}=this._computationManipulators.get(i),s=()=>{n.attached=e.grabbing||a.grabbing};s(),this.addHandles([e.events.on("grab-changed",s),a.events.on("grab-changed",s)],t)}else n.attached=!1}),c(()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}},({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&2!==e?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1})]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this._updatingHandles.consumePromise(d(this._snappingOperation.snap({point:t},this._ensureSnappingManager(),i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:i}){let n=t;if("mouse"===i){const e=this._getSnappingContext(i);n=this._ensureSnappingManager().update({point:t,context:e})}const a=new e({startPoint:C(n,new S),endPoint:null,measureType:"horizontal"});return this._stagedDimension=a,this._resetSnappingState(),a}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let n=t;if("mouse"===e){const i=this._getSnappingContext(e);n=this._ensureSnappingManager().update({point:t,context:i})}const a=C(n,new S);this._applyPointUpdate(i,{endPoint:a}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._ensureSnappingManager().doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_createManipulators(t){const e=this._setupPointManipulator(t,{isStart:!0}),i=this._setupPointManipulator(t,{isStart:!1}),n=this._setupOffsetManipulator(t),a=this._setupHeadingManipulator(t),o=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,"direct"),p=this._setupMeasureTypeManipulator(t,"horizontal"),l=this._setupMeasureTypeManipulator(t,"vertical"),u=new D({start:e,end:i,offset:n,heading:a,rotation:o,direct:r,horizontal:p,vertical:l});this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values());const d=s(u.values().map(t=>t.events.on("focus-changed",()=>{u.values().some(t=>t.focused)&&this._resetSnappingState()})));return{manipulators:u,remove:()=>{d.remove(),this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of u.values())this.manipulators.remove(t)}}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([c(()=>t.geometry,()=>this._updateManipulators(t,e),{...g,equals:o})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:n}=t,a=new H(i,{metadata:n}),s=j(a,{isStart:e.isStart,createSnappingPipelineStep:t=>ut({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this._updatingHandles}),dimension:n,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(s,t),a}_setupOffsetManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),n=x(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=new G(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=z(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupRotationManipulator(t){const{view:e}=this,i=new G(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=U(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,n=R(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),a=I(n,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(a,t),n}_updateManipulators(t,e,i={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:n,selectedComputation:a,firstGrabbedManipulator:s}=i,{start:o,end:r,offset:p,heading:l,rotation:u}=e,d=a===t,c=q(t),{dimension:m}=t;for(const f of e.values()){const t=c&&null==n&&(null==s||f===s);f===p?(f.available=t,f.selected=d):f.available=t&&d}if(!c)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator(t=>t.available=!1):e.manipulatorForMeasureType(m.measureType).available=!1;for(const f of[l,u])"direct"===m.measureType&&0!==m.offset||(f.available=!1);B(t)?u.available=!1:l.available=!1;const{geometry:h}=t;o.renderLocation=h.directSegment.startRenderSpace,r.renderLocation=h.directSegment.endRenderSpace;const{renderCoordsHelper:g}=this.view;V(p,h,g),l.available&&A(l,t,g),u.available&&E(u,t,g),e.forEachMeasureTypeManipulator((e,i)=>{e.available&&k(e,t,i,g)})}_updateManipulatorStyle(t){const e=L(t),i=F(t),n={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:a,heading:s,rotation:o}of this._computationManipulators.values())a.radius=i/2,s.update(n),o.update(n);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,n=N(t);"startPoint"in e&&(n.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(n.elevationAlignedEndPoint=e.endPoint);const a=J(n,i.renderCoordsHelper);if(null==a)return;const s=this._computeConstraint({...n,geometry:a});b(t,e,{...n,constraint:s,unconstrainedGeometry:a,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,gt);const{state:e,renderCoordsHelper:i}=this.view,n=e.camera.computeScreenPixelSizeAt(gt);t.dimension.offset=Y*n*i.unitInMeters}_computeConstraint(t){return P(O(t,this._ensureSnappingManager().options),this.view)}_createOffsetManipulatorMaterial(t){return new st({width:1,renderOccluded:4,writeDepth:!1,polygonOffset:3,isDecoration:!0},t.state.isGlobal)}get test(){}};t([_({constructOnly:!0})],ht.prototype,"analysis",void 0),t([_({constructOnly:!0})],ht.prototype,"analysisViewData",void 0),t([_({constructOnly:!0})],ht.prototype,"manipulators",void 0),t([_({constructOnly:!0})],ht.prototype,"parentTool",void 0),t([_({constructOnly:!0,nonNullable:!0})],ht.prototype,"view",void 0),t([_({readOnly:!0})],ht.prototype,"updating",null),t([_()],ht.prototype,"firstGrabbedManipulator",null),t([_()],ht.prototype,"hasGrabbedManipulators",null),t([_()],ht.prototype,"snappingOptions",null),t([_()],ht.prototype,"_stagedDimension",void 0),t([_()],ht.prototype,"_snappingManager",null),t([_()],ht.prototype,"_activeComputation",null),t([_()],ht.prototype,"_stagedComputation",null),t([_()],ht.prototype,"_snappingManagerResult",void 0),ht=t([M("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ht);const gt=v();export{ht as LengthDimensionSubTool};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import r from"../../../core/Accessor.js";import"../../../core/has.js";import{destroyMaybe as e}from"../../../core/maybe.js";import{watch as o,initial as i,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as s}from"../../../core/accessorSupport/decorators.js";import{DoubleClickZoom as d}from"./handlers/DoubleClickZoom.js";import{DragRotate as m}from"./handlers/DragRotate.js";import{DragZoom as p}from"./handlers/DragZoom.js";import{GamepadNavigation as g}from"./handlers/GamepadNavigation.js";import{KeyboardNavigation as c}from"./handlers/KeyboardNavigation.js";import{MouseWheelZoom as u}from"./handlers/MouseWheelZoom.js";import{PinchAndPanNavigation as l}from"./handlers/PinchAndPanNavigation.js";import{PointerDownCancelAnimation as h}from"./handlers/PointerDownCancelAnimation.js";import{TwoFingerTilt as w}from"./handlers/TwoFingerTilt.js";import{BrowserEventSource as f}from"../../input/BrowserEventSource.js";import{InputManager as v,ViewEventPriorities as y}from"../../input/InputManager.js";import{PreventContextMenu as _}from"../../input/handlers/PreventContextMenu.js";import{getPointerActions as D}from"../../input/handlers/support.js";import{Drag as P}from"../../input/recognizers/Drag.js";import{ImmediateDoubleClick as j}from"../../input/recognizers/ImmediateDoubleClick.js";import{PointerClickHoldAndDrag as A}from"../../input/recognizers/PointerClickHoldAndDrag.js";import{SingleAndDoubleClick as M}from"../../input/recognizers/SingleAndDoubleClick.js";import{VerticalTwoFingerDrag as b}from"../../input/recognizers/VerticalTwoFingerDrag.js";let T=class extends r{constructor(){super(...arguments),this.mode="default",this._updateMode=({mode:t,dragPrimary:r,dragSecondary:e,dragTertiary:o})=>{"pro"===t&&(e="zoom",o="pan"===r?"rotate":"pan");const i={dragPrimary:r,dragSecondary:e,dragTertiary:o};this._modeDragPan&&(this._modeDragPan.pointerActions=D("pan",i)),this._modeDragRotate&&(this._modeDragRotate.pointerActions=D("rotate",i)),this._modeDragZoom&&(this._modeDragZoom.pointerActions=D("zoom",i))}}destroy(){this.disconnect()}get primaryDragAction(){return this.view.navigation.actionMap.dragPrimary}set primaryDragAction(t){const{actionMap:r}=this.view.navigation;r.dragPrimary=t,r.dragSecondary="pan"===t?"rotate":"pan"}get updating(){return!!this._inputManager?.updating}get latestPointerInfo(){return this._inputManager?.latestPointerInfo}get latestPenInfo(){return this._inputManager?.latestPenInfo}get multiTouchActive(){return this._inputManager?.multiTouchActive??!1}disconnect(){this.removeAllHandles(),this.view.viewEvents.disconnect(),this._modeDragPan=null,this._modeDragRotate=null,this._modeDragZoom=null,this._modeKeyboardNavigation=null,this._inputManager=e(this._inputManager),this._source=e(this._source)}connect(){const t=this.view;this._source=new f(this.view.surface,t.input);const r=[new j,new A,new M,new P(this.view.navigation),new b],e=new v({eventSource:this._source,recognizers:r});this._inputManager=e,e.installHandlers("prevent-context-menu",[new _],y.INTERNAL);const a={fov:"Shift",pan:{left:"ArrowLeft",right:"ArrowRight",forward:"ArrowUp",backward:"ArrowDown",up:["u","U"],down:["j","J"]},lookAround:{headingLeft:["a","A"],headingRight:["d","D"],tiltUp:["w","W"],tiltDown:["s","S"]},modifier:["b","B"],zoom:{zoomIn:["+","="],zoomOut:["-","_"]},reset:{heading:["n","N"],tilt:["p","P"]}};this._modeDragPan=new l(t,["primary"]),this._modeDragRotate=new m(t,["secondary"],0),this._modeDragZoom=new p(t,["tertiary"],a.fov),this._modeKeyboardNavigation=new c(t,a),e.installHandlers("navigation",[new h(t),new d(t),new g(t),new u(t,a.fov),new m(t,["primary"],1,a.modifier),new l(t,["secondary"],a.modifier,!0),new l(t,["tertiary"],a.modifier),this._modeDragRotate,this._modeDragZoom,this._modeDragPan,this._modeKeyboardNavigation,new w(t)],y.INTERNAL),this.view.viewEvents.connect(e),this.addHandles([o(()=>this.view.navigation?.browserTouchPanEnabled,t=>{this._source.browserTouchPanningEnabled=!t},i),o(()=>{const{actionMap:t}=this.view.navigation,{dragPrimary:r,dragSecondary:e,dragTertiary:o}=t;return{mode:this.mode,dragPrimary:r,dragSecondary:e,dragTertiary:o}},this._updateMode,n)])}isModifierKeyDown(t){return this._inputManager?.isModifierKeyDown(t)??!1}get test(){}};t([a()],T.prototype,"view",void 0),t([a({type:["default","pro"]})],T.prototype,"mode",void 0),t([a({readOnly:!0})],T.prototype,"updating",null),t([a()],T.prototype,"latestPointerInfo",null),t([a()],T.prototype,"latestPenInfo",null),t([a()],T.prototype,"multiTouchActive",null),t([a()],T.prototype,"_inputManager",void 0),T=t([s("esri.views.3d.input.SceneInputManager")],T);const I=T;export{I as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import"../../../core/has.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as o,initial as i,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as s}from"../../../core/accessorSupport/decorators.js";import{DoubleClickZoom as d}from"./handlers/DoubleClickZoom.js";import{DragRotate as m}from"./handlers/DragRotate.js";import{DragZoom as p}from"./handlers/DragZoom.js";import{GamepadNavigation as g}from"./handlers/GamepadNavigation.js";import{KeyboardNavigation as c}from"./handlers/KeyboardNavigation.js";import{MouseWheelZoom as l}from"./handlers/MouseWheelZoom.js";import{PinchAndPanNavigation as u}from"./handlers/PinchAndPanNavigation.js";import{PointerDownCancelAnimation as h}from"./handlers/PointerDownCancelAnimation.js";import{TwoFingerTilt as w}from"./handlers/TwoFingerTilt.js";import{BrowserEventSource as f}from"../../input/BrowserEventSource.js";import{InputManager as v,ViewEventPriorities as y}from"../../input/InputManager.js";import{PreventContextMenu as _}from"../../input/handlers/PreventContextMenu.js";import{PreventTouchSelection as D}from"../../input/handlers/PreventTouchSelection.js";import{getPointerActions as P}from"../../input/handlers/support.js";import{Drag as j}from"../../input/recognizers/Drag.js";import{ImmediateDoubleClick as A}from"../../input/recognizers/ImmediateDoubleClick.js";import{PointerClickHoldAndDrag as M}from"../../input/recognizers/PointerClickHoldAndDrag.js";import{SingleAndDoubleClick as T}from"../../input/recognizers/SingleAndDoubleClick.js";import{VerticalTwoFingerDrag as b}from"../../input/recognizers/VerticalTwoFingerDrag.js";let I=class extends e{constructor(){super(...arguments),this.mode="default",this._updateMode=({mode:t,dragPrimary:e,dragSecondary:r,dragTertiary:o})=>{"pro"===t&&(r="zoom",o="pan"===e?"rotate":"pan");const i={dragPrimary:e,dragSecondary:r,dragTertiary:o};this._modeDragPan&&(this._modeDragPan.pointerActions=P("pan",i)),this._modeDragRotate&&(this._modeDragRotate.pointerActions=P("rotate",i)),this._modeDragZoom&&(this._modeDragZoom.pointerActions=P("zoom",i))}}destroy(){this.disconnect()}get primaryDragAction(){return this.view.navigation.actionMap.dragPrimary}set primaryDragAction(t){const{actionMap:e}=this.view.navigation;e.dragPrimary=t,e.dragSecondary="pan"===t?"rotate":"pan"}get updating(){return!!this._inputManager?.updating}get latestPointerInfo(){return this._inputManager?.latestPointerInfo}get latestPenInfo(){return this._inputManager?.latestPenInfo}get multiTouchActive(){return this._inputManager?.multiTouchActive??!1}disconnect(){this.removeAllHandles(),this.view.viewEvents.disconnect(),this._modeDragPan=null,this._modeDragRotate=null,this._modeDragZoom=null,this._modeKeyboardNavigation=null,this._inputManager=r(this._inputManager),this._source=r(this._source)}connect(){const t=this.view;this._source=new f(this.view.surface,t.input);const e=[new A,new M,new T,new j(this.view.navigation),new b],r=new v({eventSource:this._source,recognizers:e});this._inputManager=r,r.installHandlers("prevent-context-menu",[new _],y.INTERNAL),r.installHandlers("prevent-touch-text-selection-gesture",[new D(this.view)],y.INTERNAL);const a={fov:"Shift",pan:{left:"ArrowLeft",right:"ArrowRight",forward:"ArrowUp",backward:"ArrowDown",up:["u","U"],down:["j","J"]},lookAround:{headingLeft:["a","A"],headingRight:["d","D"],tiltUp:["w","W"],tiltDown:["s","S"]},modifier:["b","B"],zoom:{zoomIn:["+","="],zoomOut:["-","_"]},reset:{heading:["n","N"],tilt:["p","P"]}};this._modeDragPan=new u(t,["primary"]),this._modeDragRotate=new m(t,["secondary"],0),this._modeDragZoom=new p(t,["tertiary"],a.fov),this._modeKeyboardNavigation=new c(t,a),r.installHandlers("navigation",[new h(t),new d(t),new g(t),new l(t,a.fov),new m(t,["primary"],1,a.modifier),new u(t,["secondary"],a.modifier,!0),new u(t,["tertiary"],a.modifier),this._modeDragRotate,this._modeDragZoom,this._modeDragPan,this._modeKeyboardNavigation,new w(t)],y.INTERNAL),this.view.viewEvents.connect(r),this.addHandles([o(()=>this.view.navigation?.browserTouchPanEnabled,t=>{this._source.browserTouchPanningEnabled=!t},i),o(()=>{const{actionMap:t}=this.view.navigation,{dragPrimary:e,dragSecondary:r,dragTertiary:o}=t;return{mode:this.mode,dragPrimary:e,dragSecondary:r,dragTertiary:o}},this._updateMode,n)])}isModifierKeyDown(t){return this._inputManager?.isModifierKeyDown(t)??!1}get test(){}};t([a()],I.prototype,"view",void 0),t([a({type:["default","pro"]})],I.prototype,"mode",void 0),t([a({readOnly:!0})],I.prototype,"updating",null),t([a()],I.prototype,"latestPointerInfo",null),t([a()],I.prototype,"latestPenInfo",null),t([a()],I.prototype,"multiTouchActive",null),t([a()],I.prototype,"_inputManager",void 0),I=t([s("esri.views.3d.input.SceneInputManager")],I);const N=I;export{N as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{multiplyOpacity as e,getContrast as t}from"../../../../core/colorUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o}from"../../../../core/reactiveUtils.js";import{DidPointerMoveRecentlyFlag as s}from"../../analysis/Slice/sliceToolUtils.js";import{Manipulator3D as a}from"../Manipulator3D.js";import{rotateManipulatorDefaults as l}from"../manipulatorUtils.js";import{RenderObject as n}from"../RenderObject.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{Geometry as m}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as u}from"../../webgl-engine/lib/GeometryUtil.js";import{Parameters as d,ImageMaterial as f}from"../../webgl-engine/materials/ImageMaterial.js";import{RibbonLineMaterial as p}from"../../webgl-engine/materials/RibbonLineMaterial.js";class w extends a{constructor(r,s){const a=e(r.effectiveTheme.accentColor,.5),n=t(r.effectiveTheme.accentColor),c=s(a,n),m=new d(c.managedTexture,!1);m.writeDepth=!1,m.renderOccluded=16,m.isDecoration=!0;const u=new f(m),w=l.calloutWidth,h=new p({width:w,renderOccluded:4,isDecoration:!0},r.state.isGlobal);super({view:r,...g({imageMaterial:u,calloutMaterial:h})}),this._textureHandle=c,this._themeHandle=i(()=>r.effectiveTheme.accentColor,r=>{const i=e(r,.5),o=t(r),a=this._textureHandle;this._textureHandle=s(i,o),u.setParameters({managedTexture:this._textureHandle.managedTexture}),a?.release(),h.setParameters({color:r.toUnitRGBA()})},o)}destroy(){this._textureHandle=r(this._textureHandle),this._themeHandle.remove(),super.destroy()}}function g({imageMaterial:e,calloutMaterial:t}){const{focusMultiplier:r,calloutLength:i,discRadius:o}=l,a=o*r,d=(e,t)=>{const r=[0,1,2,2,3,0];return new m(t,[["position",new c([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],["uv0",new c([0,0,1,0,1,1,0,1],r,2,!0)]])},f=u(t,[[0,0,0],[i-o,0,0]]),p=u(t,[[0,0,0],[i-a,0,0]]),w=s;return{autoScaleRenderObjects:!1,collisionPriority:1,collisionType:{type:"disc",direction:[0,0,1],offset:[i,0,0]},focusMultiplier:r,radius:o,renderObjects:[new n(d(o,e),1|w),new n(f,1|w),new n(d(a,e),2|w),new n(p,2|w)],state:w}}export{w as RotateManipulator};
2
+ import{multiplyOpacity as e,getContrast as t}from"../../../../core/colorUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as o}from"../../../../core/reactiveUtils.js";import{DidPointerMoveRecentlyFlag as s}from"../../analysis/Slice/sliceToolUtils.js";import{Manipulator3D as a}from"../Manipulator3D.js";import{rotateManipulatorDefaults as l}from"../manipulatorUtils.js";import{RenderObject as n}from"../RenderObject.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{Geometry as m}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as u}from"../../webgl-engine/lib/GeometryUtil.js";import{Parameters as d,ImageMaterial as f}from"../../webgl-engine/materials/ImageMaterial.js";import{RibbonLineMaterial as p}from"../../webgl-engine/materials/RibbonLineMaterial.js";class g extends a{constructor(r,s){const a=e(r.effectiveTheme.accentColor,.5),n=t(r.effectiveTheme.accentColor),c=s(a,n),m=new d(c.managedTexture,!1);m.renderOccluded=16,m.isDecoration=!0;const u=new f(m),g=l.calloutWidth,b=new p({width:g,renderOccluded:4,isDecoration:!0},r.state.isGlobal);super({view:r,...w({imageMaterial:u,calloutMaterial:b})}),this._textureHandle=c,this._themeHandle=i(()=>r.effectiveTheme.accentColor,r=>{const i=e(r,.5),o=t(r),a=this._textureHandle;this._textureHandle=s(i,o),u.setParameters({managedTexture:this._textureHandle.managedTexture}),a?.release(),b.setParameters({color:r.toUnitRGBA()})},o)}destroy(){this._textureHandle=r(this._textureHandle),this._themeHandle.remove(),super.destroy()}}function w({imageMaterial:e,calloutMaterial:t}){const{focusMultiplier:r,calloutLength:i,discRadius:o}=l,a=o*r,d=(e,t)=>{const r=[0,1,2,2,3,0];return new m(t,[["position",new c([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],["uv0",new c([0,0,1,0,1,1,0,1],r,2,!0)]])},f=u(t,[[0,0,0],[i-o,0,0]]),p=u(t,[[0,0,0],[i-a,0,0]]),g=s;return{autoScaleRenderObjects:!1,collisionPriority:1,collisionType:{type:"disc",direction:[0,0,1],offset:[i,0,0]},focusMultiplier:r,radius:o,renderObjects:[new n(d(o,e),1|g),new n(f,1|g),new n(d(a,e),2|g),new n(p,2|g)],state:g}}export{g as RotateManipulator};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{getTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{copy as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{subtract as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as o,copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as l}from"./Object3DVisualElement.js";import{Attribute as n}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{CheckerBoardMaterial as h}from"../../webgl-engine/materials/CheckerBoardMaterial.js";class m extends l{constructor(e){super(e),this._checkerBoardMaterial=null,this._renderOccluded=4,this._transparentRenderOrder=0,this._geometry=null,this._size=t(1,1),this._color1=c(1,.5,0,.5),this._color2=c(1,1,1,.5),this.applyProperties(e)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get testsTransparentRenderOrder(){return this._transparentRenderOrder}set testsTransparentRenderOrder(e){e!==this._transparentRenderOrder&&(this._transparentRenderOrder=e,this._updateMaterial())}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get size(){return this._size}set size(e){r(this._size,e),this._updateMaterial()}get color1(){return this._color1}set color1(e){o(e,this._color1)||(a(this._color1,e),this._updateMaterial())}get color2(){return this._color2}set color2(e){o(e,this._color2)||(a(this._color2,e),this._updateMaterial())}_updateMaterial(){this._checkerBoardMaterial?.setParameters({size:this._size,color1:this._color1,color2:this._color2,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder})}createExternalResources(){this._checkerBoardMaterial=new h({size:this._size,color1:this._color1,color2:this._color2,writeDepth:!1,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder,isDecoration:this.isDecoration})}destroyExternalResources(){this._checkerBoardMaterial=null}forEachMaterial(e){e(this._checkerBoardMaterial)}createGeometries(r){if(null==this._geometry||null==this._checkerBoardMaterial)return;const t=_;e(t,this.transform);const o=this._geometry,a=[],c=i();o.position.forEach(e=>{s(c,e,t),a.push(c[0],c[1],c[2])});const l=[];o.uv.forEach(e=>{l.push(e[0],e[1])});const h=new d(this._checkerBoardMaterial,[["position",new n(a,o.triangleIndices,3,!0)],["uv0",new n(l,o.triangleIndices,2,!0)]]);r.addGeometry(h)}}const _=i();export{m as MeasurementAreaVisualElement};
2
+ import{getTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{copy as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{subtract as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as o,copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as l}from"./Object3DVisualElement.js";import{Attribute as n}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{CheckerBoardMaterial as h}from"../../webgl-engine/materials/CheckerBoardMaterial.js";class m extends l{constructor(e){super(e),this._checkerBoardMaterial=null,this._renderOccluded=4,this._transparentRenderOrder=0,this._geometry=null,this._size=t(1,1),this._color1=c(1,.5,0,.5),this._color2=c(1,1,1,.5),this.applyProperties(e)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get testsTransparentRenderOrder(){return this._transparentRenderOrder}set testsTransparentRenderOrder(e){e!==this._transparentRenderOrder&&(this._transparentRenderOrder=e,this._updateMaterial())}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get size(){return this._size}set size(e){r(this._size,e),this._updateMaterial()}get color1(){return this._color1}set color1(e){o(e,this._color1)||(a(this._color1,e),this._updateMaterial())}get color2(){return this._color2}set color2(e){o(e,this._color2)||(a(this._color2,e),this._updateMaterial())}_updateMaterial(){this._checkerBoardMaterial?.setParameters({size:this._size,color1:this._color1,color2:this._color2,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder})}createExternalResources(){this._checkerBoardMaterial=new h({size:this._size,color1:this._color1,color2:this._color2,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder,isDecoration:this.isDecoration})}destroyExternalResources(){this._checkerBoardMaterial=null}forEachMaterial(e){e(this._checkerBoardMaterial)}createGeometries(r){if(null==this._geometry||null==this._checkerBoardMaterial)return;const t=_;e(t,this.transform);const o=this._geometry,a=[],c=i();o.position.forEach(e=>{s(c,e,t),a.push(c[0],c[1],c[2])});const l=[];o.uv.forEach(e=>{l.push(e[0],e[1])});const h=new d(this._checkerBoardMaterial,[["position",new n(a,o.triangleIndices,3,!0)],["uv0",new n(l,o.triangleIndices,2,!0)]]);r.addGeometry(h)}}const _=i();export{m as MeasurementAreaVisualElement};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as t,createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as i}from"../../../../core/units.js";import{add as n,normalize as s,dot as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,copy as c,negativeInfinity as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as u}from"../../../../geometry/support/ray.js";import{sv3d as y}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as h}from"../../../../support/elevationInfoUtils.js";import{computeMapPointFromVec3d as p}from"../../support/hitTest.js";import{fromRenderAtEye as g,fromScreen as f}from"../../support/geometryUtils/ray.js";import{defaultTolerance as m,Intersector as _}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as w}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as R}from"../../webgl-engine/lib/IntersectorResult.js";import{sliceFilterPredicate as I}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as P}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as b}from"../../../support/Scheduler.js";class v{constructor(t,r,i){this.viewingMode=t,this._forEachLayer=r,this._view=i,this._externalIntersectionHandlers=new e,this._tolerance=m,this._tmpRay=u(),this._tmpRegion=a(),this._validateHUDIntersector=new _(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(b.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),H(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,H(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,i){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,i),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,i=.5){return e.getRenderCenter(T,r,i),T[0]+=.0466,T[1]-=.0123,g(e,T,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}async intersectIntersectorScreenPolygon(e,t,r){t.polygonResults.init();const i=this._view.state.camera,n=await P(i,e);null!=n&&await this._screenPolygonIntersectionTask.scheduleGenerator(()=>this._intersectIntersectorScreenPolygon(i,t,n,r))}*_intersectIntersectorScreenPolygon(e,t,r,i){const n=new x(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!("include"in i||"exclude"in i),t.camera=e,t.point=null,t.filterPredicate=null,yield*t.intersectScreenPolygon(n.layers,r);const s=this._view.slice.plane,o=s?I(s):null;yield*t.intersectScreenPolygon(n.sliceableLayers,r,o),yield*this._intersectPolygonHandlersGenerator(t,n,r,o),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,r){const i=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(i,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const i=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||R(i)&&7!==i.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=m){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return f(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||n(t,e.origin,s(y.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,i=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,i)}_intersectElevation(e,r,n=0,l=null){if(null==e)return null;const a=this._view,{renderCoordsHelper:c}=a,d=i(a.spatialReference),u=null!=r?r.mode:"absolute-height",g=h(r)/d,f=("on-the-ground"!==u?g+n:0)*d/c.unitInMeters,{camera:m}=a.state;if("absolute-height"===u){const t=c?.getAltitude(m.eye),r=o(s(V,e.direction),c.worldUpAtPosition(m.eye,S));if(t<f&&r<0||t>=f&&r>0)return null;if(c.intersectInfiniteManifold(e,f,V)){const e=p(a,V);return e.z??=0,e.z-=g,e}return null}const w=m.projectToRenderScreen(e.origin,t(y.get())),R=new x(null,this._forEachLayer),P=a.slice.plane,b=P?I(P):null,v=new _(this.viewingMode);v.options.store=0,v.options.verticalOffset=f,v.options.normalRequired=!1;const U=this._createRayIntersectionQuery(e,w,!1);v.reset(U.beginPoint,U.endPoint,m),v.point=w;let j=null;if(l&&"type"in l&&"graphics"===l.type){const e=a.allLayerViews.find(e=>e.layer===l)?.uid;j=e?t=>t.layerViewUid===e:null}else l&&(j=e=>e.graphicUid!==l.uid);switch(u){case"relative-to-scene":{const e=e=>(!j||j(e))&&!!e.lastValidElevationBB;v.intersect(R.layers,U.screenPoint,this._tolerance,null,e),this._intersectRayHandlers(v,R,U,b,!1,e=>2===e.type||7===e.type||8===e.type,!1);break}case"on-the-ground":case"relative-to-ground":this._intersectRayHandlers(v,R,U,b,!1,e=>e.isGround,!1)}if(v.results.min.getIntersectionPoint(V)){const e=p(a,V);return e.z=n,e}return null}computeIntersection(e,r,i,n){if(null==e)return;const s=this._view.state.camera,o=s.projectToRenderScreen(e.origin,t(y.get())),l=new x(n,this._forEachLayer);r.options.selectOpaqueTerrainOnly=!n||!("include"in n||"exclude"in n);const a=this._createRayIntersectionQuery(e,o,i);r.reset(a.beginPoint,a.endPoint,s),r.intersect(l.layers,a.screenPoint,this._tolerance);const c=this._view.slice.plane,d=c?I(c):null;r.intersect(l.sliceableLayers,a.screenPoint,this._tolerance,d);const u=n&&(n.requiresGroundFeedback||n.enableDraped);this._intersectRayHandlers(r,l,a,d,!!u);const h=y.get(),p=this._view,g=p.basemapTerrain;if(n&&n.enableDraped&&null!=g.spatialReference&&r.results.ground.getIntersectionPoint(h)){const e=p.overlayManager.renderer,t=p.renderCoordsHelper.spatialReference,i=y.get();p.renderCoordsHelper.fromRenderCoords(h,i,g.spatialReference),i[2]=p.elevationProvider?.getElevation(h[0],h[1],h[2],t,"ground")??0,e.intersectRay(r,i,r.results.ground,e=>l.filterRenderGeometry(e))}r.sortResults(),this._processHUDResults(r)}_processHUDResults(e){const t=e.results.hud;c(this._tmpRegion,d);const r=new Array,i=this._tmpRegion,n=e=>{r.push(new U(e))};e.sortResults(t.all),null!=t.min.distance&&n(t.min);for(const a of t.all)t.min.target.object!==a.target.object&&t.max.target.object!==a.target.object&&n(a);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&n(t.max),!r.length)return;i[0]===i[2]&&(i[2]+=1),i[1]===i[3]&&(i[3]+=1);let s=!0;const o=null==e.results.max.distance;let l=0;for(const a of r)s&&(e.results.min.copy(a.result),s=!1),o&&e.results.max.copy(a.result),2===e.options.store&&e.results.all.splice(l++,0,a.result)}_createRayIntersectionQuery(e,t,r){return new w(e.origin,n(l(),e.origin,e.direction),t,r)}_intersectRayHandlers(e,t,r,i,n,s=()=>!0,o=!0){const{options:l}=e,a=l.isFiltered,c=l.filteredLayerViewUids;for(const{handler:d,filterPredicate:u,isFiltered:y,filteredLayerViewUids:h}of this._getFilteredIntersectionHandlers(t,i,s,o))(!y||d.isGround&&n)&&(l.isFiltered=y,l.filteredLayerViewUids=h,d.intersectRay(e,u,e.rayBegin,e.rayEnd,r.screenPoint,r.isVerticalRay));l.isFiltered=a,l.filteredLayerViewUids=c}*_intersectPolygonHandlersGenerator(e,t,r,i,n=()=>!0,s=!0){const{options:o}=e,l=o.isFiltered,a=o.filteredLayerViewUids;for(const{handler:c,filterPredicate:d,isFiltered:u,filteredLayerViewUids:y}of this._getFilteredIntersectionHandlers(t,i,n,s))u||null==c.intersectScreenPolygon||(o.isFiltered=u,o.filteredLayerViewUids=y,yield*c.intersectScreenPolygon(e,d,r));o.isFiltered=l,o.filteredLayerViewUids=a}*_getFilteredIntersectionHandlers(e,t,r=()=>!0,i=!0){for(const n of this._externalIntersectionHandlers){if(!r(n))continue;let s=!1;const o=[];if(i){const t=n.layerViewUid,r=n.sublayerId,i=Array.isArray(t),l=i?t:[t];let a=!1;for(const n of l)e.filterLayerViewUid(n,r)?a=!0:i&&o.push(n);s=!a}yield new j(n,n.slicePlaneEnabled?t:null,s,o)}}}class U{constructor(e){this.result=e,this.screenPoint=r()}}class j{constructor(e,t,r,i){this.handler=e,this.filterPredicate=t,this.isFiltered=r,this.filteredLayerViewUids=i}}let L;function H(e){return L&&L.viewingMode===e||(L=new _(e)),L}class x{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:i}=this;if(null==e)return null==r&&null==i;const n=r instanceof Map?r.get(e)??!1:r?.has(e),s=i instanceof Map?i.get(e)??!1:i?.has(e);return(null==n||("boolean"==typeof n?n:null!=t&&n.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function F(e){return"object"==typeof e&&null!=e&&"intersectRay"in e}const V=l(),S=l(),T=r();export{v as SceneIntersectionHelper,F as isIntersectionHandler};
2
+ import e from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as t,createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/units.js";import{add as i,normalize as s,dot as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c,copy as a,negativeInfinity as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as u}from"../../../../geometry/support/ray.js";import{sv3d as y}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as h}from"../../../../support/elevationInfoUtils.js";import{computeMapPointFromVec3d as p}from"../../support/hitTest.js";import{fromRenderAtEye as g,fromScreen as m}from"../../support/geometryUtils/ray.js";import{defaultTolerance as f,Intersector as _,defaultScreenPolygonTriangleProcessor as P}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as w}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as R}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonTriangleProcessor as I,sliceFilterPredicate as b}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as v}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as U}from"../../../support/Scheduler.js";class j{constructor(t,r,n){this.viewingMode=t,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new e,this._tolerance=f,this._tmpRay=u(),this._tmpRegion=c(),this._validateHUDIntersector=new _(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(U.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),x(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,x(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(E,r,n),E[0]+=.0466,E[1]-=.0123,g(e,E,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}async intersectIntersectorScreenPolygon(e,t,r){t.polygonResults.init();const n=this._view.state.camera,i=await v(n,e);null!=i&&await this._screenPolygonIntersectionTask.scheduleGenerator(()=>this._intersectIntersectorScreenPolygon(n,t,i,r))}*_intersectIntersectorScreenPolygon(e,t,r,n){const i=new F(n,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!n||!("include"in n||"exclude"in n),t.camera=e,t.point=null,t.screenPolygonTriangleProcessor=P,yield*t.intersectScreenPolygon(i.layers,r);const s=this._view.slice.plane,o=s?b(s):null,l=s?new I(s):null;t.screenPolygonTriangleProcessor=l??P,yield*t.intersectScreenPolygon(i.sliceableLayers,r),t.screenPolygonTriangleProcessor=P,yield*this._intersectPolygonHandlersGenerator(t,i,r,o,l),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||R(n)&&7!==n.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=f){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return m(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||i(t,e.origin,s(y.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,r,i=0,l=null){if(null==e)return null;const c=this._view,{renderCoordsHelper:a}=c,d=n(c.spatialReference),u=null!=r?r.mode:"absolute-height",g=h(r)/d,m=("on-the-ground"!==u?g+i:0)*d/a.unitInMeters,{camera:f}=c.state;if("absolute-height"===u){const t=a?.getAltitude(f.eye),r=o(s(S,e.direction),a.worldUpAtPosition(f.eye,k));if(t<m&&r<0||t>=m&&r>0)return null;if(a.intersectInfiniteManifold(e,m,S)){const e=p(c,S);return e.z??=0,e.z-=g,e}return null}const P=f.projectToRenderScreen(e.origin,t(y.get())),w=new F(null,this._forEachLayer),R=c.slice.plane,I=R?b(R):null,v=new _(this.viewingMode);v.options.store=0,v.options.verticalOffset=m,v.options.normalRequired=!1;const U=this._createRayIntersectionQuery(e,P,!1);v.reset(U.beginPoint,U.endPoint,f),v.point=P;let j=null;if(l&&"type"in l&&"graphics"===l.type){const e=c.allLayerViews.find(e=>e.layer===l)?.uid;j=e?t=>t.layerViewUid===e:null}else l&&(j=e=>e.graphicUid!==l.uid);switch(u){case"relative-to-scene":{const e=e=>(!j||j(e))&&!!e.lastValidElevationBB;v.intersect(w.layers,U.screenPoint,this._tolerance,null,e),this._intersectRayHandlers(v,w,U,I,!1,e=>2===e.type||7===e.type||8===e.type,!1);break}case"on-the-ground":case"relative-to-ground":this._intersectRayHandlers(v,w,U,I,!1,e=>e.isGround,!1)}if(v.results.min.getIntersectionPoint(S)){const e=p(c,S);return e.z=i,e}return null}computeIntersection(e,r,n,i){if(null==e)return;const s=this._view.state.camera,o=s.projectToRenderScreen(e.origin,t(y.get())),l=new F(i,this._forEachLayer);r.options.selectOpaqueTerrainOnly=!i||!("include"in i||"exclude"in i);const c=this._createRayIntersectionQuery(e,o,n);r.reset(c.beginPoint,c.endPoint,s),r.intersect(l.layers,c.screenPoint,this._tolerance);const a=this._view.slice.plane,d=a?b(a):null;r.intersect(l.sliceableLayers,c.screenPoint,this._tolerance,d);const u=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(r,l,c,d,!!u);const h=y.get(),p=this._view,g=p.basemapTerrain;if(i&&i.enableDraped&&null!=g.spatialReference&&r.results.ground.getIntersectionPoint(h)){const e=p.overlayManager.renderer,t=p.renderCoordsHelper.spatialReference,n=y.get();p.renderCoordsHelper.fromRenderCoords(h,n,g.spatialReference),n[2]=p.elevationProvider?.getElevation(h[0],h[1],h[2],t,"ground")??0,e.intersectRay(r,n,r.results.ground,e=>l.filterRenderGeometry(e))}r.sortResults(),this._processHUDResults(r)}_processHUDResults(e){const t=e.results.hud;a(this._tmpRegion,d);const r=new Array,n=this._tmpRegion,i=e=>{r.push(new L(e))};e.sortResults(t.all),null!=t.min.distance&&i(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&i(c);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&i(t.max),!r.length)return;n[0]===n[2]&&(n[2]+=1),n[1]===n[3]&&(n[3]+=1);let s=!0;const o=null==e.results.max.distance;let l=0;for(const c of r)s&&(e.results.min.copy(c.result),s=!1),o&&e.results.max.copy(c.result),2===e.options.store&&e.results.all.splice(l++,0,c.result)}_createRayIntersectionQuery(e,t,r){return new w(e.origin,i(l(),e.origin,e.direction),t,r)}_intersectRayHandlers(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids;for(const{handler:d,filterPredicate:u,isFiltered:y,filteredLayerViewUids:h}of this._getFilteredIntersectionHandlers(t,n,null,s,o))(!y||d.isGround&&i)&&(l.isFiltered=y,l.filteredLayerViewUids=h,d.intersectRay(e,u,e.rayBegin,e.rayEnd,r.screenPoint,r.isVerticalRay));l.isFiltered=c,l.filteredLayerViewUids=a}*_intersectPolygonHandlersGenerator(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids,d=e.screenPolygonTriangleProcessor;for(const{handler:u,screenPolygonTriangleProcessor:y,isFiltered:h,filteredLayerViewUids:p}of this._getFilteredIntersectionHandlers(t,n,i,s,o))h||null==u.intersectScreenPolygon||(l.isFiltered=h,l.filteredLayerViewUids=p,e.screenPolygonTriangleProcessor=y??P,yield*u.intersectScreenPolygon(e,r));l.isFiltered=c,l.filteredLayerViewUids=a,e.screenPolygonTriangleProcessor=d}*_getFilteredIntersectionHandlers(e,t,r,n=()=>!0,i=!0){for(const s of this._externalIntersectionHandlers){if(!n(s))continue;let o=!1;const l=[];if(i){const t=s.layerViewUid,r=s.sublayerId,n=Array.isArray(t),i=n?t:[t];let c=!1;for(const s of i)e.filterLayerViewUid(s,r)?c=!0:n&&l.push(s);o=!c}yield new T(s,s.slicePlaneEnabled?t:null,s.slicePlaneEnabled?r:null,o,l)}}}class L{constructor(e){this.result=e,this.screenPoint=r()}}class T{constructor(e,t,r,n,i){this.handler=e,this.filterPredicate=t,this.screenPolygonTriangleProcessor=r,this.isFiltered=n,this.filteredLayerViewUids=i}}let H;function x(e){return H&&H.viewingMode===e||(H=new _(e)),H}class F{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:n}=this;if(null==e)return null==r&&null==n;const i=r instanceof Map?r.get(e)??!1:r?.has(e),s=n instanceof Map?n.get(e)??!1:n?.has(e);return(null==i||("boolean"==typeof i?i:null!=t&&i.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function V(e){return"object"==typeof e&&null!=e&&"intersectRay"in e}const S=l(),k=l(),E=r();export{j as SceneIntersectionHelper,V as isIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{glLayout as s}from"../support/buffer/glUtil.js";import{GeometryState as a}from"./GeometryState.js";import{PatchGeometry as o}from"./PatchGeometry.js";import{checkPatchGeometryWaterproofness as n}from"./PatchRenderDataWaterproofness.js";import{maxTileNeighborLevelDelta as l}from"./TerrainConst.js";import{internalAssert as h,neighborEdgeIndices as d,oppositeEdge as u,neighborCornerIndices as m,enableTerrainInternalChecks as g}from"./terrainUtils.js";import{TextureFader as c}from"./TextureFader.js";import{TextureReference as f}from"./TextureReference.js";import y from"./TileOverlayData.js";import{fallsWithinLayerView as _}from"./tileUtils.js";import{VertexArrayObject as p}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as x}from"../../webgl/BufferObject.js";import{VertexBuffer as D}from"../../webgl/VertexBuffer.js";class S{constructor(){this.geometry=new o,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureFader=new c(()=>this._tile.surface.fadeDuration),this.overlay=new y,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new a,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureFader.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),g&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)h(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.groundExtent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,a=d[e];if(!t)return h(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(a)),i;if(t.loaded){const r=t,a=r.renderData.geometryState,o=s-r.level;if(h(o>=0),0===o){const e=a.numVerticesPerSide-1;return Math.max(e,i)}const n=2**o,l=a.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}h(!t.leaf);let o=i;return t.forAllSubtreeOnSide(u(a),e=>e===r||(e.loaded?(o=Math.max(o,2**(e.level-s)),!0):(h(!e.leaf),!1))),o}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<4;++o){const n=e.findNeighborTile(d[o],i),u=v(e,n),m=u?.renderData?.geometryState.samplerDataVersion??-1,c=s[o],f=u!==v(e,c),y=a[o]!==m;g&&n&&(h(e.level>=n.level),h(e.level-n.level<=l)),s[o]=n,(f||y)&&(a[o]=m,this._markEdgeDirty(o));const _=r.edgeResolutions[o],p=this._calculateEdgeResolution(o,n);h(t(p)),h(p>=1),r.edgeResolutions[o]=p,_!==p&&this._markEdgeResolutionDirty(o)}for(let t=0;t<4;++t){const a=e.findNeighborTile(m[t],i);r.cornerPeerNeighbors[t]=a;const o=v(e,s[t]),n=v(e,s[(t+1)%4]),l=v(e,a);C[t]=l,C[(t+1)%4]=n,C[(t+2)%4]=e,C[(t+3)%4]=o,h(C.some(t=>t?.loaded||t===e));const d=C.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);C.forEach((e,t)=>{e&&e?.level>d&&(C[t]=null)}),h(C.some(t=>t?.loaded||t===e));const u=r.cornerNeighborCornerTiles,c=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=C[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,a=u[s]!==r,o=!a&&c[s]!==i;(a||o)&&(u[s]=r,c[s]=i,this._markCornerDirty(t))}g&&h(G.some(r=>u[4*t+r]?.loaded||u[4*t+r]===e))}g&&h(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)C[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;g&&h(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,{vertexAttributes:a}=i,o=!r||!a||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,n=0!==this.dirtyEdgeResolutions,l=s.edgeResolutions.reduce((e,t)=>Math.max(e,t),0)+1,d=o||n&&l>(i?.maxEdgeVertexCount??0),u=!d&&n,m=!u&&(0!==this.dirtyEdges||n),c=!m&&0!==this.dirtyCorners;d?(this.releaseGeometry(),this._createGeometry(e)):u?t.updateEdgeElevationsAndResolutions():m||c?t.updateEdgeElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new f(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&F)}get samplerDataChanged(){return 0!==(this._modifiedFlags&b)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&A)}get wireframeChanged(){return 0!==(this._modifiedFlags&T)}get dirtyEdges(){return this._modifiedFlags>>E&15}get dirtyCorners(){return this._modifiedFlags>>R&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>w&15}_markCornerDirty(e){const t=1<<e<<R;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<E;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<w;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<R|15<<E|15<<w}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(a=null);const o=this.geometryState;let n=!1;o.numVerticesPerSide!==s&&(this._modifiedFlags|=F,o.numVerticesPerSide=s,o.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=b,o.samplerData=t.samplerData,o.samplerDataVersion++,n=!0),e(o.clippingArea,a)||(this._modifiedFlags|=A,o.clippingArea=a,n=!0);const l=r.surface.wireframe;return o.wireframe!==l&&(this._modifiedFlags|=T,o.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new p(e,new D(e,s(t.layout),t.buffer),x.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureFader.push(e,t)}get textureReference(){return this._textureFader.current}get nextTextureReference(){return this._textureFader.next}get textureFadeFactor(){return this._textureFader.fadeFactor}get textureIsFading(){return this._textureFader.isFading}_isTextureVisible(e){return this._textureFader.current?.texture===e||this._textureFader.next?.texture===e&&this._textureFader.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,a=0,o=!1;for(let h=0;h<r;h++){const r=t[h],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][h].data,r=t&&t.samplerData;e&&e[s]===r||(o=!0),i[s++]=r,a=Math.max(a,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(h,0);if(_(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(o=!0),i[s++]=t.samplerData,a=this.tile.level}}}null!=e&&e.length!==s&&(o=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:o,samplerData:l,maxTileLevel:a}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){n(this)}}const C=[null,null,null,null];function v(e,t){return t?.loaded||t===e?t:null}const F=1,b=2,A=4,T=8,E=4,R=8,w=12,G=[0,1,2,3];export{S as PatchRenderData,v as neighborTileIfLoadedOrSelf,G as zeroToFour};
2
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{glLayout as s}from"../support/buffer/glUtil.js";import{GeometryState as a}from"./GeometryState.js";import{PatchGeometry as o}from"./PatchGeometry.js";import{checkPatchGeometryWaterproofness as n}from"./PatchRenderDataWaterproofness.js";import{maxTileNeighborLevelDelta as l}from"./TerrainConst.js";import{internalAssert as h,neighborEdgeIndices as d,oppositeEdge as u,neighborCornerIndices as m,enableTerrainInternalChecks as g}from"./terrainUtils.js";import{TextureFader as c}from"./TextureFader.js";import{TextureReference as f}from"./TextureReference.js";import _ from"./TileOverlayData.js";import{fallsWithinLayerView as y}from"./tileUtils.js";import{VertexArrayObject as p}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as x}from"../../webgl/BufferObject.js";import{VertexBuffer as D}from"../../webgl/VertexBuffer.js";class C{constructor(){this.geometry=new o,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureFader=new c(()=>this._tile.surface.fadeDuration),this.overlay=new _,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new a,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureFader.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),g&&this.tile.intersectsClippingArea)for(let t=0;t<G;++t)h(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.groundExtent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,a=d[e];if(!t)return h(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(a)),i;if(t.loaded){const r=t,a=r.renderData.geometryState,o=s-r.level;if(h(o>=0),0===o){const e=a.numVerticesPerSide-1;return Math.max(e,i)}const n=2**o,l=a.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}h(!t.leaf);let o=i;return t.forAllSubtreeOnSide(u(a),e=>e===r||(e.loaded?(o=Math.max(o,2**(e.level-s)),!0):(h(!e.leaf),!1))),o}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<G;++o){const n=e.findNeighborTile(d[o],i),u=v(e,n),m=u?.renderData?.geometryState.samplerDataVersion??-1,c=s[o],f=u!==v(e,c),_=a[o]!==m;g&&n&&(h(e.level>=n.level),h(e.level-n.level<=l)),s[o]=n,(f||_)&&(a[o]=m,this._markEdgeDirty(o));const y=r.edgeResolutions[o],p=this._calculateEdgeResolution(o,n);h(t(p)),h(p>=1),r.edgeResolutions[o]=p,y!==p&&this._markEdgeResolutionDirty(o)}for(let t=0;t<G;++t){const a=e.findNeighborTile(m[t],i);r.cornerPeerNeighbors[t]=a;const o=v(e,s[t]),n=v(e,s[(t+1)%G]),l=v(e,a);S[t]=l,S[(t+1)%G]=n,S[(t+2)%G]=e,S[(t+3)%G]=o,h(S.some(t=>t?.loaded||t===e));const d=S.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);S.forEach((e,t)=>{e&&e.level>d&&(S[t]=null)}),h(S.some(t=>t?.loaded||t===e));const u=r.cornerNeighborCornerTiles,c=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<G;++e){const r=S[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=t*G+e,a=u[s]!==r,o=!a&&c[s]!==i;(a||o)&&(u[s]=r,c[s]=i,this._markCornerDirty(t))}g&&h(V.some(r=>{const i=u[t*G+r];return i?.loaded||i===e}))}g&&h(r.edgeResolutions.every(e=>e>0));for(let t=0;t<G;++t)S[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;g&&h(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,{vertexAttributes:a}=i,o=!r||!a||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged,n=0!==this.dirtyEdgeResolutions,l=s.edgeResolutions.reduce((e,t)=>Math.max(e,t),0)+1,d=n&&l>i.maxEdgeVertexCount,u=o||this.numVerticesPerSideChanged||d,m=!u&&n,c=!m&&0!==this.dirtyEdges,f=!c&&0!==this.dirtyCorners;u?(this.releaseGeometry(),this._createGeometry(e)):m?t.updateEdgeElevationsAndResolutions():c||f?t.updateEdgeElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new f(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&F)}get samplerDataChanged(){return 0!==(this._modifiedFlags&b)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&A)}get wireframeChanged(){return 0!==(this._modifiedFlags&T)}get dirtyEdges(){return this._modifiedFlags>>E&15}get dirtyCorners(){return this._modifiedFlags>>R&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>w&15}_markCornerDirty(e){const t=1<<e<<R;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<E;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<w;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<R|15<<E|15<<w}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(a=null);const o=this.geometryState;let n=!1;o.numVerticesPerSide!==s&&(this._modifiedFlags|=F,o.numVerticesPerSide=s,o.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=b,o.samplerData=t.samplerData,o.samplerDataVersion++,n=!0),e(o.clippingArea,a)||(this._modifiedFlags|=A,o.clippingArea=a,n=!0);const l=r.surface.wireframe;return o.wireframe!==l&&(this._modifiedFlags|=T,o.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new p(e,new D(e,s(t.layout),t.buffer),x.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureFader.push(e,t)}get textureReference(){return this._textureFader.current}get nextTextureReference(){return this._textureFader.next}get textureFadeFactor(){return this._textureFader.fadeFactor}get textureIsFading(){return this._textureFader.isFading}_isTextureVisible(e){return this._textureFader.current?.texture===e||this._textureFader.next?.texture===e&&this._textureFader.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,a=0,o=!1;for(let h=0;h<r;h++){const r=t[h],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][h].data,r=t&&t.samplerData;e&&e[s]===r||(o=!0),i[s++]=r,a=Math.max(a,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(h,0);if(y(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(o=!0),i[s++]=t.samplerData,a=this.tile.level}}}null!=e&&e.length!==s&&(o=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:o,samplerData:l,maxTileLevel:a}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){n(this)}}const S=[null,null,null,null];function v(e,t){return t?.loaded||t===e?t:null}const F=1,b=2,A=4,T=8,E=4,R=8,w=12,G=4,V=[0,1,2,3];export{C as PatchRenderData,v as neighborTileIfLoadedOrSelf,V as zeroToFour};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{ColorConversion as o}from"./ColorConversion.glsl.js";import{oitResolution as r}from"../../../shaders/oitResolution.glsl.js";function l(l,c){l.include(o),l.include(r,c),l.code.add("\n vec3 emissionFilter(in vec3 srcColor, float srcAlpha) {\n vec3 color = min(srcColor + vec3(1.0 - srcAlpha), 1.0);\n float m = max(color.r, max(color.g, color.b));\n return m > 0.0 ? color / m : vec3(1.0);\n }\n ")}export{l as emissionFilter};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/util/ColorConversion.glsl.js";import"../../core/shaderLibrary/util/emissionFilter.glsl.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"./oitBlendFragment.glsl.js";import"../../shaders/oitResolution.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{O as OITAddEmissionPassParameters,b as build}from"../../../../../chunks/OITAddEmission.glsl.js";
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as s}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as i}from"../../core/shaderTechnique/ShaderTechnique.js";import{a as o}from"../../../../../chunks/OITAddEmission.glsl.js";import{makePipelineState as t,defaultColorWrite as n,add as c}from"../../../../webgl/renderState.js";let d=class extends i{constructor(){super(...arguments),this.shader=new s(o,()=>import("./OITAddEmission.glsl.js"))}initializePipeline(){return t({blending:c,colorWrite:n})}};d=e([r("esri.views.3d.webgl-engine.effects.transparency.OITAddEmissionTechnique")],d);export{d as OITAddEmissionTechnique};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{O as e}from"../../../../../chunks/OITBlendEmission.glsl.js";import{OITBlendEmissionTechnique as i}from"./OITBlendEmissionTechnique.js";import{OITBlendFragmentTechniqueConfiguration as s}from"./OITBlendFragmentTechniqueConfiguration.js";import{OITBlendTechnique as t}from"./OITBlendTechnique.js";import{OITBlendTechniqueConfiguration as n}from"./OITBlendTechniqueConfiguration.js";import{OITDimOpaqueTechnique as o}from"./OITDimOpaqueTechnique.js";import{OITResolutionConfiguration as r}from"../../shaders/oitResolution.glsl.js";import{ColorAttachment1 as a,ColorAttachment2 as u,DrawBufferNone as h}from"../../../../webgl/enums.js";class m{constructor(i){this._techniques=i,this._parameters=new e,this._blendConfiguration=new n,this._dimOpaqueConfiguration=new s,this._blendEmissionConfiguration=new r}precompile(e,s,n){this._updateConfigurations(e,s,n);const{hasTransparentEmission:r,hasOpaqueEmission:a}=e;a&&1!==n&&this._techniques.precompile(o,this._dimOpaqueConfiguration),this._techniques.precompile(t,this._blendConfiguration),r&&0===n&&this._techniques.precompile(i,this._blendEmissionConfiguration)}blend(e,s,n,r,m,f,p){this._updateConfigurations(r,m,f),this._parameters.colorTexture=s.getTexture(),this._parameters.alphaTexture=s.getTexture(a),this._parameters.emissionTexture=s.getTexture(u),this._parameters.frontFaceTexture=n.getTexture(),this._parameters.frontFaceEmissionTexture=n.getTexture(a);const c=e.drawBuffers,{hasOpaqueEmission:l,hasTransparentEmission:d}=r;if(l&&1!==f){const i=this._techniques.get(o,this._dimOpaqueConfiguration);e.bindTechnique(i,r,this._parameters),e.setDrawBuffers([h,a]),e.screen.draw(),p?.("oit opaque emission color",e.boundFramebuffer)}const _=this._techniques.get(t,this._blendConfiguration);if(e.bindTechnique(_,r,this._parameters),!l&&d){const i=c.slice();i[1]=h,e.setDrawBuffers(i),e.screen.draw()}else e.setDrawBuffers(c),e.screen.draw();if(p?.("oit composited",e.boundFramebuffer),d&&0===f){const s=this._techniques.get(i,this._blendEmissionConfiguration);e.bindTechnique(s,r,this._parameters),e.setDrawBuffers([h,a]),e.screen.draw(),p?.("oit transparent emission",e.boundFramebuffer)}e.setDrawBuffers(c)}_updateConfigurations(e,i,s){this._blendConfiguration.useFloatBlend=this._dimOpaqueConfiguration.useFloatBlend=this._blendEmissionConfiguration.useFloatBlend=e.useFloatBlend.value,this._blendConfiguration.computeHudOcclusion=i,this._blendConfiguration.hasOpaqueEmission=0===s&&e.hasOpaqueEmission,this._blendConfiguration.hasEmissionAttachment=0===s&&0!==e.emissions,this._blendConfiguration.frontFaceMask=1===s}}export{m as OITBlend};
2
+ import{O as e}from"../../../../../chunks/OITAddEmission.glsl.js";import{OITAddEmissionTechnique as i}from"./OITAddEmissionTechnique.js";import{OITBlendFragmentTechniqueConfiguration as s}from"./OITBlendFragmentTechniqueConfiguration.js";import{OITBlendTechnique as t}from"./OITBlendTechnique.js";import{OITBlendTechniqueConfiguration as n}from"./OITBlendTechniqueConfiguration.js";import{OITFilterOpaqueTechnique as r}from"./OITFilterOpaqueTechnique.js";import{OITResolutionConfiguration as o}from"../../shaders/oitResolution.glsl.js";import{ColorAttachment1 as a,ColorAttachment2 as u,DrawBufferNone as h}from"../../../../webgl/enums.js";class f{constructor(i){this._techniques=i,this._parameters=new e,this._blendConfiguration=new n,this._filterOpaqueConfiguration=new s,this._addEmissionConfiguration=new o}precompile(e,s,n){this._updateConfigurations(e,s,n);const{hasTransparentEmission:o,hasOpaqueEmission:a}=e;a&&1!==n&&this._techniques.precompile(r,this._filterOpaqueConfiguration),this._techniques.precompile(t,this._blendConfiguration),o&&0===n&&this._techniques.precompile(i,this._addEmissionConfiguration)}blend(e,s,n,o,f,m,d){this._updateConfigurations(o,f,m),this._parameters.colorTexture=s.getTexture(),this._parameters.alphaTexture=s.getTexture(a),this._parameters.emissionTexture=s.getTexture(u),this._parameters.frontFaceTexture=n.getTexture(),this._parameters.frontFaceEmissionTexture=n.getTexture(a);const p=e.drawBuffers,{hasOpaqueEmission:c,hasTransparentEmission:l}=o;if(c&&1!==m){const i=this._techniques.get(r,this._filterOpaqueConfiguration);e.bindTechnique(i,o,this._parameters),e.setDrawBuffers([h,a]),e.screen.draw(),d?.("oit opaque emission filter",e.boundFramebuffer)}const _=this._techniques.get(t,this._blendConfiguration);if(e.bindTechnique(_,o,this._parameters),!c&&l){const i=p.slice();i[1]=h,e.setDrawBuffers(i),e.screen.draw()}else e.setDrawBuffers(p),e.screen.draw();if(d?.("oit composited",e.boundFramebuffer),l&&0===m){const s=this._techniques.get(i,this._addEmissionConfiguration);e.bindTechnique(s,o,this._parameters),e.setDrawBuffers([h,a]),e.screen.draw(),d?.("oit transparent emission",e.boundFramebuffer)}e.setDrawBuffers(p)}_updateConfigurations(e,i,s){this._blendConfiguration.useFloatBlend=this._filterOpaqueConfiguration.useFloatBlend=this._addEmissionConfiguration.useFloatBlend=e.useFloatBlend.value,this._blendConfiguration.computeHudOcclusion=i,this._blendConfiguration.hasOpaqueEmission=0===s&&e.hasOpaqueEmission,this._blendConfiguration.hasEmissionAttachment=0===s&&0!==e.emissions,this._blendConfiguration.frontFaceMask=1===s}}export{f as OITBlend};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/util/emissionFilter.glsl.js";import"../../core/shaderModules/glsl.js";import"./oitBlendFragment.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../chunks/OITFilterOpaque.glsl.js";
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as i}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../../core/shaderTechnique/ShaderTechnique.js";import{O as o}from"../../../../../chunks/OITFilterOpaque.glsl.js";import{makePipelineState as t,defaultColorWrite as a,modulateDestination as l}from"../../../../webgl/renderState.js";let n=class extends s{constructor(){super(...arguments),this.shader=new i(o,()=>import("./OITFilterOpaque.glsl.js"))}initializePipeline(){return t({blending:l,colorWrite:a})}};n=e([r("esri.views.3d.webgl-engine.effects.transparency.OITFilterOpaqueTechnique")],n);export{n as OITFilterOpaqueTechnique};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{add as t,transformMat4 as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as i}from"../../../../geometry/support/frustum.js";import{create as r,fromPoints as n,copy as o}from"../../../../geometry/support/ray.js";import a from"../../webgl/RenderCamera.js";import{HUDTarget as l,HUDIntersectorResult as h}from"./HUDIntersectorResult.js";import{IntersectorOptions as c}from"./IntersectorInterfaces.js";import{IntersectorResult as f,compareOrderedIntersectionHits as m}from"./IntersectorResult.js";import{ObjectTarget as u}from"./ObjectTarget.js";import{PolygonIntersectionResults as d}from"./PolygonIntersectionResults.js";import{IntersectorTransform as y,getVerticalOffsetObject3D as g}from"./verticalOffsetUtils.js";const _=1e-5;class p{constructor(t){this.options=new c,this._results=new b,this.polygonResults=new d,this.transform=new y,this.camera=new a,this.tolerance=_,this.verticalOffset=null,this._ray=r(),this._rayEnd=s(),this._rayBeginTransformed=s(),this._rayEndTransformed=s(),this.viewingMode=t??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,e,s){this.resetWithRay(n(t,e,this._ray),s)}resetWithRay(e,s){this.camera=s,e!==this._ray&&o(e,this._ray),0!==this.options.verticalOffset?2===this.viewingMode?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,t(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(t=null,e,s,i,r){this.point=e,this.filterPredicate=i,this.tolerance=s??_;const n=g(this.verticalOffset);if(t&&t.length>0){const e=r?t=>{r(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const s of t){const t=s.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,e,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,e),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(e)):s.objects.forEach(t=>e(t))}}this.sortResults()}*intersectScreenPolygon(t=null,e,s){if(this.filterPredicate=s,this.verticalOffset=null,t?.length)for(const r of t){const t=r.getSpatialQueryAccelerator?.();if(null!=t)for(const s of t.intersectingFrustumValues(e.broadPhaseFrustum,t=>t.visible))yield*this._intersectScreenPolygonObject(s,e);else for(const s of r.objects.values())s.visible&&i(e.broadPhaseFrustum,s.boundingVolumeWorldSpace.bounds)&&(yield*this._intersectScreenPolygonObject(s,e))}}*_intersectScreenPolygonObject(t,e){const s=t.geometries;if(!s)return;const i=t.effectiveTransformation;for(const r of s){if(!r.visible)continue;const{material:s,id:n}=r;s.visible&&s.intersectScreenPolygon&&(this.transform.setAndInvalidateLazyTransforms(i,r.transformation),s.intersectScreenPolygon(r,this.transform.transform,this,e,(e,s,i,r)=>this._handleObjectScreenPolygonIntersection(new u(t,n,s),e,i,r)),yield)}}intersectObject(t){const s=t.geometries;if(!s)return;const i=t.effectiveTransformation,r=g(this.verticalOffset);for(const n of s){if(!n.visible)continue;const{material:s,id:o}=n;if(!s.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),e(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),e(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const a=this.transform.transform;null!=r&&(r.objectTransform=this.transform),s.intersectRay(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(e,s,i,r)=>this.handleObjectIntersection({object:t,geometryId:o,primitiveIndex:i},e,s,a,r))}}handleObjectIntersection(t,e,s,i,r){if(e<0||null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,e))return;const n=r?this._results.hud:this._results;t=r?new l(t,r):t;const o=r?i=>i.set(1,t,e,s):r=>r.set(4,t,e,s,i);if((null==n.min.distance||e<n.min.distance)&&o(n.min),0!==this.options.store&&(null==n.max.distance||e>n.max.distance)&&o(n.max),2===this.options.store)if(r){const t=new h(this._ray);o(t),this._results.hud.all.push(t)}else{const t=new f(this._ray);o(t),this._results.all.push(t)}}_handleObjectScreenPolygonIntersection(t,e,s,i){e<0||(null==this.filterPredicate||null!=s&&this.filterPredicate(this.camera.eye,s,1))&&this.polygonResults.add(i?1:4,i?new l(t,i):t,e)}sortResults(t=this._results.all){t.sort(m)}}class b{constructor(){this.min=new f(r()),this.max=new f(r()),this.hud={min:new h(r()),max:new h(r()),all:new Array},this.ground=new f(r()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}export{p as Intersector,_ as defaultTolerance};
2
+ import{add as t,transformMat4 as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as i}from"../../../../geometry/support/frustum.js";import{create as r,fromPoints as n,copy as o}from"../../../../geometry/support/ray.js";import a from"../../webgl/RenderCamera.js";import{HUDTarget as l,HUDIntersectorResult as c}from"./HUDIntersectorResult.js";import{IntersectorOptions as h}from"./IntersectorInterfaces.js";import{IntersectorResult as f,compareOrderedIntersectionHits as m}from"./IntersectorResult.js";import{ObjectTarget as u}from"./ObjectTarget.js";import{PolygonIntersectionResults as d}from"./PolygonIntersectionResults.js";import{IntersectorTransform as y,getVerticalOffsetObject3D as g}from"./verticalOffsetUtils.js";const _=1e-5;class p{constructor(t){this.options=new h,this._results=new b,this.polygonResults=new d,this.transform=new y,this.camera=new a,this.screenPolygonTriangleProcessor=v,this.tolerance=_,this.verticalOffset=null,this._ray=r(),this._rayEnd=s(),this._rayBeginTransformed=s(),this._rayEndTransformed=s(),this.viewingMode=t??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,e,s){this.resetWithRay(n(t,e,this._ray),s)}resetWithRay(e,s){this.camera=s,e!==this._ray&&o(e,this._ray),0!==this.options.verticalOffset?2===this.viewingMode?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,t(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(t=null,e,s,i,r){this.point=e,this.filterPredicate=i,this.tolerance=s??_;const n=g(this.verticalOffset);if(t&&t.length>0){const e=r?t=>{r(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const s of t){const t=s.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,e,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,e),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(e)):s.objects.forEach(t=>e(t))}}this.sortResults()}*intersectScreenPolygon(t=null,e){if(this.verticalOffset=null,t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.();if(null!=t)for(const s of t.intersectingFrustumValues(e.broadPhaseFrustum,t=>t.visible))yield*this._intersectScreenPolygonObject(s,e);else for(const r of s.objects.values())r.visible&&i(e.broadPhaseFrustum,r.boundingVolumeWorldSpace.bounds)&&(yield*this._intersectScreenPolygonObject(r,e))}}*_intersectScreenPolygonObject(t,e){const s=t.geometries;if(!s)return;const i=t.effectiveTransformation;for(const r of s){if(!r.visible)continue;const{material:s,id:n}=r;if(!s.visible||!s.intersectScreenPolygon)continue;this.transform.setAndInvalidateLazyTransforms(i,r.transformation);const o=s.intersectScreenPolygon(r,this.transform.transform,this,e);null!=o&&this._handleObjectScreenPolygonIntersection(new u(t,n,o.primitiveIndex),o.distance,o.point),yield}}intersectObject(t){const s=t.geometries;if(!s)return;const i=t.effectiveTransformation,r=g(this.verticalOffset);for(const n of s){if(!n.visible)continue;const{material:s,id:o}=n;if(!s.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),e(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),e(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const a=this.transform.transform;null!=r&&(r.objectTransform=this.transform),s.intersectRay(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(e,s,i,r)=>this.handleObjectIntersection({object:t,geometryId:o,primitiveIndex:i},e,s,a,r))}}handleObjectIntersection(t,e,s,i,r){if(e<0||null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,e))return;const n=r?this._results.hud:this._results;t=r?new l(t,r):t;const o=r?i=>i.set(1,t,e,s):r=>r.set(4,t,e,s,i);if((null==n.min.distance||e<n.min.distance)&&o(n.min),0!==this.options.store&&(null==n.max.distance||e>n.max.distance)&&o(n.max),2===this.options.store)if(r){const t=new c(this._ray);o(t),this._results.hud.all.push(t)}else{const t=new f(this._ray);o(t),this._results.all.push(t)}}_handleObjectScreenPolygonIntersection(t,e,s,i){e<0||(null==this.filterPredicate||null!=s&&this.filterPredicate(this.camera.eye,s,1))&&this.polygonResults.add(i?1:4,i?new l(t,i):t,e)}sortResults(t=this._results.all){t.sort(m)}}class b{constructor(){this.min=new f(r()),this.max=new f(r()),this.hud={min:new c(r()),max:new c(r()),all:new Array},this.ground=new f(r()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}const v={*processTriangle(t,e){t.list=e,t.count=e.length,yield t}};export{p as Intersector,v as defaultScreenPolygonTriangleProcessor,_ as defaultTolerance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{lerp as n,squaredDistance as r,scale as i,add as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as h}from"../../../../geometry/support/frustum.js";import{wrap as d}from"../../../../geometry/support/ray.js";import{Sphere as c}from"../../../../geometry/support/sphere.js";import{rayBoxTest as u}from"./Util.js";class l{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new f,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),f.clearPool(),D[0]=null,V.prune(),W.prune()}add(e){const t=Array.from(e);this._grow(t);const n=f.acquire();for(const r of t)++this._objectCount,this._isDegenerate(r)?this._degenerateObjects.add(r):(n.init(this._root),this._add(r,n));f.release(n)}remove(e,t=null){this._objectCount-=e.length;const n=f.acquire();for(const r of e){const e=t??this.objectToBoundingSphere(r);v(e.radius)?(n.init(this._root),b(r,e,n)):this._degenerateObjects.delete(r)}f.release(n),this._shrink()}update(e,t){if(!v(t.radius)&&this._isDegenerate(e))return;const n=R(e);this.remove(n,t),this.add(n)}forEachAlongRay(e,t,n){const r=d(e,t);_(this._root,e=>{if(!S(r,e))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),!0})}forEachAlongRayWithVerticalOffset(e,t,n,r){const i=d(e,t);_(this._root,e=>{if(!j(i,e,r))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),!0})}forEach(e){for(const t of this.values())e(t)}*values(){for(const e of this._nodeIteratorValues()){const t=e.node;yield*t.terminals,null!==t.residents&&(yield*t.residents)}yield*this.degenerateObjectValues()}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}*degenerateObjectValues(){yield*this._degenerateObjects.values()}findClosest(e,t,n,r=()=>!0,o=1/0){let a=1/0,d=1/0,c=null;const u=B(e,t),l=i=>{if(--o,!r(i))return;const s=this.objectToBoundingSphere(i);if(!h(n,s))return;const u=N(e,t,s.center),l=u-s.radius,f=u+s.radius;l<a&&(a=l,d=f,c=i)};return p(this._root,r=>{if(o<=0||!h(n,r.bounds))return!1;i(q,u,r.halfSize),s(q,q,r.bounds.center);if(N(e,t,q)>d)return!1;const a=r.node;return a.terminals.forAll(e=>l(e)),null!==a.residents&&a.residents.forAll(e=>l(e)),!0},e,t),c}forEachInDepthRange(e,t,n,r,o,a,d){let c=-1/0,u=1/0;const l={setRange:e=>{1===n?(c=Math.max(c,e.near),u=Math.min(u,e.far)):(c=Math.max(c,-e.far),u=Math.min(u,-e.near))}};l.setRange(r);const f=N(t,n,e),m=B(t,n),_=B(t,-n),b=e=>{if(!d(e))return;const r=this.objectToBoundingSphere(e),i=N(t,n,r.center)-f,s=i-r.radius,m=i+r.radius;s>u||m<c||!h(a,r)||o(e,l)};p(this._root,e=>{if(!h(a,e.bounds))return!1;i(q,m,e.halfSize),s(q,q,e.bounds.center);if(N(t,n,q)-f>u)return!1;i(q,_,e.halfSize),s(q,q,e.bounds.center);if(N(t,n,q)-f<c)return!1;const r=e.node;return r.terminals.forAll(e=>b(e)),null!==r.residents&&r.residents.forAll(e=>b(e)),!0},t,n)}forEachNode(e){_(this._root,t=>e(t.node,t.bounds,t.halfSize,t.depth))}forEachIntersectingFrustum(e,t,n=()=>!0){for(const r of this.intersectingFrustumValues(e,n))t(r)}*intersectingFrustumValues(e,t=()=>!0){for(const n of this._nodeIteratorValues(t=>h(e,t.bounds))){const r=n.node;for(const n of r.terminals)t(n)&&h(e,this.objectToBoundingSphere(n))&&(yield n);if(null!==r.residents)for(const n of r.residents)t(n)&&h(e,this.objectToBoundingSphere(n))&&(yield n)}}*_nodeIteratorValues(e=()=>!0){yield*m(this._root,e)}forEachNeighbor(e,t){const n=t.radius,i=t.center,s=t=>{const s=this.objectToBoundingSphere(t),o=s.radius,a=n+o;return!(r(s.center,i)-a*a<=0)||e(t)};let o=!0;const a=e=>{o&&(o=s(e))};_(this._root,e=>{const t=e.bounds.radius,s=n+t;if(r(e.bounds.center,i)-s*s>0)return!1;const h=e.node;return h.terminals.forAll(a),o&&null!==h.residents&&h.residents.forAll(a),o}),o&&this.forEachDegenerateObject(a)}_intersectsObject(e,t){const n=this.objectToBoundingSphere(t);return!(n.radius>0)||n.intersectRay(e)}_intersectsObjectWithOffset(e,t,n){const r=this.objectToBoundingSphere(t);return!(r.radius>0)||n.applyToBoundingSphere(r).intersectRay(e)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let n=0;n<t.length;n++){const r=f.acquire().init(e);this._add(t.at(n),r),f.release(r)}}_grow(e){if(T(e,e=>this.objectToBoundingSphere(e),k),v(k.radius)&&!this._fitsInsideTree(k))if(x(this._root.node))this._root.bounds.copyFrom(k),this._root.halfSize=1.25*this._root.bounds.radius,this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(k);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(k,e):this._growRootAsSubNode(e),f.release(e)}}_rebuildTree(e,t){L.center=t.bounds.center,L.radius=t.halfSize,T([e,L],e=>e,C);const n=f.acquire().init(this._root);this._root.initFrom(null,C,C.radius),this._root.increaseHalfSize(1.25),_(n,e=>(this.add(e.node.terminals.data),null!==e.node.residents&&this.add(e.node.residents.data),!0)),f.release(n)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return _(this._root,e=>(n=Math.max(n,e.depth),n+t<=this._maximumDepth)),n+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e.radius,n=e.center;let r=-1/0;const i=this._root.bounds.center,s=this._root.halfSize;for(let a=0;a<3;a++){const e=i[a]-s-(n[a]-t),o=n[a]+t-(i[a]+s),h=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(o/(2*s)))+1,c=2**Math.ceil(Math.log(h+d)*Math.LOG2E);r=Math.max(r,c),H[a].min=h,H[a].max=d}for(let a=0;a<3;a++){let e=H[a].min,t=H[a].max;const n=(r-(e+t))/2;e+=Math.ceil(n),t+=Math.floor(n);const o=i[a]-s-e*s*2;E.center[a]=o+(t+e)*s}const o=r*s;return E.radius=o*F,f.acquire().initFrom(null,E,o,0)}_growRootAsSubNode(e){const t=this._root.node;k.center=this._root.bounds.center,k.radius=this._root.halfSize,this._root.init(e),e.advanceTo(k,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let n=0,r=0;for(;r<t.length&&null==e;)n=r++,e=t[n];for(;r<t.length;)if(t[r++])return-1;return n}_isDegenerate(e){return!v(this.objectToBoundingSphere(e).radius)}_fitsInsideTree(e){const t=this._root.bounds,n=this._root.halfSize;return e.radius<=n&&e.center[0]>=t.center[0]-n&&e.center[0]<=t.center[0]+n&&e.center[1]>=t.center[1]-n&&e.center[1]<=t.center[1]+n&&e.center[2]>=t.center[2]-n&&e.center[2]<=t.center[2]+n}_nodeToJSON(e){const t=e.children.map(e=>e?this._nodeToJSON(e):null),n=e.residents?.map(e=>this.objectToBoundingSphere(e)),r=e.terminals?.map(e=>this.objectToBoundingSphere(e));return{children:t,residents:n,terminals:r}}}class f{constructor(){this.bounds=new c,this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,n,r=this.depth){return this.node=null!=e?e:f.createEmptyNode(),t&&this.bounds.copyFrom(t),this.halfSize=n,this.depth=r,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds.radius=this.halfSize*F}advance(e){let t=this.node.children[e];t||(t=f.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const n=w[e];return this.bounds.center[0]+=n[0]*this.halfSize,this.bounds.center[1]+=n[1]*this.halfSize,this.bounds.center[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,n=!1){for(;;){if(this.isTerminalFor(e))return t?.(this,-1),!0;if(this.isLeaf()){if(!n)return t?.(this,-1),!1;this.node.residents=null}const r=this._childIndex(e);t?.(this,r),this.advance(r)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e.radius>this.halfSize/2}_childIndex(e){const t=this.bounds.center;return(t[0]<e.center[0]?1:0)+(t[1]<e.center[1]?2:0)+(t[2]<e.center[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static{this._pool=new e(()=>new f)}static acquire(){return f._pool.acquire()}static release(e){f._pool.release(e)}static clearPool(){f._pool.prune()}}function*m(e,t=()=>!0){const n=[f.acquire().init(e)];for(;0!==n.length;){const e=n.pop();if(t(e)){if(yield e,!e.isLeaf())for(let t=0;t<e.node.children.length;t++){e.node.children[t]&&n.push(f.acquire().init(e).advance(t))}f.release(e)}}}function _(e,t){const n=m(e,t);for(const r of n);}function p(e,t,n,r=1){let i=f.acquire().init(e);const s=[i];for(y(n,r,G);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=G[e];i.node.children[t]&&s.push(f.acquire().init(i).advance(t))}f.release(i)}}function b(e,t,n){V.clear();const r=n.advanceTo(t,(e,t)=>{V.push(e.node),V.push(t)})?n.node.terminals:n.node.residents;if(r.removeUnordered(e),0===r.length)for(let i=V.length-2;i>=0;i-=2){if(!g(V.data[i],V.data[i+1]))break}}function g(e,n){return n>=0&&(e.children[n]=null),!!x(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}function S(e,t){return M(t.bounds.center,2*-t.halfSize,I),M(t.bounds.center,2*t.halfSize,P),u(e.origin,e.direction,I,P)}function j(e,t,n){return M(t.bounds.center,2*-t.halfSize,I),M(t.bounds.center,2*t.halfSize,P),n.applyToMinMax(I,P),u(e.origin,e.direction,I,P)}function x(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}function z(e,t){e[0]=Math.min(e[0],t.center[0]-t.radius),e[1]=Math.min(e[1],t.center[1]-t.radius),e[2]=Math.min(e[2],t.center[2]-t.radius)}function O(e,t){e[0]=Math.max(e[0],t.center[0]+t.radius),e[1]=Math.max(e[1],t.center[1]+t.radius),e[2]=Math.max(e[2],t.center[2]+t.radius)}function M(e,t,n){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function T(e,t,r){I[0]=1/0,I[1]=1/0,I[2]=1/0,P[0]=-1/0,P[1]=-1/0,P[2]=-1/0;for(const n of e){const e=t(n);v(e.radius)&&(z(I,e),O(P,e))}n(r.center,I,P,.5),r.radius=Math.max(P[0]-I[0],P[1]-I[1],P[2]-I[2])/2}function y(e,t,n){if(!W.length)for(let r=0;r<8;++r)W.push({index:0,distance:0});for(let r=0;r<8;++r){const n=w[r];W.data[r].index=r,W.data[r].distance=N(e,t,n)}W.sort((e,t)=>e.distance-t.distance);for(let r=0;r<8;++r)n[r]=W.data[r].index}function B(e,t){let n,r=1/0;for(let i=0;i<8;++i){const s=N(e,t,A[i]);s<r&&(r=s,n=A[i])}return n}function N(e,t,n){return t*(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])}function v(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}const w=[o(-1,-1,-1),o(1,-1,-1),o(-1,1,-1),o(1,1,-1),o(-1,-1,1),o(1,-1,1),o(-1,1,1),o(1,1,1)],A=[o(-1,-1,-1),o(-1,-1,1),o(-1,1,-1),o(-1,1,1),o(1,-1,-1),o(1,-1,1),o(1,1,-1),o(1,1,1)],F=Math.sqrt(3),D=[null];function R(e){return D[0]=e,D}const E=new c,q=a(),I=a(),P=a(),V=new t,k=new c,L=new c,C=new c,H=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],W=new t,G=[0,0,0,0,0,0,0,0];export{l as Octree};
2
+ import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{lerp as n,squaredDistance as r,scale as i,add as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphereCenterRadius as h,intersectsSphere as d}from"../../../../geometry/support/frustum.js";import{wrap as u}from"../../../../geometry/support/ray.js";import{Sphere as c}from"../../../../geometry/support/sphere.js";import{rayBoxTest as l}from"./Util.js";class f{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new m,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),m.clearPool(),R[0]=null,k.prune(),G.prune()}add(e){const t=Array.from(e);this._grow(t);const n=m.acquire();for(const r of t)++this._objectCount,this._isDegenerate(r)?this._degenerateObjects.add(r):(n.init(this._root),this._add(r,n));m.release(n)}remove(e,t=null){this._objectCount-=e.length;const n=m.acquire();for(const r of e){const e=t??this.objectToBoundingSphere(r);w(e.radius)?(n.init(this._root),g(r,e,n)):this._degenerateObjects.delete(r)}m.release(n),this._shrink()}update(e,t){if(!w(t.radius)&&this._isDegenerate(e))return;const n=E(e);this.remove(n,t),this.add(n)}forEachAlongRay(e,t,n){const r=u(e,t);p(this._root,e=>{if(!j(r,e))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),!0})}forEachAlongRayWithVerticalOffset(e,t,n,r){const i=u(e,t);p(this._root,e=>{if(!x(i,e,r))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),!0})}forEach(e){for(const t of this.values())e(t)}*values(){for(const e of this._nodeIteratorValues()){const t=e.node;yield*t.terminals,null!==t.residents&&(yield*t.residents)}yield*this.degenerateObjectValues()}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}*degenerateObjectValues(){yield*this._degenerateObjects.values()}findClosest(e,t,n,r=()=>!0,o=1/0){let a=1/0,u=1/0,c=null;const l=N(e,t),f=i=>{if(--o,!r(i))return;const s=this.objectToBoundingSphere(i);if(!d(n,s))return;const h=v(e,t,s.center),l=h-s.radius,f=h+s.radius;l<a&&(a=l,u=f,c=i)};return b(this._root,r=>{if(o<=0||!h(n,r.bounds.center,2*r.bounds.radius))return!1;i(I,l,2*r.halfSize),s(I,I,r.bounds.center);if(v(e,t,I)>u)return!1;const a=r.node;return a.terminals.forAll(e=>f(e)),null!==a.residents&&a.residents.forAll(e=>f(e)),!0},e,t),c}forEachInDepthRange(e,t,n,r,o,a,u){let c=-1/0,l=1/0;const f={setRange:e=>{1===n?(c=Math.max(c,e.near),l=Math.min(l,e.far)):(c=Math.max(c,-e.far),l=Math.min(l,-e.near))}};f.setRange(r);const m=v(t,n,e),_=N(t,n),p=N(t,-n),g=e=>{if(!u(e))return;const r=this.objectToBoundingSphere(e),i=v(t,n,r.center)-m,s=i-r.radius,h=i+r.radius;s>l||h<c||!d(a,r)||o(e,f)};b(this._root,e=>{if(!h(a,e.bounds.center,2*e.bounds.radius))return!1;i(I,_,2*e.halfSize),s(I,I,e.bounds.center);if(v(t,n,I)-m>l)return!1;i(I,p,2*e.halfSize),s(I,I,e.bounds.center);if(v(t,n,I)-m<c)return!1;const r=e.node;return r.terminals.forAll(e=>g(e)),null!==r.residents&&r.residents.forAll(e=>g(e)),!0},t,n)}forEachNode(e){p(this._root,t=>e(t.node,t.bounds,t.halfSize,t.depth))}forEachIntersectingFrustum(e,t,n=()=>!0){for(const r of this.intersectingFrustumValues(e,n))t(r)}*intersectingFrustumValues(e,t=()=>!0){for(const n of this._nodeIteratorValues(t=>h(e,t.bounds.center,2*t.bounds.radius))){const r=n.node;for(const n of r.terminals)t(n)&&d(e,this.objectToBoundingSphere(n))&&(yield n);if(null!==r.residents)for(const n of r.residents)t(n)&&d(e,this.objectToBoundingSphere(n))&&(yield n)}}*_nodeIteratorValues(e=()=>!0){yield*_(this._root,e)}forEachNeighbor(e,t){const n=t.radius,i=t.center,s=t=>{const s=this.objectToBoundingSphere(t),o=s.radius,a=n+o;return!(r(s.center,i)-a*a<=0)||e(t)};let o=!0;const a=e=>{o&&(o=s(e))};p(this._root,e=>{const t=2*e.bounds.radius,s=n+t;if(r(e.bounds.center,i)-s*s>0)return!1;const h=e.node;return h.terminals.forAll(a),o&&null!==h.residents&&h.residents.forAll(a),o}),o&&this.forEachDegenerateObject(a)}_intersectsObject(e,t){const n=this.objectToBoundingSphere(t);return!(n.radius>0)||n.intersectRay(e)}_intersectsObjectWithOffset(e,t,n){const r=this.objectToBoundingSphere(t);return!(r.radius>0)||n.applyToBoundingSphere(r).intersectRay(e)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let n=0;n<t.length;n++){const r=m.acquire().init(e);this._add(t.at(n),r),m.release(r)}}_grow(e){if(y(e,e=>this.objectToBoundingSphere(e),L),w(L.radius)&&!this._fitsInsideTree(L))if(z(this._root.node))this._root.bounds.copyFrom(L),this._root.halfSize=1.25*this._root.bounds.radius,this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(L);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(L,e):this._growRootAsSubNode(e),m.release(e)}}_rebuildTree(e,t){C.center=t.bounds.center,C.radius=t.halfSize,y([e,C],e=>e,H);const n=m.acquire().init(this._root);this._root.initFrom(null,H,H.radius),this._root.increaseHalfSize(1.25),p(n,e=>(this.add(e.node.terminals.data),null!==e.node.residents&&this.add(e.node.residents.data),!0)),m.release(n)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return p(this._root,e=>(n=Math.max(n,e.depth),n+t<=this._maximumDepth)),n+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e.radius,n=e.center;let r=-1/0;const i=this._root.bounds.center,s=this._root.halfSize;for(let a=0;a<3;a++){const e=i[a]-s-(n[a]-t),o=n[a]+t-(i[a]+s),h=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(o/(2*s)))+1,u=2**Math.ceil(Math.log(h+d)*Math.LOG2E);r=Math.max(r,u),W[a].min=h,W[a].max=d}for(let a=0;a<3;a++){let e=W[a].min,t=W[a].max;const n=(r-(e+t))/2;e+=Math.ceil(n),t+=Math.floor(n);const o=i[a]-s-e*s*2;q.center[a]=o+(t+e)*s}const o=r*s;return q.radius=o*D,m.acquire().initFrom(null,q,o,0)}_growRootAsSubNode(e){const t=this._root.node;L.center=this._root.bounds.center,L.radius=this._root.halfSize,this._root.init(e),e.advanceTo(L,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let n=0,r=0;for(;r<t.length&&null==e;)n=r++,e=t[n];for(;r<t.length;)if(t[r++])return-1;return n}_isDegenerate(e){return!w(this.objectToBoundingSphere(e).radius)}_fitsInsideTree(e){const t=this._root.bounds,n=this._root.halfSize;return e.radius<=n&&e.center[0]>=t.center[0]-n&&e.center[0]<=t.center[0]+n&&e.center[1]>=t.center[1]-n&&e.center[1]<=t.center[1]+n&&e.center[2]>=t.center[2]-n&&e.center[2]<=t.center[2]+n}_nodeToJSON(e){const t=e.children.map(e=>e?this._nodeToJSON(e):null),n=e.residents?.map(e=>this.objectToBoundingSphere(e)),r=e.terminals?.map(e=>this.objectToBoundingSphere(e));return{children:t,residents:n,terminals:r}}}class m{constructor(){this.bounds=new c,this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,n,r=this.depth){return this.node=null!=e?e:m.createEmptyNode(),t&&this.bounds.copyFrom(t),this.halfSize=n,this.depth=r,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds.radius=this.halfSize*D}advance(e){let t=this.node.children[e];t||(t=m.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const n=A[e];return this.bounds.center[0]+=n[0]*this.halfSize,this.bounds.center[1]+=n[1]*this.halfSize,this.bounds.center[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,n=!1){for(;;){if(this.isTerminalFor(e))return t?.(this,-1),!0;if(this.isLeaf()){if(!n)return t?.(this,-1),!1;this.node.residents=null}const r=this._childIndex(e);t?.(this,r),this.advance(r)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e.radius>this.halfSize/2}_childIndex(e){const t=this.bounds.center;return(t[0]<e.center[0]?1:0)+(t[1]<e.center[1]?2:0)+(t[2]<e.center[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static{this._pool=new e(()=>new m)}static acquire(){return m._pool.acquire()}static release(e){m._pool.release(e)}static clearPool(){m._pool.prune()}}function*_(e,t=()=>!0){const n=[m.acquire().init(e)];for(;0!==n.length;){const e=n.pop();if(t(e)){if(yield e,!e.isLeaf())for(let t=0;t<e.node.children.length;t++){e.node.children[t]&&n.push(m.acquire().init(e).advance(t))}m.release(e)}}}function p(e,t){const n=_(e,t);for(const r of n);}function b(e,t,n,r=1){let i=m.acquire().init(e);const s=[i];for(B(n,r,J);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=J[e];i.node.children[t]&&s.push(m.acquire().init(i).advance(t))}m.release(i)}}function g(e,t,n){k.clear();const r=n.advanceTo(t,(e,t)=>{k.push(e.node),k.push(t)})?n.node.terminals:n.node.residents;if(r.removeUnordered(e),0===r.length)for(let i=k.length-2;i>=0;i-=2){if(!S(k.data[i],k.data[i+1]))break}}function S(e,n){return n>=0&&(e.children[n]=null),!!z(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}function j(e,t){return T(t.bounds.center,2*-t.halfSize,P),T(t.bounds.center,2*t.halfSize,V),l(e.origin,e.direction,P,V)}function x(e,t,n){return T(t.bounds.center,2*-t.halfSize,P),T(t.bounds.center,2*t.halfSize,V),n.applyToMinMax(P,V),l(e.origin,e.direction,P,V)}function z(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}function O(e,t){e[0]=Math.min(e[0],t.center[0]-t.radius),e[1]=Math.min(e[1],t.center[1]-t.radius),e[2]=Math.min(e[2],t.center[2]-t.radius)}function M(e,t){e[0]=Math.max(e[0],t.center[0]+t.radius),e[1]=Math.max(e[1],t.center[1]+t.radius),e[2]=Math.max(e[2],t.center[2]+t.radius)}function T(e,t,n){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function y(e,t,r){P[0]=1/0,P[1]=1/0,P[2]=1/0,V[0]=-1/0,V[1]=-1/0,V[2]=-1/0;for(const n of e){const e=t(n);w(e.radius)&&(O(P,e),M(V,e))}n(r.center,P,V,.5),r.radius=Math.max(V[0]-P[0],V[1]-P[1],V[2]-P[2])/2}function B(e,t,n){if(!G.length)for(let r=0;r<8;++r)G.push({index:0,distance:0});for(let r=0;r<8;++r){const n=A[r];G.data[r].index=r,G.data[r].distance=v(e,t,n)}G.sort((e,t)=>e.distance-t.distance);for(let r=0;r<8;++r)n[r]=G.data[r].index}function N(e,t){let n,r=1/0;for(let i=0;i<8;++i){const s=v(e,t,F[i]);s<r&&(r=s,n=F[i])}return n}function v(e,t,n){return t*(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])}function w(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}const A=[o(-1,-1,-1),o(1,-1,-1),o(-1,1,-1),o(1,1,-1),o(-1,-1,1),o(1,-1,1),o(-1,1,1),o(1,1,1)],F=[o(-1,-1,-1),o(-1,-1,1),o(-1,1,-1),o(-1,1,1),o(1,-1,-1),o(1,-1,1),o(1,1,-1),o(1,1,1)],D=Math.sqrt(3),R=[null];function E(e){return R[0]=e,R}const q=new c,I=a(),P=a(),V=a(),k=new t,L=new c,C=new c,H=new c,W=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],G=new t,J=[0,0,0,0,0,0,0,0];export{f as Octree};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{sub as t,set as n,copy as o,cross as i,normalize as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as s,setMax as r,create as u}from"../../../../geometry/support/aaBoundingBox.js";import{boundingInfoSubdivisionThreshold as f}from"./intersectionConstants.js";import{assert as a}from"./Util.js";class l{constructor(t=0,n=!1,o=!0){this.tolerance=t,this.isVerticalRay=n,this.normalRequired=o}}const m=u();function p(n,o,i,e,c,s){if(!n.visible)return;const r=t(F,e,i),{tolerance:u}=o,f=new l(u,!1,o.options.normalRequired);if(n.boundingInfo)a(0===n.type),d(n.boundingInfo,i,r,u,c,f,s);else{const t=n.positionAttribute,o=n.primitivePositionIndices;V(i,r,0,o.length/3,o,t.data,t.stride,c,f,s)}}const h=c();function d(t,n,o,i,e,c,u){if(null==t)return;const a=U(o,h);if(s(m,t.bbMin),r(m,t.bbMax),null!=e&&e.applyToAabb(m),k(m,n,a,i)){const{primitiveIndices:s,position:r}=t,a=s?s.length:r.indices.length/3;if(a>f){const s=t.getChildren();if(void 0!==s){for(const t of s)d(t,n,o,i,e,c,u);return}}T(n,o,0,a,r.indices,r.data,r.stride,s,e,c,u)}}const b=c();function M(n,o,i,e,c,s,r,u,f){const{data:a,stride:l}=s;V(n,t(F,o,n),i,e,c,a,l,r,u,f)}function x(t,n,o,i){if(!o.visible)return;const{boundingInfo:e}=o;if(e){const{bbMin:o,bbMax:i}=e;if(t<o[0]||t>i[0]||n<o[1]||n>i[1])return}const c=o.positionAttribute,s=o.primitivePositionIndices;g(t,n,0,s.length/3,s,c,i)}function g(t,n,o,i,e,c,s){const{data:r,stride:u}=c;for(let f=o;f<i;++f){const o=3*f,i=u*e[o],c=u*e[o+1],a=u*e[o+2],l=r[i+0]-t,m=r[i+1]-n,p=r[c+0]-t,h=r[c+1]-n,d=r[a+0]-t,b=r[a+1]-n,M=d*h-b*p,x=l*b-m*d,g=p*m-h*l;(M<0||x<0||g<0)&&(M>0||x>0||g>0)||s(0,null,f)}}function y(t,n,o,i,e,c,s,r,u,f=null,a=0){const l=t[0],m=t[1],p=t[2],h=n[0],d=n[1],M=n[2];for(let x=o;x<i;++x){const t=a+(f?.[x]??x),n=3*t,o=s*e[n],i=c[o],g=c[o+1],y=c[o+2],v=s*e[n+1],q=c[v],T=c[v+1],V=c[v+2],I=s*e[n+2],j=q-i,R=T-g,B=V-y,C=c[I]-i,P=c[I+1]-g,w=c[I+2]-y,U=d*w-P*M,k=M*C-w*h,z=h*P-C*d,D=j*U+R*k+B*z,F=D*D;if(F<=E)continue;const G=l-i,H=m-g,J=p-y,K=(G*U+H*k+J*z)*D;if(K<0||K>F)continue;const L=H*B-R*J,N=J*j-B*G,O=G*R-j*H,Q=(h*L+d*N+M*O)*D;if(Q<0||K+Q>F)continue;const S=(C*L+P*N+w*O)/D;if(S>=0){u(S,r?A(j,R,B,C,P,w,b):null,t)}}}function v(t,n,o,i,e,c,s,r){const u=t[0],f=t[1],a=t[2],l=n[0],m=n[1],p=n[2];for(let h=o;h<i;++h){const t=3*h,n=t+1,o=t+2,i=c*t,d=e[i],M=e[i+1],x=e[i+2],g=c*n,y=c*o,v=e[g]-d,q=e[g+1]-M,T=e[g+2]-x,V=e[y]-d,I=e[y+1]-M,j=e[y+2]-x,R=m*j-I*p,B=p*V-j*l,C=l*I-V*m,P=v*R+q*B+T*C,w=P*P;if(w<=E)continue;const U=u-d,k=f-M,z=a-x,D=(U*R+k*B+z*C)*P;if(D<0||D>w)continue;const F=k*T-q*z,G=z*v-T*U,H=U*q-v*k,J=(l*F+m*G+p*H)*P;if(J<0||D+J>w)continue;const K=(V*F+I*G+j*H)/P;if(K>=0){r(K,s?A(v,q,T,V,I,j,b):null,h)}}}function q(t,n,o,i,e,c,s,r,u,f,a,l=null,m=0){const p=t[0],h=t[1],d=t[2],M=n[0],x=n[1],g=n[2];for(let y=o;y<i;++y){const t=m+(l?.[y]??y),n=3*t,o=s*e[n],i=c[o],v=c[o+1],q=c[o+2],T=s*e[n+1],V=c[T],I=c[T+1],j=c[T+2],R=s*e[n+2],B=c[R],C=c[R+1],P=c[R+2],w=q-u,U=r/Math.sqrt(i*i+v*v+w*w),k=i+i*U,z=v+v*U,D=q+w*U,F=j-u,G=r/Math.sqrt(V*V+I*I+F*F),H=V+V*G,J=I+I*G,K=j+F*G,L=P-u,N=r/Math.sqrt(B*B+C*C+L*L),O=H-k,Q=J-z,S=K-D,W=B+B*N-k,X=C+C*N-z,Y=P+L*N-D,Z=x*Y-X*g,$=g*W-Y*M,_=M*X-W*x,tt=O*Z+Q*$+S*_,nt=tt*tt;if(nt<=E)continue;const ot=p-k,it=h-z,et=d-D,ct=(ot*Z+it*$+et*_)*tt;if(ct<0||ct>nt)continue;const st=it*S-Q*et,rt=et*O-S*ot,ut=ot*Q-O*it,ft=(M*st+x*rt+g*ut)*tt;if(ft<0||ct+ft>nt)continue;const at=(W*st+X*rt+Y*ut)/tt;if(at>=0){a(at,f?A(O,Q,S,W,X,Y,b):null,t)}}}function T(t,n,o,i,e,c,s,r,u,f,a){const l=t[0],m=t[1],p=t[2],h=n[0],d=n[1],M=n[2],{normalRequired:x}=f;for(let g=o;g<i;++g){const t=r[g],n=3*t,o=s*e[n];let i=c[o],f=c[o+1],y=c[o+2];const v=s*e[n+1];let q=c[v],T=c[v+1],V=c[v+2];const I=s*e[n+2];let j=c[I],R=c[I+1],B=c[I+2];null!=u&&([i,f,y]=u.applyToVertex(i,f,y,g),[q,T,V]=u.applyToVertex(q,T,V,g),[j,R,B]=u.applyToVertex(j,R,B,g));const C=q-i,P=T-f,w=V-y,U=j-i,k=R-f,z=B-y,D=d*z-k*M,F=M*U-z*h,G=h*k-U*d,H=C*D+P*F+w*G,J=H*H;if(J<=E)continue;const K=l-i,L=m-f,N=p-y,O=(K*D+L*F+N*G)*H;if(O<0||O>J)continue;const Q=L*w-P*N,S=N*C-w*K,W=K*P-C*L,X=(h*Q+d*S+M*W)*H;if(X<0||O+X>J)continue;const Y=(U*Q+k*S+z*W)/H;if(Y>=0){a(Y,x?A(C,P,w,U,k,z,b):null,t)}}}function V(i,e,c,s,r,u,f,a,l,m){const p=e,h=G,d=Math.abs(p[0]),b=Math.abs(p[1]),M=Math.abs(p[2]),x=d>=b?d>=M?0:2:b>=M?1:2,g=x,y=p[g]<0?2:1,v=(x+y)%3,q=(x+(3-y))%3,T=p[v]/p[g],V=p[q]/p[g],A=1/p[g],C=I,P=j,w=R,{normalRequired:U}=l;for(let I=c;I<s;++I){const e=3*I,c=f*r[e];n(h[0],u[c+0],u[c+1],u[c+2]);const s=f*r[e+1];n(h[1],u[s+0],u[s+1],u[s+2]);const l=f*r[e+2];n(h[2],u[l+0],u[l+1],u[l+2]),a&&(o(h[0],a.applyToVertex(h[0][0],h[0][1],h[0][2],I)),o(h[1],a.applyToVertex(h[1][0],h[1][1],h[1][2],I)),o(h[2],a.applyToVertex(h[2][0],h[2][1],h[2][2],I))),t(C,h[0],i),t(P,h[1],i),t(w,h[2],i);const p=C[v]-T*C[g],d=C[q]-V*C[g],b=P[v]-T*P[g],M=P[q]-V*P[g],x=w[v]-T*w[g],y=w[q]-V*w[g],j=x*M-y*b,R=p*y-d*x,k=b*d-M*p;if((j<0||R<0||k<0)&&(j>0||R>0||k>0))continue;const z=j+R+k;if(0===z)continue;const D=j*(A*C[g])+R*(A*P[g])+k*(A*w[g]);if(D*Math.sign(z)<0)continue;const E=D/z;if(E>=0){m(E,U?B(h):null,I)}}}const I=c(),j=c(),R=c();function A(t,o,c,s,r,u,f){return n(C,t,o,c),n(P,s,r,u),i(f,C,P),e(f,f),f}function B(n){return t(C,n[1],n[0]),t(P,n[2],n[0]),i(b,C,P),e(b,b),b}const C=c(),P=c();function w(t,o,i){return n(i,1/(o[0]-t[0]),1/(o[1]-t[1]),1/(o[2]-t[2]))}function U(t,o){return n(o,1/t[0],1/t[1],1/t[2])}function k(t,n,o,i){return z(t,n,o,i,1/0)}function z(t,n,o,i,e){const c=(t[0]-i-n[0])*o[0],s=(t[3]+i-n[0])*o[0];let r=Math.min(c,s),u=Math.max(c,s);const f=(t[1]-i-n[1])*o[1],a=(t[4]+i-n[1])*o[1];if(u=Math.min(u,Math.max(f,a)),u<0)return!1;if(r=Math.max(r,Math.min(f,a)),r>u)return!1;const l=(t[2]-i-n[2])*o[2],m=(t[5]+i-n[2])*o[2];return u=Math.min(u,Math.max(l,m)),!(u<0)&&(r=Math.max(r,Math.min(l,m)),!(r>u)&&r<e)}const D=1e-7,E=D*D,F=c(),G=[c(),c(),c()];export{l as MeshIntersectionOptions,w as computeInvDir,U as computeInvDirFromDirection,A as computeNormalFromBarycentric,k as intersectAabbInvDir,z as intersectAabbInvDirBefore,y as intersectRayTriangles,V as intersectRayTrianglesWithDisplacementWatertight,q as intersectRayTrianglesWithVerticalOffsetENUGlobal,v as intersectRenderGeometryTriangles,p as intersectTriangleGeometry,x as intersectTriangleGeometry2D,M as intersectTriangles,g as intersectTriangles2d,D as triangleRayParallelTolerance};
2
+ import{sub as t,set as n,cross as o,normalize as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as c,setMax as s,create as r}from"../../../../geometry/support/aaBoundingBox.js";import{boundingInfoSubdivisionThreshold as u}from"./intersectionConstants.js";import{assert as f}from"./Util.js";class a{constructor(t=0,n=!1,o=!0){this.tolerance=t,this.isVerticalRay=n,this.normalRequired=o}}const l=r();function m(n,o,i,e,c,s){if(!n.visible)return;const r=t(E,e,i),{tolerance:u}=o,l=new a(u,!1,o.options.normalRequired);if(n.boundingInfo)f(0===n.type),h(n.boundingInfo,i,r,u,c,l,s);else{const t=n.positionAttribute,o=n.primitivePositionIndices;T(i,r,0,o.length/3,o,t.data,t.stride,c,l,s)}}const p=e();function h(t,n,o,i,e,r,f){if(null==t)return;const a=w(o,p);if(c(l,t.bbMin),s(l,t.bbMax),null!=e&&e.applyToAabb(l),U(l,n,a,i)){const{primitiveIndices:c,position:s}=t,a=c?c.length:s.indices.length/3;if(a>u){const c=t.getChildren();if(void 0!==c){for(const t of c)h(t,n,o,i,e,r,f);return}}q(n,o,0,a,s.indices,s.data,s.stride,c,e,r,f)}}const d=e();function b(n,o,i,e,c,s,r,u,f){const{data:a,stride:l}=s;T(n,t(E,o,n),i,e,c,a,l,r,u,f)}function M(t,n,o,i){if(!o.visible)return;const{boundingInfo:e}=o;if(e){const{bbMin:o,bbMax:i}=e;if(t<o[0]||t>i[0]||n<o[1]||n>i[1])return}const c=o.positionAttribute,s=o.primitivePositionIndices;x(t,n,0,s.length/3,s,c,i)}function x(t,n,o,i,e,c,s){const{data:r,stride:u}=c;for(let f=o;f<i;++f){const o=3*f,i=u*e[o],c=u*e[o+1],a=u*e[o+2],l=r[i+0]-t,m=r[i+1]-n,p=r[c+0]-t,h=r[c+1]-n,d=r[a+0]-t,b=r[a+1]-n,M=d*h-b*p,x=l*b-m*d,g=p*m-h*l;(M<0||x<0||g<0)&&(M>0||x>0||g>0)||s(0,null,f)}}function g(t,n,o,i,e,c,s,r,u,f=null,a=0){const l=t[0],m=t[1],p=t[2],h=n[0],b=n[1],M=n[2];for(let x=o;x<i;++x){const t=a+(f?.[x]??x),n=3*t,o=s*e[n],i=c[o],g=c[o+1],y=c[o+2],v=s*e[n+1],q=c[v],T=c[v+1],V=c[v+2],I=s*e[n+2],j=q-i,A=T-g,B=V-y,C=c[I]-i,P=c[I+1]-g,w=c[I+2]-y,U=b*w-P*M,k=M*C-w*h,z=h*P-C*b,E=j*U+A*k+B*z,F=E*E;if(F<=D)continue;const G=l-i,H=m-g,J=p-y,K=(G*U+H*k+J*z)*E;if(K<0||K>F)continue;const L=H*B-A*J,N=J*j-B*G,O=G*A-j*H,Q=(h*L+b*N+M*O)*E;if(Q<0||K+Q>F)continue;const S=(C*L+P*N+w*O)/E;if(S>=0){u(S,r?R(j,A,B,C,P,w,d):null,t)}}}function y(t,n,o,i,e,c,s,r){const u=t[0],f=t[1],a=t[2],l=n[0],m=n[1],p=n[2];for(let h=o;h<i;++h){const t=3*h,n=t+1,o=t+2,i=c*t,b=e[i],M=e[i+1],x=e[i+2],g=c*n,y=c*o,v=e[g]-b,q=e[g+1]-M,T=e[g+2]-x,V=e[y]-b,I=e[y+1]-M,j=e[y+2]-x,A=m*j-I*p,B=p*V-j*l,C=l*I-V*m,P=v*A+q*B+T*C,w=P*P;if(w<=D)continue;const U=u-b,k=f-M,z=a-x,E=(U*A+k*B+z*C)*P;if(E<0||E>w)continue;const F=k*T-q*z,G=z*v-T*U,H=U*q-v*k,J=(l*F+m*G+p*H)*P;if(J<0||E+J>w)continue;const K=(V*F+I*G+j*H)/P;if(K>=0){r(K,s?R(v,q,T,V,I,j,d):null,h)}}}function v(t,n,o,i,e,c,s,r,u,f,a,l=null,m=0){const p=t[0],h=t[1],b=t[2],M=n[0],x=n[1],g=n[2];for(let y=o;y<i;++y){const t=m+(l?.[y]??y),n=3*t,o=s*e[n],i=c[o],v=c[o+1],q=c[o+2],T=s*e[n+1],V=c[T],I=c[T+1],j=c[T+2],A=s*e[n+2],B=c[A],C=c[A+1],P=c[A+2],w=q-u,U=r/Math.sqrt(i*i+v*v+w*w),k=i+i*U,z=v+v*U,E=q+w*U,F=j-u,G=r/Math.sqrt(V*V+I*I+F*F),H=V+V*G,J=I+I*G,K=j+F*G,L=P-u,N=r/Math.sqrt(B*B+C*C+L*L),O=H-k,Q=J-z,S=K-E,W=B+B*N-k,X=C+C*N-z,Y=P+L*N-E,Z=x*Y-X*g,$=g*W-Y*M,_=M*X-W*x,tt=O*Z+Q*$+S*_,nt=tt*tt;if(nt<=D)continue;const ot=p-k,it=h-z,et=b-E,ct=(ot*Z+it*$+et*_)*tt;if(ct<0||ct>nt)continue;const st=it*S-Q*et,rt=et*O-S*ot,ut=ot*Q-O*it,ft=(M*st+x*rt+g*ut)*tt;if(ft<0||ct+ft>nt)continue;const at=(W*st+X*rt+Y*ut)/tt;if(at>=0){a(at,f?R(O,Q,S,W,X,Y,d):null,t)}}}function q(t,n,o,i,e,c,s,r,u,f,a){const l=t[0],m=t[1],p=t[2],h=n[0],b=n[1],M=n[2],{normalRequired:x}=f;for(let g=o;g<i;++g){const t=r[g],n=3*t,o=s*e[n];let i=c[o],f=c[o+1],y=c[o+2];const v=s*e[n+1];let q=c[v],T=c[v+1],V=c[v+2];const I=s*e[n+2];let j=c[I],A=c[I+1],B=c[I+2];null!=u&&([i,f,y]=u.applyToVertex(G,i,f,y,g),[q,T,V]=u.applyToVertex(G,q,T,V,g),[j,A,B]=u.applyToVertex(G,j,A,B,g));const C=q-i,P=T-f,w=V-y,U=j-i,k=A-f,z=B-y,E=b*z-k*M,F=M*U-z*h,H=h*k-U*b,J=C*E+P*F+w*H,K=J*J;if(K<=D)continue;const L=l-i,N=m-f,O=p-y,Q=(L*E+N*F+O*H)*J;if(Q<0||Q>K)continue;const S=N*w-P*O,W=O*C-w*L,X=L*P-C*N,Y=(h*S+b*W+M*X)*J;if(Y<0||Q+Y>K)continue;const Z=(U*S+k*W+z*X)/J;if(Z>=0){a(Z,x?R(C,P,w,U,k,z,d):null,t)}}}function T(o,i,e,c,s,r,u,f,a,l){const m=i,p=F,h=Math.abs(m[0]),d=Math.abs(m[1]),b=Math.abs(m[2]),M=h>=d?h>=b?0:2:d>=b?1:2,x=M,g=m[x]<0?2:1,y=(M+g)%3,v=(M+(3-g))%3,q=m[y]/m[x],T=m[v]/m[x],R=1/m[x],B=V,C=I,P=j,{normalRequired:w}=a;for(let V=e;V<c;++V){const i=3*V,e=u*s[i];n(p[0],r[e+0],r[e+1],r[e+2]);const c=u*s[i+1];n(p[1],r[c+0],r[c+1],r[c+2]);const a=u*s[i+2];n(p[2],r[a+0],r[a+1],r[a+2]),f&&(f.applyToVertex(p[0],p[0][0],p[0][1],p[0][2],V),f.applyToVertex(p[1],p[1][0],p[1][1],p[1][2],V),f.applyToVertex(p[2],p[2][0],p[2][1],p[2][2],V)),t(B,p[0],o),t(C,p[1],o),t(P,p[2],o);const m=B[y]-q*B[x],h=B[v]-T*B[x],d=C[y]-q*C[x],b=C[v]-T*C[x],M=P[y]-q*P[x],g=P[v]-T*P[x],I=M*b-g*d,j=m*g-h*M,U=d*h-b*m;if((I<0||j<0||U<0)&&(I>0||j>0||U>0))continue;const k=I+j+U;if(0===k)continue;const z=I*(R*B[x])+j*(R*C[x])+U*(R*P[x]);if(z*Math.sign(k)<0)continue;const D=z/k;if(D>=0){l(D,w?A(p):null,V)}}}const V=e(),I=e(),j=e();function R(t,e,c,s,r,u,f){return n(B,t,e,c),n(C,s,r,u),o(f,B,C),i(f,f),f}function A(n){return t(B,n[1],n[0]),t(C,n[2],n[0]),o(d,B,C),i(d,d),d}const B=e(),C=e();function P(t,o,i){return n(i,1/(o[0]-t[0]),1/(o[1]-t[1]),1/(o[2]-t[2]))}function w(t,o){return n(o,1/t[0],1/t[1],1/t[2])}function U(t,n,o,i){return k(t,n,o,i,1/0)}function k(t,n,o,i,e){const c=(t[0]-i-n[0])*o[0],s=(t[3]+i-n[0])*o[0];let r=Math.min(c,s),u=Math.max(c,s);const f=(t[1]-i-n[1])*o[1],a=(t[4]+i-n[1])*o[1];if(u=Math.min(u,Math.max(f,a)),u<0)return!1;if(r=Math.max(r,Math.min(f,a)),r>u)return!1;const l=(t[2]-i-n[2])*o[2],m=(t[5]+i-n[2])*o[2];return u=Math.min(u,Math.max(l,m)),!(u<0)&&(r=Math.max(r,Math.min(l,m)),!(r>u)&&r<e)}const z=1e-7,D=z*z,E=e(),F=[e(),e(),e()],G=e();export{a as MeshIntersectionOptions,P as computeInvDir,w as computeInvDirFromDirection,R as computeNormalFromBarycentric,U as intersectAabbInvDir,k as intersectAabbInvDirBefore,g as intersectRayTriangles,T as intersectRayTrianglesWithDisplacementWatertight,v as intersectRayTrianglesWithVerticalOffsetENUGlobal,y as intersectRenderGeometryTriangles,m as intersectTriangleGeometry,M as intersectTriangleGeometry2D,b as intersectTriangles,x as intersectTriangles2d,z as triangleRayParallelTolerance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{lerp as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{h as t}from"../../../../chunks/boundedPlane.js";function e(o){return(e,m,s)=>!t(o,r(i,e,m,s))}const i=o();export{e as sliceFilterPredicate};
2
+ import{copy as t,lerp as i,squaredLength as s,dot as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{h as r}from"../../../../chunks/boundedPlane.js";import{clipPolygon as c,create as e,fromValues as l}from"../../../../geometry/support/plane.js";function a(t){return(s,n,o)=>!r(t,i(g,s,n,o))}class u{constructor(t,i){this.list=t,this.count=i}}class m{constructor(t){this._remainingA=p(),this._remainingB=p(),this._visible=p(),this._slicedAwayHalfspaces=f(t)}*processTriangle(i,s){let n=new u(this._remainingA,3),o=new u(this._remainingB,0);t(n.list[0],s[0]),t(n.list[1],s[1]),t(n.list[2],s[2]);const r=new u(this._visible,0);for(const t of this._slicedAwayHalfspaces){if(r.count=c(t,n.list,n.count,r.list,!1),r.count>=3&&(i.list=r.list,i.count=r.count,yield i),o.count=c(t,n.list,n.count,o.list,!0),o.count<3)return;[o,n]=[n,o]}}}function f(t){const i=[e(t.plane),e(),e(),e(),e()];return h(t.basis1,t.origin,i[1],i[2]),h(t.basis2,t.origin,i[3],i[4]),i}function h(t,i,o,r){const c=s(t),e=n(t,i);l(t[0],t[1],t[2],-e+c,o),l(-t[0],-t[1],-t[2],e+c,r)}function p(){return Array.from({length:12},()=>o())}const g=o();export{m as SliceScreenPolygonTriangleProcessor,a as sliceFilterPredicate};