@arcgis/core 5.2.0-next.29 → 5.2.0-next.30

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 (131) hide show
  1. package/assets/esri/core/t9n/Units_en.json +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/0af6b87a3d77bb93b893.js +1 -0
  4. package/assets/esri/core/workers/chunks/{7ff37a4f315f7621462b.js → 125edba5c618c6257cb8.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{4ba4fd8fa31169760fee.js → 1282598516cd0e3056b7.js} +3 -3
  6. package/assets/esri/core/workers/chunks/414691f7758c78e2a704.js +1 -0
  7. package/assets/esri/core/workers/chunks/4452fd0c59431904d533.js +1 -0
  8. package/assets/esri/core/workers/chunks/451331f69d21c61ec93b.js +1 -0
  9. package/assets/esri/core/workers/chunks/{11f47a012dd8881e3d55.js → 4e803d12486c8de4c901.js} +23 -23
  10. package/assets/esri/core/workers/chunks/{992a90ecbab931198fd0.js → 4ecc345c3732f7fc130f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/557300ec03bae84d8afc.js +1 -0
  12. package/assets/esri/core/workers/chunks/{b18b6bb85e52b03b85e3.js → 6df54132299b9e8f6dad.js} +18 -18
  13. package/assets/esri/core/workers/chunks/{c6f5688074ae89c37add.js → 7b1678dcf62481469544.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{a90619adff41658f8057.js → 8d21f3d6edbcd7b335d0.js} +1 -1
  15. package/assets/esri/core/workers/chunks/b1a0eb6598309e11337f.js +1 -0
  16. package/assets/esri/core/workers/chunks/bd0829eb79efff5b7223.js +1 -0
  17. package/assets/esri/core/workers/chunks/bee56a6ac99312f03109.js +1 -0
  18. package/assets/esri/core/workers/chunks/c7316fd2bdb7ac9eada3.js +1 -0
  19. package/assets/esri/core/workers/chunks/daf539e9f88fc9e101e4.js +1 -0
  20. package/assets/esri/core/workers/chunks/{9fe71d49c888fd871312.js → e2d500ac1a264d09c857.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{aded4e704e09a28edc8f.js → f63e7b01c70352538b1e.js} +1 -1
  22. package/assets/esri/core/workers/chunks/f71f5778e03f68f27482.js +1 -0
  23. package/assets/esri/core/workers/chunks/fc9664d3282b052ef40f.js +1 -0
  24. package/assets/esri/widgets/Features/t9n/Features_en.json +1 -1
  25. package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_en.json +1 -1
  26. package/chunks/CutFillComposition.glsl.js +16 -10
  27. package/chunks/CutFillDepth.glsl.js +1 -14
  28. package/chunks/HUDMaterial.glsl.js +7 -7
  29. package/chunks/Viewshed.glsl.js +3 -3
  30. package/config.js +1 -1
  31. package/core/PooledArray.js +1 -1
  32. package/geometry/support/lineSegment.js +1 -1
  33. package/geometry/support/triangle.js +1 -1
  34. package/kernel.js +1 -1
  35. package/layers/AnnotationFeatureLayer.js +1 -1
  36. package/layers/DimensionFeatureLayer.js +1 -1
  37. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  38. package/layers/knowledgeGraph/nodeMovementUtils.js +1 -1
  39. package/layers/mixins/ArcGISImageService.js +1 -1
  40. package/layers/raster/datasets/pixelReader.js +1 -1
  41. package/layers/support/ExportImageServiceParameters.js +1 -1
  42. package/package.json +1 -1
  43. package/support/revision.js +1 -1
  44. package/views/2d/engine/webgl/mesh/bufcut.js +1 -1
  45. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  46. package/views/2d/engine/webgl/util/AnnotationMatcher.js +1 -1
  47. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  48. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  49. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  50. package/views/2d/layers/support/annodime/MatcherGeometryOverride.js +1 -1
  51. package/views/2d/layers/support/annodime/annotationGraphic.js +1 -1
  52. package/views/2d/layers/support/annodime/cimAnnotations.js +1 -1
  53. package/views/2d/layers/support/annodime/dimensionSymbols.js +1 -1
  54. package/views/2d/layers/support/annodime/dimensionUtils.js +1 -1
  55. package/views/2d/layers/support/annodime/fields.js +1 -1
  56. package/views/2d/layers/support/annodime/utils.js +1 -1
  57. package/views/2d/layers/support/annodime/virtualFields.js +1 -1
  58. package/views/3d/FocusAreasView.js +1 -1
  59. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  60. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  61. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  62. package/views/3d/support/hitTest.js +1 -1
  63. package/views/3d/webgl/RenderCamera.js +1 -1
  64. package/views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js +2 -2
  65. package/views/3d/webgl-engine/core/shaderModules/FloatsDrawUniform.js +2 -0
  66. package/views/3d/webgl-engine/effects/focusArea/{FocusAreaMaskNode.js → FocusAreaMask.js} +1 -1
  67. package/views/3d/webgl-engine/effects/focusArea/{FocusAreaColorNode.js → FocusAreaVisualization.js} +1 -1
  68. package/views/3d/webgl-engine/effects/geometry/{ObjectAndLayerIDRenderNode.js → ObjectAndLayerID.js} +1 -1
  69. package/views/3d/webgl-engine/effects/geometry/{RenderOccludedRenderNode.js → RenderOccluded.js} +1 -1
  70. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  71. package/views/3d/webgl-engine/lib/CutFillComputation.js +2 -0
  72. package/views/3d/webgl-engine/lib/CutFillVisualization.js +2 -0
  73. package/views/3d/webgl-engine/lib/{GaussianSplatRenderNode.js → GaussianSplatRenderer.js} +1 -1
  74. package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +2 -0
  75. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  76. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  77. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  78. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  79. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  80. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  81. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  82. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  83. package/views/3d/webgl-engine/lib/intersectionConstants.js +2 -0
  84. package/views/3d/webgl-engine/lib/screenPolygonOverlapUtils.js +2 -0
  85. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +2 -0
  86. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  87. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  88. package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
  89. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  90. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  91. package/views/3d/webgl-engine/materials/intersectWithPolygonOffset.js +2 -0
  92. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  93. package/views/3d/webgl-engine/shaders/CutFillComposition.glsl.js +1 -1
  94. package/views/3d/webgl-engine/shaders/CutFillCompositionTechnique.js +1 -1
  95. package/views/3d/webgl-engine/shaders/CutFillDepth.glsl.js +1 -1
  96. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  97. package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
  98. package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
  99. package/views/SceneView.js +1 -1
  100. package/views/draw/support/Reshape.js +1 -1
  101. package/views/layers/FeatureLikeLayerView.js +1 -1
  102. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  103. package/views/webgl/ShaderBuilder.js +1 -1
  104. package/widgets/Attachments/support/attachmentUtils.js +1 -1
  105. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  106. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  107. package/widgets/BatchAttributeForm.js +1 -1
  108. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  109. package/widgets/Editor.js +1 -1
  110. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  111. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  112. package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
  113. package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
  114. package/widgets/PanoramicViewer/utils.js +1 -1
  115. package/widgets/Sketch/support/OperationHandle.js +1 -1
  116. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  117. package/assets/esri/core/workers/chunks/0d3c9112ae07fa4a97d6.js +0 -1
  118. package/assets/esri/core/workers/chunks/1849f72f23b434e6c78d.js +0 -1
  119. package/assets/esri/core/workers/chunks/218e2d8d6cd147c769ce.js +0 -1
  120. package/assets/esri/core/workers/chunks/294f2803aac000c99693.js +0 -1
  121. package/assets/esri/core/workers/chunks/2c15c227d057292d4fa8.js +0 -1
  122. package/assets/esri/core/workers/chunks/38a2f34661563c7c29c1.js +0 -1
  123. package/assets/esri/core/workers/chunks/5468a65698931603656d.js +0 -1
  124. package/assets/esri/core/workers/chunks/780519b60aa674a61a74.js +0 -1
  125. package/assets/esri/core/workers/chunks/88827e23f8938342781c.js +0 -1
  126. package/assets/esri/core/workers/chunks/bfe9c8ab35d9bf7e1035.js +0 -1
  127. package/assets/esri/core/workers/chunks/caf150028aeac91b8d80.js +0 -1
  128. package/assets/esri/core/workers/chunks/e98a8f80023c6023e72c.js +0 -1
  129. package/views/3d/webgl-engine/lib/CutFillComputationRenderNode.js +0 -2
  130. package/views/3d/webgl-engine/lib/CutFillVisualizationRenderNode.js +0 -2
  131. package/views/3d/webgl-engine/lib/GaussianSplatShadowRenderNode.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../../core/PooledArray.js";import{property as r,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{Blit as c}from"../blit/Blit.js";import{DepthStencilAttachment as d}from"../../../../webgl/enums.js";let l=class extends o{constructor(e){super(e),this.consumes={required:[i.OCCLUDED]},this.produces=i.OCCLUDED,this._blit=new c(e.view.stage.renderView.techniques,2)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forEach(t=>{e.precompileSlots(t,9,11),t.material&&e.precompileOccludedSlots(t,p)})}render(){const e=this.input;return this._renderOccludedAndTransparentStencil(e),this._renderOccludedComposite(e),e}_renderOccludedAndTransparentStencil(e){const t=this.view.stage.renderer,r=a;this._acquirePlugins(r,8),0!==r.length&&(t.renderSlots(r,10),this._renderAndComposite(e,e.getAttachment(d),.5,()=>t.renderSlots(r,11),!1,!1),r.clear())}_renderOccludedComposite(e){const t=this.view.stage.renderer,r=a,s=this._acquirePlugins(r,u);if(0===r.length)return;const n=this._getDepthStencilAttachment(e);let i=n.clearStencil;for(const o of p)s&o&&(this._renderAndComposite(e,n.depth,16===o?1:.5,()=>t.renderOccludedSlots(r,o),!0,i),i=!1);n.release(),r.clear()}_acquirePlugins(e,t){const r=this.view.stage.renderer;e.clear();let s=0,n=!1;for(const i of r.plugins.plugins){const r=i.renderOccludedFlags&t;s|=r,r&&(e.push(i),n||=0!==i.testsTransparentRenderOrder)}return n&&e.sort((e,t)=>e.testsTransparentRenderOrder-t.testsTransparentRenderOrder),s}_renderAndComposite(e,t,r,s,i,o){const c=this.renderingContext,{width:d,height:l}=e.fbo,a=this.fboCache.acquire(d,l,"tmp color");a.attachDepth(t),c.bindFramebuffer(a.fbo),c.clearFramebuffer(n,i,o),s(),a.detachDepth(),this._blit.blend(a,e,this.bindParameters,r),a.release()}_getDepthStencilAttachment(e){const{width:t,height:r}=e.fbo;if(!this.view.stage.renderer.occludedRequiresIntegratedMeshStencil){const e=this.fboCache.acquireDepth(14,t,r,"retained stencil");return{depth:e,release:()=>e.release(),clearStencil:!0}}const s=this.fboCache.acquire(t,r,"retained stencil",14);return this.renderingContext.blitFramebuffer(e.fbo,s.fbo,1024),{depth:s.getAttachment(d),release:()=>s.release(),clearStencil:!1}}};e([r()],l.prototype,"consumes",void 0),e([r()],l.prototype,"produces",void 0),l=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccludedRenderNode")],l);const a=new t;function h(){a.prune()}const p=[4,2,16],u=p.reduce((e,t)=>e|t,0);export{l as RenderOccludedRenderNode,h as cleanupRenderOccluded};
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/PooledArray.js";import{property as r,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{Blit as c}from"../blit/Blit.js";import{DepthStencilAttachment as d}from"../../../../webgl/enums.js";let l=class extends o{constructor(e){super(e),this.consumes={required:[i.OCCLUDED]},this.produces=i.OCCLUDED,this._blit=new c(e.view.stage.renderView.techniques,2)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forEach(t=>{e.precompileSlots(t,9,11),t.material&&e.precompileOccludedSlots(t,p)})}render(){const e=this.input;return this._renderOccludedAndTransparentStencil(e),this._renderOccludedComposite(e),e}_renderOccludedAndTransparentStencil(e){const t=this.view.stage.renderer,r=a;this._acquirePlugins(r,8),0!==r.length&&(t.renderSlots(r,10),this._renderAndComposite(e,e.getAttachment(d),.5,()=>t.renderSlots(r,11),!1,!1),r.clear())}_renderOccludedComposite(e){const t=this.view.stage.renderer,r=a,s=this._acquirePlugins(r,u);if(0===r.length)return;const n=this._getDepthStencilAttachment(e);let i=n.clearStencil;for(const o of p)s&o&&(this._renderAndComposite(e,n.depth,16===o?1:.5,()=>t.renderOccludedSlots(r,o),!0,i),i=!1);n.release(),r.clear()}_acquirePlugins(e,t){const r=this.view.stage.renderer;e.clear();let s=0,n=!1;for(const i of r.plugins.plugins){const r=i.renderOccludedFlags&t;s|=r,r&&(e.push(i),n||=0!==i.testsTransparentRenderOrder)}return n&&e.sort((e,t)=>e.testsTransparentRenderOrder-t.testsTransparentRenderOrder),s}_renderAndComposite(e,t,r,s,i,o){const c=this.renderingContext,{width:d,height:l}=e.fbo,a=this.fboCache.acquire(d,l,"tmp color");a.attachDepth(t),c.bindFramebuffer(a.fbo),c.clearFramebuffer(n,i,o),s(),a.detachDepth(),this._blit.blend(a,e,this.bindParameters,r),a.release()}_getDepthStencilAttachment(e){const{width:t,height:r}=e.fbo;if(!this.view.stage.renderer.occludedRequiresIntegratedMeshStencil){const e=this.fboCache.acquireDepth(14,t,r,"retained stencil");return{depth:e,release:()=>e.release(),clearStencil:!0}}const s=this.fboCache.acquire(t,r,"retained stencil",14);return this.renderingContext.blitFramebuffer(e.fbo,s.fbo,1024),{depth:s.getAttachment(d),release:()=>s.release(),clearStencil:!1}}};e([r()],l.prototype,"consumes",void 0),e([r()],l.prototype,"produces",void 0),l=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccluded")],l);const a=new t;function h(){a.prune()}const p=[4,2,16],u=p.reduce((e,t)=>e|t,0);export{l as RenderOccluded,h as cleanupRenderOccluded};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{releaseMaybe as t}from"../../../../core/maybe.js";import{signal as i}from"../../../../core/signal.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import e from"../../webgl/RenderCamera.js";import{isColor as h}from"../core/shaderLibrary/ShaderOutput.js";import{CloudsParameters as n}from"../effects/clouds/CloudsParameters.js";import{ReprojectionUniforms as r}from"./ReprojectionUniforms.js";import{ScreenSpaceReflectionsUniforms as o}from"./ScreenSpaceReflectionsUniforms.js";import{SceneLighting as a}from"../lighting/SceneLighting.js";class l{constructor(t,i){this.width=t,this.height=i}}const g=5e5;class u{constructor(t,h){this._rctx=t,this.shadowMap=h,this._output=0,this.slot=2,this.slicePlane=null,this.hasOccludees=!1,this.emissions=0,this.transparentWithoutDepthEmissionDimmingPass=!1,this.useFloatBlend=i(!0),this.enableFillLights=!0,this.alignPixelEnabled=!1,this.decorations=!0,this.overlayStretch=1,this.viewshedEnabled=!1,this.cutFillComputationEnabled=!1,this.cutFillVisualizationEnabled=!1,this._camera=new e,this._inverseViewport=s(),this._oldLighting=new a,this._newLighting=new a,this._fadedLighting=new a,this._lighting=this._newLighting,this.screenSpaceReflections=new o,this.reprojection=new r,this.highlights=new Array,this.highlightMixOrigin=s(),this.highlightMixTexture=null,this.globalIlluminationEnabled=!1,this.hudRenderStyle=0,this.snowCover=0,this.clouds=new n,this.hasShadowHighlights=!1}destroy(){this._camera=this.contentCamera=null,this.mainDepth=this.overlay=this.ssao=this.shadowHighlight=null,this.depth=t(this.depth),this.shadowMap?.dispose()}get output(){return this._output}set output(t){this._output!==t&&(this._output=t,this._rctx.resetDrawBuffers(t))}get hasEmission(){switch(this.output){case 0:return this.hasOpaqueEmission;case 1:case 2:return this.hasTransparentEmission;default:return!1}}get hasOpaqueEmission(){return 1===this.emissions||3===this.emissions}get hasTransparentEmission(){return 2===this.emissions||3===this.emissions}get camera(){return this._camera}set camera(t){this._camera=t,this._inverseViewport[0]=1/t.fullViewport[2],this._inverseViewport[1]=1/t.fullViewport[3]}get enableOITOffset(){return 1===this.output&&this.camera.relativeElevation<g}get inverseViewport(){return this._inverseViewport}get lighting(){return this._lighting}fadeLighting(){switch(this.clouds.fadeFactor){case 0:this._lighting=this._oldLighting;break;default:this._fadedLighting.lerpLighting(this._oldLighting,this._newLighting,this.clouds.fadeFactor),this._lighting=this._fadedLighting;break;case 1:this._lighting=this._newLighting,this._oldLighting.copyFrom(this._newLighting)}}updateLighting(t,i,s,e){this._oldLighting.copyFrom(this.lighting),this._newLighting.noonFactor=i,this._newLighting.globalFactor=s,this._newLighting.set(t),this._oldLighting.updateLegacy(),1===e&&this.clouds.requestFade(),this.fadeLighting()}get hasScreenSpaceReflections(){return h(this.output)&&this.screenSpaceReflections.enabled&&null!=this.reprojection.lastFrameColor}get highlight(){return null==this.highlightLevel?null:this.highlights[this.highlightLevel]}get depth(){return this._depth}set depth(t){t&&(t.name="geometry depth"),this._depth=t}get occluder(){return 10===this.slot||11===this.slot?this.slot:null}}export{u as BindParameters,l as ViewportSize};
2
+ import{releaseMaybe as t}from"../../../../core/maybe.js";import{signal as i}from"../../../../core/signal.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import e from"../../webgl/RenderCamera.js";import{isColor as h}from"../core/shaderLibrary/ShaderOutput.js";import{CloudsParameters as n}from"../effects/clouds/CloudsParameters.js";import{ReprojectionUniforms as r}from"./ReprojectionUniforms.js";import{ScreenSpaceReflectionsUniforms as o}from"./ScreenSpaceReflectionsUniforms.js";import{SceneLighting as a}from"../lighting/SceneLighting.js";class l{constructor(t,i){this.width=t,this.height=i}}const g=5e5;class u{constructor(t,h){this._rctx=t,this.shadowMap=h,this._output=0,this.slot=2,this.slicePlane=null,this.hasOccludees=!1,this.emissions=0,this.transparentWithoutDepthEmissionDimmingPass=!1,this.useFloatBlend=i(!0),this.enableFillLights=!0,this.alignPixelEnabled=!1,this.decorations=!0,this.overlayStretch=1,this.viewshedEnabled=!1,this.cutFillComputationEnabled=!1,this.cutFillVisualizationEnabled=!1,this._camera=new e,this._inverseViewport=s(),this._oldLighting=new a,this._newLighting=new a,this._fadedLighting=new a,this._lighting=this._newLighting,this.screenSpaceReflections=new o,this.reprojection=new r,this.highlights=new Array,this.highlightMixOrigin=s(),this.highlightMixTexture=null,this.globalIlluminationEnabled=!1,this.hudRenderStyle=0,this.snowCover=0,this.clouds=new n,this.hasShadowHighlights=!1}destroy(){this._camera=this.contentCamera=null,this.mainDepth=this.overlay=this.ssao=this.shadowHighlight=null,this.depth=t(this.depth),this.shadowMap?.dispose()}get output(){return this._output}set output(t){this._output!==t&&(this._output=t,this._rctx.resetDrawBuffers(t))}get hasEmission(){switch(this.output){case 0:return this.hasOpaqueEmission;case 1:case 2:return this.hasTransparentEmission;default:return!1}}get hasOpaqueEmission(){return 1===this.emissions||3===this.emissions}get hasTransparentEmission(){return 2===this.emissions||3===this.emissions}get camera(){return this._camera}set camera(t){this._camera=t,this._inverseViewport[0]=1/t.fullViewport[2],this._inverseViewport[1]=1/t.fullViewport[3]}get enableOITOffset(){return this.camera.relativeElevation<g}get inverseViewport(){return this._inverseViewport}get lighting(){return this._lighting}fadeLighting(){switch(this.clouds.fadeFactor){case 0:this._lighting=this._oldLighting;break;default:this._fadedLighting.lerpLighting(this._oldLighting,this._newLighting,this.clouds.fadeFactor),this._lighting=this._fadedLighting;break;case 1:this._lighting=this._newLighting,this._oldLighting.copyFrom(this._newLighting)}}updateLighting(t,i,s,e){this._oldLighting.copyFrom(this.lighting),this._newLighting.noonFactor=i,this._newLighting.globalFactor=s,this._newLighting.set(t),this._oldLighting.updateLegacy(),1===e&&this.clouds.requestFade(),this.fadeLighting()}get hasScreenSpaceReflections(){return h(this.output)&&this.screenSpaceReflections.enabled&&null!=this.reprojection.lastFrameColor}get highlight(){return null==this.highlightLevel?null:this.highlights[this.highlightLevel]}get depth(){return this._depth}set depth(t){t&&(t.name="geometry depth"),this._depth=t}get occluder(){return 10===this.slot||11===this.slot?this.slot:null}}export{u as BindParameters,l as ViewportSize};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import{nextPowerOfTwo as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r}from"../../../../core/maybe.js";import{property as s,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{ortho as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as d,ZEROS as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as p,InternalRenderCategory as _}from"../../webgl.js";import{Frustum as m}from"../../state/Frustum.js";import{glLayout as f}from"../../support/buffer/glUtil.js";import{newLayout as l}from"../../support/buffer/InterleavedLayout.js";import g from"../../webgl/RenderCamera.js";import C from"../../webgl/RenderNode.js";import{ShaderOutputConfiguration as w}from"../core/shaderLibrary/ShaderOutputConfiguration.js";import{VertexArrayObject as x}from"./VertexArrayObject.js";import{C as P}from"../../../../chunks/CutFillDepth.glsl.js";import{CutFillDepthTechnique as y}from"../shaders/CutFillDepthTechnique.js";import{CutFillDepthTechniqueConfiguration as R}from"../shaders/CutFillDepthTechniqueConfiguration.js";import{C as b}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as T}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as B}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as F}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as j}from"../shaders/CutFillTargetDepthTechnique.js";import{ImmediateTask as E,TaskPriority as S}from"../../../support/Scheduler.js";import{Yield as D}from"../../../support/Yield.js";import{PrimitiveType as q,DataType as O}from"../../../webgl/enums.js";import{Sync as v}from"../../../webgl/Sync.js";import{VertexBuffer as V}from"../../../webgl/VertexBuffer.js";let A=class extends C{constructor(t){super(t),this.consumes={required:[p.TRANSPARENT]},this.produces=_.CUTFILL_COMPUTATION,this._targetDepthConfiguration=new w,this._depthConfiguration=new R,this._reductionConfiguration=new B,this._targetDepthParameters=new F,this._depthParameters=new P,this._reductionParameters=new b,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=E,this._result=new k,this._localOrigin=u(),this._maxTextureSize=512,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=14,this._colorFormat=11,this._numChannels=2,this._targetGeometryVao=null,this._numReductions=3,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(S.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._targetDepthConfiguration.output=9,this._maxTextureSize=Math.min(this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._frustum=new m(this.view.renderCoordsHelper)}destroy(){this._targetGeometryVao=i(this._targetGeometryVao),this._sync=r(this._sync),this._pixelBuffer&&(this.gl.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.view.stage.renderer.precompileCutFillOrthographicReferenceDepth()}render(){const t=this.input;if(!this._orthographicCamera||!this._targetGeometryVao||!this.needsRender||this._sync)return t;const e=this.techniques.getCompiled(j,this._targetDepthConfiguration);this._depthConfiguration.preparePass=0;const i=this.techniques.getCompiled(y,this._depthConfiguration);this._depthConfiguration.preparePass=1;const r=this.techniques.getCompiled(y,this._depthConfiguration);this._reductionConfiguration.reductionPass=0;const s=this.techniques.getCompiled(T,this._reductionConfiguration);this._reductionConfiguration.reductionPass=1;const h=this.techniques.getCompiled(T,this._reductionConfiguration);this._reductionConfiguration.reductionPass=2;const o=this.techniques.getCompiled(T,this._reductionConfiguration);if(!(e&&i&&r&&s&&h&&o))return this.requestRender(1),t;this.needsRender=!1;const n=this.renderingContext,a=this.fboCache,u=this.gl,p=n.getViewport(),_=a.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);n.bindFramebuffer(_.fbo),n.setViewport(0,0,this._width,this._height),n.clear(1280),this.view.stage.renderer.renderCutFillOrthographicReferenceDepth(this._orthographicCamera);const m=a.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);n.bindFramebuffer(m.fbo),n.setViewport(0,0,this._width,this._height),n.setClearDepth(1),n.clear(256),this._targetDepthParameters.origin=this._localOrigin,this._targetDepthParameters.cutFillCamera=this._orthographicCamera,n.bindTechnique(e,this.bindParameters,this._targetDepthParameters),n.bindVAO(this._targetGeometryVao),n.drawArrays(q.TRIANGLES,0,this._targetGeometryVao.vertexCount("geometry"));const f=a.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),l=a.acquire(this._width,this._height,"cutfill reduction odd",this._colorFormat);return this._depthParameters.referenceDepth=_.depthTexture,this._depthParameters.targetDepth=m.depthTexture,this._pixelBuffer||(this._pixelBuffer=u.createBuffer()),u.bindBuffer(u.PIXEL_PACK_BUFFER,this._pixelBuffer),u.bufferData(u.PIXEL_PACK_BUFFER,this._pixelBufferSize,u.STREAM_READ),this._prepareFBO(f,this.width,this.height),n.bindTechnique(i,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(f,l,s),this._prepareFBO(f,this.width,this.height,d),n.bindTechnique(r,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(f,l,h),this._prepareFBO(f,this.width,this.height,c),n.bindTechnique(r,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(f,l,o),_.release(),m.release(),f.release(),l.release(),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),n.setViewport(p.x,p.y,p.width,p.height),this._sync=new v(u),setTimeout(()=>this.readyToRun=!0,0),t}update(t,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=t,n=this._maxTextureSize,a=h/s,u=s>h?n:n/a,d=s>h?n*a:n;this._width=e(u),this._height=e(d);const c=[this._width,this._height];this._orthographicCamera=this._createCamera(t,c),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return D}catch(e){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const t=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}getResult(){return this._result}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(t,e,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._reductionParameters.depthTexture=t.getTexture(),this._prepareFBO(e,h,o),r.bindTechnique(i,this.bindParameters,this._reductionParameters),r.screen.draw(),[t,e]=[e,t];s.readPixels(0,0,h,o,33319,O.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(t){const e=new U(0,1,a()),i=new U(0,0,a());for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;e.totalDepth+=t[h],i.totalDepth+=t[h+1],h+=o;const n=t[h];n<e.depthExtremum&&(e.depthExtremum=n,M(e.depthExtremumCoords,t[h+1],this._width)),h+=o;const a=t[h];a>i.depthExtremum&&(i.depthExtremum=a,M(i.depthExtremumCoords,t[h+1],this._width))}this._result=new k(this._width,this._height,e,i)}_prepareFBO(t,e,i,r=c){const s=this.renderingContext;s.bindFramebuffer(t.fbo),s.setViewport(0,0,e,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(t,e){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:n},cameraNearFar:{near:a,far:u}}=t,d=new g({eye:i,center:r,up:s,near:a,far:u});return d.viewport=[0,0,e[0],e[1]],o(d.projectionMatrix,-h/2,h/2,-n/2,n/2,a,u),d}_updateTargetVao(t,e){this._targetGeometryVao=i(this._targetGeometryVao);const r=e.indices.length,s=z.createBuffer(r),h=s.position,{positions:o,indices:n}=e;for(let i=0;i<n.length;++i){const t=3*n[i];h.set(i,0,o[t]),h.set(i,1,o[t+1]),h.set(i,2,o[t+2])}const a=new V(t,f(z),s.buffer);this._targetGeometryVao=new x(t,a)}};t([s()],A.prototype,"consumes",void 0),t([s()],A.prototype,"produces",void 0),t([s()],A.prototype,"needsRender",void 0),t([s()],A.prototype,"readyToRun",void 0),t([s()],A.prototype,"done",void 0),t([s()],A.prototype,"updating",null),t([s()],A.prototype,"_frameTask",void 0),A=t([h("esri.views.3d.webgl-engine.lib.CutFillComputation")],A);const z=l().vec3f("position").freeze();function M(t,e,i){const r=e%i,s=Math.floor(e/i);n(t,r,s)}class L{constructor(t,e){this.positions=t,this.indices=e}}class U{constructor(t,e,i){this.totalDepth=t,this.depthExtremum=e,this.depthExtremumCoords=i}}class k{constructor(t=0,e=0,i=new U(0,1,a()),r=new U(0,0,a())){this.width=t,this.height=e,this.cut=i,this.fill=r}}export{A as CutFillComputation,k as CutFillComputationResult,U as CutFillDepthResult,L as TargetGeometryRenderInfo};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../core/maybe.js";import{watch as s,syncAndInitial as i}from"../../../../core/reactiveUtils.js";import{property as o,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{copy as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{InternalRenderCategory as l}from"../../webgl.js";import{glLayout as u}from"../../support/buffer/glUtil.js";import{newLayout as n}from"../../support/buffer/InterleavedLayout.js";import m from"../../webgl/RenderNode.js";import{VertexArrayObject as c}from"./VertexArrayObject.js";import{C as h}from"../../../../chunks/CutFillComposition.glsl.js";import{CutFillCompositionTechnique as d}from"../shaders/CutFillCompositionTechnique.js";import{C as f}from"../../../../chunks/CutFillMask.glsl.js";import{CutFillMaskTechnique as p}from"../shaders/CutFillMaskTechnique.js";import{DefaultMaterialPassParameters as C,DefaultMaterialDrawParameters as _,DefaultMaterialTechnique as b}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as g}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{DepthStencilAttachment as V,PrimitiveType as v,ColorAttachment0 as w}from"../../../webgl/enums.js";import{noParameters as T}from"../../../webgl/NoParameters.js";import{VertexBuffer as F}from"../../../webgl/VertexBuffer.js";let P=class extends m{constructor(e){super(e),this.consumes={required:[l.CUTFILL_COLOR,l.GROUND_DEPTH]},this.produces=l.CUTFILL_COLOR,this.measureType="cut-fill",this._vaoCut=null,this._vaoFill=null,this._maskParameters=new f,this._cutVolumeParameters=new C,this._fillVolumeParameters=new C,this._compositeParameters=new h,this._drawParameters=new _;const t=1===e.view.state.viewingMode;this._cutVolumeConfiguration=new g(t),this._cutVolumeConfiguration.customDepthTest=2,this._cutVolumeConfiguration.writeDepth=!1,this._cutVolumeConfiguration.cullFace=1,this._cutVolumeConfiguration.doubleSidedMode=2,this._fillVolumeConfiguration=new g(t),this._fillVolumeConfiguration.customDepthTest=1,this._fillVolumeConfiguration.cullFace=2}initialize(){this.addHandles([s(()=>[this.cutColor,this.fillColor],()=>this._updateColors(),i),s(()=>this.measureType,()=>this.requestRender(1),i)])}destroy(){this._disposeVaos()}render(e){"cut-fill"===this.measureType?(this._cutVolumeConfiguration.cullFace=1,this._cutVolumeConfiguration.doubleSidedMode=2):(this._cutVolumeConfiguration.cullFace=0,this._cutVolumeConfiguration.doubleSidedMode=0);const t=this.techniques.getCompiled(b,this._cutVolumeConfiguration),s=this.techniques.getCompiled(b,this._fillVolumeConfiguration),i=this.techniques.getCompiled(p),o=this.techniques.getCompiled(d),r=this.input;if(!this._vaoCut||!this._vaoFill)return r;const a=this._vaoCut.vertexCount("geometry"),u=this._vaoFill.vertexCount("geometry");if(!(t&&s&&i&&o))return this.requestRender(1),r;const n=this.bindParameters,m=n.camera,c=m.fullViewport[2],h=m.fullViewport[3],f=this.renderingContext,C=this.fboCache,_=e.find(({name:e})=>e===l.GROUND_DEPTH),g=C.acquire(c,h,"cutfill color mask",2).attachDepth(_.getAttachment(V));f.bindFramebuffer(g.fbo),f.setClearColor(0,0,0,1),f.clear(17408),f.setViewport(0,0,c,h),f.bindTechnique(i,n,T,this._maskParameters),f.setFaceCullingEnabled(!1),f.setStencilTestEnabled(!0),f.setStencilOpSeparate(1028,7680,34055,7680),f.setStencilOpSeparate(1029,7680,34056,7680),f.setDepthWriteEnabled(!1),f.bindVAO(this._vaoCut),f.setDepthTestEnabled(!0),f.setStencilWriteMask(255),f.setStencilFunction(519,0,255),f.setColorMask(!1,!1,!1,!1),f.drawArrays(v.TRIANGLES,0,a),f.setDepthTestEnabled(!1),f.setStencilWriteMask(0),f.setStencilFunction(517,0,255),f.setColorMask(!0,!1,!1,!1),f.drawArrays(v.TRIANGLES,0,a),f.bindVAO(this._vaoFill),f.setDepthTestEnabled(!0),f.setStencilWriteMask(255),f.setStencilFunction(519,0,255),f.setColorMask(!1,!0,!1,!1),f.drawArrays(v.TRIANGLES,0,u);const F=C.acquire(c,h,"cutfill color cut volume",5).acquireDepth(14);f.blitFramebuffer(r.fbo,F.fbo,256),f.bindFramebuffer(F.fbo),f.setClearColor(0,0,0,0),f.clear(16384),f.setColorMask(!0,!0,!0,!0),f.bindTechnique(t,this.bindParameters,this._cutVolumeParameters,this._drawParameters),f.bindVAO(this._vaoCut),f.drawArrays(v.TRIANGLES,0,a),F.detachDepth();const P=C.acquire(c,h,"cutfill color fill volume",5).acquireDepth(14);f.blitFramebuffer(r.fbo,P.fbo,256),f.bindFramebuffer(P.fbo),f.clear(16384),f.setColorMask(!0,!0,!0,!0),f.bindTechnique(s,this.bindParameters,this._fillVolumeParameters,this._drawParameters),f.bindVAO(this._vaoFill),f.drawArrays(v.TRIANGLES,0,u),P.detachDepth();const q=r.obtainDepthTexture();f.bindFramebuffer(r.fbo);const D=f.setDrawBuffers([w]);return this._compositeParameters.cutVolume=F.getTexture(),this._compositeParameters.fillVolume=P.getTexture(),this._compositeParameters.mask=g.getTexture(),this._compositeParameters.sceneDepth=q?.attachment,this._compositeParameters.groundDepth=_.getTexture(V),this.borderColor.toUnitRGBA(this._compositeParameters.borderColor),f.bindTechnique(o,n,this._compositeParameters),f.screen.draw(),f.setDrawBuffers(D),r.attachDepth(q),q?.release(),g.release(),F.release(),P.release(),r}enable(){this.produces=l.CUTFILL_COLOR,this.requestRender(1)}disable(){this.produces="disabled",this.requestRender(1)}updateGeometries(e,t,s){this._disposeVaos(),this._vaoCut=this._createVao(e),this._vaoFill=this._createVao(t),this._maskParameters.origin=s,a(this._drawParameters.origin,s),this.requestRender(1)}_updateColors(){this._cutVolumeParameters.diffuse=this.cutColor.toUnitRGB(),this._cutVolumeParameters.opacity=this.cutColor.a,this._fillVolumeParameters.diffuse=this.fillColor.toUnitRGB(),this._fillVolumeParameters.opacity=this.fillColor.a,this.requestRender(1)}_createVao(e){const{vertices:t,normals:s,indicesBottom:i,indicesExtruded:o}=e,r=i.length+o.length,a=this.renderingContext,l=q.createBuffer(r),{position:n,normal:m}=l;let h=0;for(let u=0;u<i.length;u++){const e=3*i[u];n.set(h,0,t[e]),n.set(h,1,t[e+1]),n.set(h,2,t[e+2]),m.set(h,0,s[e]),m.set(h,1,s[e+1]),m.set(h,2,s[e+2]),h++}for(let u=0;u<o.length;u++){const e=3*o[u];n.set(h,0,t[e]),n.set(h,1,t[e+1]),n.set(h,2,t[e+2]),m.set(h,0,s[e]),m.set(h,1,s[e+1]),m.set(h,2,s[e+2]),h++}const d=new F(a,u(q),l.buffer);return new c(a,d)}_disposeVaos(){this._vaoCut=t(this._vaoCut),this._vaoFill=t(this._vaoFill)}};e([o()],P.prototype,"consumes",void 0),e([o()],P.prototype,"produces",void 0),e([o()],P.prototype,"cutColor",void 0),e([o()],P.prototype,"fillColor",void 0),e([o()],P.prototype,"borderColor",void 0),e([o()],P.prototype,"measureType",void 0),P=e([r("esri.views.3d.webgl-engine.lib.CutFillVisualization")],P);const q=n().vec3f("position").vec3f("normal").freeze();class D{constructor(e,t,s,i){this.vertices=e,this.indicesBottom=t,this.indicesExtruded=s,this.normals=i}}export{P as CutFillVisualization,D as VolumeGeometry};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as r,set as o,scale as n,floor as h,subtract as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,set as m,positiveInfinity as c,equals as d}from"../../../../geometry/support/aaBoundingBox.js";import{InternalRenderCategory as _}from"../../webgl.js";import{addWraparound as g}from"../../layers/i3s/I3SUtil.js";import C from"../../webgl/RenderNode.js";import{G as f}from"../../../../chunks/GaussianSplat.glsl.js";import{G as P}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as b}from"../shaders/GaussianSplatCompositionTechnique.js";import{GaussianSplatCompositionTechniqueConfiguration as v}from"../shaders/GaussianSplatCompositionTechniqueConfiguration.js";import{G as x}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as S}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatTechnique as q}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as w}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{ColorAttachment1 as R,DepthStencilAttachment as E,PrimitiveType as D}from"../../../webgl/enums.js";var T;let y=class extends C{static{T=this}constructor(e){super(e),this.produces=_.GAUSSIAN_SPLAT,this._slicePlaneEnabled=!1,this.layerView=null,this._passParameters=new f,this._compositionPassParameters=new P,this._depthCompositionPassParameters=new x,this._compositionConfiguration=new v,this._clipBox=u(),this._previousCameraDirection=p(),this._previousSortRequestCameraDirection=p(),this._tileCullingRevision=0,this._sortRequestDirectionEpsilon=.01,this._directionChangeEpsilon=.001,this._configuration=new w(e.view.state.isGlobal),m(this._clipBox,c)}async initialize(){this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange()),t(()=>2===this.view.state.mode,()=>this.requestRender(1))])}precompile(){this._updateConfigurations(),this._compositionConfiguration.useFloatBlend=this.bindParameters.useFloatBlend.value,this._compositionConfiguration.hasEmission=this.bindParameters.hasOpaqueEmission,this.techniques.precompile(q,this._configuration),this.techniques.precompile(b,this._compositionConfiguration),this.techniques.precompile(S)}render(){const e=this.input;if(this._updateConfigurations(),this._handleFading(),!(this._data.visibleGaussians&&this._data.orderTexture.texture&&this._data.textureAtlas.texture&&this._data.headerTexture.texture))return e;const t=e.getAttachment(R);this._compositionConfiguration.useFloatBlend=this.bindParameters.useFloatBlend.value,this._compositionConfiguration.hasEmission=null!=t;const{fullWidth:i,fullHeight:s}=this.bindParameters.camera;this._prepareParameters(s,i);const a=this.renderingContext,r=this.fboCache,o=r.acquire(i,s,"gaussian color output"),n=e.getAttachment(E);o.attachDepth(n);const h=this.techniques.get(q,this._configuration);this._renderGaussianColorAndDepth(o,h);const l=r.acquire(i,s,this.produces);this._depthCompositionPassParameters.splatDepth=o.getTexture(R),l.attachDepth(e.getAttachment(E)),a.bindFramebuffer(l.fbo);const p=this.techniques.get(S);a.bindTechnique(p,this.bindParameters,this._depthCompositionPassParameters),a.screen.draw(),this._compositionPassParameters.color=e.getTexture(),this._compositionPassParameters.splatColor=o.getTexture(),t?(l.acquireColor(R,8,"emissive"),this._compositionPassParameters.emission=e.getTexture(R)):this._compositionPassParameters.emission=null,a.bindFramebuffer(l.fbo);const u=this.techniques.get(b,this._compositionConfiguration);return a.bindTechnique(u,this.bindParameters,this._compositionPassParameters),a.screen.draw(),o.release(),l}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}set clippingBox(e){const t=e||c;this._hasSameClipBox(t)||(m(this._clipBox,t),this._tileCullingRevision=g(this._tileCullingRevision,1),this._data.requestSort(),this.requestRender(1))}get clippingBox(){return this._clippingEnabled?this._clipBox:null}get tileCullingRevision(){return this._tileCullingRevision}get _clippingEnabled(){return!d(this._clipBox,c,(e,t)=>e===t)}get _isIdle(){return 2===this.view.state.mode}get _data(){return this.layerView.data}get _fadeHelper(){return this.layerView.fadeHelper}_updateConfigurations(){const{idleMinimumOpacity:e,nonIdleMinimumOpacity:t}=this.view.qualitySettings.gaussianSplat;this._configuration.alphaCutoff=this._isIdle?e:t,this._configuration.fadingEnabled=this._fadeHelper.fadingEnabled,this._configuration.receiveShadows=this.bindParameters.shadowMap.ready,this._configuration.hasShadowHighlights=this._configuration.receiveShadows&&this.bindParameters.hasShadowHighlights,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasSlicePlane=this._slicePlaneEnabled&&null!=this.bindParameters.slicePlane}_onCameraChange(){this._tileCullingRevision=g(this._tileCullingRevision,1);const e=this.view.state.camera.ray.direction;if(!this._directionChanged(e))return;if(r(this._previousCameraDirection,e),!this._shouldRequestSort(e))return;this._data.requestSort()&&r(this._previousSortRequestCameraDirection,e)}_directionChanged(e){return Math.abs(e[0]-this._previousCameraDirection[0])>this._directionChangeEpsilon||Math.abs(e[1]-this._previousCameraDirection[1])>this._directionChangeEpsilon||Math.abs(e[2]-this._previousCameraDirection[2])>this._directionChangeEpsilon}_shouldRequestSort(e){return Math.abs(e[0]-this._previousSortRequestCameraDirection[0])>this._sortRequestDirectionEpsilon||Math.abs(e[1]-this._previousSortRequestCameraDirection[1])>this._sortRequestDirectionEpsilon||Math.abs(e[2]-this._previousSortRequestCameraDirection[2])>this._sortRequestDirectionEpsilon}_prepareParameters(e,t){this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture,this._passParameters.splatHeader=this._data.headerTexture.texture;const i=Math.tan(.5*this.camera.fovY),s=i/e*t;a(this._passParameters.tanFov,s,i),this._passParameters.focalLength=e/(2*i);const o=this.view.qualitySettings.gaussianSplat,n=this._isIdle?o.idleMinimumSplatPixelRadius:o.nonIdleMinimumSplatPixelRadius;this._passParameters.minSplatRadius=n*Math.sqrt(t*e)/Math.sqrt(2073600),r(this._passParameters.origin,this.bindParameters.camera.eye),this._prepareHighPrecisionCameraPosition(),this._updateSlicePlaneLocalOrigin(),this._updateClipUniforms()}_updateClipUniforms(){const e=this.clippingBox||c,[t,i,s,a,r,n]=e,[h,l,p]=this.camera.eye,{clipMinCameraRelative:u,clipMaxCameraRelative:m}=this._passParameters;o(u,t-h,i-l,s-p),o(m,a-h,r-l,n-p)}_updateSlicePlaneLocalOrigin(){this._passParameters.slicePlaneLocalOrigin=this.camera.eye}_hasSameClipBox(e){return d(this._clipBox,e,(e,t)=>e===t)}_renderGaussianColorAndDepth(e,t){const i=this.renderingContext;e.acquireColor(R,5,"gaussian depth output"),i.bindFramebuffer(e.fbo),i.setClearColor(0,0,0,0),i.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(D.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_prepareHighPrecisionCameraPosition(){n(this._passParameters.tileCameraPosition,this.camera.eye,1/T.tileSize),h(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),n(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,T.tileSize),l(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this._fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this._fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};e([i()],y.prototype,"produces",void 0),e([i({constructOnly:!0})],y.prototype,"layerView",void 0),y=T=e([s("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],y);export{y as GaussianSplatRenderNode};
2
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as r,set as o,scale as n,floor as h,subtract as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,set as m,positiveInfinity as c,equals as d}from"../../../../geometry/support/aaBoundingBox.js";import{InternalRenderCategory as _}from"../../webgl.js";import{addWraparound as g}from"../../layers/i3s/I3SUtil.js";import C from"../../webgl/RenderNode.js";import{G as f}from"../../../../chunks/GaussianSplat.glsl.js";import{G as P}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as b}from"../shaders/GaussianSplatCompositionTechnique.js";import{GaussianSplatCompositionTechniqueConfiguration as v}from"../shaders/GaussianSplatCompositionTechniqueConfiguration.js";import{G as x}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as S}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatTechnique as q}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as w}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{ColorAttachment1 as R,DepthStencilAttachment as E,PrimitiveType as D}from"../../../webgl/enums.js";var T;let y=class extends C{static{T=this}constructor(e){super(e),this.produces=_.GAUSSIAN_SPLAT,this._slicePlaneEnabled=!1,this.layerView=null,this._passParameters=new f,this._compositionPassParameters=new P,this._depthCompositionPassParameters=new x,this._compositionConfiguration=new v,this._clipBox=u(),this._previousCameraDirection=p(),this._previousSortRequestCameraDirection=p(),this._tileCullingRevision=0,this._sortRequestDirectionEpsilon=.01,this._directionChangeEpsilon=.001,this._configuration=new w(e.view.state.isGlobal),m(this._clipBox,c)}async initialize(){this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange()),t(()=>2===this.view.state.mode,()=>this.requestRender(1))])}precompile(){this._updateConfigurations(),this._compositionConfiguration.useFloatBlend=this.bindParameters.useFloatBlend.value,this._compositionConfiguration.hasEmission=this.bindParameters.hasOpaqueEmission,this.techniques.precompile(q,this._configuration),this.techniques.precompile(b,this._compositionConfiguration),this.techniques.precompile(S)}render(){const e=this.input;if(this._updateConfigurations(),this._handleFading(),!(this._data.visibleGaussians&&this._data.orderTexture.texture&&this._data.textureAtlas.texture&&this._data.headerTexture.texture))return e;const t=e.getAttachment(R);this._compositionConfiguration.useFloatBlend=this.bindParameters.useFloatBlend.value,this._compositionConfiguration.hasEmission=null!=t;const{fullWidth:i,fullHeight:s}=this.bindParameters.camera;this._prepareParameters(s,i);const a=this.renderingContext,r=this.fboCache,o=r.acquire(i,s,"gaussian color output"),n=e.getAttachment(E);o.attachDepth(n);const h=this.techniques.get(q,this._configuration);this._renderGaussianColorAndDepth(o,h);const l=r.acquire(i,s,this.produces);this._depthCompositionPassParameters.splatDepth=o.getTexture(R),l.attachDepth(e.getAttachment(E)),a.bindFramebuffer(l.fbo);const p=this.techniques.get(S);a.bindTechnique(p,this.bindParameters,this._depthCompositionPassParameters),a.screen.draw(),this._compositionPassParameters.color=e.getTexture(),this._compositionPassParameters.splatColor=o.getTexture(),t?(l.acquireColor(R,8,"emissive"),this._compositionPassParameters.emission=e.getTexture(R)):this._compositionPassParameters.emission=null,a.bindFramebuffer(l.fbo);const u=this.techniques.get(b,this._compositionConfiguration);return a.bindTechnique(u,this.bindParameters,this._compositionPassParameters),a.screen.draw(),o.release(),l}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}set clippingBox(e){const t=e||c;this._hasSameClipBox(t)||(m(this._clipBox,t),this._tileCullingRevision=g(this._tileCullingRevision,1),this._data.requestSort(),this.requestRender(1))}get clippingBox(){return this._clippingEnabled?this._clipBox:null}get tileCullingRevision(){return this._tileCullingRevision}get _clippingEnabled(){return!d(this._clipBox,c,(e,t)=>e===t)}get _isIdle(){return 2===this.view.state.mode}get _data(){return this.layerView.data}get _fadeHelper(){return this.layerView.fadeHelper}_updateConfigurations(){const{idleMinimumOpacity:e,nonIdleMinimumOpacity:t}=this.view.qualitySettings.gaussianSplat;this._configuration.alphaCutoff=this._isIdle?e:t,this._configuration.fadingEnabled=this._fadeHelper.fadingEnabled,this._configuration.receiveShadows=this.bindParameters.shadowMap.ready,this._configuration.hasShadowHighlights=this._configuration.receiveShadows&&this.bindParameters.hasShadowHighlights,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasSlicePlane=this._slicePlaneEnabled&&null!=this.bindParameters.slicePlane}_onCameraChange(){this._tileCullingRevision=g(this._tileCullingRevision,1);const e=this.view.state.camera.ray.direction;if(!this._directionChanged(e))return;if(r(this._previousCameraDirection,e),!this._shouldRequestSort(e))return;this._data.requestSort()&&r(this._previousSortRequestCameraDirection,e)}_directionChanged(e){return Math.abs(e[0]-this._previousCameraDirection[0])>this._directionChangeEpsilon||Math.abs(e[1]-this._previousCameraDirection[1])>this._directionChangeEpsilon||Math.abs(e[2]-this._previousCameraDirection[2])>this._directionChangeEpsilon}_shouldRequestSort(e){return Math.abs(e[0]-this._previousSortRequestCameraDirection[0])>this._sortRequestDirectionEpsilon||Math.abs(e[1]-this._previousSortRequestCameraDirection[1])>this._sortRequestDirectionEpsilon||Math.abs(e[2]-this._previousSortRequestCameraDirection[2])>this._sortRequestDirectionEpsilon}_prepareParameters(e,t){this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture,this._passParameters.splatHeader=this._data.headerTexture.texture;const i=Math.tan(.5*this.camera.fovY),s=i/e*t;a(this._passParameters.tanFov,s,i),this._passParameters.focalLength=e/(2*i);const o=this.view.qualitySettings.gaussianSplat,n=this._isIdle?o.idleMinimumSplatPixelRadius:o.nonIdleMinimumSplatPixelRadius;this._passParameters.minSplatRadius=n*Math.sqrt(t*e)/Math.sqrt(2073600),r(this._passParameters.origin,this.bindParameters.camera.eye),this._prepareHighPrecisionCameraPosition(),this._updateSlicePlaneLocalOrigin(),this._updateClipUniforms()}_updateClipUniforms(){const e=this.clippingBox||c,[t,i,s,a,r,n]=e,[h,l,p]=this.camera.eye,{clipMinCameraRelative:u,clipMaxCameraRelative:m}=this._passParameters;o(u,t-h,i-l,s-p),o(m,a-h,r-l,n-p)}_updateSlicePlaneLocalOrigin(){this._passParameters.slicePlaneLocalOrigin=this.camera.eye}_hasSameClipBox(e){return d(this._clipBox,e,(e,t)=>e===t)}_renderGaussianColorAndDepth(e,t){const i=this.renderingContext;e.acquireColor(R,5,"gaussian depth output"),i.bindFramebuffer(e.fbo),i.setClearColor(0,0,0,0),i.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(D.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_prepareHighPrecisionCameraPosition(){n(this._passParameters.tileCameraPosition,this.camera.eye,1/T.tileSize),h(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),n(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,T.tileSize),l(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this._fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this._fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};e([i()],y.prototype,"produces",void 0),e([i({constructOnly:!0})],y.prototype,"layerView",void 0),y=T=e([s("esri.views.3d.webgl-engine.lib.GaussianSplatRenderer")],y);export{y as GaussianSplatRenderer};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{set as a,scale as s,floor as r,subtract as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{positiveInfinity as l}from"../../../../geometry/support/aaBoundingBox.js";import{InternalRenderCategory as h}from"../../webgl.js";import p from"../../webgl/RenderNode.js";import{GaussianSplatRenderer as m}from"./GaussianSplatRenderer.js";import{G as d}from"../../../../chunks/GaussianSplatShadow.glsl.js";import{GaussianSplatShadowTechnique as u}from"../shaders/GaussianSplatShadowTechnique.js";import{GaussianSplatTechniqueConfiguration as c}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{PrimitiveType as _}from"../../../webgl/enums.js";let P=class extends p{constructor(e){super(e),this.produces=h.SHADOW_CASTERS,this.layerView=null,this._passParameters=new d,this._cameraPosition=n(),this._configuration=new c(e.view.state.isGlobal)}render(){const e=this.bindRenderTarget();return this._render(),e}queryDepthRange(e){return this.layerView.suspended?null:this._data.queryVisibleTileDepthRange(e,this.layerView.clippingBox)}get _data(){return this.layerView.data}get _clippingEnabled(){return null!=this.layerView.clippingBox}get _isIdle(){return 2===this.view.state.mode}_render(){const e=this._data;if(this.layerView.suspended||0===e.visibleGaussians||!e.orderTexture.texture||!e.textureAtlas.texture||!e.headerTexture.texture)return;this._updateShadowConfigurations();const t=this.techniques.getCompiled(u,this._configuration);t?(this._prepareShadowParameters(this.bindParameters.camera),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(_.TRIANGLE_STRIP,0,4,e.visibleGaussians)):this.requestRender(1)}_updateShadowConfigurations(){this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasSlicePlane=this.layerView.slicePlaneEnabled&&null!=this.bindParameters.slicePlane,this._configuration.output=this.bindParameters.output}_prepareShadowParameters(e){const t=this._data;this._passParameters.splatOrder=t.orderTexture.texture,this._passParameters.splatAtlas=t.textureAtlas.texture,this._passParameters.splatHeader=t.headerTexture.texture;const{fullHeight:i,fullWidth:a}=e,s=this.view.qualitySettings.gaussianSplat,r=this._isIdle?s.idleMinimumSplatPixelRadius:s.nonIdleMinimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(a*i)/Math.sqrt(2073600),this._updateShadowCameraPosition(e),this._prepareShadowHighPrecisionCameraPosition(),this._passParameters.slicePlaneLocalOrigin=this._cameraPosition,this._updateShadowClipUniforms()}_updateShadowClipUniforms(){const e=this.layerView.clippingBox||l,[t,i,s,r,o,n]=e,[h,p,m]=this._cameraPosition,{clipMinCameraRelative:d,clipMaxCameraRelative:u}=this._passParameters;a(d,t-h,i-p,s-m),a(u,r-h,o-p,n-m)}_prepareShadowHighPrecisionCameraPosition(){s(this._passParameters.tileCameraPosition,this._cameraPosition,1/m.tileSize),r(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),s(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,m.tileSize),o(this._passParameters.cameraDelta,this._cameraPosition,this._passParameters.cameraDelta)}_updateShadowCameraPosition(e){const t=e.viewInverseTransposeMatrix;a(this._cameraPosition,t[3],t[7],t[11])}};e([t()],P.prototype,"produces",void 0),e([t({constructOnly:!0})],P.prototype,"layerView",void 0),P=e([i("esri.views.3d.webgl-engine.lib.GaussianSplatShadows")],P);export{P as GaussianSplatShadows};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{add as t,transformMat4 as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as i}from"../../../../geometry/support/frustum.js";import{create as r,fromPoints as n,copy as o}from"../../../../geometry/support/ray.js";import a from"../../webgl/RenderCamera.js";import{HUDTarget as h,HUDIntersectorResult as l}from"./HUDIntersectorResult.js";import{IntersectorOptions as c}from"./IntersectorInterfaces.js";import{IntersectorResult as f,compareOrderedIntersectionHits as m}from"./IntersectorResult.js";import{ObjectTarget as u}from"./ObjectTarget.js";import{PolygonIntersectionResults as d}from"./PolygonIntersectionResults.js";import{IntersectorTransform as y,getVerticalOffsetObject3D as g}from"./verticalOffsetUtils.js";const _=1e-5;class p{constructor(t){this.options=new c,this._results=new v,this.polygonResults=new d,this.transform=new y,this.camera=new a,this.tolerance=_,this.verticalOffset=null,this._ray=r(),this._rayEnd=e(),this._rayBeginTransformed=e(),this._rayEndTransformed=e(),this.viewingMode=t??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,s,e){this.resetWithRay(n(t,s,this._ray),e)}resetWithRay(s,e){this.camera=e,s!==this._ray&&o(s,this._ray),0!==this.options.verticalOffset?2===this.viewingMode?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,t(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(t=null,s,e,i,r){this.point=s,this.filterPredicate=i,this.tolerance=e??_;const n=g(this.verticalOffset);if(t&&t.length>0){const s=r?t=>{r(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const e of t){const t=e.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,s,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,s),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(s)):e.objects.forEach(t=>s(t))}}this.sortResults()}*intersectScreenPolygon(t=null,s,e){if(this.filterPredicate=e,this.verticalOffset=null,t?.length)for(const r of t)for(const t of r.objects.values())t.visible&&i(s.broadPhaseFrustum,t.boundingVolumeWorldSpace.bounds)&&(yield*this._intersectScreenPolygonObject(t,s))}*_intersectScreenPolygonObject(t,s){const e=t.geometries;if(!e)return;const i=t.effectiveTransformation;for(const r of e){if(!r.visible)continue;const{material:e,id:n}=r;e.visible&&e.intersectScreenPolygon&&(this.transform.setAndInvalidateLazyTransforms(i,r.transformation),e.intersectScreenPolygon(r,this.transform.transform,this,s,(s,e,i,r)=>this._handleObjectScreenPolygonIntersection(new u(t,n,e),s,i,r)),yield)}}intersectObject(t){const e=t.geometries;if(!e)return;const i=t.effectiveTransformation,r=g(this.verticalOffset);for(const n of e){if(!n.visible)continue;const{material:e,id:o}=n;if(!e.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),s(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),s(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const a=this.transform.transform;null!=r&&(r.objectTransform=this.transform),e.intersectRay(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(s,e,i,r)=>this.handleObjectIntersection({object:t,geometryId:o,primitiveIndex:i},s,e,a,r))}}handleObjectIntersection(t,s,e,i,r){if(s<0||null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,s))return;const n=r?this._results.hud:this._results;t=r?new h(t,r):t;const o=r?i=>i.set(1,t,s,e):r=>r.set(4,t,s,e,i);if((null==n.min.distance||s<n.min.distance)&&o(n.min),0!==this.options.store&&(null==n.max.distance||s>n.max.distance)&&o(n.max),2===this.options.store)if(r){const t=new l(this._ray);o(t),this._results.hud.all.push(t)}else{const t=new f(this._ray);o(t),this._results.all.push(t)}}_handleObjectScreenPolygonIntersection(t,s,e,i){s<0||(null==this.filterPredicate||null!=e&&this.filterPredicate(this.camera.eye,e,1))&&this.polygonResults.add(i?1:4,i?new h(t,i):t,s)}sortResults(t=this._results.all){t.sort(m)}}class v{constructor(){this.min=new f(r()),this.max=new f(r()),this.hud={min:new l(r()),max:new l(r()),all:new Array},this.ground=new f(r()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}export{p as Intersector,_ as defaultTolerance};
2
+ import{add as t,transformMat4 as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as i}from"../../../../geometry/support/frustum.js";import{create as r,fromPoints as n,copy as o}from"../../../../geometry/support/ray.js";import a from"../../webgl/RenderCamera.js";import{HUDTarget as l,HUDIntersectorResult as h}from"./HUDIntersectorResult.js";import{IntersectorOptions as c}from"./IntersectorInterfaces.js";import{IntersectorResult as f,compareOrderedIntersectionHits as m}from"./IntersectorResult.js";import{ObjectTarget as u}from"./ObjectTarget.js";import{PolygonIntersectionResults as d}from"./PolygonIntersectionResults.js";import{IntersectorTransform as y,getVerticalOffsetObject3D as g}from"./verticalOffsetUtils.js";const _=1e-5;class p{constructor(t){this.options=new c,this._results=new b,this.polygonResults=new d,this.transform=new y,this.camera=new a,this.tolerance=_,this.verticalOffset=null,this._ray=r(),this._rayEnd=s(),this._rayBeginTransformed=s(),this._rayEndTransformed=s(),this.viewingMode=t??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,e,s){this.resetWithRay(n(t,e,this._ray),s)}resetWithRay(e,s){this.camera=s,e!==this._ray&&o(e,this._ray),0!==this.options.verticalOffset?2===this.viewingMode?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,t(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(t=null,e,s,i,r){this.point=e,this.filterPredicate=i,this.tolerance=s??_;const n=g(this.verticalOffset);if(t&&t.length>0){const e=r?t=>{r(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const s of t){const t=s.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,e,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,e),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(e)):s.objects.forEach(t=>e(t))}}this.sortResults()}*intersectScreenPolygon(t=null,e,s){if(this.filterPredicate=s,this.verticalOffset=null,t?.length)for(const r of t){const t=r.getSpatialQueryAccelerator?.();if(null!=t)for(const s of t.intersectingFrustumValues(e.broadPhaseFrustum,t=>t.visible))yield*this._intersectScreenPolygonObject(s,e);else for(const s of r.objects.values())s.visible&&i(e.broadPhaseFrustum,s.boundingVolumeWorldSpace.bounds)&&(yield*this._intersectScreenPolygonObject(s,e))}}*_intersectScreenPolygonObject(t,e){const s=t.geometries;if(!s)return;const i=t.effectiveTransformation;for(const r of s){if(!r.visible)continue;const{material:s,id:n}=r;s.visible&&s.intersectScreenPolygon&&(this.transform.setAndInvalidateLazyTransforms(i,r.transformation),s.intersectScreenPolygon(r,this.transform.transform,this,e,(e,s,i,r)=>this._handleObjectScreenPolygonIntersection(new u(t,n,s),e,i,r)),yield)}}intersectObject(t){const s=t.geometries;if(!s)return;const i=t.effectiveTransformation,r=g(this.verticalOffset);for(const n of s){if(!n.visible)continue;const{material:s,id:o}=n;if(!s.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),e(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),e(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const a=this.transform.transform;null!=r&&(r.objectTransform=this.transform),s.intersectRay(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(e,s,i,r)=>this.handleObjectIntersection({object:t,geometryId:o,primitiveIndex:i},e,s,a,r))}}handleObjectIntersection(t,e,s,i,r){if(e<0||null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,e))return;const n=r?this._results.hud:this._results;t=r?new l(t,r):t;const o=r?i=>i.set(1,t,e,s):r=>r.set(4,t,e,s,i);if((null==n.min.distance||e<n.min.distance)&&o(n.min),0!==this.options.store&&(null==n.max.distance||e>n.max.distance)&&o(n.max),2===this.options.store)if(r){const t=new h(this._ray);o(t),this._results.hud.all.push(t)}else{const t=new f(this._ray);o(t),this._results.all.push(t)}}_handleObjectScreenPolygonIntersection(t,e,s,i){e<0||(null==this.filterPredicate||null!=s&&this.filterPredicate(this.camera.eye,s,1))&&this.polygonResults.add(i?1:4,i?new l(t,i):t,e)}sortResults(t=this._results.all){t.sort(m)}}class b{constructor(){this.min=new f(r()),this.max=new f(r()),this.hud={min:new h(r()),max:new h(r()),all:new Array},this.ground=new f(r()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}export{p as Intersector,_ as defaultTolerance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{lerp as n,squaredDistance as r,scale as i,add as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as h}from"../../../../geometry/support/frustum.js";import{wrap as d}from"../../../../geometry/support/ray.js";import{Sphere as c}from"../../../../geometry/support/sphere.js";import{rayBoxTest as l}from"./Util.js";class u{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new f,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),f.clearPool(),R[0]=null,k.prune(),W.prune()}add(e){const t=Array.from(e);this._grow(t);const n=f.acquire();for(const r of t)++this._objectCount,this._isDegenerate(r)?this._degenerateObjects.add(r):(n.init(this._root),this._add(r,n));f.release(n)}remove(e,t=null){this._objectCount-=e.length;const n=f.acquire();for(const r of e){const e=t??this.objectToBoundingSphere(r);B(e.radius)?(n.init(this._root),p(r,e,n)):this._degenerateObjects.delete(r)}f.release(n),this._shrink()}update(e,t){if(!B(t.radius)&&this._isDegenerate(e))return;const n=v(e);this.remove(n,t),this.add(n)}forEachAlongRay(e,t,n){const r=d(e,t);m(this._root,e=>{if(!g(r,e))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),!0})}forEachAlongRayWithVerticalOffset(e,t,n,r){const i=d(e,t);m(this._root,e=>{if(!S(i,e,r))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),!0})}forEach(e){m(this._root,t=>{const n=t.node;return n.terminals.forAll(e),null!==n.residents&&n.residents.forAll(e),!0}),this._degenerateObjects.forEach(e)}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}findClosest(e,t,n,r=()=>!0,o=1/0){let a=1/0,d=1/0,c=null;const l=A(e,t),u=i=>{if(--o,!r(i))return;const s=this.objectToBoundingSphere(i);if(!h(n,s))return;const l=N(e,t,s.center),u=l-s.radius,f=l+s.radius;u<a&&(a=u,d=f,c=i)};return _(this._root,r=>{if(o<=0||!h(n,r.bounds))return!1;i(F,l,r.halfSize),s(F,F,r.bounds.center);if(N(e,t,F)>d)return!1;const a=r.node;return a.terminals.forAll(e=>u(e)),null!==a.residents&&a.residents.forAll(e=>u(e)),!0},e,t),c}forEachInDepthRange(e,t,n,r,o,a,d){let c=-1/0,l=1/0;const u={setRange:e=>{1===n?(c=Math.max(c,e.near),l=Math.min(l,e.far)):(c=Math.max(c,-e.far),l=Math.min(l,-e.near))}};u.setRange(r);const f=N(t,n,e),m=A(t,n),p=A(t,-n),b=e=>{if(!d(e))return;const r=this.objectToBoundingSphere(e),i=N(t,n,r.center)-f,s=i-r.radius,m=i+r.radius;s>l||m<c||!h(a,r)||o(e,u)};_(this._root,e=>{if(!h(a,e.bounds))return!1;i(F,m,e.halfSize),s(F,F,e.bounds.center);if(N(t,n,F)-f>l)return!1;i(F,p,e.halfSize),s(F,F,e.bounds.center);if(N(t,n,F)-f<c)return!1;const r=e.node;return r.terminals.forAll(e=>b(e)),null!==r.residents&&r.residents.forAll(e=>b(e)),!0},t,n)}forEachNode(e){m(this._root,t=>e(t.node,t.bounds,t.halfSize,t.depth))}forEachNeighbor(e,t){const n=t.radius,i=t.center,s=t=>{const s=this.objectToBoundingSphere(t),o=s.radius,a=n+o;return!(r(s.center,i)-a*a<=0)||e(t)};let o=!0;const a=e=>{o&&(o=s(e))};m(this._root,e=>{const t=e.bounds.radius,s=n+t;if(r(e.bounds.center,i)-s*s>0)return!1;const h=e.node;return h.terminals.forAll(a),o&&null!==h.residents&&h.residents.forAll(a),o}),o&&this.forEachDegenerateObject(a)}_intersectsObject(e,t){const n=this.objectToBoundingSphere(t);return!(n.radius>0)||n.intersectRay(e)}_intersectsObjectWithOffset(e,t,n){const r=this.objectToBoundingSphere(t);return!(r.radius>0)||n.applyToBoundingSphere(r).intersectRay(e)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let n=0;n<t.length;n++){const r=f.acquire().init(e);this._add(t.at(n),r),f.release(r)}}_grow(e){if(M(e,e=>this.objectToBoundingSphere(e),I),B(I.radius)&&!this._fitsInsideTree(I))if(j(this._root.node))this._root.bounds.copyFrom(I),this._root.halfSize=1.25*this._root.bounds.radius,this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(I);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(I,e):this._growRootAsSubNode(e),f.release(e)}}_rebuildTree(e,t){L.center=t.bounds.center,L.radius=t.halfSize,M([e,L],e=>e,C);const n=f.acquire().init(this._root);this._root.initFrom(null,C,C.radius),this._root.increaseHalfSize(1.25),m(n,e=>(this.add(e.node.terminals.data),null!==e.node.residents&&this.add(e.node.residents.data),!0)),f.release(n)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return m(this._root,e=>(n=Math.max(n,e.depth),n+t<=this._maximumDepth)),n+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e.radius,n=e.center;let r=-1/0;const i=this._root.bounds.center,s=this._root.halfSize;for(let a=0;a<3;a++){const e=i[a]-s-(n[a]-t),o=n[a]+t-(i[a]+s),h=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(o/(2*s)))+1,c=2**Math.ceil(Math.log(h+d)*Math.LOG2E);r=Math.max(r,c),H[a].min=h,H[a].max=d}for(let a=0;a<3;a++){let e=H[a].min,t=H[a].max;const n=(r-(e+t))/2;e+=Math.ceil(n),t+=Math.floor(n);const o=i[a]-s-e*s*2;E.center[a]=o+(t+e)*s}const o=r*s;return E.radius=o*D,f.acquire().initFrom(null,E,o,0)}_growRootAsSubNode(e){const t=this._root.node;I.center=this._root.bounds.center,I.radius=this._root.halfSize,this._root.init(e),e.advanceTo(I,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let n=0,r=0;for(;r<t.length&&null==e;)n=r++,e=t[n];for(;r<t.length;)if(t[r++])return-1;return n}_isDegenerate(e){return!B(this.objectToBoundingSphere(e).radius)}_fitsInsideTree(e){const t=this._root.bounds,n=this._root.halfSize;return e.radius<=n&&e.center[0]>=t.center[0]-n&&e.center[0]<=t.center[0]+n&&e.center[1]>=t.center[1]-n&&e.center[1]<=t.center[1]+n&&e.center[2]>=t.center[2]-n&&e.center[2]<=t.center[2]+n}_nodeToJSON(e){const t=e.children.map(e=>e?this._nodeToJSON(e):null),n=e.residents?.map(e=>this.objectToBoundingSphere(e)),r=e.terminals?.map(e=>this.objectToBoundingSphere(e));return{children:t,residents:n,terminals:r}}}class f{constructor(){this.bounds=new c,this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,n,r=this.depth){return this.node=null!=e?e:f.createEmptyNode(),t&&this.bounds.copyFrom(t),this.halfSize=n,this.depth=r,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds.radius=this.halfSize*D}advance(e){let t=this.node.children[e];t||(t=f.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const n=w[e];return this.bounds.center[0]+=n[0]*this.halfSize,this.bounds.center[1]+=n[1]*this.halfSize,this.bounds.center[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,n=!1){for(;;){if(this.isTerminalFor(e))return t?.(this,-1),!0;if(this.isLeaf()){if(!n)return t?.(this,-1),!1;this.node.residents=null}const r=this._childIndex(e);t?.(this,r),this.advance(r)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e.radius>this.halfSize/2}_childIndex(e){const t=this.bounds.center;return(t[0]<e.center[0]?1:0)+(t[1]<e.center[1]?2:0)+(t[2]<e.center[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static{this._pool=new e(()=>new f)}static acquire(){return f._pool.acquire()}static release(e){f._pool.release(e)}static clearPool(){f._pool.prune()}}function m(e,t){let n=f.acquire().init(e);const r=[n];for(;0!==r.length;){if(n=r.pop(),t(n)&&!n.isLeaf())for(let e=0;e<n.node.children.length;e++){n.node.children[e]&&r.push(f.acquire().init(n).advance(e))}f.release(n)}}function _(e,t,n,r=1){let i=f.acquire().init(e);const s=[i];for(T(n,r,V);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=V[e];i.node.children[t]&&s.push(f.acquire().init(i).advance(t))}f.release(i)}}function p(e,t,n){k.clear();const r=n.advanceTo(t,(e,t)=>{k.push(e.node),k.push(t)})?n.node.terminals:n.node.residents;if(r.removeUnordered(e),0===r.length)for(let i=k.length-2;i>=0;i-=2){if(!b(k.data[i],k.data[i+1]))break}}function b(e,n){return n>=0&&(e.children[n]=null),!!j(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}function g(e,t){return O(t.bounds.center,2*-t.halfSize,q),O(t.bounds.center,2*t.halfSize,P),l(e.origin,e.direction,q,P)}function S(e,t,n){return O(t.bounds.center,2*-t.halfSize,q),O(t.bounds.center,2*t.halfSize,P),n.applyToMinMax(q,P),l(e.origin,e.direction,q,P)}function j(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}function x(e,t){e[0]=Math.min(e[0],t.center[0]-t.radius),e[1]=Math.min(e[1],t.center[1]-t.radius),e[2]=Math.min(e[2],t.center[2]-t.radius)}function z(e,t){e[0]=Math.max(e[0],t.center[0]+t.radius),e[1]=Math.max(e[1],t.center[1]+t.radius),e[2]=Math.max(e[2],t.center[2]+t.radius)}function O(e,t,n){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function M(e,t,r){q[0]=1/0,q[1]=1/0,q[2]=1/0,P[0]=-1/0,P[1]=-1/0,P[2]=-1/0;for(const n of e){const e=t(n);B(e.radius)&&(x(q,e),z(P,e))}n(r.center,q,P,.5),r.radius=Math.max(P[0]-q[0],P[1]-q[1],P[2]-q[2])/2}function T(e,t,n){if(!W.length)for(let r=0;r<8;++r)W.push({index:0,distance:0});for(let r=0;r<8;++r){const n=w[r];W.data[r].index=r,W.data[r].distance=N(e,t,n)}W.sort((e,t)=>e.distance-t.distance);for(let r=0;r<8;++r)n[r]=W.data[r].index}function A(e,t){let n,r=1/0;for(let i=0;i<8;++i){const s=N(e,t,y[i]);s<r&&(r=s,n=y[i])}return n}function N(e,t,n){return t*(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])}function B(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}const w=[o(-1,-1,-1),o(1,-1,-1),o(-1,1,-1),o(1,1,-1),o(-1,-1,1),o(1,-1,1),o(-1,1,1),o(1,1,1)],y=[o(-1,-1,-1),o(-1,-1,1),o(-1,1,-1),o(-1,1,1),o(1,-1,-1),o(1,-1,1),o(1,1,-1),o(1,1,1)],D=Math.sqrt(3),R=[null];function v(e){return R[0]=e,R}const E=new c,F=a(),q=a(),P=a(),k=new t,I=new c,L=new c,C=new c,H=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],W=new t,V=[0,0,0,0,0,0,0,0];export{u as Octree};
2
+ import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{lerp as n,squaredDistance as r,scale as i,add as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as h}from"../../../../geometry/support/frustum.js";import{wrap as d}from"../../../../geometry/support/ray.js";import{Sphere as c}from"../../../../geometry/support/sphere.js";import{rayBoxTest as u}from"./Util.js";class l{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new f,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),f.clearPool(),D[0]=null,V.prune(),W.prune()}add(e){const t=Array.from(e);this._grow(t);const n=f.acquire();for(const r of t)++this._objectCount,this._isDegenerate(r)?this._degenerateObjects.add(r):(n.init(this._root),this._add(r,n));f.release(n)}remove(e,t=null){this._objectCount-=e.length;const n=f.acquire();for(const r of e){const e=t??this.objectToBoundingSphere(r);v(e.radius)?(n.init(this._root),b(r,e,n)):this._degenerateObjects.delete(r)}f.release(n),this._shrink()}update(e,t){if(!v(t.radius)&&this._isDegenerate(e))return;const n=R(e);this.remove(n,t),this.add(n)}forEachAlongRay(e,t,n){const r=d(e,t);_(this._root,e=>{if(!S(r,e))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),!0})}forEachAlongRayWithVerticalOffset(e,t,n,r){const i=d(e,t);_(this._root,e=>{if(!j(i,e,r))return!1;const t=e.node;return t.terminals.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),null!==t.residents&&t.residents.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),!0})}forEach(e){for(const t of this.values())e(t)}*values(){for(const e of this._nodeIteratorValues()){const t=e.node;yield*t.terminals,null!==t.residents&&(yield*t.residents)}yield*this.degenerateObjectValues()}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}*degenerateObjectValues(){yield*this._degenerateObjects.values()}findClosest(e,t,n,r=()=>!0,o=1/0){let a=1/0,d=1/0,c=null;const u=B(e,t),l=i=>{if(--o,!r(i))return;const s=this.objectToBoundingSphere(i);if(!h(n,s))return;const u=N(e,t,s.center),l=u-s.radius,f=u+s.radius;l<a&&(a=l,d=f,c=i)};return p(this._root,r=>{if(o<=0||!h(n,r.bounds))return!1;i(q,u,r.halfSize),s(q,q,r.bounds.center);if(N(e,t,q)>d)return!1;const a=r.node;return a.terminals.forAll(e=>l(e)),null!==a.residents&&a.residents.forAll(e=>l(e)),!0},e,t),c}forEachInDepthRange(e,t,n,r,o,a,d){let c=-1/0,u=1/0;const l={setRange:e=>{1===n?(c=Math.max(c,e.near),u=Math.min(u,e.far)):(c=Math.max(c,-e.far),u=Math.min(u,-e.near))}};l.setRange(r);const f=N(t,n,e),m=B(t,n),_=B(t,-n),b=e=>{if(!d(e))return;const r=this.objectToBoundingSphere(e),i=N(t,n,r.center)-f,s=i-r.radius,m=i+r.radius;s>u||m<c||!h(a,r)||o(e,l)};p(this._root,e=>{if(!h(a,e.bounds))return!1;i(q,m,e.halfSize),s(q,q,e.bounds.center);if(N(t,n,q)-f>u)return!1;i(q,_,e.halfSize),s(q,q,e.bounds.center);if(N(t,n,q)-f<c)return!1;const r=e.node;return r.terminals.forAll(e=>b(e)),null!==r.residents&&r.residents.forAll(e=>b(e)),!0},t,n)}forEachNode(e){_(this._root,t=>e(t.node,t.bounds,t.halfSize,t.depth))}forEachIntersectingFrustum(e,t,n=()=>!0){for(const r of this.intersectingFrustumValues(e,n))t(r)}*intersectingFrustumValues(e,t=()=>!0){for(const n of this._nodeIteratorValues(t=>h(e,t.bounds))){const r=n.node;for(const n of r.terminals)t(n)&&h(e,this.objectToBoundingSphere(n))&&(yield n);if(null!==r.residents)for(const n of r.residents)t(n)&&h(e,this.objectToBoundingSphere(n))&&(yield n)}}*_nodeIteratorValues(e=()=>!0){yield*m(this._root,e)}forEachNeighbor(e,t){const n=t.radius,i=t.center,s=t=>{const s=this.objectToBoundingSphere(t),o=s.radius,a=n+o;return!(r(s.center,i)-a*a<=0)||e(t)};let o=!0;const a=e=>{o&&(o=s(e))};_(this._root,e=>{const t=e.bounds.radius,s=n+t;if(r(e.bounds.center,i)-s*s>0)return!1;const h=e.node;return h.terminals.forAll(a),o&&null!==h.residents&&h.residents.forAll(a),o}),o&&this.forEachDegenerateObject(a)}_intersectsObject(e,t){const n=this.objectToBoundingSphere(t);return!(n.radius>0)||n.intersectRay(e)}_intersectsObjectWithOffset(e,t,n){const r=this.objectToBoundingSphere(t);return!(r.radius>0)||n.applyToBoundingSphere(r).intersectRay(e)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let n=0;n<t.length;n++){const r=f.acquire().init(e);this._add(t.at(n),r),f.release(r)}}_grow(e){if(T(e,e=>this.objectToBoundingSphere(e),k),v(k.radius)&&!this._fitsInsideTree(k))if(x(this._root.node))this._root.bounds.copyFrom(k),this._root.halfSize=1.25*this._root.bounds.radius,this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(k);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(k,e):this._growRootAsSubNode(e),f.release(e)}}_rebuildTree(e,t){L.center=t.bounds.center,L.radius=t.halfSize,T([e,L],e=>e,C);const n=f.acquire().init(this._root);this._root.initFrom(null,C,C.radius),this._root.increaseHalfSize(1.25),_(n,e=>(this.add(e.node.terminals.data),null!==e.node.residents&&this.add(e.node.residents.data),!0)),f.release(n)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return _(this._root,e=>(n=Math.max(n,e.depth),n+t<=this._maximumDepth)),n+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e.radius,n=e.center;let r=-1/0;const i=this._root.bounds.center,s=this._root.halfSize;for(let a=0;a<3;a++){const e=i[a]-s-(n[a]-t),o=n[a]+t-(i[a]+s),h=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(o/(2*s)))+1,c=2**Math.ceil(Math.log(h+d)*Math.LOG2E);r=Math.max(r,c),H[a].min=h,H[a].max=d}for(let a=0;a<3;a++){let e=H[a].min,t=H[a].max;const n=(r-(e+t))/2;e+=Math.ceil(n),t+=Math.floor(n);const o=i[a]-s-e*s*2;E.center[a]=o+(t+e)*s}const o=r*s;return E.radius=o*F,f.acquire().initFrom(null,E,o,0)}_growRootAsSubNode(e){const t=this._root.node;k.center=this._root.bounds.center,k.radius=this._root.halfSize,this._root.init(e),e.advanceTo(k,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let n=0,r=0;for(;r<t.length&&null==e;)n=r++,e=t[n];for(;r<t.length;)if(t[r++])return-1;return n}_isDegenerate(e){return!v(this.objectToBoundingSphere(e).radius)}_fitsInsideTree(e){const t=this._root.bounds,n=this._root.halfSize;return e.radius<=n&&e.center[0]>=t.center[0]-n&&e.center[0]<=t.center[0]+n&&e.center[1]>=t.center[1]-n&&e.center[1]<=t.center[1]+n&&e.center[2]>=t.center[2]-n&&e.center[2]<=t.center[2]+n}_nodeToJSON(e){const t=e.children.map(e=>e?this._nodeToJSON(e):null),n=e.residents?.map(e=>this.objectToBoundingSphere(e)),r=e.terminals?.map(e=>this.objectToBoundingSphere(e));return{children:t,residents:n,terminals:r}}}class f{constructor(){this.bounds=new c,this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,n,r=this.depth){return this.node=null!=e?e:f.createEmptyNode(),t&&this.bounds.copyFrom(t),this.halfSize=n,this.depth=r,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds.radius=this.halfSize*F}advance(e){let t=this.node.children[e];t||(t=f.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const n=w[e];return this.bounds.center[0]+=n[0]*this.halfSize,this.bounds.center[1]+=n[1]*this.halfSize,this.bounds.center[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,n=!1){for(;;){if(this.isTerminalFor(e))return t?.(this,-1),!0;if(this.isLeaf()){if(!n)return t?.(this,-1),!1;this.node.residents=null}const r=this._childIndex(e);t?.(this,r),this.advance(r)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e.radius>this.halfSize/2}_childIndex(e){const t=this.bounds.center;return(t[0]<e.center[0]?1:0)+(t[1]<e.center[1]?2:0)+(t[2]<e.center[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static{this._pool=new e(()=>new f)}static acquire(){return f._pool.acquire()}static release(e){f._pool.release(e)}static clearPool(){f._pool.prune()}}function*m(e,t=()=>!0){const n=[f.acquire().init(e)];for(;0!==n.length;){const e=n.pop();if(t(e)){if(yield e,!e.isLeaf())for(let t=0;t<e.node.children.length;t++){e.node.children[t]&&n.push(f.acquire().init(e).advance(t))}f.release(e)}}}function _(e,t){const n=m(e,t);for(const r of n);}function p(e,t,n,r=1){let i=f.acquire().init(e);const s=[i];for(y(n,r,G);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=G[e];i.node.children[t]&&s.push(f.acquire().init(i).advance(t))}f.release(i)}}function b(e,t,n){V.clear();const r=n.advanceTo(t,(e,t)=>{V.push(e.node),V.push(t)})?n.node.terminals:n.node.residents;if(r.removeUnordered(e),0===r.length)for(let i=V.length-2;i>=0;i-=2){if(!g(V.data[i],V.data[i+1]))break}}function g(e,n){return n>=0&&(e.children[n]=null),!!x(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}function S(e,t){return M(t.bounds.center,2*-t.halfSize,I),M(t.bounds.center,2*t.halfSize,P),u(e.origin,e.direction,I,P)}function j(e,t,n){return M(t.bounds.center,2*-t.halfSize,I),M(t.bounds.center,2*t.halfSize,P),n.applyToMinMax(I,P),u(e.origin,e.direction,I,P)}function x(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}function z(e,t){e[0]=Math.min(e[0],t.center[0]-t.radius),e[1]=Math.min(e[1],t.center[1]-t.radius),e[2]=Math.min(e[2],t.center[2]-t.radius)}function O(e,t){e[0]=Math.max(e[0],t.center[0]+t.radius),e[1]=Math.max(e[1],t.center[1]+t.radius),e[2]=Math.max(e[2],t.center[2]+t.radius)}function M(e,t,n){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function T(e,t,r){I[0]=1/0,I[1]=1/0,I[2]=1/0,P[0]=-1/0,P[1]=-1/0,P[2]=-1/0;for(const n of e){const e=t(n);v(e.radius)&&(z(I,e),O(P,e))}n(r.center,I,P,.5),r.radius=Math.max(P[0]-I[0],P[1]-I[1],P[2]-I[2])/2}function y(e,t,n){if(!W.length)for(let r=0;r<8;++r)W.push({index:0,distance:0});for(let r=0;r<8;++r){const n=w[r];W.data[r].index=r,W.data[r].distance=N(e,t,n)}W.sort((e,t)=>e.distance-t.distance);for(let r=0;r<8;++r)n[r]=W.data[r].index}function B(e,t){let n,r=1/0;for(let i=0;i<8;++i){const s=N(e,t,A[i]);s<r&&(r=s,n=A[i])}return n}function N(e,t,n){return t*(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])}function v(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}const w=[o(-1,-1,-1),o(1,-1,-1),o(-1,1,-1),o(1,1,-1),o(-1,-1,1),o(1,-1,1),o(-1,1,1),o(1,1,1)],A=[o(-1,-1,-1),o(-1,-1,1),o(-1,1,-1),o(-1,1,1),o(1,-1,-1),o(1,-1,1),o(1,1,-1),o(1,1,1)],F=Math.sqrt(3),D=[null];function R(e){return D[0]=e,D}const E=new c,q=a(),I=a(),P=a(),V=new t,k=new c,L=new c,C=new c,H=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],W=new t,G=[0,0,0,0,0,0,0,0];export{l as Octree};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{sub as t,set as n,copy as o,cross as i,normalize as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as s,setMax as r,create as u}from"../../../../geometry/support/aaBoundingBox.js";import{assert as f}from"./Util.js";class a{constructor(t=0,n=!1,o=!0){this.tolerance=t,this.isVerticalRay=n,this.normalRequired=o}}const l=u();function m(n,o,i,e,c,s){if(!n.visible)return;const r=t(F,e,i),{tolerance:u}=o,l=new a(u,!1,o.options.normalRequired);if(n.boundingInfo)f(0===n.type),h(n.boundingInfo,i,r,u,c,l,s);else{const t=n.positionAttribute,o=n.primitivePositionIndices;T(i,r,0,o.length/3,o,t.data,t.stride,c,l,s)}}const p=c();function h(t,n,o,i,e,c,u){if(null==t)return;const f=C(o,p);if(s(l,t.bbMin),r(l,t.bbMax),null!=e&&e.applyToAabb(l),U(l,n,f,i)){const{primitiveIndices:s,position:r}=t,f=s?s.length:r.indices.length/3;if(f>z){const s=t.getChildren();if(void 0!==s){for(const t of s)h(t,n,o,i,e,c,u);return}}q(n,o,0,f,r.indices,r.data,r.stride,s,e,c,u)}}const d=c();function b(n,o,i,e,c,s,r,u,f){const{data:a,stride:l}=s;T(n,t(F,o,n),i,e,c,a,l,r,u,f)}function M(t,n,o,i){if(!o.visible)return;const{boundingInfo:e}=o;if(e){const{bbMin:o,bbMax:i}=e;if(t<o[0]||t>i[0]||n<o[1]||n>i[1])return}const c=o.positionAttribute,s=o.primitivePositionIndices;x(t,n,0,s.length/3,s,c,i)}function x(t,n,o,i,e,c,s){const{data:r,stride:u}=c;for(let f=o;f<i;++f){const o=3*f,i=u*e[o],c=u*e[o+1],a=u*e[o+2],l=r[i+0]-t,m=r[i+1]-n,p=r[c+0]-t,h=r[c+1]-n,d=r[a+0]-t,b=r[a+1]-n,M=d*h-b*p,x=l*b-m*d,g=p*m-h*l;(M<0||x<0||g<0)&&(M>0||x>0||g>0)||s(0,null,f)}}function g(t,n,o,i,e,c,s,r,u,f=null,a=0){const l=t[0],m=t[1],p=t[2],h=n[0],b=n[1],M=n[2];for(let x=o;x<i;++x){const t=a+(f?.[x]??x),n=3*t,o=s*e[n],i=c[o],g=c[o+1],y=c[o+2],v=s*e[n+1],q=c[v],T=c[v+1],V=c[v+2],I=s*e[n+2],R=q-i,A=T-g,B=V-y,P=c[I]-i,w=c[I+1]-g,C=c[I+2]-y,U=b*C-w*M,k=M*P-C*h,z=h*w-P*b,D=R*U+A*k+B*z,F=D*D;if(F<=E)continue;const G=l-i,H=m-g,J=p-y,K=(G*U+H*k+J*z)*D;if(K<0||K>F)continue;const L=H*B-A*J,N=J*R-B*G,O=G*A-R*H,Q=(h*L+b*N+M*O)*D;if(Q<0||K+Q>F)continue;const S=(P*L+w*N+C*O)/D;if(S>=0){u(S,r?j(R,A,B,P,w,C,d):null,t)}}}function y(t,n,o,i,e,c,s,r){const u=t[0],f=t[1],a=t[2],l=n[0],m=n[1],p=n[2];for(let h=o;h<i;++h){const t=3*h,n=t+1,o=t+2,i=c*t,b=e[i],M=e[i+1],x=e[i+2],g=c*n,y=c*o,v=e[g]-b,q=e[g+1]-M,T=e[g+2]-x,V=e[y]-b,I=e[y+1]-M,R=e[y+2]-x,A=m*R-I*p,B=p*V-R*l,P=l*I-V*m,w=v*A+q*B+T*P,C=w*w;if(C<=E)continue;const U=u-b,k=f-M,z=a-x,D=(U*A+k*B+z*P)*w;if(D<0||D>C)continue;const F=k*T-q*z,G=z*v-T*U,H=U*q-v*k,J=(l*F+m*G+p*H)*w;if(J<0||D+J>C)continue;const K=(V*F+I*G+R*H)/w;if(K>=0){r(K,s?j(v,q,T,V,I,R,d):null,h)}}}function v(t,n,o,i,e,c,s,r,u,f,a,l=null,m=0){const p=t[0],h=t[1],b=t[2],M=n[0],x=n[1],g=n[2];for(let y=o;y<i;++y){const t=m+(l?.[y]??y),n=3*t,o=s*e[n],i=c[o],v=c[o+1],q=c[o+2],T=s*e[n+1],V=c[T],I=c[T+1],R=c[T+2],A=s*e[n+2],B=c[A],P=c[A+1],w=c[A+2],C=q-u,U=r/Math.sqrt(i*i+v*v+C*C),k=i+i*U,z=v+v*U,D=q+C*U,F=R-u,G=r/Math.sqrt(V*V+I*I+F*F),H=V+V*G,J=I+I*G,K=R+F*G,L=w-u,N=r/Math.sqrt(B*B+P*P+L*L),O=H-k,Q=J-z,S=K-D,W=B+B*N-k,X=P+P*N-z,Y=w+L*N-D,Z=x*Y-X*g,$=g*W-Y*M,_=M*X-W*x,tt=O*Z+Q*$+S*_,nt=tt*tt;if(nt<=E)continue;const ot=p-k,it=h-z,et=b-D,ct=(ot*Z+it*$+et*_)*tt;if(ct<0||ct>nt)continue;const st=it*S-Q*et,rt=et*O-S*ot,ut=ot*Q-O*it,ft=(M*st+x*rt+g*ut)*tt;if(ft<0||ct+ft>nt)continue;const at=(W*st+X*rt+Y*ut)/tt;if(at>=0){a(at,f?j(O,Q,S,W,X,Y,d):null,t)}}}function q(t,n,o,i,e,c,s,r,u,f,a){const l=t[0],m=t[1],p=t[2],h=n[0],b=n[1],M=n[2],{normalRequired:x}=f;for(let g=o;g<i;++g){const t=r[g],n=3*t,o=s*e[n];let i=c[o],f=c[o+1],y=c[o+2];const v=s*e[n+1];let q=c[v],T=c[v+1],V=c[v+2];const I=s*e[n+2];let R=c[I],A=c[I+1],B=c[I+2];null!=u&&([i,f,y]=u.applyToVertex(i,f,y,g),[q,T,V]=u.applyToVertex(q,T,V,g),[R,A,B]=u.applyToVertex(R,A,B,g));const P=q-i,w=T-f,C=V-y,U=R-i,k=A-f,z=B-y,D=b*z-k*M,F=M*U-z*h,G=h*k-U*b,H=P*D+w*F+C*G,J=H*H;if(J<=E)continue;const K=l-i,L=m-f,N=p-y,O=(K*D+L*F+N*G)*H;if(O<0||O>J)continue;const Q=L*C-w*N,S=N*P-C*K,W=K*w-P*L,X=(h*Q+b*S+M*W)*H;if(X<0||O+X>J)continue;const Y=(U*Q+k*S+z*W)/H;if(Y>=0){a(Y,x?j(P,w,C,U,k,z,d):null,t)}}}function T(i,e,c,s,r,u,f,a,l,m){const p=e,h=G,d=Math.abs(p[0]),b=Math.abs(p[1]),M=Math.abs(p[2]),x=d>=b?d>=M?0:2:b>=M?1:2,g=x,y=p[g]<0?2:1,v=(x+y)%3,q=(x+(3-y))%3,T=p[v]/p[g],j=p[q]/p[g],B=1/p[g],P=V,w=I,C=R,{normalRequired:U}=l;for(let V=c;V<s;++V){const e=3*V,c=f*r[e];n(h[0],u[c+0],u[c+1],u[c+2]);const s=f*r[e+1];n(h[1],u[s+0],u[s+1],u[s+2]);const l=f*r[e+2];n(h[2],u[l+0],u[l+1],u[l+2]),a&&(o(h[0],a.applyToVertex(h[0][0],h[0][1],h[0][2],V)),o(h[1],a.applyToVertex(h[1][0],h[1][1],h[1][2],V)),o(h[2],a.applyToVertex(h[2][0],h[2][1],h[2][2],V))),t(P,h[0],i),t(w,h[1],i),t(C,h[2],i);const p=P[v]-T*P[g],d=P[q]-j*P[g],b=w[v]-T*w[g],M=w[q]-j*w[g],x=C[v]-T*C[g],y=C[q]-j*C[g],I=x*M-y*b,R=p*y-d*x,k=b*d-M*p;if((I<0||R<0||k<0)&&(I>0||R>0||k>0))continue;const z=I+R+k;if(0===z)continue;const D=I*(B*P[g])+R*(B*w[g])+k*(B*C[g]);if(D*Math.sign(z)<0)continue;const E=D/z;if(E>=0){m(E,U?A(h):null,V)}}}const V=c(),I=c(),R=c();function j(t,o,c,s,r,u,f){return n(B,t,o,c),n(P,s,r,u),i(f,B,P),e(f,f),f}function A(n){return t(B,n[1],n[0]),t(P,n[2],n[0]),i(d,B,P),e(d,d),d}const B=c(),P=c();function w(t,o,i){return n(i,1/(o[0]-t[0]),1/(o[1]-t[1]),1/(o[2]-t[2]))}function C(t,o){return n(o,1/t[0],1/t[1],1/t[2])}function U(t,n,o,i){return k(t,n,o,i,1/0)}function k(t,n,o,i,e){const c=(t[0]-i-n[0])*o[0],s=(t[3]+i-n[0])*o[0];let r=Math.min(c,s),u=Math.max(c,s);const f=(t[1]-i-n[1])*o[1],a=(t[4]+i-n[1])*o[1];if(u=Math.min(u,Math.max(f,a)),u<0)return!1;if(r=Math.max(r,Math.min(f,a)),r>u)return!1;const l=(t[2]-i-n[2])*o[2],m=(t[5]+i-n[2])*o[2];return u=Math.min(u,Math.max(l,m)),!(u<0)&&(r=Math.max(r,Math.min(l,m)),!(r>u)&&r<e)}const z=1e3,D=1e-7,E=D*D,F=c(),G=[c(),c(),c()];export{a as MeshIntersectionOptions,w as computeInvDir,C as computeInvDirFromDirection,j as computeNormalFromBarycentric,U as intersectAabbInvDir,k as intersectAabbInvDirBefore,g as intersectRayTriangles,T as intersectRayTrianglesWithDisplacementWatertight,v as intersectRayTrianglesWithVerticalOffsetENUGlobal,y as intersectRenderGeometryTriangles,m as intersectTriangleGeometry,M as intersectTriangleGeometry2D,b as intersectTriangles,x as intersectTriangles2d,D as triangleRayParallelTolerance};
2
+ import{sub as t,set as n,copy as o,cross as i,normalize as e}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as s,setMax as r,create as u}from"../../../../geometry/support/aaBoundingBox.js";import{boundingInfoSubdivisionThreshold as f}from"./intersectionConstants.js";import{assert as a}from"./Util.js";class l{constructor(t=0,n=!1,o=!0){this.tolerance=t,this.isVerticalRay=n,this.normalRequired=o}}const m=u();function p(n,o,i,e,c,s){if(!n.visible)return;const r=t(F,e,i),{tolerance:u}=o,f=new l(u,!1,o.options.normalRequired);if(n.boundingInfo)a(0===n.type),d(n.boundingInfo,i,r,u,c,f,s);else{const t=n.positionAttribute,o=n.primitivePositionIndices;V(i,r,0,o.length/3,o,t.data,t.stride,c,f,s)}}const h=c();function d(t,n,o,i,e,c,u){if(null==t)return;const a=U(o,h);if(s(m,t.bbMin),r(m,t.bbMax),null!=e&&e.applyToAabb(m),k(m,n,a,i)){const{primitiveIndices:s,position:r}=t,a=s?s.length:r.indices.length/3;if(a>f){const s=t.getChildren();if(void 0!==s){for(const t of s)d(t,n,o,i,e,c,u);return}}T(n,o,0,a,r.indices,r.data,r.stride,s,e,c,u)}}const b=c();function M(n,o,i,e,c,s,r,u,f){const{data:a,stride:l}=s;V(n,t(F,o,n),i,e,c,a,l,r,u,f)}function x(t,n,o,i){if(!o.visible)return;const{boundingInfo:e}=o;if(e){const{bbMin:o,bbMax:i}=e;if(t<o[0]||t>i[0]||n<o[1]||n>i[1])return}const c=o.positionAttribute,s=o.primitivePositionIndices;g(t,n,0,s.length/3,s,c,i)}function g(t,n,o,i,e,c,s){const{data:r,stride:u}=c;for(let f=o;f<i;++f){const o=3*f,i=u*e[o],c=u*e[o+1],a=u*e[o+2],l=r[i+0]-t,m=r[i+1]-n,p=r[c+0]-t,h=r[c+1]-n,d=r[a+0]-t,b=r[a+1]-n,M=d*h-b*p,x=l*b-m*d,g=p*m-h*l;(M<0||x<0||g<0)&&(M>0||x>0||g>0)||s(0,null,f)}}function y(t,n,o,i,e,c,s,r,u,f=null,a=0){const l=t[0],m=t[1],p=t[2],h=n[0],d=n[1],M=n[2];for(let x=o;x<i;++x){const t=a+(f?.[x]??x),n=3*t,o=s*e[n],i=c[o],g=c[o+1],y=c[o+2],v=s*e[n+1],q=c[v],T=c[v+1],V=c[v+2],I=s*e[n+2],j=q-i,R=T-g,B=V-y,C=c[I]-i,P=c[I+1]-g,w=c[I+2]-y,U=d*w-P*M,k=M*C-w*h,z=h*P-C*d,D=j*U+R*k+B*z,F=D*D;if(F<=E)continue;const G=l-i,H=m-g,J=p-y,K=(G*U+H*k+J*z)*D;if(K<0||K>F)continue;const L=H*B-R*J,N=J*j-B*G,O=G*R-j*H,Q=(h*L+d*N+M*O)*D;if(Q<0||K+Q>F)continue;const S=(C*L+P*N+w*O)/D;if(S>=0){u(S,r?A(j,R,B,C,P,w,b):null,t)}}}function v(t,n,o,i,e,c,s,r){const u=t[0],f=t[1],a=t[2],l=n[0],m=n[1],p=n[2];for(let h=o;h<i;++h){const t=3*h,n=t+1,o=t+2,i=c*t,d=e[i],M=e[i+1],x=e[i+2],g=c*n,y=c*o,v=e[g]-d,q=e[g+1]-M,T=e[g+2]-x,V=e[y]-d,I=e[y+1]-M,j=e[y+2]-x,R=m*j-I*p,B=p*V-j*l,C=l*I-V*m,P=v*R+q*B+T*C,w=P*P;if(w<=E)continue;const U=u-d,k=f-M,z=a-x,D=(U*R+k*B+z*C)*P;if(D<0||D>w)continue;const F=k*T-q*z,G=z*v-T*U,H=U*q-v*k,J=(l*F+m*G+p*H)*P;if(J<0||D+J>w)continue;const K=(V*F+I*G+j*H)/P;if(K>=0){r(K,s?A(v,q,T,V,I,j,b):null,h)}}}function q(t,n,o,i,e,c,s,r,u,f,a,l=null,m=0){const p=t[0],h=t[1],d=t[2],M=n[0],x=n[1],g=n[2];for(let y=o;y<i;++y){const t=m+(l?.[y]??y),n=3*t,o=s*e[n],i=c[o],v=c[o+1],q=c[o+2],T=s*e[n+1],V=c[T],I=c[T+1],j=c[T+2],R=s*e[n+2],B=c[R],C=c[R+1],P=c[R+2],w=q-u,U=r/Math.sqrt(i*i+v*v+w*w),k=i+i*U,z=v+v*U,D=q+w*U,F=j-u,G=r/Math.sqrt(V*V+I*I+F*F),H=V+V*G,J=I+I*G,K=j+F*G,L=P-u,N=r/Math.sqrt(B*B+C*C+L*L),O=H-k,Q=J-z,S=K-D,W=B+B*N-k,X=C+C*N-z,Y=P+L*N-D,Z=x*Y-X*g,$=g*W-Y*M,_=M*X-W*x,tt=O*Z+Q*$+S*_,nt=tt*tt;if(nt<=E)continue;const ot=p-k,it=h-z,et=d-D,ct=(ot*Z+it*$+et*_)*tt;if(ct<0||ct>nt)continue;const st=it*S-Q*et,rt=et*O-S*ot,ut=ot*Q-O*it,ft=(M*st+x*rt+g*ut)*tt;if(ft<0||ct+ft>nt)continue;const at=(W*st+X*rt+Y*ut)/tt;if(at>=0){a(at,f?A(O,Q,S,W,X,Y,b):null,t)}}}function T(t,n,o,i,e,c,s,r,u,f,a){const l=t[0],m=t[1],p=t[2],h=n[0],d=n[1],M=n[2],{normalRequired:x}=f;for(let g=o;g<i;++g){const t=r[g],n=3*t,o=s*e[n];let i=c[o],f=c[o+1],y=c[o+2];const v=s*e[n+1];let q=c[v],T=c[v+1],V=c[v+2];const I=s*e[n+2];let j=c[I],R=c[I+1],B=c[I+2];null!=u&&([i,f,y]=u.applyToVertex(i,f,y,g),[q,T,V]=u.applyToVertex(q,T,V,g),[j,R,B]=u.applyToVertex(j,R,B,g));const C=q-i,P=T-f,w=V-y,U=j-i,k=R-f,z=B-y,D=d*z-k*M,F=M*U-z*h,G=h*k-U*d,H=C*D+P*F+w*G,J=H*H;if(J<=E)continue;const K=l-i,L=m-f,N=p-y,O=(K*D+L*F+N*G)*H;if(O<0||O>J)continue;const Q=L*w-P*N,S=N*C-w*K,W=K*P-C*L,X=(h*Q+d*S+M*W)*H;if(X<0||O+X>J)continue;const Y=(U*Q+k*S+z*W)/H;if(Y>=0){a(Y,x?A(C,P,w,U,k,z,b):null,t)}}}function V(i,e,c,s,r,u,f,a,l,m){const p=e,h=G,d=Math.abs(p[0]),b=Math.abs(p[1]),M=Math.abs(p[2]),x=d>=b?d>=M?0:2:b>=M?1:2,g=x,y=p[g]<0?2:1,v=(x+y)%3,q=(x+(3-y))%3,T=p[v]/p[g],V=p[q]/p[g],A=1/p[g],C=I,P=j,w=R,{normalRequired:U}=l;for(let I=c;I<s;++I){const e=3*I,c=f*r[e];n(h[0],u[c+0],u[c+1],u[c+2]);const s=f*r[e+1];n(h[1],u[s+0],u[s+1],u[s+2]);const l=f*r[e+2];n(h[2],u[l+0],u[l+1],u[l+2]),a&&(o(h[0],a.applyToVertex(h[0][0],h[0][1],h[0][2],I)),o(h[1],a.applyToVertex(h[1][0],h[1][1],h[1][2],I)),o(h[2],a.applyToVertex(h[2][0],h[2][1],h[2][2],I))),t(C,h[0],i),t(P,h[1],i),t(w,h[2],i);const p=C[v]-T*C[g],d=C[q]-V*C[g],b=P[v]-T*P[g],M=P[q]-V*P[g],x=w[v]-T*w[g],y=w[q]-V*w[g],j=x*M-y*b,R=p*y-d*x,k=b*d-M*p;if((j<0||R<0||k<0)&&(j>0||R>0||k>0))continue;const z=j+R+k;if(0===z)continue;const D=j*(A*C[g])+R*(A*P[g])+k*(A*w[g]);if(D*Math.sign(z)<0)continue;const E=D/z;if(E>=0){m(E,U?B(h):null,I)}}}const I=c(),j=c(),R=c();function A(t,o,c,s,r,u,f){return n(C,t,o,c),n(P,s,r,u),i(f,C,P),e(f,f),f}function B(n){return t(C,n[1],n[0]),t(P,n[2],n[0]),i(b,C,P),e(b,b),b}const C=c(),P=c();function w(t,o,i){return n(i,1/(o[0]-t[0]),1/(o[1]-t[1]),1/(o[2]-t[2]))}function U(t,o){return n(o,1/t[0],1/t[1],1/t[2])}function k(t,n,o,i){return z(t,n,o,i,1/0)}function z(t,n,o,i,e){const c=(t[0]-i-n[0])*o[0],s=(t[3]+i-n[0])*o[0];let r=Math.min(c,s),u=Math.max(c,s);const f=(t[1]-i-n[1])*o[1],a=(t[4]+i-n[1])*o[1];if(u=Math.min(u,Math.max(f,a)),u<0)return!1;if(r=Math.max(r,Math.min(f,a)),r>u)return!1;const l=(t[2]-i-n[2])*o[2],m=(t[5]+i-n[2])*o[2];return u=Math.min(u,Math.max(l,m)),!(u<0)&&(r=Math.max(r,Math.min(l,m)),!(r>u)&&r<e)}const D=1e-7,E=D*D,F=c(),G=[c(),c(),c()];export{l as MeshIntersectionOptions,w as computeInvDir,U as computeInvDirFromDirection,A as computeNormalFromBarycentric,k as intersectAabbInvDir,z as intersectAabbInvDirBefore,y as intersectRayTriangles,V as intersectRayTrianglesWithDisplacementWatertight,q as intersectRayTrianglesWithVerticalOffsetENUGlobal,v as intersectRenderGeometryTriangles,p as intersectTriangleGeometry,x as intersectTriangleGeometry2D,M as intersectTriangles,g as intersectTriangles2d,D as triangleRayParallelTolerance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{isDepthOrShadowLike as s}from"../core/shaderLibrary/ShaderOutput.js";import{ScreenSpaceGeometry as r}from"../effects/ScreenSpaceGeometry.js";import{createEmptyTexture as t}from"./glUtil3D.js";import{IndexBufferCache as i}from"../materials/renderers/IndexBufferCache.js";import{TextureBufferCache as h}from"../materials/renderers/TextureBufferCache.js";import{VaoCache as a}from"../materials/renderers/VaoCache.js";import{VboCache as o}from"../materials/renderers/VboCache.js";import{DrawBufferNone as n}from"../../../webgl/enums.js";import{RenderingContext as u,getFramebufferDrawBuffers as c}from"../../../webgl/RenderingContext.js";class f extends u{constructor(e,s){super(e,s),this.emptyTexture=t(this),this._vaoCaches=new Map,this._vboCaches=new Map,this._indexBufferCache=null,this._textureBufferCaches=new Map,this._output=0,this.debugBoundTechnique="",this._refCount=1,this._newCache=s.newCache,this._screen=new r(this)}configure(e){super.configure(e),this._newCache=e.newCache}destroy(){this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache=e(this._indexBufferCache),this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear(),--this._refCount>0||this.dispose()}ref(){++this._refCount}get refCount(){return this._refCount}dispose(){this.emptyTexture.dispose(),this._screen.destroy(),this._screen=null,super.dispose(),this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache?.dispose(),this._indexBufferCache=null,this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear()}get newCache(){return this._newCache}get screen(){return this._screen}getVaoCache(e){const s=JSON.stringify(e),r=this._vaoCaches.get(s);if(r)return r;const t=new a(this,e);return this._vaoCaches.set(s,t),t}getVboCache(e){const s=JSON.stringify(e),r=this._vboCaches.get(s);if(r)return r;const t=new o(this,e);return this._vboCaches.set(s,t),t}get indexBufferCache(){return this._indexBufferCache??=new i(this),this._indexBufferCache}getTextureBufferCache(e){const s=JSON.stringify(e),r=this._textureBufferCaches.get(s);if(r)return r;const t=new h(this,e);return this._textureBufferCaches.set(s,t),t}resetDrawBuffers(e){this._output=e,this.setDrawBuffers(c(this._state.drawFramebuffer))}setDrawBuffers(e){return s(this._output)?super.setDrawBuffers([n]):super.setDrawBuffers(e)}bindTechnique(e,s,r,t){return this.debugBoundTechnique=e.declaredClass,this.useProgram(e.program),this.setPipelineState(e.getPipeline(s,r)),e.program.bind(s),e.program.bindPass(r,s),t&&e.program.bindDraw(s,r,t),e.program}get isAssumedMetalDriver(){if(null==this._isAssumedMetalDriver&&(this._isAssumedMetalDriver=!!has("ios")||!!has("safari"),!this._isAssumedMetalDriver&&has("mac")&&has("chrome"))){const e=this.capabilities.rendererInfo?.getUnmaskedRenderer().toLowerCase(),s=e?.includes("apple")&&e?.includes("angle")&&e?.includes("metal");this._isAssumedMetalDriver=s??!0}return this._isAssumedMetalDriver}get test(){}}export{f as RenderingContext};
2
+ import has from"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{isDepthOrShadowLike as s}from"../core/shaderLibrary/ShaderOutput.js";import{ScreenSpaceGeometry as r}from"../effects/ScreenSpaceGeometry.js";import{createEmptyTexture as t}from"./glUtil3D.js";import{IndexBufferCache as i}from"../materials/renderers/IndexBufferCache.js";import{TextureBufferCache as h}from"../materials/renderers/TextureBufferCache.js";import{VaoCache as a}from"../materials/renderers/VaoCache.js";import{VboCache as o}from"../materials/renderers/VboCache.js";import{DrawBufferNone as n}from"../../../webgl/enums.js";import{RenderingContext as u,getFramebufferDrawBuffers as c}from"../../../webgl/RenderingContext.js";class f extends u{constructor(e,s){super(e,s),this.emptyTexture=t(this),this._vaoCaches=new Map,this._vboCaches=new Map,this._indexBufferCache=null,this._textureBufferCaches=new Map,this._output=0,this.debugBoundTechnique="",this._refCount=1,this._newCache=s.newCache,this._screen=new r(this)}configure(e){super.configure(e),this._newCache=e.newCache}destroy(){this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache=e(this._indexBufferCache),this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear(),--this._refCount>0||this.dispose()}ref(){++this._refCount}get refCount(){return this._refCount}dispose(){this.emptyTexture.dispose(),this._screen.destroy(),this._screen=null,super.dispose(),this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache?.dispose(),this._indexBufferCache=null,this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear()}get newCache(){return this._newCache}get screen(){return this._screen}getVaoCache(e){const s=JSON.stringify(e),r=this._vaoCaches.get(s);if(r)return r;const t=new a(this,e);return this._vaoCaches.set(s,t),t}getVboCache(e){const s=JSON.stringify(e),r=this._vboCaches.get(s);if(r)return r;const t=new o(this,e);return this._vboCaches.set(s,t),t}get indexBufferCache(){return this._indexBufferCache??=new i(this),this._indexBufferCache}getTextureBufferCache(e){const s=JSON.stringify(e),r=this._textureBufferCaches.get(s);if(r)return r;const t=new h(this,e);return this._textureBufferCaches.set(s,t),t}resetDrawBuffers(e){this._output=e,this.setDrawBuffers(c(this._state.drawFramebuffer))}setDrawBuffers(e){return s(this._output)?super.setDrawBuffers([n]):super.setDrawBuffers(e)}bindTechnique(e,s,r,t){return this.debugBoundTechnique=e.declaredClass,this.useProgram(e.program),this.setPipelineState(e.getPipeline(s,r)),e.program.bind(s),e.program.bindPass(s,r),t&&e.program.bindDraw(s,r,t),e.program}get isAssumedMetalDriver(){if(null==this._isAssumedMetalDriver&&(this._isAssumedMetalDriver=!!has("ios")||!!has("safari"),!this._isAssumedMetalDriver&&has("mac")&&has("chrome"))){const e=this.capabilities.rendererInfo?.getUnmaskedRenderer().toLowerCase(),s=e?.includes("apple")&&e?.includes("angle")&&e?.includes("metal");this._isAssumedMetalDriver=s??!0}return this._isAssumedMetalDriver}get test(){}}export{f as RenderingContext};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{clamp as t,lerp as e,acosClamped as s}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as c,lookAt as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as n,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as l,add as m,scale as d,lerp as _,squaredDistance as g,subtract as f,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as C,copy as j,negate as y,transformMat4 as v,set as H}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as O,transformMat4 as Q}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as L}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{CascadeCamera as S}from"./CascadeCamera.js";import{applyTextureResizeModulo as V}from"./textureUtils.js";import{assert as T,logWithBase as N,verify as F,rayRay2D as R}from"./Util.js";import{DepthStencilAttachment as W}from"../../../webgl/enums.js";class z{constructor(){this.camera=new S,this.lightMat=u()}}class A{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class I{constructor(t,e){this._fbos=t,this._viewingMode=e,this._enabled=!1,this._outputs=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new A,this._projectionView=u(),this._projectionViewInverse=u(),this._modelViewLight=u(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=L(),this._cascades=[new z,new z,new z,new z],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1}disposeOutputs(){this._handle=i(this._handle),this._outputs.forEach(t=>t?.release()),this._outputs.length=0}disposeOutput(t){this._outputs[t]=i(this._outputs[t])}set maxCascades(e){this.settings.maxNumCascadesHighQuality=t(Math.floor(e),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOutputs()}get enabled(){return this._enabled}get ready(){return!!this.getOutput(5)||!!this.getOutput(7)}get renderTarget(){return this._handle}get cascades(){for(let t=0;t<this._numCascades;++t)X[t]=this._cascades[t];return X.length=this._numCascades,X}start(t,e,s,i,a){T(this.enabled);const{near:r,far:h}=xt(s);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,e);const{viewMatrix:c,projectionMatrix:o}=t;for(let n=0;n<this._numCascades;++n)this._constructCascade(n,o,c,e);this._lastOrigin=null,this.clear()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||D(),j(this._lastOrigin,t);for(let e=0;e<this._numCascades;++e){r(Z,this._cascades[e].lightMat,t);for(let t=0;t<16;++t)$[16*e+t]=Z[t]}}return $}finish(t){T(this.enabled),this._outputs[t]?.release(),this._outputs[t]=this._handle,this._handle?.setName(6===t?"shadow map highlight":"shadow map excluding highlight"),this._handle=null}getOutput(t){return this.enabled?this._outputs[t]?.getTexture(W):null}clear(){this._ensureFbo(),this.bindFramebuffer(),this._fbos.rctx.clear(256)}_computeTextureHeight({pixelRatio:t,fullWidth:e,fullHeight:s},i,a){const r=Math.min(window.devicePixelRatio,i)/t,h=a?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return V(Math.max(e,s)*r*h,this._maxTextureWidth/this._numCascades)}_ensureFbo(){this._handle?.fbo?.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(this._textureWidth,this._textureHeight,"shadow map",13),this._handle.getTexture(W)?.setShadowFiltering(!0))}bindFramebuffer(){this._fbos.rctx.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,e,s,i){const a=this._cascades[t],c=-this._cascadeDistances[t],o=-this._cascadeDistances[t+1],n=(e[10]*c+e[14])/Math.abs(e[11]*c+e[15]),u=(e[10]*o+e[14])/Math.abs(e[11]*o+e[15]);T(n<u);for(let r=0;r<8;++r){O(q,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?n:u,1);const t=E[r];Q(t,q,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}y(K,E[0]),a.camera.viewMatrix=r(U,this._modelViewLight,K);for(let r=0;r<8;++r)v(E[r],E[r],a.camera.viewMatrix);let l=E[0][2],m=E[0][2];for(let r=1;r<8;++r)l=Math.min(l,E[r][2]),m=Math.max(m,E[r][2]);l-=200,m+=200,a.camera.near=-m,a.camera.far=-l,pt(s,i,l,m,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const d=this._textureHeight;a.camera.viewport=[t*d,0,d,d]}_setupMatrices(t,e){h(this._projectionView,t.projectionMatrix,t.viewMatrix),c(this._projectionViewInverse,this._projectionView);const s=1===this._viewingMode?t.eye:H(K,0,0,1);o(this._modelViewLight,[0,0,0],[-e[0],-e[1],-e[2]],s)}_computeCascadeDistances(t,s,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(N(s/t,4)),a);const r=(s-t)/this._numCascades,h=(s/t)**(1/this._numCascades);let c=t,o=t;for(let n=0;n<this._numCascades+1;++n)this._cascadeDistances[n]=e(c,o,this.settings.splitSchemeLambda),c*=h,o+=r}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return O(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}get test(){}}const U=u(),q=L(),E=[];for(let bt=0;bt<8;++bt)E.push(L());const P=M(),k=M(),B=M(),G=M(),J=M(),K=D(),X=[];function Y(){X.length=0}const Z=u(),$=n.concat(n,n,n),tt=M(),et=M(),st=[M(),M(),M(),M()],it=M(),at=M(),rt=M(),ht=M(),ct=M(),ot=M(),nt=M();function ut(t,e,s,i,a,r,h,c){l(tt,0,0);for(let l=0;l<4;++l)m(tt,tt,t[l]);d(tt,tt,.25),l(et,0,0);for(let l=4;l<8;++l)m(et,et,t[l]);d(et,et,.25),_(st[0],t[4],t[5],.5),_(st[1],t[5],t[6],.5),_(st[2],t[6],t[7],.5),_(st[3],t[7],t[4],.5);let o=0,n=g(st[0],tt);for(let l=1;l<4;++l){const t=g(st[l],tt);t<n&&(n=t,o=l)}f(it,st[o],t[o+4]);const u=it[0];let M,C;it[0]=-it[1],it[1]=u,f(at,et,tt),p(at,it)<0&&x(it,it),_(it,it,at,s),b(it,it),M=C=p(f(rt,t[0],tt),it);for(let l=1;l<8;++l){const e=p(f(rt,t[l],tt),it);e<M?M=e:e>C&&(C=e)}w(i,tt),d(rt,it,M-e),m(i,i,rt);let j=-1,y=1,v=0,H=0;for(let l=0;l<8;++l){f(ht,t[l],i),b(ht,ht);const e=it[0]*ht[1]-it[1]*ht[0];e>0?e>j&&(j=e,v=l):e<y&&(y=e,H=l)}F(j>0,"leftArea"),F(y<0,"rightArea"),d(ct,it,M),m(ct,ct,tt),d(ot,it,C),m(ot,ot,tt),nt[0]=-it[1],nt[1]=it[0];const D=R(i,t[H],ot,m(rt,ot,nt),1,a),O=R(i,t[v],ot,rt,1,r),Q=R(i,t[v],ct,m(rt,ct,nt),1,h),L=R(i,t[H],ct,rt,1,c);F(D,"rayRay"),F(O,"rayRay"),F(Q,"rayRay"),F(L,"rayRay")}function lt(t,e){return 3*e+t}const mt=M();function dt(t,e){return l(mt,t[e],t[e+3]),mt}const _t=M(),gt=a();function ft(t,e,s,i,a){f(_t,s,i),d(_t,_t,.5),gt[0]=_t[0],gt[1]=_t[1],gt[2]=0,gt[3]=_t[1],gt[4]=-_t[0],gt[5]=0,gt[6]=_t[0]*_t[0]+_t[1]*_t[1],gt[7]=_t[0]*_t[1]-_t[1]*_t[0],gt[8]=1,gt[lt(0,2)]=-p(dt(gt,0),t),gt[lt(1,2)]=-p(dt(gt,1),t);let r=p(dt(gt,0),s)+gt[lt(0,2)],h=p(dt(gt,1),s)+gt[lt(1,2)],c=p(dt(gt,0),i)+gt[lt(0,2)],o=p(dt(gt,1),i)+gt[lt(1,2)];r=-(r+c)/(h+o),gt[lt(0,0)]+=gt[lt(1,0)]*r,gt[lt(0,1)]+=gt[lt(1,1)]*r,gt[lt(0,2)]+=gt[lt(1,2)]*r,r=1/(p(dt(gt,0),s)+gt[lt(0,2)]),h=1/(p(dt(gt,1),s)+gt[lt(1,2)]),gt[lt(0,0)]*=r,gt[lt(0,1)]*=r,gt[lt(0,2)]*=r,gt[lt(1,0)]*=h,gt[lt(1,1)]*=h,gt[lt(1,2)]*=h,gt[lt(2,0)]=gt[lt(1,0)],gt[lt(2,1)]=gt[lt(1,1)],gt[lt(2,2)]=gt[lt(1,2)],gt[lt(1,2)]+=1,r=p(dt(gt,1),e)+gt[lt(1,2)],h=p(dt(gt,2),e)+gt[lt(2,2)],c=p(dt(gt,1),s)+gt[lt(1,2)],o=p(dt(gt,2),s)+gt[lt(2,2)],r=-.5*(r/h+c/o),gt[lt(1,0)]+=gt[lt(2,0)]*r,gt[lt(1,1)]+=gt[lt(2,1)]*r,gt[lt(1,2)]+=gt[lt(2,2)]*r,r=p(dt(gt,1),e)+gt[lt(1,2)],h=p(dt(gt,2),e)+gt[lt(2,2)],c=-h/r,gt[lt(1,0)]*=c,gt[lt(1,1)]*=c,gt[lt(1,2)]*=c,a[0]=gt[0],a[1]=gt[1],a[2]=0,a[3]=gt[2],a[4]=gt[3],a[5]=gt[4],a[6]=0,a[7]=gt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=gt[6],a[13]=gt[7],a[14]=0,a[15]=gt[8]}function pt(t,e,i,a,r){const h=1/E[0][3],c=1/E[4][3];T(h<c);let o=h+Math.sqrt(h*c);const n=Math.sin(s(t[2]*e[0]+t[6]*e[1]+t[10]*e[2]));o/=n,ut(E,o,n,P,k,B,G,J),ft(P,k,G,J,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function xt(t){let{near:e,far:s}=t;return e<2&&(e=2),s<2&&(s=2),e>=s&&(e=2,s=4),{near:e,far:s}}export{I as ShadowMap,Y as cleanupShadowmap};
2
+ import has from"../../../../core/has.js";import{clamp as t,lerp as e,acosClamped as s}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as c,lookAt as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as n,create as u}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as l,add as m,scale as d,lerp as _,squaredDistance as g,subtract as f,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as C,copy as j,negate as y,transformMat4 as v,set as H}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as O,transformMat4 as Q}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as L}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{CascadeCamera as S}from"./CascadeCamera.js";import{applyTextureResizeModulo as V}from"./textureUtils.js";import{assert as T,logWithBase as N,verify as F,rayRay2D as R}from"./Util.js";import{DepthStencilAttachment as W}from"../../../webgl/enums.js";class z{constructor(){this.camera=new S,this.lightMat=u()}}class A{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class E{constructor(t,e){this._fbos=t,this._viewingMode=e,this._enabled=!1,this._outputs=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new A,this._projectionView=u(),this._projectionViewInverse=u(),this._modelViewLight=u(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=L(),this._cascades=[new z,new z,new z,new z],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1}disposeOutputs(){this._handle=i(this._handle),this._outputs.forEach(t=>t?.release()),this._outputs.length=0}disposeOutput(t){this._outputs[t]=i(this._outputs[t])}set maxCascades(e){this.settings.maxNumCascadesHighQuality=t(Math.floor(e),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOutputs()}get enabled(){return this._enabled}get ready(){return!!this.getOutput(5)||!!this.getOutput(7)}get renderTarget(){return this._handle}get cascades(){for(let t=0;t<this._numCascades;++t)X[t]=this._cascades[t];return X.length=this._numCascades,X}start(t,e,s,i,a){T(this.enabled);const{near:r,far:h}=xt(s);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,e);for(let c=0;c<this._numCascades;++c)this._constructCascade(c,t,e);this._lastOrigin=null,this.clear()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||D(),j(this._lastOrigin,t);for(let e=0;e<this._numCascades;++e){r(Z,this._cascades[e].lightMat,t);for(let t=0;t<16;++t)$[16*e+t]=Z[t]}}return $}finish(t){T(this.enabled),this._outputs[t]?.release(),this._outputs[t]=this._handle,this._handle?.setName(6===t?"shadow map highlight":"shadow map excluding highlight"),this._handle=null}getOutput(t){return this.enabled?this._outputs[t]?.getTexture(W):null}clear(){this._ensureFbo(),this.bindFramebuffer(),this._fbos.rctx.clear(256)}_computeTextureHeight({pixelRatio:t,fullWidth:e,fullHeight:s},i,a){const r=Math.min(window.devicePixelRatio,i)/t,h=a?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return V(Math.max(e,s)*r*h,this._maxTextureWidth/this._numCascades)}_ensureFbo(){this._handle?.fbo?.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(this._textureWidth,this._textureHeight,"shadow map",13),this._handle.getTexture(W)?.setShadowFiltering(!0))}bindFramebuffer(){this._fbos.rctx.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,e,s){const{viewMatrix:i,projectionMatrix:a,relativeElevation:c}=e,o=this._cascades[t],n=-this._cascadeDistances[t],u=-this._cascadeDistances[t+1],l=(a[10]*n+a[14])/Math.abs(a[11]*n+a[15]),m=(a[10]*u+a[14])/Math.abs(a[11]*u+a[15]);T(l<m);for(let r=0;r<8;++r){O(U,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?l:m,1);const t=q[r];Q(t,U,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}y(K,q[0]),o.camera.viewMatrix=r(I,this._modelViewLight,K);for(let r=0;r<8;++r)v(q[r],q[r],o.camera.viewMatrix);let d=q[0][2],_=q[0][2];for(let r=1;r<8;++r)d=Math.min(d,q[r][2]),_=Math.max(_,q[r][2]);d-=200,_+=200,o.camera.near=-_,o.camera.far=-d,o.camera.relativeElevation=c,pt(i,s,d,_,o.camera),h(o.lightMat,o.camera.projectionMatrix,o.camera.viewMatrix);const g=this._textureHeight;o.camera.viewport=[t*g,0,g,g]}_setupMatrices(t,e){h(this._projectionView,t.projectionMatrix,t.viewMatrix),c(this._projectionViewInverse,this._projectionView);const s=1===this._viewingMode?t.eye:H(K,0,0,1);o(this._modelViewLight,[0,0,0],[-e[0],-e[1],-e[2]],s)}_computeCascadeDistances(t,s,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(N(s/t,4)),a);const r=(s-t)/this._numCascades,h=(s/t)**(1/this._numCascades);let c=t,o=t;for(let n=0;n<this._numCascades+1;++n)this._cascadeDistances[n]=e(c,o,this.settings.splitSchemeLambda),c*=h,o+=r}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return O(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}get test(){}}const I=u(),U=L(),q=[];for(let bt=0;bt<8;++bt)q.push(L());const P=M(),k=M(),B=M(),G=M(),J=M(),K=D(),X=[];function Y(){X.length=0}const Z=u(),$=n.concat(n,n,n),tt=M(),et=M(),st=[M(),M(),M(),M()],it=M(),at=M(),rt=M(),ht=M(),ct=M(),ot=M(),nt=M();function ut(t,e,s,i,a,r,h,c){l(tt,0,0);for(let l=0;l<4;++l)m(tt,tt,t[l]);d(tt,tt,.25),l(et,0,0);for(let l=4;l<8;++l)m(et,et,t[l]);d(et,et,.25),_(st[0],t[4],t[5],.5),_(st[1],t[5],t[6],.5),_(st[2],t[6],t[7],.5),_(st[3],t[7],t[4],.5);let o=0,n=g(st[0],tt);for(let l=1;l<4;++l){const t=g(st[l],tt);t<n&&(n=t,o=l)}f(it,st[o],t[o+4]);const u=it[0];let M,C;it[0]=-it[1],it[1]=u,f(at,et,tt),p(at,it)<0&&x(it,it),_(it,it,at,s),b(it,it),M=C=p(f(rt,t[0],tt),it);for(let l=1;l<8;++l){const e=p(f(rt,t[l],tt),it);e<M?M=e:e>C&&(C=e)}w(i,tt),d(rt,it,M-e),m(i,i,rt);let j=-1,y=1,v=0,H=0;for(let l=0;l<8;++l){f(ht,t[l],i),b(ht,ht);const e=it[0]*ht[1]-it[1]*ht[0];e>0?e>j&&(j=e,v=l):e<y&&(y=e,H=l)}F(j>0,"leftArea"),F(y<0,"rightArea"),d(ct,it,M),m(ct,ct,tt),d(ot,it,C),m(ot,ot,tt),nt[0]=-it[1],nt[1]=it[0];const D=R(i,t[H],ot,m(rt,ot,nt),1,a),O=R(i,t[v],ot,rt,1,r),Q=R(i,t[v],ct,m(rt,ct,nt),1,h),L=R(i,t[H],ct,rt,1,c);F(D,"rayRay"),F(O,"rayRay"),F(Q,"rayRay"),F(L,"rayRay")}function lt(t,e){return 3*e+t}const mt=M();function dt(t,e){return l(mt,t[e],t[e+3]),mt}const _t=M(),gt=a();function ft(t,e,s,i,a){f(_t,s,i),d(_t,_t,.5),gt[0]=_t[0],gt[1]=_t[1],gt[2]=0,gt[3]=_t[1],gt[4]=-_t[0],gt[5]=0,gt[6]=_t[0]*_t[0]+_t[1]*_t[1],gt[7]=_t[0]*_t[1]-_t[1]*_t[0],gt[8]=1,gt[lt(0,2)]=-p(dt(gt,0),t),gt[lt(1,2)]=-p(dt(gt,1),t);let r=p(dt(gt,0),s)+gt[lt(0,2)],h=p(dt(gt,1),s)+gt[lt(1,2)],c=p(dt(gt,0),i)+gt[lt(0,2)],o=p(dt(gt,1),i)+gt[lt(1,2)];r=-(r+c)/(h+o),gt[lt(0,0)]+=gt[lt(1,0)]*r,gt[lt(0,1)]+=gt[lt(1,1)]*r,gt[lt(0,2)]+=gt[lt(1,2)]*r,r=1/(p(dt(gt,0),s)+gt[lt(0,2)]),h=1/(p(dt(gt,1),s)+gt[lt(1,2)]),gt[lt(0,0)]*=r,gt[lt(0,1)]*=r,gt[lt(0,2)]*=r,gt[lt(1,0)]*=h,gt[lt(1,1)]*=h,gt[lt(1,2)]*=h,gt[lt(2,0)]=gt[lt(1,0)],gt[lt(2,1)]=gt[lt(1,1)],gt[lt(2,2)]=gt[lt(1,2)],gt[lt(1,2)]+=1,r=p(dt(gt,1),e)+gt[lt(1,2)],h=p(dt(gt,2),e)+gt[lt(2,2)],c=p(dt(gt,1),s)+gt[lt(1,2)],o=p(dt(gt,2),s)+gt[lt(2,2)],r=-.5*(r/h+c/o),gt[lt(1,0)]+=gt[lt(2,0)]*r,gt[lt(1,1)]+=gt[lt(2,1)]*r,gt[lt(1,2)]+=gt[lt(2,2)]*r,r=p(dt(gt,1),e)+gt[lt(1,2)],h=p(dt(gt,2),e)+gt[lt(2,2)],c=-h/r,gt[lt(1,0)]*=c,gt[lt(1,1)]*=c,gt[lt(1,2)]*=c,a[0]=gt[0],a[1]=gt[1],a[2]=0,a[3]=gt[2],a[4]=gt[3],a[5]=gt[4],a[6]=0,a[7]=gt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=gt[6],a[13]=gt[7],a[14]=0,a[15]=gt[8]}function pt(t,e,i,a,r){const h=1/q[0][3],c=1/q[4][3];T(h<c);let o=h+Math.sqrt(h*c);const n=Math.sin(s(t[2]*e[0]+t[6]*e[1]+t[10]*e[2]));o/=n,ut(q,o,n,P,k,B,G,J),ft(P,k,G,J,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}function xt(t){let{near:e,far:s}=t;return e<2&&(e=2),s<2&&(s=2),e>=s&&(e=2,s=4),{near:e,far:s}}export{E as ShadowMap,Y as cleanupShadowmap};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{watch as r,initial as a,when as o,sync as n}from"../../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../../core/accessorSupport/decorators.js";import{translate as c,fromTranslation as p,scale as l,mul as w}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as f,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v,fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Sphere as _}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as V}from"../../webgl.js";import b from"../../webgl/RenderNode.js";import{ViewshedShadowMap as M}from"./ViewshedShadowMap.js";import{V as S}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as y}from"../shaders/ViewshedTechnique.js";import{ColorAttachment0 as j}from"../../../webgl/enums.js";let x=class extends b{get shadowMap(){return this._shadowMap}get hasViewsheds(){return this._viewsheds.length>0}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>P(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new S,this._viewsheds=new s,this._shadowMap=null,this.consumes={required:[V.VIEWSHED,"normals"]},this.produces=V.VIEWSHED}initialize(){this._shadowMap=new M(this.fboCache),this.addHandles([r(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},a),o(()=>!this.hasViewsheds,()=>this._shadowMap?.dispose()),r(()=>this._viewshedsInView.map(e=>[e.elevationAlignedObserverRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=i(this._shadowMap)}precompile(){if(this.hasViewsheds)for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}render(e){const s=this.bindParameters,t=this.renderingContext,i=e.find(({name:e})=>e===V.VIEWSHED);if(!this.hasViewsheds||this.isDecoration&&!s.decorations)return i;const r=this.techniques.getCompiled(y);if(!r)return this.requestRender(1),i;const a=this.view.stage.renderer.isFeatureEnabled(6);this._passParameters.shadowMap=this._shadowMap??this._passParameters.shadowMap,this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();const o=i.obtainDepthTexture();for(const n of this._viewshedsInView){if(!this._renderShadowCubeMap(s,n,a)||!this._shadowMap?.ready)continue;const e=this._setupViewshedParameters(n,s.camera);t.bindFramebuffer(i.fbo),t.bindTechnique(r,s,e),t.setDrawBuffers([j]),t.screen.draw()}return this.shadowMap?.dispose(),i.attachDepth(o),o?.release(),i}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:i}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),i)if(Array.isArray(i)){const e=i.filter(e=>!s.includes(e));s.addMany(e)}else s.includes(i)||s.add(i)}_renderShadowCubeMap(e,s,t){const i=this._shadowMap;if(!i)return!1;const r=this.view.basemapTerrain.hasStencilEnabledExtents,a=i.start(e.camera,s,t,this._contentPixelRatio,r);return a&&i.faces.forEach(e=>this.view.stage.renderer.renderViewshedShadowMap(e)),i.finish(),a}_setupViewshedParameters(e,s){const i=this._shadowMap;if(!i)return this._passParameters;const r=this._passParameters,a=e.effectiveObserverRenderSpace;r.localOrigin=a,r.observerOffset=f(D,e.elevationAlignedObserverRenderSpace,e.effectiveObserverRenderSpace),r.fovs=[t(e.horizontalFieldOfView),t(e.verticalFieldOfView)],r.headingAndTilt=[t(e.heading),t(e.tiltParallelToSurface)],r.upVector=e.tiltedUpVector;const o=A(e.elevationAlignedTargetRenderSpace,a);r.targetVector=o;const n=new Array,h=new Array;for(let t=0;t<i.numActiveFaces;t++)c(E,i.viewshedViewMatrices[t],a),n.push(...E),R(i.viewshedProjectionMatrices[t],E,I),h.push(...I);return r.viewMatrices=n,r.projectionMatrices=h,r.volumeOffset=this.selectedViewshed?.()===e.viewshed?O(e,this.view,s.eye):0,r}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function A(e,s){const t=v();return f(t,e,s)}function R(e,s,t){const i=g(.5,.5,.5);return p(t,i),l(t,t,i),w(t,t,e),w(t,t,s),t}function P(e,s){const t=new _(s.elevationAlignedObserverRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function O(e,s,t){if(null==e)return 0;const{elevationAlignedObserverRenderSpace:i,elevationAlignedTargetRenderSpace:r}=e,a=u(t,i)>u(t,r)?e.observer:e.target;return s.pixelSizeAt(a)}e([h()],x.prototype,"selectedViewshed",void 0),e([h()],x.prototype,"isDecoration",void 0),e([h()],x.prototype,"shadowMap",null),e([h()],x.prototype,"hasViewsheds",null),e([h()],x.prototype,"_contentPixelRatio",null),e([h()],x.prototype,"_viewshedsInView",null),e([h()],x.prototype,"consumes",void 0),e([h()],x.prototype,"produces",void 0),x=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],x);const D=v(),E=m(),I=m();export{x as Viewshed,O as computeOffsetScale};
2
+ import{__decorate as e}from"tslib";import s from"../../../../core/Collection.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{watch as i,initial as a,when as o,sync as n}from"../../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../../core/accessorSupport/decorators.js";import{translate as c,fromTranslation as l,scale as p,mul as w}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{sub as u,distance as v}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Sphere as _}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as V}from"../../webgl.js";import b from"../../webgl/RenderNode.js";import{ViewshedShadowMap as M}from"./ViewshedShadowMap.js";import{V as y,a as S}from"../../../../chunks/Viewshed.glsl.js";import{ViewshedTechnique as j}from"../shaders/ViewshedTechnique.js";import{ColorAttachment0 as P}from"../../../webgl/enums.js";let x=class extends b{get hasViewsheds(){return this._viewsheds.length>0}get shadowMap(){return this._shadowMap}get _contentPixelRatio(){return this.view.state.contentPixelRatio}get _viewshedsInView(){return this._viewsheds.items.filter(e=>R(this.view,e))}constructor(e){super(e),this.isDecoration=!1,this._passParameters=new y,this._drawParameters=new S,this._viewsheds=new s,this.consumes={required:[V.VIEWSHED,"normals"]},this.produces=V.VIEWSHED}initialize(){this._shadowMap=new M(this.fboCache),this.addHandles([i(()=>this.view.resolutionScale,e=>{const s=this._shadowMap;s&&(s.settings.textureSizeQuality=e)},a),o(()=>!this.hasViewsheds,()=>this._shadowMap?.releaseFBO()),i(()=>this._viewshedsInView.map(e=>[e.elevationAlignedObserverRenderSpace,e.heading,e.tilt,e.farDistance,e.horizontalFieldOfView,e.verticalFieldOfView]),()=>this.requestRender(1),n)])}destroy(){this._shadowMap=r(this._shadowMap)}precompile(){if(this.hasViewsheds)for(const e of this._viewshedsInView)if(this._shadowMap?.isActive(e))return void this.view.stage.renderer.precompileViewshedShadowMap()}render(e){const s=this.bindParameters,t=this.input;if(!this.hasViewsheds||this.isDecoration&&!s.decorations)return t;const r=this.techniques.getCompiled(j);if(!r)return this.requestRender(1),t;const i=this.renderingContext,a=this.view.stage.renderer.isFeatureEnabled(6);this._passParameters.normals=e.find(({name:e})=>"normals"===e)?.getTexture();const o=t.obtainDepthTexture();for(const n of this._viewshedsInView)this._drawParameters.shadowMap=this._renderShadowMap(s,n,a),this._drawParameters.shadowMap&&(this._setupViewshedParameters(n,s.camera),i.bindFramebuffer(t.fbo),i.bindTechnique(r,s,this._passParameters,this._drawParameters),i.setDrawBuffers([P]),i.screen.draw());return this.shadowMap?.releaseFBO(),t.attachDepth(o),o?.release(),t}updateViewsheds(e){const s=this._viewsheds,{removes:t,adds:r}=e;if(t&&(Array.isArray(t)?s.removeMany(t):s.remove(t)),r)if(Array.isArray(r)){const e=r.filter(e=>!s.includes(e));s.addMany(e)}else s.includes(r)||s.add(r)}_renderShadowMap(e,s,t){const r=this._shadowMap;if(!r)return null;const i=this.view.basemapTerrain.hasStencilEnabledExtents,a=r.start(e.camera,s,t,this._contentPixelRatio,i);return a&&r.faces.forEach(e=>this.view.stage.renderer.renderViewshedShadowMap(e)),r.finish(),a&&r.ready?r:null}_setupViewshedParameters(e,s){const r=this._drawParameters,i=e.effectiveObserverRenderSpace;r.localOrigin=i,u(r.observerOffset,e.elevationAlignedObserverRenderSpace,e.effectiveObserverRenderSpace),f(r.fovs,t(e.horizontalFieldOfView),t(e.verticalFieldOfView)),f(r.headingAndTilt,t(e.heading),t(e.tiltParallelToSurface)),r.upVector=e.tiltedUpVector,A(r.targetVector,e.elevationAlignedTargetRenderSpace,i);const a=this._drawParameters.shadowMap;if(!a)return;const o=new Array,n=new Array;for(let t=0;t<a.numActiveFaces;t++)c(F,a.viewshedViewMatrices[t],i),o.push(...F),O(a.viewshedProjectionMatrices[t],F,I),n.push(...I);r.viewMatrices=o,r.projectionMatrices=n,r.volumeOffset=this.selectedViewshed()===e.viewshed?D(e,this.view,s.eye):0}get test(){return{viewsheds:this._viewsheds,shadowMap:this._shadowMap,viewshedsInView:this._viewshedsInView}}};function A(e,s,t){return u(e,s,t)}function O(e,s,t){const r=g(.5,.5,.5);return l(t,r),p(t,t,r),w(t,t,e),w(t,t,s),t}function R(e,s){const t=new _(s.elevationAlignedObserverRenderSpace,s.farDistanceRenderSpace);return!!e.ready&&e.frustum.intersectsSphere(t)}function D(e,s,t){if(null==e)return 0;const{elevationAlignedObserverRenderSpace:r,elevationAlignedTargetRenderSpace:i}=e,a=v(t,r)>v(t,i)?e.observer:e.target;return s.pixelSizeAt(a)}e([h({constructOnly:!0})],x.prototype,"selectedViewshed",void 0),e([h()],x.prototype,"isDecoration",void 0),e([h()],x.prototype,"hasViewsheds",null),e([h()],x.prototype,"_contentPixelRatio",null),e([h()],x.prototype,"_viewshedsInView",null),e([h()],x.prototype,"consumes",void 0),e([h()],x.prototype,"produces",void 0),x=e([d("esri.views.3d.webgl-engine.lib.Viewshed")],x);const F=m(),I=m();export{x as Viewshed,D as computeOffsetScale};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{clamp as t}from"../../../../core/mathUtils.js";import{releaseMaybe as e}from"../../../../core/maybe.js";import{fromRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as r,add as o,negate as a,transformMat4 as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{applyTextureResizeModulo as n}from"./textureUtils.js";import{ViewshedFaceCamera as l}from"./ViewshedFaceCamera.js";import{DepthStencilAttachment as u,SizedDepthFormat as m}from"../../../webgl/enums.js";import{isSizedDepthStencilFormat as f}from"../../../webgl/textureUtils.js";class d{constructor(){this.textureSizeQuality=1,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.textureSizeMultiple=128,this.toleranceSides=5,this.toleranceBottomTop=10}textureSizeModifier(t){const e=t?this.textureSizeModHighQuality:this.textureSizeModLowQuality;return this.textureSizeQuality*e}textureResizeModulo(t){return Math.ceil(t/this.textureSizeMultiple)*this.textureSizeMultiple}}const p=["front","left","right","back","top","bottom"];function g(t){return!["top","bottom"].includes(t)}class x{constructor(t){this._fbos=t,this._faces={},this._width=0,this._height=0,this.settings=new d,this._maxTextureSize=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}get depthTexture(){return this._handle?.getTexture(u)}get ready(){return null!=this.depthTexture&&0!==this._width&&0!==this._height}get nearFar(){const t=this.faces;return 0===t.length?null:t[0].nearFar}get numActiveFaces(){const t=this._faces;let e=0;return Object.keys(t).forEach(i=>{t[i]&&(e+=1)}),e}get faces(){const t=this._faces,e=[];for(const i of p){const s=t[i];s&&e.push(s)}return e}get atlasRegions(){return this.faces.map(t=>[t.x/this._width,(t.x+t.width)/this._width,t.y/this._height,(t.y+t.height)/this._height])}get viewshedProjectionMatrices(){return this.faces.map(t=>t.projectionMatrix)}get viewshedViewMatrices(){return this.faces.map(t=>t.viewMatrix)}_setupFaceCamera(e,n,u,m){const{effectiveObserverRenderSpace:f,effectiveTargetRenderSpace:d,tiltedUpVector:p,farDistanceRenderSpace:x,horizontalFieldOfView:_,verticalFieldOfView:b}=n,w=c();r(w,d,f);const M=c(),S=c(),F=(t,e)=>{const r=c(),a=s();return i(a,t,e),h(r,w,a),o(r,f,r),r};let z,T=p;const v=Math.min(90,_),O=Math.min(90,Math.max(0,(_-90)/2));let j=-45,B=45,y=-45,k=45;if(g(e)){const e=e=>t(e,-45,45);y=e(-b/2)-this.settings.toleranceBottomTop,k=e(+b/2)+this.settings.toleranceBottomTop}switch(e){case"front":z=d,j=-v/2,B=v/2;break;case"left":z=F(Math.PI/2,p),j=45-O;break;case"right":z=F(-Math.PI/2,p),B=-45+O;break;case"top":z=o(M,f,p),T=a(S,w);break;case"bottom":z=r(M,f,p),T=w;break;case"back":z=F(Math.PI,p)}const V=new l({center:z,eye:f,up:T,far:x});V.sectionAnglesDeg=[j-this.settings.toleranceSides,B+this.settings.toleranceSides,y,k],V.fovY=Math.PI/2;const P=V.setViewport(u,m);return this._faces[e]=V,P}isActive(t){return this._computeActiveFaces(t).size>0}_computeActiveFaces(t){const e=new Set,{horizontalFieldOfView:i,verticalFieldOfView:s}=t,r=-s/2,o=s/2;return 0===i||0===s||(r<=45&&o>=-45&&e.add("front"),i>90&&(e.add("left"),e.add("right")),i>270&&e.add("back"),o>45-this.settings.toleranceBottomTop&&e.add("top"),r<-45+this.settings.toleranceBottomTop&&e.add("bottom")),e}_computeBaseTextureSize({pixelRatio:t,fullWidth:e,fullHeight:i},s,r,o){const a=s/t,h=this.settings.textureSizeModifier(r);return n(Math.max(e,i)*a*h,this._maxTextureSize/o)}_ensureFBO(t){const e=this._width,i=this._height,s=this._handle?.fbo;s&&s.width===e&&s.height===i&&t===f(s.depthStencilTexture?.descriptor?.internalFormat??m.DEPTH_COMPONENT16)||(this._handle?.release(),this._handle=this._allocateFBO(t))}_allocateFBO(t){const{_width:e,_height:i}=this,s=t?14:13,r=this._fbos.acquire(e,i,"viewshed shadow map",s);return r.getTexture(u)?.setShadowFiltering(!1),r}clearFBO(t){const e=this._fbos.rctx;this._ensureFBO(t),e.bindFramebuffer(this._handle?.fbo),e.setClearColor(1,1,1,1),e.clear(16640)}dispose(){this._debugFBO||(this._handle=e(this._handle))}start(t,e,i,s,r=!1){this._faces={};const o=this._computeActiveFaces(e),a=o.size;if(0===a)return!1;const h=this._computeBaseTextureSize(t,s,i,a);let c=0,n=0,l=0;return p.filter(t=>o.has(t)).forEach(t=>{const i=_(t,a);i>n&&(l=Math.max(l,c),c=0),n=i;const s=i*h;c+=this._setupFaceCamera(t,e,[c,s],h)}),l=Math.max(l,c),this._width=this.settings.textureResizeModulo(l),this._height=b(a)*h,this.clearFBO(r),!0}finish(){}get test(){}}function _(t,e){if(e<4)return 0;const i="front"===t||"left"===t;return 4===e?i?0:1:i||"right"===t?0:1}function b(t){return t<4?1:2}export{x as ViewshedShadowMap};
2
+ import has from"../../../../core/has.js";import{clamp as t}from"../../../../core/mathUtils.js";import{releaseMaybe as e}from"../../../../core/maybe.js";import{fromRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as r,add as o,negate as a,transformMat4 as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{applyTextureResizeModulo as n}from"./textureUtils.js";import{ViewshedFaceCamera as l}from"./ViewshedFaceCamera.js";import{DepthStencilAttachment as u,SizedDepthFormat as f}from"../../../webgl/enums.js";import{isSizedDepthStencilFormat as m}from"../../../webgl/textureUtils.js";class d{constructor(){this.textureSizeQuality=1,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.textureSizeMultiple=128,this.toleranceSides=5,this.toleranceBottomTop=10}textureSizeModifier(t){const e=t?this.textureSizeModHighQuality:this.textureSizeModLowQuality;return this.textureSizeQuality*e}textureResizeModulo(t){return Math.ceil(t/this.textureSizeMultiple)*this.textureSizeMultiple}}const p=["front","left","right","back","top","bottom"];function g(t){return!["top","bottom"].includes(t)}class _{constructor(t){this._fbos=t,this._faces={},this._width=0,this._height=0,this.settings=new d,this._maxTextureSize=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}get depthTexture(){return this._fbo?.getTexture(u)}get ready(){return null!=this.depthTexture&&0!==this._width&&0!==this._height}get nearFar(){const t=this.faces;return 0===t.length?null:t[0].nearFar}get numActiveFaces(){const t=this._faces;let e=0;return Object.keys(t).forEach(i=>{t[i]&&(e+=1)}),e}get faces(){const t=this._faces,e=[];for(const i of p){const s=t[i];s&&e.push(s)}return e}get atlasRegions(){return this.faces.map(t=>[t.x/this._width,(t.x+t.width)/this._width,t.y/this._height,(t.y+t.height)/this._height])}get viewshedProjectionMatrices(){return this.faces.map(t=>t.projectionMatrix)}get viewshedViewMatrices(){return this.faces.map(t=>t.viewMatrix)}_setupFaceCamera(e,n,u,f){const{effectiveObserverRenderSpace:m,effectiveTargetRenderSpace:d,tiltedUpVector:p,farDistanceRenderSpace:_,horizontalFieldOfView:x,verticalFieldOfView:b}=n,w=c();r(w,d,m);const M=c(),S=c(),F=(t,e)=>{const r=c(),a=s();return i(a,t,e),h(r,w,a),o(r,m,r),r};let z,T=p;const v=Math.min(90,x),O=Math.min(90,Math.max(0,(x-90)/2));let B=-45,j=45,y=-45,k=45;if(g(e)){const e=e=>t(e,-45,45);y=e(-b/2)-this.settings.toleranceBottomTop,k=e(+b/2)+this.settings.toleranceBottomTop}switch(e){case"front":z=d,B=-v/2,j=v/2;break;case"left":z=F(Math.PI/2,p),B=45-O;break;case"right":z=F(-Math.PI/2,p),j=-45+O;break;case"top":z=o(M,m,p),T=a(S,w);break;case"bottom":z=r(M,m,p),T=w;break;case"back":z=F(Math.PI,p)}const V=new l({center:z,eye:m,up:T,far:_});V.sectionAnglesDeg=[B-this.settings.toleranceSides,j+this.settings.toleranceSides,y,k],V.fovY=Math.PI/2;const P=V.setViewport(u,f);return this._faces[e]=V,P}isActive(t){return this._computeActiveFaces(t).size>0}_computeActiveFaces(t){const e=new Set,{horizontalFieldOfView:i,verticalFieldOfView:s}=t,r=-s/2,o=s/2;return 0===i||0===s||(r<=45&&o>=-45&&e.add("front"),i>90&&(e.add("left"),e.add("right")),i>270&&e.add("back"),o>45-this.settings.toleranceBottomTop&&e.add("top"),r<-45+this.settings.toleranceBottomTop&&e.add("bottom")),e}_computeBaseTextureSize({pixelRatio:t,fullWidth:e,fullHeight:i},s,r,o){const a=s/t,h=this.settings.textureSizeModifier(r);return n(Math.max(e,i)*a*h,this._maxTextureSize/o)}_ensureFBO(t){const e=this._width,i=this._height,s=this._fbo?.fbo;s&&s.width===e&&s.height===i&&t===m(s.depthStencilTexture?.descriptor?.internalFormat??f.DEPTH_COMPONENT16)||(this._fbo?.release(),this._fbo=this._allocateFBO(t))}_allocateFBO(t){const{_width:e,_height:i}=this,s=t?14:13,r=this._fbos.acquire(e,i,"viewshed shadow map",s);return r.getTexture(u)?.setShadowFiltering(!1),r}clearFBO(t){const e=this._fbos.rctx;this._ensureFBO(t),e.bindFramebuffer(this._fbo?.fbo),e.setClearColor(1,1,1,1),e.clear(16640)}dispose(){this._fbo=e(this._fbo)}releaseFBO(){this._debugFBO||(this._fbo=e(this._fbo))}start(t,e,i,s,r=!1){this._faces={};const o=this._computeActiveFaces(e),a=o.size;if(0===a)return!1;const h=this._computeBaseTextureSize(t,s,i,a);let c=0,n=0,l=0;return p.filter(t=>o.has(t)).forEach(t=>{const i=x(t,a);i>n&&(l=Math.max(l,c),c=0),n=i;const s=i*h;c+=this._setupFaceCamera(t,e,[c,s],h)}),l=Math.max(l,c),this._width=this.settings.textureResizeModulo(l),this._height=b(a)*h,this.clearFBO(r),!0}finish(){}get test(){}}function x(t,e){if(e<4)return 0;const i="front"===t||"left"===t;return 4===e?i?0:1:i||"right"===t?0:1}function b(t){return t<4?1:2}export{_ as ViewshedShadowMap};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{set as t,add as e,scale as r,dist as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{areaPoints3d as i}from"../../../../geometry/support/triangle.js";function s(n,o,s=o?.indices){if(!o||!s)return!1;const{size:c,data:f}=o;t(n,0,0,0),t(u,0,0,0);let g=0,d=0;for(let p=0;p<s.length-2;p+=3){const o=s[p]*c,h=s[p+1]*c,j=s[p+2]*c;t(l,f[o],f[o+1],f[o+2]),t(a,f[h],f[h+1],f[h+2]),t(m,f[j],f[j+1],f[j+2]);const x=i(l,a,m);x?(e(l,l,a),e(l,l,m),r(l,l,1/3*x),e(n,n,l),g+=x):(e(u,u,l),e(u,u,a),e(u,u,m),d+=3)}return(0!==d||0!==g)&&(0!==g?(r(n,n,1/g),!0):0!==d&&(r(n,u,1/d),!0))}function c(e,n,o=n?.indices){if(!n||!o)return!1;const{size:i,data:s}=n;t(e,0,0,0);let c=-1,f=0;for(let t=0;t<o.length;t++){const r=o[t]*i;c!==r&&(e[0]+=s[r],e[1]+=s[r+1],e[2]+=s[r+2],f++),c=r}return f>1&&r(e,e,1/f),f>0}function f(o,i,s,c=i?.indices){if(!i||!c)return!1;t(o,0,0,0),t(u,0,0,0);let f=0,m=0;const{size:g,data:d}=i,p=c.length-1,h=p+(s?2:0);for(let t=0;t<h;t+=2){const i=t<p?t+1:0,s=c[t<p?t:p]*g,h=c[i]*g;l[0]=d[s],l[1]=d[s+1],l[2]=d[s+2],a[0]=d[h],a[1]=d[h+1],a[2]=d[h+2],r(l,e(l,l,a),.5);const j=n(l,a);j>0?(e(o,o,r(l,l,j)),f+=j):0===f&&(e(u,u,l),m++)}return 0!==f?(r(o,o,1/f),!0):0!==m&&(r(o,u,1/m),!0)}const l=o(),a=o(),m=o(),u=o();export{f as computeAttachmentOriginLines,c as computeAttachmentOriginPoints,s as computeAttachmentOriginTriangles};
2
+ import{set as t,add as e,scale as r,dist as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{area3dFromValues as i}from"../../../../geometry/support/triangle.js";function s(n,o,s=o?.indices){if(!o||!s)return!1;const{size:c,data:f}=o;t(n,0,0,0),t(u,0,0,0);let g=0,d=0;for(let p=0;p<s.length-2;p+=3){const o=s[p]*c,h=s[p+1]*c,j=s[p+2]*c;t(l,f[o],f[o+1],f[o+2]),t(a,f[h],f[h+1],f[h+2]),t(m,f[j],f[j+1],f[j+2]);const x=i(l,a,m);x?(e(l,l,a),e(l,l,m),r(l,l,1/3*x),e(n,n,l),g+=x):(e(u,u,l),e(u,u,a),e(u,u,m),d+=3)}return(0!==d||0!==g)&&(0!==g?(r(n,n,1/g),!0):0!==d&&(r(n,u,1/d),!0))}function c(e,n,o=n?.indices){if(!n||!o)return!1;const{size:i,data:s}=n;t(e,0,0,0);let c=-1,f=0;for(let t=0;t<o.length;t++){const r=o[t]*i;c!==r&&(e[0]+=s[r],e[1]+=s[r+1],e[2]+=s[r+2],f++),c=r}return f>1&&r(e,e,1/f),f>0}function f(o,i,s,c=i?.indices){if(!i||!c)return!1;t(o,0,0,0),t(u,0,0,0);let f=0,m=0;const{size:g,data:d}=i,p=c.length-1,h=p+(s?2:0);for(let t=0;t<h;t+=2){const i=t<p?t+1:0,s=c[t<p?t:p]*g,h=c[i]*g;l[0]=d[s],l[1]=d[s+1],l[2]=d[s+2],a[0]=d[h],a[1]=d[h+1],a[2]=d[h+2],r(l,e(l,l,a),.5);const j=n(l,a);j>0?(e(o,o,r(l,l,j)),f+=j):0===f&&(e(u,u,l),m++)}return 0!==f?(r(o,o,1/f),!0):0!==m&&(r(o,u,1/m),!0)}const l=o(),a=o(),m=o(),u=o();export{f as computeAttachmentOriginLines,c as computeAttachmentOriginPoints,s as computeAttachmentOriginTriangles};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ const e=1e3;export{e as boundingInfoSubdivisionThreshold};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{createScreenPointArray as t,createRenderScreenPointArray3 as n}from"../../../../core/screenUtils.js";import{transformMat4 as r,copy as e,distance as o,set as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as s,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,empty as f,expandPointInPlace as a,clone as p,containsPoint as l,intersects as m,fromValues as h}from"../../../../geometry/support/aaBoundingRect.js";import{create as d,distance2 as g,fromPoints as M}from"../../../../geometry/support/lineSegment.js";import{signedDistance as b,intersectLineSegment as j}from"../../../../geometry/support/plane.js";import{containsPoint2dFromValues as x}from"../../../../geometry/support/triangle.js";class I{constructor(t,n,r){this.bounds=t,this.nearestDistance=n,this.nearestPoint=r}}function N(t,n){return t.isRectangle?l(t.bounds,n):O(n,t.points)}function T(t,n){if(!m(t.bounds,n))return!1;if(t.isRectangle)return!0;for(const r of t.points)if(l(n,r))return!0;for(let r=0;r<4;r++)if(O(k(z,n,r),t.points))return!0;for(let r=0;r<t.points.length;r++){const e=t.points[r],o=r===t.points.length-1?t.points[0]:t.points[r+1];for(let t=0;t<4;t++){if(V(e,o,k(z,n,t),k(A,n,(t+1)%4)))return!0}}return!1}function S(t,n,r,e){const o=Math.min(n[0],r[0],e[0]),i=Math.min(n[1],r[1],e[1]),s=Math.max(n[0],r[0],e[0]),c=Math.max(n[1],r[1],e[1]);if(!T(t,h(o,i,s,c,q)))return!1;if(N(t,n)||N(t,r)||N(t,e))return!0;for(const u of t.points)if(x(n,r,e,u,nt))return!0;for(let u=0;u<t.points.length;u++){const o=t.points[u],i=t.points[(u+1)%t.points.length];if(V(n,r,o,i)||V(r,e,o,i)||V(e,n,o,i))return!0}return!1}function R(t,n,r,e){const o=Math.min(n[0],r[0])-e,i=Math.min(n[1],r[1])-e,s=Math.max(n[0],r[0])+e,c=Math.max(n[1],r[1])+e;if(!m(t.bounds,h(o,i,s,c,q)))return!1;if(N(t,n)||N(t,r))return!0;const u=e*e;for(const f of t.points)if(B(f,n,r)<=u)return!0;for(let f=0;f<t.points.length;f++){const e=t.points[f],o=t.points[(f+1)%t.points.length];if(V(n,r,e,o)||Y(n,r,e,o)<=u)return!0}return!1}function y(t,n,r){return _(t,n.bbMin,n.bbMax,r)}function _(t,n,o,i){const c=f(q);tt.reset(t.eye);let u=0;for(let s=0;s<2;s++)for(let f=0;f<2;f++)for(let p=0;p<2;p++)J[0]=0===s?n[0]:o[0],J[1]=0===f?n[1]:o[1],J[2]=0===p?n[2]:o[2],i&&r(J,J,i),e(X[u++],J),F(t,J)||(t.projectToScreen(J,z),a(c,z),tt.addNearestCandidate(J));return v(t,c,X,tt),tt.valid?new I(p(c),tt.distance,s(tt.point)):null}function v(t,n,r,e){for(let o=0;o<r.length;o++)for(const i of Z){const s=o|i;if(s===o)continue;E(t,r[o],r[s],K)&&(t.projectToScreen(K,z),a(n,z),e.addNearestCandidate(K))}}function C(t,n,r,o,i){e(K,n),e(L,r);const s=t.projectToRenderScreen(K,G),c=t.projectToRenderScreen(L,H);if(null==s||null==c)return!1;const u=F(t,K),f=F(t,L);if(u&&f)return!1;if(u!==f){const n=u?K:L,r=u?s:c;if(!w(t,n,u?L:K))return!1;if(!t.projectToRenderScreen(n,r))return!1}return o[0]=s[0],o[1]=s[1],o[2]=0,i[0]=c[0],i[1]=c[1],i[2]=0,!0}function F(t,n){return P(t,n)>0}function P(t,n){return b(t.frustum[4],n)}function w(t,n,r){return E(t,n,r,n)}function E(t,n,r,e){return j(t.frustum[4],M(n,r,W),e)}function O(t,n){let r=!1;for(let e=0,o=n.length-1;e<n.length;o=e++){const i=n[e],s=n[o];if(!(i[1]>t[1]!=s[1]>t[1]))continue;const c=(s[0]-i[0])*(t[1]-i[1])/(s[1]-i[1])+i[0];t[0]<c&&(r=!r)}return r}function V(t,n,r,e){const o=D(t,n,r),i=D(t,n,e),s=D(r,e,t),c=D(r,e,n);return o!==i&&s!==c||(0===o&&U(t,n,r)||0===i&&U(t,n,e)||0===s&&U(r,e,t)||0===c&&U(r,e,n))}function Y(t,n,r,e){return V(t,n,r,e)?0:Math.min(B(t,r,e),B(n,r,e),B(r,t,n),B(e,t,n))}function B(t,n,r){return g(M(i(K,n[0],n[1],0),i(L,r[0],r[1],0),W),i(Q,t[0],t[1],0))}function D(t,n,r){const e=(n[1]-t[1])*(r[0]-n[0])-(n[0]-t[0])*(r[1]-n[1]);return Math.abs(e)<=nt?0:Math.sign(e)}function U(t,n,r){return r[0]>=Math.min(t[0],n[0])-nt&&r[0]<=Math.max(t[0],n[0])+nt&&r[1]>=Math.min(t[1],n[1])-nt&&r[1]<=Math.max(t[1],n[1])+nt}function k(t,n,r){return t[0]=0===r||3===r?n[0]:n[2],t[1]=r<2?n[1]:n[3],t}const q=u(),z=t(),A=t(),G=n(),H=n(),J=c(),K=c(),L=c(),Q=c(),W=d(),X=[c(),c(),c(),c(),c(),c(),c(),c()],Z=[1,2,4];class ${constructor(){this._origin=c(),this.point=c(),this.distance=Number.POSITIVE_INFINITY}get valid(){return Number.isFinite(this.distance)}addNearestCandidate(t){const n=o(this._origin,t);n<this.distance&&(this.distance=n,e(this.point,t))}reset(t){this.distance=Number.POSITIVE_INFINITY,e(this._origin,t)}}const tt=new $,nt=1e-9;export{I as ProjectedScreenBounds,F as isBehindNearPlane,_ as projectAabbToScreenBounds,y as projectBoundingInfoToScreenBounds,C as projectWorldLineSegmentToRenderScreen,N as screenPolygonContainsPoint,T as screenPolygonIntersectsBounds,R as screenPolygonIntersectsBufferedSegment,S as screenPolygonIntersectsTriangle};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{createScreenPointArray as t}from"../../../../core/screenUtils.js";import{copy as n,set as e,transformMat4 as i,lerp as o,distance as r,squaredDistance as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c,setMin as u,setMax as a,getMax as f,getMin as m}from"../../../../geometry/support/aaBoundingBox.js";import{signedDistance as p}from"../../../../geometry/support/plane.js";import{normalFromValues as d,closestPointFromValues as h}from"../../../../geometry/support/triangle.js";import{boundingInfoSubdivisionThreshold as I}from"./intersectionConstants.js";import{projectAabbToScreenBounds as b,projectBoundingInfoToScreenBounds as g,screenPolygonIntersectsBounds as v,screenPolygonIntersectsTriangle as y}from"./screenPolygonOverlapUtils.js";class N{constructor(){this.distance=Number.POSITIVE_INFINITY,this.primitiveIndex=0,this.hasNormal=!1,this.point=l(),this.normal=l()}update(t,e,i,o){this.distance=t,this.primitiveIndex=e,n(this.point,i),this.hasNormal=null!=o,null!=o&&n(this.normal,o)}updateIfCloser(t){const{distance:n,primitiveIndex:e,point:i,normal:o}=t;n<this.distance&&this.update(n,e,i,t.hasNormal?o:null)}get valid(){return Number.isFinite(this.distance)}}function j(t,n,e,i,o){if(!t.visible||0!==t.type)return null;const r=new N;let s;if(t.boundingInfo)s=P(t.boundingInfo,n,e,i,o);else{const r=t.positionAttribute,l=t.primitivePositionIndices;s=T(n,e,i,0,l.length/3,l,r.data,r.stride,o)}for(const l of s)r.updateIfCloser(l);return r.valid?r:null}function x(t,n,e,i,o,r,s,l,c){const u=new N;for(const a of T(t,n,e,i,o,r,s,l,c))u.updateIfCloser(a);return u.valid?u:null}function*T(t,n,e,i,o,s,l,c,u,a=null,f=0){if(null==t.camera)return;const m=t.camera;for(let p=i;p<o;++p){const t=(a?.[p]??p)+f,i=null==a?t:p,o=3*t;w(A[0],s,l,c,o+0,u,i,n),w(A[1],s,l,c,o+1,u,i,n),w(A[2],s,l,c,o+2,u,i,n);const h=F(m,A,B);if(!(h<3)){for(let t=0;t<h;t++)m.projectToScreen(B[t],E[t]);O(e,E,h)&&(S(m.eye,B,h,M),C.update(r(m.eye,M),t,M,d(U,A[0],A[1],A[2])?U:null),yield C)}}}const C=new N;function*P(t,n,e,i,o){const r=n.camera,s=null!=o?(u(V,t.bbMin),a(V,t.bbMax),o.applyToAabb(V),b(r,m(V,A[0]),f(V,A[1]),e)):g(r,t,e);if(null==s||!v(i,s.bounds))return;const{primitiveIndices:l,position:c}=t,p=l?l.length:c.indices.length/3;if(p>I){const r=t.getChildren();if(void 0!==r){for(const t of r)yield*P(t,n,e,i,o);return}}yield*T(n,e,i,0,p,c.indices,c.data,c.stride,o,l)}function w(t,o,r,s,l,c,u,a){const f=s*o[l],m=r[f+0],p=r[f+1],d=r[f+2];null!=c?n(t,c.applyToVertex(m,p,d,u)):e(t,m,p,d),a&&i(t,t,a)}function F(t,e,i){let r=0;for(let s=0;s<3;s++){const l=e[s],c=e[(s+1)%3],u=p(t.frustum[4],l),a=p(t.frustum[4],c),f=u<=0,m=a<=0;f&&m?n(i[r++],c):f&&!m?o(i[r++],l,c,u/(u-a)):!f&&m&&(o(i[r++],l,c,u/(u-a)),n(i[r++],c))}return r}function O(t,n,e){for(let i=1;i<e-1;i++)if(y(t,n[0],n[i],n[i+1]))return!0;return!1}function S(t,e,i,o){let r=Number.POSITIVE_INFINITY;for(let l=1;l<i-1;l++){h(U,t,e[0],e[l],e[l+1]);const i=s(t,U);i<r&&(r=i,n(o,U))}}const V=c(),A=[l(),l(),l()],B=[l(),l(),l(),l()],E=[t(),t(),t(),t()],M=l(),U=l();export{N as Hit,T as forEachTriangleRangeScreenPolygonHit,j as intersectTriangleGeometryScreenPolygon,x as intersectTriangleRangeScreenPolygon};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{sub as n,normalize as t,cross as r,dist as o,dot as c,len as u,scaleAndAdd as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";function e(n,t,r){const o=c(n,t)-r;return Math.abs(o)<=1e-5}function f(o,c,u){const i=s(),e=s();n(e,c,o);const f=s();return n(f,u,o),r(i,e,f),t(i,i),i}function a(r,o,u,a){const m=[o,u,a],h=f(o,u,a);if(!e(r,h,c(m[0],h)))return!1;for(let e=0;e<3;++e){const r=m[e],o=m[(e+1)%3],u=m[(e+2)%3],f=s();n(f,o,r),t(f,f);const a=s();n(a,u,r);const h=c(a,f),l=s();i(l,r,f,h);const M=s();n(M,u,l),t(M,M);const x=c(r,M);if(!(c(M,l)-x>=-1e-4))return!1}return!0}function m(o){const c=s();n(c,o[1],o[0]),t(c,c);const u=s();n(u,o[2],o[0]),t(u,u);const i=s();return r(i,c,u),t(i,i),i}function h(r,o,u){const e=s();n(e,u,o),t(e,e);const f=s();n(f,r,o);const a=c(f,e),m=s();return i(m,o,e,a),m}function l(n,t,r){const c=h(n,t,r);return o(c,n)}function M(r,e,f){const a=s();n(a,f,e);const m=u(a);t(a,a);const h=s();n(h,r,e);const l=c(h,a);if(l<0)return o(e,r);if(l>m)return o(f,r);const M=s();i(M,e,a,l);return o(M,r)}function x(n,t,r){return c(n,t)-r}function y(o,u,i){const e=s(),f=s();n(f,u,o);const a=s();n(a,i,o),r(e,f,a),t(e,e);return{normal:e,d:c(e,o)}}function A(n,t,r,o){const{normal:c,d:u}=y(t,r,o),e=x(n,c,u),f=s();return i(f,n,c,-e),a(f,t,r,o)?e:Math.min(M(n,t,r),M(n,r,o),M(n,o,t))}function b(t,r,o){const u=s();n(u,r,t);const e=m(o),f=c(e,o[0]),h=c(e,t)-f,l=c(e,r)-f;if(h*l>0)return 1/0;const M=s();return i(M,t,u,(0-h)/(l-h)),a(M,o[0],o[1],o[2])?0:A(M,o[0],o[1],o[2])}function g(n,t){const r=n.length;if(0===r)return 0;if(t<n[0])return-1;if(t>=n[r-1])return r;let o=0,c=r-1;for(;c-o>1;){const r=Math.floor(.5*(c+o));t>=n[r]?o=r:c=r}return o}function p(n,t,r,o,c,u,i){const s=u-i,e=t-n,f=new Float64Array(4*e);for(let a=0;a<e;++a){const t=3*(a+n),u=c*r[t+0],e=o[u+0],m=o[u+1],h=s/(o[u+2]-i),l=e*h,M=m*h,x=c*r[t+1],y=o[x+0],A=o[x+1],b=s/(o[x+2]-i),g=y*b,p=A*b,w=c*r[t+2],U=o[w+0],d=o[w+1],j=s/(o[w+2]-i),v=U*j,F=d*j,q=4*a;f[q+0]=Math.min(l,g,v),f[q+1]=Math.min(M,p,F),f[q+2]=Math.max(l,g,v),f[q+3]=Math.max(M,p,F)}return f}function w(n,t,r,o,c){const u=t-n,i=new Float64Array(4*u);for(let s=0;s<u;++s){const t=3*(s+n),u=c*r[t+0],e=o[u+0],f=o[u+1],a=c*r[t+1],m=o[a+0],h=o[a+1],l=c*r[t+2],M=o[l+0],x=o[l+1],y=4*s;i[y+0]=Math.min(e,m,M),i[y+1]=Math.min(f,h,x),i[y+2]=Math.max(e,m,M),i[y+3]=Math.max(f,h,x)}return i}function U(n,t){return new(d(n))(t)}function d(n){return n<128?Uint8Array:n<32768?Uint16Array:n<1<<31?Uint32Array:Array}function j(n,t){n[2]+=t}function v(n,t,r,o){const[c,u,i]=o??n,s=i-r,e=t/Math.sqrt(c*c+u*u+s*s);n[0]+=c*e,n[1]+=u*e,n[2]+=s*e}export{g as binarySearchSortedArray,m as calculateNormalFromVertices,U as createUintArray,l as distancePointLine,x as distancePointPlane,M as distancePointSegment,A as distancePointTriangle,v as elevationAlignVertexGlobal,j as elevationAlignVertexLocal,p as generateTriangleAabbsGlobal,w as generateTriangleAabbsLocal,d as getConstructorForValueCount,h as getNearestPointOnLine,b as getRayTriangleIntersectionDistance,f as getTriangleNormal,y as getTrianglePlane,e as isPointInPlane,a as isPointInTriangle};
2
+ function t(t,n,r,a,o,i,c){const e=i-c,u=n-t,h=new Float64Array(4*u);for(let M=0;M<u;++M){const n=3*(M+t),i=o*r[n+0],u=a[i+0],f=a[i+1],m=e/(a[i+2]-c),s=u*m,y=f*m,A=o*r[n+1],x=a[A+0],l=a[A+1],w=e/(a[A+2]-c),U=x*w,F=l*w,p=o*r[n+2],q=a[p+0],b=a[p+1],d=e/(a[p+2]-c),g=q*d,j=b*d,k=4*M;h[k+0]=Math.min(s,U,g),h[k+1]=Math.min(y,F,j),h[k+2]=Math.max(s,U,g),h[k+3]=Math.max(y,F,j)}return h}function n(t,n,r,a,o){const i=n-t,c=new Float64Array(4*i);for(let e=0;e<i;++e){const n=3*(e+t),i=o*r[n+0],u=a[i+0],h=a[i+1],M=o*r[n+1],f=a[M+0],m=a[M+1],s=o*r[n+2],y=a[s+0],A=a[s+1],x=4*e;c[x+0]=Math.min(u,f,y),c[x+1]=Math.min(h,m,A),c[x+2]=Math.max(u,f,y),c[x+3]=Math.max(h,m,A)}return c}function r(t,n){return new(a(t))(n)}function a(t){return t<128?Uint8Array:t<32768?Uint16Array:t<1<<31?Uint32Array:Array}function o(t,n){t[2]+=n}function i(t,n,r,a){const[o,i,c]=a??t,e=c-r,u=n/Math.sqrt(o*o+i*i+e*e);t[0]+=o*u,t[1]+=i*u,t[2]+=e*u}export{r as createUintArray,i as elevationAlignVertexGlobal,o as elevationAlignVertexLocal,t as generateTriangleAabbsGlobal,n as generateTriangleAabbsLocal,a as getConstructorForValueCount};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{exactEquals as e,set as t,copy as r,normalize as s,subtract as i,length as a,scale as o,dot as n,transformMat3 as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as u,create as c,fromValues as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{is3DGeometryOrShadowLike as m,isColor as p}from"../core/shaderLibrary/ShaderOutput.js";import{GLTextureMaterial as d}from"../lib/GLTextureMaterial.js";import{Material as f}from"../lib/Material.js";import{intersectTriangleGeometry as x}from"../lib/RayIntersections.js";import{getVerticalOffsetObject3D as T}from"../lib/verticalOffsetUtils.js";import{DefaultBufferWriter as g}from"./DefaultBufferWriter.js";import{intersectWithPolygonOffset as v}from"./PolygonOffset.js";import{verticalOffsetAtDistance as S}from"./internal/MaterialUtil.js";import{getLayout as b,DefaultMaterialPassParameters as M,DefaultMaterialTechnique as O}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as w}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{RealisticTreeTechnique as y}from"../shaders/RealisticTreeTechnique.js";import{hasShadowHighlights as C}from"../shaders/ReceiveShadowsConfiguration.js";import{alphaCutoff as R}from"../../../../webscene/support/AlphaCutoff.js";class P extends f{constructor(e,t){super(e,I),this.materialType="default",this.supportsEdges=!0,this.intersectRayDraped=void 0,this.produces=new Map([[2,e=>m(e)&&!this.transparent],[4,e=>m(e)&&this.transparent&&this.parameters.writeDepth],[8,e=>m(e)&&this.transparent&&!this.parameters.writeDepth]]),this._layout=b(this.parameters),this._configuration=new w(t.spherical)}isVisibleForOutput(e){return 5!==e&&7!==e&&6!==e||this.parameters.castShadows}get visible(){const{layerOpacity:e,colorMixMode:t,opacity:r,externalColor:s}=this.parameters;return e*("replace"===t?1:r)*("ignore"===t||isNaN(s[3])?1:s[3])>=R}get _hasEmissiveBase(){return!!this.parameters.emissiveTextureId||!e(this.parameters.emissiveBaseColor,u)}get emissions(){return this.parameters.emissiveStrength>0&&(0===this.parameters.emissiveSource&&this._hasEmissiveBase||1===this.parameters.emissiveSource)?this.transparent?2:1:0}updateConfiguration(e){super.updateConfiguration(e);const{parameters:t,_configuration:r}=this;r.hasNormalTexture=t.hasNormalTexture,r.hasColorTexture=t.hasColorTexture,r.hasMetallicRoughnessTexture=t.hasMetallicRoughnessTexture,r.hasOcclusionTexture=t.hasOcclusionTexture;const{treeRendering:s,doubleSided:i,doubleSidedType:a}=t;r.hasVertexTangents=!s&&t.hasVertexTangents,r.instanced=t.instanced,r.instancedDoublePrecision=t.instancedDoublePrecision,r.hasVVColor=!!t.vvColor,r.hasVVSize=!!t.vvSize,r.hasVerticalOffset=null!=t.verticalOffset,r.hasScreenSizePerspective=null!=t.screenSizePerspective,r.hasSlicePlane=t.hasSlicePlane,r.alphaDiscardMode=t.textureAlphaMode,r.normalType=s?0:t.normalType,r.transparent=this.transparent,r.enableOITOffset=e.enableOITOffset,r.writeDepth=t.writeDepth,r.customDepthTest=t.customDepthTest??0,r.hasOccludees=e.hasOccludees,r.cullFace=t.hasSlicePlane?0:t.cullFace,r.hasModelTransformation=!s&&null!=t.modelTransformation,r.hasVertexColors=t.hasVertexColors,r.hasSymbolColors=t.hasSymbolColors,r.doubleSidedMode=s?2:i&&"normal"===a?1:i&&"winding-order"===a?2:0,r.instancedFeatureAttribute=t.instancedFeatureAttribute,r.instancedColor=t.instancedColor,p(e.output)?(r.receiveShadows=t.receiveShadows,r.hasShadowHighlights=C(r,e),r.receiveAmbientOcclusion=t.receiveAmbientOcclusion&&null!=e.ssao,r.receiveGlobalIllumination=t.receiveAmbientOcclusion&&e.globalIlluminationEnabled):r.receiveShadows=r.hasShadowHighlights=r.receiveAmbientOcclusion=!1,r.textureAlphaPremultiplied=!!t.textureAlphaPremultiplied,r.pbrMode=t.usePBR?t.isSchematic?2:1:0,r.emissionSource=t.emissionSource,r.offsetBackfaces=!(!this.transparent||!t.offsetTransparentBackfaces),r.snowCover=e.snowCover>0,r.hasColorTextureTransform=!!t.colorTextureTransformMatrix,r.hasNormalTextureTransform=!!t.normalTextureTransformMatrix,r.hasEmissionTextureTransform=!!t.emissiveTextureTransformMatrix,r.hasOcclusionTextureTransform=!!t.occlusionTextureTransformMatrix,r.hasMetallicRoughnessTextureTransform=!!t.metallicRoughnessTextureTransformMatrix}intersectRay(e,u,c,h,m,p){if(null!=this.parameters.verticalOffset){const e=c.camera;t(N,u[12],u[13],u[14]);let p=null;switch(c.viewingMode){case 1:p=s(_,N);break;case 2:p=r(_,V)}const d=i(z,N,e.eye),f=a(d),x=o(d,d,1/f);let T=null;this.parameters.screenSizePerspective&&(T=n(p,x));const g=S(e,f,this.parameters.verticalOffset,T??0,this.parameters.screenSizePerspective,null);o(p,p,g),l(B,p,c.transform.inverseRotation),h=i(D,h,B),m=i(A,m,B)}p=v(p,this._configuration,h,m),x(e,c,h,m,T(c.verticalOffset),p)}intersectScreenPolygon(){}createGLMaterial(e){return new j(e)}createBufferWriter(){return new g(this._layout)}get transparent(){const{drivenOpacity:e,opacity:t,externalColor:r,layerOpacity:s,texture:i,textureId:a,textureAlphaMode:o,colorMixMode:n}=this.parameters,l=r[3];return e||t<1&&"replace"!==n||l<1&&"ignore"!==n||s<1||(null!=i||null!=a)&&1!==o&&2!==o&&"replace"!==n}}class j extends d{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){this._material.setParameters({receiveShadows:e.shadowMap.enabled});const r=this._material.parameters;this.updateTexture(r.textureId);const s=e.camera.viewInverseTransposeMatrix;return t(r.origin,s[3],s[7],s[11]),this._material.setParameters(this.textureBindParameters),this.getTechnique(r.treeRendering?y:O,e)}}class I extends M{constructor(){super(...arguments),this.treeRendering=!1,this.useIndexing=!1,this.hasVertexTangents=!1}get hasNormalTexture(){return!this.treeRendering&&!!this.normalTextureId}get hasColorTexture(){return!!this.textureId}get hasMetallicRoughnessTexture(){return!this.treeRendering&&!!this.metallicRoughnessTextureId}get hasOcclusionTexture(){return!this.treeRendering&&!!this.occlusionTextureId}get emissiveStrength(){return this.emissiveStrengthFromSymbol*this.emissiveStrengthKHR}get emissionSource(){return null!=this.emissiveTextureId&&0===this.emissiveSource?3:0===this.emissiveSource?2:1}get hasTextures(){return this.hasColorTexture||this.hasNormalTexture||this.hasMetallicRoughnessTexture||3===this.emissionSource||this.hasOcclusionTexture}}const D=c(),A=c(),V=h(0,0,1),_=c(),B=c(),N=c(),z=c();export{j as DefaultGLMaterial,P as DefaultMaterial,I as DefaultMaterialParameters};
2
+ import{exactEquals as e,set as t,copy as r,normalize as s,subtract as i,length as a,scale as o,dot as n,transformMat3 as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as u,create as c,fromValues as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{is3DGeometryOrShadowLike as m,isColor as p}from"../core/shaderLibrary/ShaderOutput.js";import{GLTextureMaterial as d}from"../lib/GLTextureMaterial.js";import{Material as f}from"../lib/Material.js";import{intersectTriangleGeometry as x}from"../lib/RayIntersections.js";import{getVerticalOffsetObject3D as T}from"../lib/verticalOffsetUtils.js";import{DefaultBufferWriter as g}from"./DefaultBufferWriter.js";import{intersectWithPolygonOffset as v}from"./intersectWithPolygonOffset.js";import{verticalOffsetAtDistance as S}from"./internal/MaterialUtil.js";import{getLayout as b,DefaultMaterialPassParameters as M,DefaultMaterialTechnique as O}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as w}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{RealisticTreeTechnique as y}from"../shaders/RealisticTreeTechnique.js";import{hasShadowHighlights as C}from"../shaders/ReceiveShadowsConfiguration.js";import{alphaCutoff as R}from"../../../../webscene/support/AlphaCutoff.js";class P extends f{constructor(e,t){super(e,I),this.materialType="default",this.supportsEdges=!0,this.intersectRayDraped=void 0,this.produces=new Map([[2,e=>m(e)&&!this.transparent],[4,e=>m(e)&&this.transparent&&this.parameters.writeDepth],[8,e=>m(e)&&this.transparent&&!this.parameters.writeDepth]]),this._layout=b(this.parameters),this._configuration=new w(t.spherical)}isVisibleForOutput(e){return 5!==e&&7!==e&&6!==e||this.parameters.castShadows}get visible(){const{layerOpacity:e,colorMixMode:t,opacity:r,externalColor:s}=this.parameters;return e*("replace"===t?1:r)*("ignore"===t||isNaN(s[3])?1:s[3])>=R}get _hasEmissiveBase(){return!!this.parameters.emissiveTextureId||!e(this.parameters.emissiveBaseColor,u)}get emissions(){return this.parameters.emissiveStrength>0&&(0===this.parameters.emissiveSource&&this._hasEmissiveBase||1===this.parameters.emissiveSource)?this.transparent?2:1:0}updateConfiguration(e){super.updateConfiguration(e);const{parameters:t,_configuration:r}=this;r.hasNormalTexture=t.hasNormalTexture,r.hasColorTexture=t.hasColorTexture,r.hasMetallicRoughnessTexture=t.hasMetallicRoughnessTexture,r.hasOcclusionTexture=t.hasOcclusionTexture;const{treeRendering:s,doubleSided:i,doubleSidedType:a}=t;r.hasVertexTangents=!s&&t.hasVertexTangents,r.instanced=t.instanced,r.instancedDoublePrecision=t.instancedDoublePrecision,r.hasVVColor=!!t.vvColor,r.hasVVSize=!!t.vvSize,r.hasVerticalOffset=null!=t.verticalOffset,r.hasScreenSizePerspective=null!=t.screenSizePerspective,r.hasSlicePlane=t.hasSlicePlane,r.alphaDiscardMode=t.textureAlphaMode,r.normalType=s?0:t.normalType,r.transparent=this.transparent,r.enableOITOffset=e.enableOITOffset,r.writeDepth=t.writeDepth,r.customDepthTest=t.customDepthTest??0,r.hasOccludees=e.hasOccludees,r.cullFace=t.hasSlicePlane?0:t.cullFace,r.hasModelTransformation=!s&&null!=t.modelTransformation,r.hasVertexColors=t.hasVertexColors,r.hasSymbolColors=t.hasSymbolColors,r.doubleSidedMode=s?2:i&&"normal"===a?1:i&&"winding-order"===a?2:0,r.instancedFeatureAttribute=t.instancedFeatureAttribute,r.instancedColor=t.instancedColor,p(e.output)?(r.receiveShadows=t.receiveShadows,r.hasShadowHighlights=C(r,e),r.receiveAmbientOcclusion=t.receiveAmbientOcclusion&&null!=e.ssao,r.receiveGlobalIllumination=t.receiveAmbientOcclusion&&e.globalIlluminationEnabled):r.receiveShadows=r.hasShadowHighlights=r.receiveAmbientOcclusion=!1,r.textureAlphaPremultiplied=!!t.textureAlphaPremultiplied,r.pbrMode=t.usePBR?t.isSchematic?2:1:0,r.emissionSource=t.emissionSource,r.offsetBackfaces=!(!this.transparent||!t.offsetTransparentBackfaces),r.snowCover=e.snowCover>0,r.hasColorTextureTransform=!!t.colorTextureTransformMatrix,r.hasNormalTextureTransform=!!t.normalTextureTransformMatrix,r.hasEmissionTextureTransform=!!t.emissiveTextureTransformMatrix,r.hasOcclusionTextureTransform=!!t.occlusionTextureTransformMatrix,r.hasMetallicRoughnessTextureTransform=!!t.metallicRoughnessTextureTransformMatrix}intersectRay(e,u,c,h,m,p){if(null!=this.parameters.verticalOffset){const e=c.camera;t(N,u[12],u[13],u[14]);let p=null;switch(c.viewingMode){case 1:p=s(_,N);break;case 2:p=r(_,V)}const d=i(z,N,e.eye),f=a(d),x=o(d,d,1/f);let T=null;this.parameters.screenSizePerspective&&(T=n(p,x));const g=S(e,f,this.parameters.verticalOffset,T??0,this.parameters.screenSizePerspective,null);o(p,p,g),l(B,p,c.transform.inverseRotation),h=i(D,h,B),m=i(A,m,B)}p=v(p,this._configuration,h,m),x(e,c,h,m,T(c.verticalOffset),p)}intersectScreenPolygon(){}createGLMaterial(e){return new j(e)}createBufferWriter(){return new g(this._layout)}get transparent(){const{drivenOpacity:e,opacity:t,externalColor:r,layerOpacity:s,texture:i,textureId:a,textureAlphaMode:o,colorMixMode:n}=this.parameters,l=r[3];return e||t<1&&"replace"!==n||l<1&&"ignore"!==n||s<1||(null!=i||null!=a)&&1!==o&&2!==o&&"replace"!==n}}class j extends d{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){this._material.setParameters({receiveShadows:e.shadowMap.enabled});const r=this._material.parameters;this.updateTexture(r.textureId);const s=e.camera.viewInverseTransposeMatrix;return t(r.origin,s[3],s[7],s[11]),this._material.setParameters(this.textureBindParameters),this.getTechnique(r.treeRendering?y:O,e)}}class I extends M{constructor(){super(...arguments),this.treeRendering=!1,this.useIndexing=!1,this.hasVertexTangents=!1}get hasNormalTexture(){return!this.treeRendering&&!!this.normalTextureId}get hasColorTexture(){return!!this.textureId}get hasMetallicRoughnessTexture(){return!this.treeRendering&&!!this.metallicRoughnessTextureId}get hasOcclusionTexture(){return!this.treeRendering&&!!this.occlusionTextureId}get emissiveStrength(){return this.emissiveStrengthFromSymbol*this.emissiveStrengthKHR}get emissionSource(){return null!=this.emissiveTextureId&&0===this.emissiveSource?3:0===this.emissiveSource?2:1}get hasTextures(){return this.hasColorTexture||this.hasNormalTexture||this.hasMetallicRoughnessTexture||3===this.emissionSource||this.hasOcclusionTexture}}const D=c(),A=c(),V=h(0,0,1),_=c(),B=c(),N=c(),z=c();export{j as DefaultGLMaterial,P as DefaultMaterial,I as DefaultMaterialParameters};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{normalize as t,sub as r,dot as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isOITColorAlpha as f}from"../core/shaderLibrary/ShaderOutput.js";const s=2,c=1,e=O(-1),u=O(1),i=e,a=new Array;a[0]=null,a[1]=u,a[2]=e,a[3]=O(-2),a[4]=O(-3);const l=a.map(t=>p(i,t));function m({output:t,enableOITOffset:r,polygonOffset:n}){return f(t)&&r?l[n]:a[n]}function p(t,r){return r?{factor:t.factor+r.factor,units:t.units+r.units}:t}function O(t){return{factor:c*t,units:s*t}}function b(o,f,s,c){const e=m(f);if(!e)return o;const u=x*e.units,i=t(y,r(y,c,s));return(t,r,f)=>{const s=(r?1-Math.abs(n(i,r)):0)*e.factor*g+u;return o(t+s,r,f)}}a[1]=u;const g=5e-5,x=5e-6,y=o();function d(t){const r=m(t)??{factor:0,units:0};return{factor:r.factor+e.factor*t.polygonOffsetIndex,units:r.units+e.units*t.polygonOffsetIndex}}export{d as getRibbonLineLayerPolygonOffset,b as intersectWithPolygonOffset,m as polygonOffset};
2
+ import{isOITColorAlpha as t}from"../core/shaderLibrary/ShaderOutput.js";const n=2,o=1,r=i(-1),f=i(1),u=r,e=new Array;e[0]=null,e[1]=f,e[2]=r,e[3]=i(-2),e[4]=i(-3);const s=e.map(t=>a(u,t));function c({output:n,enableOITOffset:o,polygonOffset:r}){return t(n)&&o?s[r]:e[r]}function a(t,n){return n?{factor:t.factor+n.factor,units:t.units+n.units}:t}function i(t){return{factor:o*t,units:n*t}}function p(t){const n=c(t)??{factor:0,units:0};return{factor:n.factor+r.factor*t.polygonOffsetIndex,units:n.units+r.units*t.polygonOffsetIndex}}e[1]=f;export{p as getRibbonLineLayerPolygonOffset,c as polygonOffset};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{normalize as e,set as t,scale as r,add as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as n,scale as p}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as c}from"../../../../geometry/support/buffer/BufferView.js";import{isColorOrOLID as h}from"../core/shaderLibrary/ShaderOutput.js";import l from"../lib/GLMaterial.js";import{Material as f,MaterialParameters as m}from"../lib/Material.js";import{intersectTriangleGeometry as u}from"../lib/RayIntersections.js";import{assert as d}from"../lib/Util.js";import{intersectWithPolygonOffset as g}from"./PolygonOffset.js";import{writeAttributes as b,writePosition as S}from"./internal/bufferWriterUtils.js";import{getLayout as _,ShadedColorMaterialTechnique as j}from"../shaders/ShadedColorMaterialTechnique.js";import{ShadedColorMaterialTechniqueConfiguration as w}from"../shaders/ShadedColorMaterialTechniqueConfiguration.js";import{alphaCutoff as y}from"../../../../webscene/support/AlphaCutoff.js";class x extends f{constructor(e){super(e,E),this._configuration=new w,this.supportsEdges=!0,this._pp0=i(0,0,1),this._pp1=i(0,0,0),this.produces=new Map([[2,e=>10===e||h(e)&&!this.parameters.transparent],[4,e=>h(e)&&this.parameters.transparent&&this.parameters.writeDepth],[8,e=>h(e)&&this.parameters.transparent&&!this.parameters.writeDepth]])}updateConfiguration(e){super.updateConfiguration(e),this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.screenSizeEnabled=this.parameters.screenSizeEnabled,this._configuration.shadingEnabled=this.parameters.shadingEnabled}get visible(){return this.parameters.color[3]>=y}intersectRay(e,t,r,s,i,a){this._intersect(e,r,s,i,a)}intersectScreenPolygon(){}intersectRayDraped(e,t,r,s){return this._pp0[0]=this._pp1[0]=r[0],this._pp0[1]=this._pp1[1]=r[1],this._intersect(e,t,this._pp0,this._pp1,s)}_intersect(e,i,a,o,c){const h=g(c,this._configuration,a,o);if(this.parameters.screenSizeEnabled){const c=e.attributes.get("offset"),l={applyToVertex:(e,a,o,n)=>{const p=t(T,c.data[3*n],c.data[3*n+1],c.data[3*n+2]),h=t(C,e,a,o);return r(p,p,this.parameters.screenSizeScale*(i.camera?.computeScreenPixelSizeAt(p)??1)),s(h,h,p),[h[0],h[1],h[2]]},applyToAabb:e=>{const t=n(e,T);return p(e,this.parameters.screenSizeScale*(i.camera?.computeScreenPixelSizeAt(t)??1))}};u(e,i,a,o,l,h)}else u(e,i,a,o,void 0,h)}createGLMaterial(e){return new z(e)}createBufferWriter(){return new M(_(this.parameters))}}class z extends l{beginSlot(e){return this.getTechnique(j,e)}}class E extends m{constructor(){super(...arguments),this.color=o(1,1,1,1),this.shadingTint=o(0,0,0,.25),this.shadingDirection=e(a(),[.5,-.5,-.5]),this.screenSizeScale=14,this.forceTransparentMode=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.cullFace=0,this.screenSizeEnabled=!1,this.shadingEnabled=!0}get transparent(){return this.color[3]<1||this.forceTransparentMode}}class M{constructor(e){this.layout=e}elementCount(e){return e.get("position").indices.length}write(e,t,r,s,i){const{buffer:a,offset:o}=i;b(r,s,this.layout,e,t,i);const n=a.getField("offset",c);if(n&&r.has("offset")){const e=r.get("offset");d(3===e.size),S(e,t,n,o)}}}const T=a(),C=a();export{E as Parameters,x as ShadedColorMaterial};
2
+ import{normalize as e,set as t,scale as r,add as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as n,scale as p}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as c}from"../../../../geometry/support/buffer/BufferView.js";import{isColorOrOLID as h}from"../core/shaderLibrary/ShaderOutput.js";import l from"../lib/GLMaterial.js";import{Material as f,MaterialParameters as m}from"../lib/Material.js";import{intersectTriangleGeometry as u}from"../lib/RayIntersections.js";import{assert as d}from"../lib/Util.js";import{intersectWithPolygonOffset as g}from"./intersectWithPolygonOffset.js";import{writeAttributes as b,writePosition as S}from"./internal/bufferWriterUtils.js";import{getLayout as _,ShadedColorMaterialTechnique as j}from"../shaders/ShadedColorMaterialTechnique.js";import{ShadedColorMaterialTechniqueConfiguration as w}from"../shaders/ShadedColorMaterialTechniqueConfiguration.js";import{alphaCutoff as y}from"../../../../webscene/support/AlphaCutoff.js";class x extends f{constructor(e){super(e,E),this._configuration=new w,this.supportsEdges=!0,this._pp0=i(0,0,1),this._pp1=i(0,0,0),this.produces=new Map([[2,e=>10===e||h(e)&&!this.parameters.transparent],[4,e=>h(e)&&this.parameters.transparent&&this.parameters.writeDepth],[8,e=>h(e)&&this.parameters.transparent&&!this.parameters.writeDepth]])}updateConfiguration(e){super.updateConfiguration(e),this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.screenSizeEnabled=this.parameters.screenSizeEnabled,this._configuration.shadingEnabled=this.parameters.shadingEnabled}get visible(){return this.parameters.color[3]>=y}intersectRay(e,t,r,s,i,a){this._intersect(e,r,s,i,a)}intersectScreenPolygon(){}intersectRayDraped(e,t,r,s){return this._pp0[0]=this._pp1[0]=r[0],this._pp0[1]=this._pp1[1]=r[1],this._intersect(e,t,this._pp0,this._pp1,s)}_intersect(e,i,a,o,c){const h=g(c,this._configuration,a,o);if(this.parameters.screenSizeEnabled){const c=e.attributes.get("offset"),l={applyToVertex:(e,a,o,n)=>{const p=t(T,c.data[3*n],c.data[3*n+1],c.data[3*n+2]),h=t(C,e,a,o);return r(p,p,this.parameters.screenSizeScale*(i.camera?.computeScreenPixelSizeAt(p)??1)),s(h,h,p),[h[0],h[1],h[2]]},applyToAabb:e=>{const t=n(e,T);return p(e,this.parameters.screenSizeScale*(i.camera?.computeScreenPixelSizeAt(t)??1))}};u(e,i,a,o,l,h)}else u(e,i,a,o,void 0,h)}createGLMaterial(e){return new z(e)}createBufferWriter(){return new M(_(this.parameters))}}class z extends l{beginSlot(e){return this.getTechnique(j,e)}}class E extends m{constructor(){super(...arguments),this.color=o(1,1,1,1),this.shadingTint=o(0,0,0,.25),this.shadingDirection=e(a(),[.5,-.5,-.5]),this.screenSizeScale=14,this.forceTransparentMode=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.cullFace=0,this.screenSizeEnabled=!1,this.shadingEnabled=!0}get transparent(){return this.color[3]<1||this.forceTransparentMode}}class M{constructor(e){this.layout=e}elementCount(e){return e.get("position").indices.length}write(e,t,r,s,i){const{buffer:a,offset:o}=i;b(r,s,this.layout,e,t,i);const n=a.getField("offset",c);if(n&&r.has("offset")){const e=r.get("offset");d(3===e.size),S(e,t,n,o)}}}const T=a(),C=a();export{E as Parameters,x as ShadedColorMaterial};