@arcgis/core 5.1.0-next.72 → 5.1.0-next.74

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 (220) hide show
  1. package/Viewpoint.js +1 -1
  2. package/applications/Urban/editingSessionUtils.d.ts +95 -0
  3. package/applications/Urban/editingSessionUtils.js +2 -0
  4. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/{91a0227a64a944af3286.js → 003476e950bd27a2f884.js} +2 -2
  7. package/assets/esri/core/workers/chunks/{8a664451845a47048859.js → 0539b5d015157c1d34a0.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{5a4d7ba6dc1d4b41d80d.js → 07eff82916681fcff069.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{b801631b58e6fc6cec8a.js → 0ae360bf253adee46737.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{8a14e3db28c403b046cf.js → 0d2bc1be5802681666a4.js} +1 -1
  11. package/assets/esri/core/workers/chunks/0eed2b1b06355ab89013.js +1 -0
  12. package/assets/esri/core/workers/chunks/{b495f14d90abe8d1a558.js → 12e575a6d2b008b8fc2b.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{61ef14e42bc09b787d89.js → 13e60f19f436b8d683ae.js} +1 -1
  14. package/assets/esri/core/workers/chunks/18f77ee3552d92962f15.js +1 -0
  15. package/assets/esri/core/workers/chunks/1a87e9bbd85ba29b1514.js +1 -0
  16. package/assets/esri/core/workers/chunks/{aa1a3a849aba84cf585b.js → 1db1656a033f3992f0d6.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{b54b7cc6b23a70fed700.js → 1f8ccf96069ac3a40c3d.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{cdf6ad970dc1893dac58.js → 24646a1176ce34039155.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{93ceb74ac88ef460fe5f.js → 359d3acb3953e64e5a78.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{b79058f5bda6fcac22f8.js → 37091cf498a16ccad7ff.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{0839da55707f7c4cf780.js → 3b9100c59a8050f4834e.js} +1 -1
  22. package/assets/esri/core/workers/chunks/452c01cecbbd1e370098.js +1 -0
  23. package/assets/esri/core/workers/chunks/47656ec12401e53f4bd3.js +1 -0
  24. package/assets/esri/core/workers/chunks/{260d4571722cb1ff1366.js → 484d6c1b0fe1633515b7.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{0d96e39380fd84cea9ba.js → 4bbe684050b3b04681d0.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{7e6ccf9f3e756186e93e.js → 4c13869d260a902d3014.js} +1 -1
  27. package/assets/esri/core/workers/chunks/4c97cc922eece3a91b6b.js +1 -0
  28. package/assets/esri/core/workers/chunks/{656d6963e8f837fbf28f.js → 54023458195549f66215.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{02876e434dc91c42b2f4.js → 5476c2f7b83f4ccd0335.js} +1 -1
  30. package/assets/esri/core/workers/chunks/5511e640e171c294f52a.js +2 -0
  31. package/assets/esri/core/workers/chunks/{faad127dc07e54e7f6d1.js → 5abe34bb0110694f7b42.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{c1838822b096d5f36a8b.js → 5b324e572737a308500d.js} +1 -1
  33. package/assets/esri/core/workers/chunks/6124141ac642e4ce1454.js +1 -0
  34. package/assets/esri/core/workers/chunks/{ae0a572cbbdd9815ee2e.js → 62b3e933f548ce354b99.js} +1 -1
  35. package/assets/esri/core/workers/chunks/6b66fc32451433129a88.js +1 -0
  36. package/assets/esri/core/workers/chunks/{6ea8b0d68881d16a2432.js → 6d25230dd85a4ba54c4f.js} +1 -1
  37. package/assets/esri/core/workers/chunks/6f7aaba26773fe416ac2.js +1 -0
  38. package/assets/esri/core/workers/chunks/{9f4b97204def91567e3c.js → 7595ceba529ed01c7590.js} +1 -1
  39. package/assets/esri/core/workers/chunks/75d5ea0da181f9e7425f.js +1312 -0
  40. package/assets/esri/core/workers/chunks/{af75e91b88e747aa76ac.js → 7601278ebced0c0c31cf.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{1661684357912726a72a.js → 77dd719516138afb1a2a.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{6f9ea461c268c421f9c9.js → 7951d93f5f15aa76f49c.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{ce2aa75e084ee56f5e29.js → 7f55eef696e9ed717bfc.js} +1 -1
  44. package/assets/esri/core/workers/chunks/85aac8539996372f1ee8.js +1 -0
  45. package/assets/esri/core/workers/chunks/{50d5d6654ada9f28345d.js → 85e65ced3312bf9cf162.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{b92794def31592a6a25f.js → 8d75f6f27c1c17c33992.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{3cd9bd20e75ba4d5b294.js → 8f4cd30ce23e41c1a42c.js} +1 -1
  48. package/assets/esri/core/workers/chunks/95d82c619dcbec2e1050.js +1 -0
  49. package/assets/esri/core/workers/chunks/983f6c8727fd9484718e.js +1 -0
  50. package/assets/esri/core/workers/chunks/{5a83ea967ecde01d5622.js → 9be9ccce6369f67202bc.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{628f56c09838eb9c573b.js → a270960d80d8344dd75f.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{b475f5492c6e3fd4cca8.js → a36761e3122f70fbb3c9.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{1edd39c7c4acdc591d10.js → a809b811121099a87a98.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{47f2113357b2aa4f4f37.js → a9d2c83bb10b5ade0ca0.js} +1 -1
  55. package/assets/esri/core/workers/chunks/abdf146b35e179b5b245.js +1 -0
  56. package/assets/esri/core/workers/chunks/ad064583f8a836005098.js +1 -0
  57. package/assets/esri/core/workers/chunks/{d2aa75816e84b1e7fd25.js → afc0baf86ece710ef867.js} +1 -1
  58. package/assets/esri/core/workers/chunks/b858adff7043683fe41c.js +1 -0
  59. package/assets/esri/core/workers/chunks/{68b47a5a50e0b5fffca2.js → b905e637a67fbb7af4ae.js} +1 -1
  60. package/assets/esri/core/workers/chunks/{03894992558d063d0d5e.js → bab23b905678e42815e5.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{6ef3b8d67b498d655a99.js → bcb021a167580bb1619f.js} +1 -1
  62. package/assets/esri/core/workers/chunks/be0341567bb19e101a4f.js +1 -0
  63. package/assets/esri/core/workers/chunks/bec3ee5ea945e1e07a35.js +1 -0
  64. package/assets/esri/core/workers/chunks/{a65d576e90179a2b5400.js → c5507480344176fad241.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{d4a9eb4470cc6a1f67fc.js → c5f155fe114a2a05aaf2.js} +2 -2
  66. package/assets/esri/core/workers/chunks/{84772b023d04e415f17f.js → c61002a117dc2218d6af.js} +1 -1
  67. package/assets/esri/core/workers/chunks/c70df6ed190f9ebcf6aa.js +1 -0
  68. package/assets/esri/core/workers/chunks/{0dad0bca8d58b2c63d22.js → c804a66ef7615aa8de89.js} +1 -1
  69. package/assets/esri/core/workers/chunks/cd7159600ce132e32d04.js +1 -0
  70. package/assets/esri/core/workers/chunks/{dec6d41d614105e6fd93.js → d00dafad202450e6ee2e.js} +1 -1
  71. package/assets/esri/core/workers/chunks/d1a7d13e1d48abcd7bf1.js +1 -0
  72. package/assets/esri/core/workers/chunks/{06df187a116709f69952.js → d35c475f004367e333eb.js} +1 -1
  73. package/assets/esri/core/workers/chunks/d82da31dc702b8fd6a07.js +1 -0
  74. package/assets/esri/core/workers/chunks/dd4f431511edd975a53b.js +1 -0
  75. package/assets/esri/core/workers/chunks/{99101789035f1787c630.js → e785f76c1a75cb1d1e1f.js} +1 -1
  76. package/assets/esri/core/workers/chunks/f53805c7a84203305b2c.js +1 -0
  77. package/assets/esri/core/workers/chunks/f590b60fca607d66001a.js +1 -0
  78. package/assets/esri/core/workers/chunks/{f6d047358d14328f3622.js → f60292d97bcdbf19165b.js} +1 -1
  79. package/assets/esri/core/workers/chunks/fb5a2205f05afc396119.js +1 -0
  80. package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
  81. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
  82. package/chunks/GlobalIllumination.glsl.js +186 -116
  83. package/chunks/GlobalIlluminationBlur.glsl.js +81 -61
  84. package/chunks/GlobalIlluminationUpscale.glsl.js +66 -0
  85. package/chunks/geometryEngineBase.js +1 -1
  86. package/config.js +1 -1
  87. package/core/has.js +1 -1
  88. package/form/elements/FieldElement.d.ts +3 -2
  89. package/form/elements/FieldElement.js +1 -1
  90. package/form/elements/inputs/Input.d.ts +1 -1
  91. package/form/elements/inputs/MultipleChoiceInput.d.ts +65 -0
  92. package/form/elements/inputs/MultipleChoiceInput.js +2 -0
  93. package/form/elements/inputs/inputUtils.js +1 -1
  94. package/form/elements/inputs/multipleChoice/Choice.d.ts +30 -0
  95. package/form/elements/inputs/multipleChoice/Choice.js +2 -0
  96. package/form/elements/inputs/multipleChoice/OtherChoice.d.ts +28 -0
  97. package/form/elements/inputs/multipleChoice/OtherChoice.js +2 -0
  98. package/form/elements/inputs.d.ts +11 -2
  99. package/form/elements/inputs.js +1 -1
  100. package/form/support/formUtils.js +1 -1
  101. package/geometry/geometryEngine.js +1 -1
  102. package/geometry/geometryEngineJSON.js +1 -1
  103. package/geometry/operators/projectOperator.d.ts +5 -4
  104. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  105. package/geometry/support/normalizeUtils.js +1 -1
  106. package/geometry/support/normalizeUtilsCommon.js +1 -1
  107. package/identity/IdentityManagerBase.js +1 -1
  108. package/interfaces.d.ts +28 -0
  109. package/kernel.js +1 -1
  110. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  111. package/layers/IntegratedMeshLayer.js +1 -1
  112. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  113. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  114. package/layers/support/SymbolLayerDrawing.d.ts +18 -4
  115. package/package.json +2 -2
  116. package/popup/Features.d.ts +9 -9
  117. package/popup/Features.js +1 -1
  118. package/popup/actionUtils.js +1 -1
  119. package/popup/actions.js +1 -1
  120. package/portal/Portal.js +1 -1
  121. package/portal/PortalQueryParams.js +1 -1
  122. package/rest/print.js +1 -1
  123. package/support/revision.js +1 -1
  124. package/third-party-notices.txt +7 -29
  125. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  126. package/views/3d/camera/intersectionUtils.js +1 -1
  127. package/views/3d/environment/EnvironmentManager.js +1 -1
  128. package/views/3d/input/SceneInputManager.js +1 -1
  129. package/views/3d/input/handlers/PinchAndPanNavigation.js +1 -1
  130. package/views/3d/layers/I3SMeshView3D.js +1 -1
  131. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  132. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  133. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  134. package/views/3d/state/GoToOperation.js +1 -1
  135. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  136. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  137. package/views/3d/support/cameraScaleUtils.js +2 -0
  138. package/views/3d/support/cameraUtils.js +1 -1
  139. package/views/3d/support/orientedBoundingBox.js +1 -1
  140. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  141. package/views/3d/support/renderInfoUtils/line.js +1 -1
  142. package/views/3d/support/viewpointUtils.js +1 -1
  143. package/views/3d/terrain/TerrainRenderer.js +1 -1
  144. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  145. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +13 -12
  146. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  147. package/views/3d/webgl-engine/core/shaderLibrary/shading/GlobalIlluminationWeights.glsl.js +21 -0
  148. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadGlobalIllumination.glsl.js +11 -7
  149. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +2 -0
  150. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  151. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlur.glsl.js +2 -0
  152. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlurTechnique.js +1 -1
  153. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechnique.js +1 -1
  154. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationUpscale.glsl.js +2 -0
  155. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationUpscaleTechnique.js +2 -0
  156. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  157. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  158. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  159. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  160. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  161. package/views/3d/webgl.js +1 -1
  162. package/views/SceneView.d.ts +1 -0
  163. package/views/draw/support/editingSessionUtils.js +2 -0
  164. package/views/interactive/sketch/SketchOptions.d.ts +3 -1
  165. package/views/interactive/sketch/SketchTooltipOptions.d.ts +15 -1
  166. package/views/support/Scheduler.js +1 -1
  167. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  168. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  169. package/widgets/BatchAttributeForm/inputs/SingleFeatureInputAdapter.js +2 -0
  170. package/widgets/BatchAttributeForm/inputs/TextElementInput.d.ts +28 -4
  171. package/widgets/BatchAttributeForm/inputs/TextElementInput.js +1 -1
  172. package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
  173. package/widgets/BatchAttributeForm/templates/AttachmentElementTemplate.js +2 -0
  174. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  175. package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
  176. package/widgets/BatchAttributeForm/templates/support/templateUtils.js +1 -1
  177. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  178. package/widgets/Editor/EditorViewModel.js +1 -1
  179. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  180. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  181. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  182. package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
  183. package/widgets/Editor/support/SketchController.js +1 -1
  184. package/widgets/Editor/workflowUtils.js +1 -1
  185. package/widgets/Search/support/layerSearchUtils.js +1 -1
  186. package/widgets/support/widgetUtils.js +1 -1
  187. package/assets/esri/core/workers/chunks/027c3ea756db68e51f0a.js +0 -1
  188. package/assets/esri/core/workers/chunks/0c00e5e4bd18467bcecd.js +0 -1
  189. package/assets/esri/core/workers/chunks/0ef93722524620023f69.js +0 -1
  190. package/assets/esri/core/workers/chunks/266ba61b72a278d93a26.js +0 -1
  191. package/assets/esri/core/workers/chunks/2abf124e2956e4f76688.js +0 -1
  192. package/assets/esri/core/workers/chunks/43678e08a3d9d51c2a6d.js +0 -1
  193. package/assets/esri/core/workers/chunks/5b278b9980752ef495a2.js +0 -1
  194. package/assets/esri/core/workers/chunks/5e59ff96aecdf2adcb3b.js +0 -1
  195. package/assets/esri/core/workers/chunks/74be994d789c57031631.js +0 -1
  196. package/assets/esri/core/workers/chunks/770880ad43f252962017.js +0 -1
  197. package/assets/esri/core/workers/chunks/81750c5177d8d52a3e05.js +0 -1
  198. package/assets/esri/core/workers/chunks/85edbb072a2ce6c1bb30.js +0 -2
  199. package/assets/esri/core/workers/chunks/943cf0653a2b7de16a4f.js +0 -1
  200. package/assets/esri/core/workers/chunks/a11f05ddd8314b648f76.js +0 -1
  201. package/assets/esri/core/workers/chunks/a37fc886227365f7ecd5.js +0 -1
  202. package/assets/esri/core/workers/chunks/af5db0372d526e592fcc.js +0 -1
  203. package/assets/esri/core/workers/chunks/bc53ce9a643f82d516c2.js +0 -1
  204. package/assets/esri/core/workers/chunks/bea70be8e38b8c83ccd2.js +0 -1
  205. package/assets/esri/core/workers/chunks/c3381b9a36299210ee47.js +0 -1
  206. package/assets/esri/core/workers/chunks/d0c3ab70f390cd579fed.js +0 -1
  207. package/assets/esri/core/workers/chunks/d8d7331600d93bbca2b4.js +0 -1
  208. package/assets/esri/core/workers/chunks/dca595fdd5e1a571e441.js +0 -1
  209. package/assets/esri/core/workers/chunks/de583214195eff13cb00.js +0 -1140
  210. package/assets/esri/core/workers/chunks/df8143b72ef94806c992.js +0 -1
  211. package/assets/esri/core/workers/chunks/ef013a77950c1902de11.js +0 -1
  212. package/assets/esri/core/workers/chunks/fa160a2a5dc9f5a7c34b.js +0 -1
  213. package/geometry/support/triangulationUtilsDeprecated.js +0 -2
  214. package/views/3d/layers/graphics/extrudeUtilsDeprecated.js +0 -2
  215. package/views/3d/support/renderInfoUtils/polygonDeprecated.js +0 -2
  216. package/views/3d/webgl-engine/core/shaderLibrary/shading/EncodingColor.glsl.js +0 -7
  217. package/views/3d/webgl-engine/shaders/GlobalIllumination.glsl.js +0 -2
  218. package/views/3d/webgl-engine/shaders/GlobalIlluminationBlur.glsl.js +0 -2
  219. /package/assets/esri/core/workers/chunks/{85edbb072a2ce6c1bb30.js.LICENSE.txt → 5511e640e171c294f52a.js.LICENSE.txt} +0 -0
  220. /package/assets/esri/core/workers/chunks/{d4a9eb4470cc6a1f67fc.js.LICENSE.txt → c5f155fe114a2a05aaf2.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as r,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ONES as i,ZEROS as n,fromArray as s,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as l}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as p}from"./defaultSymbolComplexity.js";import{ElevationContext as c}from"./ElevationContext.js";import{zeroContext as u}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as d}from"./graphicUtils.js";import{Loadable as h}from"./Loadable.js";import{getSizeAttributeValue as y,getAttributeValue as g}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as f}from"../support/symbolColorUtils.js";const v=()=>e.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class m extends h{constructor(e,t,r,o,i=!0){super(r.schedule),this.symbol=e,this.symbolLayer=t,this._context=r,this._drivenOpacityFallbackAlwaysOpaque=i,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=v(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=o.renderPriority,this._renderPriorityStep=o.renderPriorityStep,this._elevationContext=new c,this.updateComplexity(),this.ignoreDrivers=o.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=_(this._context.renderer,i)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){const{complexity:e}=this;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,r=_(e,this._drivenOpacityFallbackAlwaysOpaque);return r.color!==t.color||r.opacity!==t.opacity||r.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||r.size!==t.size||r.rotation!==t.rotation}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,r,o){const i=e.projectionSuccess,n="polygons"in e?e.polygons:"polygonIndices"in e?e.polygonIndices:null,s=`${o} geometry failed to be created`;i?!this._logGeometryValidationWarnings(t,r,o)&&0===n?.length&&"rings"===r&&t.length>0&&t[0].length>2&&v().warnOncePerTick(`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):v().warnOncePerTick(`${s} (failed to project geometry to view spatial reference)`)}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,r){const o=`${r} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(v().warnOncePerTick(`${o} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(v().warnOncePerTick(`${o} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,r=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+r+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return v().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":l(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return C}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.setFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.setFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}createElevationContextForGraphic(e){const t=new c;return this.updateElevationContextForGraphic(t,e),t}updateElevationContextForGraphic(e,t){const r=t.geometry,o=this.getDefaultElevationInfo(r);e.unit=null!=this._elevationContext.unit?this._elevationContext.unit:o.unit,e.mode=this.getGeometryElevationMode(r,o),e.offsetMeters=this._elevationContext.meterUnitOffset??o.offset??0;const i=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===e.mode;i&&(e.mode="relative-to-ground",e.offsetMeters=0);const n=i?u:this._elevationContext.featureExpressionInfoContext;n?e.updateFeatureExpressionInfoContextForGraphic(n,t,this._context.layer):e.setFeatureExpressionInfoContext(null)}prepareSymbolLayerPatch(e){}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=b){const r=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?r:e?r*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(e,r=b){const o=this._getCombinedOpacity(e,r);if(this._drivenProperties.color)return d(null,o);const i=e?.toUnitRGB()??t;return d(i,o)}_getDrivenUInt8Color({color:e,opacity:t},r,o){const{color:s,opacity:a}=this._drivenProperties,l=r?.toUnitRGBA()??(o?i:n),p=s?e?.output??l:null,c=e||r||o,u=s?null:l[3];return d(p,a&&c?t?.output??u:null,255)}_getDrivenUInt8ColorWithNaNSupport({color:e,opacity:t},i,n){const l=i?s(i.toUnitRGBA()):a(NaN,NaN,NaN,n?NaN:0);return this._drivenProperties.color&&null!=e&&r(l,e.output),this._drivenProperties.opacity&&null!=t&&(l[3]=t.output),o(l,l,255),f(l,l)}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return p(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,r){switch(e){case"opacity":return this.layerOpacityChanged(t,r),!0;case"screenSizePerspectiveEnabled":return this.layerScreenSizePerspectiveChanged(t,r),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return 2!==this.layerElevationInfoChanged(t,r,e)}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,r);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;case"terrainTransparency":return this.terrainTransparencyChanged();default:return!1}}terrainTransparencyChanged(){return!0}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,r){let o=1;return e?.forEach(e=>{const i=t(e);if(null!=i){const t=e.graphic;this.updateElevationContextForGraphic(i.elevationContext,t),i.needsElevationUpdates=r(i.elevationContext.mode)}else o=2}),o}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,r=y(t.size,e.size),o=g(t.color,e.color),i=g(t.opacity,e.opacity);return a(r,o,i,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&v().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.source??null,color:this._fastUpdates?.visualVariables.color?.source??null,opacity:this._fastUpdates?.visualVariables.opacity?.source??null,rotation:this._fastUpdates?.visualVariables.rotation?.source??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function _(e,t){const r={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case"color":if(r.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const o=e.stops[t].color;o&&o.a<1&&(r.opacityAlwaysOpaque=!1)}break;case"opacity":r.opacity=!0,r.opacityAlwaysOpaque=!1;break;case"size":r.size=!0;break;case"rotation":r.rotation=!0}}),r}const x={mode:"on-the-ground",offset:0,unit:"meters"},C={mode:"absolute-height",offset:0,unit:"meters"},b={hasIntrinsicColor:!1},O=a(NaN,NaN,NaN,NaN);export{m as Graphics3DSymbolLayer,_ as getDrivenProperties,O as nanFallbackColor};
2
+ import e from"../../../../core/Logger.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as r,scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ONES as o,ZEROS as n,fromArray as s,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as l}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as p}from"./defaultSymbolComplexity.js";import{ElevationContext as c}from"./ElevationContext.js";import{zeroContext as u}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as d}from"./graphicUtils.js";import{Loadable as h}from"./Loadable.js";import{getSizeAttributeValue as y,getAttributeValue as f}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as g}from"../support/symbolColorUtils.js";const v=()=>e.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class m extends h{constructor(e,t,r,i,o=!0){super(r.schedule),this.symbol=e,this.symbolLayer=t,this._context=r,this._drivenOpacityFallbackAlwaysOpaque=o,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=v(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=i.renderPriority,this._renderPriorityStep=i.renderPriorityStep,this._elevationContext=new c,this.updateComplexity(),this.ignoreDrivers=i.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=_(this._context.renderer,o)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){const{complexity:e}=this;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,r=_(e,this._drivenOpacityFallbackAlwaysOpaque);return r.color!==t.color||r.opacity!==t.opacity||r.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||r.size!==t.size||r.rotation!==t.rotation}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,r,i){const o=e.projectionSuccess,n="polygonIndices"in e?e.polygonIndices:null,s=`${i} geometry failed to be created`;o?!this._logGeometryValidationWarnings(t,r,i)&&0===n?.length&&"rings"===r&&t.length>0&&t[0].length>2&&v().warnOncePerTick(`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):v().warnOncePerTick(`${s} (failed to project geometry to view spatial reference)`)}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,r){const i=`${r} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(v().warnOncePerTick(`${i} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(v().warnOncePerTick(`${i} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,r=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+r+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return v().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":l(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return C}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.setFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.setFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}createElevationContextForGraphic(e){const t=new c;return this.updateElevationContextForGraphic(t,e),t}updateElevationContextForGraphic(e,t){const r=t.geometry,i=this.getDefaultElevationInfo(r);e.unit=null!=this._elevationContext.unit?this._elevationContext.unit:i.unit,e.mode=this.getGeometryElevationMode(r,i),e.offsetMeters=this._elevationContext.meterUnitOffset??i.offset??0;const o=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===e.mode;o&&(e.mode="relative-to-ground",e.offsetMeters=0);const n=o?u:this._elevationContext.featureExpressionInfoContext;n?e.updateFeatureExpressionInfoContextForGraphic(n,t,this._context.layer):e.setFeatureExpressionInfoContext(null)}prepareSymbolLayerPatch(e){}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=b){const r=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?r:e?r*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(e,r=b){const i=this._getCombinedOpacity(e,r);if(this._drivenProperties.color)return d(null,i);const o=e?.toUnitRGB()??t;return d(o,i)}_getDrivenUInt8Color({color:e,opacity:t},r,i){const{color:s,opacity:a}=this._drivenProperties,l=r?.toUnitRGBA()??(i?o:n),p=s?e?.output??l:null,c=e||r||i,u=s?null:l[3];return d(p,a&&c?t?.output??u:null,255)}_getDrivenUInt8ColorWithNaNSupport({color:e,opacity:t},o,n){const l=o?s(o.toUnitRGBA()):a(NaN,NaN,NaN,n?NaN:0);return this._drivenProperties.color&&null!=e&&r(l,e.output),this._drivenProperties.opacity&&null!=t&&(l[3]=t.output),i(l,l,255),g(l,l)}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return p(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,r){switch(e){case"opacity":return this.layerOpacityChanged(t,r),!0;case"screenSizePerspectiveEnabled":return this.layerScreenSizePerspectiveChanged(t,r),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return 2!==this.layerElevationInfoChanged(t,r,e)}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,r);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;case"terrainTransparency":return this.terrainTransparencyChanged();default:return!1}}terrainTransparencyChanged(){return!0}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,r){let i=1;return e?.forEach(e=>{const o=t(e);if(null!=o){const t=e.graphic;this.updateElevationContextForGraphic(o.elevationContext,t),o.needsElevationUpdates=r(o.elevationContext.mode)}else i=2}),i}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,r=y(t.size,e.size),i=f(t.color,e.color),o=f(t.opacity,e.opacity);return a(r,i,o,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&v().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.source??null,color:this._fastUpdates?.visualVariables.color?.source??null,opacity:this._fastUpdates?.visualVariables.opacity?.source??null,rotation:this._fastUpdates?.visualVariables.rotation?.source??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function _(e,t){const r={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case"color":if(r.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const i=e.stops[t].color;i&&i.a<1&&(r.opacityAlwaysOpaque=!1)}break;case"opacity":r.opacity=!0,r.opacityAlwaysOpaque=!1;break;case"size":r.size=!0;break;case"rotation":r.rotation=!0}}),r}const x={mode:"on-the-ground",offset:0,unit:"meters"},C={mode:"absolute-height",offset:0,unit:"meters"},b={hasIntrinsicColor:!1},O=a(NaN,NaN,NaN,NaN);export{m as Graphics3DSymbolLayer,_ as getDrivenProperties,O as nanFallbackColor};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import e from"../../../core/Error.js";import{onAbort as n,createAbortError as a}from"../../../core/promiseUtils.js";import{whenOnce as r}from"../../../core/reactiveUtils.js";import{toRenderCamera as o}from"../webgl.js";import{applyAll as s}from"../camera/constraintUtils.js";import{isPointToPointAnimationController as l,PointToPointAnimationController as h}from"./controllers/PointToPointAnimationController.js";import{SurfaceCollisionCorrectionController as c}from"./controllers/SurfaceCollisionCorrectionController.js";import{create as m}from"../support/viewpointUtils.js";class w{constructor(t,i,e){this._target=t,this._options=i,this.view=e,this.state="pending",this._animationController=null,this.promise=new Promise((t,i)=>{this._resolveCallback=t,this._rejectCallback=i;const e=new AbortController;null!=this._options.signal&&n(this._options.signal,()=>this.abort()),this._abortController=e,this._waitForReady()})}_resolve(t){if("finished"!==this.state)return this.state="finished",this._resolveCallback(t)}_reject(t){if("finished"!==this.state)return this.state="finished",this._rejectCallback(t)}abort(t=!1){if(this._abortController.abort(),"wait-for-animation-finish"===this.state)!t&&null!=this._animationController&&this.view.state.cameraController===this._animationController&&this._animationController.running&&this._animationController.stopController();this._reject(a())}async _waitForReady(){if(this.state="wait-for-ready",!this.view.ready)try{await r(()=>this.view.ready,this._abortController.signal)}catch(t){return this._reject(t)}this._createViewPoint()}async _createViewPoint(){if("finished"!==this.state){this.state="wait-for-viewpoint",this._animationController=this._options.animate?this._getAnimationController():null;try{const t=await m(this.view,this._target,this._abortController.signal);if("finished"===this.state)return;const i=t?this._getCameraFromViewpoint(t):null;if(null==i)return;if(this._options.animate){if(null==this._animationController)return;this._startAnimation(i,this._animationController)}else this.view.stateManager.setStateCamera(i.camera,{applyConstraints:!i.isFullySpecified,positionAndOrientationOnly:!0,doNotCancelGoToOperation:!0}),this._resolve()}catch(t){this._reject(t)}}}_getCameraFromViewpoint(n){const a=!!(this._target instanceof i&&this._target.camera||this._target instanceof t||"position"in this._target&&void 0!==this._target.position?.z||Array.isArray(this._target)&&void 0!==this._target[2]),r=n.camera;if(null==r)return null;if(!this.view.stateManager.isCompatible(r)){const t=r.position,i=t&&t.spatialReference,n=i?i.wkid:"none",a=this.view.spatialReference?.wkid;return this._reject(new e("GotoAnimation:incompatible-spatialreference",`Resulting camera has an incompatible spatial reference (camera: ${n}, view: ${a})`,{camera:r})),null}const s=o(this.view,r);return null==s?(this._reject(new e("GotoAnimation:invalid-camera","Resulting camera is invalid")),null):{viewpoint:n,camera:s,isFullySpecified:a}}_startAnimation(t,i){this.state="wait-for-animation-finish";const n=i.viewAnimation;if(null==n)return void this._reject(new e("GotoAnimation:missing-animation","Unreachable code in view.stateManager"));if(n.update(t.viewpoint,"running"),!i.running||null==i.viewAnimation||i.viewAnimation.target!==t.viewpoint||this.view.state.cameraController!==i)return this.abort();let a;t.isFullySpecified?a=new c({view:this.view,desiredCamera:t.camera}):s(this.view,t.camera),i.begin(t.camera,this._options);const r=()=>{const e=this.view.state.cameraController;a&&(e&&e.running?l(e)&&null!=e.viewAnimation&&e.viewAnimation.target===t.viewpoint&&(this.view.state.cameraController=a):null!=i.viewAnimation&&i.viewAnimation.target===t.viewpoint&&4===i.state&&(this.view.state.cameraController=a))},o=t=>{if(null!=this.view.state)switch(i.state){case 4:switch(this.state){case"pending":case"wait-for-ready":case"wait-for-viewpoint":case"wait-for-animation-finish":this._resolve()}break;case 0:case 1:case 2:case 3:switch(this.state){case"pending":case"wait-for-ready":case"wait-for-viewpoint":case"wait-for-animation-finish":this._reject(t)}}};n.when(r,t=>o(t)),i.asyncResult={resolve:()=>o(),reject:t=>o(t)}}_getAnimationController(){let t=null,i=null;const n=this.view.state.cameraController;return l(n)&&(n.updateStateFromViewAnimation(),n.running&&(t=n,i=t.viewAnimation)),null==t&&(t=new h({view:this.view,mode:"animation"}),i=t.viewAnimation,this.view.state.switchCameraController(t),1===t.state)?(i?.stop(),this._reject(new e("GotoAnimation:goto-cannot-interrupt","Cannot start an animation while interacting")),null):t}}export{w as GoToOperation};
2
+ import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import e from"../../../core/Error.js";import{onAbort as n,createAbortError as a}from"../../../core/promiseUtils.js";import{whenOnce as r}from"../../../core/reactiveUtils.js";import{toRenderCameraWithScale as o}from"../webgl.js";import{applyAll as s}from"../camera/constraintUtils.js";import{isPointToPointAnimationController as l,PointToPointAnimationController as h}from"./controllers/PointToPointAnimationController.js";import{SurfaceCollisionCorrectionController as c}from"./controllers/SurfaceCollisionCorrectionController.js";import{create as m}from"../support/viewpointUtils.js";class w{constructor(t,i,e){this._target=t,this._options=i,this.view=e,this.state="pending",this._animationController=null,this.promise=new Promise((t,i)=>{this._resolveCallback=t,this._rejectCallback=i;const e=new AbortController;null!=this._options.signal&&n(this._options.signal,()=>this.abort()),this._abortController=e,this._waitForReady()})}_resolve(t){if("finished"!==this.state)return this.state="finished",this._resolveCallback(t)}_reject(t){if("finished"!==this.state)return this.state="finished",this._rejectCallback(t)}abort(t=!1){if(this._abortController.abort(),"wait-for-animation-finish"===this.state)!t&&null!=this._animationController&&this.view.state.cameraController===this._animationController&&this._animationController.running&&this._animationController.stopController();this._reject(a())}async _waitForReady(){if(this.state="wait-for-ready",!this.view.ready)try{await r(()=>this.view.ready,this._abortController.signal)}catch(t){return this._reject(t)}this._createViewPoint()}async _createViewPoint(){if("finished"!==this.state){this.state="wait-for-viewpoint",this._animationController=this._options.animate?this._getAnimationController():null;try{const t=await m(this.view,this._target,this._abortController.signal);if("finished"===this.state)return;const i=t?this._getCameraFromViewpoint(t):null;if(null==i)return;if(this._options.animate){if(null==this._animationController)return;this._startAnimation(i,this._animationController)}else this.view.stateManager.setStateCamera(i.camera,{applyConstraints:!i.isFullySpecified,positionAndOrientationOnly:!0,doNotCancelGoToOperation:!0}),this._resolve()}catch(t){this._reject(t)}}}_getCameraFromViewpoint(n){const a=this._target instanceof i,r=this._target instanceof t,s=!!(a&&this._target.camera||r||"position"in this._target&&void 0!==this._target.position?.z||Array.isArray(this._target)&&void 0!==this._target[2]),l=n.camera;if(null==l)return null;if(!this.view.stateManager.isCompatible(l)){const t=l.position,i=t&&t.spatialReference,n=i?i.wkid:"none",a=this.view.spatialReference?.wkid;return this._reject(new e("GotoAnimation:incompatible-spatialreference",`Resulting camera has an incompatible spatial reference (camera: ${n}, view: ${a})`,{camera:l})),null}const h=o(this.view,l,n.scale);return null==h?(this._reject(new e("GotoAnimation:invalid-camera","Resulting camera is invalid")),null):{viewpoint:n,camera:h,isFullySpecified:s}}_startAnimation(t,i){this.state="wait-for-animation-finish";const n=i.viewAnimation;if(null==n)return void this._reject(new e("GotoAnimation:missing-animation","Unreachable code in view.stateManager"));if(n.update(t.viewpoint,"running"),!i.running||null==i.viewAnimation||i.viewAnimation.target!==t.viewpoint||this.view.state.cameraController!==i)return this.abort();let a;t.isFullySpecified?a=new c({view:this.view,desiredCamera:t.camera}):s(this.view,t.camera),i.begin(t.camera,this._options);const r=()=>{const e=this.view.state.cameraController;a&&(e&&e.running?l(e)&&null!=e.viewAnimation&&e.viewAnimation.target===t.viewpoint&&(this.view.state.cameraController=a):null!=i.viewAnimation&&i.viewAnimation.target===t.viewpoint&&4===i.state&&(this.view.state.cameraController=a))},o=t=>{if(null!=this.view.state)switch(i.state){case 4:switch(this.state){case"pending":case"wait-for-ready":case"wait-for-viewpoint":case"wait-for-animation-finish":this._resolve()}break;case 0:case 1:case 2:case 3:switch(this.state){case"pending":case"wait-for-ready":case"wait-for-viewpoint":case"wait-for-animation-finish":this._reject(t)}}};n.when(r,t=>o(t)),i.asyncResult={resolve:()=>o(),reject:t=>o(t)}}_getAnimationController(){let t=null,i=null;const n=this.view.state.cameraController;return l(n)&&(n.updateStateFromViewAnimation(),n.running&&(t=n,i=t.viewAnimation)),null==t&&(t=new h({view:this.view,mode:"animation"}),i=t.viewAnimation,this.view.state.switchCameraController(t),1===t.state)?(i?.stop(),this._reject(new e("GotoAnimation:goto-cannot-interrupt","Cannot start an animation while interacting")),null):t}}export{w as GoToOperation};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{cyclicalPI as i}from"../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../core/mathUtils.js";import{createScreenPointArray as n,screenPointObjectToArray as s}from"../../../../core/screenUtils.js";import{subclass as o}from"../../../../core/accessorSupport/decorators.js";import{copy as a,distance as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as m,negate as h,length as c,subtract as _,normalize as p,add as u,scale as l,dot as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as P}from"../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as v}from"../../../../geometry/support/axisAngle.js";import{create as C,fromPositionAndNormal as w,getNormal as b}from"../../../../geometry/support/plane.js";import{Sphere as M}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as S,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as j}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as E}from"../../input/util.js";import{InteractiveController as y}from"./InteractiveController.js";import{PanPlanarMomentumController as x}from"./momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as A}from"./momentum/PanSphericalMomentumController.js";import{RotationMomentumController as O}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as R}from"./momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as z}from"./momentum/ZoomSphericalMomentumController.js";import{pickPointAndInitSphere as k,excludeTerrain as F,inferNavigationMode as H,sphereOrPlanePointFromScreenPoint as D,maxPanDistanceModifier as T,minPinchAndPanCameraHeight as U,pivotSearchAreaSize as G,intersectPlaneFromScreenPointAtEye as I,applyZoomOnSphere as Z,shouldPreserveHeading as V,applyPanSphericalPreserveHeading as q,applyPanSphericalDirectRotation as B,normalizeRotationDelta as J,applyRotation as K,applyPanPlanar as L,applyZoomToPoint as N}from"../utils/navigationUtils.js";import Q from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as W}from"../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as X}from"../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as Y}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as $}from"../../../navigation/ZoomMomentumEstimator.js";let tt=class extends y{constructor(){super(...arguments),this._smoothRotation=new E(.05),this._rotationAxis=g(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=C(),this._beginRadius=0,this._smoothScaling=new E(.05),this._zoomCenterScreen=n(),this._zoomMomentumEstimator=new $,this._rotationMomentumEstimator=new Y,this._panSphericalMomentumEstimator=new X,this._panPlanarMomentumEstimator=new W,this._adjustedSphere=new M,this._tmp3d=g(),this._tmpScreenPointArray=n(),this._beginScreenPoint=n(),this._beginScenePoint=g(),this._screenPickPoint=n(),this._scenePickPoint=g(),this._navigationMode=1,this._sphere=new M,this._pointerCount=0,this._tmpInteractionDirection=g(),this._beginCamera=new Q,this._constraintOptions=new j(15,0,0,this._beginCamera)}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.running)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._beginAngle=t.angle,this._pointerCount=t.pointers.size,this._smoothRotation.reset(),s(t.center,this._screenPickPoint),a(this._beginScreenPoint,this._screenPickPoint);const n=k(this._intersectionHelper,this.startCamera,this._screenPickPoint,P(this.view.spatialReference).radius,1,this.view.basemapTerrain.invisible?F:{});null!=n.scenePickPoint&&(this._scenePickPoint=n.scenePickPoint,this._sphere=n.sphere,m(this._beginScenePoint,this._scenePickPoint),this._navigationMode=H(this.startCamera,this._screenPickPoint,this.view.renderCoordsHelper,this.view.viewingMode),0===this._navigationMode&&this._preparePlanarPanMode(t,n.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;1===this._navigationMode?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return 1===this._navigationMode?new z({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere.radius}):new R({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new O({view:this.view,momentum:e,center:this._sphere.center,axis:this._rotationAxis});if(1===this._navigationMode){const t=this.view.animationsEnabled&&this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new A({view:this.view,momentum:t})}else{const t=this.view.animationsEnabled&&this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new x({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=h(this._tmp3d,this.startCamera.viewForward);w(this._scenePickPoint,e,this._panningPlane);const o=n(this._screenPickPoint[0],0),a=g(),r=c(this.startCamera.eye);this._adjustedSphere.radius=r<this._sphere.radius?r-100:this._sphere.radius,D(this._adjustedSphere,this.startCamera,o,a);const P=g(),v=g(),C=g();_(P,this._scenePickPoint,this.currentCamera.eye);const M=c(P);p(P,P);const S=T*Math.max(Math.abs(this.view.camera.position.z),U),f=this.view.stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,G);let j=null!=f?f:S;i&&(j=Math.min(j,M)),m(C,u(v,this.currentCamera.eye,l(v,P,j))),this._panningPlane[3]=-d(b(this._panningPlane),C),this.startCamera.center=u(v,this.startCamera.eye,l(v,this.startCamera.viewForward,j));const E=s(t.center,this._tmpScreenPointArray);I(this._panningPlane,this.startCamera,E,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),Z(this._sphere,this.currentCamera,this._smoothScaling.value),s(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=S(t.radius-this._beginRadius),f(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=s(t.center,this._tmpScreenPointArray);D(this._sphere,this.currentCamera,i,this._tmp3d),V(this._beginScenePoint,d(this.currentCamera.up,this._beginScenePoint),this._sphere.radius,this._beginHeading,this.view.camera.tilt,this.startCamera.aboveGround)?(q(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(B(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere.radius,this.view.camera.tilt)),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=S(r(this._screenPickPoint,i)),f(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){p(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||h(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+J(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),K(this.currentCamera,this._sphere.center,v(this._rotationAxis,s)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=S(t.radius*e),f(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=s(t.center,this._tmpScreenPointArray);I(this._panningPlane,this.currentCamera,i,this._tmp3d)&&(L(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=S(r(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),f(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),N(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=S(t.radius-this._beginRadius),f(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){m(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||h(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=J(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const o=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(o,.001*t.timestamp),K(this.currentCamera,this._sphere.center,v(this._rotationAxis,o)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=S(t.radius*o),f(this.view,this.currentCamera,this._constraintOptions)}};tt=t([o("esri.views.3d.state.controllers.PinchAndPanControllerGlobal")],tt);export{tt as PinchAndPanControllerGlobal};
2
+ import{__decorate as t}from"tslib";import{cyclicalPI as i}from"../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../core/mathUtils.js";import{createScreenPointArray as n,screenPointObjectToArray as s}from"../../../../core/screenUtils.js";import{property as o,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{copy as r,distance as m}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as h,negate as c,length as _,subtract as p,normalize as l,add as u,scale as d,dot as g}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as C}from"../../../../geometry/support/axisAngle.js";import{create as w,fromPositionAndNormal as M,getNormal as b}from"../../../../geometry/support/plane.js";import{Sphere as S}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as f,applyAll as j}from"../../camera/constraintUtils.js";import{ConstraintOptions as E}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as y}from"../../input/util.js";import{InteractiveController as O}from"./InteractiveController.js";import{PanPlanarMomentumController as x}from"./momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as A}from"./momentum/PanSphericalMomentumController.js";import{RotationMomentumController as z}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as R}from"./momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as k}from"./momentum/ZoomSphericalMomentumController.js";import{pickPointAndInitSphere as H,excludeTerrain as F,inferNavigationMode as D,sphereOrPlanePointFromScreenPoint as T,maxPanDistanceModifier as U,minPinchAndPanCameraHeight as G,pivotSearchAreaSize as I,intersectPlaneFromScreenPointAtEye as Z,applyZoomOnSphere as V,shouldPreserveHeading as q,applyPanSphericalPreserveHeading as B,applyPanSphericalDirectRotation as J,normalizeRotationDelta as K,applyRotation as L,applyPanPlanar as N,applyZoomToPoint as Q}from"../utils/navigationUtils.js";import W from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as X}from"../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as Y}from"../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as $}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as tt}from"../../../navigation/ZoomMomentumEstimator.js";let it=class extends O{constructor(t){super(t),this.forceHorizontalPan=!1,this._smoothRotation=new y(.05),this._rotationAxis=P(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=w(),this._beginRadius=0,this._smoothScaling=new y(.05),this._zoomCenterScreen=n(),this._zoomMomentumEstimator=new tt,this._rotationMomentumEstimator=new $,this._panSphericalMomentumEstimator=new Y,this._panPlanarMomentumEstimator=new X,this._adjustedSphere=new S,this._tmp3d=P(),this._tmpScreenPointArray=n(),this._beginScreenPoint=n(),this._beginScenePoint=P(),this._screenPickPoint=n(),this._scenePickPoint=P(),this._navigationMode=1,this._sphere=new S,this._pointerCount=0,this._tmpInteractionDirection=P(),this._beginCamera=new W,this._constraintOptions=new E(15,0,0,this._beginCamera)}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.running)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._beginAngle=t.angle,this._pointerCount=t.pointers.size,this._smoothRotation.reset(),s(t.center,this._screenPickPoint),r(this._beginScreenPoint,this._screenPickPoint);const n=H(this._intersectionHelper,this.startCamera,this._screenPickPoint,v(this.view.spatialReference).radius,1,this.view.basemapTerrain.invisible?F:{});null!=n.scenePickPoint&&(this._scenePickPoint=n.scenePickPoint,this._sphere=n.sphere,h(this._beginScenePoint,this._scenePickPoint),this.forceHorizontalPan?this._navigationMode=1:this._navigationMode=D(this.startCamera,this._screenPickPoint,this.view.renderCoordsHelper,this.view.viewingMode),0===this._navigationMode&&this._preparePlanarPanMode(t,n.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;1===this._navigationMode?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return 1===this._navigationMode?new k({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere.radius}):new R({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new z({view:this.view,momentum:e,center:this._sphere.center,axis:this._rotationAxis});if(1===this._navigationMode){const t=this.view.animationsEnabled&&this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new A({view:this.view,momentum:t})}else{const t=this.view.animationsEnabled&&this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new x({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=c(this._tmp3d,this.startCamera.viewForward);M(this._scenePickPoint,e,this._panningPlane);const o=n(this._screenPickPoint[0],0),a=P(),r=_(this.startCamera.eye);this._adjustedSphere.radius=r<this._sphere.radius?r-100:this._sphere.radius,T(this._adjustedSphere,this.startCamera,o,a);const m=P(),v=P(),C=P();p(m,this._scenePickPoint,this.currentCamera.eye);const w=_(m);l(m,m);const S=U*Math.max(Math.abs(this.view.camera.position.z),G),f=this.view.stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,I);let j=null!=f?f:S;i&&(j=Math.min(j,w)),h(C,u(v,this.currentCamera.eye,d(v,m,j))),this._panningPlane[3]=-g(b(this._panningPlane),C),this.startCamera.center=u(v,this.startCamera.eye,d(v,this.startCamera.viewForward,j));const E=s(t.center,this._tmpScreenPointArray);Z(this._panningPlane,this.startCamera,E,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),V(this._sphere,this.currentCamera,this._smoothScaling.value),s(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=f(t.radius-this._beginRadius),j(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=s(t.center,this._tmpScreenPointArray);T(this._sphere,this.currentCamera,i,this._tmp3d),q(this._beginScenePoint,g(this.currentCamera.up,this._beginScenePoint),this._sphere.radius,this._beginHeading,this.view.camera.tilt,this.startCamera.aboveGround)?(B(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(J(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere.radius,this.view.camera.tilt)),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=f(m(this._screenPickPoint,i)),j(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){l(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||c(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+K(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),L(this.currentCamera,this._sphere.center,C(this._rotationAxis,s)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=f(t.radius*e),j(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=s(t.center,this._tmpScreenPointArray);Z(this._panningPlane,this.currentCamera,i,this._tmp3d)&&(N(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=f(m(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),j(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),Q(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=f(t.radius-this._beginRadius),j(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){h(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||c(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=K(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const o=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(o,.001*t.timestamp),L(this.currentCamera,this._sphere.center,C(this._rotationAxis,o)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=f(t.radius*o),j(this.view,this.currentCamera,this._constraintOptions)}};t([o({constructOnly:!0})],it.prototype,"forceHorizontalPan",void 0),it=t([a("esri.views.3d.state.controllers.PinchAndPanControllerGlobal")],it);export{it as PinchAndPanControllerGlobal};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{createScreenPointArray as i,screenPointObjectToArray as e}from"../../../../core/screenUtils.js";import{subclass as n}from"../../../../core/accessorSupport/decorators.js";import{distance as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{negate as o,copy as a,dot as r,subtract as m,length as h,normalize as l,scale as c,add as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _,fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrapAxisAngle as d}from"../../../../geometry/support/axisAngle.js";import{create as g,fromNormalAndOffset as C,setOffsetFromPoint as v,negate as b,getNormal as w}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as M,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as P}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as V}from"../../input/util.js";import{getVoxelWasm as z}from"../../layers/VoxelWasm.js";import{InteractiveController as S}from"./InteractiveController.js";import{PanPlanarMomentumController as j}from"./momentum/PanPlanarMomentumController.js";import{RotationMomentumController as E}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as H}from"./momentum/ZoomPlanarMomentumController.js";import{excludeTerrain as x,inferNavigationMode as y,getTiltScaleFactor as O,maxPanDistanceModifier as F,minPinchAndPanCameraHeight as R,pivotSearchAreaSize as A,centroid as T,applyZoomToPoint as U,applyPanPlanar as D,normalizeRotationDelta as I,applyRotation as Z,intersectPlaneFromScreenPointAtEye as k}from"../utils/navigationUtils.js";import G from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as L}from"../../../navigation/PanPlanarMomentumEstimator.js";import{RotationMomentumEstimator as W}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as q}from"../../../navigation/ZoomMomentumEstimator.js";const B=u(0,0,1);let J=class extends S{constructor(){super(...arguments),this._rotationValueSmooth=new V(.05),this._scalingValueSmooth=new V(.05),this._planeHorizontal=g(),this._planeVertical=g(),this._rotationMomentumEstimator=new W,this._panMomentumEstimator=new L(300,12,.9),this._zoomMomentumEstimator=new q,this._beginRadius=0,this._beginCenter=_(),this._beginAngle=0,this._tmpPoints=[],this._navigationMode=1,this._beginCenterScreen=i(),this._tmpCentroid3d=_(),this._tmpCentroid2d=i(),this._tmp2d=i(),this._pointerCount=0,this._beginCamera=new G,this._constraintOptions=new P(15,0,0,this._beginCamera)}begin(t){if(!this.running)return;const i=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=i,this._rotationMomentumEstimator.enabled=i,this._panMomentumEstimator.enabled=i,this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._rotationValueSmooth.reset(),this._scalingValueSmooth.reset(),e(t.center,this._beginCenterScreen),C(B,0,this._planeHorizontal);const n=_(),s=this._intersectionHelper.intersectScreenFreePointFallback(this._beginCenterScreen,n,this.view.basemapTerrain.invisible?x:{}),u=_();o(u,this.startCamera.viewForward);const d=_();a(d,B);const g=r(u,d);this._navigationMode=y(this.startCamera,this._beginCenterScreen,this.view.renderCoordsHelper,this.view.viewingMode);const M=O(d,this.startCamera.viewForward,F)*Math.max(Math.abs(this.view.camera.position.z),R);v(this._planeHorizontal,this._planeHorizontal,n),this.startCamera.aboveGround||b(this._planeHorizontal,this._planeHorizontal);const f=_(),P=_(),V=_();m(f,n,this.currentCamera.eye);const S=h(f);if(l(f,f),0===this._navigationMode){c(d,d,g),m(w(this._planeVertical),u,d),l(w(this._planeVertical),w(this._planeVertical)),v(this._planeVertical,this._planeVertical,n);const i=this.view.stage.renderView.getMinimalDepthForArea(z(this.view),this._beginCenterScreen[0],this._beginCenterScreen[1],this.view.state.camera,A);let e=null!=i?i:M;s&&(e=Math.min(e,S)),a(V,p(P,this.currentCamera.eye,c(P,f,e))),this._planeVertical[3]=-r(w(this._planeVertical),V),this._computePlanePoints(t.pointers,this._planeVertical,this.startCamera,this._tmpPoints),T(this._tmpPoints,this._beginCenter)}else{const i=s?S:M;a(V,p(P,this.currentCamera.eye,c(P,f,i))),this._planeHorizontal[3]=-r(w(this._planeHorizontal),V),this._computePlanePoints(t.pointers,this._planeHorizontal,this.startCamera,this._tmpPoints),T(this._tmpPoints,this._beginCenter)}this._beginCamera.copyFrom(this.startCamera)}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1,n=1===this._navigationMode?this._planeHorizontal:this._planeVertical,o=this._beginCenter;if(i){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._scalingValueSmooth.gain=e,this._scalingValueSmooth.update(i),U(this.currentCamera,o,this._scalingValueSmooth.value,this.view.state.constraints.minimumPoiDistance),this._zoomMomentumEstimator.add(this._scalingValueSmooth.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=M(Math.abs(t.radius-this._beginRadius)),f(this.view,this.currentCamera,this._constraintOptions)}if(this._computePlanePoints(t.pointers,n,this.currentCamera,this._tmpPoints),T(this._tmpPoints,this._tmpCentroid3d),e(t.center,this._tmpCentroid2d),D(this.currentCamera,o,this._tmpCentroid3d),this._panMomentumEstimator.add(this._tmpCentroid2d,this._tmpCentroid3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=M(s(this._beginCenterScreen,this._tmpCentroid2d)),f(this.view,this.currentCamera,this._constraintOptions),i){const i=o,e=this._rotationValueSmooth.value,n=e+I(t.angle-e),s=.00125*Math.min(Math.max(t.radius,40),120);this._rotationValueSmooth.gain=s,this._rotationValueSmooth.update(n);const a=this._rotationValueSmooth.value-this._beginAngle;this._rotationMomentumEstimator.add(a,.001*t.timestamp);const r=w(this._planeHorizontal);Z(this.currentCamera,i,d(r,a)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=M(Math.abs(t.radius*a)),f(this.view,this.currentCamera,this._constraintOptions)}this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return new H({view:this.view,momentum:i,zoomCenter:this._beginCenter});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new E({view:this.view,momentum:e,center:this._beginCenter,axis:w(this._planeHorizontal)});const n=this.view.animationsEnabled&&this._panMomentumEstimator.evaluateMomentum();return n?new j({view:this.view,momentum:n}):null}_computePlanePoints(t,i,e,n){n.length=t.size;const s=this._tmp2d;let o=0;return t.forEach(t=>{s[0]=t.x,s[1]=t.y,void 0===n[o]&&(n[o]=_()),k(i,e,s,n[o]),o+=1}),n}get _intersectionHelper(){return this.view.sceneIntersectionHelper}};J=t([n("esri.views.3d.state.controllers.PinchAndPanControllerLocal")],J);export{J as PinchAndPanControllerLocal};
2
+ import{__decorate as t}from"tslib";import{createScreenPointArray as i,screenPointObjectToArray as e}from"../../../../core/screenUtils.js";import{property as n,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{distance as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{negate as a,copy as r,dot as m,subtract as h,length as l,normalize as c,scale as p,add as _}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,fromValues as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrapAxisAngle as g}from"../../../../geometry/support/axisAngle.js";import{create as C,fromNormalAndOffset as v,setOffsetFromPoint as b,negate as w,getNormal as M}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as f,applyAll as P}from"../../camera/constraintUtils.js";import{ConstraintOptions as z}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as V}from"../../input/util.js";import{getVoxelWasm as S}from"../../layers/VoxelWasm.js";import{InteractiveController as j}from"./InteractiveController.js";import{PanPlanarMomentumController as E}from"./momentum/PanPlanarMomentumController.js";import{RotationMomentumController as H}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as y}from"./momentum/ZoomPlanarMomentumController.js";import{excludeTerrain as x,inferNavigationMode as O,getTiltScaleFactor as F,maxPanDistanceModifier as R,minPinchAndPanCameraHeight as A,pivotSearchAreaSize as T,centroid as U,applyZoomToPoint as D,applyPanPlanar as I,normalizeRotationDelta as Z,applyRotation as k,intersectPlaneFromScreenPointAtEye as G}from"../utils/navigationUtils.js";import L from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as W}from"../../../navigation/PanPlanarMomentumEstimator.js";import{RotationMomentumEstimator as q}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as B}from"../../../navigation/ZoomMomentumEstimator.js";const J=d(0,0,1);let K=class extends j{constructor(t){super(t),this.forceHorizontalPan=!1,this._rotationValueSmooth=new V(.05),this._scalingValueSmooth=new V(.05),this._planeHorizontal=C(),this._planeVertical=C(),this._rotationMomentumEstimator=new q,this._panMomentumEstimator=new W(300,12,.9),this._zoomMomentumEstimator=new B,this._beginRadius=0,this._beginCenter=u(),this._beginAngle=0,this._tmpPoints=[],this._navigationMode=1,this._beginCenterScreen=i(),this._tmpCentroid3d=u(),this._tmpCentroid2d=i(),this._tmp2d=i(),this._pointerCount=0,this._beginCamera=new L,this._constraintOptions=new z(15,0,0,this._beginCamera)}begin(t){if(!this.running)return;const i=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=i,this._rotationMomentumEstimator.enabled=i,this._panMomentumEstimator.enabled=i,this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._rotationValueSmooth.reset(),this._scalingValueSmooth.reset(),e(t.center,this._beginCenterScreen),v(J,0,this._planeHorizontal);const n=u(),o=this._intersectionHelper.intersectScreenFreePointFallback(this._beginCenterScreen,n,this.view.basemapTerrain.invisible?x:{}),s=u();a(s,this.startCamera.viewForward);const d=u();r(d,J);const g=m(s,d);this.forceHorizontalPan?this._navigationMode=1:this._navigationMode=O(this.startCamera,this._beginCenterScreen,this.view.renderCoordsHelper,this.view.viewingMode);const C=F(d,this.startCamera.viewForward,R)*Math.max(Math.abs(this.view.camera.position.z),A);b(this._planeHorizontal,this._planeHorizontal,n),this.startCamera.aboveGround||w(this._planeHorizontal,this._planeHorizontal);const f=u(),P=u(),z=u();h(f,n,this.currentCamera.eye);const V=l(f);if(c(f,f),0===this._navigationMode){p(d,d,g),h(M(this._planeVertical),s,d),c(M(this._planeVertical),M(this._planeVertical)),b(this._planeVertical,this._planeVertical,n);const i=this.view.stage.renderView.getMinimalDepthForArea(S(this.view),this._beginCenterScreen[0],this._beginCenterScreen[1],this.view.state.camera,T);let e=null!=i?i:C;o&&(e=Math.min(e,V)),r(z,_(P,this.currentCamera.eye,p(P,f,e))),this._planeVertical[3]=-m(M(this._planeVertical),z),this._computePlanePoints(t.pointers,this._planeVertical,this.startCamera,this._tmpPoints),U(this._tmpPoints,this._beginCenter)}else{const i=o?V:C;r(z,_(P,this.currentCamera.eye,p(P,f,i))),this._planeHorizontal[3]=-m(M(this._planeHorizontal),z),this._computePlanePoints(t.pointers,this._planeHorizontal,this.startCamera,this._tmpPoints),U(this._tmpPoints,this._beginCenter)}this._beginCamera.copyFrom(this.startCamera)}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1,n=1===this._navigationMode?this._planeHorizontal:this._planeVertical,o=this._beginCenter;if(i){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._scalingValueSmooth.gain=e,this._scalingValueSmooth.update(i),D(this.currentCamera,o,this._scalingValueSmooth.value,this.view.state.constraints.minimumPoiDistance),this._zoomMomentumEstimator.add(this._scalingValueSmooth.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=f(Math.abs(t.radius-this._beginRadius)),P(this.view,this.currentCamera,this._constraintOptions)}if(this._computePlanePoints(t.pointers,n,this.currentCamera,this._tmpPoints),U(this._tmpPoints,this._tmpCentroid3d),e(t.center,this._tmpCentroid2d),I(this.currentCamera,o,this._tmpCentroid3d),this._panMomentumEstimator.add(this._tmpCentroid2d,this._tmpCentroid3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=f(s(this._beginCenterScreen,this._tmpCentroid2d)),P(this.view,this.currentCamera,this._constraintOptions),i){const i=o,e=this._rotationValueSmooth.value,n=e+Z(t.angle-e),s=.00125*Math.min(Math.max(t.radius,40),120);this._rotationValueSmooth.gain=s,this._rotationValueSmooth.update(n);const a=this._rotationValueSmooth.value-this._beginAngle;this._rotationMomentumEstimator.add(a,.001*t.timestamp);const r=M(this._planeHorizontal);k(this.currentCamera,i,g(r,a)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=f(Math.abs(t.radius*a)),P(this.view,this.currentCamera,this._constraintOptions)}this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return new y({view:this.view,momentum:i,zoomCenter:this._beginCenter});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new H({view:this.view,momentum:e,center:this._beginCenter,axis:M(this._planeHorizontal)});const n=this.view.animationsEnabled&&this._panMomentumEstimator.evaluateMomentum();return n?new E({view:this.view,momentum:n}):null}_computePlanePoints(t,i,e,n){n.length=t.size;const o=this._tmp2d;let s=0;return t.forEach(t=>{o[0]=t.x,o[1]=t.y,void 0===n[s]&&(n[s]=u()),G(i,e,o,n[s]),s+=1}),n}get _intersectionHelper(){return this.view.sceneIntersectionHelper}};t([n({constructOnly:!0})],K.prototype,"forceHorizontalPan",void 0),K=t([o("esri.views.3d.state.controllers.PinchAndPanControllerLocal")],K);export{K as PinchAndPanControllerLocal};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ const t=96*39.37;function e(e,n,r){const{unitInMeters:o}=e.renderCoordsHelper;r/=o;return n.width/2/n.pixelRatio/(t/r)/Math.tan(n.fovX/2)}function n(t,n){return e(t,t.state.camera,n)}function r(e,n){const{camera:r}=e.state,{unitInMeters:o}=e.renderCoordsHelper,a=n*Math.tan(r.fovX/2),i=r.width/2/r.pixelRatio;return t/(i/a)*o}export{r as distanceToScale,n as scaleToDistance,e as scaleToDistanceAt};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../Camera.js";import t from"../../../core/Logger.js";import{deg2rad as n,rad2deg as r,asinClamped as i}from"../../../core/mathUtils.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{copy as o,distance as c,dist as s,length as l}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,clone as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import p from"../../../geometry/Point.js";import{projectAsync as d,project as h}from"../../../geometry/projectionUtils.js";import g from"../../../geometry/SpatialReference.js";import{projectPointToVectorAsync as y,projectPointToVector as v}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPointAsync as R,projectVectorToPoint as w}from"../../../geometry/projection/projectVectorToPoint.js";import{gcsCyclical as x,webMercatorCyclical as M}from"../../../geometry/support/normalizeUtils.js";import{toRenderCamera as j}from"../webgl.js";import{getGreatCircleSpanAt as T}from"./earthUtils.js";import{getElevationAtPoint as z}from"./ElevationProvider.js";import{viewModeDependentUtil as S,directionToHeadingTilt as C}from"./viewingModeUtils.js";import{isSpatialReferenceSupported as b}from"../../support/spatialReferenceSupport.js";const P=()=>t.getLogger("esri.views.3d.support.cameraUtils"),A=96*39.37,L=1,U=8,H=5,q=1,I=u();function E(e){return e.spatialReference??g.WGS84}function F(e,t,n,r,i){return S(e).headingTiltToDirectionUp(t,n,r,i)}function G(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper;t/=r;return n.width/2/n.pixelRatio/(A/t)/Math.tan(n.fovX/2)}function O(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper,i=t*Math.tan(n.fovX/2),a=n.width/2/n.pixelRatio;return A/(a/i)*r}function X(e,t,n,r){const i=r.levelAtScale(t),a=k(C(e,n.eye,n.viewForward,n.up).tilt),o=Math.max(i-a,0);return r.scaleAtLevel(o)}function D(e,t,n){const r=n.levelAtScale(e),i=k(t);return n.scaleAtLevel(r+i)}function k(e){return 2*((e>90?180-e:e)/90)**2}function V(e,t,n=0){const r=e.basemapTerrain?.tilingScheme;if(!r)return 0;const i=m(e.spatialReference).radius,a=2===e.state.viewingMode?t.eye[2]:l(t.eye)-i;return X(e,O(e,Math.abs(a-n)),t,r)}function W(e,t,n=0){const r=j(e,t);return r?V(e,r,n):0}const Y=1,N=100;function Z(e,t,a,o){if(0===t)return 0;const s=e.state.contentCamera,u=c(s.eye,a),f=e.basemapTerrain?.tilingScheme;if(!f)return P().error("#scaleToTargetDistance()","Cannot compute distance from scale without a tiling scheme"),u;let p=u;const d=C(e,s.eye,s.viewForward,s.up),h=d.tilt>90;if(e.state.isLocal){const r=(G(e,D(t,d.tilt,f))-Math.abs(s.eye[2]-o[2]))/Math.cos(n(d.tilt));return p=h?p-r:p+r,p}let g=1/0,y=0,v=te(e,d.heading,d.tilt,a,u,1);if(!v)return p;const R=l(o);for(;g>Y&&y<N;){const o=l(v.eye),u=h?180-v.tilt:v.tilt,w=n(u),x=Math.sin(w)*o,M=Math.cos(w)*o,j=G(e,D(t,v.tilt,f)),T=h?R-j:R+j,z=i(x/T),S=Math.cos(z)*T-M,C=c(v.eye,a);p=h?C-S:C+S,v=te(e,d.heading,d.tilt,a,p,1);const b=Me(e,v,r(s.fov));if(!v||!b)return p;const P=W(e,b,R-m(e.spatialReference).radius);g=Math.abs(t-P),++y}return p}async function B(e,t,n,r,i,a){return K(e,t,G(e,n),r,i,a)}function J(e,t,n,r,i,a){return Me(e,te(e,r.heading,r.tilt,t,n,i),r.fov,a)}async function K(e,t,n,r,i,o){const c=await ne(e,r.heading,r.tilt,t,n,i,o);return a(o),je(e,c,r.fov,o)}function Q(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,I,e.spatialReference)&&e.elevationProvider&&(z(e.elevationProvider,I)??0)>I[2]-q)}async function $(e,t,n){if(Q(e,t))return!0;const{elevationProvider:r,spatialReference:i,renderCoordsHelper:o}=e;if(null==r||!o.fromRenderCoords(t,I,i))return!1;const[c,s,l]=I,u=await r.queryElevation(c,s,l,i,"ground",n)??0;return a(n),u>l-q}async function _(e,t,n){const r=u();if(null==t)return o(r,e.state.camera.center);if(t instanceof p){const{renderSpatialReference:i,basemapTerrain:o,elevationProvider:c}=e,s=t.spatialReference;if(await y(t,r,i,{signal:n}),a(n),null==t.z&&null!=o&&null!=c){const i=await c.queryElevation(t.x,t.y,t.z??0,s,"ground",n);a(n),null!=i&&e.renderCoordsHelper.setAltitude(r,i)}return r}return o(r,t)}function ee(e,t){const n=u();if(null==t)return o(n,e.state.camera.center);if(t instanceof p){if(!v(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:i}=e;if(null==t.z&&null!=r&&null!=i){const r=z(i,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return o(n,t)}function te(e,t,n,r,i,a){return re(e,t,n,r instanceof p?r:null,ee(e,r),i,a)}async function ne(e,t,n,r,i,o,c){const s=r instanceof p?r:null,l=await _(e,r,c);return a(c),ie(e,t,n,s,l,i,o,c)}function re(e,t,n,r,i,a,o){if(null==i)return null;if(!r&&(r=new p({spatialReference:E(e)}),!w(i,e.renderSpatialReference,r)))return null;const c=ae(e,t,n,i,a,o);if(oe(e,n,o)&&Q(e,c.eye)){const{tilt:o,mode:c}=ce(e,n,i,a);return re(e,t,o,r,i,a,c)}return se(c,i)}async function ie(e,t,n,r,i,o,c,s){r||(r=new p({spatialReference:E(e)}),await R(i,e.renderSpatialReference,r,{signal:s})||(r=null)),a(s);const l=ae(e,t,n,i,o,c);if(oe(e,n,c)&&await $(e,l.eye,s)){a(s);const{tilt:c,mode:l}=ce(e,n,i,o);return ie(e,t,c,r,i,o,l,s)}return se(l,i)}function ae(e,t,n,r,i,a){const o=ge(e,t,n,r,i=Math.max(i,e.state.constraints.minimumPoiDistance),a);return(0,S(e).eyeForCenterWithHeadingTilt)(r,i,o.heading,o.tilt)}function oe(e,t,n){const r=e.map.ground.navigationConstraint;return 1===n&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function ce(e,t,n,r){const i=we(e,n,r,Re(e,r,t,n));return{tilt:i,mode:t-i<1?0:1}}function se(e,t){return{...e,center:f(t)}}function le(e,t){const{state:n,spatialReference:r}=e,i=t.spatialReference;return n.isGlobal&&b(i,1)||n.isLocal&&r.equals(i)}function ue(e,t){let n,r,i;if(e.state.isGlobal){const e=new p(t.xmin,t.ymin,t.spatialReference),a=new p(t.xmax,t.ymax,t.spatialReference),o=t.spatialReference.isGeographic?x:M;n=new p({x:o.center(e.x,a.x),y:(a.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=m(t.spatialReference),s=T(n,e,a);r=s.lon,i=s.lat,o.diff(e.x,a.x)>o.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),i=Math.min(i,c.halfCircumference)}else{const a=e.renderSpatialReference??t.spatialReference;a.equals(t.spatialReference)||(t=h(t,a)),r=t.xmax-t.xmin,i=t.ymax-t.ymin;const o=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new p({x:t.xmin+.5*r,y:t.ymin+.5*i,z:o,spatialReference:a})}const a=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,o=e.state.camera,c=1/Math.tan(o.fovX/2),s=1/Math.tan(o.fovY/2),l=1/Math.tan(o.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*i*s,.5*a*l)/L}}async function fe(e,t,n,r,i,o){const c=le(e,t)?t:await d(t,e.spatialReference,{signal:o});a(o);const{center:s,distance:l}=ue(e,c),u=await ne(e,n,r,s,l,i,o);return a(o),je(e,u,e.camera.fov,o)}function me(e,t,n,r,i,a){let o;try{o=le(e,t)?t:h(t,e.spatialReference)}catch(u){return null}const{center:c,distance:s}=ue(e,o),l=te(e,n,r,c,s,i);return null==l?null:Me(e,l,e.camera.fov,a)}function pe(e,t,n){const r=e.renderSpatialReference,i=new p({spatialReference:E(e)});if(!w(n,r,i))return null;const a=Math.tan(t.fovX/2),o=Math.tan(t.fovY/2),c=s(t.eye,n),l=2*c*a*L,u=2*c*o*L;return S(e).toExtent(e,i,l,u)}function de(e,t){return S(e).toArea(e,t)}function he(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>U)return!0;const i=t,a=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return c(i,a)/(Math.tan(.5*e.state.camera.fov)*r)>H}function ge(e,t,n,r,i,a){let o=0;return 1===a&&he(e,r,i)?(t=0,o=ve(e,i,n,r)):o=xe(e,r,i,n),o=e.state.constraints.clampTilt(i,o),{heading:t,tilt:n=we(e,r,i,o)}}const ye=.7;function ve(e,t,n,r){const i=xe(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);a.max=Math.min(a.max,.5*Math.PI);const o=a.min*(1-ye)+a.max*ye;return Math.min(i,o)}function Re(e,t,n,r){let i=xe(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);return i=Math.min(i,.5*Math.PI),a.min*(1-ye)+i*ye}function we(e,t,n,r){return S(e).lookAtTiltToEyeTilt(r,t,n)}function xe(e,t,n,r){return S(e).eyeTiltToLookAtTilt(r,t,n)}function Me(t,n,r,i){if(null==n)return null;const a=t.renderSpatialReference,o=new p({spatialReference:E(t)});return w(n.eye,a,o)?(i??=new e,i.position=o,i.heading=n.heading,i.tilt=n.tilt,i.fov=r,i):null}async function je(t,n,r,i){const o=t.renderSpatialReference,c=new p({spatialReference:E(t)});return await R(n.eye,o,c,{signal:i}),a(i),new e(c,n.heading,n.tilt,r)}function Te(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);P().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function ze(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);P().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{X as applyTiltAdjustToScale,O as distanceToScale,K as fromCenterDistanceAsync,J as fromCenterDistanceSync,B as fromCenterScale,fe as fromExtentAsync,me as fromExtentSync,ne as getObserverForPointAtDistanceAsync,te as getObserverForPointAtDistanceSync,E as getViewSR,F as headingTiltToDirectionUp,D as removeTiltAdjustFromScale,Y as scaleErrorThreshold,G as scaleToDistance,Te as scaleToZoom,de as toArea,pe as toExtent,Z as viewScaleToCameraDistance,ze as zoomToScale};
2
+ import e from"../../../Camera.js";import t from"../../../core/Logger.js";import{deg2rad as n,rad2deg as r,asinClamped as i}from"../../../core/mathUtils.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{copy as o,distance as c,dist as s,length as l}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,clone as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import p from"../../../geometry/Point.js";import{projectAsync as d,project as h}from"../../../geometry/projectionUtils.js";import g from"../../../geometry/SpatialReference.js";import{projectPointToVectorAsync as y,projectPointToVector as v}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPointAsync as R,projectVectorToPoint as w}from"../../../geometry/projection/projectVectorToPoint.js";import{gcsCyclical as x,webMercatorCyclical as M}from"../../../geometry/support/normalizeUtils.js";import{toRenderCamera as j}from"../webgl.js";import{scaleToDistance as T,distanceToScale as S}from"./cameraScaleUtils.js";import{getGreatCircleSpanAt as z}from"./earthUtils.js";import{getElevationAtPoint as b}from"./ElevationProvider.js";import{viewModeDependentUtil as C,directionToHeadingTilt as P}from"./viewingModeUtils.js";import{isSpatialReferenceSupported as A}from"../../support/spatialReferenceSupport.js";const L=()=>t.getLogger("esri.views.3d.support.cameraUtils"),U=1,q=8,E=5,F=1,G=u();function H(e){return e.spatialReference??g.WGS84}function I(e,t,n,r,i){return C(e).headingTiltToDirectionUp(t,n,r,i)}function O(e,t,n,r){const i=r.levelAtScale(t),a=k(P(e,n.eye,n.viewForward,n.up).tilt),o=Math.max(i-a,0);return r.scaleAtLevel(o)}function D(e,t,n){const r=n.levelAtScale(e),i=k(t);return n.scaleAtLevel(r+i)}function k(e){return 2*((e>90?180-e:e)/90)**2}function V(e,t,n=0){const r=e.basemapTerrain?.tilingScheme;if(!r)return 0;const i=m(e.spatialReference).radius,a=2===e.state.viewingMode?t.eye[2]:l(t.eye)-i,o=Math.abs(a-n);return O(e,S(e,o),t,r)}function W(e,t,n=0){const r=j(e,t);return r?V(e,r,n):0}const X=1,Y=100;function N(e,t,a,o){if(0===t)return 0;const s=e.state.contentCamera,u=c(s.eye,a),f=e.basemapTerrain?.tilingScheme;if(!f)return L().error("#scaleToTargetDistance()","Cannot compute distance from scale without a tiling scheme"),u;let p=u;const d=P(e,s.eye,s.viewForward,s.up),h=d.tilt>90;if(e.state.isLocal){const r=D(t,d.tilt,f),i=(T(e,r)-Math.abs(s.eye[2]-o[2]))/Math.cos(n(d.tilt));return p=h?p-i:p+i,p}let g=1/0,y=0,v=ee(e,d.heading,d.tilt,a,u,1);if(!v)return p;const R=l(o);for(;g>X&&y<Y;){const o=l(v.eye),u=h?180-v.tilt:v.tilt,w=n(u),x=Math.sin(w)*o,M=Math.cos(w)*o,j=D(t,v.tilt,f),S=T(e,j),z=h?R-S:R+S,b=i(x/z),C=Math.cos(b)*z-M,P=c(v.eye,a);p=h?P-C:P+C,v=ee(e,d.heading,d.tilt,a,p,1);const A=xe(e,v,r(s.fov));if(!v||!A)return p;const L=W(e,A,R-m(e.spatialReference).radius);g=Math.abs(t-L),++y}return p}async function Z(e,t,n,r,i,a){return J(e,t,T(e,n),r,i,a)}function B(e,t,n,r,i,a){return xe(e,ee(e,r.heading,r.tilt,t,n,i),r.fov,a)}async function J(e,t,n,r,i,o){const c=await te(e,r.heading,r.tilt,t,n,i,o);return a(o),Me(e,c,r.fov,o)}function K(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,G,e.spatialReference)&&e.elevationProvider&&(b(e.elevationProvider,G)??0)>G[2]-F)}async function Q(e,t,n){if(K(e,t))return!0;const{elevationProvider:r,spatialReference:i,renderCoordsHelper:o}=e;if(null==r||!o.fromRenderCoords(t,G,i))return!1;const[c,s,l]=G,u=await r.queryElevation(c,s,l,i,"ground",n)??0;return a(n),u>l-F}async function $(e,t,n){const r=u();if(null==t)return o(r,e.state.camera.center);if(t instanceof p){const{renderSpatialReference:i,basemapTerrain:o,elevationProvider:c}=e,s=t.spatialReference;if(await y(t,r,i,{signal:n}),a(n),null==t.z&&null!=o&&null!=c){const i=await c.queryElevation(t.x,t.y,t.z??0,s,"ground",n);a(n),null!=i&&e.renderCoordsHelper.setAltitude(r,i)}return r}return o(r,t)}function _(e,t){const n=u();if(null==t)return o(n,e.state.camera.center);if(t instanceof p){if(!v(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:i}=e;if(null==t.z&&null!=r&&null!=i){const r=b(i,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return o(n,t)}function ee(e,t,n,r,i,a){return ne(e,t,n,r instanceof p?r:null,_(e,r),i,a)}async function te(e,t,n,r,i,o,c){const s=r instanceof p?r:null,l=await $(e,r,c);return a(c),re(e,t,n,s,l,i,o,c)}function ne(e,t,n,r,i,a,o){if(null==i)return null;if(!r&&(r=new p({spatialReference:H(e)}),!w(i,e.renderSpatialReference,r)))return null;const c=ie(e,t,n,i,a,o);if(ae(e,n,o)&&K(e,c.eye)){const{tilt:o,mode:c}=oe(e,n,i,a);return ne(e,t,o,r,i,a,c)}return ce(c,i)}async function re(e,t,n,r,i,o,c,s){r||(r=new p({spatialReference:H(e)}),await R(i,e.renderSpatialReference,r,{signal:s})||(r=null)),a(s);const l=ie(e,t,n,i,o,c);if(ae(e,n,c)&&await Q(e,l.eye,s)){a(s);const{tilt:c,mode:l}=oe(e,n,i,o);return re(e,t,c,r,i,o,l,s)}return ce(l,i)}function ie(e,t,n,r,i,a){const o=he(e,t,n,r,i=Math.max(i,e.state.constraints.minimumPoiDistance),a);return(0,C(e).eyeForCenterWithHeadingTilt)(r,i,o.heading,o.tilt)}function ae(e,t,n){const r=e.map.ground.navigationConstraint;return 1===n&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function oe(e,t,n,r){const i=Re(e,n,r,ve(e,r,t,n));return{tilt:i,mode:t-i<1?0:1}}function ce(e,t){return{...e,center:f(t)}}function se(e,t){const{state:n,spatialReference:r}=e,i=t.spatialReference;return n.isGlobal&&A(i,1)||n.isLocal&&r.equals(i)}function le(e,t){let n,r,i;if(e.state.isGlobal){const e=new p(t.xmin,t.ymin,t.spatialReference),a=new p(t.xmax,t.ymax,t.spatialReference),o=t.spatialReference.isGeographic?x:M;n=new p({x:o.center(e.x,a.x),y:(a.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=m(t.spatialReference),s=z(n,e,a);r=s.lon,i=s.lat,o.diff(e.x,a.x)>o.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),i=Math.min(i,c.halfCircumference)}else{const a=e.renderSpatialReference??t.spatialReference;a.equals(t.spatialReference)||(t=h(t,a)),r=t.xmax-t.xmin,i=t.ymax-t.ymin;const o=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new p({x:t.xmin+.5*r,y:t.ymin+.5*i,z:o,spatialReference:a})}const a=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,o=e.state.camera,c=1/Math.tan(o.fovX/2),s=1/Math.tan(o.fovY/2),l=1/Math.tan(o.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*i*s,.5*a*l)/U}}async function ue(e,t,n,r,i,o){const c=se(e,t)?t:await d(t,e.spatialReference,{signal:o});a(o);const{center:s,distance:l}=le(e,c),u=await te(e,n,r,s,l,i,o);return a(o),Me(e,u,e.camera.fov,o)}function fe(e,t,n,r,i,a){let o;try{o=se(e,t)?t:h(t,e.spatialReference)}catch(u){return null}const{center:c,distance:s}=le(e,o),l=ee(e,n,r,c,s,i);return null==l?null:xe(e,l,e.camera.fov,a)}function me(e,t,n){const r=e.renderSpatialReference,i=new p({spatialReference:H(e)});if(!w(n,r,i))return null;const a=Math.tan(t.fovX/2),o=Math.tan(t.fovY/2),c=s(t.eye,n),l=2*c*a*U,u=2*c*o*U;return C(e).toExtent(e,i,l,u)}function pe(e,t){return C(e).toArea(e,t)}function de(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>q)return!0;const i=t,a=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return c(i,a)/(Math.tan(.5*e.state.camera.fov)*r)>E}function he(e,t,n,r,i,a){let o=0;return 1===a&&de(e,r,i)?(t=0,o=ye(e,i,n,r)):o=we(e,r,i,n),o=e.state.constraints.clampTilt(i,o),{heading:t,tilt:n=Re(e,r,i,o)}}const ge=.7;function ye(e,t,n,r){const i=we(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);a.max=Math.min(a.max,.5*Math.PI);const o=a.min*(1-ge)+a.max*ge;return Math.min(i,o)}function ve(e,t,n,r){let i=we(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);return i=Math.min(i,.5*Math.PI),a.min*(1-ge)+i*ge}function Re(e,t,n,r){return C(e).lookAtTiltToEyeTilt(r,t,n)}function we(e,t,n,r){return C(e).eyeTiltToLookAtTilt(r,t,n)}function xe(t,n,r,i){if(null==n)return null;const a=t.renderSpatialReference,o=new p({spatialReference:H(t)});return w(n.eye,a,o)?(i??=new e,i.position=o,i.heading=n.heading,i.tilt=n.tilt,i.fov=r,i):null}async function Me(t,n,r,i){const o=t.renderSpatialReference,c=new p({spatialReference:H(t)});return await R(n.eye,o,c,{signal:i}),a(i),new e(c,n.heading,n.tilt,r)}function je(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);L().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function Te(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);L().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{O as applyTiltAdjustToScale,J as fromCenterDistanceAsync,B as fromCenterDistanceSync,Z as fromCenterScale,ue as fromExtentAsync,fe as fromExtentSync,te as getObserverForPointAtDistanceAsync,ee as getObserverForPointAtDistanceSync,H as getViewSR,I as headingTiltToDirectionUp,D as removeTiltAdjustFromScale,X as scaleErrorThreshold,je as scaleToZoom,pe as toArea,me as toExtent,N as viewScaleToCameraDistance,Te as zoomToScale};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{fromQuat as t,scale as e}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as r,conjugate as i,multiply as n}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,create as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as c,transformQuat as f,dot as d,cross as u,len as l,scale as m,transformMat3 as _,add as g,transformQuatValues as p,sub as b,abs as M,max as j,min as S,length as z,scaleAndAdd as x,sign as y,multiply as C}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as q,freeze as A,create as P,UNIT_Z as R}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as Q}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{create as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as w}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as D}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as H}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as F}from"../../../geometry/projection/projectBuffer.js";import{getProjector as k}from"../../../geometry/projection/projectors.js";import{getNormal as B}from"../../../geometry/support/plane.js";import{isPlateCarree as Z}from"../../../geometry/support/spatialReferenceUtils.js";import{sv3d as U,sq4d as W}from"../../../geometry/support/vectorStacks.js";import{computeOBB as X}from"./dito.js";import{Vertices as Y}from"../webgl-engine/lib/Attribute.js";class G{constructor(t=q,e=bt,a=o){this._data=[t[0],t[1],t[2],e[0],e[1],e[2],a[0],a[1],a[2],a[3]]}clone(){return G.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(t){const e=new G;return e._copyFromData(t),e}static fromJSON(t){return new G(t.center,t.halfSize,t.quaternion)}copy(t){this._copyFromData(t.data)}_copyFromData(t){for(let e=0;e<10;++e)this._data[e]=t[e]}get center(){return c(U.get(),this._data[0],this._data[1],this._data[2])}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(t){return t[0]=this._data[0],t[1]=this._data[1],t[2]=this._data[2],t}set center(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]}setCenter(t,e,a){this._data[0]=t,this._data[1]=e,this._data[2]=a}get halfSize(){return c(U.get(),this._data[3],this._data[4],this._data[5])}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(t){return t[0]=this._data[3],t[1]=this._data[4],t[2]=this._data[5],t}set halfSize(t){this._data[3]=t[0],this._data[4]=t[1],this._data[5]=t[2]}get quaternion(){return r(W.get(),this._data[6],this._data[7],this._data[8],this._data[9])}get quaternionConjugate(){return r(W.get(),-this._data[6],-this._data[7],-this._data[8],this._data[9])}getQuaternion(t){return t[0]=this._data[6],t[1]=this._data[7],t[2]=this._data[8],t[3]=this._data[9],t}getQuaternionConjugate(t){return t[0]=-this._data[6],t[1]=-this._data[7],t[2]=-this._data[8],t[3]=this._data[9],t}set quaternion(t){this._data[6]=t[0],this._data[7]=t[1],this._data[8]=t[2],this._data[9]=t[3]}get data(){return this._data}getCorners(t){const e=this._data,a=r(O,e[6],e[7],e[8],e[9]);for(let s=0;s<8;++s){const r=t[s];r[0]=(1&s?-1:1)*e[3],r[1]=(2&s?-1:1)*e[4],r[2]=(4&s?-1:1)*e[5],f(r,r,a),r[0]+=e[0],r[1]+=e[1],r[2]+=e[2]}return t}getAxes(t){const e=this._data,a=r(O,e[6],e[7],e[8],e[9]);return f(t[0],[1,0,0],a),f(t[1],[0,1,0],a),f(t[2],[0,0,1],a),t}intersectsFrustum(t){const{centerX:e,centerY:a,centerZ:s}=this,r=t.planes;for(const d of r){const t=B(d),r=this.projectedRadius(t);if(e*t[0]+a*t[1]+s*t[2]+d[3]-r>0)return!1}const i=this.getAxes(mt),n=t.points,o=this.halfSize;for(let u=0;u<3;++u){const t=i[u],r=-t[0]*e-t[1]*a-t[2]*s,h=o[u];let c=!0,f=!0;for(const e of n){const a=d(e,t)+r;c&&=a>h,f&&=a<-h}if(c||f)return!1}if(this.getCorners(lt).some(e=>t.intersectsPoint(e)))return!0;const h=St;for(let d=0;d<3;++d){const t=i[d];h[d]=t[0]*e+t[1]*a+t[2]*s}const c=t=>{for(let e=0;e<3;++e){const a=i[e],s=o[e],r=a[0]*t[0]+a[1]*t[1]+a[2]*t[2]-h[e];if(r>s||r<-s)return!1}return!0};if(t.points.some(t=>c(t)))return!0;const f=t.lines,_=jt;for(let g=0;g<8;++g){const t=f[g].direction;for(const r of i){u(_,t,r);const i=l(_);if(!(i>0))continue;m(_,_,1/i);const o=this.projectedRadius(_),h=_[0]*e+_[1]*a+_[2]*s,c=h-o,f=h+o;let g=!1,p=!1,b=!0;for(const t of n){const e=d(_,t);if(e>f){if(p){b=!1;break}g=!0}else{if(!(e<c)){b=!1;break}if(g){b=!1;break}p=!0}}if(b)return!1}}return!0}intersectsFrustumConservativeApproximation(t){return this.intersectPlane(t[0])<=0&&this.intersectPlane(t[1])<=0&&this.intersectPlane(t[2])<=0&&this.intersectPlane(t[3])<=0&&this.intersectPlane(t[4])<=0&&this.intersectPlane(t[5])<=0}get radius(){const t=this._data[3],e=this._data[4],a=this._data[5];return Math.sqrt(t*t+e*e+a*a)}intersectsPoint(t){const e=this.getAxes(mt),a=this.halfSize,{center:s}=this;for(let r=0;r<3;++r){const i=e[r],n=a[r],o=d(i,t)-d(i,s);if(o>n||o<-n)return!1}return!0}intersectSphere(t){const{center:e,radius:a}=t,s=this._data,r=s[3],i=s[4],n=s[5],o=r+i+n+a,h=s[0]-e[0];if(Math.abs(h)>o)return!1;const c=s[1]-e[1];if(Math.abs(c)>o)return!1;const f=s[2]-e[2];if(Math.abs(f)>o)return!1;const d=-s[6],u=-s[7],l=-s[8],m=u*f-l*c,_=l*h-d*f,g=d*c-u*h,p=u*g-l*_,b=l*m-d*g,M=d*_-u*m,j=2*s[9],S=Math.abs(h+m*j+2*p),z=Math.abs(c+_*j+2*b),x=Math.abs(f+g*j+2*M),y=S-Math.min(S,r),C=z-Math.min(z,i),q=x-Math.min(x,n);return y*y+C*C+q*q<=a*a}intersectSphereWithMBS(t,e=this.radius){const a=this._data,{center:s,radius:r}=t,i=e+r,n=a[0]-s[0];if(n>i)return!1;const o=a[1]-s[1];if(o>i)return!1;const h=a[2]-s[2];if(h>i)return!1;if(n*n+o*o+h*h>i*i)return!1;const c=-a[6],f=-a[7],d=-a[8],u=f*h-d*o,l=d*n-c*h,m=c*o-f*n,_=f*m-d*l,g=d*u-c*m,p=c*l-f*u,b=2*a[9],M=Math.abs(n+u*b+2*_),j=Math.abs(o+l*b+2*g),S=Math.abs(h+m*b+2*p),z=M-Math.min(M,a[3]),x=j-Math.min(j,a[4]),y=S-Math.min(S,a[5]);return z*z+x*x+y*y<r*r}intersectPlane(t){const e=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],a=this.projectedRadius(B(t));return e>a?1:e<-a?-1:0}intersectRay(t,e,a=0){const s=this._data,r=O;r[0]=-s[6],r[1]=-s[7],r[2]=-s[8],r[3]=s[9],I[0]=t[0]-s[0],I[1]=t[1]-s[1],I[2]=t[2]-s[2];const i=f(I,I,O),n=f(J,e,O);let o=-1/0,h=1/0;const c=this.getHalfSize(ft);for(let f=0;f<3;f++){const t=i[f],e=n[f],s=c[f]+a;if(Math.abs(e)>1e-6){const a=(s-t)/e,r=(-s-t)/e;o=Math.max(o,Math.min(a,r)),h=Math.min(h,Math.max(a,r))}else if(t>s||t<-s)return!1}return o<=h}projectedArea(a,s,r,n){const o=this.getQuaternion(T);i(O,o),I[0]=a[0]-this._data[0],I[1]=a[1]-this._data[1],I[2]=a[2]-this._data[2],f(I,I,O);const h=this.getHalfSize(ft),d=I[0]<-h[0]?-1:I[0]>h[0]?1:0,u=I[1]<-h[1]?-1:I[1]>h[1]?1:0,l=I[2]<-h[2]?-1:I[2]>h[2]?1:0,m=Math.abs(d)+Math.abs(u)+Math.abs(l);if(0===m)return 1/0;const p=1===m?4:6,b=6*(d+3*u+9*l+13);t(dt,o),e(dt,dt,h);const M=this.getCenter(ht);for(let t=0;t<p;t++){const e=L[b+t];c(I,((1&e)<<1)-1,(2&e)-1,((4&e)>>1)-1),_(I,I,dt),g(N,M,I),N[3]=1,Q(N,N,s);const a=1/Math.max(1e-6,N[3]);K[2*t]=N[0]*a,K[2*t+1]=N[1]*a}const j=2*p-2;let S=K[0]*(K[3]-K[j+1])+K[j]*(K[1]-K[j-1]);for(let t=2;t<j;t+=2)S+=K[t]*(K[t+3]-K[t-1]);return Math.abs(S)*r*n*.125}projectedRadius(t){const e=this._data;return p(I,t,-e[6],-e[7],-e[8],e[9]),Math.abs(I[0]*e[3])+Math.abs(I[1]*e[4])+Math.abs(I[2]*e[5])}signedDistancePlane(t,e){const a=this._data,s=t[0]*a[0]+t[1]*a[1]+t[2]*a[2]+e,r=this.projectedRadius(t);return s>r?s-r:s<-r?s+r:0}signedDistanceRangePlane(t){const e=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],a=this.projectedRadius(B(t));return{min:e-a,max:e+a}}toAaBoundingBox(e){const a=this.getQuaternion(T),s=t(dt,a),r=this._data[3]*Math.abs(s[0])+this._data[4]*Math.abs(s[3])+this._data[5]*Math.abs(s[6]),i=this._data[3]*Math.abs(s[1])+this._data[4]*Math.abs(s[4])+this._data[5]*Math.abs(s[7]),n=this._data[3]*Math.abs(s[2])+this._data[4]*Math.abs(s[5])+this._data[5]*Math.abs(s[8]);e[0]=this._data[0]-r,e[1]=this._data[1]-i,e[2]=this._data[2]-n,e[3]=this._data[0]+r,e[4]=this._data[1]+i,e[5]=this._data[2]+n}transform(t,e,a,s=0,r=D(a),i=D(e),n=k(e,i)){if(a===r)e.isGeographic?rt(this,t,e,s,i):st(this,t,e,s,i,n);else if(e.isGeographic&&(a.isWebMercator||Z(a)))tt(e,this,a,t,s);else if(e.isWebMercator&&Z(a))et(e,this,a,t,s);else{const r=this.getCenter(ht);r[2]+=s,F(r,e,0,r,a,0),t.center=r,this!==t&&(t.quaternion=this.getQuaternion(T),t.halfSize=this.getHalfSize(ft))}}}const O=h(),T=h(),E=h(),I=P(),J=P(),N=v();function V(t,e=new G){return X(t,e),e}const K=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],L=(()=>{const t=new Int8Array(162);let e=0;const a=a=>{for(let s=0;s<a.length;s++)t[e+s]=a[s];e+=6};return a([6,2,3,1,5,4]),a([0,2,3,1,5,4]),a([0,2,3,7,5,4]),a([0,1,3,2,6,4]),a([0,1,3,2,0,0]),a([0,1,5,7,3,2]),a([0,1,3,7,6,4]),a([0,1,3,7,6,2]),a([0,1,5,7,6,2]),a([0,1,5,4,6,2]),a([0,1,5,4,0,0]),a([0,1,3,7,5,4]),a([0,2,6,4,0,0]),a([0,0,0,0,0,0]),a([1,3,7,5,0,0]),a([2,3,7,6,4,0]),a([2,3,7,6,0,0]),a([2,3,1,5,7,6]),a([0,1,5,7,6,2]),a([0,1,5,7,6,4]),a([0,1,3,7,6,4]),a([4,5,7,6,2,0]),a([4,5,7,6,0,0]),a([4,5,1,3,7,6]),a([0,2,3,7,5,4]),a([6,2,3,7,5,4]),a([6,2,3,1,5,4]),t})();function $(t,e,a,s,r){const n=t.getQuaternion(T);r.quaternion=n,i(O,n);const o=t.getCenter(ht),h=t.getHalfSize(ft);if(1===s){f(_t,o,O),M(gt,_t),S(pt,gt,h),b(pt,gt,pt);const s=z(pt);g(pt,gt,h);const i=z(pt);if(s<a)r.center=o,c(_t,a,a,a),r.halfSize=g(_t,h,_t);else{const n=i>0?1+e/i:1,o=s>0?1+a/s:1,c=(o+n)/2,d=(o-n)/2;m(pt,gt,d),r.halfSize=x(pt,pt,h,c),m(pt,gt,c),x(pt,pt,h,d),y(_t,_t),C(_t,pt,_t);const u=t.getQuaternion(E);r.center=f(_t,_t,u)}}else{r.center=x(_t,o,R,(a+e)/2);const t=f(_t,R,O);M(t,t),r.halfSize=x(gt,h,t,(a-e)/2)}return r}function tt(t,e,a,s,r){e.getCenter(ht),ht[2]+=r;const i=D(a);F(ht,t,0,ht,i,0),at(i,e,ht,a,s)}function et(t,e,a,s,r){e.getCenter(ht),ht[2]+=r,at(t,e,ht,a,s)}function at(e,a,s,r,i){const n=a.getQuaternion(T),o=t(dt,n),h=a.getHalfSize(ft);for(let t=0;t<8;++t){for(let e=0;e<3;++e)ot[e]=h[e]*(t&1<<e?-1:1);for(let e=0;e<3;++e){let a=s[e];for(let t=0;t<3;++t)a+=ot[t]*o[3*t+e];it[3*t+e]=a}}F(it,e,0,it,r,0,8),V(nt,i)}function st(t,e,a,s,r=D(a),o=k(a,r)){t.getCorners(lt),t.getCenter(ot),ot[2]+=s,H(a,ot,ut,r),e.setCenter(ut[12],ut[13],ut[14]);const h=2*Math.sqrt(1+ut[0]+ut[5]+ut[10]);O[0]=(ut[6]-ut[9])/h,O[1]=(ut[8]-ut[2])/h,O[2]=(ut[1]-ut[4])/h,O[3]=.25*h;const d=t.getQuaternion(T);e.quaternion=n(O,O,d),i(O,O),c(gt,0,0,0);const u=e.getCenter(ct);for(const i of lt)i[2]+=s,o(i,0,i,0),b(_t,i,u),f(_t,_t,O),M(_t,_t),j(gt,gt,_t);e.halfSize=gt}function rt(t,e,a,s,r=D(a)){const n=w(a),o=1+Math.max(0,s)/(n.radius+t.centerZ);t.getCenter(ot),ot[2]+=s,F(ot,a,0,ot,r,0),e.center=ot;const h=t.getQuaternion(T);e.quaternion=h,i(O,h),c(_t,0,0,1),f(_t,_t,O);const d=t.getHalfSize(ft);c(_t,d[0]*Math.abs(_t[0]),d[1]*Math.abs(_t[1]),d[2]*Math.abs(_t[2])),m(_t,_t,n.inverseFlattening),g(_t,d,_t),e.halfSize=m(_t,_t,o)}const it=new Array(24),nt=new Y(it,3),ot=P(),ht=P(),ct=P(),ft=P(),dt=a(),ut=s(),lt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],mt=[P(),P(),P()],_t=P(),gt=P(),pt=P(),bt=A(-1,-1,-1);function Mt(t){return Array.from(t)}const jt=P(),St=[0,0,0];export{G as Obb,V as compute,$ as computeOffsetObb,Mt as ensurePackedObbData};
2
+ import{fromQuat as t,scale as e}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as r,conjugate as i,multiply as n}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,create as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as c,transformQuat as d,dot as f,cross as u,len as l,scale as _,transformMat3 as m,add as g,transformQuatValues as p,sub as b,abs as M,max as j,min as S,length as z,scaleAndAdd as x,sign as y,multiply as C}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as q,freeze as A,create as P,UNIT_Z as R}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as Q}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{create as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as H}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as w}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as D}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as F}from"../../../geometry/projection/projectBuffer.js";import{getProjector as k}from"../../../geometry/projection/projectors.js";import{getNormal as B}from"../../../geometry/support/plane.js";import{isPlateCarree as Z}from"../../../geometry/support/spatialReferenceUtils.js";import{sv3d as U,sq4d as W}from"../../../geometry/support/vectorStacks.js";import{computeOBB as X}from"./dito.js";import{Vertices as Y}from"../webgl-engine/lib/Attribute.js";class G{constructor(t=q,e=bt,a=o){this._data=[t[0],t[1],t[2],e[0],e[1],e[2],a[0],a[1],a[2],a[3]]}clone(){return G.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(t){const e=new G;return e._copyFromData(t),e}static fromJSON(t){return new G(t.center,t.halfSize,t.quaternion)}copy(t){this._copyFromData(t.data)}_copyFromData(t){for(let e=0;e<10;++e)this._data[e]=t[e]}get center(){return c(U.get(),this._data[0],this._data[1],this._data[2])}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(t){return t[0]=this._data[0],t[1]=this._data[1],t[2]=this._data[2],t}set center(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]}setCenter(t,e,a){this._data[0]=t,this._data[1]=e,this._data[2]=a}get halfSize(){return c(U.get(),this._data[3],this._data[4],this._data[5])}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(t){return t[0]=this._data[3],t[1]=this._data[4],t[2]=this._data[5],t}set halfSize(t){this._data[3]=t[0],this._data[4]=t[1],this._data[5]=t[2]}setHalfSize(t,e,a){this._data[3]=t,this._data[4]=e,this._data[5]=a}get quaternion(){return r(W.get(),this._data[6],this._data[7],this._data[8],this._data[9])}get quaternionConjugate(){return r(W.get(),-this._data[6],-this._data[7],-this._data[8],this._data[9])}getQuaternion(t){return t[0]=this._data[6],t[1]=this._data[7],t[2]=this._data[8],t[3]=this._data[9],t}getQuaternionConjugate(t){return t[0]=-this._data[6],t[1]=-this._data[7],t[2]=-this._data[8],t[3]=this._data[9],t}set quaternion(t){this._data[6]=t[0],this._data[7]=t[1],this._data[8]=t[2],this._data[9]=t[3]}get data(){return this._data}getCorners(t){const e=this._data,a=r(O,e[6],e[7],e[8],e[9]);for(let s=0;s<8;++s){const r=t[s];r[0]=(1&s?-1:1)*e[3],r[1]=(2&s?-1:1)*e[4],r[2]=(4&s?-1:1)*e[5],d(r,r,a),r[0]+=e[0],r[1]+=e[1],r[2]+=e[2]}return t}getAxes(t){const e=this._data,a=r(O,e[6],e[7],e[8],e[9]);return d(t[0],[1,0,0],a),d(t[1],[0,1,0],a),d(t[2],[0,0,1],a),t}intersectsFrustum(t){const{centerX:e,centerY:a,centerZ:s}=this,r=t.planes;for(const f of r){const t=B(f),r=this.projectedRadius(t);if(e*t[0]+a*t[1]+s*t[2]+f[3]-r>0)return!1}const i=this.getAxes(_t),n=t.points,o=this.halfSize;for(let u=0;u<3;++u){const t=i[u],r=-t[0]*e-t[1]*a-t[2]*s,h=o[u];let c=!0,d=!0;for(const e of n){const a=f(e,t)+r;c&&=a>h,d&&=a<-h}if(c||d)return!1}if(this.getCorners(lt).some(e=>t.intersectsPoint(e)))return!0;const h=St;for(let f=0;f<3;++f){const t=i[f];h[f]=t[0]*e+t[1]*a+t[2]*s}const c=t=>{for(let e=0;e<3;++e){const a=i[e],s=o[e],r=a[0]*t[0]+a[1]*t[1]+a[2]*t[2]-h[e];if(r>s||r<-s)return!1}return!0};if(t.points.some(t=>c(t)))return!0;const d=t.lines,m=jt;for(let g=0;g<8;++g){const t=d[g].direction;for(const r of i){u(m,t,r);const i=l(m);if(!(i>0))continue;_(m,m,1/i);const o=this.projectedRadius(m),h=m[0]*e+m[1]*a+m[2]*s,c=h-o,d=h+o;let g=!1,p=!1,b=!0;for(const t of n){const e=f(m,t);if(e>d){if(p){b=!1;break}g=!0}else{if(!(e<c)){b=!1;break}if(g){b=!1;break}p=!0}}if(b)return!1}}return!0}intersectsFrustumConservativeApproximation(t){return this.intersectPlane(t[0])<=0&&this.intersectPlane(t[1])<=0&&this.intersectPlane(t[2])<=0&&this.intersectPlane(t[3])<=0&&this.intersectPlane(t[4])<=0&&this.intersectPlane(t[5])<=0}get radius(){const t=this._data[3],e=this._data[4],a=this._data[5];return Math.sqrt(t*t+e*e+a*a)}intersectsPoint(t){const e=this.getAxes(_t),a=this.halfSize,{center:s}=this;for(let r=0;r<3;++r){const i=e[r],n=a[r],o=f(i,t)-f(i,s);if(o>n||o<-n)return!1}return!0}intersectSphere(t){const{center:e,radius:a}=t,s=this._data,r=s[3],i=s[4],n=s[5],o=r+i+n+a,h=s[0]-e[0];if(Math.abs(h)>o)return!1;const c=s[1]-e[1];if(Math.abs(c)>o)return!1;const d=s[2]-e[2];if(Math.abs(d)>o)return!1;const f=-s[6],u=-s[7],l=-s[8],_=u*d-l*c,m=l*h-f*d,g=f*c-u*h,p=u*g-l*m,b=l*_-f*g,M=f*m-u*_,j=2*s[9],S=Math.abs(h+_*j+2*p),z=Math.abs(c+m*j+2*b),x=Math.abs(d+g*j+2*M),y=S-Math.min(S,r),C=z-Math.min(z,i),q=x-Math.min(x,n);return y*y+C*C+q*q<=a*a}intersectSphereWithMBS(t,e=this.radius){const a=this._data,{center:s,radius:r}=t,i=e+r,n=a[0]-s[0];if(n>i)return!1;const o=a[1]-s[1];if(o>i)return!1;const h=a[2]-s[2];if(h>i)return!1;if(n*n+o*o+h*h>i*i)return!1;const c=-a[6],d=-a[7],f=-a[8],u=d*h-f*o,l=f*n-c*h,_=c*o-d*n,m=d*_-f*l,g=f*u-c*_,p=c*l-d*u,b=2*a[9],M=Math.abs(n+u*b+2*m),j=Math.abs(o+l*b+2*g),S=Math.abs(h+_*b+2*p),z=M-Math.min(M,a[3]),x=j-Math.min(j,a[4]),y=S-Math.min(S,a[5]);return z*z+x*x+y*y<r*r}intersectPlane(t){const e=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],a=this.projectedRadius(B(t));return e>a?1:e<-a?-1:0}intersectRay(t,e,a=0){const s=this._data,r=O;r[0]=-s[6],r[1]=-s[7],r[2]=-s[8],r[3]=s[9],I[0]=t[0]-s[0],I[1]=t[1]-s[1],I[2]=t[2]-s[2];const i=d(I,I,O),n=d(J,e,O);let o=-1/0,h=1/0;const c=this.getHalfSize(dt);for(let d=0;d<3;d++){const t=i[d],e=n[d],s=c[d]+a;if(Math.abs(e)>1e-6){const a=(s-t)/e,r=(-s-t)/e;o=Math.max(o,Math.min(a,r)),h=Math.min(h,Math.max(a,r))}else if(t>s||t<-s)return!1}return o<=h}projectedArea(a,s,r,n){const o=this.getQuaternion(T);i(O,o),I[0]=a[0]-this._data[0],I[1]=a[1]-this._data[1],I[2]=a[2]-this._data[2],d(I,I,O);const h=this.getHalfSize(dt),f=I[0]<-h[0]?-1:I[0]>h[0]?1:0,u=I[1]<-h[1]?-1:I[1]>h[1]?1:0,l=I[2]<-h[2]?-1:I[2]>h[2]?1:0,_=Math.abs(f)+Math.abs(u)+Math.abs(l);if(0===_)return 1/0;const p=1===_?4:6,b=6*(f+3*u+9*l+13);t(ft,o),e(ft,ft,h);const M=this.getCenter(ht);for(let t=0;t<p;t++){const e=L[b+t];c(I,((1&e)<<1)-1,(2&e)-1,((4&e)>>1)-1),m(I,I,ft),g(N,M,I),N[3]=1,Q(N,N,s);const a=1/Math.max(1e-6,N[3]);K[2*t]=N[0]*a,K[2*t+1]=N[1]*a}const j=2*p-2;let S=K[0]*(K[3]-K[j+1])+K[j]*(K[1]-K[j-1]);for(let t=2;t<j;t+=2)S+=K[t]*(K[t+3]-K[t-1]);return Math.abs(S)*r*n*.125}projectedRadius(t){const e=this._data;return p(I,t,-e[6],-e[7],-e[8],e[9]),Math.abs(I[0]*e[3])+Math.abs(I[1]*e[4])+Math.abs(I[2]*e[5])}signedDistancePlane(t,e){const a=this._data,s=t[0]*a[0]+t[1]*a[1]+t[2]*a[2]+e,r=this.projectedRadius(t);return s>r?s-r:s<-r?s+r:0}signedDistanceRangePlane(t){const e=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],a=this.projectedRadius(B(t));return{min:e-a,max:e+a}}toAaBoundingBox(e){const a=this.getQuaternion(T),s=t(ft,a),r=this._data[3]*Math.abs(s[0])+this._data[4]*Math.abs(s[3])+this._data[5]*Math.abs(s[6]),i=this._data[3]*Math.abs(s[1])+this._data[4]*Math.abs(s[4])+this._data[5]*Math.abs(s[7]),n=this._data[3]*Math.abs(s[2])+this._data[4]*Math.abs(s[5])+this._data[5]*Math.abs(s[8]);e[0]=this._data[0]-r,e[1]=this._data[1]-i,e[2]=this._data[2]-n,e[3]=this._data[0]+r,e[4]=this._data[1]+i,e[5]=this._data[2]+n}transform(t,e,a,s=0,r=w(a),i=w(e),n=k(e,i)){if(a===r)e.isGeographic?rt(this,t,e,s,i):st(this,t,e,s,i,n);else if(e.isGeographic&&(a.isWebMercator||Z(a)))tt(e,this,a,t,s);else if(e.isWebMercator&&Z(a))et(e,this,a,t,s);else{const r=this.getCenter(ht);r[2]+=s,F(r,e,0,r,a,0),t.center=r,this!==t&&(t.quaternion=this.getQuaternion(T),t.halfSize=this.getHalfSize(dt))}}}const O=h(),T=h(),E=h(),I=P(),J=P(),N=v();function V(t,e=new G){return X(t,e),e}const K=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],L=(()=>{const t=new Int8Array(162);let e=0;const a=a=>{for(let s=0;s<a.length;s++)t[e+s]=a[s];e+=6};return a([6,2,3,1,5,4]),a([0,2,3,1,5,4]),a([0,2,3,7,5,4]),a([0,1,3,2,6,4]),a([0,1,3,2,0,0]),a([0,1,5,7,3,2]),a([0,1,3,7,6,4]),a([0,1,3,7,6,2]),a([0,1,5,7,6,2]),a([0,1,5,4,6,2]),a([0,1,5,4,0,0]),a([0,1,3,7,5,4]),a([0,2,6,4,0,0]),a([0,0,0,0,0,0]),a([1,3,7,5,0,0]),a([2,3,7,6,4,0]),a([2,3,7,6,0,0]),a([2,3,1,5,7,6]),a([0,1,5,7,6,2]),a([0,1,5,7,6,4]),a([0,1,3,7,6,4]),a([4,5,7,6,2,0]),a([4,5,7,6,0,0]),a([4,5,1,3,7,6]),a([0,2,3,7,5,4]),a([6,2,3,7,5,4]),a([6,2,3,1,5,4]),t})();function $(t,e,a,s,r){const n=t.getQuaternion(T);r.quaternion=n,i(O,n);const o=t.getCenter(ht),h=t.getHalfSize(dt);if(1===s){d(mt,o,O),M(gt,mt),S(pt,gt,h),b(pt,gt,pt);const s=z(pt);g(pt,gt,h);const i=z(pt);if(s<a)r.center=o,c(mt,a,a,a),r.halfSize=g(mt,h,mt);else{const n=i>0?1+e/i:1,o=s>0?1+a/s:1,c=(o+n)/2,f=(o-n)/2;_(pt,gt,f),r.halfSize=x(pt,pt,h,c),_(pt,gt,c),x(pt,pt,h,f),y(mt,mt),C(mt,pt,mt);const u=t.getQuaternion(E);r.center=d(mt,mt,u)}}else{r.center=x(mt,o,R,(a+e)/2);const t=d(mt,R,O);M(t,t),r.halfSize=x(gt,h,t,(a-e)/2)}return r}function tt(t,e,a,s,r){e.getCenter(ht),ht[2]+=r;const i=w(a);F(ht,t,0,ht,i,0),at(i,e,ht,a,s)}function et(t,e,a,s,r){e.getCenter(ht),ht[2]+=r,at(t,e,ht,a,s)}function at(e,a,s,r,i){const n=a.getQuaternion(T),o=t(ft,n),h=a.getHalfSize(dt);for(let t=0;t<8;++t){for(let e=0;e<3;++e)ot[e]=h[e]*(t&1<<e?-1:1);for(let e=0;e<3;++e){let a=s[e];for(let t=0;t<3;++t)a+=ot[t]*o[3*t+e];it[3*t+e]=a}}F(it,e,0,it,r,0,8),V(nt,i)}function st(t,e,a,s,r=w(a),o=k(a,r)){t.getCorners(lt),t.getCenter(ot),ot[2]+=s,D(a,ot,ut,r),e.setCenter(ut[12],ut[13],ut[14]);const h=2*Math.sqrt(1+ut[0]+ut[5]+ut[10]);O[0]=(ut[6]-ut[9])/h,O[1]=(ut[8]-ut[2])/h,O[2]=(ut[1]-ut[4])/h,O[3]=.25*h;const f=t.getQuaternion(T);e.quaternion=n(O,O,f),i(O,O),c(gt,0,0,0);const u=e.getCenter(ct);for(const i of lt)i[2]+=s,o(i,0,i,0),b(mt,i,u),d(mt,mt,O),M(mt,mt),j(gt,gt,mt);e.halfSize=gt}function rt(t,e,a,s,r=w(a)){const n=H(a),o=1+Math.max(0,s)/(n.radius+t.centerZ);t.getCenter(ot),ot[2]+=s,F(ot,a,0,ot,r,0),e.center=ot;const h=t.getQuaternion(T);e.quaternion=h,i(O,h),c(mt,0,0,1),d(mt,mt,O);const f=t.getHalfSize(dt);c(mt,f[0]*Math.abs(mt[0]),f[1]*Math.abs(mt[1]),f[2]*Math.abs(mt[2])),_(mt,mt,n.inverseFlattening),g(mt,f,mt),e.halfSize=_(mt,mt,o)}const it=new Array(24),nt=new Y(it,3),ot=P(),ht=P(),ct=P(),dt=P(),ft=a(),ut=s(),lt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],_t=[P(),P(),P()],mt=P(),gt=P(),pt=P(),bt=A(-1,-1,-1);function Mt(t){return Array.from(t)}const jt=P(),St=[0,0,0];export{G as Obb,V as compute,$ as computeOffsetObb,Mt as ensurePackedObbData};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{on as i}from"../../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{distance as n,exactEquals as a,copy as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../geometry/Point.js";import{distanceToScale as h}from"../cameraUtils.js";import{PointOfInterest as p}from"./PointOfInterest.js";import{PropertiesPool as u}from"../../../support/PropertiesPool.js";import{Yield as m}from"../../../support/Yield.js";let _=class extends p{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new u({location:()=>new c,renderLocation:()=>d()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryController=null,this.renderLocation=d(),this._tmpPoint=new c}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(i(()=>this.map?.ground?.layers,"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=n(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return h(r,e)}get updating(){return this._dirty||null!=this._elevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._elevationQueryController;t&&(this._elevationQueryController=null,t.abort(),this.notifyChange("updating"))}get readyToRun(){return!this._elevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),m;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>f&&1===this.renderCoordsHelper.viewingMode&&(t.isWGS84||t.isWebMercator);let i=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:i.signal,cache:this.cache,minDemResolution:e?g:0}).then(t=>this._updateSurfaceAltitude(t.geometry.z??0)).catch(t=>{r(t)||this._updateSurfaceAltitude(0)}).finally(()=>{this._elevationQueryController===i&&(this._elevationQueryController=null,this.notifyChange("updating")),i=null}),this._elevationQueryController=i,this.notifyChange("updating"),m}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(y,this._estimatedSurfaceAltitude,this._camera.eye),a(this._get("renderLocation"),y)||(this._set("renderLocation",l(this._propertiesPool.get("renderLocation"),y)),this.notifyChange("renderLocation"))}};t([o({constructOnly:!0})],_.prototype,"scheduler",void 0),t([o({constructOnly:!0})],_.prototype,"cache",void 0),t([o({constructOnly:!0})],_.prototype,"map",void 0),t([o({constructOnly:!0})],_.prototype,"task",void 0),t([o()],_.prototype,"location",null),t([o()],_.prototype,"renderLocation",void 0),t([o()],_.prototype,"scale",null),t([o()],_.prototype,"updating",null),_=t([s("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],_);const y=d(),f=1e5,g=1e6;export{_ as CameraOnSurface};
2
+ import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{on as i}from"../../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{distance as n,exactEquals as a,copy as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../geometry/Point.js";import{distanceToScale as h}from"../cameraScaleUtils.js";import{PointOfInterest as p}from"./PointOfInterest.js";import{PropertiesPool as u}from"../../../support/PropertiesPool.js";import{Yield as m}from"../../../support/Yield.js";let _=class extends p{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new u({location:()=>new c,renderLocation:()=>d()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryController=null,this.renderLocation=d(),this._tmpPoint=new c}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(i(()=>this.map?.ground?.layers,"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=n(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return h(r,e)}get updating(){return this._dirty||null!=this._elevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._elevationQueryController;t&&(this._elevationQueryController=null,t.abort(),this.notifyChange("updating"))}get readyToRun(){return!this._elevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),m;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>f&&1===this.renderCoordsHelper.viewingMode&&(t.isWGS84||t.isWebMercator);let i=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:i.signal,cache:this.cache,minDemResolution:e?g:0}).then(t=>this._updateSurfaceAltitude(t.geometry.z??0)).catch(t=>{r(t)||this._updateSurfaceAltitude(0)}).finally(()=>{this._elevationQueryController===i&&(this._elevationQueryController=null,this.notifyChange("updating")),i=null}),this._elevationQueryController=i,this.notifyChange("updating"),m}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(y,this._estimatedSurfaceAltitude,this._camera.eye),a(this._get("renderLocation"),y)||(this._set("renderLocation",l(this._propertiesPool.get("renderLocation"),y)),this.notifyChange("renderLocation"))}};t([o({constructOnly:!0})],_.prototype,"scheduler",void 0),t([o({constructOnly:!0})],_.prototype,"cache",void 0),t([o({constructOnly:!0})],_.prototype,"map",void 0),t([o({constructOnly:!0})],_.prototype,"task",void 0),t([o()],_.prototype,"location",null),t([o()],_.prototype,"renderLocation",void 0),t([o()],_.prototype,"scale",null),t([o()],_.prototype,"updating",null),_=t([s("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],_);const y=d(),f=1e5,g=1e6;export{_ as CameraOnSurface};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{projectBuffer as e}from"../../../../geometry/projection/projectBuffer.js";import{newDoubleArray as o,doubleSubArray as t}from"../../../../geometry/support/DoubleArray.js";import{ringsToTriangulationInfo as n}from"../../../../geometry/support/triangulationUtilsDeprecated.js";import{applyPerVertexElevationAlignment as r}from"../../layers/graphics/elevationAlignmentUtils.js";import{drapedZ as i}from"../../terrain/OverlayRenderer.js";function s(e,t,i,s){const p="polygon"===e.type?1:0,a="polygon"===e.type?e.rings:e.paths,{position:c,outlines:u}=n(a,!!e.hasZ,p,e.spatialReference),f=o(c.length),m=r(c,e.spatialReference,0,f,0,c,0,c.length/3,t,i,s),g=null!=m;return{lines:g?l(u,c,f):[],projectionSuccess:g,sampledElevation:m}}function p(o,t){const r="polygon"===o.type?1:0,s="polygon"===o.type?o.rings:o.paths,{position:p,outlines:a}=n(s,!1,r,o.spatialReference),c=e(p,o.spatialReference,0,p,t,0);for(let e=2;e<p.length;e+=3)p[e]=i;return{lines:c?l(a,p):[],projectionSuccess:c}}function l(e,o,n=null){const r=new Array;for(const{index:i,count:s}of e){if(s<=1)continue;const e=3*i,p=3*s;r.push({position:t(o,3*i,3*s),mapPositions:null!=n?t(n,e,p):void 0})}return r}export{s as geometryToRenderInfo,p as geometryToRenderInfoDraped};
2
+ import{projectBuffer as e}from"../../../../geometry/projection/projectBuffer.js";import{newDoubleArray as o,doubleSubArray as n}from"../../../../geometry/support/DoubleArray.js";import{applyPerVertexElevationAlignment as t}from"../../layers/graphics/elevationAlignmentUtils.js";import{ringsToOutlinedTessellationInfo as s}from"../../layers/graphics/tessellationUtils.js";import{drapedZ as r}from"../../terrain/OverlayRenderer.js";function i(e,n,r,i){const l="polygon"===e.type,a="polygon"===e.type?e.rings:e.paths,{positions:c,outlines:f}=s(a,{hasZ:!!e.hasZ,ccwRingsAsHoles:l,spatialReference:e.spatialReference}),u=o(c.length),g=t(c,e.spatialReference,0,u,0,c,0,c.length/3,n,r,i),m=null!=g;return{lines:m?p(f,c,u):[],projectionSuccess:m,sampledElevation:g}}function l(o,n){const t="polygon"===o.type,i="polygon"===o.type?o.rings:o.paths,{positions:l,outlines:a}=s(i,{hasZ:!1,ccwRingsAsHoles:t,spatialReference:o.spatialReference}),c=e(l,o.spatialReference,0,l,n,0);for(let e=2;e<l.length;e+=3)l[e]=r;return{lines:c?p(a,l):[],projectionSuccess:c}}function p(e,o,t=null){const s=new Array;for(const{index:r,count:i}of e){if(i<=1)continue;const e=3*r,l=3*i;s.push({position:n(o,3*r,3*i),mapPositions:null!=t?n(t,e,l):void 0})}return s}export{i as geometryToRenderInfo,l as geometryToRenderInfoDraped};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import{cyclicalDegrees as o}from"../../../core/Cyclical.js";import a from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scale as u,add as f,distance as p,copy as g,subtract as y,set as h,transformMat3 as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectAsync as R,tryProject as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as B}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as M}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as S}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as A,empty as E,expandWithVec3 as V,expandWithAABB as O,width as U,height as k,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as W}from"../../../geometry/support/centroid.js";import{intersectsPoint as Y}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as q}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as D,toRenderCamera as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{getViewSR as _,fromExtentAsync as H,scaleToDistance as K,fromCenterDistanceAsync as L,fromExtentSync as Q,distanceToScale as $,fromCenterDistanceSync as tt,fromCenterScale as et,zoomToScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as rt}from"./ElevationProvider.js";import{directionToHeadingTilt as ot}from"./viewingModeUtils.js";const at=.66;function it(t){return 360-o.normalize(t)}function st(t){return o.normalize(360-t)}function ct(t,e,n){const r=e.camera;if(null!=r)return mt(r,_(t));const{targetGeometry:o}=e;if(null==o)return null;const{camera:a,mode:i}=ft(t,e.rotation,n);if("point"===o.type)return pt(t,e,o,a,i);const s=o.extent;return null==s?null:Q(t,s,a.heading,a.tilt,i)}async function lt(t,e,n,r){const o=e.camera;if(null!=o)return ut(o,_(t),r);const{targetGeometry:a}=e;if(null==a)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===a.type)return gt(t,e,a,i,s,r);const c=a.extent;if(null==c)throw new Error("Target geometry has no extent!");return H(t,c,i.heading,i.tilt,s,r)}function mt(t,e){const n=t.position,r=z(n,e);if(!r)return null;const o=t.clone();return o.position=r.clone(),o}async function ut(t,e,n){const r=t.position,o=await R(r,e,{signal:n});i(n);const a=t.clone();return a.position=o.clone(),a}function ft(t,e,n){const r=D(t,t.state.camera);let o=1;return null!=e&&(r.heading=it(e),o=0),null!=n&&(r.tilt=n),{camera:r,mode:o}}function pt(t,e,n,r,o){const a=t.spatialReference,i=z(n.clone(),a);if(!i)return null;const s=null!=e.scale?K(t,e.scale):t.state.camera.distance;return tt(t,i,s,r,o)}async function gt(t,e,n,r,o,a){const s=t.spatialReference,c=await R(n.clone(),s,{signal:a});i(a);const l=null!=e.scale?K(t,e.scale):t.state.camera.distance;return L(t,c,l,r,o,a)}function yt(t,e,r=null){return null==r&&(r=new n),jt(t,null,e.clone(),r)}async function ht(e,r,o){const i=At(e,r);if(!i)throw new a("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Et(await zt(e,i.target,i,o,c))}if(i.target instanceof t)return Et(await Gt(e,i.target,o,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Et(l||t?await Mt(e,i,i.target.center,s,o,c):await Ft(e,i,i.target,s,o,c))}const m=new Ot,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,o),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ut),Jt.x=Ut[0],Jt.y=Ut[1],Jt.z=Ut[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=A(m.boundingBox):(Jt.z=void 0,t=C(P(m.boundingBox,Ct))),l||t)return Et(await Mt(e,i,Jt,s,o,c));const n=Vt(e,m.screenSpaceObjects);return Et(await Pt(e,i,Jt,m.boundingBox,n,s,o,c))}return i.position?Et(await St(e,i,s,c,o)):Et(await Zt(e,i,s,o,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?nt(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?q(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,r){const o=t.spatialReference||G.WGS84;if(e??=J(t,n),null==e)return r;const a=new b({spatialReference:o});return S(e.center,t.renderSpatialReference,a)?(r.targetGeometry=a,r.scale=$(t,e.distance),r.rotation=st(n.heading),r.camera=n,r):r}async function vt(t,e,n,r){const o=()=>new a("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw o();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":{const t=W(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:r}),Ut[2]=rt(t.elevationProvider,n)??0):Ut[2]=0}const s=Xt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ut),0===c.length)throw o();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[a,f,p]of u.points)Ut[0]=a,Ut[1]=f,Ut[2]=p,V(n.boundingBox,Ut);else for(const[a,f]of u.points)Ut[0]=a,Ut[1]=f,V(n.boundingBox,Ut)}async function bt(t,e,n,o,a){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,o,a);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,o,a);const{screenSpaceObjects:l,boundingBox:m}=c.value;O(o.boundingBox,m),l&&l.forEach(t=>{o.screenSpaceObjects.push(t)}),isFinite(m[2])&&(o.hasZ=!0)}async function Rt(t,n,r,o,a){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Jt.x=e,Jt.y=r,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,o,a)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,r,o,a))):n instanceof j?await vt(t,n,o,a):n instanceof e&&await bt(t,n,r,o,a)}async function zt(t,e,n,r,o){if(e.camera)return Gt(t,e.camera,r,o);o.scale=e.scale,o.rotation=e.rotation,o.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,o.camera=null,null!=n.heading?o.rotation=st(n.heading):null!=n.rotation&&(o.rotation=n.rotation);const a=dt(t,n);return null!=a&&(o.scale=a),o.camera=await lt(t,o,n.tilt,r),o}async function Gt(t,e,n,r){const o=t.spatialReference,a=await R(e.position,o,{signal:n}),i=e.clone();return i.position=a,jt(t,null,i,r)}async function Bt(t,e,n,r,o,a,i){const s=t.renderSpatialReference;return await M(e,qt,s,{signal:i}),await M(n,Yt,s,{signal:i}),a.targetGeometry=new b(e),o.position=new b(n),y(Wt,qt,Yt),ot(t,Yt,Wt,r.up,o),a.scale=$(t,p(Yt,qt)),a.rotation=st(o.heading),a.camera=o,a}async function Mt(t,e,n,r,o,a){a.targetGeometry=n.clone();const i=X(t);if(e.position)return Bt(t,a.targetGeometry,e.position,i,r,a,o);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ut,i.viewForward,-n);i.eye=f(Ut,i.center,r),a.scale=$(t,n)}D(t,i,r);const s=xt(r,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await M(a.targetGeometry,Ut,t.renderSpatialReference,{signal:o});const e=Y(i.frustum,Ut)?p(i.eye,Ut):i.distance;a.camera=await L(t,a.targetGeometry,e,r,s),a.scale=$(t,e)}else a.scale=n,a.camera=await et(t,a.targetGeometry,a.scale,r,s,o)}return a}async function St(t,e,n,r,o){const a=X(t);g(Wt,a.viewForward),ot(t,a.eye,Wt,a.up,Dt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:o});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:Dt.heading,n.tilt=null!=e.tilt?e.tilt:Dt.tilt,jt(t,null,n,r)}async function Zt(t,e,n,r,o){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const a=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return S(a.center,s,c)?Mt(t,e,c,n,r,o):o}return o.scale=t.scale,o.camera=t.camera.clone(),xt(o.camera,e),o}async function Ft(t,e,n,r,o,a){a.targetGeometry=n.clone();const i=X(t);D(t,i,r);const s=xt(r,e)?0:1;return a.camera=await H(t,n,r.heading,r.tilt,s,o),a}function Tt(t,e,n,r,o){let a=0;null!=n.z?a=n.z:t.basemapTerrain&&t.elevationProvider&&(a=rt(t.elevationProvider,n)),h(Ut,n.x,n.y,a),B(t.spatialReference,Ut,kt,t.renderSpatialReference),s(Nt,kt),c(Nt,Nt),E(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=r[e[2]];isFinite(n)||(n=a),h(Ut,r[e[0]],r[e[1]],n),Z(Ut,t.spatialReference,Ut,t.renderSpatialReference),V(It,d(Ut,Ut,Nt))}const l=U(It),m=k(It),u=N(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/o}async function Pt(t,e,n,r,o,a,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,r,o);D(t,c,a);const m=xt(a,e)?0:1;return s.camera=await L(t,s.targetGeometry,l,a,m,i),s.scale=$(t,l),s}function At(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Et(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Vt(t,e){const n=at;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let o=0;o<e.length;o++){const t=e[o].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class Ot{constructor(){this.hasZ=!1,this.boundingBox=E(),this.screenSpaceObjects=new Array}}const Ut=w(),kt=m(),Nt=l(),It=F(),Ct=I(),Wt=w(),Yt=w(),qt=w(),Dt={heading:0,tilt:0},Jt=new b,Xt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const r=t.hasZ;for(let o=0;o<t.rings.length;o++){const a=t.rings[o];for(let t=0;t<a.length;t++)n[0]=a[t][0],n[1]=a[t][1],r&&(n[2]=a[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let o=0;o<t.paths.length;o++){const a=t.paths[o];for(let t=0;t<a.length;t++)n[0]=a[t][0],n[1]=a[t][1],r&&(n[2]=a[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,o=t.hasZ;for(let a=0;a<r.length;a++)n[0]=r[a][0],n[1]=r[a][1],o&&(n[2]=r[a][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
2
+ import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import{cyclicalDegrees as a}from"../../../core/Cyclical.js";import o from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scale as u,add as f,distance as p,copy as g,subtract as y,set as h,transformMat3 as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectAsync as R,tryProject as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as S}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as B}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as M}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as A,empty as E,expandWithVec3 as U,expandWithAABB as V,width as O,height as k,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as W}from"../../../geometry/support/centroid.js";import{intersectsPoint as Y}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as q}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as D,toRenderCameraWithScale as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{scaleToDistance as _,distanceToScale as H}from"./cameraScaleUtils.js";import{getViewSR as K,fromExtentAsync as L,fromCenterDistanceAsync as Q,fromExtentSync as $,fromCenterDistanceSync as tt,zoomToScale as et,fromCenterScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as rt}from"./ElevationProvider.js";import{directionToHeadingTilt as at}from"./viewingModeUtils.js";const ot=.66;function it(t){return 360-a.normalize(t)}function st(t){return a.normalize(360-t)}function ct(t,e,n){const r=e.camera;if(null!=r)return mt(r,K(t));const{targetGeometry:a}=e;if(null==a)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===a.type)return pt(t,e,a,o,i);const s=a.extent;return null==s?null:$(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,r){const a=e.camera;if(null!=a)return ut(a,K(t),r);const{targetGeometry:o}=e;if(null==o)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===o.type)return gt(t,e,o,i,s,r);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return L(t,c,i.heading,i.tilt,s,r)}function mt(t,e){const n=t.position,r=z(n,e);if(!r)return null;const a=t.clone();return a.position=r.clone(),a}async function ut(t,e,n){const r=t.position,a=await R(r,e,{signal:n});i(n);const o=t.clone();return o.position=a.clone(),o}function ft(t,e,n){const r=D(t,t.state.camera);let a=1;return null!=e&&(r.heading=it(e),a=0),null!=n&&(r.tilt=n),{camera:r,mode:a}}function pt(t,e,n,r,a){const o=t.spatialReference,i=z(n.clone(),o);if(!i)return null;const s=null!=e.scale?_(t,e.scale):t.state.camera.distance;return tt(t,i,s,r,a)}async function gt(t,e,n,r,a,o){const s=t.spatialReference,c=await R(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?_(t,e.scale):t.state.camera.distance;return Q(t,c,l,r,a,o)}function yt(t,e,r=null){return null==r&&(r=new n),jt(t,null,e.clone(),r)}async function ht(e,r,a){const i=At(e,r);if(!i)throw new o("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Et(await zt(e,i.target,i,a,c))}if(i.target instanceof t)return Et(await Gt(e,i.target,a,c,dt(e,i)));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Et(l||t?await Bt(e,i,i.target.center,s,a,c):await Ft(e,i,i.target,s,a,c))}const m=new Vt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,a),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ot),Jt.x=Ot[0],Jt.y=Ot[1],Jt.z=Ot[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=A(m.boundingBox):(Jt.z=void 0,t=C(P(m.boundingBox,Ct))),l||t)return Et(await Bt(e,i,Jt,s,a,c));const n=Ut(e,m.screenSpaceObjects);return Et(await Pt(e,i,Jt,m.boundingBox,n,s,a,c))}return i.position?Et(await Mt(e,i,s,c,a)):Et(await Zt(e,i,s,a,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?et(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?q(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,r,a){const o=t.spatialReference||G.WGS84;if(e??=J(t,n,a),null==e)return r;const i=new b({spatialReference:o});return M(e.center,t.renderSpatialReference,i)?(r.targetGeometry=i,r.scale=a??H(t,e.distance),r.rotation=st(n.heading),r.camera=n,r):r}async function vt(t,e,n,r){const a=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw a();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":{const t=W(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:r}),Ot[2]=rt(t.elevationProvider,n)??0):Ot[2]=0}const s=Xt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ot),0===c.length)throw a();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ot[0]=o,Ot[1]=f,Ot[2]=p,U(n.boundingBox,Ot);else for(const[o,f]of u.points)Ot[0]=o,Ot[1]=f,U(n.boundingBox,Ot)}async function bt(t,e,n,a,o){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,a,o);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,a,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;V(a.boundingBox,m),l&&l.forEach(t=>{a.screenSpaceObjects.push(t)}),isFinite(m[2])&&(a.hasZ=!0)}async function Rt(t,n,r,a,o){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Jt.x=e,Jt.y=r,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,a,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,r,a,o))):n instanceof j?await vt(t,n,a,o):n instanceof e&&await bt(t,n,r,a,o)}async function zt(t,e,n,r,a){if(e.camera)return Gt(t,e.camera,r,a,dt(t,n)??e.scale);a.scale=e.scale,a.rotation=e.rotation,a.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,a.camera=null,null!=n.heading?a.rotation=st(n.heading):null!=n.rotation&&(a.rotation=n.rotation);const o=dt(t,n);return null!=o&&(a.scale=o),a.camera=await lt(t,a,n.tilt,r),a}async function Gt(t,e,n,r,a){const o=t.spatialReference,i=await R(e.position,o,{signal:n}),s=e.clone();return s.position=i,jt(t,null,s,r,a)}async function St(t,e,n,r,a,o,i){const s=t.renderSpatialReference;return await B(e,qt,s,{signal:i}),await B(n,Yt,s,{signal:i}),o.targetGeometry=new b(e),a.position=new b(n),y(Wt,qt,Yt),at(t,Yt,Wt,r.up,a),o.scale=H(t,p(Yt,qt)),o.rotation=st(a.heading),o.camera=a,o}async function Bt(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=X(t);if(e.position)return St(t,o.targetGeometry,e.position,i,r,o,a);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ot,i.viewForward,-n);i.eye=f(Ot,i.center,r),o.scale=H(t,n)}D(t,i,r);const s=xt(r,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await B(o.targetGeometry,Ot,t.renderSpatialReference,{signal:a});const e=Y(i.frustum,Ot)?p(i.eye,Ot):i.distance;o.camera=await Q(t,o.targetGeometry,e,r,s),o.scale=H(t,e)}else o.scale=n,o.camera=await nt(t,o.targetGeometry,o.scale,r,s,a)}return o}async function Mt(t,e,n,r,a){const o=X(t);g(Wt,o.viewForward),at(t,o.eye,Wt,o.up,Dt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:a});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:Dt.heading,n.tilt=null!=e.tilt?e.tilt:Dt.tilt,jt(t,null,n,r,dt(t,e))}async function Zt(t,e,n,r,a){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return M(o.center,s,c)?Bt(t,e,c,n,r,a):a}return a.scale=t.scale,a.camera=t.camera.clone(),xt(a.camera,e),a}async function Ft(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=X(t);D(t,i,r);const s=xt(r,e)?0:1;return o.camera=await L(t,n,r.heading,r.tilt,s,a),o}function Tt(t,e,n,r,a){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=rt(t.elevationProvider,n)),h(Ot,n.x,n.y,o),S(t.spatialReference,Ot,kt,t.renderSpatialReference),s(Nt,kt),c(Nt,Nt),E(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=r[e[2]];isFinite(n)||(n=o),h(Ot,r[e[0]],r[e[1]],n),Z(Ot,t.spatialReference,Ot,t.renderSpatialReference),U(It,d(Ot,Ot,Nt))}const l=O(It),m=k(It),u=N(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/a}async function Pt(t,e,n,r,a,o,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,r,a);D(t,c,o);const m=xt(o,e)?0:1;return s.camera=await Q(t,s.targetGeometry,l,o,m,i),s.scale=H(t,l),s}function At(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Et(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Ut(t,e){const n=ot;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let a=0;a<e.length;a++){const t=e[a].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class Vt{constructor(){this.hasZ=!1,this.boundingBox=E(),this.screenSpaceObjects=new Array}}const Ot=w(),kt=m(),Nt=l(),It=F(),Ct=I(),Wt=w(),Yt=w(),qt=w(),Dt={heading:0,tilt:0},Jt=new b,Xt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const r=t.hasZ;for(let a=0;a<t.rings.length;a++){const o=t.rings[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let a=0;a<t.paths.length;a++){const o=t.paths[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,a=t.hasZ;for(let o=0;o<r.length;o++)n[0]=r[o][0],n[1]=r[o][1],a&&(n[2]=r[o][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as h}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as d,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as P,fallsWithinLayerView as w,sortTiles as O,compareTiles as S}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as D}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as I}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as U}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as L}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as V}from"../../webgl/enums.js";const H=7,z=10,Q=200,W=p();let Z=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new I,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new P,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>1===this._desiredSlot],[7,()=>7===this._desiredSlot],[9,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new L(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get layerViewUid(){return M}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(w(e,i)!==w(t,i))return!1}return!0}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=z-H,i=Math.max(0,Math.floor((e.level-t)/H)*H);if(this._isGlobal&&0===i)return d;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=J,n=K;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,d=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(W,v.boundingBox);const P=_.localOrigin;null!=g&&(g.localOrigin=P,g.applyToAabb(W));const w=W;if(X[0]=i[0]-P[0],X[1]=i[1]-P[1],X[2]=i[2]-P[2],!j(w,X,n,f,b))return;const O=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},S=(n,o,c)=>{if((!T||null!=o)&&n>=0&&(x.backfacesTerrain||h(o,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==d.distance||n<d.distance)&&O(d,n,o),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),O(p,n,o),e.results.all.push(p)):n<p.distance&&O(p,n,o)),(null==a.distance||n<a.distance)&&O(a,n,o),0!==x.store&&(null==l.distance||n>l.distance)&&O(l,n,o)}},D=Y;o(D,r,P);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),I=new E(G.typedBuffer,3,M.stride/4),U=q/3;if(!g&&U>Q){const e=c.renderData;e.intersectionData??=new A(B,U,I),e.intersectionData.intersectRay(X,D,R,S)}else C(X,D,0,U,B,I,g,R,S)},P=this._rootTiles;if(null!=P){(()=>{const t=this._tileIterator;t.reset(P);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillComputationEnabled:r,slot:s,hasEmission:n,useFloatBlend:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(9===s){if(0===(e.renderOccludedMask&b))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.hasShadowHighlights=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.useFloatBlend=a.value,e.output){case 0:case 1:case 2:{const i=e.bind;o.screenSpaceReflections=i.hasScreenSpaceReflections,o.cloudReflections=null!=i.clouds.data;const r=9===s;return o.receiveShadows=t.ready&&!r,o.hasShadowHighlights=U(o,e.bind),o.renderOccluded=r,o.receiveAmbientOcclusion=!r&&null!=i.ssao,o.receiveGlobalIllumination=!r&&null!=i.globalIllumination,o.hasEmission=n,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:return this._acquireTechnique(e.output);case 11:return this._acquireTechnique(11);case 10:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=D(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)O(i,t);e.sort((e,t)=>S(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],V.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=9===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",d),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:d;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?V.LINES:V.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const h of c.values()){const i=h[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of h){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:h,bind:d}=e;s&&(t.useStencil=this._useStencilForTile(i),h.setPipelineState(t.getPipeline(d)));const u=a.geometry.indexCount;h.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),h.drawElements(r,u,o.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(N,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],Z.prototype,"visibleTiles",null),e([a({readOnly:!0})],Z.prototype,"_isGlobal",null),e([a()],Z.prototype,"renderOccludedFlags",null),e([a({value:!1})],Z.prototype,"renderingDisabled",null),e([a({value:!0})],Z.prototype,"visible",null),e([a()],Z.prototype,"renderPatchBorders",null),e([a()],Z.prototype,"wireframe",null),Z=e([l("esri.views.3d.terrain.TerrainRenderer")],Z);const J=_(),K=_(),X=_(),Y=_();export{Z as TerrainRenderer};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as P,fallsWithinLayerView as w,sortTiles as O,compareTiles as S}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as D}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as I}from"../webgl-engine/materials/DrawParameters.js";import{hasShadowHighlights as U}from"../webgl-engine/shaders/ReceiveShadowsConfiguration.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as L}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as V}from"../../webgl/enums.js";const H=7,z=10,Q=200,W=p();let Z=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new I,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new P,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>1===this._desiredSlot],[7,()=>7===this._desiredSlot],[9,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new L(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get layerViewUid(){return M}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(w(e,i)!==w(t,i))return!1}return!0}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=z-H,i=Math.max(0,Math.floor((e.level-t)/H)*H);if(this._isGlobal&&0===i)return h;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=J,n=K;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(W,v.boundingBox);const P=_.localOrigin;null!=g&&(g.localOrigin=P,g.applyToAabb(W));const w=W;if(X[0]=i[0]-P[0],X[1]=i[1]-P[1],X[2]=i[2]-P[2],!j(w,X,n,f,b))return;const O=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},S=(n,o,c)=>{if((!T||null!=o)&&n>=0&&(x.backfacesTerrain||d(o,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&O(h,n,o),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),O(p,n,o),e.results.all.push(p)):n<p.distance&&O(p,n,o)),(null==a.distance||n<a.distance)&&O(a,n,o),0!==x.store&&(null==l.distance||n>l.distance)&&O(l,n,o)}},D=Y;o(D,r,P);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),I=new E(G.typedBuffer,3,M.stride/4),U=q/3;if(!g&&U>Q){const e=c.renderData;e.intersectionData??=new A(B,U,I),e.intersectionData.intersectRay(X,D,R,S)}else C(X,D,0,U,B,I,g,R,S)},P=this._rootTiles;if(null!=P){(()=>{const t=this._tileIterator;t.reset(P);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return 7;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillComputationEnabled:r,slot:s,hasEmission:n,useFloatBlend:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(9===s){if(0===(e.renderOccludedMask&b))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.hasShadowHighlights=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.useFloatBlend=a.value,e.output){case 0:case 1:case 2:{const i=e.bind;o.screenSpaceReflections=i.hasScreenSpaceReflections,o.cloudReflections=null!=i.clouds.data;const r=9===s;return o.receiveShadows=t.ready&&!r,o.hasShadowHighlights=U(o,e.bind),o.renderOccluded=r,o.receiveAmbientOcclusion=!r&&null!=i.ssao,o.receiveGlobalIllumination=!r&&i.globalIlluminationEnabled,o.hasEmission=n,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:return this._acquireTechnique(e.output);case 11:return this._acquireTechnique(11);case 10:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=D(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)O(i,t);e.sort((e,t)=>S(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],V.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=9===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?V.LINES:V.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),d.drawElements(r,u,o.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(N,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],Z.prototype,"visibleTiles",null),e([a({readOnly:!0})],Z.prototype,"_isGlobal",null),e([a()],Z.prototype,"renderOccludedFlags",null),e([a({value:!1})],Z.prototype,"renderingDisabled",null),e([a({value:!0})],Z.prototype,"visible",null),e([a()],Z.prototype,"renderPatchBorders",null),e([a()],Z.prototype,"wireframe",null),Z=e([l("esri.views.3d.terrain.TerrainRenderer")],Z);const J=_(),K=_(),X=_(),Y=_();export{Z as TerrainRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{destroyMaybe as e}from"../../../../../core/maybe.js";import{set as t,transformMat3 as a,add 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{create as i}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as s}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as n}from"../../../support/orientedBoundingBox.js";import{ComponentParametersUniform as l,ComponentParametersVarying as m}from"./ComponentDrawParameters.js";import{UniformComponentParameters as h}from"./UniformComponentParameters.js";import{olidEnabled as c}from"../../effects/geometry/olidUtils.js";import{defaultHighlightName as d}from"../../../../support/HighlightDefaults.js";class p{constructor(e,t,a,r,o,i){this._collection=e,this.transform=t,this.obb=a,this._componentData=r,this._renderable=o,this._intersectionGeometry=i,this.visible=!1,this.offsetObb=null,this._aabbInWorldCoordinates=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}updateMaterial(e,t){const{_renderable:a}=this,r=a.material,o=this._collection.materials.acquire({...r.parameters,opacity:a.opacity,...e},a.geometry.parameters,t??a.drawParameters.componentParameters);this._collection.materials.release(r),o!==r&&a.updateMaterial(o)}get opacity(){return this.renderable.opacity}updateOpacity(e){this.opacity!==e&&(this._renderable.updateOpacity(e),this.updateMaterial({opacity:e}))}updateCameraDerivedParameters(e){const{eye:t}=e,{centerX:a,centerY:r,centerZ:o}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-a)**2+(t[1]-r)**2+(t[2]-o)**2}setComponentData(e,t){const a=this._componentData,{materialDataBuffer:r,materialDataIndices:o}=a,i=new h,d=r.textureBuffer,p=d.getVec4Field("colorAndCastShadows"),f=d.getScalarField("elevationOffset"),b=d.getScalarField("emissiveStrength"),g=d.getScalarField("emissiveSourceMode"),y=d.getVec4Field("olidColor"),_=new Uint8Array(4),v=new Uint32Array(_.buffer);let M,w=0,C=0,S=0,x=0,D=0,O=a.verticalOffsets,P=1/0,j=-1/0,A=!1,I=!1,k=!1,G=0;for(let n=0;n<a.count;n++){e(n,i),w+=+(i.externalColor[3]<1),C+=+(3===i.externalColorMixMode&&1===i.externalColor[3]),x+=+(i.emissiveStrength>0),D+=+(1===i.emissiveSource),I||=1!==i.emissiveStrength,S+=+i.castShadows,s(i.externalColor,i.externalColorMixMode,_),_[2]=254&_[2]|+i.castShadows,p.setArray(o[n],_),A||=n>0&&G!==v[0],G=v[0],k||=0!==i.elevationOffset,k&&null==O&&(O=new Array(n).fill(0)),null!=O&&(O[n]=i.elevationOffset),P=Math.min(P,i.elevationOffset),j=Math.max(j,i.elevationOffset),f.set(o[n],i.elevationOffset),b.set(o[n],i.emissiveStrength),g.set(o[n],0===i.emissiveSource?0:255);const t=i.olidColor;null!=t&&y.setArray(o[n],t),i.pickable!==a.isPickable(n)&&a.updatePickabilityWithCount(n,i.pickable)}if(a.verticalOffsets=k?O:null,this.offsetObb=k?n(this.obb,P,j,t,this.offsetObb??this.obb.clone()):null,A||k||c()||(I||D>0)&&x>0){const{count:e}=a;M=new m(u(w,e),u(C,e),u(x,e),u(D,e),u(S,e)),d.updateTexture(),this._renderable.updateComponentParametersVarying(M,d)}else M=new l(i.externalColor,i.externalColorMixMode,i.emissiveStrength,i.emissiveSource,i.castShadows?0:2),this._renderable.updateComponentParametersUniform(M);this.updateMaterial({},M)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){const e=i(),{positions:s}=this._intersectionGeometry;if(Math.floor(s.length/3)>0){const{rotationScale:i,position:n}=this.transform;let l=1/0,m=1/0,h=1/0,c=-1/0,d=-1/0,p=-1/0;const u=o();for(let e=0;e<s.length;e+=3)t(u,s[e+0],s[e+1],s[e+2]),a(u,u,i),r(u,u,n),l=Math.min(l,u[0]),m=Math.min(m,u[1]),h=Math.min(h,u[2]),c=Math.max(c,u[0]),d=Math.max(d,u[1]),p=Math.max(p,u[2]);e[0]=l,e[1]=m,e[2]=h,e[3]=c,e[4]=d,e[5]=p}return e}submit(e,t){const{componentData:a,renderable:r}=this;if(r.drawParameters.opacity<=0)return;const{geometry:o,drawParameters:i,material:s}=r,n=r.meta.cameraDepthSquared,{geometryRanges:l,highlightRangesMap:m,shadowmapRanges:h}=a,c=e=>e.submitDraw(s,i,o,l,n);switch(s.materialPass){case 0:c(e.opaque);break;case 1:c(e.transparent);break;case 2:c(e.opaque),c(e.transparent);break;case 3:c(e.integratedMesh),f(t)&&c(e.occludedGround),b(t)&&c(e.highlightIntegratedMesh);break;case 4:c(e.transparentIntegratedMesh)}if(i.castAnyShadows){if(null!=m)for(const t of m)t[0]===d&&e.highlightShadowMap.submitDraw(s,i,o,t[1],n,t[0]);null!=h&&e.defaultShadowMap.submitDraw(s,i,o,h,n),c(e.shadowMap)}if(null!=m)for(const d of m)e.highlight.submitDraw(s,i,o,d[1],n,d[0]);t.viewshedEnabled&&c(e.viewshedShadowMap)}}function u(e,t){return e===t?0:0===e?2:1}function f(e){return null!=e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)}function b(e){return null!=e.overlay?.getTexture(2)}export{p as ComponentObject};
2
+ import{destroyMaybe as e}from"../../../../../core/maybe.js";import{set as t,transformMat3 as a,add 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{create as i}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as s}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as n}from"../../../support/orientedBoundingBox.js";import{ComponentParametersUniform as l,ComponentParametersVarying as m}from"./ComponentDrawParameters.js";import{UniformComponentParameters as h}from"./UniformComponentParameters.js";import{olidEnabled as c}from"../../effects/geometry/olidUtils.js";import{defaultHighlightName as d}from"../../../../support/HighlightDefaults.js";class p{constructor(e,t,a,r,o,i){this._collection=e,this.transform=t,this.obb=a,this._componentData=r,this._renderable=o,this._intersectionGeometry=i,this.visible=!1,this.offsetObb=null,this._aabbInWorldCoordinates=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}updateMaterial(e,t){const{_renderable:a}=this,r=a.material,o=this._collection.materials.acquire({...r.parameters,opacity:a.opacity,...e},a.geometry.parameters,t??a.drawParameters.componentParameters);this._collection.materials.release(r),o!==r&&a.updateMaterial(o)}get opacity(){return this.renderable.opacity}updateOpacity(e){this.opacity!==e&&(this._renderable.updateOpacity(e),this.updateMaterial({opacity:e}))}updateCameraDerivedParameters(e){const{eye:t}=e,{centerX:a,centerY:r,centerZ:o}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-a)**2+(t[1]-r)**2+(t[2]-o)**2}setComponentData(e,t){const a=this._componentData,{materialDataBuffer:r,materialDataIndices:o}=a,i=new h,d=r.textureBuffer,p=d.getVec4Field("colorAndCastShadows"),f=d.getScalarField("elevationOffset"),b=d.getScalarField("emissiveStrength"),g=d.getScalarField("emissiveSourceMode"),y=d.getVec4Field("olidColor"),_=new Uint8Array(4),v=new Uint32Array(_.buffer);let M,w=0,C=0,S=0,x=0,D=0,O=a.verticalOffsets,P=1/0,j=-1/0,A=!1,I=!1,k=!1,G=0;for(let n=0;n<a.count;n++){e(n,i),w+=+(i.externalColor[3]<1),C+=+(3===i.externalColorMixMode&&1===i.externalColor[3]),x+=+(i.emissiveStrength>0),D+=+(1===i.emissiveSource),I||=1!==i.emissiveStrength,S+=+i.castShadows,s(i.externalColor,i.externalColorMixMode,_),_[2]=254&_[2]|+i.castShadows,p.setArray(o[n],_),A||=n>0&&G!==v[0],G=v[0],k||=0!==i.elevationOffset,k&&null==O&&(O=new Array(n).fill(0)),null!=O&&(O[n]=i.elevationOffset),P=Math.min(P,i.elevationOffset),j=Math.max(j,i.elevationOffset),f.set(o[n],i.elevationOffset),b.set(o[n],i.emissiveStrength),g.set(o[n],0===i.emissiveSource?0:255);const t=i.olidColor;null!=t&&y.setArray(o[n],t),i.pickable!==a.isPickable(n)&&a.updatePickabilityWithCount(n,i.pickable)}if(a.verticalOffsets=k?O:null,this.offsetObb=k?n(this.obb,P,j,t,this.offsetObb??this.obb.clone()):null,A||k||c()||(I||D>0)&&x>0){const{count:e}=a;M=new m(u(w,e),u(C,e),u(x,e),u(D,e),u(S,e)),d.updateTexture(),this._renderable.updateComponentParametersVarying(M,d)}else M=new l(i.externalColor,i.externalColorMixMode,i.emissiveStrength,i.emissiveSource,i.castShadows?0:2),this._renderable.updateComponentParametersUniform(M);this.updateMaterial({},M)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){const e=i(),{positions:o}=this._intersectionGeometry;if(Math.floor(o.length/3)>0){const{rotationScale:i,position:s}=this.transform;let n=1/0,l=1/0,m=1/0,h=-1/0,c=-1/0,d=-1/0;const p=g;for(let e=0;e<o.length;e+=3)t(p,o[e+0],o[e+1],o[e+2]),a(p,p,i),r(p,p,s),n=Math.min(n,p[0]),l=Math.min(l,p[1]),m=Math.min(m,p[2]),h=Math.max(h,p[0]),c=Math.max(c,p[1]),d=Math.max(d,p[2]);e[0]=n,e[1]=l,e[2]=m,e[3]=h,e[4]=c,e[5]=d}return e}submit(e,t){const{componentData:a,renderable:r}=this;if(r.drawParameters.opacity<=0)return;const{geometry:o,drawParameters:i,material:s}=r,n=r.meta.cameraDepthSquared,{geometryRanges:l,highlightRangesMap:m,shadowmapRanges:h}=a,c=e=>e.submitDraw(s,i,o,l,n);switch(s.materialPass){case 0:c(e.opaque);break;case 1:c(e.transparent);break;case 2:c(e.opaque),c(e.transparent);break;case 3:c(e.integratedMesh),f(t)&&c(e.occludedGround),b(t)&&c(e.highlightIntegratedMesh);break;case 4:c(e.transparentIntegratedMesh)}if(i.castAnyShadows){if(null!=m)for(const t of m)t[0]===d&&e.highlightShadowMap.submitDraw(s,i,o,t[1],n,t[0]);null!=h&&e.defaultShadowMap.submitDraw(s,i,o,h,n),c(e.shadowMap)}if(null!=m)for(const d of m)e.highlight.submitDraw(s,i,o,d[1],n,d[0]);t.viewshedEnabled&&c(e.viewshedShadowMap)}}function u(e,t){return e===t?0:0===e?2:1}function f(e){return null!=e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)}function b(e){return null!=e.overlay?.getTexture(2)}const g=o();export{p as ComponentObject};