@arcgis/core 5.0.0-next.60 → 5.0.0-next.61
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/analysis/VolumeMeasurement/volumeMeasurementConfiguration.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{1e8ceed33a3657ac02b3.js → 153ff2ceefccd946498b.js} +1 -1
- package/assets/esri/core/workers/chunks/{7147fc7502b385b302b2.js → 23b623637126f8411a30.js} +1 -1
- package/assets/esri/core/workers/chunks/{a7aa87e2c4197ba595ef.js → 2abc205f81f26fc4852b.js} +2 -2
- package/assets/esri/core/workers/chunks/{492d575894c7905bb70c.js → 3d49c6427120edc8eac9.js} +1 -1
- package/assets/esri/core/workers/chunks/{23a9dd9454d5249bbd59.js → 3da53c017f9c5d2d778a.js} +1 -1
- package/assets/esri/core/workers/chunks/{60362c5651ef41fa7e5f.js → 4cf2bec636dd8ceecf0c.js} +1 -1
- package/assets/esri/core/workers/chunks/{3d1a5a3467f3a6585b3e.js → 4f03d19a70dca6c507be.js} +1 -1
- package/assets/esri/core/workers/chunks/{5d31fbabaa875f8627c0.js → 631a11a2b2001c708527.js} +1 -1
- package/assets/esri/core/workers/chunks/{fa95c9248fbfab338f2e.js → 63b8cd7d5cafbaeed894.js} +1 -1
- package/assets/esri/core/workers/chunks/6b4a24248182245167ca.js +1 -0
- package/assets/esri/core/workers/chunks/{352c674730c7b7258ae3.js → 76086517591d0eb35156.js} +1 -1
- package/assets/esri/core/workers/chunks/{436f206898306df019ac.js → 7c47fefbf4c93b63200f.js} +1 -1
- package/assets/esri/core/workers/chunks/7e8573749a02e1f54fb1.js +1 -0
- package/assets/esri/core/workers/chunks/{424daef7b5dec1b99aba.js → af3e93a4ac3ff2addc90.js} +1 -1
- package/assets/esri/core/workers/chunks/{bf82bb1cdd8b31e7f2aa.js → bb08359610a41e304b55.js} +1 -1
- package/assets/esri/core/workers/chunks/{495b11fdecc3ba90d454.js → bfc063d4431bfa162160.js} +1 -1
- package/assets/esri/core/workers/chunks/d13b2ce8a89938b0472b.js +1 -0
- package/assets/esri/core/workers/chunks/{0483a2cfdb8c7158e73a.js → e85da52d9cc7d9396872.js} +1 -1
- package/assets/esri/core/workers/chunks/{1ced78750c61600b2d4e.js → f351007cdcd0938d3b6c.js} +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ar.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bg.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ca.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_cs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_da.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_de.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_el.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_es.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_et.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_he.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hu.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_id.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_it.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ja.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ko.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lt.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_nl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_no.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-BR.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-PT.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ro.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ru.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_th.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_tr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_uk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_vi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-CN.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-HK.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-TW.json +1 -1
- package/chunks/CutFillDepth.glsl.js +13 -10
- package/chunks/CutFillReduction.glsl.js +14 -8
- package/chunks/GaussianSplat.glsl.js +1 -1
- package/chunks/Laserlines.glsl.js +2 -2
- package/chunks/boundedPlane.js +1 -1
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/vec32.js +1 -1
- package/config.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/effects/FocusAreas.d.ts +1 -1
- package/geometry/support/lineSegment.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/kernel.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +1 -1
- package/layers/support/FieldsIndex.d.ts +2 -1
- package/layers/support/tiles3DUtils.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/flow/dataUtils.js +1 -1
- package/views/2d/engine/flow/utils.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/interactive/SegmentLabels2D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/environment/ChapmanApproximation.glsl.js +1 -1
- package/views/3d/environment/CloudsParameters.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/interactive/SegmentLabels3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementManipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/state/Frustum.js +1 -1
- package/views/3d/state/controllers/FovController.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/flow/FlowWorker.js +1 -1
- package/views/3d/support/flow/StreamlineResources3D.js +1 -1
- package/views/3d/support/flow/constants.js +1 -1
- package/views/3d/support/flow/geometryUtils.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/support/intersectionUtils.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/FBOCacheFormats.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
- package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
- package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
- package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +13 -12
- package/views/3d/webgl-engine/shaders/CutFillDepthTechniqueConfiguration.js +5 -0
- package/views/3d/webgl-engine/shaders/CutFillReductionTechniqueConfiguration.js +5 -0
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/coordinateHelper.js +1 -1
- package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
- package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
- package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/support/euclideanLengthMeasurementUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/webdoc/widgets/FloorFilter.js +1 -1
- package/widgets/Expand/ExpandViewModel.d.ts +1 -0
- package/widgets/Expand/ExpandViewModel.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/1e17ad6cdffa5016a3db.js +0 -1
- package/assets/esri/core/workers/chunks/21ebd234cf32ae52b3ea.js +0 -1
- package/assets/esri/core/workers/chunks/262c5794650853457acc.js +0 -1
- /package/effects/{FocusAreaStyle.d.ts → types.d.ts} +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{estimateNestedObjectMemory as e}from"../../../../core/memoryEstimations.js";import{Seconds as t}from"../../../../core/time.js";import{
|
|
5
|
+
import"../../../../core/has.js";import{estimateNestedObjectMemory as e}from"../../../../core/memoryEstimations.js";import{Seconds as t}from"../../../../core/time.js";import{fadeOutTime as s}from"./constants.js";import{FlowQuery3D as r}from"./FlowQuery3D.js";class i{constructor(e,s,r,i,m){this._query=e,this.streamlines=s,this._material=r,this.geometries=i,this._bytesPerFeature=m,this._endTime=t(1/0),this.usedMemory=null,this.computeMemory()}computeMemory(){const t=e(this.streamlines),s=e(this.geometries.map(e=>e.attributes)),r=this.streamlines.length*this._bytesPerFeature;this.usedMemory=t+s+r}get startTime(){return this._query.time}set startTime(e){this._query.time!==e&&(this._query=new r(this._query.extent,this._query.timeExtent,this._query.size,this._query.pixelRatio,t(e))),this.setMaterialParameters({startTime:e})}get endTime(){return this._endTime}set endTime(e){this._endTime!==e&&(this._endTime=e,this.setMaterialParameters({endTime:e}))}get query(){return this._query}hasFadedOut(e){return this.endTime+s<e}setMaterialParameters(e){this._material.setParameters(e)}get test(){return null}}export{i as StreamlineResources3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
import{Seconds as e}from"../../../../core/time.js";const o=.1,r=e(1),t=e(1),m=1e3,c=!1,i=3,p=1,s=27e6,f=501,j=256,n=!0,x=3,a=2,b=2;export{o as averageLoadingTimeSmoothingFactor,p as defaultTransitionDuration,a as densityFactor,t as fadeInTime,r as fadeOutTime,b as loadAllTilesDensityFactor,j as minimumTracingResolution,s as scaleThresholdForLoadingAllTiles,c as seamlessTransitionEnabled,f as streamlinGeometryBatchSize,x as tileFilterDistance,n as tileFilteringByDistanceEnabled,m as tilesWaitingTime,i as transitionDurationFactor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newFloatArray as o}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as e}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as r}from"../../../../support/elevationInfoUtils.js";import{convertVisualVariables as i,ConvertOptions as s}from"../../layers/support/FastSymbolUpdates.js";import{animatedLineStripsToParameters as n,createGeometry as a}from"../engineContent/line.js";import{valuesPerFlowVertex as l}from"./loadUtils.js";import{drapedZ as p}from"../../terrain/OverlayRenderer.js";function c(t,r,{vertices:i,stage:s,hasMagnitude:c},m,u,d){const{spatialReference:v}=r.extent,h=[],
|
|
5
|
+
import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newFloatArray as o}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as e}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as r}from"../../../../support/elevationInfoUtils.js";import{convertVisualVariables as i,ConvertOptions as s}from"../../layers/support/FastSymbolUpdates.js";import{animatedLineStripsToParameters as n,createGeometry as a}from"../engineContent/line.js";import{valuesPerFlowVertex as l}from"./loadUtils.js";import{drapedZ as p}from"../../terrain/OverlayRenderer.js";function c(t,r,{vertices:i,stage:s,hasMagnitude:c},m,u,d){const{spatialReference:v}=r.extent,h=[],g=l(c),y=r.flowExtentInfo.modelSize[0];let S=0;for(let o=0;o<i.length;o+=g){if(d&&o>0){const t=i[o]-i[o-g];t>y/2?S-=y:-t>y/2&&(S+=y)}const[e,s]=r.modelToMapSpace(i[o]+S,i[o+1],!1),n=d?[e,s,p]:f(e,s,v,t,m);h.push(n)}const j=Math.floor(i.length/g),V=e(j);for(let o=0;o<j;o++)V[o]=i[o*g+2];const{hasVVColor:b,hasVVOpacity:z,hasVVSize:C}=u.parameters;let w,x,R;if(c&&(b||z||C)){const t=o(j);for(let o=0;o<j;o++)t[o]=i[o*g+3];b&&(w=[t]),z&&(x=[t]),C&&(R=[t])}const U=n([h],void 0,[{timeStamps:V,stage:s}],w,x,R);return a(u,U[0])}function m(t,o,e){if(null==t)return{};let r=null;if(t.visualVariables){const o=[],e=t.visualVariables,n=new s({supports:{size:!0,color:!0,rotation:!1,opacity:!0}});r=i(e,n,o)}const n=r?.color?[1,1,1,1]:t.color.toUnitRGBA();n[3]*=o;return{color:n,width:t.trailWidth,cap:0,animationSpeed:t.flowSpeed,trailLength:t.trailLength,animation:3,emissiveStrength:e,vvColor:r?.color,vvOpacity:r?.opacity,vvSize:r?.size}}function f(o,e,i,s,n){const{absoluteZ:a}=r(o,e,0,i,s,n),l=t(o,e,a);return s.renderCoordsHelper.toRenderCoords(l,i,l),l}export{c as createStreamlineGeometry,m as materialParametersFromRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{signal as r}from"../../../../core/signal.js";import{
|
|
5
|
+
import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{signal as r}from"../../../../core/signal.js";import{n as s}from"../../../../chunks/vec32.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as i}from"../../../../geometry/support/frustum.js";import{Sphere as n}from"../../../../geometry/support/sphere.js";import{makeScheduleFunction as a}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as o}from"../GaussianSplatWorkerHandle.js";import{GaussianSplatFadeTexture as u}from"./GaussianSplatFadeTexture.js";import{GaussianSplatOrderTexture as h}from"./GaussianSplatOrderTexture.js";import{GaussianSplatTextureAtlas as d}from"./GaussianSplatTextureAtlas.js";class l{constructor(e){this._updating=r(!1),this.visibleGaussians=0,this._visibleGaussianTiles=new Array,this._workerHandle=null,this._isSorting=!1,this._pendingSortTask=!1,this._bufferCapacity=0,this._minimumBoundingSphere=new n,this._cameraDirectionNormalized=t(),this._renderer=e,this._orderTexture=new h(this._renderer.renderingContext),this._fadingTexture=new u(this._renderer.renderingContext),this._textureAtlas=new d(this._renderer.renderingContext,this._renderer.view.resourceController.memoryController,this._renderer.fboCache);const{resourceController:s}=this._renderer.view;this._workerHandle=new o(a(s))}get textureAtlas(){return this._textureAtlas}get orderTexture(){return this._orderTexture}get fadingTexture(){return this._fadingTexture}get visibleGaussianTiles(){return this._visibleGaussianTiles}updateGaussianVisibility(e){this._visibleGaussianTiles=e,this.requestSort()}isUpdating(){return this._updating.value}destroy(){this._pendingSortTask=!1,this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas.destroy(),this._orderTexture.destroy(),this._fadingTexture.destroy()}requestSort(){this._updating.value=!0,this._isSorting?this._pendingSortTask=!0:(this._isSorting=!0,this._pendingSortTask=!1,this._sortOnWorker().then(()=>this._handleSortComplete()).catch(()=>this._handleSortComplete()))}_handleSortComplete(){this._isSorting=!1,this._pendingSortTask?this.requestSort():this._updating.value=!1}_clearBuffersAndTextures(){this._bufferCapacity=0,this._orderTexture.clear(),this._textureAtlas.clear()}_ensureBufferCapacity(r){if(this._bufferCapacity<r){const s=Math.ceil(r*e);this._atlasIndicesBuffer=new Uint32Array(s),this._sortedAtlasIndicesBuffer=new Uint32Array(s),this._distancesBuffer=new Float64Array(s),this._sortOrderBuffer=new Uint32Array(s),this._bufferCapacity=s}}async _sortOnWorker(){if(0===this._visibleGaussianTiles.length)return this.visibleGaussians=0,this._clearBuffersAndTextures(),void this._renderer.requestRender(1);const e=!1;let r=this._visibleGaussianTiles.reduce((e,r)=>e+r.gaussianAtlasIndices.length,0);this._ensureBufferCapacity(r),this._textureAtlas.ensureTextureAtlas();const{frustum:t}=this._renderer.camera;s(this._cameraDirectionNormalized,this._renderer.camera.ray.direction);const n=this._cameraDirectionNormalized[0],a=this._cameraDirectionNormalized[1],o=this._cameraDirectionNormalized[2];let u=0;if(this._visibleGaussianTiles.forEach(e=>{const{gaussianAtlasIndices:s,positions:h}=e;if(this._minimumBoundingSphere.center=e.obb.center,this._minimumBoundingSphere.radius=e.obb.radius+e.maxScale,i(t,this._minimumBoundingSphere))for(let r=0;r<s.length;r++){this._atlasIndicesBuffer[u]=s[r];const e=3*r,t=h[e],i=h[e+1],d=h[e+2];this._distancesBuffer[u]=t*n+i*a+d*o,this._sortOrderBuffer[u]=u,u++}else r-=s.length}),0===r)return this.visibleGaussians=0,this._clearBuffersAndTextures(),void this._renderer.requestRender(1);const h={distances:this._distancesBuffer,sortOrderIndices:this._sortOrderBuffer,numGaussians:r,preciseSort:e};await(this._workerHandle?.sort(h).then(e=>{this._distancesBuffer=e.distances,this._sortOrderBuffer=e.sortedOrderIndices;const s=this._sortedAtlasIndicesBuffer.subarray(0,r);for(let i=0;i<r;i++)s[i]=this._atlasIndicesBuffer[e.sortedOrderIndices[i]];this._orderTexture.setData(s,r);const t=this._renderer.view.qualitySettings.gaussianSplat.maxAllowedVisibleGaussians;this.visibleGaussians=Math.min(r,t),this._renderer.requestRender(1)}))}}export{l as GaussianSplatDataStore};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";import"../../../webgl/BufferObject.js";import{FramebufferObject as e}from"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import{Texture as r}from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as s,SizedPixelFormat as a}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTextureHeight as i,GaussianSplatAtlasPages as o,splatAtlasTextureWidth as l,elementsPerSplatPage as h}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";class p{constructor(t,e,r){this._splatAtlasTextureHeight=i,this.texture=null,this._rctx=t,this._fboCache=r,this.pageAllocator=new o,this._cache=e.newCache("gaussian texture cache",t=>t.dispose())}ensureTextureAtlas(){if(this.texture)return;const t=this._cache.pop("splatTextureAtlas");if(t)return void(this.texture=t);const e=new u;e.height=this._splatAtlasTextureHeight,e.width=l,e.pixelFormat=36249,e.dataType=s.UNSIGNED_INT,e.internalFormat=a.RGBA32UI,e.samplingMode=9728,e.wrapMode=33071,e.isImmutable=!0,this.texture=new r(this._rctx,e),this._updatePageAllocator()}grow(){if(!this.texture)return this.ensureTextureAtlas(),!1;const r=Math.floor(this._splatAtlasTextureHeight*t);if(r*l>this._rctx.parameters.maxPreferredTexturePixels)return!1;const s=new e(this._rctx,this.texture),a=this._fboCache.acquire(l,r,"gaussian splat atlas resize",
|
|
5
|
+
import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";import"../../../webgl/BufferObject.js";import{FramebufferObject as e}from"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import{Texture as r}from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as s,SizedPixelFormat as a}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTextureHeight as i,GaussianSplatAtlasPages as o,splatAtlasTextureWidth as l,elementsPerSplatPage as h}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";class p{constructor(t,e,r){this._splatAtlasTextureHeight=i,this.texture=null,this._rctx=t,this._fboCache=r,this.pageAllocator=new o,this._cache=e.newCache("gaussian texture cache",t=>t.dispose())}ensureTextureAtlas(){if(this.texture)return;const t=this._cache.pop("splatTextureAtlas");if(t)return void(this.texture=t);const e=new u;e.height=this._splatAtlasTextureHeight,e.width=l,e.pixelFormat=36249,e.dataType=s.UNSIGNED_INT,e.internalFormat=a.RGBA32UI,e.samplingMode=9728,e.wrapMode=33071,e.isImmutable=!0,this.texture=new r(this._rctx,e),this._updatePageAllocator()}grow(){if(!this.texture)return this.ensureTextureAtlas(),!1;const r=Math.floor(this._splatAtlasTextureHeight*t);if(r*l>this._rctx.parameters.maxPreferredTexturePixels)return!1;const s=new e(this._rctx,this.texture),a=this._fboCache.acquire(l,r,"gaussian splat atlas resize",12);return this._rctx.blitFramebuffer(s,a.fbo,16384,9728,0,0,l,this._splatAtlasTextureHeight,0,0,l,this._splatAtlasTextureHeight),this.texture?.dispose(),this.texture=a.fbo?.detachColorTexture(),s.dispose(),a.dispose(),this._splatAtlasTextureHeight=r,this._updatePageAllocator(),!0}requestPage(){let t=this.pageAllocator.findFirstFreePage();return null===t&&this.grow()&&(t=this.pageAllocator.findFirstFreePage()),null!==t&&this.pageAllocator.allocate(t),t}freePage(t){this.pageAllocator.free(t)}update(t,e,r){this.ensureTextureAtlas(),this.texture.updateData(0,t,e,h,1,r)}_updatePageAllocator(){const t=l*this._splatAtlasTextureHeight/h;this.pageAllocator.pageCount!==t&&this.pageAllocator.resize(t)}clear(){this.texture&&(this._cache.put("splatTextureAtlas",this.texture),this.texture=null)}destroy(){this._cache.destroy(),this.texture?.dispose()}}export{p as GaussianSplatTextureAtlas};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{
|
|
5
|
+
import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{B as n,d as t,e as i,j as e,g as c,i as o,n as u}from"../../../chunks/vec32.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as l,signedDistance as s}from"../../../geometry/support/plane.js";function p(r,n,t){return r[0]*n[0]+r[1]*n[1]+r[2]*n[2]+r[3]<t}function a(r,n,t){const i=n[0],e=n[1],c=n[2];return!(r[0][0]*i+r[0][1]*e+r[0][2]*c+r[0][3]>t)&&(!(r[1][0]*i+r[1][1]*e+r[1][2]*c+r[1][3]>t)&&(!(r[2][0]*i+r[2][1]*e+r[2][2]*c+r[2][3]>t)&&(!(r[3][0]*i+r[3][1]*e+r[3][2]*c+r[3][3]>t)&&(!(r[4][0]*i+r[4][1]*e+r[4][2]*c+r[4][3]>t)&&!(r[5][0]*i+r[5][1]*e+r[5][2]*c+r[5][3]>t)))))}function m(r,n,t,i){return h(r,n,null,v(i,n,t,!1))}function d(r,n){for(let t=0;t<6;t++){if(s(r[t],n)>0)return!1}return!0}function g(r,n,t,i){return h(r,n,t,v(i,n,t,!0))}function j(r,n,t,u){const f=c(t,i(r,u,n));return o(r,n,e(r,t,f))}const b={dir:f(),len:0,clip:r()};function v(r,c,o,f){const l=b;return r?(o&&f&&(l.len=n(c,o)),t(l.dir,r)):f?(l.len=n(c,o),i(l.dir,o,c),e(l.dir,l.dir,1/l.len)):(i(l.dir,o,c),u(l.dir,l.dir)),l}function x(r,n,t){const i=c(l(r),t.dir),e=-s(r,n);if(e<0&&i>=0)return!1;if(i>-1e-6&&i<1e-6)return e>0;if((e<0||i<0)&&!(e<0&&i<0))return!0;const o=e/i;return i>0?o<t.clip[1]&&(t.clip[1]=o):o>t.clip[0]&&(t.clip[0]=o),t.clip[0]<=t.clip[1]}function h(r,n,t,i){i.clip[0]=0,i.clip[1]=t?i.len:Number.MAX_VALUE;for(let e=0;e<r.length;e++)if(!x(r[e],n,i))return!1;return!0}export{j as closestPointOnRay,g as frustumLineSegment,d as frustumPoint,m as frustumRay,a as frustumSphere,p as planeSphere};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{fromQuat as t,scale as e}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as r,conjugate as i,multiply as n}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,create as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{h as c,r as d,g as f,f as u,u as l,j as m,v as _,w as g,x as p,t as M,i as b,a as j,y as S,z,b as x,c as y,A as C,B as A}from"../../../chunks/vec32.js";import{ZEROS as q,freeze as P,create as Q,UNIT_Z as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as R}from"../../../chunks/vec42.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as D}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as H}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as k}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as F}from"../../../geometry/projection/projectBuffer.js";import{getProjector as B}from"../../../geometry/projection/projectors.js";import{getNormal as W}from"../../../geometry/support/plane.js";import{isPlateCarree as U}from"../../../geometry/support/spatialReferenceUtils.js";import{sv3d as Z,sq4d as G}from"../../../geometry/support/vectorStacks.js";import{computeOBB as I}from"./dito.js";import{Vertices as O}from"../webgl-engine/lib/Attribute.js";class T{constructor(t=q,e=bt,a=o){this._data=[t[0],t[1],t[2],e[0],e[1],e[2],a[0],a[1],a[2],a[3]]}clone(){return T.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(t){const e=new T;return e._copyFromData(t),e}static fromJSON(t){return new T(t.center,t.halfSize,t.quaternion)}copy(t){this._copyFromData(t.data)}_copyFromData(t){for(let e=0;e<10;++e)this._data[e]=t[e]}get center(){return c(Z.get(),this._data[0],this._data[1],this._data[2])}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(t){return t[0]=this._data[0],t[1]=this._data[1],t[2]=this._data[2],t}set center(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]}setCenter(t,e,a){this._data[0]=t,this._data[1]=e,this._data[2]=a}get halfSize(){return c(Z.get(),this._data[3],this._data[4],this._data[5])}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(t){return t[0]=this._data[3],t[1]=this._data[4],t[2]=this._data[5],t}set halfSize(t){this._data[3]=t[0],this._data[4]=t[1],this._data[5]=t[2]}get quaternion(){return r(G.get(),this._data[6],this._data[7],this._data[8],this._data[9])}getQuaternion(t){return t[0]=this._data[6],t[1]=this._data[7],t[2]=this._data[8],t[3]=this._data[9],t}set quaternion(t){this._data[6]=t[0],this._data[7]=t[1],this._data[8]=t[2],this._data[9]=t[3]}get data(){return this._data}getCorners(t){const e=this._data,a=r(X,e[6],e[7],e[8],e[9]);for(let s=0;s<8;++s){const r=t[s];r[0]=(1&s?-1:1)*e[3],r[1]=(2&s?-1:1)*e[4],r[2]=(4&s?-1:1)*e[5],d(r,r,a),r[0]+=e[0],r[1]+=e[1],r[2]+=e[2]}return t}getAxes(t){const e=this._data,a=r(X,e[6],e[7],e[8],e[9]);return d(t[0],[1,0,0],a),d(t[1],[0,1,0],a),d(t[2],[0,0,1],a),t}intersectsFrustum(t){const e=this.center,a=t.planes;for(const d of a){const t=W(d),a=this.projectedRadius(t);if(f(t,e)+d[3]-a>0)return!1}const s=this.getAxes(_t),r=t.points,i=this.halfSize;for(let d=0;d<3;++d){const t=s[d],a=-f(t,e),n=i[d];let o=!0,h=!0;for(const e of r){const s=f(e,t)+a;o&&=s>n,h&&=s<-n}if(o||h)return!1}if(this.getCorners(mt).some(e=>t.intersectsPoint(e)))return!0;const n=zt;for(let d=0;d<3;++d){const t=s[d];n[d]=f(t,e)}const o=t=>{for(let e=0;e<3;++e){const a=s[e],r=i[e],o=f(a,t)-n[e];if(o>r||o<-r)return!1}return!0};if(t.points.some(t=>o(t)))return!0;const h=t.lines,c=St;for(let d=0;d<8;++d){const t=h[d].direction;for(const a of s){u(c,t,a);const s=l(c);if(!(s>0))continue;m(c,c,1/s);const i=this.projectedRadius(c),n=f(e,c),o=n-i,h=n+i;let d=!1,_=!1,g=!0;for(const t of r){const e=f(c,t);if(e>h){if(_){g=!1;break}d=!0}else{if(!(e<o)){g=!1;break}if(d){g=!1;break}_=!0}}if(g)return!1}}return!0}doesIntersectFrustumConservativeApproximation(t){return this.intersectPlane(t[0])<=0&&this.intersectPlane(t[1])<=0&&this.intersectPlane(t[2])<=0&&this.intersectPlane(t[3])<=0&&this.intersectPlane(t[4])<=0&&this.intersectPlane(t[5])<=0}get radius(){const t=this._data[3],e=this._data[4],a=this._data[5];return Math.sqrt(t*t+e*e+a*a)}intersectsPoint(t){const e=this.getAxes(_t),a=this.halfSize,{center:s}=this;for(let r=0;r<3;++r){const i=e[r],n=a[r],o=f(i,t)-f(i,s);if(o>n||o<-n)return!1}return!0}intersectSphere(t){const{center:e}=t,a=this._data;J[0]=a[0]-e[0],J[1]=a[1]-e[1],J[2]=a[2]-e[2];const s=this.getQuaternion(Y);return i(X,s),d(J,J,X),_(J,J),N[0]=Math.min(J[0],a[3]),N[1]=Math.min(J[1],a[4]),N[2]=Math.min(J[2],a[5]),g(N,J)<t.radius*t.radius}intersectSphereWithMBS(t,e=this.radius){const a=this._data,{center:s}=t;J[0]=a[0]-s[0],J[1]=a[1]-s[1],J[2]=a[2]-s[2];const r=t.radius,i=r+e;return!(p(J)>i*i)&&(X[0]=-a[6],X[1]=-a[7],X[2]=-a[8],X[3]=a[9],d(J,J,X),_(J,J),N[0]=Math.min(J[0],a[3]),N[1]=Math.min(J[1],a[4]),N[2]=Math.min(J[2],a[5]),g(N,J)<r*r)}intersectPlane(t){const e=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],a=this.projectedRadius(W(t));return e>a?1:e<-a?-1:0}intersectRay(t,e,a=0){const s=this._data,r=X;r[0]=-s[6],r[1]=-s[7],r[2]=-s[8],r[3]=s[9],J[0]=t[0]-s[0],J[1]=t[1]-s[1],J[2]=t[2]-s[2];const i=d(J,J,X),n=d(N,e,X);let o=-1/0,h=1/0;const c=this.getHalfSize(ft);for(let d=0;d<3;d++){const t=i[d],e=n[d],s=c[d]+a;if(Math.abs(e)>1e-6){const a=(s-t)/e,r=(-s-t)/e;o=Math.max(o,Math.min(a,r)),h=Math.min(h,Math.max(a,r))}else if(t>s||t<-s)return!1}return o<=h}projectedArea(a,s,r,n){const o=this.getQuaternion(Y);i(X,o),J[0]=a[0]-this._data[0],J[1]=a[1]-this._data[1],J[2]=a[2]-this._data[2],d(J,J,X);const h=this.getHalfSize(ft),f=J[0]<-h[0]?-1:J[0]>h[0]?1:0,u=J[1]<-h[1]?-1:J[1]>h[1]?1:0,l=J[2]<-h[2]?-1:J[2]>h[2]?1:0,m=Math.abs(f)+Math.abs(u)+Math.abs(l);if(0===m)return 1/0;const _=1===m?4:6,g=6*(f+3*u+9*l+13);t(ut,o),e(ut,ut,h);const p=this.getCenter(ct);for(let t=0;t<_;t++){const e=$[g+t];c(J,((1&e)<<1)-1,(2&e)-1,((4&e)>>1)-1),M(J,J,ut),b(V,p,J),V[3]=1,R(V,V,s);const a=1/Math.max(1e-6,V[3]);L[2*t]=V[0]*a,L[2*t+1]=V[1]*a}const j=2*_-2;let S=L[0]*(L[3]-L[j+1])+L[j]*(L[1]-L[j-1]);for(let t=2;t<j;t+=2)S+=L[t]*(L[t+3]-L[t-1]);return Math.abs(S)*r*n*.125}projectedRadius(t){const e=this.getQuaternion(Y);return i(X,e),d(J,t,X),Math.abs(J[0]*this._data[3])+Math.abs(J[1]*this._data[4])+Math.abs(J[2]*this._data[5])}minimumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]-this.projectedRadius(W(t))}maximumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]+this.projectedRadius(W(t))}toAaBoundingBox(e){const a=this.getQuaternion(Y),s=t(ut,a),r=this._data[3]*Math.abs(s[0])+this._data[4]*Math.abs(s[3])+this._data[5]*Math.abs(s[6]),i=this._data[3]*Math.abs(s[1])+this._data[4]*Math.abs(s[4])+this._data[5]*Math.abs(s[7]),n=this._data[3]*Math.abs(s[2])+this._data[4]*Math.abs(s[5])+this._data[5]*Math.abs(s[8]);e[0]=this._data[0]-r,e[1]=this._data[1]-i,e[2]=this._data[2]-n,e[3]=this._data[0]+r,e[4]=this._data[1]+i,e[5]=this._data[2]+n}transform(t,e,a,s=0,r=H(a),i=H(e),n=B(e,i)){if(a===r)e.isGeographic?it(this,t,e,s,i):rt(this,t,e,s,i,n);else if(e.isWGS84&&(a.isWebMercator||U(a)))et(e,this,a,t,s);else if(e.isWebMercator&&U(a))at(e,this,a,t,s);else{const r=this.getCenter(ct);r[2]+=s,F(r,e,0,r,a,0),t.center=r,this!==t&&(t.quaternion=this.getQuaternion(Y),t.halfSize=this.getHalfSize(ft))}}}const X=h(),Y=h(),E=h(),J=Q(),N=Q(),V=w();function K(t,e=new T){return I(t,e),e}const L=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],$=(()=>{const t=new Int8Array(162);let e=0;const a=a=>{for(let s=0;s<a.length;s++)t[e+s]=a[s];e+=6};return a([6,2,3,1,5,4]),a([0,2,3,1,5,4]),a([0,2,3,7,5,4]),a([0,1,3,2,6,4]),a([0,1,3,2,0,0]),a([0,1,5,7,3,2]),a([0,1,3,7,6,4]),a([0,1,3,7,6,2]),a([0,1,5,7,6,2]),a([0,1,5,4,6,2]),a([0,1,5,4,0,0]),a([0,1,3,7,5,4]),a([0,2,6,4,0,0]),a([0,0,0,0,0,0]),a([1,3,7,5,0,0]),a([2,3,7,6,4,0]),a([2,3,7,6,0,0]),a([2,3,1,5,7,6]),a([0,1,5,7,6,2]),a([0,1,5,7,6,4]),a([0,1,3,7,6,4]),a([4,5,7,6,2,0]),a([4,5,7,6,0,0]),a([4,5,1,3,7,6]),a([0,2,3,7,5,4]),a([6,2,3,7,5,4]),a([6,2,3,1,5,4]),t})();function tt(t,e,a,s,r){const n=t.getQuaternion(Y);r.quaternion=n,i(X,n);const o=t.getCenter(ct),h=t.getHalfSize(ft);if(1===s){d(gt,o,X),_(pt,gt),z(Mt,pt,h),j(Mt,pt,Mt);const s=x(Mt);b(Mt,pt,h);const i=x(Mt);if(s<a)r.center=o,c(gt,a,a,a),r.halfSize=b(gt,h,gt);else{const n=i>0?1+e/i:1,o=s>0?1+a/s:1,c=(o+n)/2,f=(o-n)/2;m(Mt,pt,f),r.halfSize=y(Mt,Mt,h,c),m(Mt,pt,c),y(Mt,Mt,h,f),C(gt,gt),A(gt,Mt,gt);const u=t.getQuaternion(E);r.center=d(gt,gt,u)}}else{r.center=y(gt,o,v,(a+e)/2);const t=d(gt,v,X);_(t,t),r.halfSize=y(pt,h,t,(a-e)/2)}return r}function et(t,e,a,s,r){e.getCenter(ct),ct[2]+=r;const i=H(a);F(ct,t,0,ct,i,0),st(i,e,ct,a,s)}function at(t,e,a,s,r){e.getCenter(ct),ct[2]+=r,st(t,e,ct,a,s)}function st(e,a,s,r,i){const n=a.getQuaternion(Y),o=t(ut,n),h=a.getHalfSize(ft);for(let t=0;t<8;++t){for(let e=0;e<3;++e)ht[e]=h[e]*(t&1<<e?-1:1);for(let e=0;e<3;++e){let a=s[e];for(let t=0;t<3;++t)a+=ht[t]*o[3*t+e];nt[3*t+e]=a}}F(nt,e,0,nt,r,0,8),K(ot,i)}function rt(t,e,a,s,r=H(a),o=B(a,r)){t.getCorners(mt),t.getCenter(ht),ht[2]+=s,k(a,ht,lt,r),e.setCenter(lt[12],lt[13],lt[14]);const h=2*Math.sqrt(1+lt[0]+lt[5]+lt[10]);X[0]=(lt[6]-lt[9])/h,X[1]=(lt[8]-lt[2])/h,X[2]=(lt[1]-lt[4])/h,X[3]=.25*h;const f=t.getQuaternion(Y);e.quaternion=n(X,X,f),i(X,X),c(pt,0,0,0);const u=e.getCenter(dt);for(const i of mt)i[2]+=s,o(i,0,i,0),j(gt,i,u),d(gt,gt,X),_(gt,gt),S(pt,pt,gt);e.halfSize=pt}function it(t,e,a,s,r=H(a)){const n=D(a),o=1+Math.max(0,s)/(n.radius+t.centerZ);t.getCenter(ht),ht[2]+=s,F(ht,a,0,ht,r,0),e.center=ht;const h=t.getQuaternion(Y);e.quaternion=h,i(X,h),c(gt,0,0,1),d(gt,gt,X);const f=t.getHalfSize(ft);c(gt,f[0]*Math.abs(gt[0]),f[1]*Math.abs(gt[1]),f[2]*Math.abs(gt[2])),m(gt,gt,n.inverseFlattening),b(gt,f,gt),e.halfSize=m(gt,gt,o)}const nt=new Array(24),ot=new O(nt,3),ht=Q(),ct=Q(),dt=Q(),ft=Q(),ut=a(),lt=s(),mt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],_t=[Q(),Q(),Q()],gt=Q(),pt=Q(),Mt=Q(),bt=P(-1,-1,-1);function jt(t){return Array.from(t)}const St=Q(),zt=[0,0,0];export{T as Obb,K as compute,tt as computeOffsetObb,jt as ensurePackedObbData};
|
|
5
|
+
import{fromQuat as t,scale as a}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as e}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as r,conjugate as i,multiply as n}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,create as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{h as c,r as f,g as d,f as u,u as l,j as m,t as _,i as g,a as p,v as M,w as b,x as j,b as S,c as z,y as x,z as y}from"../../../chunks/vec32.js";import{ZEROS as C,freeze as q,create as A,UNIT_Z as P}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as v}from"../../../chunks/vec42.js";import{create as Q}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as w}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as D}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as H}from"../../../geometry/projection/projectBuffer.js";import{getProjector as k}from"../../../geometry/projection/projectors.js";import{getNormal as F}from"../../../geometry/support/plane.js";import{isPlateCarree as B}from"../../../geometry/support/spatialReferenceUtils.js";import{sv3d as W,sq4d as U}from"../../../geometry/support/vectorStacks.js";import{computeOBB as Z}from"./dito.js";import{Vertices as G}from"../webgl-engine/lib/Attribute.js";class O{constructor(t=C,a=pt,e=o){this._data=[t[0],t[1],t[2],a[0],a[1],a[2],e[0],e[1],e[2],e[3]]}clone(){return O.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(t){const a=new O;return a._copyFromData(t),a}static fromJSON(t){return new O(t.center,t.halfSize,t.quaternion)}copy(t){this._copyFromData(t.data)}_copyFromData(t){for(let a=0;a<10;++a)this._data[a]=t[a]}get center(){return c(W.get(),this._data[0],this._data[1],this._data[2])}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(t){return t[0]=this._data[0],t[1]=this._data[1],t[2]=this._data[2],t}set center(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]}setCenter(t,a,e){this._data[0]=t,this._data[1]=a,this._data[2]=e}get halfSize(){return c(W.get(),this._data[3],this._data[4],this._data[5])}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(t){return t[0]=this._data[3],t[1]=this._data[4],t[2]=this._data[5],t}set halfSize(t){this._data[3]=t[0],this._data[4]=t[1],this._data[5]=t[2]}get quaternion(){return r(U.get(),this._data[6],this._data[7],this._data[8],this._data[9])}getQuaternion(t){return t[0]=this._data[6],t[1]=this._data[7],t[2]=this._data[8],t[3]=this._data[9],t}set quaternion(t){this._data[6]=t[0],this._data[7]=t[1],this._data[8]=t[2],this._data[9]=t[3]}get data(){return this._data}getCorners(t){const a=this._data,e=r(T,a[6],a[7],a[8],a[9]);for(let s=0;s<8;++s){const r=t[s];r[0]=(1&s?-1:1)*a[3],r[1]=(2&s?-1:1)*a[4],r[2]=(4&s?-1:1)*a[5],f(r,r,e),r[0]+=a[0],r[1]+=a[1],r[2]+=a[2]}return t}getAxes(t){const a=this._data,e=r(T,a[6],a[7],a[8],a[9]);return f(t[0],[1,0,0],e),f(t[1],[0,1,0],e),f(t[2],[0,0,1],e),t}intersectsFrustum(t){const a=this.center,e=t.planes;for(const f of e){const t=F(f),e=this.projectedRadius(t);if(d(t,a)+f[3]-e>0)return!1}const s=this.getAxes(lt),r=t.points,i=this.halfSize;for(let f=0;f<3;++f){const t=s[f],e=-d(t,a),n=i[f];let o=!0,h=!0;for(const a of r){const s=d(a,t)+e;o&&=s>n,h&&=s<-n}if(o||h)return!1}if(this.getCorners(ut).some(a=>t.intersectsPoint(a)))return!0;const n=jt;for(let f=0;f<3;++f){const t=s[f];n[f]=d(t,a)}const o=t=>{for(let a=0;a<3;++a){const e=s[a],r=i[a],o=d(e,t)-n[a];if(o>r||o<-r)return!1}return!0};if(t.points.some(t=>o(t)))return!0;const h=t.lines,c=bt;for(let f=0;f<8;++f){const t=h[f].direction;for(const e of s){u(c,t,e);const s=l(c);if(!(s>0))continue;m(c,c,1/s);const i=this.projectedRadius(c),n=d(a,c),o=n-i,h=n+i;let f=!1,_=!1,g=!0;for(const t of r){const a=d(c,t);if(a>h){if(_){g=!1;break}f=!0}else{if(!(a<o)){g=!1;break}if(f){g=!1;break}_=!0}}if(g)return!1}}return!0}intersectsFrustumConservativeApproximation(t){return this.intersectPlane(t[0])<=0&&this.intersectPlane(t[1])<=0&&this.intersectPlane(t[2])<=0&&this.intersectPlane(t[3])<=0&&this.intersectPlane(t[4])<=0&&this.intersectPlane(t[5])<=0}get radius(){const t=this._data[3],a=this._data[4],e=this._data[5];return Math.sqrt(t*t+a*a+e*e)}intersectsPoint(t){const a=this.getAxes(lt),e=this.halfSize,{center:s}=this;for(let r=0;r<3;++r){const i=a[r],n=e[r],o=d(i,t)-d(i,s);if(o>n||o<-n)return!1}return!0}intersectSphere(t){const{center:a,radius:e}=t,s=this._data,r=s[3],i=s[4],n=s[5],o=Math.max(r,i,n)+e,h=s[0]-a[0];if(h>o)return!1;const c=s[1]-a[1];if(c>o)return!1;const f=s[2]-a[2];if(f>o)return!1;const d=-s[6],u=-s[7],l=-s[8],m=u*f-l*c,_=l*h-d*f,g=d*c-u*h,p=u*g-l*_,M=l*m-d*g,b=d*_-u*m,j=2*s[9],S=Math.abs(h+m*j+2*p),z=Math.abs(c+_*j+2*M),x=Math.abs(f+g*j+2*b),y=S-Math.min(S,r),C=z-Math.min(z,i),q=x-Math.min(x,n);return y*y+C*C+q*q<e*e}intersectSphereWithMBS(t,a=this.radius){const e=this._data,{center:s,radius:r}=t,i=a+r,n=e[0]-s[0];if(n>i)return!1;const o=e[1]-s[1];if(o>i)return!1;const h=e[2]-s[2];if(h>i)return!1;if(n*n+o*o+h*h>i*i)return!1;const c=-e[6],f=-e[7],d=-e[8],u=f*h-d*o,l=d*n-c*h,m=c*o-f*n,_=f*m-d*l,g=d*u-c*m,p=c*l-f*u,M=2*e[9],b=Math.abs(n+u*M+2*_),j=Math.abs(o+l*M+2*g),S=Math.abs(h+m*M+2*p),z=b-Math.min(b,e[3]),x=j-Math.min(j,e[4]),y=S-Math.min(S,e[5]);return z*z+x*x+y*y<r*r}intersectPlane(t){const a=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],e=this.projectedRadius(F(t));return a>e?1:a<-e?-1:0}intersectRay(t,a,e=0){const s=this._data,r=T;r[0]=-s[6],r[1]=-s[7],r[2]=-s[8],r[3]=s[9],E[0]=t[0]-s[0],E[1]=t[1]-s[1],E[2]=t[2]-s[2];const i=f(E,E,T),n=f(I,a,T);let o=-1/0,h=1/0;const c=this.getHalfSize(ct);for(let f=0;f<3;f++){const t=i[f],a=n[f],s=c[f]+e;if(Math.abs(a)>1e-6){const e=(s-t)/a,r=(-s-t)/a;o=Math.max(o,Math.min(e,r)),h=Math.min(h,Math.max(e,r))}else if(t>s||t<-s)return!1}return o<=h}projectedArea(e,s,r,n){const o=this.getQuaternion(X);i(T,o),E[0]=e[0]-this._data[0],E[1]=e[1]-this._data[1],E[2]=e[2]-this._data[2],f(E,E,T);const h=this.getHalfSize(ct),d=E[0]<-h[0]?-1:E[0]>h[0]?1:0,u=E[1]<-h[1]?-1:E[1]>h[1]?1:0,l=E[2]<-h[2]?-1:E[2]>h[2]?1:0,m=Math.abs(d)+Math.abs(u)+Math.abs(l);if(0===m)return 1/0;const p=1===m?4:6,M=6*(d+3*u+9*l+13);t(ft,o),a(ft,ft,h);const b=this.getCenter(ot);for(let t=0;t<p;t++){const a=K[M+t];c(E,((1&a)<<1)-1,(2&a)-1,((4&a)>>1)-1),_(E,E,ft),g(J,b,E),J[3]=1,v(J,J,s);const e=1/Math.max(1e-6,J[3]);V[2*t]=J[0]*e,V[2*t+1]=J[1]*e}const j=2*p-2;let S=V[0]*(V[3]-V[j+1])+V[j]*(V[1]-V[j-1]);for(let t=2;t<j;t+=2)S+=V[t]*(V[t+3]-V[t-1]);return Math.abs(S)*r*n*.125}projectedRadius(t){const a=this.getQuaternion(X);return i(T,a),f(E,t,T),Math.abs(E[0]*this._data[3])+Math.abs(E[1]*this._data[4])+Math.abs(E[2]*this._data[5])}minimumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]-this.projectedRadius(F(t))}maximumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]+this.projectedRadius(F(t))}toAaBoundingBox(a){const e=this.getQuaternion(X),s=t(ft,e),r=this._data[3]*Math.abs(s[0])+this._data[4]*Math.abs(s[3])+this._data[5]*Math.abs(s[6]),i=this._data[3]*Math.abs(s[1])+this._data[4]*Math.abs(s[4])+this._data[5]*Math.abs(s[7]),n=this._data[3]*Math.abs(s[2])+this._data[4]*Math.abs(s[5])+this._data[5]*Math.abs(s[8]);a[0]=this._data[0]-r,a[1]=this._data[1]-i,a[2]=this._data[2]-n,a[3]=this._data[0]+r,a[4]=this._data[1]+i,a[5]=this._data[2]+n}transform(t,a,e,s=0,r=w(e),i=w(a),n=k(a,i)){if(e===r)a.isGeographic?st(this,t,a,s,i):et(this,t,a,s,i,n);else if(a.isWGS84&&(e.isWebMercator||B(e)))$(a,this,e,t,s);else if(a.isWebMercator&&B(e))tt(a,this,e,t,s);else{const r=this.getCenter(ot);r[2]+=s,H(r,a,0,r,e,0),t.center=r,this!==t&&(t.quaternion=this.getQuaternion(X),t.halfSize=this.getHalfSize(ct))}}}const T=h(),X=h(),Y=h(),E=A(),I=A(),J=Q();function N(t,a=new O){return Z(t,a),a}const V=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],K=(()=>{const t=new Int8Array(162);let a=0;const e=e=>{for(let s=0;s<e.length;s++)t[a+s]=e[s];a+=6};return e([6,2,3,1,5,4]),e([0,2,3,1,5,4]),e([0,2,3,7,5,4]),e([0,1,3,2,6,4]),e([0,1,3,2,0,0]),e([0,1,5,7,3,2]),e([0,1,3,7,6,4]),e([0,1,3,7,6,2]),e([0,1,5,7,6,2]),e([0,1,5,4,6,2]),e([0,1,5,4,0,0]),e([0,1,3,7,5,4]),e([0,2,6,4,0,0]),e([0,0,0,0,0,0]),e([1,3,7,5,0,0]),e([2,3,7,6,4,0]),e([2,3,7,6,0,0]),e([2,3,1,5,7,6]),e([0,1,5,7,6,2]),e([0,1,5,7,6,4]),e([0,1,3,7,6,4]),e([4,5,7,6,2,0]),e([4,5,7,6,0,0]),e([4,5,1,3,7,6]),e([0,2,3,7,5,4]),e([6,2,3,7,5,4]),e([6,2,3,1,5,4]),t})();function L(t,a,e,s,r){const n=t.getQuaternion(X);r.quaternion=n,i(T,n);const o=t.getCenter(ot),h=t.getHalfSize(ct);if(1===s){f(mt,o,T),M(_t,mt),j(gt,_t,h),p(gt,_t,gt);const s=S(gt);g(gt,_t,h);const i=S(gt);if(s<e)r.center=o,c(mt,e,e,e),r.halfSize=g(mt,h,mt);else{const n=i>0?1+a/i:1,o=s>0?1+e/s:1,c=(o+n)/2,d=(o-n)/2;m(gt,_t,d),r.halfSize=z(gt,gt,h,c),m(gt,_t,c),z(gt,gt,h,d),x(mt,mt),y(mt,gt,mt);const u=t.getQuaternion(Y);r.center=f(mt,mt,u)}}else{r.center=z(mt,o,P,(e+a)/2);const t=f(mt,P,T);M(t,t),r.halfSize=z(_t,h,t,(e-a)/2)}return r}function $(t,a,e,s,r){a.getCenter(ot),ot[2]+=r;const i=w(e);H(ot,t,0,ot,i,0),at(i,a,ot,e,s)}function tt(t,a,e,s,r){a.getCenter(ot),ot[2]+=r,at(t,a,ot,e,s)}function at(a,e,s,r,i){const n=e.getQuaternion(X),o=t(ft,n),h=e.getHalfSize(ct);for(let t=0;t<8;++t){for(let a=0;a<3;++a)nt[a]=h[a]*(t&1<<a?-1:1);for(let a=0;a<3;++a){let e=s[a];for(let t=0;t<3;++t)e+=nt[t]*o[3*t+a];rt[3*t+a]=e}}H(rt,a,0,rt,r,0,8),N(it,i)}function et(t,a,e,s,r=w(e),o=k(e,r)){t.getCorners(ut),t.getCenter(nt),nt[2]+=s,D(e,nt,dt,r),a.setCenter(dt[12],dt[13],dt[14]);const h=2*Math.sqrt(1+dt[0]+dt[5]+dt[10]);T[0]=(dt[6]-dt[9])/h,T[1]=(dt[8]-dt[2])/h,T[2]=(dt[1]-dt[4])/h,T[3]=.25*h;const d=t.getQuaternion(X);a.quaternion=n(T,T,d),i(T,T),c(_t,0,0,0);const u=a.getCenter(ht);for(const i of ut)i[2]+=s,o(i,0,i,0),p(mt,i,u),f(mt,mt,T),M(mt,mt),b(_t,_t,mt);a.halfSize=_t}function st(t,a,e,s,r=w(e)){const n=R(e),o=1+Math.max(0,s)/(n.radius+t.centerZ);t.getCenter(nt),nt[2]+=s,H(nt,e,0,nt,r,0),a.center=nt;const h=t.getQuaternion(X);a.quaternion=h,i(T,h),c(mt,0,0,1),f(mt,mt,T);const d=t.getHalfSize(ct);c(mt,d[0]*Math.abs(mt[0]),d[1]*Math.abs(mt[1]),d[2]*Math.abs(mt[2])),m(mt,mt,n.inverseFlattening),g(mt,d,mt),a.halfSize=m(mt,mt,o)}const rt=new Array(24),it=new G(rt,3),nt=A(),ot=A(),ht=A(),ct=A(),ft=e(),dt=s(),ut=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],lt=[A(),A(),A()],mt=A(),_t=A(),gt=A(),pt=q(-1,-1,-1);function Mt(t){return Array.from(t)}const bt=A(),jt=[0,0,0];export{O as Obb,N as compute,L as computeOffsetObb,Mt as ensurePackedObbData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{on as r}from"../../../../core/reactiveUtils.js";import{property as i,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{
|
|
5
|
+
import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{on as r}from"../../../../core/reactiveUtils.js";import{property as i,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{B as s,m as n,d as a}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import d from"../../../../geometry/Point.js";import{InvalidLayerError as h}from"../../../../layers/support/ElevationQuery.js";import{distanceToScale as p}from"../cameraUtils.js";import{PointOfInterest as c}from"./PointOfInterest.js";import{PropertiesPool as u}from"../../../support/PropertiesPool.js";import{Yield as m}from"../../../support/Yield.js";let _=class extends c{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new u({location:()=>new d,renderLocation:()=>l()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryController=null,this.renderLocation=l(),this._tmpPoint=new d}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(r(()=>this.map?.ground?.layers,"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=s(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return p(r,e)}get updating(){return this._dirty||null!=this._elevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._elevationQueryController;t&&(this._elevationQueryController=null,t.abort(),this.notifyChange("updating"))}get readyToRun(){return!this._elevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),m;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>f&&1===this.renderCoordsHelper.viewingMode&&(t.isWGS84||t.isWebMercator);let r=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:r.signal,cache:this.cache,minDemResolution:e?g:0}).then(t=>this._updateSurfaceAltitude(t.geometry.z??0)).catch(t=>{if(t.name===h)if(this.integratedMeshElevationSampler){this._tmpPoint.spatialReference=this.integratedMeshElevationSampler.spatialReference,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const t=this.integratedMeshElevationSampler.elevationAt(this._tmpPoint.x,this._tmpPoint.y)??0;this._updateSurfaceAltitude(t===this.integratedMeshElevationSampler.noDataValue?0:t)}else this._updateSurfaceAltitude(0)}).catch(()=>{}).then(()=>{this._elevationQueryController===r&&(this._elevationQueryController=null,this.notifyChange("updating")),r=null}),this._elevationQueryController=r,m}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(y,this._estimatedSurfaceAltitude,this._camera.eye),n(this._get("renderLocation"),y)||(this._set("renderLocation",a(this._propertiesPool.get("renderLocation"),y)),this.notifyChange("renderLocation"))}};t([i({constructOnly:!0})],_.prototype,"scheduler",void 0),t([i({constructOnly:!0})],_.prototype,"cache",void 0),t([i({constructOnly:!0})],_.prototype,"map",void 0),t([i({constructOnly:!0})],_.prototype,"task",void 0),t([i({constructOnly:!0})],_.prototype,"integratedMeshElevationSampler",void 0),t([i()],_.prototype,"location",null),t([i()],_.prototype,"renderLocation",void 0),t([i()],_.prototype,"scale",null),t([i()],_.prototype,"updating",null),_=t([o("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],_);const y=l(),f=1e5,g=1e6;export{_ as CameraOnSurface};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{clamp as e}from"../../../../core/mathUtils.js";import{removeMaybe as r,destroyMaybe as i}from"../../../../core/maybe.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{d as a,
|
|
5
|
+
import{__decorate as t}from"tslib";import{clamp as e}from"../../../../core/mathUtils.js";import{removeMaybe as r,destroyMaybe as i}from"../../../../core/maybe.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{d as a,B as n,j as c,i as u,m as l,D as d}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../../geometry/ellipsoidUtils.js";import f from"../../../../geometry/Point.js";import{projectBoundingRect as m}from"../../../../geometry/projection/projectBoundingRect.js";import{create as _}from"../../../../geometry/support/aaBoundingRect.js";import{debugFlags as S}from"../debugFlags.js";import{PointOfInterest as y}from"./PointOfInterest.js";import{PropertiesPool as g}from"../../../support/PropertiesPool.js";import{Yield as A}from"../../../support/Yield.js";let j=class extends y{constructor(t){super(t),this._propertiesPool=new g({location:()=>new f,renderLocation:()=>p()},this),this._currentSurfaceAltitude=0,this._latestSurfaceAltitude=0,this.distance=0,this.renderLocation=p(),this.updating=!1}initialize(){this._frameWorker=this.scheduler.registerTask(this.task,this),this.runTask()}destroy(){this._frameWorker=r(this._frameWorker),this._propertiesPool=i(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool?.get("location");return t?(t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t):new f}updateRenderLocation(){this.updating=!0,this._updateRenderLocation()}get estimatedSurfaceAltitude(){return this._latestSurfaceAltitude}get readyToRun(){return this.updating}runTask(){return this._latestSurfaceAltitude=this.estimateSurfaceAltitudeAtCenter(),this._updateRenderLocation(),this.updating=!1,A}_updateRenderLocation(){const t=L;let e=this._calculateSurfaceIntersection(this._currentSurfaceAltitude,t);const r=this._currentSurfaceAltitude!==this._latestSurfaceAltitude;!e&&r&&(e=this._calculateSurfaceIntersection(this._latestSurfaceAltitude,t),e&&(this._currentSurfaceAltitude=this._latestSurfaceAltitude));const i=v;e&&this._latestSurfaceAltitudeChangesDistanceSignificantly(t,i)&&(a(t,i),this._currentSurfaceAltitude=this._latestSurfaceAltitude),e?this.distance=n(this._camera.eye,t):(c(t,this._camera.viewForward,this._get("distance")),u(t,t,this._camera.eye)),l(this._get("renderLocation"),t)||this._set("renderLocation",a(this._propertiesPool.get("renderLocation"),t))}_calculateSurfaceIntersection(t,r){const i=this._camera;if(!this.renderCoordsHelper.intersectInfiniteManifold(i.ray,t,r))return!1;if(this.state.isGlobal){const e=h(this.renderCoordsHelper.spatialReference).radius,s=e+t,o=d(i.eye),a=o<s*s,l=n(i.eye,r);if(a&&l>e/4){const t=s-Math.sqrt(o);return c(r,i.viewForward,t),u(r,r,i.eye),!0}}else{const t=this.surface?.ready?this.surface.groundExtent:null;null!=t&&m(t,this.surface?.spatialReference,C,this.renderCoordsHelper.spatialReference)&&(r[0]=e(r[0],C[0],C[2]),r[1]=e(r[1],C[1],C[3]))}return!0}_latestSurfaceAltitudeChangesDistanceSignificantly(t,e){if(this._latestSurfaceAltitude===this._currentSurfaceAltitude||null==t)return!1;if(this._calculateSurfaceIntersection(this._latestSurfaceAltitude,e)){if(S.TESTS_DISABLE_OPTIMIZATIONS)return!0;const r=this._camera.eye,i=n(r,t),s=n(r,e);if(Math.abs(s-i)/i>R)return!0}return!1}};t([s({constructOnly:!0})],j.prototype,"scheduler",void 0),t([s({constructOnly:!0})],j.prototype,"task",void 0),t([s()],j.prototype,"distance",void 0),t([s({constructOnly:!0})],j.prototype,"estimateSurfaceAltitudeAtCenter",void 0),t([s({readOnly:!0})],j.prototype,"location",null),t([s({readOnly:!0})],j.prototype,"renderLocation",void 0),t([s()],j.prototype,"updating",void 0),j=t([o("esri.views.3d.support.pointsOfInterest.CenterOnSurface")],j);const R=.05,L=p(),v=p(),C=_();export{j as CenterOnSurface};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{clamp as t}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{property as n,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{m as a,g as c,
|
|
5
|
+
import{__decorate as e}from"tslib";import{clamp as t}from"../../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../../core/maybe.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{property as n,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{m as a,g as c,E as d,d as p,l,e as u,n as h}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{wrap as y}from"../../../../geometry/support/ray.js";import{PointOfInterest as g}from"./PointOfInterest.js";import{PropertiesPool as P}from"../../../support/PropertiesPool.js";import{TaskPriority as _}from"../../../support/Scheduler.js";import{Yield as L}from"../../../support/Yield.js";let R=class extends g{constructor(e){super(e),this._propertiesPool=new P({location:()=>new f,renderLocation:()=>m()},this),this._dirty=!0,this.renderLocation=this._propertiesPool.get("renderLocation")}initialize(){this.addHandles([o(()=>this.centerOnSurface.renderLocation,()=>this.updateRenderLocation(),{equals:a}),o(()=>this.state.contentCamera,()=>this.updateRenderLocation())]),this.scheduler&&this.addHandles(this.scheduler.registerTask(_.POINT_OF_INTEREST_FREQUENT,this))}destroy(){this._propertiesPool=r(this._propertiesPool)}get updating(){return this._dirty||this.centerOnSurface.updating}get location(){const e=this._propertiesPool.get("location");return e.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,e),e}get worldUnitsPerContentPixel(){const{camera:e,contentPixelRatio:t}=this.state;return e.computeRenderPixelSizeAt(this.renderLocation)*(e.pixelRatio/t)}get readyToRun(){return this._dirty}runTask(){const e=this._get("renderLocation"),r=this.centerOnSurface.renderLocation,o=this.renderCoordsHelper,i=this.state.contentCamera;this._dirty=!1,o.worldUpAtPosition(r,S);const n=Math.max(0,(Math.acos(c(S,i.viewForward))-.5*Math.PI)*(i.aboveGround?1:-1));if(Number.isNaN(n)){if(!e||!d(e,r)){const e=this._propertiesPool.get("renderLocation");p(e,r),this._set("renderLocation",e)}return L}const s=1-t(n/(.5*Math.PI),0,1),a=s*s*s;this._calculateScreenHorizontalEdgeOnSurface(O);const u=this._propertiesPool.get("renderLocation");return l(u,r,O,a),e&&d(e,u)||this._set("renderLocation",u),L}_calculateScreenHorizontalEdgeOnSurface(e){const t=this.state.contentCamera,r=t.getRenderCenter(i());if(r[1]=t.aboveGround?t.padding[2]:t.fullHeight-t.padding[0],this.estimateSurfaceIntersectionAtRenderPoint(r,e))return e;const o=this.renderCoordsHelper.getAltitude(this.centerOnSurface.renderLocation);if(t.unprojectFromRenderScreen(r,j)){u(j,j,t.eye);const r=h(j,j);if(this.renderCoordsHelper.intersectInfiniteManifold(y(t.eye,r),o,e))return e}return this.renderCoordsHelper.setAltitude(e,o,t.eye)}updateRenderLocation(){this._dirty=!0}};e([n()],R.prototype,"_dirty",void 0),e([n({constructOnly:!0})],R.prototype,"scheduler",void 0),e([n({constructOnly:!0})],R.prototype,"centerOnSurface",void 0),e([n({constructOnly:!0})],R.prototype,"estimateSurfaceIntersectionAtRenderPoint",void 0),e([n()],R.prototype,"updating",null),e([n()],R.prototype,"location",null),e([n()],R.prototype,"renderLocation",void 0),e([n()],R.prototype,"worldUnitsPerContentPixel",null),R=e([s("esri.views.3d.support.pointsOfInterest.Focus")],R);const S=m(),j=m(),O=m();export{R as Focus};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as a}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{cyclicalDegrees as r}from"../../../core/Cyclical.js";import o from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{j as u,i as f,D as p,d as g,e as y,h,t as d}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectAsync as R,tryProject as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as B}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as M}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as S}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as A,empty as E,expandWithVec3 as V,expandWithAABB as k,width as O,height as U,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as D}from"../../../geometry/support/centroid.js";import{intersectsPoint as W}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as Y}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as q,toRenderCamera as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{getViewSR as _,fromExtentAsync as H,scaleToDistance as K,fromCenterDistanceAsync as L,fromExtentSync as Q,distanceToScale as $,fromCenterDistanceSync as tt,fromCenterScale as et,zoomToScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as at}from"./ElevationProvider.js";import{directionToHeadingTilt as rt}from"./viewingModeUtils.js";const ot=.66;function it(t){return 360-r.normalize(t)}function st(t){return r.normalize(360-t)}function ct(t,e,n){const a=e.camera;if(null!=a)return mt(a,_(t));const{targetGeometry:r}=e;if(null==r)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===r.type)return pt(t,e,r,o,i);const s=r.extent;return null==s?null:Q(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,a){const r=e.camera;if(null!=r)return ut(r,_(t),a);const{targetGeometry:o}=e;if(null==o)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===o.type)return gt(t,e,o,i,s,a);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return H(t,c,i.heading,i.tilt,s,a)}function mt(t,e){const n=t.position,a=z(n,e);if(!a)return null;const r=t.clone();return r.position=a.clone(),r}async function ut(t,e,n){const a=t.position,r=await R(a,e,{signal:n});i(n);const o=t.clone();return o.position=r.clone(),o}function ft(t,e,n){const a=q(t,t.state.camera);let r=1;return null!=e&&(a.heading=it(e),r=0),null!=n&&(a.tilt=n),{camera:a,mode:r}}function pt(t,e,n,a,r){const o=t.spatialReference,i=z(n.clone(),o);if(!i)return null;const s=null!=e.scale?K(t,e.scale):t.state.camera.distance;return tt(t,i,s,a,r)}async function gt(t,e,n,a,r,o){const s=t.spatialReference,c=await R(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?K(t,e.scale):t.state.camera.distance;return L(t,c,l,a,r,o)}function yt(t,e,a=null){return null==a&&(a=new n),jt(t,null,e.clone(),a)}async function ht(e,a,r){const i=At(e,a);if(!i)throw new o("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Et(await zt(e,i.target,i,r,c))}if(i.target instanceof t)return Et(await Gt(e,i.target,r,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Et(l||t?await Mt(e,i,i.target.center,s,r,c):await Ft(e,i,i.target,s,r,c))}const m=new kt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,r),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ot),Jt.x=Ot[0],Jt.y=Ot[1],Jt.z=Ot[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=A(m.boundingBox):(Jt.z=void 0,t=C(P(m.boundingBox,Ct))),l||t)return Et(await Mt(e,i,Jt,s,r,c));const n=Vt(e,m.screenSpaceObjects);return Et(await Pt(e,i,Jt,m.boundingBox,n,s,r,c))}return i.position?Et(await St(e,i,s,c,r)):Et(await Zt(e,i,s,r,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?nt(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?Y(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,a){const r=t.spatialReference||G.WGS84;if(e??=J(t,n),null==e)return a;const o=new b({spatialReference:r});return S(e.center,t.renderSpatialReference,o)?(a.targetGeometry=o,a.scale=$(t,e.distance),a.rotation=st(n.heading),a.camera=n,a):a}async function vt(t,e,n,a){const r=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw r();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":{const t=D(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:a}),Ot[2]=at(t.elevationProvider,n)??0):Ot[2]=0}const s=Xt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ot),0===c.length)throw r();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:a});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ot[0]=o,Ot[1]=f,Ot[2]=p,V(n.boundingBox,Ot);else for(const[o,f]of u.points)Ot[0]=o,Ot[1]=f,V(n.boundingBox,Ot)}async function bt(t,e,n,r,o){const i=await a(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,r,o);const s=i.value,c=await a(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,r,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;k(r.boundingBox,m),l&&l.forEach(t=>{r.screenSpaceObjects.push(t)}),isFinite(m[2])&&(r.hasZ=!0)}async function Rt(t,n,a,r,o){if(Array.isArray(n)&&2===n.length){const e=n[0],a=n[1];if("number"==typeof e&&"number"==typeof a)return Jt.x=e,Jt.y=a,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,r,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,a,r,o))):n instanceof j?await vt(t,n,r,o):n instanceof e&&await bt(t,n,a,r,o)}async function zt(t,e,n,a,r){if(e.camera)return Gt(t,e.camera,a,r);r.scale=e.scale,r.rotation=e.rotation,r.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,r.camera=null,null!=n.heading?r.rotation=st(n.heading):null!=n.rotation&&(r.rotation=n.rotation);const o=dt(t,n);return null!=o&&(r.scale=o),r.camera=await lt(t,r,n.tilt,a),r}async function Gt(t,e,n,a){const r=t.spatialReference,o=await R(e.position,r,{signal:n}),i=e.clone();return i.position=o,jt(t,null,i,a)}async function Bt(t,e,n,a,r,o,i){const s=t.renderSpatialReference;return await M(e,Yt,s,{signal:i}),await M(n,Wt,s,{signal:i}),o.targetGeometry=new b(e),r.position=new b(n),y(Dt,Yt,Wt),rt(t,Wt,Dt,a.up,r),o.scale=$(t,p(Wt,Yt)),o.rotation=st(r.heading),o.camera=r,o}async function Mt(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=X(t);if(e.position)return Bt(t,o.targetGeometry,e.position,i,a,o,r);if(e.zoomFactor){const n=i.distance/e.zoomFactor,a=u(Ot,i.viewForward,-n);i.eye=f(Ot,i.center,a),o.scale=$(t,n)}q(t,i,a);const s=xt(a,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await M(o.targetGeometry,Ot,t.renderSpatialReference,{signal:r});const e=W(i.frustum,Ot)?p(i.eye,Ot):i.distance;o.camera=await L(t,o.targetGeometry,e,a,s),o.scale=$(t,e)}else o.scale=n,o.camera=await et(t,o.targetGeometry,o.scale,a,s,r)}return o}async function St(t,e,n,a,r){const o=X(t);g(Dt,o.viewForward),rt(t,o.eye,Dt,o.up,qt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:r});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:qt.heading,n.tilt=null!=e.tilt?e.tilt:qt.tilt,jt(t,null,n,a)}async function Zt(t,e,n,a,r){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return S(o.center,s,c)?Mt(t,e,c,n,a,r):r}return r.scale=t.scale,r.camera=t.camera.clone(),xt(r.camera,e),r}async function Ft(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=X(t);q(t,i,a);const s=xt(a,e)?0:1;return o.camera=await H(t,n,a.heading,a.tilt,s,r),o}function Tt(t,e,n,a,r){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=at(t.elevationProvider,n)),h(Ot,n.x,n.y,o),B(t.spatialReference,Ot,Ut,t.renderSpatialReference),s(Nt,Ut),c(Nt,Nt),E(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=a[e[2]];isFinite(n)||(n=o),h(Ot,a[e[0]],a[e[1]],n),Z(Ot,t.spatialReference,Ot,t.renderSpatialReference),V(It,d(Ot,Ot,Nt))}const l=O(It),m=U(It),u=N(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/r}async function Pt(t,e,n,a,r,o,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,a,r);q(t,c,o);const m=xt(o,e)?0:1;return s.camera=await L(t,s.targetGeometry,l,o,m,i),s.scale=$(t,l),s}function At(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Et(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Vt(t,e){const n=ot;if(!e.length)return n;let a=Number.NEGATIVE_INFINITY;for(let r=0;r<e.length;r++){const t=e[r].screenSpaceBoundingRect;a=Math.max(a,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-a/Math.min(t.width,t.height)*2}class kt{constructor(){this.hasZ=!1,this.boundingBox=E(),this.screenSpaceObjects=new Array}}const Ot=w(),Ut=m(),Nt=l(),It=F(),Ct=I(),Dt=w(),Wt=w(),Yt=w(),qt={heading:0,tilt:0},Jt=new b,Xt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const a=t.hasZ;for(let r=0;r<t.rings.length;r++){const o=t.rings[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const a=t.hasZ;for(let r=0;r<t.paths.length;r++){const o=t.paths[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const a=t.points,r=t.hasZ;for(let o=0;o<a.length;o++)n[0]=a[o][0],n[1]=a[o][1],r&&(n[2]=a[o][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
|
|
5
|
+
import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as a}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{cyclicalDegrees as r}from"../../../core/Cyclical.js";import o from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{j as u,i as f,B as p,d as g,e as y,h,t as d}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectAsync as R,tryProject as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as B}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as M}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as S}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as A,empty as E,expandWithVec3 as V,expandWithAABB as k,width as O,height as U,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as W}from"../../../geometry/support/centroid.js";import{intersectsPoint as Y}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as q}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as D,toRenderCamera as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{getViewSR as _,fromExtentAsync as H,scaleToDistance as K,fromCenterDistanceAsync as L,fromExtentSync as Q,distanceToScale as $,fromCenterDistanceSync as tt,fromCenterScale as et,zoomToScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as at}from"./ElevationProvider.js";import{directionToHeadingTilt as rt}from"./viewingModeUtils.js";const ot=.66;function it(t){return 360-r.normalize(t)}function st(t){return r.normalize(360-t)}function ct(t,e,n){const a=e.camera;if(null!=a)return mt(a,_(t));const{targetGeometry:r}=e;if(null==r)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===r.type)return pt(t,e,r,o,i);const s=r.extent;return null==s?null:Q(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,a){const r=e.camera;if(null!=r)return ut(r,_(t),a);const{targetGeometry:o}=e;if(null==o)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===o.type)return gt(t,e,o,i,s,a);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return H(t,c,i.heading,i.tilt,s,a)}function mt(t,e){const n=t.position,a=z(n,e);if(!a)return null;const r=t.clone();return r.position=a.clone(),r}async function ut(t,e,n){const a=t.position,r=await R(a,e,{signal:n});i(n);const o=t.clone();return o.position=r.clone(),o}function ft(t,e,n){const a=D(t,t.state.camera);let r=1;return null!=e&&(a.heading=it(e),r=0),null!=n&&(a.tilt=n),{camera:a,mode:r}}function pt(t,e,n,a,r){const o=t.spatialReference,i=z(n.clone(),o);if(!i)return null;const s=null!=e.scale?K(t,e.scale):t.state.camera.distance;return tt(t,i,s,a,r)}async function gt(t,e,n,a,r,o){const s=t.spatialReference,c=await R(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?K(t,e.scale):t.state.camera.distance;return L(t,c,l,a,r,o)}function yt(t,e,a=null){return null==a&&(a=new n),jt(t,null,e.clone(),a)}async function ht(e,a,r){const i=At(e,a);if(!i)throw new o("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Et(await zt(e,i.target,i,r,c))}if(i.target instanceof t)return Et(await Gt(e,i.target,r,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Et(l||t?await Mt(e,i,i.target.center,s,r,c):await Ft(e,i,i.target,s,r,c))}const m=new kt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,r),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ot),Jt.x=Ot[0],Jt.y=Ot[1],Jt.z=Ot[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=A(m.boundingBox):(Jt.z=void 0,t=C(P(m.boundingBox,Ct))),l||t)return Et(await Mt(e,i,Jt,s,r,c));const n=Vt(e,m.screenSpaceObjects);return Et(await Pt(e,i,Jt,m.boundingBox,n,s,r,c))}return i.position?Et(await St(e,i,s,c,r)):Et(await Zt(e,i,s,r,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?nt(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?q(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,a){const r=t.spatialReference||G.WGS84;if(e??=J(t,n),null==e)return a;const o=new b({spatialReference:r});return S(e.center,t.renderSpatialReference,o)?(a.targetGeometry=o,a.scale=$(t,e.distance),a.rotation=st(n.heading),a.camera=n,a):a}async function vt(t,e,n,a){const r=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw r();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":{const t=W(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:a}),Ot[2]=at(t.elevationProvider,n)??0):Ot[2]=0}const s=Xt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ot),0===c.length)throw r();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:a});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ot[0]=o,Ot[1]=f,Ot[2]=p,V(n.boundingBox,Ot);else for(const[o,f]of u.points)Ot[0]=o,Ot[1]=f,V(n.boundingBox,Ot)}async function bt(t,e,n,r,o){const i=await a(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,r,o);const s=i.value,c=await a(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,r,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;k(r.boundingBox,m),l&&l.forEach(t=>{r.screenSpaceObjects.push(t)}),isFinite(m[2])&&(r.hasZ=!0)}async function Rt(t,n,a,r,o){if(Array.isArray(n)&&2===n.length){const e=n[0],a=n[1];if("number"==typeof e&&"number"==typeof a)return Jt.x=e,Jt.y=a,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,r,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,a,r,o))):n instanceof j?await vt(t,n,r,o):n instanceof e&&await bt(t,n,a,r,o)}async function zt(t,e,n,a,r){if(e.camera)return Gt(t,e.camera,a,r);r.scale=e.scale,r.rotation=e.rotation,r.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,r.camera=null,null!=n.heading?r.rotation=st(n.heading):null!=n.rotation&&(r.rotation=n.rotation);const o=dt(t,n);return null!=o&&(r.scale=o),r.camera=await lt(t,r,n.tilt,a),r}async function Gt(t,e,n,a){const r=t.spatialReference,o=await R(e.position,r,{signal:n}),i=e.clone();return i.position=o,jt(t,null,i,a)}async function Bt(t,e,n,a,r,o,i){const s=t.renderSpatialReference;return await M(e,qt,s,{signal:i}),await M(n,Yt,s,{signal:i}),o.targetGeometry=new b(e),r.position=new b(n),y(Wt,qt,Yt),rt(t,Yt,Wt,a.up,r),o.scale=$(t,p(Yt,qt)),o.rotation=st(r.heading),o.camera=r,o}async function Mt(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=X(t);if(e.position)return Bt(t,o.targetGeometry,e.position,i,a,o,r);if(e.zoomFactor){const n=i.distance/e.zoomFactor,a=u(Ot,i.viewForward,-n);i.eye=f(Ot,i.center,a),o.scale=$(t,n)}D(t,i,a);const s=xt(a,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await M(o.targetGeometry,Ot,t.renderSpatialReference,{signal:r});const e=Y(i.frustum,Ot)?p(i.eye,Ot):i.distance;o.camera=await L(t,o.targetGeometry,e,a,s),o.scale=$(t,e)}else o.scale=n,o.camera=await et(t,o.targetGeometry,o.scale,a,s,r)}return o}async function St(t,e,n,a,r){const o=X(t);g(Wt,o.viewForward),rt(t,o.eye,Wt,o.up,Dt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:r});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:Dt.heading,n.tilt=null!=e.tilt?e.tilt:Dt.tilt,jt(t,null,n,a)}async function Zt(t,e,n,a,r){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return S(o.center,s,c)?Mt(t,e,c,n,a,r):r}return r.scale=t.scale,r.camera=t.camera.clone(),xt(r.camera,e),r}async function Ft(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=X(t);D(t,i,a);const s=xt(a,e)?0:1;return o.camera=await H(t,n,a.heading,a.tilt,s,r),o}function Tt(t,e,n,a,r){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=at(t.elevationProvider,n)),h(Ot,n.x,n.y,o),B(t.spatialReference,Ot,Ut,t.renderSpatialReference),s(Nt,Ut),c(Nt,Nt),E(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=a[e[2]];isFinite(n)||(n=o),h(Ot,a[e[0]],a[e[1]],n),Z(Ot,t.spatialReference,Ot,t.renderSpatialReference),V(It,d(Ot,Ot,Nt))}const l=O(It),m=U(It),u=N(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/r}async function Pt(t,e,n,a,r,o,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,a,r);D(t,c,o);const m=xt(o,e)?0:1;return s.camera=await L(t,s.targetGeometry,l,o,m,i),s.scale=$(t,l),s}function At(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Et(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Vt(t,e){const n=ot;if(!e.length)return n;let a=Number.NEGATIVE_INFINITY;for(let r=0;r<e.length;r++){const t=e[r].screenSpaceBoundingRect;a=Math.max(a,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-a/Math.min(t.width,t.height)*2}class kt{constructor(){this.hasZ=!1,this.boundingBox=E(),this.screenSpaceObjects=new Array}}const Ot=w(),Ut=m(),Nt=l(),It=F(),Ct=I(),Wt=w(),Yt=w(),qt=w(),Dt={heading:0,tilt:0},Jt=new b,Xt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const a=t.hasZ;for(let r=0;r<t.rings.length;r++){const o=t.rings[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const a=t.hasZ;for(let r=0;r<t.paths.length;r++){const o=t.paths[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const a=t.points,r=t.hasZ;for(let o=0;o<a.length;o++)n[0]=a[o][0],n[1]=a[o][1],r&&(n[2]=a[o][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{cyclicalPI as r}from"../../../core/Cyclical.js";import"../../../core/has.js";import{clamp as s,deg2rad as i}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{watch as a,when as o,sync as l}from"../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../core/accessorSupport/decorators.js";import{subtract as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{i as u,e as p,d as m,D as g}from"../../../chunks/vec32.js";import{create as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as _,s as v,i as f}from"../../../chunks/vec42.js";import{fromValues as w,create as x}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as S}from"../../../geometry/projection/projectVectorToVector.js";import{create as P,width as O,center as D,copy as T,intersection as M,contains as j,offset as b}from"../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as I}from"../../../geometry/support/normalizeUtils.js";import{create as E,wrap as U}from"../../../geometry/support/ray.js";import{Sphere as V}from"../../../geometry/support/sphere.js";import{angleAroundAxis as C}from"../../../geometry/support/vector.js";import{y2lat as q}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as A}from"../state/utils/viewUtils.js";import{debugFlags as F}from"../support/debugFlags.js";import{DebugPoint as H}from"../support/debugUtils.js";import{OverlayRenderer as G}from"./OverlayRenderer.js";import{Intersector as z}from"../webgl-engine/lib/Intersector.js";import{fromValues as L}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as B}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{applyTextureResizeModulo as k,ensureTextureSize as W}from"../webgl-engine/lib/textureUtils.js";import{removeLoadedShaderModules as Y}from"../webgl-engine/parts/renderUtils.js";import{TaskPriority as N,noBudget as X}from"../../support/Scheduler.js";import{Yield as Z}from"../../support/Yield.js";const J=1.3,K=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let Q,$=class extends t{constructor(e){super(e),this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._latestOriginId=0,this.groundView=e.view.groundView}initialize(){const{view:e}=this;this.renderer=new G({parent:this}),e.stage.renderer.plugins.add(this.renderer);const t=()=>this.requestRender();this._groundIntersector=new z(e.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this.addHandles([a(()=>this.renderer.hasHighlights,t),this.renderer.events.on("has-water",()=>e.stage?.renderer.updateHasFlags()),this.renderer.events.on("content-changed",t),a(()=>e.state.camera.pixelRatio,t),a(()=>e.state.alignPixelEnabled,t),this.renderer.events.on("textures-disposed",()=>this.groundView.requestRender(1)),a(()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location],()=>this.setPlacementDirty()),a(()=>[e.state?.pixelRatio,e.state?.contentPixelRatio],()=>this.setPlacementDirty(),l),o(()=>this.groundView,e=>e.on("elevation-change",()=>this.setPlacementDirty())),e.on("resize",()=>this.setPlacementDirty()),e.resourceController.scheduler.registerTask(N.OVERLAY,this)]),e.stage.renderer.overlay=this}destroy(){this.view?.stage&&(this.view.stage.renderer.plugins.remove(this.renderer),this.view.stage.renderer.overlay=null,n(this.renderer)),Q&&(Q.hide(),Q=null),this.renderer=null}get spatialReference(){return this._spatialReference}set spatialReference(e){this._spatialReference=e,this.renderer.longitudeCyclical=null;const t=this.view.renderSpatialReference;null!=e&&null!=t?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this.renderer.longitudeCyclical=I(e))):this.renderer.disposeOverlays()}get readyToRun(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||F.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.groundView.ready}get _isSpherical(){return this.view.state.isGlobal}get worldToPCSRatio(){return null!=this._spatialReference&&this._spatialReference.isGeographic&&!this.view.state.isLocal?R(this._spatialReference).metersPerDegree:1}get _overlayStretch(){return J/this.view.resolutionScale}get longitudeCyclical(){return this.renderer.longitudeCyclical}get suspended(){return this.terrainSurface.enabled&&this.terrainSurface.suspended}get updating(){return this.readyToRun||!!this.renderer?.updating||this._contentUpdated}render(){return this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.precompileShaders(this.view.state)?this._drawOverlays():null}get hasOverlays(){return this.renderer.hasOverlays}registerDrapeSource(e,t){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources),this.renderer.registerDrapeSource(e,t),this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("readyToRun")}registerGeometryDrapeSource(e){const t=new B({stage:this.view.stage,drapeSource:e,rendererContext:this.renderer});return this.registerDrapeSource(e,t),t}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&null!=e.setDrapingExtent&&null!=this._spatialReference&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("readyToRun"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.requestRender()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this.updateOverlays(e,this.view.state.contentCamera,1)}updateOverlays(e,t,r){if(!this._spatialReference)return Z;const s=this._computeOverlayHeight(t);this._computeOverlayExtents(t,s,ie),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources,ie.stretch);const i=this._updateOverlay(0,ie.inner,s,1*ie.pixelRatioAdjustment,ie.mapUnitsPerPixel),n=O(ie.inner)/O(ie.outer),a=this._updateOverlay(1,ie.outer,s,n*ie.pixelRatioAdjustment,ie.mapUnitsPerPixel);1!==i&&1!==a||(this._drapeSources.forEach(e=>this._updateDrapeSourceExtent(e)),this.groundView.updateOverlayParameters(),this.groundView.requestRender(r)),0===i&&0===a||this.requestRender(),this._placementDirty=!1,e.madeProgress()}_computeOverlayHeight(e){const t=this.view.state.contentPixelRatio*this.view.resolutionScale,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t,i=Math.ceil(1.5*Math.max(r,s)),{maxPreferredTexturePixels:n,maxTextureSize:a}=this.view.stage.renderView.renderingContext.parameters,o=.5*a;return k(W({width:i,height:i},{maxPreferredTexturePixels:2*n,maxTextureSize:o})[1],o)}get overlays(){return this.renderer.overlays}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return 0;const n=this.renderer.overlays[e],a=n.mapUnitsPerPixel;if(n.mapUnitsPerPixel=i,n.pixelRatio=s,ee(t,n.extent)&&r===n.resolution)return a===i?0:2;n.setExtent(t),n.resolution=r;const o=D(n.extent);return n.renderLocalOrigin=L(o[0],o[1],0,"OV_"+this._latestOriginId++),1}overlayPixelSizeInMapUnits(e,t){if(0===this.renderer.overlays.length)return t();const r=this.renderer.overlays[0],s=this.renderer.overlays[1],i=this._pointIsInExtent(e,r.extent)?r:s;return(i.extent[2]-i.extent[0])/i.resolution}reloadShaders(){Y(),this.requestRender(),this.runTask(X)}requestRender(e=1){this.renderer.hasOverlays?(1===e?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this._drawTexturesAnimateDirty=!0,this.view.stage.renderView.requestRender(e)):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s,i){const n=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,oe,t,r);if(null==n)return!1;const a=n.origin,o=u(se,n.origin,n.direction);this._groundIntersector.reset(a,o,e),this._groundIntersector.intersect([]),this.view.groundView.intersect(this._groundIntersector,null,a,o);const l=this._groundIntersector.results.min;return l.getIntersectionPoint(i)&&l.withinDistance(s)}_findHorizonBasedPointOfInterest(e,t){let i=.5;const n=.55,a=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=s(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),d=e.aboveGround;if("global"===this.view.viewingMode){const t=se;le.radius=R(this.view.spatialReference).radius+h,le.closestPointOnSilhouette(U(e.eye,e.viewForward),t),p(t,t,e.eye);const s=r.normalize(C(e.viewForward,t,e.viewRight))/e.fovY+.5,a=s<=0||s>=1?.5:n;i=d?a*s:s+a*(1-s)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),r=Math.tan(t),a=w(0,r,1,0),o=_(a,a,e.projectionMatrix)[1],l=s(.5+.5*o,0,1);i=1===l||0===l?.5:d?l*n:1-(1-l)*n}return this._intersectGroundFromView(e,.5,i,o.distance,t)}_computeOverlayExtents(e,t,r){const{view:s}=this,n=s.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,a=y();this._findHorizonBasedPointOfInterest(e,a)||m(a,n);const o=this._renderSR;F.OVERLAY_SHOW_CENTER?(null==Q&&(Q=new H(s.graphics,"red")),Q.show(a,o)):null!=Q&&Q.hide();const l=Math.max(.1,g(e.eye,a)),h=A(s.renderCoordsHelper,n,e.eye),d=this._spatialReference;this._overlaySREqualsRenderSR||S(a,o,a,d);const u=this._isSpherical,p=this.groundView.groundExtent,_=!u&&d?.isGeographic,w=_&&d?1/R(d).metersPerDegree:1,x=s.state.contentPixelRatio,P=e.perScreenPixelRatio/x*l*w;r.mapUnitsPerPixel=P/this.worldToPCSRatio,r.stretch=this._overlayStretch;let D=t*P/2*r.stretch,b=!1,I=_?90:1/0;u&&p&&d&&(d.isWebMercator?(D/=Math.cos(q(a[1])),I=p[3]):(b=!0,D/=R(d).metersPerDegree,I=90),D>=I&&(D=I,a[1]=0,d.isWebMercator&&(a[0]=0)));let E=1;b&&(E=1/Math.max(.2,Math.cos(Math.abs(i(a[1])))),D*E>180&&(E=180/D),r.mapUnitsPerPixel*=E);const U=Math.log(2)/12;D=Math.exp(Math.round(Math.log(D)/U)*U);const V=D*E,C=32,G=.5*t/(C*V),z=.5*t/(C*D);a[0]=Math.round(a[0]*G)/G,a[1]=Math.round(a[1]*z)/z;const L=r.inner;L[0]=a[0]-V,L[1]=a[1]-D,L[2]=a[0]+V,L[3]=a[1]+D,u&&this._shiftExtentToFitBounds(L,1/0,I);const B=r.outer;if(p&&6*V>O(p))T(B,p);else{if(Math.PI/2-Math.abs(h-Math.PI/2)<=.25*Math.PI)B[0]=L[0]-V,B[1]=L[1]-D,B[2]=L[2]+V,B[3]=L[3]+D;else{S(e.eye,o,se,d),c(re,a,se);let t=-Math.atan2(re[1],re[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));v(re,K[r],2*D),re[0]*=E,re[2]*=E,f(B,L,re)}}if(u&&this.longitudeCyclical)B[0]=this.longitudeCyclical.clamp(B[0]),B[2]=this.longitudeCyclical.clamp(B[2]),B[1]=Math.max(B[1],-I),B[3]=Math.min(B[3],I);else{const e=M(L,p,ne),t=M(B,p,ae);j(e,t)&&(B[2]=B[0],B[3]=B[1])}const k=Math.abs(L[2]-L[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,k),r.pixelRatioAdjustment=r.mapUnitsPerPixel/k}_drawOverlays(e=this.view.state){if(!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return this.renderer;const t=!this._drawTexturesDirty&&this._drawTexturesAnimateDirty?0:1;this._drawTexturesDirty=this._drawTexturesAnimateDirty=!1;const r=this.renderer.computeValidity();this.renderer.releaseRenderTargets(t),this.renderer.drawOverlays(e,t);return r!==this.renderer.computeValidity()&&(this.groundView.updateOverlayParameters(),this.groundView.requestRender(1)),this.groundView.requestRender(t),1===t&&this.terrainSurface.requestUpdate(),this.renderer}_pointIsInExtent(e,t){if(this.longitudeCyclical)return this.longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),b(e,s,i)}get test(){}};function ee(e,t){const r=1e-5,s=F.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([h()],$.prototype,"_spatialReference",void 0),e([h({readOnly:!0})],$.prototype,"readyToRun",null),e([h()],$.prototype,"_placementDirty",void 0),e([h()],$.prototype,"_contentUpdated",void 0),e([h()],$.prototype,"_isSpherical",null),e([h()],$.prototype,"worldToPCSRatio",null),e([h()],$.prototype,"renderer",void 0),e([h({constructOnly:!0})],$.prototype,"view",void 0),e([h({constructOnly:!0})],$.prototype,"groundView",void 0),e([h({constructOnly:!0})],$.prototype,"terrainSurface",void 0),e([h()],$.prototype,"suspended",null),e([h()],$.prototype,"updating",null),$=e([d("esri.views.3d.terrain.OverlayManager")],$);class te{constructor(){this.inner=P(),this.outer=P(),this.mapUnitsPerPixel=0,this.pixelRatioAdjustment=1,this.stretch=J}}const re=x(),se=y(),ie=new te,ne=P(),ae=P(),oe=E(),le=new V;export{$ as OverlayManager};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{cyclicalPI as r}from"../../../core/Cyclical.js";import"../../../core/has.js";import{clamp as s,deg2rad as i}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{watch as a,when as o,sync as l}from"../../../core/reactiveUtils.js";import{property as h,subclass as d}from"../../../core/accessorSupport/decorators.js";import{subtract as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{i as u,e as p,d as m,B as g}from"../../../chunks/vec32.js";import{create as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as _,s as v,i as f}from"../../../chunks/vec42.js";import{fromValues as w,create as x}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as S}from"../../../geometry/projection/projectVectorToVector.js";import{create as P,width as O,center as D,copy as T,intersection as M,contains as j,offset as b}from"../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as I}from"../../../geometry/support/normalizeUtils.js";import{create as E,wrap as U}from"../../../geometry/support/ray.js";import{Sphere as V}from"../../../geometry/support/sphere.js";import{angleAroundAxis as C}from"../../../geometry/support/vector.js";import{y2lat as q}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as A}from"../state/utils/viewUtils.js";import{debugFlags as F}from"../support/debugFlags.js";import{DebugPoint as H}from"../support/debugUtils.js";import{OverlayRenderer as G}from"./OverlayRenderer.js";import{Intersector as z}from"../webgl-engine/lib/Intersector.js";import{fromValues as B}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as L}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{applyTextureResizeModulo as k,ensureTextureSize as W}from"../webgl-engine/lib/textureUtils.js";import{removeLoadedShaderModules as Y}from"../webgl-engine/parts/renderUtils.js";import{TaskPriority as N,noBudget as X}from"../../support/Scheduler.js";import{Yield as Z}from"../../support/Yield.js";const J=1.3,K=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let Q,$=class extends t{constructor(e){super(e),this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._latestOriginId=0,this.groundView=e.view.groundView}initialize(){const{view:e}=this;this.renderer=new G({parent:this}),e.stage.renderer.plugins.add(this.renderer);const t=()=>this.requestRender();this._groundIntersector=new z(e.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this.addHandles([a(()=>this.renderer.hasHighlights,t),this.renderer.events.on("has-water",()=>e.stage?.renderer.updateHasFlags()),this.renderer.events.on("content-changed",t),a(()=>e.state.camera.pixelRatio,t),a(()=>e.state.alignPixelEnabled,t),this.renderer.events.on("textures-disposed",()=>this.groundView.requestRender(1)),a(()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location],()=>this.setPlacementDirty()),a(()=>[e.state?.pixelRatio,e.state?.contentPixelRatio],()=>this.setPlacementDirty(),l),o(()=>this.groundView,e=>e.on("elevation-change",()=>this.setPlacementDirty())),e.on("resize",()=>this.setPlacementDirty()),e.resourceController.scheduler.registerTask(N.OVERLAY,this)]),e.stage.renderer.overlay=this}destroy(){this.view?.stage&&(this.view.stage.renderer.plugins.remove(this.renderer),this.view.stage.renderer.overlay=null,n(this.renderer)),Q&&(Q.hide(),Q=null),this.renderer=null}get spatialReference(){return this._spatialReference}set spatialReference(e){this._spatialReference=e,this.renderer.longitudeCyclical=null;const t=this.view.renderSpatialReference;null!=e&&null!=t?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this.renderer.longitudeCyclical=I(e))):this.renderer.disposeOverlays()}get readyToRun(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||F.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.groundView.ready}get _isSpherical(){return this.view.state.isGlobal}get worldToPCSRatio(){return null!=this._spatialReference&&this._spatialReference.isGeographic&&!this.view.state.isLocal?R(this._spatialReference).metersPerDegree:1}get _overlayStretch(){return J/this.view.resolutionScale}get longitudeCyclical(){return this.renderer.longitudeCyclical}get suspended(){return this.terrainSurface.enabled&&this.terrainSurface.suspended}get updating(){return this.readyToRun||!!this.renderer?.updating||this._contentUpdated}render(e){return this._contentUpdated=!1,this.renderer.time=e,this.renderer.processSyncDrapeSources(),this.renderer.precompileShaders(this.view.state)?this._drawOverlays():null}get hasOverlays(){return this.renderer.hasOverlays}registerDrapeSource(e,t){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources),this.renderer.registerDrapeSource(e,t),this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("readyToRun")}registerGeometryDrapeSource(e){const t=new L({stage:this.view.stage,drapeSource:e,rendererContext:this.renderer});return this.registerDrapeSource(e,t),t}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&null!=e.setDrapingExtent&&null!=this._spatialReference&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("readyToRun"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.requestRender()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this.updateOverlays(e,this.view.state.contentCamera,1)}updateOverlays(e,t,r){if(!this._spatialReference)return Z;const s=this._computeOverlayHeight(t);this._computeOverlayExtents(t,s,ie),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources,ie.stretch);const i=this._updateOverlay(0,ie.inner,s,1*ie.pixelRatioAdjustment,ie.mapUnitsPerPixel),n=O(ie.inner)/O(ie.outer),a=this._updateOverlay(1,ie.outer,s,n*ie.pixelRatioAdjustment,ie.mapUnitsPerPixel);1!==i&&1!==a||(this._drapeSources.forEach(e=>this._updateDrapeSourceExtent(e)),this.groundView.updateOverlayParameters(),this.groundView.requestRender(r)),0===i&&0===a||this.requestRender(),this._placementDirty=!1,e.madeProgress()}_computeOverlayHeight(e){const t=this.view.state.contentPixelRatio*this.view.resolutionScale,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t,i=Math.ceil(1.5*Math.max(r,s)),{maxPreferredTexturePixels:n,maxTextureSize:a}=this.view.stage.renderView.renderingContext.parameters,o=.5*a;return k(W({width:i,height:i},{maxPreferredTexturePixels:2*n,maxTextureSize:o})[1],o)}get overlays(){return this.renderer.overlays}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return 0;const n=this.renderer.overlays[e],a=n.mapUnitsPerPixel;if(n.mapUnitsPerPixel=i,n.pixelRatio=s,ee(t,n.extent)&&r===n.resolution)return a===i?0:2;n.setExtent(t),n.resolution=r;const o=D(n.extent);return n.renderLocalOrigin=B(o[0],o[1],0,"OV_"+this._latestOriginId++),1}overlayPixelSizeInMapUnits(e,t){if(0===this.renderer.overlays.length)return t();const r=this.renderer.overlays[0],s=this.renderer.overlays[1],i=this._pointIsInExtent(e,r.extent)?r:s;return(i.extent[2]-i.extent[0])/i.resolution}reloadShaders(){Y(),this.requestRender(),this.runTask(X)}requestRender(e=1){this.renderer.hasOverlays?(1===e?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this._drawTexturesAnimateDirty=!0,this.view.stage.renderView.requestRender(e)):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s,i){const n=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,oe,t,r);if(null==n)return!1;const a=n.origin,o=u(se,n.origin,n.direction);this._groundIntersector.reset(a,o,e),this._groundIntersector.intersect([]),this.view.groundView.intersect(this._groundIntersector,null,a,o);const l=this._groundIntersector.results.min;return l.getIntersectionPoint(i)&&l.withinDistance(s)}_findHorizonBasedPointOfInterest(e,t){let i=.5;const n=.55,a=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=s(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),d=e.aboveGround;if("global"===this.view.viewingMode){const t=se;le.radius=R(this.view.spatialReference).radius+h,le.closestPointOnSilhouette(U(e.eye,e.viewForward),t),p(t,t,e.eye);const s=r.normalize(C(e.viewForward,t,e.viewRight))/e.fovY+.5,a=s<=0||s>=1?.5:n;i=d?a*s:s+a*(1-s)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),r=Math.tan(t),a=w(0,r,1,0),o=_(a,a,e.projectionMatrix)[1],l=s(.5+.5*o,0,1);i=1===l||0===l?.5:d?l*n:1-(1-l)*n}return this._intersectGroundFromView(e,.5,i,o.distance,t)}_computeOverlayExtents(e,t,r){const{view:s}=this,n=s.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,a=y();this._findHorizonBasedPointOfInterest(e,a)||m(a,n);const o=this._renderSR;F.OVERLAY_SHOW_CENTER?(null==Q&&(Q=new H(s.graphics,"red")),Q.show(a,o)):null!=Q&&Q.hide();const l=Math.max(.1,g(e.eye,a)),h=A(s.renderCoordsHelper,n,e.eye),d=this._spatialReference;this._overlaySREqualsRenderSR||S(a,o,a,d);const u=this._isSpherical,p=this.groundView.groundExtent,_=!u&&d?.isGeographic,w=_&&d?1/R(d).metersPerDegree:1,x=s.state.contentPixelRatio,P=e.perScreenPixelRatio/x*l*w;r.mapUnitsPerPixel=P/this.worldToPCSRatio,r.stretch=this._overlayStretch;let D=t*P/2*r.stretch,b=!1,I=_?90:1/0;u&&p&&d&&(d.isWebMercator?(D/=Math.cos(q(a[1])),I=p[3]):(b=!0,D/=R(d).metersPerDegree,I=90),D>=I&&(D=I,a[1]=0,d.isWebMercator&&(a[0]=0)));let E=1;b&&(E=1/Math.max(.2,Math.cos(Math.abs(i(a[1])))),D*E>180&&(E=180/D),r.mapUnitsPerPixel*=E);const U=Math.log(2)/12;D=Math.exp(Math.round(Math.log(D)/U)*U);const V=D*E,C=32,G=.5*t/(C*V),z=.5*t/(C*D);a[0]=Math.round(a[0]*G)/G,a[1]=Math.round(a[1]*z)/z;const B=r.inner;B[0]=a[0]-V,B[1]=a[1]-D,B[2]=a[0]+V,B[3]=a[1]+D,u&&this._shiftExtentToFitBounds(B,1/0,I);const L=r.outer;if(p&&6*V>O(p))T(L,p);else{if(Math.PI/2-Math.abs(h-Math.PI/2)<=.25*Math.PI)L[0]=B[0]-V,L[1]=B[1]-D,L[2]=B[2]+V,L[3]=B[3]+D;else{S(e.eye,o,se,d),c(re,a,se);let t=-Math.atan2(re[1],re[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));v(re,K[r],2*D),re[0]*=E,re[2]*=E,f(L,B,re)}}if(u&&this.longitudeCyclical)L[0]=this.longitudeCyclical.clamp(L[0]),L[2]=this.longitudeCyclical.clamp(L[2]),L[1]=Math.max(L[1],-I),L[3]=Math.min(L[3],I);else{const e=M(B,p,ne),t=M(L,p,ae);j(e,t)&&(L[2]=L[0],L[3]=L[1])}const k=Math.abs(B[2]-B[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,k),r.pixelRatioAdjustment=r.mapUnitsPerPixel/k}_drawOverlays(e=this.view.state){if(!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return this.renderer;const t=!this._drawTexturesDirty&&this._drawTexturesAnimateDirty?0:1;this._drawTexturesDirty=this._drawTexturesAnimateDirty=!1;const r=this.renderer.computeValidity();this.renderer.releaseRenderTargets(t),this.renderer.drawOverlays(e,t);return r!==this.renderer.computeValidity()&&(this.groundView.updateOverlayParameters(),this.groundView.requestRender(1)),this.groundView.requestRender(t),1===t&&this.terrainSurface.requestUpdate(),this.renderer}_pointIsInExtent(e,t){if(this.longitudeCyclical)return this.longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),b(e,s,i)}get test(){}};function ee(e,t){const r=1e-5,s=F.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([h()],$.prototype,"_spatialReference",void 0),e([h({readOnly:!0})],$.prototype,"readyToRun",null),e([h()],$.prototype,"_placementDirty",void 0),e([h()],$.prototype,"_contentUpdated",void 0),e([h()],$.prototype,"_isSpherical",null),e([h()],$.prototype,"worldToPCSRatio",null),e([h()],$.prototype,"renderer",void 0),e([h({constructOnly:!0})],$.prototype,"view",void 0),e([h({constructOnly:!0})],$.prototype,"groundView",void 0),e([h({constructOnly:!0})],$.prototype,"terrainSurface",void 0),e([h()],$.prototype,"suspended",null),e([h()],$.prototype,"updating",null),$=e([d("esri.views.3d.terrain.OverlayManager")],$);class te{constructor(){this.inner=P(),this.outer=P(),this.mapUnitsPerPixel=0,this.pixelRatioAdjustment=1,this.stretch=J}}const re=x(),se=y(),ie=new te,ne=P(),ae=P(),oe=E(),le=new V;export{$ as OverlayManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as a,on as h,syncAndInitial as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u,subclass as p}from"../../../core/accessorSupport/decorators.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{h as m}from"../../../chunks/vec32.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import w from"../webgl/RenderCamera.js";import{T as x}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as T}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as b,renderHighlightBuffer as O}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as S}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as D}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as C,defaultRenderOccludedMask as P}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as j}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import{Texture as k}from"../../webgl/Texture.js";import{TextureDescriptor as G}from"../../webgl/TextureDescriptor.js";let I=class extends T{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new x,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new w,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[19,e=>8!==e||this.hasHighlights],[20,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new C(this._rctx,new j(t,e.state.viewingMode),i),this.addHandles([a(()=>s.updating,()=>this.events.emit("content-changed"),d),a(()=>this._spatialReference,e=>this._localOriginFactory=new D(e),d),h(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),a(()=>b(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),a(()=>e.state.highlights,r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const n=this._camera;n.near=1,n.far=1e4,n.relativeElevation=null,this._bindParameters.slot=19,this._bindParameters.camera=n,this._bindParameters.updateLighting([new F(y())],0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new S(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(a(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?L:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._setOutput(this._renderTargets?.targets.find(r=>r.content===e)?.output??0);++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._setOutput(t),s}_setOutput(e){const r=this._renderContext.output;return this._renderContext.output=e,this._bindParameters.slot=2===e?20:19,r}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._setOutput(e),8===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=L),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n,content:o}=r;if(this.isEmpty||2===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:a,_camera:h,_renderContext:d,_bindParameters:l}=this;if(h.pixelRatio=t.pixelRatio*i,this._setOutput(n),l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,4===o&&(d.renderOccludedMask=L),!this.renders(o))return d.renderOccludedMask=P,!1;const{resolution:c}=t,u=0===e,p=u?0:c;a.setViewport(p,0,c,c),this._bindTargetFBO(r),u&&(8===n?a.gl.clearBufferuiv(a.gl.COLOR,0,[0,0,0,0]):(a.setClearColor(0,0,0,0),a.clear(16384)));if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==o&&2!==o){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,B[e]),a.bindTechnique(r,l,this._passParameters),a.screen.draw()}if(8===n){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),O(a,t,{width:s,height:s},l,()=>this._renderAllGeometry(e,r),p)}else this._renderAllGeometry(e,r);return a.bindFramebuffer(null),d.renderOccludedMask=P,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,o=s.renderGroup??(n?0:1),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new U(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new G(e);i.samplingMode=9728,this._passParameters.texture=new k(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class U{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const B=[[1,.5,.5],[.5,.5,1]],H=-2,L=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,H as drapedZ,L as overlayRenderOccludedFlag};
|
|
5
|
+
import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as a,on as h,syncAndInitial as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u,subclass as p}from"../../../core/accessorSupport/decorators.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{h as m}from"../../../chunks/vec32.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import x from"../webgl/RenderCamera.js";import{T as w}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as T}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as b,renderHighlightBuffer as O}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as S}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as D}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as C,defaultRenderOccludedMask as P}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as j}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import{Texture as k}from"../../webgl/Texture.js";import{TextureDescriptor as G}from"../../webgl/TextureDescriptor.js";let I=class extends T{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new w,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new x,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[19,e=>8!==e||this.hasHighlights],[20,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new C(this._rctx,new j(t,e.state.viewingMode),i),this.addHandles([a(()=>s.updating,()=>this.events.emit("content-changed"),d),a(()=>this._spatialReference,e=>this._localOriginFactory=new D(e),d),h(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),a(()=>b(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),a(()=>e.state.highlights,r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const n=this._camera;n.near=1,n.far=1e4,n.relativeElevation=null,this._bindParameters.slot=19,this._bindParameters.camera=n,this._bindParameters.updateLighting([new F(y())],0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}set time(e){this._renderContext.time=e}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new S(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(a(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?L:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._setOutput(this._renderTargets?.targets.find(r=>r.content===e)?.output??0);++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._setOutput(t),s}_setOutput(e){const r=this._renderContext.output;return this._renderContext.output=e,this._bindParameters.slot=2===e?20:19,r}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._setOutput(e),8===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=L),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n,content:o}=r;if(this.isEmpty||2===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:a,_camera:h,_renderContext:d,_bindParameters:l}=this;if(h.pixelRatio=t.pixelRatio*i,this._setOutput(n),l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,4===o&&(d.renderOccludedMask=L),!this.renders(o))return d.renderOccludedMask=P,!1;const{resolution:c}=t,u=0===e,p=u?0:c;a.setViewport(p,0,c,c),this._bindTargetFBO(r),u&&(8===n?a.gl.clearBufferuiv(a.gl.COLOR,0,[0,0,0,0]):(a.setClearColor(0,0,0,0),a.clear(16384)));if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==o&&2!==o){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,B[e]),a.bindTechnique(r,l,this._passParameters),a.screen.draw()}if(8===n){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),O(a,t,{width:s,height:s},l,()=>this._renderAllGeometry(e,r),p)}else this._renderAllGeometry(e,r);return a.bindFramebuffer(null),d.renderOccludedMask=P,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,o=s.renderGroup??(n?0:1),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new U(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new G(e);i.samplingMode=9728,this._passParameters.texture=new k(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class U{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const B=[[1,.5,.5],[.5,.5,1]],H=-2,L=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,H as drapedZ,L as overlayRenderOccludedFlag};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{D as s,H as o,u as a,e as n,n as l,g as d,a as g,G as h}from"../../../chunks/vec32.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as E,neighborCornerIndices as C,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import V from"./TileOverlayData.js";import{fallsWithinLayerView as T}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class N{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new V,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new y,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.groundExtent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=$[e];if(!t)return v(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(v(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(E(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!e.leaf),!1))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(C[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>e+t+1,0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(e,p(t.layout),t.buffer),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(T(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.groundExtent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=C.map(t=>e.findNeighborCornerTileExact(t,t=>!t.intersectsClippingArea||t.loaded||t.level===e.level)??null).map(e=>e?.intersectsClippingArea?e:null),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[y])return;const x=e.findNeighborTile(r,e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea);if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const E=2**_;if(_<0)return void v(!1);const C=e.renderData,S=C.geometry,j=C.localOrigin,R=S.getEdgeCount(y),V=S.numVerticesPerSide-1,T=$.geometry;if(!T)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,N=T.getEdgeCount(P),L=R-1,X=N-1;v(L*E===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*E})`);const B=e.extent,H=0===r||4===r,W=N-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=T.numVerticesPerSide-1;v(_>0||q===Math.max(J,V));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<E);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,F,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(F,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,F,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.groundExtent;if(null==_||c(_,s,p)){const t=o(F,G),r=a(F)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${N}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,C.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(F),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,F,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,F,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${F} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=T.getEdgeCount(N);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(F)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,O,Y),T.getEdgeNormal(P,M,Z),l(k,O),l(U,M);const E=d(k,U),V=1-E<.01||!1||e===x;if(!V){const t=u();g(t,O,M);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${N-1}) nedge ${P} :${D(O)} vs ${D(M)} dot = ${E} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),T.getEdgeNormal(P,r,Z),h(O,t)||console.warn("Missing update in tile normal: ",D(O)," => ",D(t)),h(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}v(V,r())}}Y+=1,Z+=1}})}}const F=u(),G=u(),O=u(),M=u(),k=u(),U=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{N as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q as zeroToFour};
|
|
5
|
+
import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{B as s,F as o,u as a,e as n,n as l,g as d,a as g,E as h}from"../../../chunks/vec32.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as E,neighborCornerIndices as C,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import V from"./TileOverlayData.js";import{fallsWithinLayerView as T}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class F{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new V,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new y,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.groundExtent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=$[e];if(!t)return v(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(v(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(E(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!e.leaf),!1))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(C[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>e+t+1,0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(e,p(t.layout),t.buffer),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(T(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.groundExtent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=C.map(t=>e.findNeighborCornerTileExact(t,t=>!t.intersectsClippingArea||t.loaded||t.level===e.level)??null).map(e=>e?.intersectsClippingArea?e:null),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[y])return;const x=e.findNeighborTile(r,e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea);if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const E=2**_;if(_<0)return void v(!1);const C=e.renderData,S=C.geometry,j=C.localOrigin,R=S.getEdgeCount(y),V=S.numVerticesPerSide-1,T=$.geometry;if(!T)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=T.getEdgeCount(P),L=R-1,X=F-1;v(L*E===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*E})`);const B=e.extent,H=0===r||4===r,W=F-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=T.numVerticesPerSide-1;v(_>0||q===Math.max(J,V));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<E);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,N,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(N,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,N,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.groundExtent;if(null==_||c(_,s,p)){const t=o(N,G),r=a(N)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${F}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,C.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(N),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,N,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,N,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${N} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=T.getEdgeCount(F);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(N)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,O,Y),T.getEdgeNormal(P,M,Z),l(k,O),l(U,M);const E=d(k,U),V=1-E<.01||!1||e===x;if(!V){const t=u();g(t,O,M);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${F-1}) nedge ${P} :${D(O)} vs ${D(M)} dot = ${E} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),T.getEdgeNormal(P,r,Z),h(O,t)||console.warn("Missing update in tile normal: ",D(O)," => ",D(t)),h(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}v(V,r())}}Y+=1,Z+=1}})}}const N=u(),G=u(),O=u(),M=u(),k=u(),U=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{F as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q as zeroToFour};
|