@arcgis/core 5.1.0-next.46 → 5.1.0-next.48
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{521a671182b0f79e3624.js → 193775b3b7de8f5dc578.js} +1 -1
- package/assets/esri/core/workers/chunks/{c0ecb68387e342dddf58.js → 25509953f19fbc4949a1.js} +1 -1
- package/assets/esri/core/workers/chunks/2669a7195f1de21a9cf3.js +1 -0
- package/assets/esri/core/workers/chunks/36425d29aaa5852cb41d.js +1 -0
- package/assets/esri/core/workers/chunks/440a650ed0867a16f559.js +1 -0
- package/assets/esri/core/workers/chunks/{aa367ca7f8326fd67881.js → 4afddb66242438b38df0.js} +1 -1
- package/assets/esri/core/workers/chunks/5344919fc6e8050450f1.js +1 -0
- package/assets/esri/core/workers/chunks/53c149bca42595b7dd1e.js +1 -0
- package/assets/esri/core/workers/chunks/{6afdaa6c4555c467dca7.js → 54420b66fd53d6e19ba5.js} +1 -1
- package/assets/esri/core/workers/chunks/797bf402489b3677a5f7.js +1 -0
- package/assets/esri/core/workers/chunks/{5c830cce32710d70dfa6.js → 7dba4121cdd20dbc4b20.js} +1 -1
- package/assets/esri/core/workers/chunks/947a715b608c8affd812.js +1 -0
- package/assets/esri/core/workers/chunks/{ce0a6bc9df30af778ac9.js → 9f7b5749f3ceca8d5978.js} +12 -9
- package/assets/esri/core/workers/chunks/aa69cbaa38b49677ddff.js +1 -0
- package/assets/esri/core/workers/chunks/{beb53b372d356800f333.js → ab414a60808ea05a63e6.js} +1 -1
- package/assets/esri/core/workers/chunks/b98dd9fc9a7e3ff6bd49.js +1 -0
- package/assets/esri/core/workers/chunks/cb8c17daec7055bf99cc.js +1 -0
- package/assets/esri/core/workers/chunks/cd491c37ba1ac381178c.js +1 -0
- package/assets/esri/core/workers/chunks/{a9f35127c3f5bf42036b.js → de359f89e03da18999fc.js} +1 -1
- package/chunks/Fog.glsl.js +3 -3
- package/chunks/GlowComposition.glsl.js +5 -3
- package/chunks/OITBlend.glsl.js +2 -1
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/core/workers/Connection.js +1 -1
- package/core/workers/WorkerHandle.js +1 -1
- package/core/workers/workers.js +1 -1
- package/geometry/support/curves/bezierCurveUtils.js +1 -1
- package/kernel.js +1 -1
- package/layers/Layer.d.ts +2 -1
- package/layers/Lyr3DWorkerHandle.js +1 -1
- package/layers/ParquetLayer.d.ts +23 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/layers/support/RasterJobHandler.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/package.json +1 -1
- package/smartMapping/statistics/support/statsWorker.js +1 -1
- package/support/revision.js +1 -1
- package/time/TimeExtent.d.ts +34 -0
- package/time/TimeInterval.d.ts +15 -0
- package/views/2d/engine/vectorTiles/TileHandler.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/Highlights.js +1 -1
- package/views/3d/layers/i3s/Intersector.js +1 -1
- package/views/3d/layers/support/patternUtils.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialGlobalParameters.js +2 -0
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/effects/fog/Fog.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
- package/views/3d/webgl-engine/effects/fog/FogTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowBlurTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowComposition.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowCompositionTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PolygonOffset.js +2 -0
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/TriangleTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/Dithering.glsl.js +4 -0
- package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +11 -10
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechniqueConfiguration.js +1 -1
- package/views/SceneView.d.ts +2 -1
- package/views/SceneView.js +1 -1
- package/views/support/LayerViewManager.js +1 -1
- package/views/types.d.ts +33 -2
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0601c316da0256a60538.js +0 -1
- package/assets/esri/core/workers/chunks/13d55e3c9aea04116eaa.js +0 -1
- package/assets/esri/core/workers/chunks/54c1d31e1efab765ee7a.js +0 -1
- package/assets/esri/core/workers/chunks/5b515b5741733bcb4645.js +0 -1
- package/assets/esri/core/workers/chunks/7f07f490c6fcc794c8d9.js +0 -1
- package/assets/esri/core/workers/chunks/abcb39ad1e2d54710766.js +0 -1
- package/assets/esri/core/workers/chunks/c2aa3b1344b42a904234.js +0 -1
- package/assets/esri/core/workers/chunks/cf5e4cf9b1aa37eeb6b0.js +0 -1
- package/assets/esri/core/workers/chunks/e63046a9567d84228644.js +0 -1
- package/assets/esri/core/workers/chunks/f4ec2dcdc4bbf7dbcc94.js +0 -1
- package/assets/esri/core/workers/chunks/fce8d4ff920baf8856e6.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{onLocaleChange as t,fetchMessageBundle as i}from"../../../../intl.js";import s from"../../../../core/Accessor.js";import{multiplyOpacityToUnitRGBA as n,getContrast as l,multiplyOpacity as r}from"../../../../core/colorUtils.js";import"../../../../core/has.js";import{nextHighestPowerOfTen as o,deg2rad as a}from"../../../../core/mathUtils.js";import{destroyMaybe as c}from"../../../../core/maybe.js";import{toUnit as h}from"../../../../core/quantity.js";import{formatDecimal as u,formatImperialVerticalLength as d,formatImperialLength as m,formatMetricVerticalLength as g,formatMetricLength as p}from"../../../../core/quantityFormatUtils.js";import{watch as _,syncAndInitial as v,initial as b}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as L,createRenderScreenPointArray as w}from"../../../../core/screenUtils.js";import{adaptiveImperialLengthUnit as y,convertUnit as S}from"../../../../core/units.js";import{property as f,subclass as E}from"../../../../core/accessorSupport/decorators.js";import{dot as V}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{scale as z,add as A}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{renderScreenSpaceTangent as M}from"../../interactive/support/viewUtils.js";import{LabelVisualElement as C,mirrorPosition as j}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as O}from"../../interactive/visualElements/LineVisualElement.js";import{MeasurementArrowVisualElement as x}from"../../interactive/visualElements/MeasurementArrowVisualElement.js";import{RightAngleQuadVisualElement as D}from"../../interactive/visualElements/RightAngleQuadVisualElement.js";import{GeodesicSegment as G,EuclideanSegment as H}from"../../interactive/visualElements/support/Segment.js";import{createStipplePatternSimple as R}from"../../webgl-engine/materials/lineStippleUtils.js";import{geodeticDistanceThresholdMeters as k}from"../../../support/measurementWorkerUtils.js";let T=class extends s{get _parameters(){const e=this.view.effectiveTheme,{accentColor:t,textColor:i}=e,s=t.toUnitRGBA(),o=n(t,.75),a=l(t).toUnitRGBA(),c=l(i,160);return{accentColor:s,contrastColor:a,translucentAccentColor:o,triangleLineWidth:3,geodesicProjectionLineWidth:2,guideLineWidth:2,guideStippleLengthPixels:3,directLabelFontSize:16,horizontalLabelFontSize:12,verticalLabelFontSize:12,textColor:i,textBackgroundColor:r(c,.6),textCalloutColor:r(c,.5)}}get visible(){return this.analysisView.visible}get viewMode(){const{elevationAlignedStartPoint:e,elevationAlignedEndPoint:t}=this.analysisView;if(null==e||null==t||e.equals(t))return 0;const i=this.analysisView.result;if(null==i)return 1;if("geodesic"===this.actualVisualizedMeasurement)return this._requiresGeodesicGuideAt(this._startPosition)||this._requiresGeodesicGuideAt(this._endPosition)?3:1;const{verticalDistance:s,horizontalDistance:n}=i,l=h(s,"meters").value,r=h(n,"meters").value;return Math.min(l/r,r/l)<this.triangleCollapseRatioThreshold?1:2}get actualVisualizedMeasurement(){const{measurementMode:e,result:t}=this.analysisView;switch(e){case 0:return null!=t&&h(t.horizontalDistance,"meters").value>k?"geodesic":"euclidean";case 1:return"euclidean";case 2:return"geodesic"}}get allowVisualElementsOrientationChange(){return null==this._triangleOrientationOverride}set allowVisualElementsOrientationChange(e){null==this._triangleOrientationOverride!==e&&(null==this._triangleOrientationOverride?this._triangleOrientationOverride=this._actualVisualElementsOrientation:this._triangleOrientationOverride=null)}get labels(){return"geodesic"===this.actualVisualizedMeasurement?{direct:null,horizontal:this._segmentLabel,vertical:this._verticalLabel}:{direct:this._segmentLabel,horizontal:this._horizontalLabel,vertical:this._verticalLabel}}constructor(e){super(e),this._segmentVisualElement=null,this._triangleVisualElement=null,this._rightAngleQuad=null,this._projectedGeodesicLine=null,this._geodesicStartHint=null,this._geodesicEndHint=null,this._segmentLabel=null,this._verticalLabel=null,this._horizontalLabel=null,this._startPosition=P(),this._endPosition=P(),this._cornerPosition=P(),this._startPositionAtSeaLevel=P(),this._endPositionAtSeaLevel=P(),this._triangleOrientationOverride=null,this.messages=null,this.loadingMessages=!0,this.visualElementOrientation=0,this.triangleCollapseRatioThreshold=.03}initialize(){const e={attached:!0,view:this.view,isDecoration:!0},{guideLineWidth:i,guideStippleLengthPixels:s,triangleLineWidth:n,geodesicProjectionLineWidth:l,directLabelFontSize:r,verticalLabelFontSize:o,horizontalLabelFontSize:a}=this._parameters;this._segmentVisualElement=new x({...e,geometry:null,renderOccluded:4,transparentRenderOrder:2}),this._triangleVisualElement=new O({...e,width:n,renderOccluded:4,transparentRenderOrder:3}),this._rightAngleQuad=new D({...e,renderOccluded:4,transparentRenderOrder:4});const c={...e,polygonOffset:!0,renderOccluded:4,transparentRenderOrder:1};this._projectedGeodesicLine=new O({...c,width:l,stipplePattern:R(s)}),this._geodesicStartHint=new O({...c,width:i,stipplePattern:R(s)}),this._geodesicEndHint=new O({...c,width:i,stipplePattern:R(s)}),this._segmentLabel=new C({...e,fontSize:r}),this._verticalLabel=new C({...e,fontSize:o}),this._horizontalLabel=new C({...e,fontSize:a}),this.addHandles([_(()=>{const{elevationAlignedStartPoint:e,elevationAlignedEndPoint:t}=this.analysisView,i=this.view;return{view:i,camera:i.state.camera,viewMode:this.viewMode,elevationAlignedStartPoint:e,elevationAlignedEndPoint:t,orientation:this._actualVisualElementsOrientation,visualizedMeasurement:this.actualVisualizedMeasurement,stripeLength:this._measurementArrowStripeLength}},e=>this._updateGeometryAndViewMode(e),v),_(()=>({visible:this.visible,viewMode:this.viewMode}),e=>this._updateVisualElementVisibility(e),v),_(()=>({text:this._labelsText,visualizedMeasurement:this.actualVisualizedMeasurement}),e=>this._updateLabelText(e),v),_(()=>({visible:this.visible,viewMode:this.viewMode}),e=>this._updateLabelVisibility(e),v),_(()=>this._measurementArrowStripeLength,e=>this._updateSegmentStripeLength(e),v),t(()=>this._updateMessageBundle()),_(()=>this._parameters,({textBackgroundColor:e,textCalloutColor:t,textColor:i,translucentAccentColor:s,accentColor:n,contrastColor:l})=>{const{_segmentLabel:r,_verticalLabel:o,_horizontalLabel:a,_triangleVisualElement:c,_rightAngleQuad:h,_projectedGeodesicLine:u,_geodesicStartHint:d,_geodesicEndHint:m,_segmentVisualElement:g}=this;r.backgroundColor=e,r.calloutColor=t,r.textColor=i,o.backgroundColor=e,o.calloutColor=t,o.textColor=i,a.backgroundColor=e,a.calloutColor=t,a.textColor=i,c.color=s,h.color=s,u.color=s,d.color=s,m.color=s,g.color=n,g.contrastColor=l},b)]),this._updateMessageBundle()}destroy(){this._segmentVisualElement=c(this._segmentVisualElement),this._triangleVisualElement=c(this._triangleVisualElement),this._rightAngleQuad=c(this._rightAngleQuad),this._projectedGeodesicLine=c(this._projectedGeodesicLine),this._geodesicStartHint=c(this._geodesicStartHint),this._geodesicEndHint=c(this._geodesicEndHint),this._segmentLabel=c(this._segmentLabel),this._verticalLabel=c(this._verticalLabel),this._horizontalLabel=c(this._horizontalLabel),this.set("view",null)}_updateVisualElementVisibility({visible:e,viewMode:t}){if(this._segmentVisualElement.visible=!1,this._triangleVisualElement.visible=!1,this._rightAngleQuad.visible=!1,this._projectedGeodesicLine.visible=!1,this._geodesicStartHint.visible=!1,this._geodesicEndHint.visible=!1,e)switch(t){case 0:break;case 1:this._segmentVisualElement.visible=!0;break;case 2:this._segmentVisualElement.visible=!0,this._triangleVisualElement.visible=!0,this._rightAngleQuad.visible=!0;break;case 3:this._segmentVisualElement.visible=!0,this._projectedGeodesicLine.visible=!0,this._geodesicStartHint.visible=!0,this._geodesicEndHint.visible=!0}}_updateGeometryAndViewMode({view:e,camera:t,viewMode:i,elevationAlignedStartPoint:s,elevationAlignedEndPoint:n,orientation:l,visualizedMeasurement:r,stripeLength:o}){const a=e.renderCoordsHelper;if(null==a||null==s||null==n||s.equals(n))return;let c=this._startPosition,h=this._endPosition;a.toRenderCoords(s,c),a.toRenderCoords(n,h);const u=1===l?1:-1,d=u*(a.getAltitude(h)-a.getAltitude(c));d<0&&(c=this._endPosition,h=this._startPosition);const m="geodesic"===r?new G(this._startPosition,this._endPosition,a.spatialReference):new H(this._startPosition,this._endPosition);switch(this._segmentVisualElement.geometry=m,this._updateSegmentStripeLength(o),i){case 1:this._updateSegment(m,l);break;case 2:this._updateSegmentAndTriangle({view:e,camera:t,segment:m,orientation:l,startPosition:c,endPosition:h,deltaSign:u,altitudeDelta:d});break;case 3:this._updateSegmentAndProjection({view:e,orientation:l,startPosition:c,endPosition:h})}}_updateSegment(e,t){this._segmentLabel.anchor=1===t?"top":"bottom",this._segmentLabel.geometry={type:"segment",segment:e,sampleLocation:"center"}}_updateSegmentAndTriangle({view:{renderCoordsHelper:e},camera:t,segment:i,orientation:s,startPosition:n,endPosition:l,deltaSign:r,altitudeDelta:o}){const a=this._cornerPosition;e.worldUpAtPosition(n,a),z(a,a,r*Math.abs(o)),A(a,a,n),this._triangleVisualElement.geometry=[[[n[0],n[1],n[2]],[a[0],a[1],a[2]],[l[0],l[1],l[2]]]],this._rightAngleQuad.geometry={previous:n,center:a,next:l};const c=new H(n,a),h=new H(a,l),u=U(n,l,a,s,t);u&&(this._segmentLabel.anchor=u.segment,this._segmentLabel.geometry={type:"segment",segment:i,sampleLocation:"center"},this._verticalLabel.geometry={type:"segment",segment:c,sampleLocation:"center"},this._verticalLabel.anchor=u.vertical,this._horizontalLabel.geometry={type:"segment",segment:h,sampleLocation:"center"},this._horizontalLabel.anchor=u.horizontal)}_updateSegmentAndProjection({view:{renderCoordsHelper:e},orientation:t,startPosition:i,endPosition:s}){e.setAltitude(this._startPositionAtSeaLevel,0,i),e.setAltitude(this._endPositionAtSeaLevel,0,s);const n=new G(this._startPositionAtSeaLevel,this._endPositionAtSeaLevel,e.spatialReference);this._projectedGeodesicLine.setGeometryFromSegment(n),this._geodesicStartHint.setGeometryFromSegment(new H(this._startPositionAtSeaLevel,i)),this._geodesicEndHint.setGeometryFromSegment(new H(this._endPositionAtSeaLevel,s)),this._segmentLabel.geometry={type:"segment",segment:n,sampleLocation:"center"},this._segmentLabel.anchor=1===t?"top":"bottom"}_updateLabelText({text:e,visualizedMeasurement:t}){null!=e?(this._segmentLabel.text="euclidean"===t?e.directDistance:e.horizontalDistance,this._horizontalLabel.text=e.horizontalDistance,this._verticalLabel.text=e.verticalDistance):(this._segmentLabel.text=null,this._horizontalLabel.text=null,this._verticalLabel.text=null),this.notifyChange("labels")}_updateLabelVisibility({visible:e,viewMode:t}){const i=this._segmentLabel,s=this._horizontalLabel,n=this._verticalLabel;if(i.visible=!1,s.visible=!1,n.visible=!1,e)switch(t){case 1:case 3:i.visible=!0;break;case 2:i.visible=!0,s.visible=!0,n.visible=!0}}get _labelsText(){if(this.destroyed)return null;const e=this.messages,t=this.analysisView.result;if(null==t||null==e)return null;const{directDistance:i,horizontalDistance:s,verticalDistance:n}=t,l=this.analysisView.unit,r=e=>({directDistance:"",horizontalDistance:"",verticalDistance:"",...e});switch(l){case"metric":return r({directDistance:i&&p(e,i),horizontalDistance:s&&p(e,s),verticalDistance:n&&g(e,n)});case"imperial":return r({directDistance:i&&m(e,i),horizontalDistance:s&&m(e,s),verticalDistance:n&&d(e,n)});default:return r({directDistance:i&&u(e,i,l),horizontalDistance:s&&u(e,s,l),verticalDistance:n&&u(e,n,l)})}}_updateSegmentStripeLength(e){const t=this._segmentVisualElement;null!=e?(t.stripeLength=e,t.stripesEnabled=!0):t.stripesEnabled=!1}get _actualVisualElementsOrientation(){if(null!=this._triangleOrientationOverride)return this._triangleOrientationOverride;const e=this.visualElementOrientation;return 0===e?this.view.state.camera.aboveGround?1:2:e}_requiresGeodesicGuideAt(e){const t=this.view;if(!t?.state)return!1;const i=t.state.camera,s=t.renderCoordsHelper;if(!s)return!1;const n=i.computeScreenPixelSizeAt(e);return s.getAltitude(e)/n>=10}get _measurementArrowStripeLength(){const{result:e,unit:t}=this.analysisView;if(null==e)return null;let i=null;const s=e.directDistance;switch(t){case"metric":i=s&&h(s,"meters");break;case"imperial":i=s&&h(s,y(s.value,s.unit));break;default:i=s&&h(s,t)}if(null==i)return null;return o(i.value/30)*S(1,i.unit,"meters")}_updateMessageBundle(){this.loadingMessages=!0,i("esri/core/t9n/Units").then(e=>{this.messages=e}).finally(()=>{this.loadingMessages=!1})}get testData(){}};function U(e,t,i,s,n){const l=M(e,i,n,B),r=M(e,t,n,W);if(null==l||null==r)return null;const o=n.projectToRenderScreen(i,Q),a=n.projectToRenderScreen(t,q),c={segment:"bottom",horizontal:"top",vertical:null==o||null==a||o[0]<a[0]?"left":"right"};if(V(l,r)>=F){const e=Math.sign(l[1])===Math.sign(r[1]);c.segment=e?j(c.vertical):c.vertical}else{const e=I;M(i,t,n,e),V(e,r)>=F&&(c.segment=Math.sign(e[0])===Math.sign(r[0])?j(c.horizontal):c.horizontal)}if(2===s){const e=e=>"top"===e?"bottom":"top";c.segment=e(c.segment),c.horizontal=e(c.horizontal),c.vertical=e(c.vertical)}return c}e([f()],T.prototype,"_parameters",null),e([f()],T.prototype,"_triangleOrientationOverride",void 0),e([f()],T.prototype,"messages",void 0),e([f()],T.prototype,"view",void 0),e([f()],T.prototype,"analysis",void 0),e([f()],T.prototype,"analysisView",void 0),e([f()],T.prototype,"loadingMessages",void 0),e([f()],T.prototype,"visible",null),e([f()],T.prototype,"viewMode",null),e([f()],T.prototype,"actualVisualizedMeasurement",null),e([f()],T.prototype,"visualElementOrientation",void 0),e([f()],T.prototype,"triangleCollapseRatioThreshold",void 0),e([f()],T.prototype,"allowVisualElementsOrientationChange",null),e([f()],T.prototype,"labels",null),e([f()],T.prototype,"_labelsText",null),e([f()],T.prototype,"_actualVisualElementsOrientation",null),e([f()],T.prototype,"_measurementArrowStripeLength",null),T=e([E("esri.views.3d.analysis.DirectLineMeasurement.DirectLineMeasurementVisualization")],T);const F=Math.cos(a(12)),Q=L(),q=L(),B=w(),W=w(),I=w();export{T as DirectLineMeasurementVisualization};
|
|
2
|
+
import{__decorate as e}from"tslib";import{onLocaleChange as t,fetchMessageBundle as i}from"../../../../intl.js";import s from"../../../../core/Accessor.js";import{multiplyOpacityToUnitRGBA as n,getContrast as l,multiplyOpacity as r}from"../../../../core/colorUtils.js";import"../../../../core/has.js";import{nextHighestPowerOfTen as o,deg2rad as a}from"../../../../core/mathUtils.js";import{destroyMaybe as c}from"../../../../core/maybe.js";import{toUnit as h}from"../../../../core/quantity.js";import{formatDecimal as u,formatImperialVerticalLength as d,formatImperialLength as m,formatMetricVerticalLength as g,formatMetricLength as p}from"../../../../core/quantityFormatUtils.js";import{watch as _,syncAndInitial as v,initial as b}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as L,createRenderScreenPointArray as w}from"../../../../core/screenUtils.js";import{adaptiveImperialLengthUnit as y,convertUnit as S}from"../../../../core/units.js";import{property as f,subclass as E}from"../../../../core/accessorSupport/decorators.js";import{dot as V}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{scale as z,add as A}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{renderScreenSpaceTangent as M}from"../../interactive/support/viewUtils.js";import{LabelVisualElement as C,mirrorPosition as j}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as O}from"../../interactive/visualElements/LineVisualElement.js";import{MeasurementArrowVisualElement as x}from"../../interactive/visualElements/MeasurementArrowVisualElement.js";import{RightAngleQuadVisualElement as D}from"../../interactive/visualElements/RightAngleQuadVisualElement.js";import{GeodesicSegment as G,EuclideanSegment as H}from"../../interactive/visualElements/support/Segment.js";import{createStipplePatternSimple as R}from"../../webgl-engine/materials/lineStippleUtils.js";import{geodeticDistanceThresholdMeters as k}from"../../../support/measurementWorkerUtils.js";let T=class extends s{get _parameters(){const e=this.view.effectiveTheme,{accentColor:t,textColor:i}=e,s=t.toUnitRGBA(),o=n(t,.75),a=l(t).toUnitRGBA(),c=l(i,160);return{accentColor:s,contrastColor:a,translucentAccentColor:o,triangleLineWidth:3,geodesicProjectionLineWidth:2,guideLineWidth:2,guideStippleLengthPixels:3,directLabelFontSize:16,horizontalLabelFontSize:12,verticalLabelFontSize:12,textColor:i,textBackgroundColor:r(c,.6),textCalloutColor:r(c,.5)}}get visible(){return this.analysisView.visible}get viewMode(){const{elevationAlignedStartPoint:e,elevationAlignedEndPoint:t}=this.analysisView;if(null==e||null==t||e.equals(t))return 0;const i=this.analysisView.result;if(null==i)return 1;if("geodesic"===this.actualVisualizedMeasurement)return this._requiresGeodesicGuideAt(this._startPosition)||this._requiresGeodesicGuideAt(this._endPosition)?3:1;const{verticalDistance:s,horizontalDistance:n}=i,l=h(s,"meters").value,r=h(n,"meters").value;return Math.min(l/r,r/l)<this.triangleCollapseRatioThreshold?1:2}get actualVisualizedMeasurement(){const{measurementMode:e,result:t}=this.analysisView;switch(e){case 0:return null!=t&&h(t.horizontalDistance,"meters").value>k?"geodesic":"euclidean";case 1:return"euclidean";case 2:return"geodesic"}}get allowVisualElementsOrientationChange(){return null==this._triangleOrientationOverride}set allowVisualElementsOrientationChange(e){null==this._triangleOrientationOverride!==e&&(null==this._triangleOrientationOverride?this._triangleOrientationOverride=this._actualVisualElementsOrientation:this._triangleOrientationOverride=null)}get labels(){return"geodesic"===this.actualVisualizedMeasurement?{direct:null,horizontal:this._segmentLabel,vertical:this._verticalLabel}:{direct:this._segmentLabel,horizontal:this._horizontalLabel,vertical:this._verticalLabel}}constructor(e){super(e),this._segmentVisualElement=null,this._triangleVisualElement=null,this._rightAngleQuad=null,this._projectedGeodesicLine=null,this._geodesicStartHint=null,this._geodesicEndHint=null,this._segmentLabel=null,this._verticalLabel=null,this._horizontalLabel=null,this._startPosition=P(),this._endPosition=P(),this._cornerPosition=P(),this._startPositionAtSeaLevel=P(),this._endPositionAtSeaLevel=P(),this._triangleOrientationOverride=null,this.messages=null,this.loadingMessages=!0,this.visualElementOrientation=0,this.triangleCollapseRatioThreshold=.03}initialize(){const e={attached:!0,view:this.view,isDecoration:!0},{guideLineWidth:i,guideStippleLengthPixels:s,triangleLineWidth:n,geodesicProjectionLineWidth:l,directLabelFontSize:r,verticalLabelFontSize:o,horizontalLabelFontSize:a}=this._parameters;this._segmentVisualElement=new x({...e,geometry:null,renderOccluded:4,transparentRenderOrder:2}),this._triangleVisualElement=new O({...e,width:n,renderOccluded:4,transparentRenderOrder:3}),this._rightAngleQuad=new D({...e,renderOccluded:4,transparentRenderOrder:4});const c={...e,polygonOffset:3,renderOccluded:4,transparentRenderOrder:1};this._projectedGeodesicLine=new O({...c,width:l,stipplePattern:R(s)}),this._geodesicStartHint=new O({...c,width:i,stipplePattern:R(s)}),this._geodesicEndHint=new O({...c,width:i,stipplePattern:R(s)}),this._segmentLabel=new C({...e,fontSize:r}),this._verticalLabel=new C({...e,fontSize:o}),this._horizontalLabel=new C({...e,fontSize:a}),this.addHandles([_(()=>{const{elevationAlignedStartPoint:e,elevationAlignedEndPoint:t}=this.analysisView,i=this.view;return{view:i,camera:i.state.camera,viewMode:this.viewMode,elevationAlignedStartPoint:e,elevationAlignedEndPoint:t,orientation:this._actualVisualElementsOrientation,visualizedMeasurement:this.actualVisualizedMeasurement,stripeLength:this._measurementArrowStripeLength}},e=>this._updateGeometryAndViewMode(e),v),_(()=>({visible:this.visible,viewMode:this.viewMode}),e=>this._updateVisualElementVisibility(e),v),_(()=>({text:this._labelsText,visualizedMeasurement:this.actualVisualizedMeasurement}),e=>this._updateLabelText(e),v),_(()=>({visible:this.visible,viewMode:this.viewMode}),e=>this._updateLabelVisibility(e),v),_(()=>this._measurementArrowStripeLength,e=>this._updateSegmentStripeLength(e),v),t(()=>this._updateMessageBundle()),_(()=>this._parameters,({textBackgroundColor:e,textCalloutColor:t,textColor:i,translucentAccentColor:s,accentColor:n,contrastColor:l})=>{const{_segmentLabel:r,_verticalLabel:o,_horizontalLabel:a,_triangleVisualElement:c,_rightAngleQuad:h,_projectedGeodesicLine:u,_geodesicStartHint:d,_geodesicEndHint:m,_segmentVisualElement:g}=this;r.backgroundColor=e,r.calloutColor=t,r.textColor=i,o.backgroundColor=e,o.calloutColor=t,o.textColor=i,a.backgroundColor=e,a.calloutColor=t,a.textColor=i,c.color=s,h.color=s,u.color=s,d.color=s,m.color=s,g.color=n,g.contrastColor=l},b)]),this._updateMessageBundle()}destroy(){this._segmentVisualElement=c(this._segmentVisualElement),this._triangleVisualElement=c(this._triangleVisualElement),this._rightAngleQuad=c(this._rightAngleQuad),this._projectedGeodesicLine=c(this._projectedGeodesicLine),this._geodesicStartHint=c(this._geodesicStartHint),this._geodesicEndHint=c(this._geodesicEndHint),this._segmentLabel=c(this._segmentLabel),this._verticalLabel=c(this._verticalLabel),this._horizontalLabel=c(this._horizontalLabel),this.set("view",null)}_updateVisualElementVisibility({visible:e,viewMode:t}){if(this._segmentVisualElement.visible=!1,this._triangleVisualElement.visible=!1,this._rightAngleQuad.visible=!1,this._projectedGeodesicLine.visible=!1,this._geodesicStartHint.visible=!1,this._geodesicEndHint.visible=!1,e)switch(t){case 0:break;case 1:this._segmentVisualElement.visible=!0;break;case 2:this._segmentVisualElement.visible=!0,this._triangleVisualElement.visible=!0,this._rightAngleQuad.visible=!0;break;case 3:this._segmentVisualElement.visible=!0,this._projectedGeodesicLine.visible=!0,this._geodesicStartHint.visible=!0,this._geodesicEndHint.visible=!0}}_updateGeometryAndViewMode({view:e,camera:t,viewMode:i,elevationAlignedStartPoint:s,elevationAlignedEndPoint:n,orientation:l,visualizedMeasurement:r,stripeLength:o}){const a=e.renderCoordsHelper;if(null==a||null==s||null==n||s.equals(n))return;let c=this._startPosition,h=this._endPosition;a.toRenderCoords(s,c),a.toRenderCoords(n,h);const u=1===l?1:-1,d=u*(a.getAltitude(h)-a.getAltitude(c));d<0&&(c=this._endPosition,h=this._startPosition);const m="geodesic"===r?new G(this._startPosition,this._endPosition,a.spatialReference):new H(this._startPosition,this._endPosition);switch(this._segmentVisualElement.geometry=m,this._updateSegmentStripeLength(o),i){case 1:this._updateSegment(m,l);break;case 2:this._updateSegmentAndTriangle({view:e,camera:t,segment:m,orientation:l,startPosition:c,endPosition:h,deltaSign:u,altitudeDelta:d});break;case 3:this._updateSegmentAndProjection({view:e,orientation:l,startPosition:c,endPosition:h})}}_updateSegment(e,t){this._segmentLabel.anchor=1===t?"top":"bottom",this._segmentLabel.geometry={type:"segment",segment:e,sampleLocation:"center"}}_updateSegmentAndTriangle({view:{renderCoordsHelper:e},camera:t,segment:i,orientation:s,startPosition:n,endPosition:l,deltaSign:r,altitudeDelta:o}){const a=this._cornerPosition;e.worldUpAtPosition(n,a),z(a,a,r*Math.abs(o)),A(a,a,n),this._triangleVisualElement.geometry=[[[n[0],n[1],n[2]],[a[0],a[1],a[2]],[l[0],l[1],l[2]]]],this._rightAngleQuad.geometry={previous:n,center:a,next:l};const c=new H(n,a),h=new H(a,l),u=U(n,l,a,s,t);u&&(this._segmentLabel.anchor=u.segment,this._segmentLabel.geometry={type:"segment",segment:i,sampleLocation:"center"},this._verticalLabel.geometry={type:"segment",segment:c,sampleLocation:"center"},this._verticalLabel.anchor=u.vertical,this._horizontalLabel.geometry={type:"segment",segment:h,sampleLocation:"center"},this._horizontalLabel.anchor=u.horizontal)}_updateSegmentAndProjection({view:{renderCoordsHelper:e},orientation:t,startPosition:i,endPosition:s}){e.setAltitude(this._startPositionAtSeaLevel,0,i),e.setAltitude(this._endPositionAtSeaLevel,0,s);const n=new G(this._startPositionAtSeaLevel,this._endPositionAtSeaLevel,e.spatialReference);this._projectedGeodesicLine.setGeometryFromSegment(n),this._geodesicStartHint.setGeometryFromSegment(new H(this._startPositionAtSeaLevel,i)),this._geodesicEndHint.setGeometryFromSegment(new H(this._endPositionAtSeaLevel,s)),this._segmentLabel.geometry={type:"segment",segment:n,sampleLocation:"center"},this._segmentLabel.anchor=1===t?"top":"bottom"}_updateLabelText({text:e,visualizedMeasurement:t}){null!=e?(this._segmentLabel.text="euclidean"===t?e.directDistance:e.horizontalDistance,this._horizontalLabel.text=e.horizontalDistance,this._verticalLabel.text=e.verticalDistance):(this._segmentLabel.text=null,this._horizontalLabel.text=null,this._verticalLabel.text=null),this.notifyChange("labels")}_updateLabelVisibility({visible:e,viewMode:t}){const i=this._segmentLabel,s=this._horizontalLabel,n=this._verticalLabel;if(i.visible=!1,s.visible=!1,n.visible=!1,e)switch(t){case 1:case 3:i.visible=!0;break;case 2:i.visible=!0,s.visible=!0,n.visible=!0}}get _labelsText(){if(this.destroyed)return null;const e=this.messages,t=this.analysisView.result;if(null==t||null==e)return null;const{directDistance:i,horizontalDistance:s,verticalDistance:n}=t,l=this.analysisView.unit,r=e=>({directDistance:"",horizontalDistance:"",verticalDistance:"",...e});switch(l){case"metric":return r({directDistance:i&&p(e,i),horizontalDistance:s&&p(e,s),verticalDistance:n&&g(e,n)});case"imperial":return r({directDistance:i&&m(e,i),horizontalDistance:s&&m(e,s),verticalDistance:n&&d(e,n)});default:return r({directDistance:i&&u(e,i,l),horizontalDistance:s&&u(e,s,l),verticalDistance:n&&u(e,n,l)})}}_updateSegmentStripeLength(e){const t=this._segmentVisualElement;null!=e?(t.stripeLength=e,t.stripesEnabled=!0):t.stripesEnabled=!1}get _actualVisualElementsOrientation(){if(null!=this._triangleOrientationOverride)return this._triangleOrientationOverride;const e=this.visualElementOrientation;return 0===e?this.view.state.camera.aboveGround?1:2:e}_requiresGeodesicGuideAt(e){const t=this.view;if(!t?.state)return!1;const i=t.state.camera,s=t.renderCoordsHelper;if(!s)return!1;const n=i.computeScreenPixelSizeAt(e);return s.getAltitude(e)/n>=10}get _measurementArrowStripeLength(){const{result:e,unit:t}=this.analysisView;if(null==e)return null;let i=null;const s=e.directDistance;switch(t){case"metric":i=s&&h(s,"meters");break;case"imperial":i=s&&h(s,y(s.value,s.unit));break;default:i=s&&h(s,t)}if(null==i)return null;return o(i.value/30)*S(1,i.unit,"meters")}_updateMessageBundle(){this.loadingMessages=!0,i("esri/core/t9n/Units").then(e=>{this.messages=e}).finally(()=>{this.loadingMessages=!1})}get testData(){}};function U(e,t,i,s,n){const l=M(e,i,n,B),r=M(e,t,n,W);if(null==l||null==r)return null;const o=n.projectToRenderScreen(i,Q),a=n.projectToRenderScreen(t,q),c={segment:"bottom",horizontal:"top",vertical:null==o||null==a||o[0]<a[0]?"left":"right"};if(V(l,r)>=F){const e=Math.sign(l[1])===Math.sign(r[1]);c.segment=e?j(c.vertical):c.vertical}else{const e=I;M(i,t,n,e),V(e,r)>=F&&(c.segment=Math.sign(e[0])===Math.sign(r[0])?j(c.horizontal):c.horizontal)}if(2===s){const e=e=>"top"===e?"bottom":"top";c.segment=e(c.segment),c.horizontal=e(c.horizontal),c.vertical=e(c.vertical)}return c}e([f()],T.prototype,"_parameters",null),e([f()],T.prototype,"_triangleOrientationOverride",void 0),e([f()],T.prototype,"messages",void 0),e([f()],T.prototype,"view",void 0),e([f()],T.prototype,"analysis",void 0),e([f()],T.prototype,"analysisView",void 0),e([f()],T.prototype,"loadingMessages",void 0),e([f()],T.prototype,"visible",null),e([f()],T.prototype,"viewMode",null),e([f()],T.prototype,"actualVisualizedMeasurement",null),e([f()],T.prototype,"visualElementOrientation",void 0),e([f()],T.prototype,"triangleCollapseRatioThreshold",void 0),e([f()],T.prototype,"allowVisualElementsOrientationChange",null),e([f()],T.prototype,"labels",null),e([f()],T.prototype,"_labelsText",null),e([f()],T.prototype,"_actualVisualElementsOrientation",null),e([f()],T.prototype,"_measurementArrowStripeLength",null),T=e([E("esri.views.3d.analysis.DirectLineMeasurement.DirectLineMeasurementVisualization")],T);const F=Math.cos(a(12)),Q=L(),q=L(),B=w(),W=w(),I=w();export{T as DirectLineMeasurementVisualization};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import{destroyMaybe as a,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as r,when as l,syncAndInitial as o}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{createScreenPoint as p,screenPointObjectToArray as u}from"../../../../core/screenUtils.js";import{property as c,subclass as d}from"../../../../core/accessorSupport/decorators.js";import{fromRotation as _,fromScaling as v,multiply as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{dot as y,length as P,copy as w,scale as f,add as g,transformMat4 as M,normalize as V,set as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as T,create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as k,ZEROS as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{d as E,c as S,n as C,f as j}from"../../../../chunks/boundedPlane.js";import{signedDistance as H,create as R,intersectRay as z,getNormal as O}from"../../../../geometry/support/plane.js";import{create as G}from"../../../../geometry/support/ray.js";import{sv3d as U,sm4d as I,sv2d as K}from"../../../../geometry/support/vectorStacks.js";import{getSliceableContainer as A}from"../../../../graphic/getSliceableContainer.js";import{getRotateHeadingTexture as F,getTiltRotateTexture as B}from"../images/Factory.js";import{getOutlineColor as L,planeColor as q}from"./settings.js";import{pointerMoveTimerMs as N,planePreviewOutlineWidth as J,forceVerticalModifier as Q,forceHorizontalModifier as W,previewFadeDurationSeconds as X,previewFadeDotThreshold as Y,initialDepthOffsetFrac as Z}from"./sliceToolConfig.js";import{createGridVisualElement as $,createOutlineVisualElement as tt,planeToShape as et,createRotatePlane as it,resizePlane as at,calculatePlaneHalfSize as st,createPlane as nt,DidPointerMoveRecentlyFlag as rt,calculateBoundedPlaneTranslateRotate as lt,updateShiftRestartHandle as ot,updateRotateHeadingHandle as ht,updateRotateTiltHandle as pt,updateResizeHandle as ut,createShiftPlane as ct}from"./sliceToolUtils.js";import{calculateInputRotationTransform as dt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as _t}from"../../interactive/editingTools/dragEventPipeline3D.js";import{ResizeManipulator as vt}from"../../interactive/manipulators/ResizeManipulator.js";import{RotateManipulator as mt}from"../../interactive/manipulators/RotateManipulator.js";import{ShiftManipulator as yt}from"../../interactive/manipulators/ShiftManipulator.js";import{fromScreenNormalized as Pt}from"../../support/geometryUtils/ray.js";import{AnalysisToolBase as wt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as ft}from"../../../interactive/dragEventPipeline.js";import{newToolIntersector as gt}from"../../../interactive/ToolIntersector.js";import{createScreenPointFromEvent as Mt}from"../../../support/screenUtils.js";var Vt;let bt=class extends wt{static{Vt=this}constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.multiTouchEnabled=!1,this.removeIncompleteOnCancel=!1,this._mode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._frameTask=null,this._pointerMoveTimerMs=N,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=E(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=p(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=gt(t.view.state.viewingMode)}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&S(this.analysisViewData.plane,this._startPlane),this.inputState=null)},e=new yt(this.view,1);this.shiftManipulator=e,this.manipulators.add(e),this.addHandles([this._createShiftDragPipeline(e),e.events.on("grab-changed",i=>{this._onShiftGrab(i),t(e)})]);const i=!this.view.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,a=new mt(this.view,(t,e)=>F(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateHeadingManipulator=a,this.manipulators.add(a),this.addHandles([this._createRotateHeadingDragPipeline(a),a.events.on("grab-changed",e=>{this._onRotateHeadingGrab(e),t(a)})]);const s=new mt(this.view,(t,e)=>B(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateTiltManipulator=s,this.manipulators.add(s),this.addHandles([this._createRotateTiltDragPipeline(s),s.events.on("grab-changed",e=>{this._onRotateTiltGrab(e),t(s)})]),this.resizeManipulators=this._resizeHandles.map((e,i)=>{const a=new vt(this.view,e);return this.addHandles([this._createResizeDragPipeline(a),a.events.on("grab-changed",e=>{this._onResizeGrab(e,i),t(a)})]),a}),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=$(this.view),this._previewPlaneOutlineVisualElement=tt(this.view),this._previewPlaneOutlineVisualElement.width=J,this.addHandles(n(()=>[this.analysisViewData.plane,this.analysis.tiltEnabled],()=>this._updateManipulators(),r)),this.addHandles([l(()=>"sliced"===this.state,()=>{this.finishToolCreation(),this.stop()},o),n(()=>this.view.state.camera,()=>this._onCameraChange())])}destroy(){this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=a(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=a(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this.active&&(this._placingSlicePlane||"exclude"===this.mode)?"crosshair":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this.removeHandles("analysis"),this._set("analysis",t)}get mode(){return this._mode}static{this.disableEngineLayers=!1}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _placingSlicePlane(){return this.active&&!this.inputState&&"place"===this._mode}start(t){this._finishToolCreationIfValid(),this._mode=t,this.active||(this.view.activeTool=this)}stop(){this.active&&(this.view.activeTool=null)}onActivate(){this._finishToolCreationIfValid(),"none"===this._mode&&null==this.analysisViewData.plane&&(this._mode="place")}onDeactivate(){this._mode="none",this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-move":this._onPointerMove(t);break;case"immediate-click":if(!Dt(t))return;"exclude"===this._mode?t.defer(async()=>{await this._onClickExcludeLayer(t)&&t.stopPropagation()}):this._onClickPlacePlane(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Mt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onClickPlacePlane(t){if(!this._placingSlicePlane)return!1;const i=Mt(t),a=E();return!!this._pickPlane(i,!1,this._activeKeyModifiers,a)&&(S(a,this._startPlane),this.analysis.shape=et(a,this.view,this.view.spatialReference,new e),this.stop(),!0)}async _onClickExcludeLayer(t){if("exclude"!==this.mode)return!1;const e=await this.view.hitTest(Mt(t)),i=e.results.at(0);if(i){const t="graphic"===i.type&&i.graphic;if(t){const e=A(t.origin)??t.sourceLayer??t.layer;e&&"subtype-sublayer"!==e.type&&this.analysis.excludedLayers.push(e)}}else e.ground.layer?this.analysis.excludedLayers.push(e.ground.layer):this.analysis.excludeGroundSurface=!0;return this.stop(),!0}_onKeyDown(t){return(t.key===Q||t.key===W)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==Q&&t.key!==W||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=Pt(this.view.state.camera,t.screenPoint,xt);S(this.analysisViewData.plane,this._startPlane),this.inputState=Tt(e,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,E()):null;e.next(_t(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(y(C(this.analysisViewData.plane),e.ray.direction)/P(e.ray.direction)))/i,1),s=-H(this._startPlane.plane,e.renderEnd),n=-H(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=w(U.get(),this._startPlane.origin),i=w(U.get(),C(this._startPlane));f(i,i,-t.depth),g(i,i,e);const a=j(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,E());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=it(this.analysisViewData.plane,this.view.renderCoordsHelper,1,R()),i=Pt(this.view.state.camera,t.screenPoint,xt),a=D();z(e,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,E()):null;e.next(_t(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=it(this.analysisViewData.plane,this.view.renderCoordsHelper,2,R()),i=Pt(this.view.state.camera,t.screenPoint,xt),a=D();z(e,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,E()):null;e.next(_t(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=O(t.rotatePlane),a=dt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=_(I.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=M(U.get(),this._startPlane.basis1,e),a=M(U.get(),this._startPlane.basis2,e),s=j(this.analysisViewData.plane.origin,i,a,E());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=Pt(this.view.state.camera,t.screenPoint,xt),a=U.get();z(this.analysisViewData.plane.plane,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:T(a)})}_createResizeDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=S(this.analysisViewData.plane,E());e.next(_t(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next(()=>{this._updateBoundedPlane(s)})})}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=at(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,S(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){if("exclude"===this.mode)return;let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(this.active){const a=null!=i?i:E();if(i=null!=i?S(i,kt):null,this._pickPlane(t,!0,e,a)){const t=Y;let e=!1;null!=i&&(e=y(O(i.plane),O(a.plane))<t||y(V(U.get(),i.basis1),V(U.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=h({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*X),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=s(this._frameTask)}_pickMinResult(t){const e=u(t,K.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=U.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(U.get()),l=this.view.state.camera;y(r,l.viewForward)>0&&f(r,r,-1);const o=st(n,l),h=(e?1:-1)*o*Z,p=f(U.get(),r,h);g(p,p,n);const u=this.analysis.tiltEnabled?3:0,c=i[Q]?2:i[W]?1:u;return nt(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=s(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=rt,this.rotateHeadingManipulator.state|=rt,this.rotateTiltManipulator.state|=rt,this._prevPointerMoveTimeout=this._clock.setTimeout(()=>{this.shiftManipulator.state&=~rt,this.rotateHeadingManipulator.state&=~rt,this.rotateTiltManipulator.state&=~rt},this._pointerMoveTimerMs)}_updateManipulators(){if(Vt.disableEngineLayers)return;let t,e,i=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=this._previewPlane??t,i=!1;else{if(null==this._previewPlane)return this._setManipulatorVisibility(!1),void this._setPreviewPlaneVisibility(!1);e=t=this._previewPlane,i=!0}if(this._setManipulatorVisibility(!i),!i){const e=lt(t,I.get());ot(this.shiftManipulator,e,t,this.view.state.camera),ht(this.rotateHeadingManipulator,e,t,this.view.renderCoordsHelper),pt(this.rotateTiltManipulator,e,t),this.resizeManipulators.forEach((i,a)=>ut(i,this._resizeHandles[a],e,t))}this._setPreviewPlaneVisibility(i||"place"===this._mode),this._updatePreviewPlaneTransform(e),this._updateMaterials()}_setManipulatorVisibility(t){this.shiftManipulator.available=t,this.rotateHeadingManipulator.available=t,this.rotateTiltManipulator.available=t&&this.analysis.tiltEnabled,this.resizeManipulators.forEach(e=>e.available=t)}_updatePreviewPlaneTransform(t){const e=lt(t,I.get()),i=b(U.get(),P(t.basis1),P(t.basis2),1),a=v(I.get(),i),s=m(a,e,a);this._previewPlaneOutlineVisualElement.transform=s,this._previewPlaneGridVisualElement.transform=s}_setPreviewPlaneVisibility(t){const e=this._previewPlaneOutlineVisualElement,i=this._previewPlaneGridVisualElement;t&&(e.attached=!0,i.attached=!0),e.visible=t,i.visible=t}_updateMaterials(){const t=L(this.view.effectiveTheme);t[3]*=this._previewPlaneOpacity;const e=k(q);e[3]*=this._previewPlaneOpacity,this._previewPlaneOutlineVisualElement.color=t,this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=x}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach(t=>{t.interactive=!0});this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach(e=>{e.interactive=e===t})}_finishToolCreationIfValid(){this.analysis.valid&&this.finishToolCreation()}get test(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function Tt(t,e,i){const a=ct(e,C(i),t.direction,R()),s=D();return z(a,t,s)?{type:"shift",shiftPlane:a,depth:0,startPoint:s}:null}function Dt(t){return"mouse"!==t.pointerType||0===t.button}t([c()],bt.prototype,"_clock",void 0),t([c({constructOnly:!0})],bt.prototype,"view",void 0),t([c()],bt.prototype,"analysisViewData",void 0),t([c({readOnly:!0})],bt.prototype,"state",null),t([c({readOnly:!0})],bt.prototype,"cursor",null),t([c()],bt.prototype,"analysis",null),t([c()],bt.prototype,"multiTouchEnabled",void 0),t([c()],bt.prototype,"removeIncompleteOnCancel",void 0),t([c()],bt.prototype,"_mode",void 0),t([c()],bt.prototype,"mode",null),t([c({value:null})],bt.prototype,"inputState",null),t([c()],bt.prototype,"_placingSlicePlane",null),bt=Vt=t([d("esri.views.3d.analysis.Slice.SliceTool")],bt);const kt=E(),xt=G();export{bt as default};
|
|
2
|
+
import{__decorate as t}from"tslib";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import{destroyMaybe as a,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as r,when as l,syncAndInitial as o}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{createScreenPoint as p,screenPointObjectToArray as u}from"../../../../core/screenUtils.js";import{property as c,subclass as d}from"../../../../core/accessorSupport/decorators.js";import{fromRotation as _,fromScaling as v,multiply as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{dot as y,length as P,copy as w,scale as f,add as g,transformMat4 as M,normalize as V,set as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as T,create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as k,ZEROS as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{d as E,c as S,n as C,f as j}from"../../../../chunks/boundedPlane.js";import{signedDistance as H,create as R,intersectRay as z,getNormal as O}from"../../../../geometry/support/plane.js";import{create as G}from"../../../../geometry/support/ray.js";import{sv3d as U,sm4d as I,sv2d as K}from"../../../../geometry/support/vectorStacks.js";import{getSliceableContainer as A}from"../../../../graphic/getSliceableContainer.js";import{getRotateHeadingTexture as F,getTiltRotateTexture as B}from"../images/Factory.js";import{getOutlineColor as L,planeColor as q}from"./settings.js";import{pointerMoveTimerMs as N,planePreviewOutlineWidth as J,forceVerticalModifier as Q,forceHorizontalModifier as W,previewFadeDurationSeconds as X,previewFadeDotThreshold as Y,initialDepthOffsetFrac as Z}from"./sliceToolConfig.js";import{createGridVisualElement as $,createOutlineVisualElement as tt,planeToShape as et,createRotatePlane as it,resizePlane as at,calculatePlaneHalfSize as st,createPlane as nt,DidPointerMoveRecentlyFlag as rt,calculateBoundedPlaneTranslateRotate as lt,updateShiftRestartHandle as ot,updateRotateHeadingHandle as ht,updateRotateTiltHandle as pt,updateResizeHandle as ut,createShiftPlane as ct}from"./sliceToolUtils.js";import{calculateInputRotationTransform as dt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as _t}from"../../interactive/editingTools/dragEventPipeline3D.js";import{ResizeManipulator as vt}from"../../interactive/manipulators/ResizeManipulator.js";import{RotateManipulator as mt}from"../../interactive/manipulators/RotateManipulator.js";import{ShiftManipulator as yt}from"../../interactive/manipulators/ShiftManipulator.js";import{fromScreenNormalized as Pt}from"../../support/geometryUtils/ray.js";import{AnalysisToolBase as wt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as ft}from"../../../interactive/dragEventPipeline.js";import{newToolIntersector as gt}from"../../../interactive/ToolIntersector.js";import{createScreenPointFromEvent as Mt}from"../../../support/screenUtils.js";var Vt;let bt=class extends wt{static{Vt=this}constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.multiTouchEnabled=!1,this.removeIncompleteOnCancel=!1,this._mode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._frameTask=null,this._pointerMoveTimerMs=N,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=E(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=p(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=gt(t.view.state.viewingMode)}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&S(this.analysisViewData.plane,this._startPlane),this.inputState=null)},e=new yt(this.view,1);this.shiftManipulator=e,this.manipulators.add(e),this.addHandles([this._createShiftDragPipeline(e),e.events.on("grab-changed",i=>{this._onShiftGrab(i),t(e)})]);const i=!this.view.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,a=new mt(this.view,(t,e)=>F(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateHeadingManipulator=a,this.manipulators.add(a),this.addHandles([this._createRotateHeadingDragPipeline(a),a.events.on("grab-changed",e=>{this._onRotateHeadingGrab(e),t(a)})]);const s=new mt(this.view,(t,e)=>B(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateTiltManipulator=s,this.manipulators.add(s),this.addHandles([this._createRotateTiltDragPipeline(s),s.events.on("grab-changed",e=>{this._onRotateTiltGrab(e),t(s)})]),this.resizeManipulators=this._resizeHandles.map((e,i)=>{const a=new vt(this.view,e);return this.addHandles([this._createResizeDragPipeline(a),a.events.on("grab-changed",e=>{this._onResizeGrab(e,i),t(a)})]),a}),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=$(this.view),this._previewPlaneOutlineVisualElement=tt(this.view),this._previewPlaneOutlineVisualElement.width=J,this.addHandles(n(()=>[this.analysisViewData.plane,this.analysis.tiltEnabled],()=>this._updateManipulators(),r)),this.addHandles([l(()=>"sliced"===this.state,()=>{this.finishToolCreation(),this.stop()},o),n(()=>this.view.state.camera,()=>this._onCameraChange())])}destroy(){this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=a(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=a(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this.active&&(this._placingSlicePlane||"exclude"===this.mode)?"crosshair":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this.removeHandles("analysis"),this._set("analysis",t)}get mode(){return this._mode}static{this.disableEngineLayers=!1}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _placingSlicePlane(){return this.active&&!this.inputState&&"place"===this._mode}start(t){this._finishToolCreationIfValid(),this._mode=t,this.active||(this.view.activeTool=this)}stop(){this.active&&(this.view.activeTool=null)}onActivate(){this._finishToolCreationIfValid(),"none"===this._mode&&null==this.analysisViewData.plane&&(this._mode="place")}onDeactivate(){this._mode="none",this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-move":this._onPointerMove(t);break;case"immediate-click":if(!Dt(t))return;"exclude"===this._mode?t.defer(async()=>{await this._onClickExcludeLayer(t)&&t.stopPropagation()}):this._onClickPlacePlane(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Mt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onClickPlacePlane(t){if(!this._placingSlicePlane)return!1;const i=Mt(t),a=E();return!!this._pickPlane(i,!1,this._activeKeyModifiers,a)&&(S(a,this._startPlane),this.analysis.shape=et(a,this.view,this.view.spatialReference,new e),this.stop(),!0)}async _onClickExcludeLayer(t){if("exclude"!==this.mode)return!1;const e=await this.view.hitTest(Mt(t)),i=e.results.at(0);if(i){const t=("graphic"===i.type?A(i.graphic.origin)??i.graphic.sourceLayer??null:null)??i.layer;t&&"subtype-sublayer"!==t.type&&this.analysis.excludedLayers.push(t)}else e.ground.layer?this.analysis.excludedLayers.push(e.ground.layer):this.analysis.excludeGroundSurface=!0;return this.stop(),!0}_onKeyDown(t){return(t.key===Q||t.key===W)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==Q&&t.key!==W||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=Pt(this.view.state.camera,t.screenPoint,xt);S(this.analysisViewData.plane,this._startPlane),this.inputState=Tt(e,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,E()):null;e.next(_t(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(y(C(this.analysisViewData.plane),e.ray.direction)/P(e.ray.direction)))/i,1),s=-H(this._startPlane.plane,e.renderEnd),n=-H(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=w(U.get(),this._startPlane.origin),i=w(U.get(),C(this._startPlane));f(i,i,-t.depth),g(i,i,e);const a=j(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,E());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=it(this.analysisViewData.plane,this.view.renderCoordsHelper,1,R()),i=Pt(this.view.state.camera,t.screenPoint,xt),a=D();z(e,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,E()):null;e.next(_t(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=it(this.analysisViewData.plane,this.view.renderCoordsHelper,2,R()),i=Pt(this.view.state.camera,t.screenPoint,xt),a=D();z(e,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,E()):null;e.next(_t(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=O(t.rotatePlane),a=dt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=_(I.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=M(U.get(),this._startPlane.basis1,e),a=M(U.get(),this._startPlane.basis2,e),s=j(this.analysisViewData.plane.origin,i,a,E());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=Pt(this.view.state.camera,t.screenPoint,xt),a=U.get();z(this.analysisViewData.plane.plane,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:T(a)})}_createResizeDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=S(this.analysisViewData.plane,E());e.next(_t(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next(()=>{this._updateBoundedPlane(s)})})}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=at(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,S(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){if("exclude"===this.mode)return;let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(this.active){const a=null!=i?i:E();if(i=null!=i?S(i,kt):null,this._pickPlane(t,!0,e,a)){const t=Y;let e=!1;null!=i&&(e=y(O(i.plane),O(a.plane))<t||y(V(U.get(),i.basis1),V(U.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=h({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*X),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=s(this._frameTask)}_pickMinResult(t){const e=u(t,K.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=U.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(U.get()),l=this.view.state.camera;y(r,l.viewForward)>0&&f(r,r,-1);const o=st(n,l),h=(e?1:-1)*o*Z,p=f(U.get(),r,h);g(p,p,n);const u=this.analysis.tiltEnabled?3:0,c=i[Q]?2:i[W]?1:u;return nt(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=s(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=rt,this.rotateHeadingManipulator.state|=rt,this.rotateTiltManipulator.state|=rt,this._prevPointerMoveTimeout=this._clock.setTimeout(()=>{this.shiftManipulator.state&=~rt,this.rotateHeadingManipulator.state&=~rt,this.rotateTiltManipulator.state&=~rt},this._pointerMoveTimerMs)}_updateManipulators(){if(Vt.disableEngineLayers)return;let t,e,i=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=this._previewPlane??t,i=!1;else{if(null==this._previewPlane)return this._setManipulatorVisibility(!1),void this._setPreviewPlaneVisibility(!1);e=t=this._previewPlane,i=!0}if(this._setManipulatorVisibility(!i),!i){const e=lt(t,I.get());ot(this.shiftManipulator,e,t,this.view.state.camera),ht(this.rotateHeadingManipulator,e,t,this.view.renderCoordsHelper),pt(this.rotateTiltManipulator,e,t),this.resizeManipulators.forEach((i,a)=>ut(i,this._resizeHandles[a],e,t))}this._setPreviewPlaneVisibility(i||"place"===this._mode),this._updatePreviewPlaneTransform(e),this._updateMaterials()}_setManipulatorVisibility(t){this.shiftManipulator.available=t,this.rotateHeadingManipulator.available=t,this.rotateTiltManipulator.available=t&&this.analysis.tiltEnabled,this.resizeManipulators.forEach(e=>e.available=t)}_updatePreviewPlaneTransform(t){const e=lt(t,I.get()),i=b(U.get(),P(t.basis1),P(t.basis2),1),a=v(I.get(),i),s=m(a,e,a);this._previewPlaneOutlineVisualElement.transform=s,this._previewPlaneGridVisualElement.transform=s}_setPreviewPlaneVisibility(t){const e=this._previewPlaneOutlineVisualElement,i=this._previewPlaneGridVisualElement;t&&(e.attached=!0,i.attached=!0),e.visible=t,i.visible=t}_updateMaterials(){const t=L(this.view.effectiveTheme);t[3]*=this._previewPlaneOpacity;const e=k(q);e[3]*=this._previewPlaneOpacity,this._previewPlaneOutlineVisualElement.color=t,this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=x}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach(t=>{t.interactive=!0});this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach(e=>{e.interactive=e===t})}_finishToolCreationIfValid(){this.analysis.valid&&this.finishToolCreation()}get test(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function Tt(t,e,i){const a=ct(e,C(i),t.direction,R()),s=D();return z(a,t,s)?{type:"shift",shiftPlane:a,depth:0,startPoint:s}:null}function Dt(t){return"mouse"!==t.pointerType||0===t.button}t([c()],bt.prototype,"_clock",void 0),t([c({constructOnly:!0})],bt.prototype,"view",void 0),t([c()],bt.prototype,"analysisViewData",void 0),t([c({readOnly:!0})],bt.prototype,"state",null),t([c({readOnly:!0})],bt.prototype,"cursor",null),t([c()],bt.prototype,"analysis",null),t([c()],bt.prototype,"multiTouchEnabled",void 0),t([c()],bt.prototype,"removeIncompleteOnCancel",void 0),t([c()],bt.prototype,"_mode",void 0),t([c()],bt.prototype,"mode",null),t([c({value:null})],bt.prototype,"inputState",null),t([c()],bt.prototype,"_placingSlicePlane",null),bt=Vt=t([d("esri.views.3d.analysis.Slice.SliceTool")],bt);const kt=E(),xt=G();export{bt as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../../../intl.js";import{volumeMeasurementConfiguration as o}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import r from"../../../../core/Accessor.js";import{equals as n}from"../../../../core/arrayUtils.js";import{cyclicalPI as l}from"../../../../core/Cyclical.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import{formatDecimal as c,preferredVolumePrecision as u}from"../../../../core/quantityFormatUtils.js";import{watch as m,initial as d}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as h}from"../../../../core/units.js";import{property as p,subclass as g}from"../../../../core/accessorSupport/decorators.js";import{e as y}from"../../../../chunks/earcut.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f,normalize as v,subtract as j,cross as L,dot as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as G}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as V}from"../../../../geometry/support/Indices.js";import{angleAroundAxis as x}from"../../../../geometry/support/vector.js";import{t as R}from"../../../../chunks/vec3.js";import A from"../../../../symbols/support/ElevationInfo.js";import{LabelVisualElement as M}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as O}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as D}from"../../interactive/visualElements/OutlineVisualElement.js";import{EuclideanSegment as F}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as E}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as U}from"../../layers/graphics/extrudeUtils.js";import{polygonToRenderInfo as S}from"../../support/renderInfoUtils/polygon.js";import{CutFillVisualizationRenderNode as N,VolumeGeometry as B}from"../../webgl-engine/lib/CutFillVisualizationRenderNode.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";let T=class extends r{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get updating(){return this.loadingMessages}get hasUnsupportedError(){const{error:e}=this.analysisViewData;return!!e&&["unsupported-coordinate-system","unsupported-layer-transparency"].includes(e.name)}get _extrusionHeights(){const{renderCoordsHelper:e}=this.view,{depthExtremaPositions:t,targetGeometry:i}=this.analysisViewData,{targetElevationRange:s}=o;if(!i||!t)return{cut:s,fill:-s};let r=-1/0;for(const o of i.rings)for(const e of o)r=Math.max(r,e[2]);const n=1,l=e.getAltitude(t.fill);return{cut:s,fill:Math.min(l-r,0)-n}}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._elevationContext=E.fromElevationInfo(new A({mode:"absolute-height"})),this._projectionLines=[]}initialize(){const{view:e}=this,i={view:e,isDecoration:!0},s=o,r={...i,width:s.geometryOutlineWidth};this._elevationAlignedGeometry=new D({...r,isDraped:!0,color:s.geometryOutlineColor.toUnitRGBA()}),this._targetGeometry=new D(r);const n={...i,attached:!0,width:s.projectionLineWidth,renderOccluded:4,polygonOffset:!0},l={...n,stipplePattern:H(s.projectionLineStippleSize)},a=s.cutProjectionLineColor.toUnitRGBA(),c=s.fillProjectionLineColor.toUnitRGBA();this._cutProjectionLines=new O({...n,color:a}),this._occludedCutProjectionLines=new O({...l,color:a}),this._fillProjectionLines=new O({...n,color:c}),this._occludedFillProjectionLines=new O({...l,color:c});const u={...i,attached:!0};this._cutVolumeLabel=new M({...u,distance:s.labelDistance}),this._fillVolumeLabel=new M({...u,distance:-s.labelDistance}),this._renderNode=new N({view:e,cutColor:s.cutColor,fillColor:s.fillColor,borderColor:s.geometryOutlineColor}),this.addHandles([m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry}),({elevationAlignedGeometry:e,targetGeometry:t})=>{this._elevationAlignedGeometry.geometry=e,this._targetGeometry.geometry=t},d),m(()=>({interactive:this.analysisViewData.interactive,measureType:this.analysis.measureType,visible:this.visible}),({visible:e,interactive:t,measureType:i})=>{this._elevationAlignedGeometry.visible=e&&!t,this._targetGeometry.visible=e&&"cut-fill"===i,this._renderNode.measureType=i},d),m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry,visible:this.visible}),({elevationAlignedGeometry:e,targetGeometry:t,visible:i})=>this._updateProjectionLines(e,t,i),d),m(()=>({interactive:this.analysisViewData.interactive,accentColor:this.view.effectiveTheme.accentColor,hasResult:!!this.analysisViewData.result}),({interactive:e,accentColor:t,hasResult:i})=>{this._updateColors(e,t,i)},d),m(()=>[this.analysisViewData.targetGeometry,this._extrusionHeights],()=>this._updateCutFillGeometry(),d),m(()=>this.visible&&this.view.state.camera.aboveGround&&!this.hasUnsupportedError,e=>this._updateCutFillVisibility(e),d),m(()=>{const{messages:e,unitsMessages:t,visible:i,analysisViewData:s}=this;return{depthExtremaPositions:s.depthExtremaPositions,effectiveDisplayUnits:s.effectiveDisplayUnits,messages:e,unitsMessages:t,result:s.result,visible:i&&!!s.result}},e=>this._updateLabels(e)),m(()=>this.view.state.camera,e=>this._updateProjectionLineOcclusion(e),d),t(()=>this._updateMessageBundle())]),this._updateMessageBundle()}destroy(){this._elevationAlignedGeometry=a(this._elevationAlignedGeometry),this._targetGeometry=a(this._targetGeometry),this._cutProjectionLines=a(this._cutProjectionLines),this._occludedCutProjectionLines=a(this._occludedCutProjectionLines),this._fillProjectionLines=a(this._fillProjectionLines),this._occludedFillProjectionLines=a(this._occludedFillProjectionLines),this._cutVolumeLabel=a(this._cutVolumeLabel),this._fillVolumeLabel=a(this._fillVolumeLabel),this._renderNode.destroy()}_updateProjectionLines(e,t,i){if(this._cutProjectionLines.visible=i,this._occludedCutProjectionLines.visible=i,this._fillProjectionLines.visible=i,this._occludedFillProjectionLines.visible=i,!e||!t)return;const{renderCoordsHelper:s}=this.view,o=[],r=[],l=[],a=[],c=[],u=e.spatialReference;for(let m=0;m<e.rings.length;m++){const i=e.rings[m],d=i.length>1&&n(i[0],i[i.length-1]),h=i.length-(d?1:0),p=[];for(let e=0;e<h;++e){const o=i[e],r=f(C(),o[0],o[1],o[2]);s.toRenderCoords(r,u,r);const n=t.rings[m][e],l=f(C(),n[0],n[1],n[2]);s.toRenderCoords(l,u,l);const a=new F(r,l);p.push(a)}const g=this.view.state.camera;for(let s=0;s<p.length;++s){const i=p[s],n=p[0===s?p.length-1:s-1],u=p[s===p.length-1?0:s+1],d=e.rings[m][s],h=t.rings[m][s],y=d[2]>h[2],_=new I(i,n,u,y);o.push(_),_.updateOccluded(g);const f=_.isOccluded;y?(f?l:r).push(i):(f?c:a).push(i)}}this._projectionLines=o,this._cutProjectionLines.setGeometryFromSegments(r),this._occludedCutProjectionLines.setGeometryFromSegments(l),this._fillProjectionLines.setGeometryFromSegments(a),this._occludedFillProjectionLines.setGeometryFromSegments(c)}_updateProjectionLineOcclusion(e){const t=[],i=[],s=[],o=[];let r=!1,n=!1;for(const l of this._projectionLines){l.updateOccluded(e)&&(r||=l.isCut,n||=!l.isCut);const a=l.isOccluded;(l.isCut?a?i:t:a?o:s).push(l.segment)}n&&(this._fillProjectionLines.setGeometryFromSegments(s),this._occludedFillProjectionLines.setGeometryFromSegments(o)),r&&(this._cutProjectionLines.setGeometryFromSegments(t),this._occludedCutProjectionLines.setGeometryFromSegments(i))}_updateColors(e,t,i){const{geometryOutlineColor:s,cutColor:r,fillColor:n,cutColorMuted:l,fillColorMuted:a,cutProjectionLineColor:c,fillProjectionLineColor:u}=o;if(this._renderNode.cutColor=i?r:l,this._renderNode.fillColor=i?n:a,e){const e=t.toUnitRGBA();this._targetGeometry.color=e,this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e,this._fillProjectionLines.color=e,this._occludedFillProjectionLines.color=e,this._renderNode.borderColor=t}else{this._targetGeometry.color=s.toUnitRGBA();const e=(i?c:l).toUnitRGBA();this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e;const t=(i?u:a).toUnitRGBA();this._fillProjectionLines.color=t,this._occludedFillProjectionLines.color=t,this._renderNode.borderColor=s}}_updateLabels(e){const{effectiveDisplayUnits:t,depthExtremaPositions:s,messages:o,unitsMessages:r,result:n,visible:l}=e;if(this._cutVolumeLabel.visible=l,this._fillVolumeLabel.visible=l,this._cutVolumeLabel.geometry=s?{type:"point",point:s.cut}:null,this._fillVolumeLabel.geometry=s?{type:"point",point:s.fill}:null,null==n||null==o||null==r)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const a=t.volume,c=i(o.labels.cut,{volume:z(r,n.cutVolume,a)}),u=i(o.labels.fill,{volume:z(r,n.fillVolume,a)});this._cutVolumeLabel.text=c,this._fillVolumeLabel.text=u}_updateCutFillVisibility(e){e?this._renderNode.enable():this._renderNode.disable()}_updateCutFillGeometry(){const{renderCoordsHelper:e}=this.view,{targetGeometry:t}=this.analysisViewData,{cut:i,fill:s}=this._extrusionHeights;if(!t?.extent)return;const{center:o}=t.extent,r=w(o.x,o.y,0),n=C();e.toRenderCoords(r,t.spatialReference,n);const l=this._getExtrudedVolumes(t,i,r,n),a=this._getExtrudedVolumes(t,s,r,n);this._renderNode.updateGeometries(l,a,n)}_getExtrudedVolumes(e,t,i,s){const{renderCoordsHelper:o,spatialReference:r,elevationProvider:n}=this.view,l=C(),a=1===o.viewingMode;o.worldUpAtPosition(s,l);const c=S(e,n,o,this._elevationContext),{polygons:u,mapPositions:m,position:d}=c;return u.map(e=>{const s=e.count,n=y(e.mapPositions,e.holeIndices,3),c=n.length,u=6*s,h=V(u+c),p=V(c),g=G(3*u),f=G(3*u);U(d,m,n,e,g,null,f,null,h,p,t,l,a);const v=_(),j=_();if(P(r,i,v,o.spatialReference),j[12]=-v[12],j[13]=-v[13],j[14]=-v[14],R(g,g,j),"stockpile"===this.analysis.measureType)for(let t=0;t<f.length;t+=3)f[t]=l[0],f[t+1]=l[1],f[t+2]=l[2];return new B(g,p,h,f)})}async _updateMessageBundle(){this.loadingMessages=!0;try{this.unitsMessages=await s("esri/core/t9n/Units"),this.messages=await s("esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis")}finally{this.loadingMessages=!1}}};function z(e,t,i){if(!t||!e)return null;const s=h(t.value,t.unit,i),o=u(s);return c(e,t,s,o)}e([p({constructOnly:!0})],T.prototype,"view",void 0),e([p({constructOnly:!0})],T.prototype,"analysis",void 0),e([p({constructOnly:!0})],T.prototype,"analysisViewData",void 0),e([p()],T.prototype,"unitsMessages",void 0),e([p()],T.prototype,"messages",void 0),e([p()],T.prototype,"loadingMessages",void 0),e([p({readOnly:!0})],T.prototype,"visible",null),e([p()],T.prototype,"updating",null),e([p()],T.prototype,"hasUnsupportedError",null),e([p()],T.prototype,"_extrusionHeights",null),T=e([g("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],T);class I{constructor(e,t,i,s){this.segment=e,this.previous=t,this.next=i,this.isCut=s,this._isOccluded=!1,this._n1=C(),this._n2=C();const o=v(k,j(k,e.endRenderSpace,e.startRenderSpace));v(this._n1,L(this._n1,o,v(W,j(W,t.startRenderSpace,e.startRenderSpace)))),v(this._n2,L(this._n2,o,v(W,j(W,e.startRenderSpace,i.startRenderSpace)))),this._isConvex=l.normalize(x(this._n1,this._n2,o))<0}get isOccluded(){return this._isOccluded}updateOccluded(e){j(k,this.segment.startRenderSpace,e.eye);const t=b(this._n1,k)<0,i=b(this._n2,k)<0,s=this._isOccluded;return this._isOccluded=this._isConvex?t&&i:t||i,this._isOccluded!==s}}const k=C(),W=C();export{T as VolumeMeasurementCutFillVisualization};
|
|
2
|
+
import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as i,fetchMessageBundle as s}from"../../../../intl.js";import{volumeMeasurementConfiguration as o}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import r from"../../../../core/Accessor.js";import{equals as n}from"../../../../core/arrayUtils.js";import{cyclicalPI as l}from"../../../../core/Cyclical.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import{formatDecimal as c,preferredVolumePrecision as u}from"../../../../core/quantityFormatUtils.js";import{watch as m,initial as d}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as h}from"../../../../core/units.js";import{property as p,subclass as g}from"../../../../core/accessorSupport/decorators.js";import{e as y}from"../../../../chunks/earcut.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f,normalize as v,subtract as j,cross as L,dot as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as G}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as V}from"../../../../geometry/support/Indices.js";import{angleAroundAxis as x}from"../../../../geometry/support/vector.js";import{t as R}from"../../../../chunks/vec3.js";import A from"../../../../symbols/support/ElevationInfo.js";import{LabelVisualElement as M}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as O}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as D}from"../../interactive/visualElements/OutlineVisualElement.js";import{EuclideanSegment as F}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as E}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as U}from"../../layers/graphics/extrudeUtils.js";import{polygonToRenderInfo as S}from"../../support/renderInfoUtils/polygon.js";import{CutFillVisualizationRenderNode as N,VolumeGeometry as B}from"../../webgl-engine/lib/CutFillVisualizationRenderNode.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";let T=class extends r{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get updating(){return this.loadingMessages}get hasUnsupportedError(){const{error:e}=this.analysisViewData;return!!e&&["unsupported-coordinate-system","unsupported-layer-transparency"].includes(e.name)}get _extrusionHeights(){const{renderCoordsHelper:e}=this.view,{depthExtremaPositions:t,targetGeometry:i}=this.analysisViewData,{targetElevationRange:s}=o;if(!i||!t)return{cut:s,fill:-s};let r=-1/0;for(const o of i.rings)for(const e of o)r=Math.max(r,e[2]);const n=1,l=e.getAltitude(t.fill);return{cut:s,fill:Math.min(l-r,0)-n}}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._elevationContext=E.fromElevationInfo(new A({mode:"absolute-height"})),this._projectionLines=[]}initialize(){const{view:e}=this,i={view:e,isDecoration:!0},s=o,r={...i,width:s.geometryOutlineWidth};this._elevationAlignedGeometry=new D({...r,isDraped:!0,color:s.geometryOutlineColor.toUnitRGBA()}),this._targetGeometry=new D(r);const n={...i,attached:!0,width:s.projectionLineWidth,renderOccluded:4,polygonOffset:3},l={...n,stipplePattern:H(s.projectionLineStippleSize)},a=s.cutProjectionLineColor.toUnitRGBA(),c=s.fillProjectionLineColor.toUnitRGBA();this._cutProjectionLines=new O({...n,color:a}),this._occludedCutProjectionLines=new O({...l,color:a}),this._fillProjectionLines=new O({...n,color:c}),this._occludedFillProjectionLines=new O({...l,color:c});const u={...i,attached:!0};this._cutVolumeLabel=new M({...u,distance:s.labelDistance}),this._fillVolumeLabel=new M({...u,distance:-s.labelDistance}),this._renderNode=new N({view:e,cutColor:s.cutColor,fillColor:s.fillColor,borderColor:s.geometryOutlineColor}),this.addHandles([m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry}),({elevationAlignedGeometry:e,targetGeometry:t})=>{this._elevationAlignedGeometry.geometry=e,this._targetGeometry.geometry=t},d),m(()=>({interactive:this.analysisViewData.interactive,measureType:this.analysis.measureType,visible:this.visible}),({visible:e,interactive:t,measureType:i})=>{this._elevationAlignedGeometry.visible=e&&!t,this._targetGeometry.visible=e&&"cut-fill"===i,this._renderNode.measureType=i},d),m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry,visible:this.visible}),({elevationAlignedGeometry:e,targetGeometry:t,visible:i})=>this._updateProjectionLines(e,t,i),d),m(()=>({interactive:this.analysisViewData.interactive,accentColor:this.view.effectiveTheme.accentColor,hasResult:!!this.analysisViewData.result}),({interactive:e,accentColor:t,hasResult:i})=>{this._updateColors(e,t,i)},d),m(()=>[this.analysisViewData.targetGeometry,this._extrusionHeights],()=>this._updateCutFillGeometry(),d),m(()=>this.visible&&this.view.state.camera.aboveGround&&!this.hasUnsupportedError,e=>this._updateCutFillVisibility(e),d),m(()=>{const{messages:e,unitsMessages:t,visible:i,analysisViewData:s}=this;return{depthExtremaPositions:s.depthExtremaPositions,effectiveDisplayUnits:s.effectiveDisplayUnits,messages:e,unitsMessages:t,result:s.result,visible:i&&!!s.result}},e=>this._updateLabels(e)),m(()=>this.view.state.camera,e=>this._updateProjectionLineOcclusion(e),d),t(()=>this._updateMessageBundle())]),this._updateMessageBundle()}destroy(){this._elevationAlignedGeometry=a(this._elevationAlignedGeometry),this._targetGeometry=a(this._targetGeometry),this._cutProjectionLines=a(this._cutProjectionLines),this._occludedCutProjectionLines=a(this._occludedCutProjectionLines),this._fillProjectionLines=a(this._fillProjectionLines),this._occludedFillProjectionLines=a(this._occludedFillProjectionLines),this._cutVolumeLabel=a(this._cutVolumeLabel),this._fillVolumeLabel=a(this._fillVolumeLabel),this._renderNode.destroy()}_updateProjectionLines(e,t,i){if(this._cutProjectionLines.visible=i,this._occludedCutProjectionLines.visible=i,this._fillProjectionLines.visible=i,this._occludedFillProjectionLines.visible=i,!e||!t)return;const{renderCoordsHelper:s}=this.view,o=[],r=[],l=[],a=[],c=[],u=e.spatialReference;for(let m=0;m<e.rings.length;m++){const i=e.rings[m],d=i.length>1&&n(i[0],i[i.length-1]),h=i.length-(d?1:0),p=[];for(let e=0;e<h;++e){const o=i[e],r=f(C(),o[0],o[1],o[2]);s.toRenderCoords(r,u,r);const n=t.rings[m][e],l=f(C(),n[0],n[1],n[2]);s.toRenderCoords(l,u,l);const a=new F(r,l);p.push(a)}const g=this.view.state.camera;for(let s=0;s<p.length;++s){const i=p[s],n=p[0===s?p.length-1:s-1],u=p[s===p.length-1?0:s+1],d=e.rings[m][s],h=t.rings[m][s],y=d[2]>h[2],_=new I(i,n,u,y);o.push(_),_.updateOccluded(g);const f=_.isOccluded;y?(f?l:r).push(i):(f?c:a).push(i)}}this._projectionLines=o,this._cutProjectionLines.setGeometryFromSegments(r),this._occludedCutProjectionLines.setGeometryFromSegments(l),this._fillProjectionLines.setGeometryFromSegments(a),this._occludedFillProjectionLines.setGeometryFromSegments(c)}_updateProjectionLineOcclusion(e){const t=[],i=[],s=[],o=[];let r=!1,n=!1;for(const l of this._projectionLines){l.updateOccluded(e)&&(r||=l.isCut,n||=!l.isCut);const a=l.isOccluded;(l.isCut?a?i:t:a?o:s).push(l.segment)}n&&(this._fillProjectionLines.setGeometryFromSegments(s),this._occludedFillProjectionLines.setGeometryFromSegments(o)),r&&(this._cutProjectionLines.setGeometryFromSegments(t),this._occludedCutProjectionLines.setGeometryFromSegments(i))}_updateColors(e,t,i){const{geometryOutlineColor:s,cutColor:r,fillColor:n,cutColorMuted:l,fillColorMuted:a,cutProjectionLineColor:c,fillProjectionLineColor:u}=o;if(this._renderNode.cutColor=i?r:l,this._renderNode.fillColor=i?n:a,e){const e=t.toUnitRGBA();this._targetGeometry.color=e,this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e,this._fillProjectionLines.color=e,this._occludedFillProjectionLines.color=e,this._renderNode.borderColor=t}else{this._targetGeometry.color=s.toUnitRGBA();const e=(i?c:l).toUnitRGBA();this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e;const t=(i?u:a).toUnitRGBA();this._fillProjectionLines.color=t,this._occludedFillProjectionLines.color=t,this._renderNode.borderColor=s}}_updateLabels(e){const{effectiveDisplayUnits:t,depthExtremaPositions:s,messages:o,unitsMessages:r,result:n,visible:l}=e;if(this._cutVolumeLabel.visible=l,this._fillVolumeLabel.visible=l,this._cutVolumeLabel.geometry=s?{type:"point",point:s.cut}:null,this._fillVolumeLabel.geometry=s?{type:"point",point:s.fill}:null,null==n||null==o||null==r)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const a=t.volume,c=i(o.labels.cut,{volume:z(r,n.cutVolume,a)}),u=i(o.labels.fill,{volume:z(r,n.fillVolume,a)});this._cutVolumeLabel.text=c,this._fillVolumeLabel.text=u}_updateCutFillVisibility(e){e?this._renderNode.enable():this._renderNode.disable()}_updateCutFillGeometry(){const{renderCoordsHelper:e}=this.view,{targetGeometry:t}=this.analysisViewData,{cut:i,fill:s}=this._extrusionHeights;if(!t?.extent)return;const{center:o}=t.extent,r=w(o.x,o.y,0),n=C();e.toRenderCoords(r,t.spatialReference,n);const l=this._getExtrudedVolumes(t,i,r,n),a=this._getExtrudedVolumes(t,s,r,n);this._renderNode.updateGeometries(l,a,n)}_getExtrudedVolumes(e,t,i,s){const{renderCoordsHelper:o,spatialReference:r,elevationProvider:n}=this.view,l=C(),a=1===o.viewingMode;o.worldUpAtPosition(s,l);const c=S(e,n,o,this._elevationContext),{polygons:u,mapPositions:m,position:d}=c;return u.map(e=>{const s=e.count,n=y(e.mapPositions,e.holeIndices,3),c=n.length,u=6*s,h=V(u+c),p=V(c),g=G(3*u),f=G(3*u);U(d,m,n,e,g,null,f,null,h,p,t,l,a);const v=_(),j=_();if(P(r,i,v,o.spatialReference),j[12]=-v[12],j[13]=-v[13],j[14]=-v[14],R(g,g,j),"stockpile"===this.analysis.measureType)for(let t=0;t<f.length;t+=3)f[t]=l[0],f[t+1]=l[1],f[t+2]=l[2];return new B(g,p,h,f)})}async _updateMessageBundle(){this.loadingMessages=!0;try{this.unitsMessages=await s("esri/core/t9n/Units"),this.messages=await s("esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis")}finally{this.loadingMessages=!1}}};function z(e,t,i){if(!t||!e)return null;const s=h(t.value,t.unit,i),o=u(s);return c(e,t,s,o)}e([p({constructOnly:!0})],T.prototype,"view",void 0),e([p({constructOnly:!0})],T.prototype,"analysis",void 0),e([p({constructOnly:!0})],T.prototype,"analysisViewData",void 0),e([p()],T.prototype,"unitsMessages",void 0),e([p()],T.prototype,"messages",void 0),e([p()],T.prototype,"loadingMessages",void 0),e([p({readOnly:!0})],T.prototype,"visible",null),e([p()],T.prototype,"updating",null),e([p()],T.prototype,"hasUnsupportedError",null),e([p()],T.prototype,"_extrusionHeights",null),T=e([g("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],T);class I{constructor(e,t,i,s){this.segment=e,this.previous=t,this.next=i,this.isCut=s,this._isOccluded=!1,this._n1=C(),this._n2=C();const o=v(k,j(k,e.endRenderSpace,e.startRenderSpace));v(this._n1,L(this._n1,o,v(W,j(W,t.startRenderSpace,e.startRenderSpace)))),v(this._n2,L(this._n2,o,v(W,j(W,e.startRenderSpace,i.startRenderSpace)))),this._isConvex=l.normalize(x(this._n1,this._n2,o))<0}get isOccluded(){return this._isOccluded}updateOccluded(e){j(k,this.segment.startRenderSpace,e.eye);const t=b(this._n1,k)<0,i=b(this._n2,k)<0,s=this._isOccluded;return this._isOccluded=this._isConvex?t&&i:t||i,this._isOccluded!==s}}const k=C(),W=C();export{T as VolumeMeasurementCutFillVisualization};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{copy as e,subtract as t,exactEquals as r,negate as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s,fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as l,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromRay as d,getStart as _,getEnd as p,create as c}from"../../../../geometry/support/clipRay.js";import{intersectClipRay as u}from"../../../../geometry/support/frustum.js";import{fromPoints as m,pointAt as f,create as y}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPoints as b}from"../../../../geometry/support/ray.js";import{EngineVisualElement as D}from"./EngineVisualElement.js";import{LaserlineVisualElement as w}from"./LaserlineVisualElement.js";import{drapedZ as O}from"../../terrain/OverlayRenderer.js";import{createPolylineGeometry as j}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as x}from"../../webgl-engine/lib/RenderGeometry.js";import{RibbonLineMaterial as C}from"../../webgl-engine/materials/RibbonLineMaterial.js";class E extends D{constructor(e){super(e),this._ray=g(),this._isWorldDown=!1,this._start=s(),this._end=n(1,0,0),this._width=1,this._color=l(1,0,1,1),this._polygonOffset=!1,this._writeDepthEnabled=!0,this._innerWidth=0,this._innerColor=l(1,1,1,1),this._stipplePattern=null,this._stippleOffColor=null,this._stipplePreferContinuous=!0,this._falloff=0,this._extensionType=0,this._laserlineStyle=null,this._laserlineEnabled=!1,this._renderOccluded=4,this._fadedExtensions=A,this._laserline=new w({view:this.view,isDecoration:e.isDecoration}),this.applyProperties(e)}destroy(){this._laserline.destroy(),super.destroy()}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:G,recreateGeometry:(e,t)=>this._recreateObject3DGeometry(e,t),cameraChanged:()=>this._updateGeometry(),forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:G,recreateGeometry:e=>this._recreateDrapedGeometry(e),forEachMaterial:(e,t)=>t(e.material)}}updateVisibility(e){super.updateVisibility(e),this._laserline.visible=e}onAttachedChange(){this._laserline.attached=this._laserlineAttached}setStartEndFromWorldDownAtLocation(r){this._isWorldDown=!0,e(this._start,r),this.view.renderCoordsHelper.worldUpAtPosition(r,this._end),t(this._end,r,this._end),b(this._start,this._end,this._ray),this._updateGeometry()}get start(){return this._start}set start(t){this._isWorldDown=!1,r(this._start,t)||(e(this._start,t),b(this._start,this._end,this._ray),this._updateGeometry())}get end(){return this._end}set end(t){this._isWorldDown=!1,r(this._end,t)||(e(this._end,t),b(this._start,this._end,this._ray),this._updateGeometry())}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get color(){return this._color}set color(e){a(e,this._color)||(o(this._color,e),this._updateMaterial())}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){e!==this._polygonOffset&&(this._polygonOffset=e,this._updateMaterial())}get writeDepthEnabled(){return this._writeDepthEnabled}set writeDepthEnabled(e){this._writeDepthEnabled!==e&&(this._writeDepthEnabled=e,this._updateMaterial())}get innerWidth(){return this._innerWidth}set innerWidth(e){e!==this._innerWidth&&(this._innerWidth=e,this._updateMaterial())}get innerColor(){return this._innerColor}set innerColor(e){a(e,this._innerColor)||(o(this._innerColor,e),this._updateMaterial())}get stipplePattern(){return this._stipplePattern}set stipplePattern(e){const t=null!=e!=(null!=this._stipplePattern);this._stipplePattern=e,t?this.recreate():this._updateMaterial()}get stippleOffColor(){return this._stippleOffColor}set stippleOffColor(e){null!=e&&null!=this._stippleOffColor&&a(e,this._stippleOffColor)||(this._stippleOffColor=null!=e?h(e):null,this._updateMaterial())}get stipplePreferContinuous(){return this._stipplePreferContinuous}set stipplePreferContinuous(e){e!==this._stipplePreferContinuous&&(this._stipplePreferContinuous=e,this._updateMaterial())}get falloff(){return this._falloff}set falloff(e){e!==this._falloff&&(this._falloff=e,this._updateMaterial())}get extensionType(){return this._extensionType}set extensionType(e){e!==this._extensionType&&(this._extensionType=e,this.recreateGeometry())}get _laserlineAttached(){return this._laserlineEnabled&&null!=this._laserlineStyle&&this.attached&&!this.isDraped}get laserlineStyle(){return this._laserlineStyle}set laserlineStyle(e){this._laserlineStyle=e,this._laserline.attached=this._laserlineAttached,null!=e&&(this._laserline.style=e)}get laserlineEnabled(){return this._laserlineEnabled}set laserlineEnabled(e){this._laserlineEnabled!==e&&(this._laserlineEnabled=e,this._laserline.attached=this._laserlineAttached)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get _normalizedRenderOccluded(){return this.isDraped&&8===this._renderOccluded?4:this._renderOccluded}get fadedExtensions(){return this._fadedExtensions}set fadedExtensions(e){this._fadedExtensions=e??A,this.recreateGeometry()}_updateMaterial(){const{materialParameters:e}=this;this.object3dResources.resources?.material.setParameters(e),this.drapedResources.resources?.material.setParameters(e)}get materialParameters(){return{width:this._width,color:this._color,stippleOffColor:this._stippleOffColor,stipplePattern:this._stipplePattern,stipplePreferContinuous:this._stipplePreferContinuous,innerWidth:this._innerWidth,innerColor:this._innerColor,falloff:this._falloff,
|
|
2
|
+
import{copy as e,subtract as t,exactEquals as r,negate as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s,fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as l,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromRay as d,getStart as _,getEnd as p,create as c}from"../../../../geometry/support/clipRay.js";import{intersectClipRay as u}from"../../../../geometry/support/frustum.js";import{fromPoints as m,pointAt as f,create as y}from"../../../../geometry/support/lineSegment.js";import{create as g,fromPoints as b}from"../../../../geometry/support/ray.js";import{EngineVisualElement as D}from"./EngineVisualElement.js";import{LaserlineVisualElement as w}from"./LaserlineVisualElement.js";import{drapedZ as O}from"../../terrain/OverlayRenderer.js";import{createPolylineGeometry as j}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as x}from"../../webgl-engine/lib/RenderGeometry.js";import{RibbonLineMaterial as C}from"../../webgl-engine/materials/RibbonLineMaterial.js";class E extends D{constructor(e){super(e),this._ray=g(),this._isWorldDown=!1,this._start=s(),this._end=n(1,0,0),this._width=1,this._color=l(1,0,1,1),this._polygonOffset=!1,this._writeDepthEnabled=!0,this._innerWidth=0,this._innerColor=l(1,1,1,1),this._stipplePattern=null,this._stippleOffColor=null,this._stipplePreferContinuous=!0,this._falloff=0,this._extensionType=0,this._laserlineStyle=null,this._laserlineEnabled=!1,this._renderOccluded=4,this._fadedExtensions=A,this._laserline=new w({view:this.view,isDecoration:e.isDecoration}),this.applyProperties(e)}destroy(){this._laserline.destroy(),super.destroy()}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:G,recreateGeometry:(e,t)=>this._recreateObject3DGeometry(e,t),cameraChanged:()=>this._updateGeometry(),forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:G,recreateGeometry:e=>this._recreateDrapedGeometry(e),forEachMaterial:(e,t)=>t(e.material)}}updateVisibility(e){super.updateVisibility(e),this._laserline.visible=e}onAttachedChange(){this._laserline.attached=this._laserlineAttached}setStartEndFromWorldDownAtLocation(r){this._isWorldDown=!0,e(this._start,r),this.view.renderCoordsHelper.worldUpAtPosition(r,this._end),t(this._end,r,this._end),b(this._start,this._end,this._ray),this._updateGeometry()}get start(){return this._start}set start(t){this._isWorldDown=!1,r(this._start,t)||(e(this._start,t),b(this._start,this._end,this._ray),this._updateGeometry())}get end(){return this._end}set end(t){this._isWorldDown=!1,r(this._end,t)||(e(this._end,t),b(this._start,this._end,this._ray),this._updateGeometry())}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get color(){return this._color}set color(e){a(e,this._color)||(o(this._color,e),this._updateMaterial())}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){e!==this._polygonOffset&&(this._polygonOffset=e,this._updateMaterial())}get writeDepthEnabled(){return this._writeDepthEnabled}set writeDepthEnabled(e){this._writeDepthEnabled!==e&&(this._writeDepthEnabled=e,this._updateMaterial())}get innerWidth(){return this._innerWidth}set innerWidth(e){e!==this._innerWidth&&(this._innerWidth=e,this._updateMaterial())}get innerColor(){return this._innerColor}set innerColor(e){a(e,this._innerColor)||(o(this._innerColor,e),this._updateMaterial())}get stipplePattern(){return this._stipplePattern}set stipplePattern(e){const t=null!=e!=(null!=this._stipplePattern);this._stipplePattern=e,t?this.recreate():this._updateMaterial()}get stippleOffColor(){return this._stippleOffColor}set stippleOffColor(e){null!=e&&null!=this._stippleOffColor&&a(e,this._stippleOffColor)||(this._stippleOffColor=null!=e?h(e):null,this._updateMaterial())}get stipplePreferContinuous(){return this._stipplePreferContinuous}set stipplePreferContinuous(e){e!==this._stipplePreferContinuous&&(this._stipplePreferContinuous=e,this._updateMaterial())}get falloff(){return this._falloff}set falloff(e){e!==this._falloff&&(this._falloff=e,this._updateMaterial())}get extensionType(){return this._extensionType}set extensionType(e){e!==this._extensionType&&(this._extensionType=e,this.recreateGeometry())}get _laserlineAttached(){return this._laserlineEnabled&&null!=this._laserlineStyle&&this.attached&&!this.isDraped}get laserlineStyle(){return this._laserlineStyle}set laserlineStyle(e){this._laserlineStyle=e,this._laserline.attached=this._laserlineAttached,null!=e&&(this._laserline.style=e)}get laserlineEnabled(){return this._laserlineEnabled}set laserlineEnabled(e){this._laserlineEnabled!==e&&(this._laserlineEnabled=e,this._laserline.attached=this._laserlineAttached)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get _normalizedRenderOccluded(){return this.isDraped&&8===this._renderOccluded?4:this._renderOccluded}get fadedExtensions(){return this._fadedExtensions}set fadedExtensions(e){this._fadedExtensions=e??A,this.recreateGeometry()}_updateMaterial(){const{materialParameters:e}=this;this.object3dResources.resources?.material.setParameters(e),this.drapedResources.resources?.material.setParameters(e)}get materialParameters(){return{width:this._width,color:this._color,stippleOffColor:this._stippleOffColor,stipplePattern:this._stipplePattern,stipplePreferContinuous:this._stipplePreferContinuous,innerWidth:this._innerWidth,innerColor:this._innerColor,falloff:this._falloff,polygonOffset:this._polygonOffset?3:0,renderOccluded:this._normalizedRenderOccluded,isDecoration:this.isDecoration,writeDepth:this._writeDepthEnabled}}_createObject3DResources(e){const t=new C(this.materialParameters,this.view.state.isGlobal),r=new Array;return this._createObject3DGeometry(t,e,r),{material:t,geometries:r}}_recreateObject3DGeometry(e,t){e.geometries.length=0,this._createObject3DGeometry(e.material,t,e.geometries)}_createObject3DGeometry(e,t,r){const i=this._createGeometry(e);r.push(i),t.addGeometry(i),this._updateVerticesObject3D(t)}_createDrapedResources(){const e=new C(this.materialParameters,this.view.state.isGlobal);return{material:e,geometries:[this._createDrapedGeometry(e)]}}_recreateDrapedGeometry(e){e.geometries=[this._createDrapedGeometry(e.material)]}_createDrapedGeometry(e){const t=this._createGeometry(e);return this._updateVerticesDraped(t),new x(t)}_createGeometry(e){const t=3===this.extensionType,r=t?[s(),s(),s(),s()]:[s(),s()];return j(e,r,null,t?[1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0]:null)}_updateGeometry(){if(this.isDraped)this.drapedResources.recreateGeometry();else{const e=this.object3dResources.object;e&&this._updateVerticesObject3D(e)}}_updateVerticesObject3D(e){const t=this._lineSegment;this._updateVertexAttributesObject3D(e,t),this._laserline.intersectsLine=t}_updateVerticesDraped(e){this._updateVertexAttributesDraped(e,this._lineSegment)}get _lineSegment(){return 3===this._extensionType?this._updateLineSegmentFinite(M):this._updateLineSegmentInfinite(this._extensionType,M)}_updateLineSegmentFinite(e){return m(this._start,this._end,e)}_updateLineSegmentInfinite(e,t){const r=this.view.state.camera;switch(d(this._ray,P),e){case 0:P.c0=-Number.MAX_VALUE;break;case 1:case 2:{const e=this._ray.origin,t=this.view.elevationProvider.getElevation(e[0],e[1],e[2],this.view.renderCoordsHelper.spatialReference,"ground")??0,r=this.view.renderCoordsHelper.getAltitude(e);this._isWorldDown&&r<t&&i(P.ray.direction,P.ray.direction),2===this._extensionType&&null!=t&&(P.c1=Math.abs(r-t));break}}if(!u(r.frustum,P))return this._updateLineSegmentFinite(t);const s=_(P,v),n=p(P,R);return m(s,n,t)}_updateVertexAttributesObject3D(e,t){const r=e.geometries[0].getMutableAttribute("position")?.data;if(!r)return;let i=0;for(const s of this._lineVertices(t))r[i++]=s[0],r[i++]=s[1],r[i++]=s[2];e.geometryVertexAttributeUpdated(e.geometries[0],"position")}_updateVertexAttributesDraped(e,t){const r=e.getMutableAttribute("position")?.data;if(!r)return;let i=0;for(const s of this._lineVertices(t))r[i++]=s[0],r[i++]=s[1],r[i++]=O;e.invalidateBoundingInfo()}*_lineVertices(e){3===this.extensionType?(yield f(e,-this.fadedExtensions.start,v),yield f(e,0,v),yield f(e,1,v),yield f(e,1+this.fadedExtensions.end,v)):(yield f(e,0,v),yield f(e,1,v))}}function G(e){e.geometries=[]}const P=c(),v=s(),R=s(),M=y(),V=1/3,A={start:V,end:V};export{E as ExtendedLineVisualElement};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{fromTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as
|
|
2
|
+
import{fromTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as t,transformMat4 as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as i,create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as n}from"./Object3DVisualElement.js";import{lineStripsToParameters as l,createGeometry as m}from"../../support/engineContent/line.js";import{isImagePattern as p}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as h}from"../../webgl-engine/materials/RibbonLineMaterial.js";class d extends n{constructor(e,r){super(e),this._hasExternalMaterial=!1,this._hasExternalMaterial=null!=r,this._material=r??new h({width:1,color:a(1,0,1,1),stipplePreferContinuous:!0,isClosed:!1,falloff:0,innerWidth:1,renderOccluded:4,isDecoration:!!e.isDecoration,writeDepth:!0},e.view.state.isGlobal),this.applyProperties(e)}setGeometryFromPoint(e,r=1e3){const t=o();this.view.renderCoordsHelper.toRenderCoords(e,t)&&this.setGeometryFromRenderSpacePoint(t,r)}setGeometryFromRenderSpacePoint(e,r=1e3){this.geometry=[[[e[0]-r,e[1],e[2]],[e[0]+r,e[1],e[2]]],[[e[0],e[1]-r,e[2]],[e[0],e[1]+r,e[2]]],[[e[0],e[1],e[2]-r],[e[0],e[1],e[2]+r]]]}setGeometryFromExtent(e){const r=this.view.spatialReference,s=o(),i=o(),a=100,n=[];t(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,r,i),n.push([i[0],i[1],i[2]]),t(s,e[2],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,r,i),n.push([i[0],i[1],i[2]]),t(s,e[2],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,r,i),n.push([i[0],i[1],i[2]]),t(s,e[0],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,r,i),n.push([i[0],i[1],i[2]]),t(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,r,i),n.push([i[0],i[1],i[2]]),t(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,r,i),n.push([i[0],i[1],i[2]]),this.geometry=[n]}setGeometryFromFrustum(e){const r=[];e.lines.forEach(e=>{r.push([e.origin[0],e.origin[1],e.origin[2]]),r.push([e.endpoint[0],e.endpoint[1],e.endpoint[2]])}),this.geometry=[r]}setGeometryFromBoundedPlane(e){const r=[],t=e.origin,s=e.basis1,i=e.basis2,a=.5,n=o(),l=o(),m=o(),p=o();n[0]=t[0]-s[0]*a-i[0]*a,n[1]=t[1]-s[1]*a-i[1]*a,n[2]=t[2]-s[2]*a-i[2]*a,l[0]=t[0]-s[0]*a+i[0]*a,l[1]=t[1]-s[1]*a+i[1]*a,l[2]=t[2]-s[2]*a+i[2]*a,m[0]=t[0]+s[0]*a+i[0]*a,m[1]=t[1]+s[1]*a+i[1]*a,m[2]=t[2]+s[2]*a+i[2]*a,p[0]=t[0]+s[0]*a-i[0]*a,p[1]=t[1]+s[1]*a-i[1]*a,p[2]=t[2]+s[2]*a-i[2]*a,r.push([n[0],n[1],n[2]]),r.push([l[0],l[1],l[2]]),r.push([m[0],m[1],m[2]]),r.push([p[0],p[1],p[2]]),r.push([n[0],n[1],n[2]]),this.geometry=[r]}setGeometryFromSegment(r){if(!r.visible)return void(this.geometry=null);const t=r.endRenderSpace;this.transform=e(f,t);const{points:s}=r.createRenderGeometry(t,this.view.renderCoordsHelper);this.geometry=[s]}setGeometryFromSegments(r,t=i){this.transform=e(f,t),this.geometry=r.filter(({visible:e})=>e).map(e=>e.createRenderGeometry(t,this.view.renderCoordsHelper).points)}getTransformedGeometry(){return null==this._geometry?null:this._geometry.map(e=>e.map(e=>s(o(),e,this.transform)))}get renderOccluded(){return this._material.parameters.renderOccluded}set renderOccluded(e){this._material.setParameters({renderOccluded:e})}get transparentRenderOrder(){return this._material.parameters.testsTransparentRenderOrder}set transparentRenderOrder(e){this._material.setParameters({testsTransparentRenderOrder:e})}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get width(){return this._material.parameters.width}set width(e){this._material.setParameters({width:e})}get color(){return this._material.parameters.color}set color(e){const r=1===e[3];this._material.setParameters({color:e,writeDepth:r})}get innerWidth(){return this._material.parameters.innerWidth}set innerWidth(e){this._material.setParameters({innerWidth:e})}get innerColor(){return this._material.parameters.innerColor}set innerColor(e){this._material.setParameters({innerColor:e})}get stipplePattern(){const{stipplePattern:e}=this._material.parameters;return p(e)?null:e}set stipplePattern(e){null!=this._material&&this._material.setParameters({stipplePattern:e})}get stippleOffColor(){return this._material.parameters.stippleOffColor}set stippleOffColor(e){this._material.setParameters({stippleOffColor:e})}get stipplePreferContinuous(){return this._material.parameters.stipplePreferContinuous}set stipplePreferContinuous(e){this._material.setParameters({stipplePreferContinuous:e})}get falloff(){return this._material.parameters.falloff}set falloff(e){this._material.setParameters({falloff:e})}get polygonOffset(){return this._material.parameters.polygonOffset}set polygonOffset(e){this._material.setParameters({polygonOffset:e})}createExternalResources(){}destroyExternalResources(){}createGeometries(e){for(const r of l(this.geometry)){const t=m(this._material,r);e.addGeometry(t)}}forEachMaterial(e){this._hasExternalMaterial||e(this._material)}}const f=r();export{d as LineVisualElement};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{getTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{copy as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{subtract as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as o,copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as l}from"./Object3DVisualElement.js";import{Attribute as n}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{CheckerBoardMaterial as h}from"../../webgl-engine/materials/CheckerBoardMaterial.js";class m extends l{constructor(e){super(e),this._checkerBoardMaterial=null,this._renderOccluded=4,this._transparentRenderOrder=0,this._geometry=null,this._size=t(1,1),this._color1=c(1,.5,0,.5),this._color2=c(1,1,1,.5),this.applyProperties(e)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get testsTransparentRenderOrder(){return this._transparentRenderOrder}set testsTransparentRenderOrder(e){e!==this._transparentRenderOrder&&(this._transparentRenderOrder=e,this._updateMaterial())}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get size(){return this._size}set size(e){r(this._size,e),this._updateMaterial()}get color1(){return this._color1}set color1(e){o(e,this._color1)||(a(this._color1,e),this._updateMaterial())}get color2(){return this._color2}set color2(e){o(e,this._color2)||(a(this._color2,e),this._updateMaterial())}_updateMaterial(){this._checkerBoardMaterial?.setParameters({size:this._size,color1:this._color1,color2:this._color2,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder})}createExternalResources(){this._checkerBoardMaterial=new h({size:this._size,color1:this._color1,color2:this._color2,writeDepth:!1,polygonOffset
|
|
2
|
+
import{getTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{copy as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{subtract as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as o,copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as l}from"./Object3DVisualElement.js";import{Attribute as n}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{CheckerBoardMaterial as h}from"../../webgl-engine/materials/CheckerBoardMaterial.js";class m extends l{constructor(e){super(e),this._checkerBoardMaterial=null,this._renderOccluded=4,this._transparentRenderOrder=0,this._geometry=null,this._size=t(1,1),this._color1=c(1,.5,0,.5),this._color2=c(1,1,1,.5),this.applyProperties(e)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get testsTransparentRenderOrder(){return this._transparentRenderOrder}set testsTransparentRenderOrder(e){e!==this._transparentRenderOrder&&(this._transparentRenderOrder=e,this._updateMaterial())}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get size(){return this._size}set size(e){r(this._size,e),this._updateMaterial()}get color1(){return this._color1}set color1(e){o(e,this._color1)||(a(this._color1,e),this._updateMaterial())}get color2(){return this._color2}set color2(e){o(e,this._color2)||(a(this._color2,e),this._updateMaterial())}_updateMaterial(){this._checkerBoardMaterial?.setParameters({size:this._size,color1:this._color1,color2:this._color2,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder})}createExternalResources(){this._checkerBoardMaterial=new h({size:this._size,color1:this._color1,color2:this._color2,writeDepth:!1,polygonOffset:1,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder,isDecoration:this.isDecoration})}destroyExternalResources(){this._checkerBoardMaterial=null}forEachMaterial(e){e(this._checkerBoardMaterial)}createGeometries(r){if(null==this._geometry||null==this._checkerBoardMaterial)return;const t=_;e(t,this.transform);const o=this._geometry,a=[],c=i();o.position.forEach(e=>{s(c,e,t),a.push(c[0],c[1],c[2])});const l=[];o.uv.forEach(e=>{l.push(e[0],e[1])});const h=new d(this._checkerBoardMaterial,[["position",new n(a,o.triangleIndices,3,!0)],["uv0",new n(l,o.triangleIndices,2,!0)]]);r.addGeometry(h)}}const _=i();export{m as MeasurementAreaVisualElement};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{EventEmitter as e}from"../../../../core/Evented.js";import{set as t,add as r,scale as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as o,copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as n,clone as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as h}from"../../../../geometry/projection/projectBuffer.js";import{expandWithBuffer as c}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as d}from"../../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as m}from"../../../../layers/graphics/dehydratedPoint.js";import{getGeometryEffectiveElevationMode as p}from"../../../../support/elevationInfoUtils.js";import u from"../../../../symbols/support/ElevationInfo.js";import{EngineVisualElement as _}from"./EngineVisualElement.js";import{LaserlineVisualElement as f}from"./LaserlineVisualElement.js";import{ElevationContext as g}from"../../layers/graphics/ElevationContext.js";import{createGeometry as y}from"../../support/engineContent/line.js";import{geometryToRenderInfoDraped as O,geometryToRenderInfo as C}from"../../support/renderInfoUtils/line.js";import{RenderGeometry as v}from"../../webgl-engine/lib/RenderGeometry.js";import{RibbonLineMaterial as b}from"../../webgl-engine/materials/RibbonLineMaterial.js";class w extends _{constructor(t){super(t),this._attachmentOrigin=m(0,0,0,null),this._attachmentOriginDirty=!0,this.events=new e,this._geometry=null,this._width=1,this._color=n(1,0,1,1),this._innerWidth=0,this._innerColor=n(1,1,1,1),this._stipplePattern=null,this._stippleOffColor=null,this._falloff=0,this._elevationInfo=null,this._laserlineStyle=null,this._laserlineEnabled=!1,this._renderOccluded=8,this._attachmentOrigin.spatialReference=t.view.spatialReference,this._laserline=new f({view:t.view,isDecoration:t.isDecoration}),this.applyProperties(t),this.attached=t.attached??!0}destroy(){this._laserline.destroy(),super.destroy()}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:R,recreateGeometry:(e,t)=>{e.geometries.length=0,this._recreateGeometry(t,e.material,e.geometries)},forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:R,recreateGeometry:e=>{e.geometries=this._createRenderGeometriesDraped(e.material),this._attachmentOriginChanged()},forEachMaterial:(e,t)=>t(e.material)}}get _laserlineAttached(){return this.attached&&this.visible&&null!=this._laserlineStyle&&!this.isDraped&&this.laserlineEnabled}onAttachedChange(e){this._laserline.attached=this._laserlineAttached,e&&this._attachmentOriginChanged()}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateMaterial()}get geometry(){return this._geometry}set geometry(e){const t=this._isClosed;this._geometry=e,this.recreateGeometry(),t!==this._isClosed&&this._updateMaterial()}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get color(){return this._color}set color(e){o(e,this._color)||(a(this._color,e),this._updateMaterial())}get innerWidth(){return this._innerWidth}set innerWidth(e){e!==this._innerWidth&&(this._innerWidth=e,this._updateMaterial())}get innerColor(){return this._innerColor}set innerColor(e){o(e,this._innerColor)||(a(this._innerColor,e),this._updateMaterial())}get stipplePattern(){return this._stipplePattern}set stipplePattern(e){const t=null!=e!=(null!=this._stipplePattern);this._stipplePattern=e,t?this.recreate():this._updateMaterial()}get stippleOffColor(){return this._stippleOffColor}set stippleOffColor(e){e&&this._stippleOffColor&&o(e,this._stippleOffColor)||(this._stippleOffColor=e?l(e):null,this._updateMaterial())}get falloff(){return this._falloff}set falloff(e){e!==this._falloff&&(this._falloff=e,this._updateMaterial())}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this.recreateGeometry()}get laserlineStyle(){return this._laserlineStyle}set laserlineStyle(e){this._laserlineStyle=e,this._laserline.attached=this._laserlineAttached,null!=e&&(this._laserline.style=e)}get laserlineEnabled(){return this._laserlineEnabled}set laserlineEnabled(e){this._laserlineEnabled!==e&&(this._laserlineEnabled=e,this._laserline.attached=this._laserlineAttached)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get attachmentOrigin(){if(!this._attachmentOriginDirty)return this._attachmentOrigin;const e=this.object3dResources.resources?.geometries;if(!e||0===e.length)return null;t(D,0,0,0);let s=0;for(const t of e)t.computeAttachmentOrigin(j)&&(r(D,D,j),s++);return 0===s?null:(i(D,D,1/s),this.view.renderCoordsHelper.fromRenderCoords(D,this._attachmentOrigin),this._attachmentOriginDirty=!1,this._attachmentOrigin)}_updateMaterial(){this.object3dResources.resources?.material.setParameters(this._materialParameters),this.drapedResources.resources?.material.setParameters(this._materialParameters)}get _isClosed(){return null!=this.geometry&&"polygon"===this.geometry.type}get _materialParameters(){return{width:this._width,color:this._color,stippleOffColor:this._stippleOffColor,stipplePattern:this._stipplePattern,stipplePreferContinuous:!1,isClosed:this._isClosed,falloff:this._falloff,innerColor:this._innerColor,innerWidth:this._innerWidth,join:"round",
|
|
2
|
+
import{EventEmitter as e}from"../../../../core/Evented.js";import{set as t,add as r,scale as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{exactEquals as o,copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as n,clone as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as h}from"../../../../geometry/projection/projectBuffer.js";import{expandWithBuffer as c}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as d}from"../../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as m}from"../../../../layers/graphics/dehydratedPoint.js";import{getGeometryEffectiveElevationMode as p}from"../../../../support/elevationInfoUtils.js";import u from"../../../../symbols/support/ElevationInfo.js";import{EngineVisualElement as _}from"./EngineVisualElement.js";import{LaserlineVisualElement as f}from"./LaserlineVisualElement.js";import{ElevationContext as g}from"../../layers/graphics/ElevationContext.js";import{createGeometry as y}from"../../support/engineContent/line.js";import{geometryToRenderInfoDraped as O,geometryToRenderInfo as C}from"../../support/renderInfoUtils/line.js";import{RenderGeometry as v}from"../../webgl-engine/lib/RenderGeometry.js";import{RibbonLineMaterial as b}from"../../webgl-engine/materials/RibbonLineMaterial.js";class w extends _{constructor(t){super(t),this._attachmentOrigin=m(0,0,0,null),this._attachmentOriginDirty=!0,this.events=new e,this._geometry=null,this._width=1,this._color=n(1,0,1,1),this._innerWidth=0,this._innerColor=n(1,1,1,1),this._stipplePattern=null,this._stippleOffColor=null,this._falloff=0,this._elevationInfo=null,this._laserlineStyle=null,this._laserlineEnabled=!1,this._renderOccluded=8,this._attachmentOrigin.spatialReference=t.view.spatialReference,this._laserline=new f({view:t.view,isDecoration:t.isDecoration}),this.applyProperties(t),this.attached=t.attached??!0}destroy(){this._laserline.destroy(),super.destroy()}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:R,recreateGeometry:(e,t)=>{e.geometries.length=0,this._recreateGeometry(t,e.material,e.geometries)},forEachMaterial:(e,t)=>t(e.material)}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:R,recreateGeometry:e=>{e.geometries=this._createRenderGeometriesDraped(e.material),this._attachmentOriginChanged()},forEachMaterial:(e,t)=>t(e.material)}}get _laserlineAttached(){return this.attached&&this.visible&&null!=this._laserlineStyle&&!this.isDraped&&this.laserlineEnabled}onAttachedChange(e){this._laserline.attached=this._laserlineAttached,e&&this._attachmentOriginChanged()}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateMaterial()}get geometry(){return this._geometry}set geometry(e){const t=this._isClosed;this._geometry=e,this.recreateGeometry(),t!==this._isClosed&&this._updateMaterial()}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._updateMaterial())}get color(){return this._color}set color(e){o(e,this._color)||(a(this._color,e),this._updateMaterial())}get innerWidth(){return this._innerWidth}set innerWidth(e){e!==this._innerWidth&&(this._innerWidth=e,this._updateMaterial())}get innerColor(){return this._innerColor}set innerColor(e){o(e,this._innerColor)||(a(this._innerColor,e),this._updateMaterial())}get stipplePattern(){return this._stipplePattern}set stipplePattern(e){const t=null!=e!=(null!=this._stipplePattern);this._stipplePattern=e,t?this.recreate():this._updateMaterial()}get stippleOffColor(){return this._stippleOffColor}set stippleOffColor(e){e&&this._stippleOffColor&&o(e,this._stippleOffColor)||(this._stippleOffColor=e?l(e):null,this._updateMaterial())}get falloff(){return this._falloff}set falloff(e){e!==this._falloff&&(this._falloff=e,this._updateMaterial())}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this.recreateGeometry()}get laserlineStyle(){return this._laserlineStyle}set laserlineStyle(e){this._laserlineStyle=e,this._laserline.attached=this._laserlineAttached,null!=e&&(this._laserline.style=e)}get laserlineEnabled(){return this._laserlineEnabled}set laserlineEnabled(e){this._laserlineEnabled!==e&&(this._laserlineEnabled=e,this._laserline.attached=this._laserlineAttached)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get attachmentOrigin(){if(!this._attachmentOriginDirty)return this._attachmentOrigin;const e=this.object3dResources.resources?.geometries;if(!e||0===e.length)return null;t(D,0,0,0);let s=0;for(const t of e)t.computeAttachmentOrigin(j)&&(r(D,D,j),s++);return 0===s?null:(i(D,D,1/s),this.view.renderCoordsHelper.fromRenderCoords(D,this._attachmentOrigin),this._attachmentOriginDirty=!1,this._attachmentOrigin)}_updateMaterial(){this.object3dResources.resources?.material.setParameters(this._materialParameters),this.drapedResources.resources?.material.setParameters(this._materialParameters)}get _isClosed(){return null!=this.geometry&&"polygon"===this.geometry.type}get _materialParameters(){return{width:this._width,color:this._color,stippleOffColor:this._stippleOffColor,stipplePattern:this._stipplePattern,stipplePreferContinuous:!1,isClosed:this._isClosed,falloff:this._falloff,innerColor:this._innerColor,innerWidth:this._innerWidth,join:"round",polygonOffset:3,renderOccluded:this._normalizedRenderOccluded,isDecoration:this.isDecoration}}get _normalizedRenderOccluded(){return this.isDraped&&8===this._renderOccluded?4:this._renderOccluded}_recreateGeometry(e,t,r){this._createRenderGeometries(t,r);for(const i of r)e.addGeometry(i);this._attachmentOriginChanged()}_attachmentOriginChanged(){this._attachmentOriginDirty=!0,this.events.emit("attachment-origin-changed")}_createObject3DResources(e){const t=new b(this._materialParameters,this.view.state.isGlobal),r=new Array;return this._recreateGeometry(e,t,r),{material:t,geometries:r}}_createDrapedResources(){const e=new b(this._materialParameters,this.view.state.isGlobal);return{material:e,geometries:this._createRenderGeometriesDraped(e)}}_createRenderGeometriesDraped(e){const{geometry:t,view:r}=this,i=r.basemapTerrain.spatialReference;if(null==t||null==i)return[];return O(t,i).lines.map(({position:t})=>{const s={overlayInfo:{spatialReference:i,renderCoordsHelper:r.renderCoordsHelper},attributeData:{position:t},removeDuplicateStartEnd:this._isClosed};return new v(y(e,s))})}calculateMapBounds(e){if(null==this.object3dResources.resources)return!1;const t=this.view.renderCoordsHelper;for(const r of this.object3dResources.resources.geometries){const i=r.attributes.get("position"),s=d(i.data.length);h(i.data,t.spatialReference,0,s,this.view.spatialReference,0),c(e,s)}return!0}_createRenderGeometries(e,t){const r=this.geometry;if(null==r)return;const i=C(r,this.view.elevationProvider,this.view.renderCoordsHelper,g.fromElevationInfo(this.elevationInfo??new u({mode:p(r,null)}))),s=new Array;for(const{position:o,mapPositions:a}of i.lines){const r={mapPositions:a,attributeData:{position:o},removeDuplicateStartEnd:this._isClosed};t.push(y(e,r)),s.push(o)}this._laserline.pathVerticalPlane=s}}function R(e){e.geometries=[]}const j=s(),D=s();export{w as OutlineVisualElement};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{watch as e}from"../../../../core/reactiveUtils.js";import{fromTranslation as t,scale as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{distance as s,normalize as a,subtract as o,copy as n,exactEquals as l,add as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,ZEROS as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as h}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{sv3d as _}from"../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as p}from"../../../../layers/graphics/dehydratedPoint.js";import{EngineVisualElement as g}from"./EngineVisualElement.js";import{drapedZ as f}from"../../terrain/OverlayRenderer.js";import{Attribute as M}from"../../webgl-engine/lib/Attribute.js";import{Geometry as R}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as O}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as b}from"../../webgl-engine/lib/RenderGeometry.js";import{ColorMaterial as j}from"../../webgl-engine/materials/ColorMaterial.js";import{RibbonLineMaterial as D}from"../../webgl-engine/materials/RibbonLineMaterial.js";class w extends g{constructor(e){super(e),this._maxSize=0,this._position=u(),this._up=u(),this._right=u(),this._renderOccluded=4,this._color=m(1,0,0,1),this._outlineColor=m(0,0,0,1),this._outlineSize=0,this._size=32,this._outlineRenderOccluded=16,this.applyProperties(e)}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:()=>{},cameraChanged:()=>this._updateTransformObject3D(),forEachMaterial:(e,t)=>{t(e.outlineMaterial),t(e.quadMaterial)}}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:y,forEachMaterial:(e,t)=>{t(e.outlineMaterial),t(e.quadMaterial)}}}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateQuadMaterial())}get transparentRenderOrder(){return this._transparentRenderOrder}set transparentRenderOrder(e){this._transparentRenderOrder=e,this._updateQuadMaterial()}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateOutlineMaterial(),this._updateQuadMaterial()}get color(){return this._color}set color(e){h(this._color,e),this._updateQuadMaterial()}get outlineColor(){return this._outlineColor}set outlineColor(e){h(this._outlineColor,e),this._updateOutlineMaterial()}get outlineSize(){return this._outlineSize}set outlineSize(e){const t=0===this._outlineSize!=(0===e);this._outlineSize=e,t?this.recreateGeometry():this._updateOutlineMaterial()}get size(){return this._size}set size(e){e!==this._size&&(this._size=e,this._updateTransform())}get outlineRenderOccluded(){return this._outlineRenderOccluded}set outlineRenderOccluded(e){this._outlineRenderOccluded=e,this._updateOutlineMaterial()}set geometry({previous:e,center:t,next:r}){this._maxSize=Math.min(s(t,e),s(t,r))/3,a(this._up,o(this._up,e,t)),a(this._right,o(this._right,r,t)),n(this._position,t),this.recreateGeometry()}_createObject3DResources(e){const t=new j(this._quadMaterialParameters),r=0===this._outlineSize?void 0:new D(this._outlineMaterialParameters,this.view.state.isGlobal);return this._createObject3DGeometries(e,t,r),{quadMaterial:t,outlineMaterial:r}}_createObject3DGeometries(e,t,r){if(l(this._up,d)&&l(this._right,d))return;const i=this._createGeometries(t,r);for(const s of i)e.addGeometry(s);this._updateTransformObject3D(e)}_createDrapedResources(){const t=new j(this._quadMaterialParameters),r=0===this._outlineSize?void 0:new D(this._outlineMaterialParameters,this.view.state.isGlobal),i=this._createGeometries(t,r).map(e=>new b(e));this._setTransformDraped(i);return{quadMaterial:t,outlineMaterial:r,geometries:i,pixelRatioHandle:e(()=>this.view.state.contentPixelRatio,()=>this.drapedResources.recreateGeometry())}}_createGeometries(e,t){const{up:r,right:i,corner:s}=this._getVertices(),a=z(r,i,s,e);if(!t)return[a];return[a,O(t,[r,s,i])]}_getVertices(){let e=this._up,t=this._right;const r=c(_.get(),e,t);return this.isDraped&&(e=n(_.get(),e),t=n(_.get(),t),e[2]=0,t[2]=0,r[2]=0),{up:e,right:t,corner:r}}_updateTransform(){this.isDraped?this.drapedResources.recreateGeometry():this._updateTransformObject3D()}_updateTransformObject3D(e=this.object3dResources.object){if(!e)return;const i=this.view.state.camera,s=this._size*i.computeScreenPixelSizeAt(this._position),a=Math.min(this._maxSize,s);t(v,this._position),r(v,v,[a,a,a]),e.transformation=v}_setTransformDraped(e){if(0===e.length)return;const{view:{overlayManager:i,state:{contentPixelRatio:s}}}=this,{_position:a,_size:o}=this,l=n(_.get(),a);l[2]=f;const c=x;c.spatialReference=i.spatialReference,c.x=l[0],c.y=l[1];const u=o*(this.view.overlayPixelSizeInMapUnits(c)*s),d=Math.min(this._maxSize,u);t(v,l),r(v,v,[d,d,1]);for(const t of e)t.transformation=v}get _quadMaterialParameters(){return{color:this._color,forceTransparentMode:!0,writeDepth:!1,polygonOffset
|
|
2
|
+
import{watch as e}from"../../../../core/reactiveUtils.js";import{fromTranslation as t,scale as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{distance as s,normalize as a,subtract as o,copy as n,exactEquals as l,add as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,ZEROS as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as h}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{sv3d as _}from"../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as p}from"../../../../layers/graphics/dehydratedPoint.js";import{EngineVisualElement as g}from"./EngineVisualElement.js";import{drapedZ as f}from"../../terrain/OverlayRenderer.js";import{Attribute as M}from"../../webgl-engine/lib/Attribute.js";import{Geometry as R}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as O}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as b}from"../../webgl-engine/lib/RenderGeometry.js";import{ColorMaterial as j}from"../../webgl-engine/materials/ColorMaterial.js";import{RibbonLineMaterial as D}from"../../webgl-engine/materials/RibbonLineMaterial.js";class w extends g{constructor(e){super(e),this._maxSize=0,this._position=u(),this._up=u(),this._right=u(),this._renderOccluded=4,this._color=m(1,0,0,1),this._outlineColor=m(0,0,0,1),this._outlineSize=0,this._size=32,this._outlineRenderOccluded=16,this.applyProperties(e)}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:()=>{},cameraChanged:()=>this._updateTransformObject3D(),forEachMaterial:(e,t)=>{t(e.outlineMaterial),t(e.quadMaterial)}}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:y,forEachMaterial:(e,t)=>{t(e.outlineMaterial),t(e.quadMaterial)}}}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateQuadMaterial())}get transparentRenderOrder(){return this._transparentRenderOrder}set transparentRenderOrder(e){this._transparentRenderOrder=e,this._updateQuadMaterial()}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateOutlineMaterial(),this._updateQuadMaterial()}get color(){return this._color}set color(e){h(this._color,e),this._updateQuadMaterial()}get outlineColor(){return this._outlineColor}set outlineColor(e){h(this._outlineColor,e),this._updateOutlineMaterial()}get outlineSize(){return this._outlineSize}set outlineSize(e){const t=0===this._outlineSize!=(0===e);this._outlineSize=e,t?this.recreateGeometry():this._updateOutlineMaterial()}get size(){return this._size}set size(e){e!==this._size&&(this._size=e,this._updateTransform())}get outlineRenderOccluded(){return this._outlineRenderOccluded}set outlineRenderOccluded(e){this._outlineRenderOccluded=e,this._updateOutlineMaterial()}set geometry({previous:e,center:t,next:r}){this._maxSize=Math.min(s(t,e),s(t,r))/3,a(this._up,o(this._up,e,t)),a(this._right,o(this._right,r,t)),n(this._position,t),this.recreateGeometry()}_createObject3DResources(e){const t=new j(this._quadMaterialParameters),r=0===this._outlineSize?void 0:new D(this._outlineMaterialParameters,this.view.state.isGlobal);return this._createObject3DGeometries(e,t,r),{quadMaterial:t,outlineMaterial:r}}_createObject3DGeometries(e,t,r){if(l(this._up,d)&&l(this._right,d))return;const i=this._createGeometries(t,r);for(const s of i)e.addGeometry(s);this._updateTransformObject3D(e)}_createDrapedResources(){const t=new j(this._quadMaterialParameters),r=0===this._outlineSize?void 0:new D(this._outlineMaterialParameters,this.view.state.isGlobal),i=this._createGeometries(t,r).map(e=>new b(e));this._setTransformDraped(i);return{quadMaterial:t,outlineMaterial:r,geometries:i,pixelRatioHandle:e(()=>this.view.state.contentPixelRatio,()=>this.drapedResources.recreateGeometry())}}_createGeometries(e,t){const{up:r,right:i,corner:s}=this._getVertices(),a=z(r,i,s,e);if(!t)return[a];return[a,O(t,[r,s,i])]}_getVertices(){let e=this._up,t=this._right;const r=c(_.get(),e,t);return this.isDraped&&(e=n(_.get(),e),t=n(_.get(),t),e[2]=0,t[2]=0,r[2]=0),{up:e,right:t,corner:r}}_updateTransform(){this.isDraped?this.drapedResources.recreateGeometry():this._updateTransformObject3D()}_updateTransformObject3D(e=this.object3dResources.object){if(!e)return;const i=this.view.state.camera,s=this._size*i.computeScreenPixelSizeAt(this._position),a=Math.min(this._maxSize,s);t(v,this._position),r(v,v,[a,a,a]),e.transformation=v}_setTransformDraped(e){if(0===e.length)return;const{view:{overlayManager:i,state:{contentPixelRatio:s}}}=this,{_position:a,_size:o}=this,l=n(_.get(),a);l[2]=f;const c=x;c.spatialReference=i.spatialReference,c.x=l[0],c.y=l[1];const u=o*(this.view.overlayPixelSizeInMapUnits(c)*s),d=Math.min(this._maxSize,u);t(v,l),r(v,v,[d,d,1]);for(const t of e)t.transformation=v}get _quadMaterialParameters(){return{color:this._color,forceTransparentMode:!0,writeDepth:!1,polygonOffset:1,renderOccluded:this._renderOccluded,isDecoration:this.isDecoration,testsTransparentRenderOrder:this._transparentRenderOrder}}_updateQuadMaterial(){this.object3dResources.resources?.quadMaterial.setParameters(this._quadMaterialParameters),this.drapedResources.resources?.quadMaterial.setParameters(this._quadMaterialParameters)}get _outlineMaterialParameters(){return{color:this._outlineColor,width:this._outlineSize,renderOccluded:this._outlineRenderOccluded,isDecoration:this.isDecoration}}_updateOutlineMaterial(){this.object3dResources.resources?.outlineMaterial?.setParameters(this._outlineMaterialParameters),this.drapedResources.resources?.outlineMaterial?.setParameters(this._outlineMaterialParameters)}}function y(e){e.pixelRatioHandle.remove(),e.geometries=[]}function z(e,t,r,i){return new R(i,[["position",new M([0,0,0,...t,...e,...r],[0,1,2,1,2,3],3,!0)]])}const v=i(),x=p(0,0,void 0,null);export{w as RightAngleQuadVisualElement};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{debounce as r,ignoreAbortErrors as l,throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as a,sync as o,when as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{signal as c}from"../../../core/signal.js";import{Seconds as p,secondsFromMilliseconds as m}from"../../../core/time.js";import{property as g,subclass as f}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as _}from"../../../geometry/projectionUtils.js";import y from"../../../geometry/SpatialReference.js";import{fromExtent as v,intersection as w,toExtent as T,create as S,intersects as b}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as R}from"../../../geometry/support/spatialReferenceUtils.js";import x from"../../../symbols/support/ElevationInfo.js";import L from"./SubView3D.js";import{getFeatureTileId as A}from"./support/FeatureTileDescriptor.js";import{makeScheduleFunction as E}from"./support/makeScheduleFunction.js";import{debugFlags as j}from"../support/debugFlags.js";import{tileFilterDistance as M,scaleThresholdForLoadingAllTiles as P,defaultTransitionDuration as U,transitionDurationFactor as C,seamlessTransitionEnabled as I,densityFactor as W,loadAllTilesDensityFactor as F,averageLoadingTimeSmoothingFactor as D,fadeOutTime as k,fadeInTime as q,minimumTracingResolution as O}from"../support/flow/constants.js";import{isFullExtent as V,wrappedWidth as G,FlowQuery3D as B}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as H}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as z,createStreamlineGeometry as N}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Q}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as J}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as K}from"../support/flow/StreamlineResources3DShape.js";import{webMercatorWorldExtent as X}from"../terrain/TerrainConst.js";import{descendantsAtLevel as Y,tilesAreRelated as Z}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as $}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as ee}from"../webgl-engine/materials/RibbonLineMaterial.js";import{hasLayerBasedScaleVisibility as te,isInEffectiveScaleRange as ie}from"../../support/layerViewUtils.js";import{TaskPriority as se}from"../../support/Scheduler.js";import{simulationSettingsEqual as re,getPositions as le,getFlowSimulationSettings as ne}from"../../support/flow/utils.js";let ae=class extends L{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=c(!0),this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideSeamlessTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=r(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*s(s){for(let r=0;r<e.length;++r){const l=e.at(r);t(l)&&i.add(l),s.madeProgress(),s.done&&(s=yield)}}await this.frameTask.scheduleGenerator(s),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new H(E(i)),this.frameTask=i.scheduler.registerTask(se.FLOW_GENERATOR),this._updateTask=h({update:()=>this._update()}),this.addHandles([a(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&re(e,t)}),a(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this.visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),o),u(()=>!this.view.animationsEnabled,()=>{const{_resources:e,_lastResources:t}=this;null!=e&&(e.startTime=he),null!=t&&(t.startTime=he)},o),a(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),u(()=>e.allTilesCreated,()=>this._triggerTilesUpdate(),o),t.enableFeatureTiles(),a(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),a(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],s=e?.visualVariables??[];s.length===i.length&&s.every((e,t)=>e.type===i[t].type)||this.clear()}),u(()=>!t.featureTiles?.updating,()=>{this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear(),this.notifyChange("updating")}abort(){this._abortController=s(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=_(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _dataBounds(){const e=this._fullExtentSurfaceSpatialReference;return null==e?null:v(e)}get _fullExtentSurfaceSpatialReference(){return _(this.layer.fullExtent,this.surface.spatialReference).geometry}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get extent(){if(this.loadAllTiles)return ce(this._fullExtentSurfaceSpatialReference);const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<M&&e.add(t)}),t=e}const s=Q(t,this.spatialReferenceInfo);return null==s?null:(w(s,this._clippingArea,s),ce(T(s,e)))}get loadAllTiles(){return this.view.scale>(j.FLOW_GLOBAL_SCALE_THRESHOLD??P)}get isDataGlobal(){const{extent:e,spatialReferenceInfo:t}=this;return null!=e&&V(e.xmin,e.xmax,t)}get loadAllTilesLevel(){const{tilingScheme:e}=this.surface;return Math.min(Math.ceil(e.levelAtScale(j.FLOW_GLOBAL_SCALE_THRESHOLD??P)),e.getMaxLod())}get targetTiles(){const e=new Map;if(this.loadAllTiles){const{_dataBounds:t}=this;if(null==t)return e;const i=S(),s=this.loadAllTilesLevel,r=this.surface.tilingScheme,l=r.rootTilesInExtent(t).flatMap(e=>Y(e,s));for(const n of l){const[l,a,o]=n;r.getExtent(s,a,o,i),ue(t,i)&&e.set(A(s,a,o),n)}return e}const{renderedTiles:t}=this;for(const i of t??[])e.set(i.key,i.lij);return e}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=_(e,this.surface.spatialReference).geometry;return null==t?null:v(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...z(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&"screenSizePerspectiveEnabled"in this.layer&&$(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?U:this._averageLoadingTime*C)}get _transitionEnabled(){return this.view.qualitySettings.flow.transitionEnabled}get _seamlessTransitionEnabled(){return!!this._transitionEnabled&&(null!=this._overrideSeamlessTransitionEnabled?this._overrideSeamlessTransitionEnabled:I)}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=G(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,s]=this.view.size;let r,l;i<s?(r=i,l=i/t):(r=s*t,l=s);const n=O,a=this.view.qualitySettings.flow.maxTracingResolution,o=Math.max(1,n/Math.min(r,l)),u=o*Math.min(1,a/Math.max(r*o,l*o));return[Math.round(r*u),Math.round(l*u)]}get visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _effectiveDensity(){const{_simulationSettings:e}=this;if(null==e)return 0;const t=e.density*this.view.quality;return e.lineSpacing/Math.sqrt(t)<e.lineCollisionWidth?(e.lineSpacing/e.lineCollisionWidth)**2:t}get elevationInfo(){return("elevationInfo"in this.layer?this.layer.elevationInfo:void 0)??oe}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:le(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return R(this.surface.spatialReference)}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&(this.renderedTiles.size>0||this.loadAllTiles)&&null!=this.extent}hasWork(){return null==this.extent||this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this._debugAllowAutoLoading.value&&this.visible&&!(this.destroyed||this.destroying)&&this.hasWork()}get visibleAtCurrentScale(){return!te()||ie(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=ne(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,i.maxNumberOfStreamlines=this.view.qualitySettings.flow.maxTotalNumberOfStreamlines,i.density*=W,this.loadAllTiles&&this.isDataGlobal&&(i.density*=F),null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const s="global"===this.view.viewingMode&&null!=i&&V(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:s,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(){const e=this._time;this._lastResources?.hasFadedOut(e)&&this._lastResources.detach();const t=this._nextStateForTransition(e);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==t||!this.loadRequirementsMet)return void(this._loadingState=t);this._loadingState="loading";const i=async()=>{const t=this._time,i=this._seamlessTransitionEnabled&&null!=this._resources?p(e+this._seamlessTransitionWaitingTime):e;await this._load(i);const s=p((this._time-t)/1e3);this._updateAverageLoadingTime(s)};this.updatingHandles.consumePromise(l(i())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=D;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading.value&&(this.visible?this.requireLoad=!0:this.clear())}get _time(){return m(this.layerView.view.stage.renderer.renderContext.time)}async _load(e){const{extent:t,view:i}=this;if(!this.visible)return void this.clear();if(null==t)return void(this._loadingState="ready-to-load");this._transitionEnabled||(this._lastResources?.detach(),this._lastResources=null,this._resources?.detach(),this._resources=null);const s=new B(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const r=this._abortController;try{const t=await this._loadStreamlines(s,r.signal);if(n(r.signal),null!=t){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=t;const i=this._getStartTime(e);null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,this.view.animationsEnabled||(this._lastResources?.detach(),this._lastResources=null),await t.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}catch(l){this._loadingState="ready-to-load"}}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:s,material:r}=await this._createGeometry(e,i);return this._draped?new J(e,i,r,s,this.layerView):new K(e,i,r,s,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new ee(this._materialParameters,this.view.state.isGlobal),s=new Array,{elevationInfo:r,_draped:l,view:n}=this;function*a(a){for(let o=0;o<t.length;++o)s.push(N(n,e,t[o],r,i,l)),a.madeProgress(),a.done&&(a=yield)}return await this.frameTask.scheduleGenerator(a),{geometries:s,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.consumePromise(l(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:s,loadAllTiles:r}=this;if(r){const{loadAllTilesLevel:t}=this;return i=>i.level===t&&ue(e,i.extent)}const l=t=>t.rendered&&t.visible&&ue(e,t.extent),{featureTiles:n}=i;if(!n)return l;const a=n.tiles.filter(e=>e.measures.visible);return e=>l(e)&&ue(s,e.extent)&&a.some(({lij:i})=>t(i,e.lij)||Z(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+k?"transitioning":"ready-to-load"}_getStartTime(e){if(!this.view.animationsEnabled)return he;const t=this._time;return p(t>e?t:e)}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],ae.prototype,"type",void 0),e([g()],ae.prototype,"renderedTiles",void 0),e([g()],ae.prototype,"_resources",void 0),e([g()],ae.prototype,"_lastResources",void 0),e([g()],ae.prototype,"requireLoad",void 0),e([g()],ae.prototype,"_averageLoadingTime",void 0),e([g()],ae.prototype,"_loadingState",void 0),e([g()],ae.prototype,"emissiveStrength",void 0),e([g()],ae.prototype,"_clippingArea",null),e([g()],ae.prototype,"_dataBounds",null),e([g()],ae.prototype,"_fullExtentSurfaceSpatialReference",null),e([g()],ae.prototype,"_draped",null),e([g()],ae.prototype,"extent",null),e([g()],ae.prototype,"loadAllTiles",null),e([g()],ae.prototype,"isDataGlobal",null),e([g()],ae.prototype,"loadAllTilesLevel",null),e([g()],ae.prototype,"targetTiles",null),e([g()],ae.prototype,"_featureTilesBounds",null),e([g()],ae.prototype,"_flowRenderer",null),e([g()],ae.prototype,"_materialParameters",null),e([g()],ae.prototype,"_opacity",null),e([g()],ae.prototype,"_seamlessTransitionWaitingTime",null),e([g()],ae.prototype,"_transitionEnabled",null),e([g()],ae.prototype,"_seamlessTransitionEnabled",null),e([g()],ae.prototype,"_tracingResolution",null),e([g()],ae.prototype,"visible",null),e([g()],ae.prototype,"_effectiveDensity",null),e([g()],ae.prototype,"elevationInfo",null),e([g()],ae.prototype,"needsMagnitude",null),e([g()],ae.prototype,"spatialReferenceInfo",null),e([g()],ae.prototype,"loadingState",null),e([g()],ae.prototype,"updating",null),e([g()],ae.prototype,"visibleAtCurrentScale",null),e([g()],ae.prototype,"_overrideMaterialParameters",void 0),e([g()],ae.prototype,"_overrideSimulationSettings",void 0),e([g()],ae.prototype,"_overrideSeamlessTransitionEnabled",void 0),e([g()],ae.prototype,"_simulationSettings",null),e([g()],ae.prototype,"surface",null),ae=e([f("esri.views.3d.layers.FlowSubView3D")],ae);const oe=new x({mode:"on-the-ground"});function ue(e,t){return null==e||null==t||b(e,t)}const de=T(X,y.WebMercator),he=p(-q);function ce(e){return null!=e&&e.spatialReference.isWebMercator?e?.intersection(de):e}export{ae as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{debounce as r,ignoreAbortErrors as l,throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as a,sync as o,when as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{signal as c}from"../../../core/signal.js";import{Seconds as p,secondsFromMilliseconds as m}from"../../../core/time.js";import{property as g,subclass as f}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as _}from"../../../geometry/projectionUtils.js";import y from"../../../geometry/SpatialReference.js";import{fromExtent as v,intersection as w,toExtent as T,create as S,intersects as b}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as R}from"../../../geometry/support/spatialReferenceUtils.js";import x from"../../../symbols/support/ElevationInfo.js";import L from"./SubView3D.js";import{getFeatureTileId as A}from"./support/FeatureTileDescriptor.js";import{makeScheduleFunction as E}from"./support/makeScheduleFunction.js";import{debugFlags as j}from"../support/debugFlags.js";import{tileFilterDistance as M,scaleThresholdForLoadingAllTiles as P,defaultTransitionDuration as U,transitionDurationFactor as C,seamlessTransitionEnabled as I,densityFactor as W,loadAllTilesDensityFactor as F,averageLoadingTimeSmoothingFactor as D,fadeOutTime as k,fadeInTime as q,minimumTracingResolution as O}from"../support/flow/constants.js";import{isFullExtent as V,wrappedWidth as G,FlowQuery3D as B}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as H}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as z,createStreamlineGeometry as N}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Q}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as J}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as K}from"../support/flow/StreamlineResources3DShape.js";import{webMercatorWorldExtent as X}from"../terrain/TerrainConst.js";import{descendantsAtLevel as Y,tilesAreRelated as Z}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as $}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as ee}from"../webgl-engine/materials/RibbonLineMaterial.js";import{hasLayerBasedScaleVisibility as te,isInEffectiveScaleRange as ie}from"../../support/layerViewUtils.js";import{TaskPriority as se}from"../../support/Scheduler.js";import{simulationSettingsEqual as re,getPositions as le,getFlowSimulationSettings as ne}from"../../support/flow/utils.js";let ae=class extends L{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=c(!0),this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideSeamlessTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=r(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*s(s){for(let r=0;r<e.length;++r){const l=e.at(r);t(l)&&i.add(l),s.madeProgress(),s.done&&(s=yield)}}await this.frameTask.scheduleGenerator(s),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new H(E(i)),this.frameTask=i.scheduler.registerTask(se.FLOW_GENERATOR),this._updateTask=h({update:()=>this._update()}),this.addHandles([a(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&re(e,t)}),a(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this.visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),o),u(()=>!this.view.animationsEnabled,()=>{const{_resources:e,_lastResources:t}=this;null!=e&&(e.startTime=he),null!=t&&(t.startTime=he)},o),a(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),u(()=>e.allTilesCreated,()=>this._triggerTilesUpdate(),o),t.enableFeatureTiles(),a(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),a(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],s=e?.visualVariables??[];s.length===i.length&&s.every((e,t)=>e.type===i[t].type)||this.clear()}),u(()=>!t.featureTiles?.updating,()=>{this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear(),this.notifyChange("updating")}abort(){this._abortController=s(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=_(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _dataBounds(){const e=this._fullExtentSurfaceSpatialReference;return null==e?null:v(e)}get _fullExtentSurfaceSpatialReference(){return _(this.layer.fullExtent,this.surface.spatialReference).geometry}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get extent(){if(this.loadAllTiles)return ce(this._fullExtentSurfaceSpatialReference);const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<M&&e.add(t)}),t=e}const s=Q(t,this.spatialReferenceInfo);return null==s?null:(w(s,this._clippingArea,s),ce(T(s,e)))}get loadAllTiles(){return this.view.scale>(j.FLOW_GLOBAL_SCALE_THRESHOLD??P)}get isDataGlobal(){const{extent:e,spatialReferenceInfo:t}=this;return null!=e&&V(e.xmin,e.xmax,t)}get loadAllTilesLevel(){const{tilingScheme:e}=this.surface;return Math.min(Math.ceil(e.levelAtScale(j.FLOW_GLOBAL_SCALE_THRESHOLD??P)),e.getMaxLod())}get targetTiles(){const e=new Map;if(this.loadAllTiles){const{_dataBounds:t}=this;if(null==t)return e;const i=S(),s=this.loadAllTilesLevel,r=this.surface.tilingScheme,l=r.rootTilesInExtent(t).flatMap(e=>Y(e,s));for(const n of l){const[l,a,o]=n;r.getExtent(s,a,o,i),ue(t,i)&&e.set(A(s,a,o),n)}return e}const{renderedTiles:t}=this;for(const i of t??[])e.set(i.key,i.lij);return e}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=_(e,this.surface.spatialReference).geometry;return null==t?null:v(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"===e?.type?e:null}get _materialParameters(){return{...z(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&"screenSizePerspectiveEnabled"in this.layer&&$(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?U:this._averageLoadingTime*C)}get _transitionEnabled(){return this.view.qualitySettings.flow.transitionEnabled}get _seamlessTransitionEnabled(){return!!this._transitionEnabled&&(null!=this._overrideSeamlessTransitionEnabled?this._overrideSeamlessTransitionEnabled:I)}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=G(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,s]=this.view.size;let r,l;i<s?(r=i,l=i/t):(r=s*t,l=s);const n=O,a=this.view.qualitySettings.flow.maxTracingResolution,o=Math.max(1,n/Math.min(r,l)),u=o*Math.min(1,a/Math.max(r*o,l*o));return[Math.round(r*u),Math.round(l*u)]}get visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _effectiveDensity(){const{_simulationSettings:e}=this;if(null==e)return 0;const t=e.density*this.view.quality;return e.lineSpacing/Math.sqrt(t)<e.lineCollisionWidth?(e.lineSpacing/e.lineCollisionWidth)**2:t}get elevationInfo(){return("elevationInfo"in this.layer?this.layer.elevationInfo:void 0)??oe}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:le(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return R(this.surface.spatialReference)}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&(this.renderedTiles.size>0||this.loadAllTiles)&&null!=this.extent}hasWork(){return null==this.extent||this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this._debugAllowAutoLoading.value&&this.visible&&!(this.destroyed||this.destroying)&&this.hasWork()}get visibleAtCurrentScale(){return!te()||ie(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=ne(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,i.maxNumberOfStreamlines=this.view.qualitySettings.flow.maxTotalNumberOfStreamlines,i.density*=W,this.loadAllTiles&&this.isDataGlobal&&(i.density*=F),null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const s="global"===this.view.viewingMode&&null!=i&&V(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:s,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(){const e=this._time;this._lastResources?.hasFadedOut(e)&&this._lastResources.detach();const t=this._nextStateForTransition(e);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==t||!this.loadRequirementsMet)return void(this._loadingState=t);this._loadingState="loading";const i=async()=>{const t=this._time,i=this._seamlessTransitionEnabled&&null!=this._resources?p(e+this._seamlessTransitionWaitingTime):e;await this._load(i);const s=p((this._time-t)/1e3);this._updateAverageLoadingTime(s)};this.updatingHandles.consumePromise(l(i())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=D;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading.value&&(this.visible?this.requireLoad=!0:this.clear())}get _time(){return m(this.layerView.view.stage.renderer.renderContext.time)}async _load(e){const{extent:t,view:i}=this;if(!this.visible)return void this.clear();if(null==t)return void(this._loadingState="ready-to-load");this._transitionEnabled||(this._lastResources?.detach(),this._lastResources=null,this._resources?.detach(),this._resources=null);const s=new B(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const r=this._abortController;try{const t=await this._loadStreamlines(s,r.signal);if(n(r.signal),null!=t){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=t;const i=this._getStartTime(e);null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,this.view.animationsEnabled||(this._lastResources?.detach(),this._lastResources=null),await t.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}catch(l){this._loadingState="ready-to-load"}}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:s,material:r}=await this._createGeometry(e,i);return this._draped?new J(e,i,r,s,this.layerView):new K(e,i,r,s,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new ee(this._materialParameters,this.view.state.isGlobal),s=new Array,{elevationInfo:r,_draped:l,view:n}=this;function*a(a){for(let o=0;o<t.length;++o)s.push(N(n,e,t[o],r,i,l)),a.madeProgress(),a.done&&(a=yield)}return await this.frameTask.scheduleGenerator(a),{geometries:s,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.consumePromise(l(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:s,loadAllTiles:r}=this;if(r){const{loadAllTilesLevel:t}=this;return i=>i.level===t&&ue(e,i.extent)}const l=t=>t.rendered&&t.visible&&ue(e,t.extent),{featureTiles:n}=i;if(!n)return l;const a=n.tiles.filter(e=>e.measures.visible);return e=>l(e)&&ue(s,e.extent)&&a.some(({lij:i})=>t(i,e.lij)||Z(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+k?"transitioning":"ready-to-load"}_getStartTime(e){if(!this.view.animationsEnabled)return he;const t=this._time;return p(t>e?t:e)}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],ae.prototype,"type",void 0),e([g()],ae.prototype,"renderedTiles",void 0),e([g()],ae.prototype,"_resources",void 0),e([g()],ae.prototype,"_lastResources",void 0),e([g()],ae.prototype,"requireLoad",void 0),e([g()],ae.prototype,"_averageLoadingTime",void 0),e([g()],ae.prototype,"_loadingState",void 0),e([g()],ae.prototype,"emissiveStrength",void 0),e([g()],ae.prototype,"_clippingArea",null),e([g()],ae.prototype,"_dataBounds",null),e([g()],ae.prototype,"_fullExtentSurfaceSpatialReference",null),e([g()],ae.prototype,"_draped",null),e([g()],ae.prototype,"extent",null),e([g()],ae.prototype,"loadAllTiles",null),e([g()],ae.prototype,"isDataGlobal",null),e([g()],ae.prototype,"loadAllTilesLevel",null),e([g()],ae.prototype,"targetTiles",null),e([g()],ae.prototype,"_featureTilesBounds",null),e([g()],ae.prototype,"_flowRenderer",null),e([g()],ae.prototype,"_materialParameters",null),e([g()],ae.prototype,"_opacity",null),e([g()],ae.prototype,"_seamlessTransitionWaitingTime",null),e([g()],ae.prototype,"_transitionEnabled",null),e([g()],ae.prototype,"_seamlessTransitionEnabled",null),e([g()],ae.prototype,"_tracingResolution",null),e([g()],ae.prototype,"visible",null),e([g()],ae.prototype,"_effectiveDensity",null),e([g()],ae.prototype,"elevationInfo",null),e([g()],ae.prototype,"needsMagnitude",null),e([g()],ae.prototype,"spatialReferenceInfo",null),e([g()],ae.prototype,"loadingState",null),e([g()],ae.prototype,"updating",null),e([g()],ae.prototype,"visibleAtCurrentScale",null),e([g()],ae.prototype,"_overrideMaterialParameters",void 0),e([g()],ae.prototype,"_overrideSimulationSettings",void 0),e([g()],ae.prototype,"_overrideSeamlessTransitionEnabled",void 0),e([g()],ae.prototype,"_simulationSettings",null),e([g()],ae.prototype,"surface",null),ae=e([f("esri.views.3d.layers.FlowSubView3D")],ae);const oe=new x({mode:"on-the-ground"});function ue(e,t){return null==e||null==t||b(e,t)}const de=T(X,y.WebMercator),he=p(-q);function ce(e){return null!=e&&e.spatialReference.isWebMercator?e?.intersection(de):e}export{ae as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{removeMaybe as i}from"../../../core/maybe.js";import{watch as s,initial as r}from"../../../core/reactiveUtils.js";import{unitFromRESTJSON as a,convertUnit as n}from"../../../core/units.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as d}from"../../../geometry/ellipsoidUtils.js";import u from"../../../geometry/HeightModelInfo.js";import{create as m}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as p}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as c,isWebMercator as f,equals as g,isGeographic as y}from"../../../geometry/support/spatialReferenceUtils.js";import _ from"../../../geometry/support/WKIDUnitConversion.js";import{getHeightModelInfoFromVCS as w}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as v}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as b}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as x}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as S}from"./LayerView3D.js";import{addLayerViewToWasm as C,getLyr3DWasm as H,removeLayerViewFromWasm as M}from"./Lyr3DWasm.js";import{LayerElevationProvider as E}from"./i3s/LayerElevationProvider.js";import{ElevationRange as P}from"../support/ElevationRange.js";import{projectToBoundingBox as j}from"../support/extentUtils.js";import{Obb as U}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as A,elementsPerSplatPage as G,packedGaussianSizeInU32 as V,splatPageSizeInU32WithoutHeader as R,gaussiansPerSplatPage as I,splatAtlasTextureWidth as O}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as T}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as L}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as B}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as F}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as k}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import D from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as N,isInEffectiveScaleRange as z}from"../../support/layerViewUtils.js";import{TaskPriority as q}from"../../support/Scheduler.js";const W=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D");let $=class extends(S(D)){constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(A),this._tmpObbsWithChangedVisibility=new Array,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(q.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=m();return j(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderNode?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw N("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=C(this).then(e=>{this._wasmLayerId=e,this._renderNode=new k({view:this.view,layerView:this}),this.data=new T(this._renderNode),this.fadeHelper=new L(this),this._intersectionHandler=new B(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new E({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([s(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),s(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),r)]),this._suspendedHandle=s(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r),this.addHandles([s(()=>this._clippingBox,e=>this._renderNode.clippingBox=e,r)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians)});this.addHandles([s(()=>this.view.qualitySettings.fadeDuration,e=>{this.fadeHelper.onFadeDurationChanged(e),this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}),s(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),s(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return H(this.view)}get usedMemory(){return this._usedMemory}get cachedMemory(){return this._cacheMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return v(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new P(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return z(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=t.desc.prims[0],s=i.vertexCount,r=i.atrbs[0].view,a=i.atrbs[0].view.byteCount,n=i.atrbs[0].view.byteOffset;let o=null;if("U32"!==r.type)return W().warnOnce("unexpected meshData.data format"),{memUsageBytes:0,numGaussians:0};o=new Uint32Array(t.data.buffer,n,a/4);const l=this.extractHeader(o),u=Math.ceil(s/I),m=new Uint32Array(s),p=new Array;let c=!1,f=0;const g=async e=>{for(;f<u&&!e.done&&!c;f++){let t=this.data.textureAtlas.requestPage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.requestPage()),null!==t){p.push(t);const i=s-f*I,r=Math.min(i,I),a=f*I;for(let e=0;e<r;e++)m[e+a]=e+G*t;const n=f*R;this._pageBuffer.set(o.subarray(n,n+r*V)),this._pageBuffer.set(l.packedHeader,R);const h=t*G,d=h%O,u=Math.floor(h/O);this.data.textureAtlas.update(d,u,this._pageBuffer),e.madeProgress()}else c=!0}f<u&&!c&&await this._frameTask.schedule(g)};if(await this._frameTask.schedule(g),c)return W().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};const y=new Float32Array(3*s),_=new Float32Array(s),w=2.048,v=l.tileOrigin.x*w,b=l.tileOrigin.y*w,x=l.tileOrigin.z*w,S=l.invPosScale;let C=null;if(t.desc.obb){const e=t.desc.obb.quaternion;C=new U(t.desc.obb.center,t.desc.obb.halfSize,h(...e))}C||(W().warnOnce("encountered tile without a bounding box"),C=new U);const H=C.centerX,M=C.centerY,E=C.centerZ,j=new P,A=this.view.state.isGlobal,T=A?d(this.view.spatialReference).radius:0;let L=0,B=0,k=0;const D=async e=>{for(;k<s&&!e.done;k++){const t=k*V,{rawX:i,rawY:s,rawZ:r}=this._extractGaussianPosition(o,t),a=this._extractGaussianSphericalScale(o,t),n=i*S+v,l=s*S+b,h=r*S+x;y[L]=n-H,y[L+1]=l-M,y[L+2]=h-E;const d=A?Math.sqrt(n*n+l*l+h*h)-T:h;j.expandElevationRangeValues(d,d),_[k]=a*a,B=Math.max(B,a),L+=3,e.madeProgress()}k<s&&await this._frameTask.schedule(D)};await this._frameTask.schedule(D);const{fullExtent:N}=this.layer;N?.hasZ&&N.zmax&&N.zmin&&(j.minElevation=Math.max(j.minElevation,N.zmin),j.maxElevation=Math.min(j.maxElevation,N.zmax));const z=new F(e.handle,C,m,p,y,_,B,j);return this._memCache.put(`${z.handle}`,z),this._tileHandles.set(e.handle,z),this._cacheMemory+=z.usedMemory,{memUsageBytes:z.usedMemory,numGaussians:s}}_extractGaussianPosition(e,t){const i=e[t+1];return{rawX:16383&i,rawY:i>>>14&16383,rawZ:i>>>28&15|(1023&e[t+2])<<4}}_extractGaussianSphericalScale(e,t){const i=e[t+2],s=i>>>10&255,r=i>>>18&255,a=i>>>26&63|(3&e[t+3])<<6,n=Math.exp(s/16-10),o=Math.exp(r/16-10),l=Math.exp(a/16-10);return Math.max(n,o,l)}freeRenderable(e){const t=this._tileHandles.get(e);t&&(t.isVisible&&!this.fadeHelper.isTileFadingOut(t)?this._usedMemory-=t.usedMemory:this._cacheMemory-=t.usedMemory,t.pageIds.forEach(e=>this.data.textureAtlas.freePage(e)),this.freeObject(t),this._tileHandles.delete(e)),this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}setRenderableVisibility(e,t,i){const s=this._tmpObbsWithChangedVisibility;s.length=0;for(let r=0;r<i;r++){if(!t[r])continue;const i=e[r],a=this._tileHandles.get(i);a&&(a.isVisible&&!this.fadeHelper.isTileFadingOut(a)||(a.isVisible=!0,s.push(a.obb),this.fadeHelper.isTileFadingOut(a)||this._popTileFromCache(a),this.fadeHelper.fadeTile(a,0)))}for(let r=0;r<i;r++){if(t[r])continue;const i=e[r],a=this._tileHandles.get(i);a&&a.isVisible&&(s.push(a.obb),this.fadeHelper.fadeTile(a,1))}s.length>0&&this._elevationProvider&&this._elevationProvider.notifyObjectsChanged(s),this.updateGaussians()}_popTileFromCache(e){this._usedMemory+=e.usedMemory,this._cacheMemory-=e.usedMemory,this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedMemory-=e.usedMemory,this._cacheMemory+=e.usedMemory,this._memCache.put(`${e.handle}`,e)}destroy(){M(this),this._suspendedHandle&&(this._suspendedHandle=i(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>{for(const t of this._tileHandles.values())e(t.obb)}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._renderNode.destroy(),this.data.destroy(),this._memCache.destroy()}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(c(this.view.renderSpatialReference)||f(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&g(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=w(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!y(t)&&t.wkid&&-1!==t.wkid&&(i=a(_.units[_[t.wkid]])),i&&(e=new u({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===p(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=n(1,"meters",e.heightUnit)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=b(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,v(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderNode&&(this._renderNode.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())t.isVisible&&e.push(t);this.data.updateGaussianVisibility(e),this.notifyChange("updating")}setMaximumGaussianCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())e.isVisible||this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),r=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:r},invPosScale:a}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;return this._tileHandles.forEach(i=>{i.isVisible?e++:t++}),new x(this.usedMemory,e,t,this.cachedMemory)}get test(){}};e([o()],$.prototype,"layer",void 0),e([o({readOnly:!0})],$.prototype,"_clippingBox",null),e([o()],$.prototype,"elevationOffset",null),e([o({readOnly:!0})],$.prototype,"visibleAtCurrentScale",null),e([o()],$.prototype,"fullExtentInLocalViewSpatialReference",void 0),$=e([l("esri.views.3d.layers.GaussianSplatLayerView3D")],$);const X=$;export{X as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{removeMaybe as i}from"../../../core/maybe.js";import{watch as s,initial as r}from"../../../core/reactiveUtils.js";import{unitFromRESTJSON as a,convertUnit as n}from"../../../core/units.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as d}from"../../../geometry/ellipsoidUtils.js";import u from"../../../geometry/HeightModelInfo.js";import{create as m}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as p}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as c,isWebMercator as f,equals as g,isGeographic as y}from"../../../geometry/support/spatialReferenceUtils.js";import _ from"../../../geometry/support/WKIDUnitConversion.js";import{getHeightModelInfoFromVCS as w}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as v}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as b}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as x}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as S}from"./LayerView3D.js";import{addLayerViewToWasm as C,getLyr3DWasm as H,removeLayerViewFromWasm as M}from"./Lyr3DWasm.js";import{LayerElevationProvider as E}from"./i3s/LayerElevationProvider.js";import{ElevationRange as P}from"../support/ElevationRange.js";import{projectToBoundingBox as j}from"../support/extentUtils.js";import{Obb as U}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as T,elementsPerSplatPage as A,packedGaussianSizeInU32 as G,splatPageSizeInU32WithoutHeader as V,gaussiansPerSplatPage as R,splatAtlasTextureWidth as I}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as O}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as L}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as B}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as F}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as k}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import D from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as N,isInEffectiveScaleRange as z}from"../../support/layerViewUtils.js";import{TaskPriority as q}from"../../support/Scheduler.js";const W=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D");let $=class extends(S(D)){constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(T),this._tmpTilesWithChangedVisibility=new Array,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(q.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=m();return j(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderNode?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw N("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=C(this).then(e=>{this._wasmLayerId=e,this._renderNode=new k({view:this.view,layerView:this}),this.data=new O(this._renderNode),this.fadeHelper=new L(this),this._intersectionHandler=new B(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new E({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([s(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),s(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),r)]),this._suspendedHandle=s(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r),this.addHandles([s(()=>this._clippingBox,e=>this._renderNode.clippingBox=e,r)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians)});this.addHandles([s(()=>this.view.qualitySettings.fadeDuration,e=>{this.fadeHelper.onFadeDurationChanged(e),this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}),s(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),s(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return H(this.view)}get usedMemory(){return this._usedMemory}get cachedMemory(){return this._cacheMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return v(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new P(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return z(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=t.desc.prims[0],s=i.vertexCount,r=i.atrbs[0].view,a=i.atrbs[0].view.byteCount,n=i.atrbs[0].view.byteOffset;let o=null;if("U32"!==r.type)return W().warnOnce("unexpected meshData.data format"),{memUsageBytes:0,numGaussians:0};o=new Uint32Array(t.data.buffer,n,a/4);const l=this.extractHeader(o),u=Math.ceil(s/R),m=new Uint32Array(s),p=new Array;let c=!1,f=0;const g=async e=>{for(;f<u&&!e.done&&!c;f++){let t=this.data.textureAtlas.requestPage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.requestPage()),null!==t){p.push(t);const i=s-f*R,r=Math.min(i,R),a=f*R;for(let e=0;e<r;e++)m[e+a]=e+A*t;const n=f*V;this._pageBuffer.set(o.subarray(n,n+r*G)),this._pageBuffer.set(l.packedHeader,V);const h=t*A,d=h%I,u=Math.floor(h/I);this.data.textureAtlas.update(d,u,this._pageBuffer),e.madeProgress()}else c=!0}f<u&&!c&&await this._frameTask.schedule(g)};if(await this._frameTask.schedule(g),c)return W().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};const y=new Float32Array(3*s),_=new Float32Array(s),w=2.048,v=l.tileOrigin.x*w,b=l.tileOrigin.y*w,x=l.tileOrigin.z*w,S=l.invPosScale;let C=null;if(t.desc.obb){const e=t.desc.obb.quaternion;C=new U(t.desc.obb.center,t.desc.obb.halfSize,h(...e))}C||(W().warnOnce("encountered tile without a bounding box"),C=new U);const H=C.centerX,M=C.centerY,E=C.centerZ,j=new P,T=this.view.state.isGlobal,O=T?d(this.view.spatialReference).radius:0;let L=0,B=0,k=0;const D=async e=>{for(;k<s&&!e.done;k++){const t=k*G,{rawX:i,rawY:s,rawZ:r}=this._extractGaussianPosition(o,t),a=this._extractGaussianSphericalScale(o,t),n=i*S+v,l=s*S+b,h=r*S+x;y[L]=n-H,y[L+1]=l-M,y[L+2]=h-E;const d=T?Math.sqrt(n*n+l*l+h*h)-O:h;j.expandElevationRangeValues(d,d),_[k]=a*a,B=Math.max(B,a),L+=3,e.madeProgress()}k<s&&await this._frameTask.schedule(D)};await this._frameTask.schedule(D);const{fullExtent:N}=this.layer;N?.hasZ&&N.zmax&&N.zmin&&(j.minElevation=Math.max(j.minElevation,N.zmin),j.maxElevation=Math.min(j.maxElevation,N.zmax));const z=new F(e.handle,C,m,p,y,_,B,j);return this._memCache.put(`${z.handle}`,z),this._tileHandles.set(e.handle,z),this._cacheMemory+=z.usedMemory,{memUsageBytes:z.usedMemory,numGaussians:s}}_extractGaussianPosition(e,t){const i=e[t+1];return{rawX:16383&i,rawY:i>>>14&16383,rawZ:i>>>28&15|(1023&e[t+2])<<4}}_extractGaussianSphericalScale(e,t){const i=e[t+2],s=i>>>10&255,r=i>>>18&255,a=i>>>26&63|(3&e[t+3])<<6,n=Math.exp(s/16-10),o=Math.exp(r/16-10),l=Math.exp(a/16-10);return Math.max(n,o,l)}freeRenderable(e){const t=this._tileHandles.get(e);t&&(t.isVisible?(this.fadeHelper.onTileDiscarded(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,t.pageIds.forEach(e=>this.data.textureAtlas.freePage(e)),this.freeObject(t),this._tileHandles.delete(e)),this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(t=>{for(const i of e)t(i.obb)})}setRenderableVisibility(e,t,i){const s=this._tmpTilesWithChangedVisibility;s.length=0;for(let r=0;r<i;r++){if(!t[r])continue;const i=e[r],a=this._tileHandles.get(i);a&&(a.isVisible&&!this.fadeHelper.isTileFadingOut(a)||(a.isVisible=!0,s.push(a),this.fadeHelper.isTileFadingOut(a)||this._popTileFromCache(a),this.fadeHelper.fadeTile(a,0)))}for(let r=0;r<i;r++){if(t[r])continue;const i=e[r],a=this._tileHandles.get(i);a&&a.isVisible&&(s.push(a),this.fadeHelper.fadeTile(a,1))}s.length>0&&this.notifyTileObbsChanged(s),this.updateGaussians()}_popTileFromCache(e){this._usedMemory+=e.usedMemory,this._cacheMemory-=e.usedMemory,this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedMemory-=e.usedMemory,this._cacheMemory+=e.usedMemory,this._memCache.put(`${e.handle}`,e)}destroy(){M(this),this._suspendedHandle&&(this._suspendedHandle=i(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>{for(const t of this._tileHandles.values())e(t.obb)}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._renderNode.destroy(),this.data.destroy(),this._memCache.destroy()}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(c(this.view.renderSpatialReference)||f(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&g(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=w(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!y(t)&&t.wkid&&-1!==t.wkid&&(i=a(_.units[_[t.wkid]])),i&&(e=new u({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===p(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=n(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=b(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,v(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderNode&&(this._renderNode.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())t.isVisible&&e.push(t);this.data.updateGaussianVisibility(e),this.notifyChange("updating")}setMaximumGaussianCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())e.isVisible||this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),r=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:r},invPosScale:a}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;return this._tileHandles.forEach(i=>{i.isVisible?e++:t++}),new x(this.usedMemory,e,t,this.cachedMemory)}get test(){}};e([o()],$.prototype,"layer",void 0),e([o({readOnly:!0})],$.prototype,"_clippingBox",null),e([o()],$.prototype,"elevationOffset",null),e([o({readOnly:!0})],$.prototype,"visibleAtCurrentScale",null),e([o()],$.prototype,"fullExtentInLocalViewSpatialReference",void 0),$=e([l("esri.views.3d.layers.GaussianSplatLayerView3D")],$);const X=$;export{X as default};
|