@arcgis/core 4.33.0-next.20250324 → 4.33.0-next.20250325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/09c9e4e94f09ba9f4c22.js +1 -0
- package/assets/esri/core/workers/chunks/{3bea1400160042dca9f3.js → 0e82365be7d9257e7cb2.js} +1 -1
- package/assets/esri/core/workers/chunks/3808f10747cecc8a1a9b.js +1 -0
- package/assets/esri/core/workers/chunks/{e5e1f8ac53c70427a60b.js → 59e4e780dcdfed555ca5.js} +1 -1
- package/assets/esri/core/workers/chunks/{33005043f7084048296d.js → 6ab96eaaad0aaad46db9.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c9160e3d596fe75392d.js → 75ec4d2ae9d427a1434f.js} +1 -1
- package/assets/esri/core/workers/chunks/{11f9d7cd95891596b716.js → 77199b4b39ee8b4303de.js} +1 -1
- package/assets/esri/core/workers/chunks/{74c01de62ccaed0666e0.js → 81f2f1614ea27f4c2e65.js} +1 -1
- package/assets/esri/core/workers/chunks/{d787474e78360c925fd9.js → a59ad50d932da1e28c8f.js} +1 -1
- package/assets/esri/core/workers/chunks/{47c04980098dc0c228d7.js → b02ac03503bfff1ff922.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ee000c92e4d5d21e22d.js → bc3f42401131a12fce9b.js} +1 -1
- package/assets/esri/core/workers/chunks/{9cfce9414b874878d761.js → bea2f317b73a86e2a997.js} +1 -1
- package/assets/esri/core/workers/chunks/{2cedf4222238c86a98e8.js → c6bcfa99fb222894fa0e.js} +1 -1
- package/assets/esri/core/workers/chunks/cb386923200272cf26a9.js +1 -0
- package/chunks/LineSeries.js +1 -1
- package/chunks/Theme.js +1 -1
- package/chunks/Tick.js +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/chunks/nl_NL.js +1 -1
- package/chunks/vec32.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/geometry/support/buffer/BufferView.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/package.json +1 -1
- package/rest/support/DirectionLine.js +1 -1
- package/rest/support/DirectionPoint.js +1 -1
- package/rest/support/PointBarrier.js +1 -1
- package/rest/support/PolygonBarrier.js +1 -1
- package/rest/support/PolylineBarrier.js +1 -1
- package/rest/support/RouteInfo.js +1 -1
- package/rest/support/Stop.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/RouteLayerView2D.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
- package/views/3d/layers/graphics/LabelDeconflictor.js +1 -1
- package/views/3d/layers/graphics/deconflictorDebug.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/RibbonVertexPosition.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/interactive/SegmentLabels.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/tooltip/tooltipCommonUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/assets/esri/core/workers/chunks/1034155c525d2b7baaa1.js +0 -1
- package/assets/esri/core/workers/chunks/2b9ce6648823f6962f58.js +0 -1
- package/assets/esri/core/workers/chunks/88a7780b1c689afff8bd.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as i}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{lerp as s}from"../../../../core/mathUtils.js";import e from"../../../../core/PooledArray.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as l,j as h,h as p,i as u,c as d}from"../../../../chunks/vec32.js";import{ZEROS as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as m,t as b,b as g}from"../../../../chunks/vec42.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as G}from"../../../../geometry/ellipsoidUtils.js";import{create as w,empty as S,offset as B,width as N,height as D,expand as I,intersects as T}from"../../../../geometry/support/aaBoundingRect.js";import{d as j,a as C,e as P}from"../../../../chunks/boundedPlane.js";import{create as V}from"../../../../geometry/support/ray.js";import{a as A,h as x,j as O,c as M}from"../../../../chunks/sphere.js";import{drawAccelerationStruct as E,prepare as z,drawPoly as X}from"./deconflictorDebug.js";import{VisibilityGroup as Y,VisibilityFlag as F}from"./enums.js";import L from"../../webgl/RenderCamera.js";import{newIntersector as R}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as H}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{applyPrecomputedScaleFactor as W}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as U}from"../../webgl-engine/lib/VertexAttribute.js";import{HUDMaterial as k}from"../../webgl-engine/materials/HUDMaterial.js";import{ScaleInfo as q}from"../../webgl-engine/materials/ScaleInfo.js";const J=f(),K=f(),Q=v(),Z=v(),$=f(),ii=c(),ti=M(),si=V(),ei=f(),ri=w();class ai{constructor(){this.aabr=w(),this.distance=0,this.distanceToTerrain=0,this.culled=!1,this.visible=!1}}class oi{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this.info={}}}var ci;!function(i){i[i.Idle=0]="Idle",i[i.Process=1]="Process",i[i.Sort=2]="Sort",i[i.Deconflict=3]="Deconflict",i[i.NumStates=4]="NumStates"}(ci||(ci={}));class ni{constructor(){this.camera=new L,this.slicePlane=j(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.copyFrom(i.camera),C(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let li=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ni,this._state=ci.Idle,this._active=new Map,this._visible=new Map,this._iterators=new _i,this._accBinsNumX=15,this._accBinsNumY=20,this._accBinsSizeX=0,this._accBinsSizeY=0,this._accBins=null,this._accNumTests=0,this._updatingHandles=new y}destroy(){this._updatingHandles.destroy(),this._active.clear(),this._visible.clear(),this._iterators=null}setDirty(){!this._dirty&&this._active.size>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._state!==ci.Idle||this._dirty||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;const i=this._state/ci.NumStates;return this._dirty?.5*i:i}get running(){return this.view.ready&&null!=this.view.state&&this.updating}runTask(i){switch(this._state){case ci.Idle:this._startUpdate(),i.madeProgress();case ci.Process:if(this._state=ci.Process,!this._processActiveGraphics(i))return;case ci.Sort:if(this._state=ci.Sort,!this._sortVisibleGraphics(i))return;case ci.Deconflict:if(this._state=ci.Deconflict,!this._deconflictVisibleGraphics(i))return;default:E((()=>({bins:this._accBins,numX:this._accBinsNumX,numY:this._accBinsNumY,sizeX:this._accBinsSizeX,sizeY:this._accBinsSizeY,numTests:this._accNumTests,numVisible:this._visible.size}))),this._state=ci.Idle,this.notifyChange("updating")}}modifyGraphics(i,t){t?i.forEach((i=>this.addToActiveGraphics(i))):i.forEach((i=>this.removeFromActiveGraphics(i))),this.setDirty()}layerSupportsDeconfliction(i){if(null==i||"object3d"!==i.type)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const s=t?.geometries[0],e=s?.material;return e instanceof k}_startUpdate(){z(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;this._initBins(i,t),this._resetIterators()}addToActiveGraphics(i){i.info[this.visibilityGroup]=new ai,this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){this._visible.delete(i.graphics3DGraphic.graphic.uid),hi(i,this.visibilityGroup),delete i.info[this.visibilityGroup],this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}_createTerrainIntersector(){const i=R(this.view.state.viewingMode);i.options.store=H.MIN;const t=this.view.basemapTerrain,s=this.view.state.camera;return o(ii,this._viewState.camera.viewInverseTransposeMatrix),e=>{l(K,e,ii),i.reset(s.eye,K,s),t.intersect(i,null,s.eye,K);const r=i.results.ground.dist;return null!=r?r*h(K,s.eye):0}}_processActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),s=this._viewState.camera.inverseProjectionMatrix,e="global"===this.view.viewingMode&&1===this.view.map.ground.opacity&&this._viewState.camera.relativeElevation>0,r=this.view.map.ground.opacity>0?this._createTerrainIntersector():null,a=e?ti:null;let o=0;for(null!=a&&(l(A(a),_,this._viewState.camera.viewMatrix),a[3]=G(this.view.spatialReference).radius,o=x(a,_));!i.done;){i.madeProgress();const e=t.next();if(!0===e.done)return this._resetActiveGraphicsIterator(),!0;const c=e.value,n=c?.info[this.visibilityGroup];n&&(this._collectGraphics3DGraphics(c,s,a,o,r),n.culled?(this._setGraphicVisibility(c,!1),this._visible.delete(c.graphics3DGraphic.graphic.uid)):this._visible.set(c.graphics3DGraphic.graphic.uid,c))}return!1}_sortVisibleGraphics(i){const t=this._ensureSortGraphicsIterator();for(;!i.done;){const s=t.next();if(i.madeProgress(),!0===s.done)return this._resetSortGraphicsIterator(),!0}return!1}_deconflictVisibleGraphics(i){const t=this._ensureVisibleGraphicsIterator(),s=this.visibilityGroup===Y.LABEL;for(;!i.done;){i.madeProgress();const e=t.next();if(!0===e.done)return this._resetVisibleGraphicsIterator(),!0;const r=e.value,a=r.info[this.visibilityGroup];if(!a||a.culled){this._setGraphicVisibility(r,!1);continue}const o=r.graphics3DGraphic,c=!s||o.isVisible();a.visible=c&&!this._isConflicted(r),a.visible&&this._addToBins(r),this._setGraphicVisibility(r,a.visible),X(a,a.visible)}return!1}_resetIterators(){this._iterators.active=null,this._iterators.visible=null,this._iterators.sort=null}_ensureActiveGraphicsIterator(){return this._iterators.active||(this._iterators.active=pi(this._active)),this._iterators.active}_resetActiveGraphicsIterator(){this._iterators.active=null}_ensureVisibleGraphicsIterator(){return this._iterators.visible||(this._iterators.visible=pi(this._visible)),this._iterators.visible}_resetVisibleGraphicsIterator(){this._iterators.visible=null}_ensureSortGraphicsIterator(){return this._iterators.sort||(this._iterators.sort=ui(this._visible,this._iterators.sortArray,this.visibilityGroup)),this._iterators.sort}_resetSortGraphicsIterator(){this._iterators.sort=null}_collectGraphics3DGraphics(i,t,s,e,r){const a=i.graphics3DGraphic;if(a.destroyed)return;const o=i.info[this.visibilityGroup];if(!a.isVisible(Y.GRAPHIC,F.DECONFLICTION))return void(o.culled=!0);const c=this.getGraphicsLayers(a);S(o.aabr);let n=null;for(const l of c){if(!this.layerSupportsDeconfliction(l))continue;const a=l.stageObject.geometries[0].material;if(null==n){if(n=gi,this._getProjectionInfo(l,t,n),n.isOutsideScreen||this._isCulledBySlice(i,J)||null!=s&&bi(n,s,e))return void(o.culled=!0);n.distanceToTerrain=r?.(n.positionView)??0}this._expandBoundingRect(o,l,a,n)}null==n?o.culled=!0:(o.distance=n.distance,o.distanceToTerrain=n.distanceToTerrain,o.culled=!1)}_getProjectionInfo(i,t,s){const e=this._viewState.camera,r=i.stageObject,a=r.geometries[0],o=a.material,c=A(r.boundingVolumeWorldSpace.bounds);l(J,c,e.viewMatrix);const n=a.attributes,h=n.get(U.NORMAL).data,d=n.get(U.CENTEROFFSETANDDISTANCE).data;o.applyShaderOffsetsView(J,h,r.transformation,d,e,s.scaleInfo,J),m(Q,J[0],J[1],J[2],1),b(Z,Q,e.projectionMatrix),p(s.positionNDC,Z,1/Z[3]),o.applyShaderOffsetsNDC(s.positionNDC,d,e,s.positionNDC,$),s.distanceWithoutPolygonOffset=e.depthNDCToWorld($[2]),s.distance=$[2]===s.positionNDC[2]?s.distanceWithoutPolygonOffset:e.depthNDCToWorld(s.positionNDC[2]),m(Z,s.positionNDC[0],s.positionNDC[1],s.positionNDC[2],1),b(Q,Z,t),g(Q,Q,1/Q[3]),u(s.positionView,J[0],J[1],J[2])}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&P(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,e,{positionNDC:r,scaleInfo:a}){const o=this._viewState.camera,c=t.getScreenSize(fi);W(c,a.factor,c),c[0]*=o.pixelRatio,c[1]*=o.pixelRatio;const n=B(e.calculateRelativeScreenBounds(c,a.factorAlignment.scale,ri),s(0,o.fullWidth,.5+.5*r[0]),s(0,o.fullHeight,.5+.5*r[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(N(n),D(n));n[0]-=i,n[1]-=i,n[2]+=i,n[3]+=i}I(i.aabr,n,i.aabr)}_isConflicted(i){const t=i.graphics3DGraphic.graphic.uid,s=i.info[this.visibilityGroup];let e=!0;for(let r=Math.floor(s.aabr[0]/this._accBinsSizeX);r<=Math.floor(s.aabr[2]/this._accBinsSizeX);r++)if(!(r<0||r>=this._accBinsNumX))for(let i=Math.floor(s.aabr[1]/this._accBinsSizeY);i<=Math.floor(s.aabr[3]/this._accBinsSizeY);i++){if(i<0||i>=this._accBinsNumY)continue;e=!1;const a=this._accBins[r][i];for(let i=0;i<a.length;i++){const e=a.data[i],r=e.info[this.visibilityGroup];if(r&&r.visible&&e.graphics3DGraphic.graphic.uid!==t&&(this._accNumTests++,T(r.aabr,s.aabr)))return!0}}return e}_initBins(i,t){if(null==this._accBins){this._accBins=[];for(let i=0;i<this._accBinsNumX;i++){this._accBins.push([]);const i=this._accBins[this._accBins.length-1];for(let t=0;t<this._accBinsNumY;t++)i.push(new e)}}else for(let s=0;s<this._accBinsNumX;s++)for(let i=0;i<this._accBinsNumY;i++)this._accBins[s][i].clear();this._accBinsSizeX=i/this._accBinsNumX,this._accBinsSizeY=t/this._accBinsNumY,this._accNumTests=0}_addToBins(i){const t=i.info[this.visibilityGroup],s=Math.floor(t.aabr[0]/this._accBinsSizeX),e=Math.floor(t.aabr[2]/this._accBinsSizeX),r=Math.floor(t.aabr[1]/this._accBinsSizeY),a=Math.floor(t.aabr[3]/this._accBinsSizeY);for(let o=s;o<=e;o++)if(!(o<0||o>=this._accBinsNumX))for(let t=r;t<=a;t++)t<0||t>=this._accBinsNumY||this._accBins[o][t].push(i)}_setGraphicVisibility(i,t){const s=i.graphics3DGraphic;s.destroyed||(s.setVisibilityFlag(this.visibilityGroup,F.DECONFLICTION,t),this.visibilityGroup===Y.LABEL&&this.view.labeler.setLabelGraphicVisibility(s,t))}};function hi(i,t){const s=i.graphics3DGraphic;s.destroyed||s.setVisibilityFlag(t,F.DECONFLICTION,!0)}function*pi(i){if(Map.prototype.entries){const t=i.entries();for(let i=t.next();!i.done;i=t.next())yield i.value[1]}else yield*i.values()}function*ui(i,t,s){t.clear(),i.forEach(((i,e)=>{const r=t.pushNew();r.id=e,r.visible=i.graphics3DGraphic.getVisibilityFlag(s,F.DECONFLICTION);const a=i.info?.[s];r.prio=i.graphics3DGraphic.deconflictionPriority,r.distance=a?a.distance:Number.MAX_VALUE,r.behindTerrain=!!a&&0!==a.distanceToTerrain&&a.distance>a.distanceToTerrain})),yield;const e=t.iterableSort(((i,t)=>i.behindTerrain!==t.behindTerrain?+i.behindTerrain-+t.behindTerrain:i.prio!==t.prio?t.prio-i.prio:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?+t.visible-+i.visible:i.id-t.id));for(let r=e.next();!r.done;r=e.next())yield;t.forAll((t=>{const s=i.get(t.id);s&&(i.delete(t.id),i.set(t.id,s))})),t.clear()}i([r({constructOnly:!0})],li.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],li.prototype,"updating",null),i([r({readOnly:!0})],li.prototype,"_updatingHandles",void 0),li=i([a("esri.views.3d.layers.graphics.Deconflictor")],li);class di{constructor(){this.id=0,this.visible=!1,this.behindTerrain=!1,this.prio=0,this.distance=0}}class _i{constructor(i=null,t=null,s=null){this.active=i,this.visible=t,this.sort=s,this.sortArray=new e({allocator:i=>i||new di})}}const fi=n();class mi{constructor(){this.positionView=f(),this.positionNDC=f(),this.distance=0,this.distanceToTerrain=0,this.distanceWithoutPolygonOffset=0,this.scaleInfo=new q}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1||i[2]>=1}}function bi(i,t,s){return d(si.direction,i.positionView),u(si.origin,0,0,0),!!O(t,si,ei)&&i.distanceWithoutPolygonOffset>s}const gi=new mi;export{li as Deconflictor,oi as DeconflictorGraphic,ni as DeconflictorViewState,ci as State};
|
|
5
|
+
import{_ as i}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{lerp as e}from"../../../../core/mathUtils.js";import s from"../../../../core/PooledArray.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as l,t as h,c as u,i as p,H as d,h as _}from"../../../../chunks/vec32.js";import{ZEROS as f,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as g,t as m,b}from"../../../../chunks/vec42.js";import{create as I}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as w}from"../../../../geometry/ellipsoidUtils.js";import{create as G,empty as B,offset as N,width as D,height as S,expand as V,intersects as P}from"../../../../geometry/support/aaBoundingRect.js";import{d as C,a as j,e as T}from"../../../../chunks/boundedPlane.js";import{create as O,fromPoints as A}from"../../../../geometry/support/ray.js";import{a as E,h as x,j as M,c as L}from"../../../../chunks/sphere.js";import{drawAccelerationStruct as z,prepare as H,drawPoly as R}from"./deconflictorDebug.js";import{VisibilityGroup as F,VisibilityFlag as X}from"./enums.js";import Y from"../../webgl/RenderCamera.js";import{newIntersector as k}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as W}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{applyPrecomputedScaleFactor as U}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as q}from"../../webgl-engine/lib/VertexAttribute.js";import{HUDMaterial as J}from"../../webgl-engine/materials/HUDMaterial.js";import{ScaleInfo as K}from"../../webgl-engine/materials/ScaleInfo.js";const Q=v(),Z=v(),$=I(),ii=I(),ti=v(),ei=c(),si=L(),ri=O(),ai=v(),oi=G();class ci{constructor(){this.aabr=G(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1}}class ni{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this.graphicPositionView=null,this._info=null,this._labelInfo=null}assertInfo(i){let t=this.getInfo(i);return t||(t=new ci,i===F.LABEL?this._labelInfo=t:this._info=t),t}getInfo(i){return i===F.LABEL?this._labelInfo:this._info}removeInfo(i){i===F.LABEL?this._labelInfo=null:this._info=null}}var li;!function(i){i[i.Idle=0]="Idle",i[i.VisibilityInactive=1]="VisibilityInactive",i[i.Process=2]="Process",i[i.Sort=3]="Sort",i[i.Deconflict=4]="Deconflict",i[i.NumStates=5]="NumStates"}(li||(li={}));class hi{constructor(){this.camera=new Y,this.slicePlane=C(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.copyFrom(i.camera),j(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let ui=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new hi,this._state=li.Idle,this._inactive=new Map,this._active=new Map,this._visible=new Map,this._inactiveIterator=null,this._activeIterator=null,this._visibleIterator=null,this._sortIterator=null,this._sortArray=new s({allocator:i=>i||new fi}),this._accBinsNumX=15,this._accBinsNumY=20,this._accBinsSizeX=0,this._accBinsSizeY=0,this._accBins=null,this._accNumTests=0,this._updatingHandles=new y}initialize(){this._updatingHandles.add((()=>(this.view?.map?.ground?.opacity??0)>0),(()=>this.setDirty()))}destroy(){this._updatingHandles.destroy(),this._inactive.clear(),this._active.clear(),this._visible.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._inactive.size>0)&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._state!==li.Idle||this._dirty||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;const i=this._state/li.NumStates;return this._dirty?.5*i:i}get running(){return this.view.ready&&null!=this.view.state&&this.updating}runTask(i){switch(this._state){case li.Idle:this._startUpdate(),i.madeProgress();case li.VisibilityInactive:if(this._state=li.VisibilityInactive,!this._processInactiveGraphics(i))return;case li.Process:if(this._state=li.Process,!this._processActiveGraphics(i))return;case li.Sort:if(this._state=li.Sort,!this._sortVisibleGraphics(i))return;case li.Deconflict:if(this._state=li.Deconflict,!this._deconflictVisibleGraphics(i))return;default:z((()=>({bins:this._accBins,numX:this._accBinsNumX,numY:this._accBinsNumY,sizeX:this._accBinsSizeX,sizeY:this._accBinsSizeY,numTests:this._accNumTests,numVisible:this._visible.size}))),this._state=li.Idle,this.notifyChange("updating")}}setGraphicsActive(i,t){t?i.forEach((i=>this.addToActiveGraphics(i))):i.forEach((i=>this.removeFromActiveGraphics(i)))}setGraphicsInactive(i,t){t?i.forEach((i=>this.addToInactiveGraphics(i))):i.forEach((i=>this.removeFromInactiveGraphics(i)))}layerSupportsDeconfliction(i){if(null==i||"object3d"!==i.type)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const e=t?.geometries[0],s=e?.material;return s instanceof J}_startUpdate(){H(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;this._initBins(i,t),this._resetIterators()}addToActiveGraphics(i){i.assertInfo(this.visibilityGroup),this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){this._visible.delete(i.graphics3DGraphic.graphic.uid),pi(i,this.visibilityGroup),i.removeInfo(this.visibilityGroup),this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}addToInactiveGraphics(i){this._inactive.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromInactiveGraphics(i){this._inactive.delete(i.graphics3DGraphic.graphic.uid)}_createIntersector(){const i=this.view.sceneIntersectionHelper,t=k(this.view.state.viewingMode);t.options.store=W.MIN,t.options.hud=!1,t.options.normalRequired=!1;const e=this.view.state.camera;return s=>{t.reset(e.eye,s,e),i.computeIntersection(A(e.eye,s,ri),t,{enableDraped:!1});const r=t.results.min.dist;return null!=r?r*l(s,e.eye):0}}_processInactiveGraphics(i){if(0===this._inactive.size)return!0;const t=this._ensureInactiveGraphicsIterator(),e=this._viewState.camera,s=this.view.renderCoordsHelper.getAltitude(e.eye),r=o(ei,e.viewInverseTransposeMatrix),a=this.view.map.ground.opacity>0,c="global"===this.view.viewingMode&&a&&e.relativeElevation>0?si:null;let n=0;null!=c&&(h(E(c),f,e.viewMatrix),c[3]=w(this.view.spatialReference).radius,n=x(c,f));const l=a?this._createIntersector():null,u=G();for(;!i.done;){i.madeProgress();const a=t.next();if(!0===a.done)return this._inactiveIterator=null,!0;const o=a.value,p=o.graphics3DGraphic;if(p.destroyed)continue;if(!p.isVisible(F.GRAPHIC,X.DECONFLICTION))continue;const d=this.getGraphicsLayers(p);let _=null,f=!0;for(const i of d){if(!this.layerSupportsDeconfliction(i))continue;_=bi,this._getProjectionInfo(i,e,_),B(u);const t=i.stageObject.geometries[0].material;if(this._expandBoundingRect(u,e,i,t,_),u[0]>e.fullWidth||u[1]>e.fullHeight||u[2]<0||u[3]<0){f=!1;break}if(this._isCulledBySlice(o,_.positionView)){f=!1;break}if(null!=c&&mi(_,c,n)){f=!1;break}h(Z,_.positionView,r),_.altitude=this.view.renderCoordsHelper.getAltitude(Z),_.distanceToOccluder=l?.(Z)??0,f=this._occludedVisibility(_.distanceToOccluder,_.distance,_.altitude,s),this._setCachedGraphicPosition(o,_.positionView);break}R(u,f,!0),this._setGraphicVisibility(o,f)}return!1}_setCachedGraphicPosition(i,t){const e=this.visibilityGroup===F.LABEL||i.getInfo(F.LABEL);this.visibilityGroup===F.GRAPHIC&&e?i.graphicPositionView=u(i.graphicPositionView??v(),t):i.graphicPositionView&&!e?i.graphicPositionView=null:i.graphicPositionView&&p(i.graphicPositionView,NaN,NaN,NaN)}_processActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),e=this._viewState.camera,s=o(ei,e.viewInverseTransposeMatrix),r=e.relativeElevation,a=this.view.renderCoordsHelper.getAltitude(e.eye),c=this.view.map.ground.opacity>0,n="global"===this.view.viewingMode&&c&&r>0,l=c?this._createIntersector():null,u=n?si:null;let p=0;for(null!=u&&(h(E(u),f,e.viewMatrix),u[3]=w(this.view.spatialReference).radius,p=x(u,f));!i.done;){i.madeProgress();const r=t.next();if(!0===r.done)return this._activeIterator=null,!0;const o=r.value,c=o.assertInfo(this.visibilityGroup);this._collectGraphics3DGraphics(o,c,e,s,u,p,l),this._occludedVisibility(c.distanceToOccluder,c.distance,c.altitude,a)||(c.culled=!0),c.culled?(R(c.aabr,!1,!0),this._setGraphicVisibility(o,!1),this._visible.delete(o.graphics3DGraphic.graphic.uid)):this._visible.set(o.graphics3DGraphic.graphic.uid,o)}return!1}_occludedVisibility(i,t,e,s){return 0===i||t<=i+10+2*(Math.max(100,Math.abs(e-s))-100)}_sortVisibleGraphics(i){const t=this._ensureSortGraphicsIterator();for(;!i.done;){const e=t.next();if(i.madeProgress(),!0===e.done)return this._sortIterator=null,!0}return!1}_deconflictVisibleGraphics(i){const t=this._ensureVisibleGraphicsIterator(),e=this.visibilityGroup===F.LABEL;for(;!i.done;){i.madeProgress();const s=t.next();if(!0===s.done)return this._visibleIterator=null,!0;const r=s.value,a=r.getInfo(this.visibilityGroup);if(!a||a.culled){this._setGraphicVisibility(r,!1);continue}const o=r.graphics3DGraphic,c=!e||o.isVisible();a.visible=c&&!this._isConflicted(r.graphics3DGraphic.graphic.uid,a),a.visible&&this._addToBins(r,a),this._setGraphicVisibility(r,a.visible),R(a.aabr,a.visible)}return!1}_resetIterators(){this._inactiveIterator=null,this._activeIterator=null,this._visibleIterator=null,this._sortIterator=null}_ensureInactiveGraphicsIterator(){return this._inactiveIterator||(this._inactiveIterator=di(this._inactive)),this._inactiveIterator}_ensureActiveGraphicsIterator(){return this._activeIterator||(this._activeIterator=di(this._active)),this._activeIterator}_ensureVisibleGraphicsIterator(){return this._visibleIterator||(this._visibleIterator=di(this._visible)),this._visibleIterator}_ensureSortGraphicsIterator(){return this._sortIterator||(this._sortIterator=_i(this._visible,this._sortArray,this.visibilityGroup)),this._sortIterator}_collectGraphics3DGraphics(i,t,e,s,r,a,o){const c=i.graphics3DGraphic;if(c.destroyed)return;if(!c.isVisible(F.GRAPHIC,X.DECONFLICTION))return void(t.culled=!0);const n=this.getGraphicsLayers(c);B(t.aabr);let l=null;for(const u of n){if(!this.layerSupportsDeconfliction(u))continue;if(null==l){if(l=bi,this._getProjectionInfo(u,e,l),l.isOutsideScreen||this._isCulledBySlice(i,l.positionView)||null!=r&&mi(l,r,a))return void(t.culled=!0);const c=this.visibilityGroup===F.LABEL?i.getInfo(F.GRAPHIC):null;c&&i.graphicPositionView&&d(l.positionView,i.graphicPositionView)?(l.altitude=c.altitude,l.distanceToOccluder=c.distanceToOccluder):(h(Z,l.positionView,s),l.altitude=this.view.renderCoordsHelper.getAltitude(Z),l.distanceToOccluder=o?.(Z)??0,this._setCachedGraphicPosition(i,l.positionView))}const c=u.stageObject.geometries[0].material;this._expandBoundingRect(t.aabr,e,u,c,l)}null==l?t.culled=!0:(t.altitude=l.altitude,t.distance=l.distance,t.distanceToOccluder=l.distanceToOccluder,t.culled=!1)}_getProjectionInfo(i,t,e){const s=i.stageObject,r=s.geometries[0],a=r.material,o=E(s.boundingVolumeWorldSpace.bounds);h(Q,o,t.viewMatrix);const c=r.attributes,n=c.get(q.NORMAL).data,l=c.get(q.CENTEROFFSETANDDISTANCE).data;a.applyShaderOffsetsView(Q,n,s.transformation,l,t,e.scaleInfo,Q),g($,Q[0],Q[1],Q[2],1),m(ii,$,t.projectionMatrix),_(e.positionNDC,ii,1/ii[3]),a.applyShaderOffsetsNDC(e.positionNDC,l,t,e.positionNDC,ti),e.distanceWithoutPolygonOffset=t.depthNDCToWorld(ti[2]),e.distance=ti[2]===e.positionNDC[2]?e.distanceWithoutPolygonOffset:t.depthNDCToWorld(e.positionNDC[2]),g(ii,e.positionNDC[0],e.positionNDC[1],e.positionNDC[2],1),m($,ii,t.inverseProjectionMatrix),b($,$,1/$[3]),p(e.positionView,Q[0],Q[1],Q[2])}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&T(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,s,r,{positionNDC:a,scaleInfo:o}){const c=s.getScreenSize(vi);U(c,o.factor,c),c[0]*=t.pixelRatio,c[1]*=t.pixelRatio;const n=N(r.calculateRelativeScreenBounds(c,o.factorAlignment.scale*t.pixelRatio,oi),e(0,t.fullWidth,.5+.5*a[0]),e(0,t.fullHeight,.5+.5*a[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(D(n),S(n));n[0]-=i,n[1]-=i,n[2]+=i,n[3]+=i}V(i,n,i)}_isConflicted(i,t){let e=!0;for(let s=Math.floor(t.aabr[0]/this._accBinsSizeX);s<=Math.floor(t.aabr[2]/this._accBinsSizeX);s++)if(!(s<0||s>=this._accBinsNumX))for(let r=Math.floor(t.aabr[1]/this._accBinsSizeY);r<=Math.floor(t.aabr[3]/this._accBinsSizeY);r++){if(r<0||r>=this._accBinsNumY)continue;e=!1;const a=this._accBins[s][r];for(let e=0;e<a.length;e++){const s=a.data[e],r=s.getInfo(this.visibilityGroup);if(r&&r.visible&&s.graphics3DGraphic.graphic.uid!==i&&(this._accNumTests++,P(r.aabr,t.aabr)))return!0}}return e}_initBins(i,t){if(null==this._accBins){this._accBins=[];for(let i=0;i<this._accBinsNumX;i++){this._accBins.push([]);const i=this._accBins[this._accBins.length-1];for(let t=0;t<this._accBinsNumY;t++)i.push(new s)}}else for(let e=0;e<this._accBinsNumX;e++)for(let i=0;i<this._accBinsNumY;i++)this._accBins[e][i].clear();this._accBinsSizeX=i/this._accBinsNumX,this._accBinsSizeY=t/this._accBinsNumY,this._accNumTests=0}_addToBins(i,t){const e=Math.floor(t.aabr[0]/this._accBinsSizeX),s=Math.floor(t.aabr[2]/this._accBinsSizeX),r=Math.floor(t.aabr[1]/this._accBinsSizeY),a=Math.floor(t.aabr[3]/this._accBinsSizeY);for(let o=e;o<=s;o++)if(!(o<0||o>=this._accBinsNumX))for(let t=r;t<=a;t++)t<0||t>=this._accBinsNumY||this._accBins[o][t].push(i)}_setGraphicVisibility(i,t){const e=i.graphics3DGraphic;e.destroyed||(e.setVisibilityFlag(this.visibilityGroup,X.DECONFLICTION,t),this.visibilityGroup===F.LABEL&&this.view.labeler.setLabelGraphicVisibility(e,t))}};function pi(i,t){const e=i.graphics3DGraphic;e.destroyed||e.setVisibilityFlag(t,X.DECONFLICTION,!0)}function*di(i){if(Map.prototype.entries){const t=i.entries();for(let i=t.next();!i.done;i=t.next())yield i.value[1]}else yield*i.values()}function*_i(i,t,e){t.clear(),i.forEach(((i,s)=>{const r=t.pushNew();r.id=s,r.visible=i.graphics3DGraphic.getVisibilityFlag(e,X.DECONFLICTION);const a=i.getInfo(e);r.prio=i.graphics3DGraphic.deconflictionPriority,r.distance=a?.distance??Number.MAX_VALUE,r.behindTerrain=!!a&&0!==a.distanceToOccluder&&a.distance>a.distanceToOccluder})),yield;const s=t.iterableSort(((i,t)=>i.behindTerrain!==t.behindTerrain?+i.behindTerrain-+t.behindTerrain:i.prio!==t.prio?t.prio-i.prio:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?+t.visible-+i.visible:i.id-t.id));for(let r=s.next();!r.done;r=s.next())yield;t.forAll((t=>{const e=i.get(t.id);e&&(i.delete(t.id),i.set(t.id,e))})),t.clear()}i([r({constructOnly:!0})],ui.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],ui.prototype,"updating",null),i([r({readOnly:!0})],ui.prototype,"_updatingHandles",void 0),ui=i([a("esri.views.3d.layers.graphics.Deconflictor")],ui);class fi{constructor(){this.id=0,this.visible=!1,this.behindTerrain=!1,this.prio=0,this.distance=0}}const vi=n();class gi{constructor(){this.positionView=v(),this.positionNDC=v(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.scaleInfo=new K}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1||i[2]>=1}}function mi(i,t,e){return u(ri.direction,i.positionView),p(ri.origin,0,0,0),!!M(t,ri,ai)&&i.distanceWithoutPolygonOffset>e}const bi=new gi;export{ui as Deconflictor,ni as DeconflictorGraphic,hi as DeconflictorViewState,li as State};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{destroyMaybe as t,removeMaybe as i}from"../../../../core/maybe.js";import{initial as s}from"../../../../core/reactiveUtils.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{t as a}from"../../../../chunks/boundedPlane.js";import{Deconflictor as n,DeconflictorGraphic as o}from"./Deconflictor.js";import{VisibilityGroup as c,VisibilityFlag as h}from"./enums.js";import{LabelDeconflictor as l}from"./LabelDeconflictor.js";import{TaskPriority as p}from"../../../support/Scheduler.js";let d=class extends n{constructor(){super(...arguments),this._contexts=new Map,this.visibilityGroup=c.GRAPHIC,this._marginFactor=-.1,this.test={overrideMarginFactor:e=>{this._marginFactor=e,this.setDirty()}}}get labels(){return this._labels}get viewState(){return this._viewState}initialize(){this._updatingHandles.add((()=>this.view?.state?.camera),(()=>{this._updateViewState(),this.setDirty()})),this._updatingHandles.add((()=>
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{destroyMaybe as t,removeMaybe as i}from"../../../../core/maybe.js";import{initial as s}from"../../../../core/reactiveUtils.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{t as a}from"../../../../chunks/boundedPlane.js";import{Deconflictor as n,DeconflictorGraphic as o}from"./Deconflictor.js";import{VisibilityGroup as c,VisibilityFlag as h}from"./enums.js";import{LabelDeconflictor as l}from"./LabelDeconflictor.js";import{TaskPriority as p}from"../../../support/Scheduler.js";let d=class extends n{constructor(){super(...arguments),this._contexts=new Map,this.visibilityGroup=c.GRAPHIC,this._marginFactor=-.1,this.test={overrideMarginFactor:e=>{this._marginFactor=e,this.setDirty()}}}get labels(){return this._labels}get viewState(){return this._viewState}initialize(){this._updatingHandles.add((()=>this.view?.state?.camera),(()=>{this._updateViewState(),this.setDirty()})),this._updatingHandles.add((()=>this.view?.slicePlane),(()=>{this._updateSlicePlane(),this._slicePlaneChanged()}),s),this._frameTask=this.view.resourceController.scheduler.registerTask(p.GRAPHICS_DECONFLICTOR,this),this._labels=new l({view:this.view,parent:this})}destroy(){this._labels=t(this._labels),this._frameTask=i(this._frameTask)}get marginFactor(){return this._marginFactor}setDirty(){this._contexts.size>0&&(super.setDirty(),this._labels.setDirty())}runTask(e){super.runTask(e),this.running||this._labels.setDirty()}_updateViewState(){this.view?.state&&(this._viewState.camera.copyFrom(this.view.state.camera),this._updateSlicePlane())}_updateSlicePlane(){const e=this.view?this.view.slicePlane:null;null!=e&&a(e,this._viewState.camera.viewMatrix,this._viewState.slicePlane),this._viewState.slicePlaneEnabled=null!=e}_slicePlaneChanged(){for(const e of this._contexts.keys())if(e.symbolCreationContext.slicePlaneEnabled)return void this.setDirty()}addGraphicsOwner(e){const t=this._getGraphicsContext(e);return{addGraphic:i=>this._addGraphic(e,t,i),removeGraphic:e=>this._removeGraphic(t,e),labelingInfoChange:()=>this._labels.enabledChanged(e,t),featureReductionChange:()=>this.enabledChanged(e,t),slicePlaneEnabledChange:()=>this._slicePlaneEnabledChanged(e,t),clear:()=>t.forEach((e=>this._removeGraphic(t,e.graphics3DGraphic))),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){const t=this._contexts.get(e);t&&(t.forEach((e=>this._removeGraphic(t,e.graphics3DGraphic))),this._contexts.delete(e),this.setDirty())}_addGraphic(e,t,i){const s=i.graphic.uid,r=new o(i,e.symbolCreationContext.slicePlaneEnabled);t.set(s,r),m(e)?this.addToActiveGraphics(r):this.addToInactiveGraphics(r),e.labelsEnabled&&this._labels.addToActiveGraphics(r);const a=!this._graphicSupportsDeconfliction(i)||!m(e);i.setVisibilityFlag(c.GRAPHIC,h.DECONFLICTION,a)}_removeGraphic(e,t){const i=t.graphic.uid,s=e.get(i);s&&(this.removeFromActiveGraphics(s),this.removeFromInactiveGraphics(s),this._labels.removeFromActiveGraphics(s),e.delete(i),this.setDirty())}enabledChanged(e,t){const i=m(e);i||u(e),this.setGraphicsActive(t,i),this.setGraphicsInactive(t,!i)}_slicePlaneEnabledChanged(e,t){const i=e.symbolCreationContext.slicePlaneEnabled;t.forEach((e=>e.slicePlaneEnabled=i)),this.setDirty()}getGraphicsLayers(e){return e.layers}_graphicSupportsDeconfliction(e){if(e.isDraped)return!1;const t=e.layers;if(!t?.length)return!1;for(const i of t)if(this.layerSupportsDeconfliction(i))return!0;return!1}_getGraphicsContext(e){const t=this._contexts.get(e);if(t)return t;const i=new Map;return this._contexts.set(e,i),this.setDirty(),i}};function m(e){const t=e.layer;return!(!t?.featureReduction||"selection"!==t.featureReduction.type)}function u(e){const t=e.graphics3DGraphics;t&&t.forEach((e=>e.setVisibilityFlag(c.GRAPHIC,h.DECONFLICTION,!0)))}d=e([r("esri.views.3d.layers.graphics.GraphicsDeconflictor")],d);export{d as GraphicsDeconflictor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as r}from"../../../../chunks/tslib.es6.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{Deconflictor as e,State as o}from"./Deconflictor.js";import{VisibilityGroup as i}from"./enums.js";import{RenderState as a}from"../../../support/RenderState.js";import{Yield as c}from"../../../support/Yield.js";const n=2e3;let p=class extends e{constructor(r){super(r),this.visibilityGroup=i.LABEL,this.marginFactor=.05,this._lastDeconfliction=0}get viewState(){return this.parent.viewState}runTask(r){if(this.parent.running)return c;const t=performance.now();if(r.state!==a.IDLE&&t-this._lastDeconfliction<n)return c;super.runTask(r),this.state===o.Idle&&(this._lastDeconfliction=t)}enabledChanged(r,t){this.setGraphicsActive(t,r.labelsEnabled)}getGraphicsLayers(r){return r.labelLayers}};r([t({constructOnly:!0})],p.prototype,"parent",void 0),p=r([s("esri.views.3d.layers.graphics.LabelDeconflictor")],p);export{p as LabelDeconflictor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{debugFlags as e}from"../../support/debugFlags.js";let t,l
|
|
5
|
+
import{debugFlags as e}from"../../support/debugFlags.js";let t,n,l=!1,i=!1,o=!1,s=!1,r=null;function a(e){const t=i?e():null;if(!t?.bins)return;c();const l=n;let o=0;for(let n=0;n<t.numX;n++)for(let e=0;e<t.numY;e++){const i=t.bins[n][t.numY-1-e];o+=i.length;const s=n*t.sizeX,r=(n+1)*t.sizeX,a=e*t.sizeY,u=(e+1)*t.sizeY;l.fillText(i.length.toFixed(),s+5,a+15),d(s,r,a,u,"blue")}l.fillText("total totalShownLabels: "+o,70,40),l.fillText("total visible labels: "+t.numVisible,70,50),l.fillText("total numTests: "+t.numTests,70,30)}function u(a){o=e.DECONFLICTOR_SHOW_VISIBLE,s=e.DECONFLICTOR_SHOW_INVISIBLE,l=o||s,i=e.DECONFLICTOR_SHOW_GRID,r=null,l||i?(n&&t&&n.clearRect(0,0,t.width,t.height),r=()=>h(a)):t&&(t.parentElement.removeChild(t),t=null)}function c(){r&&(r(),r=null)}function h(e){null==t&&(t=document.createElement("canvas"),t.setAttribute("id","debugCanvas2d"),e.surface.parentElement.style.position="relative",e.surface.parentElement.appendChild(t),t.style.position="absolute",t.style.width="100%",t.style.height="100%",t.style.display="block",t.style.pointerEvents="none",n=t.getContext("2d"),n.font="12px Arial");const{width:l,height:i}=e.state.camera;t.width=l,t.height=i}function d(e,l,i,o,s){c();const r=t.height,a=n;a.beginPath(),a.lineWidth=1,a.strokeStyle=s,a.moveTo(e,r-i),a.lineTo(l,r-i),a.stroke(),a.lineTo(l,r-o),a.stroke(),a.lineTo(e,r-o),a.stroke(),a.lineTo(e,r-i),a.stroke(),a.closePath()}function f(e,t,n=!1){l&&(t&&o||!t&&s)&&d(e[0],e[2],e[1],e[3],n?t?"pink":"grey":t?"green":"red")}export{a as drawAccelerationStruct,f as drawPoly,u as prepare};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{n as e,a as t,f as i,b as s,c as n,H as r,y as o,h as a,G as c,s as u,j as l,l as h,k as d,d as m,g as _}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as f,i as v}from"../../../../chunks/vec42.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as S}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as M}from"../../../../geometry/projection/projectors.js";import{create as x,fromMatrix as C,intersectsSphere as I,createPoints as P}from"../../../../geometry/support/frustum.js";import{signedDistance as E,getNormal as D}from"../../../../geometry/support/plane.js";import{isPlateCarree as F}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as O,w as B}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as V}from"../../../../layers/graphics/dehydratedPoint.js";import{ViewingMode as j}from"../../../ViewingMode.js";import{evaluateElevationAlignmentAtPoint as A}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as L}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as y,extractExpressionInfo as w}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as G}from"./I3SNode.js";import{isValidMbs as N,intersectBoundingRectWithMbs as U,MbsIntersectResult as k}from"./I3SUtil.js";import{Obb as T,computeOffsetObb as q}from"../../support/orientedBoundingBox.js";const z=1e5;class H{get _frustumMbsCenter(){return this._frustumMbs}get _frustumMbsRadius(){return this._frustumMbs[3]}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=x(),this._frustumMbs=g(),this._useFrustumCulling=!1,this._poi=p(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new T,this._tmp1=p(),this._tmp2=p(),this._tmp3=p(),this._tmp0=p(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=R(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=V(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||F(u)),this._indexSREllipsoidRadius=b(this._indexSR).radius,this._indexSRSphericalPCPF=R(e),this._projectorIndexSRToIndexSRSphericalPCPF=M(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=L.fromElevationInfo(e),this._elevationContext.updateFeatureExpressionInfoContext(y(w(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,r){C(n.viewMatrix,n.projectionMatrix,this._frustum,X);{const r=n.eye,o=Z;e(o,n.viewForward);const a=Y;t(a,X[4],r);const c=.5*i(a,a)/i(o,a),u=this._frustumMbs;s(u,r,o,c);const l=1+c;u[3]=l}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);return void(e&&i.expandElevationRange(e))}const r=s[0],o=s[1],a=s[2],c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const u=t?null:this._elevationProvider.getRootElevationBounds?.();u&&i.expandElevationRange(u)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(N(t))return t;e.serviceMbsInIndexSR&&f(t,e.serviceMbsInIndexSR);const i=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(i)){let s=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":s=this._elevationContext.geometryZWithOffset(t[2],this._renderCoordsHelper)+i-t[2],n=r-i;break;case"on-the-ground":s=i-t[2],n=r-i}t[2]+=s+.5*n,t[3]+=.5*n}else this._elevationContext&&t[3]<z&&(this._tmpPoint.x=t[0],this._tmpPoint.y=t[1],this._tmpPoint.z=t[2],t[2]=A(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return S(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new T,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i[3];let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<z){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=A(e,this._elevationProvider,u,c)-a}const l=o>0,h=l?this._tmpObb:t;return s.transform(h,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),l&&q(h,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(ee,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),ee):null}ensureElevationAgnosticBoundingVolume(e){return-1===e.elevationAgnosticBoundingVolume[3]&&e.level>0&&(this._viewingMode===j.Global?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),o=t.elevationAgnosticBoundingVolume;let a,c=-1;if(s){const t=te;s.getCenter(t),e(t,t),a=t,s.getCorners(ie);for(const s of ie){e(s,s);const n=i(s,t);if(n<=0)return void(o[3]=-1);const r=Math.sqrt(1-n*n);c=Math.max(c,r)}}else{const i=t.serviceMbsInRenderSR;if(!N(i))return void(o[3]=-1);{const t=n(te,O(i)),s=i[3],u=r(t);if(u<s)return void(o[3]=-1);c=s/u,e(t,t),a=t}}v(o,a);const u=.001;o[3]=c+u}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(te);e[2]=0,v(t,e);let s=0;const n=se;i.getCorners(ie);for(const t of ie){t[2]=0;const e=o(n,t);s=Math.max(s,e)}t[3]=Math.sqrt(s)}else{const i=e.serviceMbsInRenderSR;if(N(i)){const e=n(te,O(i));e[2]=0,v(t,e),t[3]=i[3]}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):I(this._frustum,B(t))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(-1===e[3]||(this._viewingMode===j.Global?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n[3];if(-1===r||r>.9)return!0;const o=this._frustumPlanes,c=this._frustumMbsCenter,u=n,l=i(u,c),h=this._frustumMbsRadius,d=l-h,m=l+h;if(d<=0)return!0;const _=a(K,u,d),p=a(Q,u,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=D(v),r=e($,n),o=i(r,u);if(Math.abs(1-o)<.01)continue;const c=ne;a(c,u,o),t(c,c,r),e(c,c);const l=re;s(l,_,c,d*f);if(E(v,l)<=0)continue;s(l,p,c,m*f);if(E(v,l)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e[3];if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,o=r(n);if(o<=s)return!0;const u=e,l=i(u,n);{const e=a(J,u,l);if(c(e,n)<s)return!0}const h=l/o;if(l<=0){return-h<s}const d=Math.sqrt(1-h*h);if(d<t)return!0;const m=s/o;return d*Math.sqrt(1-m*m)-m*h<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(-1===e[3])return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=ie;if(t.getCorners(o),this._viewingMode===j.Global){const t=e,c=i(t,n),u=c-s,l=c+s;if(u<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=oe;if(a(o,n,u/r),E(e,o)<=0){s=!1;break}const c=oe;if(a(c,n,l/r),E(e,c)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=D(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=n(J,t);s[2]=0;const r=e[3];return c(s,e)<=r+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||U(this._clippingArea,e)!==k.OUTSIDE}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(u(O(i),this._camPos)),n=s-i[3];return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e)[3]}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=l(O(t),this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t[3],s=(Math.abs(t[0]*(t[0]-this._camPos[0])+t[1]*(t[1]-this._camPos[1])+t[2]*(t[2]-this._camPos[2]))/h(O(t))+i)/l(O(t),this._camPos);return Math.min(1,s)}hasLOD(e){return e.lodMetric!==G.None}_getDistanceGlobeMode(e,t){const s=h(O(t)),n=h(e)-s;a(this._tmp0,e,i(e,O(t))/d(e));const r=u(O(t),this._tmp0),o=t[3];if(r<=o*o)return Math.abs(n);{const r=a(this._tmp0,O(t),1/s),c=s,u=o*o/2/c,d=a(this._tmp1,r,c-u),p=e,f=m(this._tmp2,p,d),v=m(this._tmp2,f,a(this._tmp3,r,i(r,f))),g=_(this._tmp2,d,a(this._tmp2,v,o/h(v)));let b=l(p,g);if(n>=2e5){const e=m(this._tmp1,p,g);let t=i(e,r)/h(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):W(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(e.lodMetric===G.None)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case G.ScreenSpaceRelative:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i[3];return this._updateMinMaxDistance(r),e.maxError*t<=n}case G.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(e,e.serviceMbsInIndexSR[3]*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case G.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case G.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToPOI(e){const t=this.getServiceMbsInRenderSR(e);return l(O(t),this._poi)-t[3]}distCameraToPOI(){return l(this._camPos,this._poi)}}function W(e,t){const i=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],r=i*i+s*s,o=t[3];if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const Z=p(),X=P(),Y=p(),J=p(),K=p(),Q=p(),$=p(),ee=new T,te=p(),ie=[p(),p(),p(),p(),p(),p(),p(),p()],se=p(),ne=p(),re=p(),oe=p();export{H as default};
|
|
5
|
+
import{n as e,a as t,f as i,b as s,c as n,I as r,y as o,h as a,G as c,s as u,j as l,l as h,k as d,d as m,g as _}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as f,i as v}from"../../../../chunks/vec42.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as S}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as M}from"../../../../geometry/projection/projectors.js";import{create as x,fromMatrix as C,intersectsSphere as I,createPoints as P}from"../../../../geometry/support/frustum.js";import{signedDistance as E,getNormal as D}from"../../../../geometry/support/plane.js";import{isPlateCarree as F}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as O,w as B}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as V}from"../../../../layers/graphics/dehydratedPoint.js";import{ViewingMode as j}from"../../../ViewingMode.js";import{evaluateElevationAlignmentAtPoint as A}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as L}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as y,extractExpressionInfo as w}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as G}from"./I3SNode.js";import{isValidMbs as N,intersectBoundingRectWithMbs as U,MbsIntersectResult as k}from"./I3SUtil.js";import{Obb as T,computeOffsetObb as q}from"../../support/orientedBoundingBox.js";const z=1e5;class H{get _frustumMbsCenter(){return this._frustumMbs}get _frustumMbsRadius(){return this._frustumMbs[3]}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=x(),this._frustumMbs=g(),this._useFrustumCulling=!1,this._poi=p(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new T,this._tmp1=p(),this._tmp2=p(),this._tmp3=p(),this._tmp0=p(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=R(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=V(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||F(u)),this._indexSREllipsoidRadius=b(this._indexSR).radius,this._indexSRSphericalPCPF=R(e),this._projectorIndexSRToIndexSRSphericalPCPF=M(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=L.fromElevationInfo(e),this._elevationContext.updateFeatureExpressionInfoContext(y(w(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,r){C(n.viewMatrix,n.projectionMatrix,this._frustum,X);{const r=n.eye,o=Z;e(o,n.viewForward);const a=Y;t(a,X[4],r);const c=.5*i(a,a)/i(o,a),u=this._frustumMbs;s(u,r,o,c);const l=1+c;u[3]=l}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);return void(e&&i.expandElevationRange(e))}const r=s[0],o=s[1],a=s[2],c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const u=t?null:this._elevationProvider.getRootElevationBounds?.();u&&i.expandElevationRange(u)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(N(t))return t;e.serviceMbsInIndexSR&&f(t,e.serviceMbsInIndexSR);const i=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(i)){let s=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":s=this._elevationContext.geometryZWithOffset(t[2],this._renderCoordsHelper)+i-t[2],n=r-i;break;case"on-the-ground":s=i-t[2],n=r-i}t[2]+=s+.5*n,t[3]+=.5*n}else this._elevationContext&&t[3]<z&&(this._tmpPoint.x=t[0],this._tmpPoint.y=t[1],this._tmpPoint.z=t[2],t[2]=A(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return S(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new T,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i[3];let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<z){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=A(e,this._elevationProvider,u,c)-a}const l=o>0,h=l?this._tmpObb:t;return s.transform(h,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),l&&q(h,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(ee,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),ee):null}ensureElevationAgnosticBoundingVolume(e){return-1===e.elevationAgnosticBoundingVolume[3]&&e.level>0&&(this._viewingMode===j.Global?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),o=t.elevationAgnosticBoundingVolume;let a,c=-1;if(s){const t=te;s.getCenter(t),e(t,t),a=t,s.getCorners(ie);for(const s of ie){e(s,s);const n=i(s,t);if(n<=0)return void(o[3]=-1);const r=Math.sqrt(1-n*n);c=Math.max(c,r)}}else{const i=t.serviceMbsInRenderSR;if(!N(i))return void(o[3]=-1);{const t=n(te,O(i)),s=i[3],u=r(t);if(u<s)return void(o[3]=-1);c=s/u,e(t,t),a=t}}v(o,a);const u=.001;o[3]=c+u}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(te);e[2]=0,v(t,e);let s=0;const n=se;i.getCorners(ie);for(const t of ie){t[2]=0;const e=o(n,t);s=Math.max(s,e)}t[3]=Math.sqrt(s)}else{const i=e.serviceMbsInRenderSR;if(N(i)){const e=n(te,O(i));e[2]=0,v(t,e),t[3]=i[3]}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):I(this._frustum,B(t))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(-1===e[3]||(this._viewingMode===j.Global?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n[3];if(-1===r||r>.9)return!0;const o=this._frustumPlanes,c=this._frustumMbsCenter,u=n,l=i(u,c),h=this._frustumMbsRadius,d=l-h,m=l+h;if(d<=0)return!0;const _=a(K,u,d),p=a(Q,u,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=D(v),r=e($,n),o=i(r,u);if(Math.abs(1-o)<.01)continue;const c=ne;a(c,u,o),t(c,c,r),e(c,c);const l=re;s(l,_,c,d*f);if(E(v,l)<=0)continue;s(l,p,c,m*f);if(E(v,l)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e[3];if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,o=r(n);if(o<=s)return!0;const u=e,l=i(u,n);{const e=a(J,u,l);if(c(e,n)<s)return!0}const h=l/o;if(l<=0){return-h<s}const d=Math.sqrt(1-h*h);if(d<t)return!0;const m=s/o;return d*Math.sqrt(1-m*m)-m*h<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(-1===e[3])return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=ie;if(t.getCorners(o),this._viewingMode===j.Global){const t=e,c=i(t,n),u=c-s,l=c+s;if(u<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=oe;if(a(o,n,u/r),E(e,o)<=0){s=!1;break}const c=oe;if(a(c,n,l/r),E(e,c)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=D(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=n(J,t);s[2]=0;const r=e[3];return c(s,e)<=r+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||U(this._clippingArea,e)!==k.OUTSIDE}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(u(O(i),this._camPos)),n=s-i[3];return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e)[3]}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=l(O(t),this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t[3],s=(Math.abs(t[0]*(t[0]-this._camPos[0])+t[1]*(t[1]-this._camPos[1])+t[2]*(t[2]-this._camPos[2]))/h(O(t))+i)/l(O(t),this._camPos);return Math.min(1,s)}hasLOD(e){return e.lodMetric!==G.None}_getDistanceGlobeMode(e,t){const s=h(O(t)),n=h(e)-s;a(this._tmp0,e,i(e,O(t))/d(e));const r=u(O(t),this._tmp0),o=t[3];if(r<=o*o)return Math.abs(n);{const r=a(this._tmp0,O(t),1/s),c=s,u=o*o/2/c,d=a(this._tmp1,r,c-u),p=e,f=m(this._tmp2,p,d),v=m(this._tmp2,f,a(this._tmp3,r,i(r,f))),g=_(this._tmp2,d,a(this._tmp2,v,o/h(v)));let b=l(p,g);if(n>=2e5){const e=m(this._tmp1,p,g);let t=i(e,r)/h(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):W(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(e.lodMetric===G.None)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case G.ScreenSpaceRelative:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i[3];return this._updateMinMaxDistance(r),e.maxError*t<=n}case G.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(e,e.serviceMbsInIndexSR[3]*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case G.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case G.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToPOI(e){const t=this.getServiceMbsInRenderSR(e);return l(O(t),this._poi)-t[3]}distCameraToPOI(){return l(this._camPos,this._poi)}}function W(e,t){const i=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],r=i*i+s*s,o=t[3];if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const Z=p(),X=P(),Y=p(),J=p(),K=p(),Q=p(),$=p(),ee=new T,te=p(),ie=[p(),p(),p(),p(),p(),p(),p(),p()],se=p(),ne=p(),re=p(),oe=p();export{H as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{I as e,i as t,n as i,f as s,h as o,c as r,G as a}from"../../../../chunks/vec32.js";import{create as l,freeze as n,ZEROS as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as c}from"../../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as h}from"../../../../geometry/support/frustum.js";import{fromValues as m}from"../../../../geometry/support/ray.js";import{ViewingMode as p}from"../../../ViewingMode.js";import{FeatureTileVisibility3D as u,minTileLOD as _}from"./FeatureTileVisibility3D.js";import f from"../../webgl/RenderCamera.js";class v{constructor(e,t,i){this._renderCoordsHelper=e,this._tilingScheme=t,this._camera=new f,this._surfaceElevation=0,this._focusOnMap=[0,0],this._visibility=new u(e,i)}set opaqueGround(e){this._visibility.opaqueGround=e}setup(e,t,i){this._camera.copyFrom(e),this._surfaceElevation=i,this._focusOnMap[0]=t.x,this._focusOnMap[1]=t.y,this._visibility.setup(this._camera)}done(){this._visibility.done()}update(e){const{measures:t,extent:i,level:s}=e;t.visible=this._visibility.compute(e),t.distance=c(i,this._focusOnMap),t.mergeable=!0,t.lodLevel=_,t.splitPriority=Math.max(0,_-s),t.visible&&(this._isGlobal?this._updateSplitAndLodGlobal(e):this._updateSplitAndLodLocal(e))}_updateSplitAndLodGlobal(r){const a=r.level,l=this._renderCoordsHelper,{eye:n,fov:d}=this._camera,c=l.referenceEllipsoid.radius,h=e(n)-c;if(2*Math.atan(c/h)<d&&h>0)return void(r.measures.lodLevel=Math.max(a,_));const m=M,{extent:p}=r,{_surfaceElevation:u}=this;t(m[0],p[0],p[1],u),t(m[1],p[2],p[1],u),t(m[2],p[2],p[3],u),t(m[3],p[0],p[3],u);const f=t(y,.5*(p[0]+p[2]),.5*(p[1]+p[3]),u),v=this._tilingScheme.spatialReference;for(let e=0;e<4;++e)l.toRenderCoords(m[e],v,m[e]);l.toRenderCoords(f,v,f);const b=i(L.direction,f),x=s(n,b),S=o(g,b,x);this._updateSplitAndLod(r,m,f,S)}_updateSplitAndLodLocal(e){const i=M,{extent:s}=e,{_surfaceElevation:o}=this;t(i[0],s[0],s[1],o),t(i[1],s[2],s[1],o),t(i[2],s[2],s[3],o),t(i[3],s[0],s[3],o);const a=this._tilingScheme.spatialReference;for(let t=0;t<4;++t)this._renderCoordsHelper.toRenderCoords(i[t],a,i[t]);const l=t(y,.5*(i[0][0]+i[2][0]),.5*(i[0][1]+i[2][1]),.25*(i[0][2]+i[1][2]+i[2][2]+i[3][2])),n=t(b,l[0],l[1],0),{eye:d,far:c}=this._camera,h=t(g,n[0],n[1],d[2]);t(L.origin,n[0],n[1],d[2]-2*c),r(L.direction,x),this._updateSplitAndLod(e,i,l,h)}_updateSplitAndLod(e,t,i,o){const r=Math.max(a(t[0],t[2]),a(t[1],t[3]),a(t[0],i)+a(i,t[2]),a(t[1],i)+a(i,t[3])),{eye:l,near:n,fov:d,viewForward:c,width:m,height:p,pixelRatio:u,frustum:_}=this._camera,f=s(l,c),v=s(i,c)-f,M=a(i,l);let y=v,b=v,g=M,x=M;const L=(e,t)=>t<n?1:Math.sqrt(e*e-t*t)/t;let C=L(M,v);for(const h of t){const e=s(h,c)-f;y=Math.min(y,e),b=Math.max(b,e);const t=a(h,l);x=Math.max(x,t),g=Math.min(g,t);const i=L(t,e);C=Math.min(C,i)}if(b<n)return void(e.measures.lodLevel=0);const G=Math.cos(.5*d),R=a(l,o);C>G&&R>j*r&&(b=w*x,y=w*g);const A=.5*Math.sqrt(m*m+p*p)/u,E=2*Math.tan(.5*d),q=e=>Math.max(n,e)*S/A*E,H=e.level,O=r*2**H*Math.max(1,E),P=q(y),F=Math.ceil(Math.log2(Math.max(1,O/P)));if(e.measures.lodLevel=Math.max(F,e.measures.lodLevel),e.measures.splitPriority+=e.measures.lodLevel-H,H<F){const i=+h(_,t[0])+ +h(_,t[1])+ +h(_,t[2])+ +h(_,t[3]);e.measures.splitPriority+=i}const V=q(b)/P;V>2.5&&(e.measures.splitPriority+=V)}get _isGlobal(){return this._renderCoordsHelper.viewingMode===p.Global}}const M=[l(),l(),l(),l()],y=l(),b=l(),g=l(),x=n(0,0,1),L=m(d,x),S=312,j=.5,w=2;export{v as FeatureTileMeasurements3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{n as t,c as r,a as n,f as e,b as s,i as o,G as i,e as u,g as c,h as f,
|
|
5
|
+
import{n as t,c as r,a as n,f as e,b as s,i as o,G as i,e as u,g as c,h as f,I as a}from"../../../../chunks/vec32.js";import{create as h,freeze as l,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as d}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBuffer as _}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as g}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as b}from"../../../../geometry/support/frustum.js";import{fromValues as M,signedDistance as F}from"../../../../geometry/support/plane.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{Frustum as S}from"../../state/Frustum.js";class G{constructor(t,r){this._renderCoordsHelper=t,this.opaqueGround=r,this._cache=new Map,this._cameraForward=h(),this._cameraEye=h(),this._cameraFovY=55*Math.PI/180,this._frustumBoundingSphereCenter=h(),this._frustumBoundingSphereRadius=0,this._frustum=new S(t),this._renderSR=t.spatialReference;const n=d(this._renderSR);this._renderSREllipsoidRadius=p(n).radius}setup(n){this._aboveGround=n.aboveGround,this._frustum.update(n),t(this._cameraForward,n.viewForward),r(this._cameraEye,n.eye),this._cameraFovY=n.fovY,this._updateFrustumBoundingSphere()}done(){this._cache.clear()}compute(t){if(this._cache.has(t.id))return this._cache.get(t.id);const r=this._isVisibleInFrustum(t);return this._cache.set(t.id,r),r}_isVisibleInFrustum(t){return this._renderCoordsHelper.viewingMode===R.Local?this._isTileVisibleInFrustumLocal(t):this._isTileVisibleInFrustumGlobal(t)}_updateFrustumBoundingSphere(){const r=this._frustum,o=r.origin,i=W;t(i,r.direction);const u=r.points,c=z;n(c,u[4],o);const f=.5*e(c,c)/e(i,c),a=this._frustumBoundingSphereCenter;s(a,o,i,f);const h=1+f;this._frustumBoundingSphereRadius=h}_isTileVisibleInFrustumLocal(t){const r=t.spatialReference,u=t.extent,c=this._renderSR;if(C[0]=u[0],C[1]=u[1],C[2]=0,C[3]=u[2],C[4]=u[3],C[5]=0,!_(C,r,0,C,c,0))return!1;o(P[0],C[0],C[1],0),o(P[1],C[3],C[1],0),o(P[2],C[3],C[4],0),o(P[3],C[0],C[4],0),o(k,.5*(C[0]+C[3]),.5*(C[1]+C[4]),.5*(C[2]+C[5]));const f=Gt,a=.5*i(P[0],P[2]),h=this._frustum,l=this._frustumBoundingSphereRadius,m=this._frustumBoundingSphereCenter,p=J;n(p,m,k);const d=e(f,p),g=D;s(g,k,f,d);if(i(g,m)>a+l)return!1;const b=this._cameraForward,M=e(b,Gt),F=this._cameraFovY,R=this._cameraEye;if(Math.abs(M)<Math.abs(Math.cos(.5*F))){let t=!0;const r=o(jt,b[0],b[1],0),n=e(R,r);for(let s=0;s<4;++s){const o=P[s];if(e(o,r)-n>0){t=!1;break}}if(t)return!1}{const t=P[0],r=P[2];if(t[0]<=R[0]&&R[0]<=r[0]&&t[1]<=R[1]&&R[1]<=r[1])return!0}const S=E,G=this.opaqueGround&&this._aboveGround,j=this.opaqueGround&&!this._aboveGround,v=Math.min(j?Mt:1/0,d+l),B=Math.max(G?-430:-1/0,d-l);for(let n=0;n<4;++n)s(S[n],P[n],f,v),s(S[n+4],P[n],f,B);if(w(h.planes,S,8))return!1;if(T(h.planes,S,8))return!0;for(let n=0;n<4;++n){const t=S[n],r=S[n+4];if(vt(h.planes,t,r))return!0;const e=S[(n+1)%4];if(vt(h.planes,t,e))return!0;const s=S[4+(n+1)%4];if(vt(h.planes,r,s))return!0}if(It[0][3]=+P[0][0],It[1][3]=-P[2][0],It[2][3]=+P[0][1],It[3][3]=-P[2][1],It[4][3]=+B,It[5][3]=-v,T(It,h.points))return!0;if(T(It,h.points))return!0;for(let n=0;n<4;++n){const t=R,r=h.points[n+4];if(Bt(It,t,r))return!0;const e=h.points[4+(n+1)%4];if(Bt(It,r,e))return!0}return!1}_isTileVisibleInFrustumGlobal(r){if(r.level<V)return!0;const l=r.spatialReference,m=r.extent,p=this.opaqueGround&&this._aboveGround,d=this.opaqueGround&&!this._aboveGround,_=P,b=.5*(m[0]+m[2]);if(o(_[0],m[0],m[1],0),o(_[1],m[2],m[1],0),o(_[2],m[2],m[3],0),o(_[3],m[0],m[3],0),o(_[4],b,m[1],0),o(_[5],b,m[3],0),!g(_,l,0,_,this._renderSR,0,6))return!1;const M=_[0][2]>0,R=_[3][2]<0,S=M||R,G=this._renderSREllipsoidRadius;if(S){const t=Y;j(t,wt,_[0]);const r=H;if(j(r,wt,_[1]),M){const n=L,e=_[4],s=O;j(s,e,wt),j(n,s,e);const o=_[0];u(o,t,n),B(o,G);const i=_[1];u(i,r,n),B(i,G)}else if(R){const n=L,e=_[5],s=O;j(s,e,wt),j(n,e,s);const o=_[3];u(o,n,t),B(o,G);const i=_[2];u(i,n,r),B(i,G)}}const y=k,I=n(Z,_[3],_[0]);t(I,I);const T=c($,_[0],_[3]);f(T,T,.5);const q=-e(T,I),E=c(tt,_[0],_[1]);f(E,E,.5);const C=c(rt,_[2],_[3]);f(C,C,.5);const W=n(nt,C,E);t(W,W);const z=-(q+e(I,E))/e(I,W);s(y,E,W,z),B(y,G);const D=this._frustumBoundingSphereRadius,J=this._frustumBoundingSphereCenter,ut=this._frustum,dt=ut.planes,_t=A;t(_t,y);const gt=e(_[0],_t)/a(_[0]),Gt=ut.origin,jt=ut.points;let vt=!1;if(p){{vt=!0;const r=t(Ft,Gt);for(let s=0;s<4;++s){const o=jt[4+s],i=n(h(),o,Gt);t(i,i);const c=u(h(),r,i);t(c,c);const f=u(h(),i,c);t(f,f);if(e(Gt,f)>G){vt=!1;break}}}if(vt){if(e(Gt,_t)<G*gt-Mt)return!1}const r=t(Ft,ut.origin);if(e(r,_t)<0)return!1;{const r=t(Rt,ut.direction);if(e(r,_t)>St)return!1}}const Bt=Math.sqrt(1-gt*gt);if(Bt>.9)return!0;let yt=!1;const It=e(_t,J),Tt=a(J);if(Tt<=D&&!dt.some((t=>F(t,K)>0))){if(!p)return!0;yt=!0}const Vt=It/Tt;if(!yt&&It<=0){if(-It>D)return!1}const qt=D/Tt;if(Math.sqrt(1-Vt*Vt)*Math.sqrt(1-qt*qt)-qt*Vt>Bt)return!1;if(!vt){if(_.some((t=>ut.intersectsPoint(t))))return!0;if(ut.intersectsPoint(y))return!0}const xt=N;n(xt,J,K);const Et=e(xt,_t),Ct=U;f(Ct,_t,Et);const Pt=i(Ct,J),kt=l.isWGS84,Lt=r.lij,Yt=kt&&Lt[2]===2**Lt[0]-1,Ht=kt&&0===Lt[2],Ot=Ht?lt:Yt?at:ct,At=Ht?mt:Yt?ht:ft;if(!yt){const t=_,r=pt,n=et,e=st,s=K;for(const o of Ot){const i=t[o];if(v(n,t[(o+1)%4],i),v(e,s,i),j(r,e,n),x(r,jt,1))return!1}}let Ut=null;if(!p&&Et<1.01*D){const t=2.5*D;if(Pt>gt*t+D)return!1;const r=X,n=t/gt;for(let e=0;e<4;++e)f(r[e],_[e],n/G);o(r[4],0,0,0),Ut=r}else{const t=(d?G+Mt:Et+D)/gt,r=p?G-Mt:(Et-D)/gt,n=Q;for(let e=0;e<4;++e){const s=_[e];f(n[e],s,r/G),f(n[e+4],s,t/G)}Ut=n}if(w(dt,Ut,Ut.length))return!1;const Wt=ut.lines,zt=ot,Dt=it;for(const e of Wt){t(Dt,e.direction);for(const r of At){const e=Ut[r];if(t(zt,e),bt(Dt,zt,Ut,jt))return!1;const s=(r+1)%4;if(p){const r=Ut[s];if(n(zt,r,e),t(zt,zt),bt(Dt,zt,Ut,jt))return!1}if(d){const e=Ut[4+r],o=Ut[4+s];if(n(zt,o,e),t(zt,zt),bt(Dt,zt,Ut,jt))return!1}}}return!0}}function j(r,n,e){return u(r,n,e),t(r,r),r}function v(r,e,s){return n(r,e,s),t(r,r),r}function B(t,r){return f(t,t,r/a(t)),t}const y=[b.LEFT,b.RIGHT,b.BOTTOM,b.TOP,b.FAR];function I(t,r,n){for(let e=0;e<n;++e)if(F(t,r[e])<=0)return!1;return!0}function w(t,r,n){for(const e of y)if(I(t[e],r,n))return!0;return!1}function T(t,r,n=r.length){for(let e=0;e<n;++e){const n=r[e];let s=!0;for(const r of t){if(F(r,n)>0){s=!1;break}}if(s)return!0}return!1}const V=2,q=4;function x(t,r,n){for(const s of r)if(e(s,t)<n)return!1;return!0}const E=[h(),h(),h(),h(),h(),h(),h(),h()],C=[0,0,0,0,0,0],P=[h(),h(),h(),h(),h(),h()],k=h(),L=h(),Y=h(),H=h(),O=h(),A=h(),U=h(),W=h(),z=h(),D=h(),J=h(),K=l(0,0,0),N=h(),Q=[h(),h(),h(),h(),h(),h(),h(),h()],X=[h(),h(),h(),h(),h()],Z=h(),$=h(),tt=h(),rt=h(),nt=h(),et=h(),st=h(),ot=h(),it=h(),ut=h(),ct=[0,1,2,3],ft=[0,1,2,3],at=[0,1,3],ht=[0,1,3],lt=[1,2,3],mt=[1,2,3],pt=h();function dt(t,r,n){let s=1/0,o=-1/0;for(const i of n){const t=e(r,i);s=Math.min(s,t),o=Math.max(o,t)}t[0]=s,t[1]=o}function _t(t,r,n,s){let o=1/0,i=-1/0;for(const u of s){const s=e(n,u);if(o=Math.min(o,s),i=Math.max(i,s),o<=r&&i>=t)return!1}return!0}const gt=[0,0];function bt(t,r,n,e){if(0===n.length||0===e.length)return!0;const s=ut;j(s,t,r);const o=e[0]<n[0],i=o?n:e,u=gt;return dt(u,s,o?e:n),_t(u[0],u[1],s,i)}const Mt=430,Ft=h(),Rt=h(),St=Math.cos(.25*Math.PI),Gt=m(0,0,1),jt=h();function vt(t,r,n){const e={t0:0,t1:1};for(const s of y){if(!yt(t[s],r,n,e))return!1}return e.t0<e.t1}function Bt(t,r,n){const e={t0:0,t1:1};for(const s of t){if(!yt(s,r,n,e))return!1}return e.t0<e.t1}function yt(t,r,n,e){let{t0:s,t1:o}=e;const i=F(t,r),u=F(t,n);if(i>=0&&u>=0)return!1;if(i<0&&u>=0){const t=-i/(u-i);if(t<s)return!1;t<o&&(o=t)}else if(i>=0&&u<0){const t=i/(i-u);if(t>o)return!1;t>s&&(s=t)}return e.t0=s,e.t1=o,!0}const It=[M(-1,0,0,1),M(1,0,0,-1),M(0,-1,0,1),M(0,1,0,-1),M(0,0,-1,1),M(0,0,1,-1)],wt=l(0,0,1);export{G as FeatureTileVisibility3D,T as isAnyVertexInPolyhedron,w as isConvexHullOutsideOfFrustum,q as maxLODLevelDelta,V as minTileLOD};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{BufferViewVec2f16 as e,BufferViewVec2f as t,BufferViewVec2f64 as i,
|
|
5
|
+
import{BufferViewVec2f16 as e,BufferViewVec2f as t,BufferViewVec2f64 as i,BufferViewVec3f16 as s,BufferViewVec3f as r,BufferViewVec3f64 as n,BufferViewVec4f16 as h,BufferViewVec4f as d,BufferViewVec4f64 as u,BufferViewMat3f as f,BufferViewMat3f64 as o,BufferViewMat4f as l,BufferViewMat4f64 as p,BufferViewVec4u8 as c,BufferViewFloat16 as a,BufferViewFloat as _,BufferViewFloat64 as F,BufferViewUint8 as y,BufferViewUint16 as m,BufferViewInt8 as b,BufferViewVec2i8 as g,BufferViewVec2i16 as w,BufferViewVec2u8 as v,BufferViewVec4u16 as E,BufferViewUint32 as M,BufferViewVec3u8 as T,BufferViewVec2u16 as A,BufferViewVec3u16 as B,BufferViewVec2u32 as U,BufferViewVec3u32 as C,BufferViewVec4u32 as L,BufferViewVec3i8 as j,BufferViewVec4i8 as x,BufferViewInt16 as z,BufferViewVec3i16 as $,BufferViewVec4i16 as V,BufferViewInt32 as k,BufferViewVec2i32 as q,BufferViewVec3i32 as D,BufferViewVec4i32 as G}from"../../../../geometry/support/buffer/BufferView.js";import{elementTypeSize as H}from"../../../../geometry/support/buffer/types.js";import{assert as I}from"../../webgl-engine/lib/Util.js";class J{constructor(e,t){this.layout=e,this.buffer="number"==typeof t?new ArrayBuffer(t*e.stride):t;for(const i of e.fields.keys()){const t=e.fields.get(i);this[i]=new t.constructor(this.buffer,t.offset,this.stride)}}get stride(){return this.layout.stride}get count(){return this.buffer.byteLength/this.stride}get byteLength(){return this.buffer.byteLength}getField(e,t){const i=this[e];return i&&i.elementCount===t.ElementCount&&i.elementType===t.ElementType?i:null}slice(e,t){return new J(this.layout,this.buffer.slice(e*this.stride,t*this.stride))}copyFrom(e,t=0,i=0,s=e.count){const r=this.stride;if(r%4==0){const n=new Uint32Array(e.buffer,t*r,s*r/4);new Uint32Array(this.buffer,i*r,s*r/4).set(n)}else{const n=new Uint8Array(e.buffer,t*r,s*r);new Uint8Array(this.buffer,i*r,s*r).set(n)}return this}get cachedMemory(){return this.byteLength}dispose(){}}class K{constructor(e){this._stride=0,this._fields=new Map,e&&(this._stride=e.stride,e.fields.forEach((e=>this._fields.set(e[0],{...e[1],constructor:R(e[1].constructor)}))))}freeze(){return this}vec2f16(t,i){return this._appendField(t,e,i),this}vec2f(e,i){return this._appendField(e,t,i),this}vec2f64(e,t){return this._appendField(e,i,t),this}vec3f16(e,t){return this._appendField(e,s,t),this}vec3f(e,t){return this._appendField(e,r,t),this}vec3f64(e,t){return this._appendField(e,n,t),this}vec4f16(e,t){return this._appendField(e,h,t),this}vec4f(e,t){return this._appendField(e,d,t),this}vec4f64(e,t){return this._appendField(e,u,t),this}mat3f(e,t){return this._appendField(e,f,t),this}mat3f64(e,t){return this._appendField(e,o,t),this}mat4f(e,t){return this._appendField(e,l,t),this}mat4f64(e,t){return this._appendField(e,p,t),this}vec4u8(e,t){return this._appendField(e,c,t),this}f16(e,t){return this._appendField(e,a,t),this}f32(e,t){return this._appendField(e,_,t),this}f64(e,t){return this._appendField(e,F,t),this}u8(e,t){return this._appendField(e,y,t),this}u16(e,t){return this._appendField(e,m,t),this}i8(e,t){return this._appendField(e,b,t),this}vec2i8(e,t){return this._appendField(e,g,t),this}vec2i16(e,t){return this._appendField(e,w,t),this}vec2u8(e,t){return this._appendField(e,v,t),this}vec4u16(e,t){return this._appendField(e,E,t),this}u32(e,t){return this._appendField(e,M,t),this}_appendField(e,t,i){if(this._fields.has(e))return void I(!1,`${e} already added to vertex buffer layout`);const s=t.ElementCount*H(t.ElementType),r=this._stride;this._fields.set(e,{constructor:t,size:s,offset:r,optional:i}),this._alignFields()}_alignFields(){let e=0,t=1;this._fields.forEach((i=>{const s=H(i.constructor.ElementType);e=Math.floor((e+s-1)/s)*s,i.offset=e,e+=i.size,t=Math.max(t,s)})),e=Math.floor((e+t-1)/t)*t,this._stride=e}createBuffer(e){return new J(this,e)}createView(e){return new J(this,e)}clone(){const e=new K;return e._stride=this._stride,e._fields=new Map,this._fields.forEach(((t,i)=>e._fields.set(i,t))),e.BufferType=this.BufferType,e}get stride(){return this._stride}get fields(){return this._fields}}function N(){return new K}class O{constructor(e){this.fields=new Array,e.fields.forEach(((e,t)=>{const i={...e,constructor:Q(e.constructor)};this.fields.push([t,i])})),this.stride=e.stride}}const P=[_,t,r,d,f,l,F,i,n,u,o,p,y,v,T,c,m,A,B,E,M,U,C,L,b,g,j,x,z,w,$,V,k,q,D,G];function Q(e){return`${e.ElementType}_${e.ElementCount}`}function R(e){return S.get(e)}const S=new Map;P.forEach((e=>S.set(Q(e),e)));export{J as InterleavedBuffer,K as InterleavedLayout,O as PackedLayout,N as newLayout};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";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 s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{f as c,
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";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 s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{f as c,H as a,c as p,m as d,d as l,n as u}from"../../../../chunks/vec32.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import m from"../../../../geometry/Point.js";import{wrap as f}from"../../../../geometry/support/ray.js";import{PointOfInterest as g}from"./PointOfInterest.js";import{PaddingSide as y}from"../../webgl-engine/lib/rendererUtils.js";import{PropertiesPool as P}from"../../../support/PropertiesPool.js";import{TaskPriority as _}from"../../../support/Scheduler.js";import{Yield as j}from"../../../support/Yield.js";const L=Array;let O=class extends g{constructor(e){super(e),this._propertiesPool=new P({location:m,renderLocation:L},this),this._dirty=!0,this.renderLocation=this._propertiesPool.get("renderLocation")}initialize(){this.addHandles([o((()=>this.centerOnSurface.renderLocation),(()=>this.updateRenderLocation())),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 running(){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 s=Math.max(0,(Math.acos(c(S,i.viewForward))-.5*Math.PI)*(i.aboveGround?1:-1));if(Number.isNaN(s)){if(!e||!a(e,r)){const e=this._propertiesPool.get("renderLocation");p(e,r),this._set("renderLocation",e)}return j}const n=1-t(s/(.5*Math.PI),0,1),l=n*n*n;this._calculateScreenHorizontalEdgeOnSurface(C);const u=this._propertiesPool.get("renderLocation");return d(u,r,C,l),e&&a(e,u)||this._set("renderLocation",u),j}_calculateScreenHorizontalEdgeOnSurface(e){const t=this.state.contentCamera,r=t.getRenderCenter(i());if(r[1]=t.aboveGround?t.padding[y.BOTTOM]:t.fullHeight-t.padding[y.TOP],this.estimateSurfaceIntersectionAtRenderPoint(r,e))return e;const o=this.renderCoordsHelper.getAltitude(this.centerOnSurface.renderLocation);if(t.unprojectFromRenderScreen(r,R)){l(R,R,t.eye);const r=u(R,R);if(this.renderCoordsHelper.intersectInfiniteManifold(f(t.eye,r),o,e))return e}return this.renderCoordsHelper.setAltitude(e,o,t.eye)}updateRenderLocation(){this._dirty=!0}};e([s()],O.prototype,"_dirty",void 0),e([s({constructOnly:!0})],O.prototype,"scheduler",void 0),e([s({constructOnly:!0})],O.prototype,"centerOnSurface",void 0),e([s({constructOnly:!0})],O.prototype,"estimateSurfaceIntersectionAtRenderPoint",void 0),e([s()],O.prototype,"updating",null),e([s()],O.prototype,"location",null),e([s()],O.prototype,"renderLocation",void 0),e([s()],O.prototype,"worldUnitsPerContentPixel",null),O=e([n("esri.views.3d.support.pointsOfInterest.Focus")],O);const S=h(),R=h(),C=h();export{O 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/4.33/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}from"../../../core/maybe.js";import{j as i,G as s,H as o,d as a,n,f as l,a as d,I as g}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as x}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as v}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as E}from"./TerrainConst.js";import{enableTerrainInternalChecks as $,internalAssert as S,neighborEdgeIndices as C,oppositeEdge as D,neighborCornerIndices as b,v32s as T,lij2s as j}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as A}from"./TextureFader.js";import{TextureReference as V}from"./TextureReference.js";import w from"./TileOverlayData.js";import{fallsWithinLayerView as N}from"./tileUtils.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{vertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{PixelFormat as O}from"../../webgl/enums.js";class I{constructor(){this.geometry=new v,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureOpacity=1,this._textureRef=new R((()=>this._tile.surface.fadeDuration)),this.overlay=new w,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 p,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),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)S(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.extent;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=C[e];if(!t)return S(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(S(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)}S(!t.leaf);let a=i;return t.forAllSubtreeOnSide(D(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(S(!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(C[a],i),l=q(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==q(e,g),m=o[a]!==d;$&&n&&(S(e.level>=n.level),S(e.level-n.level<=E)),s[a]=n,(h||m)&&(o[a]=d,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);S(t(c)),S(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(b[t],i);r.cornerPeerNeighbors[t]=o;const a=q(e,s[t]),n=q(e,s[(t+1)%4]),l=q(e,o);W[t]=l,W[(t+1)%4]=n,W[(t+2)%4]=e,W[(t+3)%4]=a,S(W.some((t=>t?.loaded||t===e)));const d=W.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);W.forEach(((e,t)=>{e&&e?.level>d&&(W[t]=null)})),S(W.some((t=>t?.loaded||t===e)));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=W[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(te.some((r=>g[4*t+r]?.loaded||g[4*t+r]===e)))}$&&S(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)W[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&S(!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?O.RGBA:O.RGB;return null!=this._texture&&(r===y.FADING&&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(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new V(this._texture,y.FADING,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&z)}get samplerDataChanged(){return!!(this._modifiedFlags&J)}get clippingAreaChanged(){return!!(this._modifiedFlags&K)}get wireframeChanged(){return!!(this._modifiedFlags&Q)}get dirtyEdges(){return this._modifiedFlags>>Y&15}get dirtyCorners(){return this._modifiedFlags>>Z&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>ee&15}_markCornerDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<ee;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Z|15<<Y|15<<ee}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 t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new F(e,P,new Map([["geometry",f(t.layout)]]),new Map([["geometry",G.createVertex(e,i.STATIC_DRAW,t.buffer)]]),G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){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[x.ELEVATION],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[x.ELEVATION][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,x.ELEVATION);if(N(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(!$)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void S(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=C.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;S(0===this.dirtyCorners),S(0===this.dirtyEdges),S(0===this.dirtyEdgeResolutions),S(!this.numVerticesPerSideChanged),S(!this.samplerDataChanged),S(!this.clippingAreaChanged),S(!this.wireframeChanged);const y=b.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];S(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}C.forEach(((r,y)=>{if(f[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 S(!t)}S(x.loaded||x.level===e.level),S(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return S(!x.leaf),void S(0===v);const E=x.renderData;S(e.isEdgeNeighbor(x,r)),S(v>=0);const $=2**v;if(v<0)return void S(!1);const C=e.renderData,D=C.geometry,b=C.localOrigin,R=D.getEdgeCount(y),A=D.numVerticesPerSide-1,V=E.geometry;if(!V)return void S(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;S(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),S(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const F=(y+2)%4,P=V.getEdgeCount(F),G=R-1,O=P-1;S(G*$===O,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${F},res=${O} (expected:${G*$})`);const I=e.extent,W=r===_.NORTH||r===_.SOUTH,q=P-1,z=q>>v,J=R-1;if(z<1)return void S(1===J);S(z===J),S(t(z));const K=V.numVerticesPerSide-1;S(v>0||z===Math.max(K,A));const Q=e.getNeighborEdgeStartVertexIndex(y,x);S(0<=Q&&Q<$);const Y=Q*z;S(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,M,b,0),D.getEdgeVertexPosition(y,U,b,R-1);const te=i(M,U),re=Math.max(B,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=t/z,f=W?I[0]+i*(I[2]-I[0]):r===_.WEST?I[0]:I[2],p=W?r===_.SOUTH?I[1]:I[3]:I[1]+i*(I[3]-I[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(M,U),r=o(M)-c.radius,i=o(U)-c.radius,u=t<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${R}] and [${x.lij}].edge${F}[${ee}/${P}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(M),r=m(U);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=h();d(i,M,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${M} d=${o(i)} [${i}]`),d(i,U,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${U} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=V.getEdgeCount(P);S(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${F}][${ee}/${l}] ${T(M)} vs ${T(U)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,k,Z),V.getEdgeNormal(F,L,ee),n(H,k),n(X,L);const _=l(H,X),$=1-_<.01||!1||e===x;if(!$){const t=h();d(t,k,L);const r=()=>`Mismatch in tile edge normal ${j(e.lij)} (${Z}/${R-1}) edge ${y} vs neighbor ${j(x.lij)} (${ee}/${P-1}) nedge ${F} :${T(k)} vs ${T(L)} dot = ${_} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,Z),V.getEdgeNormal(F,r,ee),g(k,t)||console.warn("Missing update in tile normal: ",T(k)," => ",T(t)),g(L,r)||console.warn("Missing update in neighbor normal: ",T(L)," => ",T(r))}S($,r())}}Z+=1,ee+=1}}))}}const M=h(),U=h(),k=h(),L=h(),H=h(),X=h(),B=1,W=[null,null,null,null];function q(e,t){return t?.loaded||t===e?t:null}const z=1,J=2,K=4,Q=8,Y=4,Z=8,ee=12,te=[0,1,2,3];export{A as ActivationTime,I as PatchRenderData,q as neighborTileIfLoadedOrSelf,te 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}from"../../../core/maybe.js";import{j as i,G as s,I as o,d as a,n,f as l,a as d,H as g}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as x}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as v}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as E}from"./TerrainConst.js";import{enableTerrainInternalChecks as $,internalAssert as S,neighborEdgeIndices as C,oppositeEdge as D,neighborCornerIndices as b,v32s as T,lij2s as j}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as A}from"./TextureFader.js";import{TextureReference as V}from"./TextureReference.js";import w from"./TileOverlayData.js";import{fallsWithinLayerView as N}from"./tileUtils.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{vertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{PixelFormat as O}from"../../webgl/enums.js";class I{constructor(){this.geometry=new v,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureOpacity=1,this._textureRef=new R((()=>this._tile.surface.fadeDuration)),this.overlay=new w,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 p,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),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)S(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.extent;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=C[e];if(!t)return S(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(S(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)}S(!t.leaf);let a=i;return t.forAllSubtreeOnSide(D(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(S(!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(C[a],i),l=q(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==q(e,g),m=o[a]!==d;$&&n&&(S(e.level>=n.level),S(e.level-n.level<=E)),s[a]=n,(h||m)&&(o[a]=d,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);S(t(c)),S(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(b[t],i);r.cornerPeerNeighbors[t]=o;const a=q(e,s[t]),n=q(e,s[(t+1)%4]),l=q(e,o);W[t]=l,W[(t+1)%4]=n,W[(t+2)%4]=e,W[(t+3)%4]=a,S(W.some((t=>t?.loaded||t===e)));const d=W.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);W.forEach(((e,t)=>{e&&e?.level>d&&(W[t]=null)})),S(W.some((t=>t?.loaded||t===e)));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=W[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(te.some((r=>g[4*t+r]?.loaded||g[4*t+r]===e)))}$&&S(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)W[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&S(!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?O.RGBA:O.RGB;return null!=this._texture&&(r===y.FADING&&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(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new V(this._texture,y.FADING,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&z)}get samplerDataChanged(){return!!(this._modifiedFlags&J)}get clippingAreaChanged(){return!!(this._modifiedFlags&K)}get wireframeChanged(){return!!(this._modifiedFlags&Q)}get dirtyEdges(){return this._modifiedFlags>>Y&15}get dirtyCorners(){return this._modifiedFlags>>Z&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>ee&15}_markCornerDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<ee;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Z|15<<Y|15<<ee}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 t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new F(e,P,new Map([["geometry",f(t.layout)]]),new Map([["geometry",G.createVertex(e,i.STATIC_DRAW,t.buffer)]]),G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){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[x.ELEVATION],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[x.ELEVATION][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,x.ELEVATION);if(N(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(!$)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void S(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=C.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;S(0===this.dirtyCorners),S(0===this.dirtyEdges),S(0===this.dirtyEdgeResolutions),S(!this.numVerticesPerSideChanged),S(!this.samplerDataChanged),S(!this.clippingAreaChanged),S(!this.wireframeChanged);const y=b.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];S(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}C.forEach(((r,y)=>{if(f[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 S(!t)}S(x.loaded||x.level===e.level),S(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return S(!x.leaf),void S(0===v);const E=x.renderData;S(e.isEdgeNeighbor(x,r)),S(v>=0);const $=2**v;if(v<0)return void S(!1);const C=e.renderData,D=C.geometry,b=C.localOrigin,R=D.getEdgeCount(y),A=D.numVerticesPerSide-1,V=E.geometry;if(!V)return void S(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;S(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),S(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const F=(y+2)%4,P=V.getEdgeCount(F),G=R-1,O=P-1;S(G*$===O,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${F},res=${O} (expected:${G*$})`);const I=e.extent,W=r===_.NORTH||r===_.SOUTH,q=P-1,z=q>>v,J=R-1;if(z<1)return void S(1===J);S(z===J),S(t(z));const K=V.numVerticesPerSide-1;S(v>0||z===Math.max(K,A));const Q=e.getNeighborEdgeStartVertexIndex(y,x);S(0<=Q&&Q<$);const Y=Q*z;S(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,M,b,0),D.getEdgeVertexPosition(y,U,b,R-1);const te=i(M,U),re=Math.max(B,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=t/z,f=W?I[0]+i*(I[2]-I[0]):r===_.WEST?I[0]:I[2],p=W?r===_.SOUTH?I[1]:I[3]:I[1]+i*(I[3]-I[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(M,U),r=o(M)-c.radius,i=o(U)-c.radius,u=t<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${R}] and [${x.lij}].edge${F}[${ee}/${P}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(M),r=m(U);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=h();d(i,M,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${M} d=${o(i)} [${i}]`),d(i,U,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${U} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=V.getEdgeCount(P);S(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${F}][${ee}/${l}] ${T(M)} vs ${T(U)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,k,Z),V.getEdgeNormal(F,L,ee),n(H,k),n(X,L);const _=l(H,X),$=1-_<.01||!1||e===x;if(!$){const t=h();d(t,k,L);const r=()=>`Mismatch in tile edge normal ${j(e.lij)} (${Z}/${R-1}) edge ${y} vs neighbor ${j(x.lij)} (${ee}/${P-1}) nedge ${F} :${T(k)} vs ${T(L)} dot = ${_} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,Z),V.getEdgeNormal(F,r,ee),g(k,t)||console.warn("Missing update in tile normal: ",T(k)," => ",T(t)),g(L,r)||console.warn("Missing update in neighbor normal: ",T(L)," => ",T(r))}S($,r())}}Z+=1,ee+=1}}))}}const M=h(),U=h(),k=h(),L=h(),H=h(),X=h(),B=1,W=[null,null,null,null];function q(e,t){return t?.loaded||t===e?t:null}const z=1,J=2,K=4,Q=8,Y=4,Z=8,ee=12,te=[0,1,2,3];export{A as ActivationTime,I as PatchRenderData,q as neighborTileIfLoadedOrSelf,te as zeroToFour};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{lerp as t}from"../../../core/mathUtils.js";import{n as e,i,g as s,h as o,
|
|
5
|
+
import{lerp as t}from"../../../core/mathUtils.js";import{n as e,i,g as s,h as o,I as n,e as r,f as l,G as a,a as h}from"../../../chunks/vec32.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as d}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as c}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as p,numPlanes as f,PlaneIndex as m}from"../../../geometry/support/frustum.js";import{c as g,a as x}from"../../../chunks/sphere.js";import{PatchType as $}from"./interfaces.js";import{createSphericalGlobePatch as _,updateCornerSpherical as v,updateEdgesAndCornersSpherical as M,updateEdgeElevationsAndResolutionsSpherical as b}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as j,internalAssert as S,almostEquals as T}from"./terrainUtils.js";import{Tile as E,CenterPosition as I}from"./Tile.js";import{TileFrustumVisibility as B}from"./TileFrustumVisibility.js";import{compareTilesByLij as H}from"./tileUtils.js";class y extends E{constructor(t,e,i,s,o){super(),this._convexHull=new Array(24),this._boundingSphere=g(),this._baseUsedMemory=1816,this.init(t,e,i,s,o)}init(i,s,o,n,r){super.init(i,s,o,n,r);const l=this.ellipsoid.radius,a=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],c=this.extentInRadians[3],p=t(h,c,.5),f=t(a,u,.5),m=0===i?0:Math.min(Math.abs(h),Math.abs(c));this._edgeLen=(u-a)*Math.cos(m)*l,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=l-Math.sqrt(l*l-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])i(x(t[I.MIDDLE]),0,0,0),i(t[I.TOP],0,0,0),i(t[I.BOTTOM],0,0,0),t[I.MIDDLE][3]=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[I.MIDDLE],i=this.convexHull;let s=0;for(let t=0;t<8;++t)s=Math.max(s,D(x(e),i,3*t));t[I.MIDDLE][3]=Math.sqrt(s)}}_calculateFrustumVisibility(t){if(!p(t,this._boundingSphere))return B.OUTSIDE;if(this.lij[0]<10)return B.INTERSECTS;const e=this.convexHull,i=this.surface.view.state.camera.near;let s=!0;for(let o=0;o<f;o++){const n=o===m.NEAR,r=t[o],l=r[0],a=r[1],h=r[2],u=r[3]-(n?i:0);let d=!1;for(let t=0;t<8;++t){const i=3*t;if(l*e[i]+a*e[i+1]+h*e[i+2]+u<0){if(d=!0,!s)break}else s=!1}if(!d)return B.OUTSIDE}return s?B.INSIDE:B.INTERSECTS}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){_(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),j&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=x(t),r=this.elevationBoundsMin,l=this.elevationBoundsMax,a=this.ellipsoid.radius,h=l;if(0===this.level)i(e,0,0,0),t[3]=a+h;else{const i=this.extentInRadians,h=.5*(i[0]+i[2]),u=i[1],d=i[3];O(V,h,u,a),O(A,h,d,a),s(e,V,A);o(e,e,(a+.5*(r+l))/n(e));const c=this.convexHull;let p=0;const f=(t,e)=>{const i=t[0]-c[3*e],s=t[1]-c[3*e+1],o=t[2]-c[3*e+2];return Math.sqrt(i*i+s*s+o*o)};for(let t=0;t<8;++t){const i=f(e,t);p=Math.max(p,i)}const m=p;t[3]=m+2}}_updateConvexHull(){const t=this.extentInRadians,i=this.ellipsoid.radius;if(0===this.level)return;const a=this.elevationBoundsMin,d=this.elevationBoundsMax,c=this._getPatchType(),p=this.surface.isWebMercator,f=p&&c===$.HAS_NORTH_POLE,m=p&&c===$.HAS_SOUTH_POLE,g=m||f,x=Math.PI/2,_=t[0],v=t[2],M=m?-x:t[1],b=f?x:t[3],j=.5*(_+v),E=a,I=i+(g?Math.min(0,E-1):E),B=(t,e,i)=>O(t,e,i,I),H=u(),y=u(),L=u(),D=u();B(H,_,M),B(y,_,b),B(L,v,b),B(D,v,M);const R=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};R(H,0),R(y,1),R(L,2),R(D,3);const V=d,A=i+(g?Math.max(0,V+1):V),C=u(),F=u(),N=u();O(F,j,b,I),O(N,j,M,I),s(C,F,N),e(C,C);const U=u(),k=u(),w=(t,i)=>{h(k,t,i),e(k,k);const n=-l(t,U)/l(k,U);S(n>=0),o(k,k,n),s(t,t,k)};if(2**this.lij[0]>2*this.lij[1]){const t=N,i=u();r(i,P,t),e(i,i),r(U,t,i),e(U,U),S(T(l(U,t)/n(t),0)),w(H,y),w(D,L),R(H,0),R(D,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=F,i=u();r(i,P,t),e(i,i),r(U,i,t),e(U,U),w(y,H),w(L,D),R(y,1),R(L,2)}const q=(t,e)=>{const i=A/l(e,C);for(let s=0;s<3;++s)this._convexHull[3*t+s]=e[s]*i};q(4,H),q(5,y),q(6,L),q(7,D)}_getPatchType(){const t=this.lij[1],e=0===t,i=t===(1<<this.level)-1;return e?i?$.HAS_BOTH_POLES:$.HAS_NORTH_POLE:i?$.HAS_SOUTH_POLE:$.REGULAR}intersectsRay(t,e,i,s){const o=this._boundingSphere,n=o[3]+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],l=o[0]-t[0],a=o[1]-t[1],h=o[2]-t[2],u=(l*e[0]+a*e[1]+h*e[2])/r,d=e[0]*u-l,c=e[1]*u-a,p=e[2]*u-h;return d*d+c*c+p*p<n*n}get minimumVerticesPerSide(){return this.level<L.length?L[this.level]+1:2}updateCornerElevations(){v(this.renderData),this._updateBoundingVolumes()}updateEdgeElevations(){M(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){b(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!j)return;if(this.level<=2)return;const t=this._boundingSphere,i=t[3],o=x(t),d=u(),p=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=p+f,$=1,_=0,v=this._center[I.MIDDLE][3],M=this.convexHull,b=(t,e)=>{for(let i=0;i<3;++i)t[i]=M[3*e+i]};{const t=u(),i=u(),s=u(),o=u(),n=u(),a=(a,u,d,c)=>{b(i,a),b(s,u),b(o,d),h(i,i,s),h(o,o,s),r(t,i,o),e(t,t);const p=l(t,s);b(n,c);const f=l(t,n),m=Math.abs(f-p);S(T(m,0),`Non coplanar ${a},${u},${d},${c} diff = ${m}`)};a(0,1,2,3),a(4,5,6,7),a(0,1,4,5),a(1,2,5,6),a(2,3,6,7),a(3,0,7,4)}const E=c(24),B=(t,e,i)=>{const s=4*t;for(let o=0;o<3;++o)E[s+o]=e[o];E[s+3]=i},y=u(),L=u(),D=u(),P=u(),V=(t,i,s,o)=>{b(y,i),b(L,s),b(D,o),h(y,y,L),e(y,y),h(D,D,L),e(D,D),r(P,y,D),e(P,P);const n=l(P,L);B(t,P,n)};V(0,0,1,2),V(1,1,0,4),V(2,1,5,2),V(3,3,2,6),V(4,4,0,3),V(5,4,6,5);const A=(t,e,i,s)=>{const o=4*t;return E[o]*e+E[o+1]*i+E[o+2]*s-E[o+3]},C=(t,e,i,s)=>A(t,e,i,s)>=-1,F=(t,e)=>C(t,e[0],e[1],e[2]),N=2**this.lij[0]>2*this.lij[1],U=(t,e,s)=>Math.sqrt(R(t,e,s,o[0],o[1],o[2]))<i,k=t=>U(t[0],t[1],t[2]),w=(t,e)=>U(t[e],t[e+1],t[e+2]),q=this.extentInRadians,G=.5*(q[0]+q[2]),z=q[1],W=q[3],J=u(),K=u();O(J,G,W,g),O(K,G,z,g);const Q=N?"Upper":"Lower";let X=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,s=C(e,M[i],M[i+1],M[i+2]);X&&=s,S(s,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}S(F(e,K),`Tile[${this.lij}] (${Q}) bottom mid outside of plane ${e}`),S(F(e,J),`Tile[${this.lij}] (${Q}) top mid outside of plane ${e}`)}S(X,"Not all convex hull points are inside convex hull polyhedron"),S(k(K),`Tile[${this.lij}] (${Q}) bottom mid outside of bounding sphere`),S(k(J),`Tile[${this.lij}] (${Q}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=w(M,3*e);S(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const i=3*t;C(e,M[i],M[i+1],M[i+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:Y}=this,Z=Math.max(Y[2]-Y[0],Y[3]-Y[1]),tt=Math.round(Z*p),{renderData:et}=this;if(!et)return;const{geometry:it,geometryState:st,localOrigin:ot}=et,nt=it.vertexAttributes?.position;if(!nt)return;const rt=u(),lt=it.numVerticesPerSide-2,{indices:at,indexCount:ht,edgeVerticesStartIndex:ut,poleVerticesStartIndex:dt}=it;if(!at)return;const ct=new Set;for(let e=0;e<ht;++e){const t=at[e];if(ct.has(t))continue;ct.add(t);const r=t<dt,l=t>=ut;let h=!1,u=-1;if(l){let e=ut;for(let i=0;i<4;++i){const s=st.edgeResolutions[i];if(t===e||t===e+s-1){h=!0;break}if(e+=s,t<e){u=i;break}}}const c=l?st.edgePeerNeighbors[u]:null,g=l&&c&&H(this,c)>0;nt.getVec(t,d),s(rt,d,ot);const x=n(rt)-p;let M=0,b=!1;const j=f-x,S=x-m,T=j>$,E=S>$,I=T||E,B=()=>{const e=r?"internal":l&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(T?"(below)":E?"(above)":"")+(g?"(Neighbor)":"")},y=a(rt,o);if(y>=i+_){const t=y-i;I||(console.error(`${B()} is out of the bounding sphere by ${t.toFixed(0)} / ${i.toFixed(0)}[tol=${_}] h=${x.toFixed(0)} / [${f.toFixed(0)}..${m.toFixed(0)}] (${(t/i).toFixed(0)})`),b=!0)}for(let e=0;e<6;++e)if(!C(e,rt[0],rt[1],rt[2])){const s=A(e,rt[0],rt[1],rt[2]),o=t%lt,n=(t-o)/lt;0===e&&j||5===e&&S||(console.error(`${B()} (${o},${n})|${lt}] is out of the bounding trapezoid plane ${e} h=${Math.round(x)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(s)} radii = ${Math.round(i)}/${Math.round(v)}} : maxL = ${tt}`),++M)}if(b||M>0)break}}get convexHull(){return this._convexHull}}const L=[128,64,64,32,16,8,8,4];function D(t,e,i){return R(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function R(t,e,i,s,o,n){const r=s-t,l=o-e,a=n-i;return r*r+l*l+a*a}const O=(t,e,i,s)=>{const o=Math.cos(e),n=Math.sin(e),r=Math.cos(i),l=Math.sin(i);t[0]=s*r*o,t[1]=s*r*n,t[2]=s*l},P=[0,0,1],V=u(),A=u();export{y as SphericalPatch};
|
|
@@ -9,7 +9,7 @@ return vvSizeFallback.x;
|
|
|
9
9
|
return intrinsicWidth * clamp(vvSizeOffset + sizeFeatureAttribute * vvSizeFactor, vvSizeMinSize, vvSizeMaxSize).x;
|
|
10
10
|
}`)):(c.attributes.add(r.SIZE,"float"),s.code.add(v`float getSize(){
|
|
11
11
|
return intrinsicWidth * size;
|
|
12
|
-
}`)),l.vvOpacity?(c.attributes.add(r.OPACITYFEATUREATTRIBUTE,"float"),s.constants.add("vvOpacityNumber","int",8),s.uniforms.add(new a("vvOpacityValues",(i=>i.vvOpacity.values),o),new a("vvOpacityOpacities",(i=>i.vvOpacity.opacityValues),o),new e("vvOpacityFallback",(i=>i.vvOpacity.fallback))),s.code.add(v`float interpolateOpacity(
|
|
12
|
+
}`)),l.vvOpacity?(c.attributes.add(r.OPACITYFEATUREATTRIBUTE,"float"),s.constants.add("vvOpacityNumber","int",8),s.uniforms.add(new a("vvOpacityValues",(i=>i.vvOpacity.values),o),new a("vvOpacityOpacities",(i=>i.vvOpacity.opacityValues),o),new e("vvOpacityFallback",(i=>i.vvOpacity.fallback))),s.code.add(v`float interpolateOpacity(float value){
|
|
13
13
|
if (isnan(value)) {
|
|
14
14
|
return vvOpacityFallback;
|
|
15
15
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{equals as r}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as s}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{watch as o,syncAndInitial as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{equals as r}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as s}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{watch as o,syncAndInitial as a,sync as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{H as _,c as l}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as u}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as p}from"./BindParameters.js";import{DepthRange as d}from"./DepthRange.js";import{createQuadVAO as g}from"./glUtil3D.js";import{ShadowCastRenderer as f,shadowCastDisabledElevationThreshold as b,shadowCastDisableElevationMax as w,shadowCastDisableElevationMin as v}from"./ShadowCastRenderer.js";import{ShadowMap as y}from"./ShadowMap.js";import{S as R}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as A}from"../shaders/ShadowCastAccumulateTechnique.js";import{TaskPriority as j}from"../../../support/Scheduler.js";import{PixelFormat as S,PixelType as F,SizedPixelFormat as C,TextureWrapMode as x,FramebufferBit as P}from"../../../webgl/enums.js";import{FramebufferObject as D}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as E}from"../../../webgl/TextureDescriptor.js";import{vertexCount as q}from"../../../webgl/Util.js";let M=class extends t{constructor(e,t,r,s,i,h){super({}),this.fbos=e,this._techniques=t,this._stage=r,this._prepareForShadowMapPass=s,this._renderToShadowMap=i,this._requestRender=h,this._progress=0,this._sampleCount=0,this._passParameters=new u,this._cachedLightDirections=[],this._depthRange=d.zero,this._previewing=!1,this._cameraForcedForScreenshot=!1,this._shadowAccumulatorKey="shadowAccumulator",this._rctx=e.rctx,this._bindParameters=new p(new y(e,r.viewingMode)),this._bindParameters.shadowMap.enabled=!0,this._vao=g(this._rctx),this._accumulationRenderer=new f(t,this._rctx,this,h);const c=this._stage.view.resourceController.scheduler;this.addHandles([c.registerTask(j.SHADOW_ACCUMULATOR,this),o((()=>r.renderView),(e=>{this.removeHandles(L),null!=e&&this.addHandles(e.events.on("force-camera-for-screenshot",(()=>this._cameraForcedForScreenshot=!0)),L)}),a),o((()=>this._previewing),(()=>this._requestRenderIfEnabled()),n)],this._shadowAccumulatorKey),t.precompile(A)}normalizeCtorArgs(){return{}}dispose(){this._disable(),this.removeHandles(this._shadowAccumulatorKey),this._accumulationRenderer=i(this._accumulationRenderer),this._bindParameters.shadowMap.dispose(),this._fbo=i(this._fbo),this._vao=i(this._vao),this._cachedLightDirections.length=0,this._sampleCount=0}get computedSamples(){return this._progress}get shadowCastTexture(){return this._fbo?.colorTexture}get accumulating(){return this._active&&this._previewing||this._refining}get _refining(){return this._active&&!this._doneAccumulating&&!this._previewing}get _active(){return null!=this._fbo&&this._sampleCount>0}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==d.zero&&this._opacityFromElevation>b}get _doneAccumulating(){return this._progress>=this._sampleCount}get _lightDirections(){return this._cachedLightDirections}set _lightDirections(e){const t=this._cachedLightDirections;if(r(t,e,_))return;const s=Math.min(R,e.length);t.length=s,this._sampleCount=s;for(let r=0;r<s;++r)t[r]=l(t[r]??m(),e[r]);this._invalidate()}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get running(){return this._refining&&this.canAccumulate&&this._progress>0}runTask(e){for(this._prepareForShadowMapPass(this._bindParameters);!e.done&&!this._doneAccumulating;)this._accumulateShadow(),e.madeProgress();this._requestRender()}renderAccumulation(e,t,r,s){if(this._depthRange=t,this._updateCamera(r),this._bindParameters.contentCamera=s,this._bindParameters.depth=e,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!this.accumulating||!this.canAccumulate)return!1;(this._previewing||0===this._progress||this._cameraForcedForScreenshot)&&this._clear();let i=this._cameraForcedForScreenshot?this._sampleCount:Math.min(T,this._sampleCount);i-=this._progress;for(let o=0;o<i;++o)this._accumulateShadow(),this._requestRender();return this._cameraForcedForScreenshot=!1,i>0}precompile(){this._accumulationRenderer.precompile()}render(e){this._accumulationRenderer.render(e)}setOptions(e){if(void 0!==e.enabled){const t=null!=this._fbo;e.enabled!==t&&(e.enabled?this._enable():this._disable())}void 0!==e.previewing&&(this._previewing=e.previewing),void 0!==e.lightDirections&&(this._lightDirections=e.lightDirections),this._accumulationRenderer.setOptions(e)}readAccumulatedShadow(e,t){return!this._active||!this._fbo||this._progress<1||e<0||e>=this._fbo.width||t<0||t>=this._fbo.height?0:(this._fbo.readPixels(e,t,1,1,S.RGBA,F.UNSIGNED_BYTE,O),O[0]/this._progress)}_enable(){this._progress=0;const e=new E;e.pixelFormat=S.RED,e.internalFormat=C.R8,e.wrapMode=x.CLAMP_TO_EDGE,this._fbo=new D(this._rctx,e),this._requestRender()}_disable(){this._fbo=i(this._fbo),this._requestRender()}_invalidate(){this._progress=0,this._requestRenderIfEnabled()}_clear(){this._rctx.bindFramebuffer(this._fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clear(P.COLOR),this._progress=0}_accumulateShadow(){this._renderToShadowMap(this._bindParameters,this._lightDirections[this._progress++],this._depthRange);const e=this._techniques.get(A);this._rctx.bindFramebuffer(this._fbo),this._rctx.bindTechnique(e,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.primitiveType,0,q(this._vao,"geometry"))}_updateCamera(e){const t=this._fbo;if(null==t)return;const r=this._bindParameters.camera;e.equals(r)||r.copyFrom(e),t.resize(e.fullWidth,e.fullHeight),this._opacityFromElevation=1-s(v,w,e.relativeElevation)}_requestRenderIfEnabled(){this._fbo&&this._requestRender()}get test(){}};e([h()],M.prototype,"_progress",void 0),e([h()],M.prototype,"_sampleCount",void 0),e([h()],M.prototype,"_fbo",void 0),e([h()],M.prototype,"_depthRange",void 0),e([h()],M.prototype,"_previewing",void 0),e([h()],M.prototype,"_accumulationRenderer",void 0),e([h()],M.prototype,"_refining",null),e([h()],M.prototype,"_active",null),e([h()],M.prototype,"canAccumulate",null),e([h()],M.prototype,"_doneAccumulating",null),e([h()],M.prototype,"_opacityFromElevation",null),e([h()],M.prototype,"running",null),M=e([c("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],M);const T=6,L="renderView",O=new Uint8Array(4);export{M as ShadowAccumulator};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{f as n,a as t,e as r,n as o,b as c,G as s,
|
|
5
|
+
import{f as n,a as t,e as r,n as o,b as c,G as s,I as u}from"../../../../chunks/vec32.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";function i(t,r,o){const c=n(t,r)-o;return Math.abs(c)<=1e-5}function a(n,c,s){const u=e(),i=e();t(i,c,n);const a=e();return t(a,s,n),r(u,i,a),o(u,u),u}function f(r,s,u,f){const m=[s,u,f],h=a(s,u,f);if(!i(r,h,n(m[0],h)))return!1;for(let i=0;i<3;++i){const r=m[i],s=m[(i+1)%3],u=m[(i+2)%3],a=e();t(a,s,r),o(a,a);const f=e();t(f,u,r);const h=n(f,a),l=e();c(l,r,a,h);const M=e();t(M,u,l),o(M,M);const x=n(r,M);if(!(n(M,l)-x>=-1e-4))return!1}return!0}function m(n){const c=e();t(c,n[1],n[0]),o(c,c);const s=e();t(s,n[2],n[0]),o(s,s);const u=e();return r(u,c,s),o(u,u),u}function h(r,s,u){const i=e();t(i,u,s),o(i,i);const a=e();t(a,r,s);const f=n(a,i),m=e();return c(m,s,i,f),m}function l(n,t,r){const o=h(n,t,r);return s(o,n)}function M(r,i,a){const f=e();t(f,a,i);const m=u(f);o(f,f);const h=e();t(h,r,i);const l=n(h,f);if(l<0)return s(i,r);if(l>m)return s(a,r);const M=e();c(M,i,f,l);return s(M,r)}function x(t,r,o){return n(t,r)-o}function y(c,s,u){const i=e(),a=e();t(a,s,c);const f=e();t(f,u,c),r(i,a,f),o(i,i);return{normal:i,d:n(i,c)}}function A(n,t,r,o){const{normal:s,d:u}=y(t,r,o),i=x(n,s,u),a=e();return c(a,n,s,-i),f(a,t,r,o)?i:Math.min(M(n,t,r),M(n,r,o),M(n,o,t))}function b(r,o,s){const u=e();t(u,o,r);const i=m(s),a=n(i,s[0]),h=n(i,r)-a,l=n(i,o)-a;if(h*l>0)return 1/0;const M=e();return c(M,r,u,(0-h)/(l-h)),f(M,s[0],s[1],s[2])?0:A(M,s[0],s[1],s[2])}function p(n,t){const r=n.length;if(0===r)return 0;if(t<n[0])return-1;if(t>=n[r-1])return r;let o=0,c=r-1;for(;c-o>1;){const r=Math.floor(.5*(c+o));t>=n[r]?o=r:c=r}return o}function w(n,t,r,o,c,s,u){const e=s-u,i=t-n,a=new Float64Array(4*i);for(let f=0;f<i;++f){const t=3*(f+n),s=c*r[t+0],i=o[s+0],m=o[s+1],h=e/(o[s+2]-u),l=i*h,M=m*h,x=c*r[t+1],y=o[x+0],A=o[x+1],b=e/(o[x+2]-u),p=y*b,w=A*b,U=c*r[t+2],d=o[U+0],g=o[U+1],j=e/(o[U+2]-u),v=d*j,F=g*j,k=4*f;a[k+0]=Math.min(l,p,v),a[k+1]=Math.min(M,w,F),a[k+2]=Math.max(l,p,v),a[k+3]=Math.max(M,w,F)}return a}function U(n,t,r,o,c){const s=t-n,u=new Float64Array(4*s);for(let e=0;e<s;++e){const t=3*(e+n),s=c*r[t+0],i=o[s+0],a=o[s+1],f=c*r[t+1],m=o[f+0],h=o[f+1],l=c*r[t+2],M=o[l+0],x=o[l+1],y=4*e;u[y+0]=Math.min(i,m,M),u[y+1]=Math.min(a,h,x),u[y+2]=Math.max(i,m,M),u[y+3]=Math.max(a,h,x)}return u}function d(n,t){return new(g(n))(t)}function g(n){return n<128?Uint8Array:n<32768?Uint16Array:n<1<<31?Uint32Array:Array}function j(n,t){n[2]+=t}function v(n,t,r,o){const[c,s,u]=o??n,e=u-r,i=t/Math.sqrt(c*c+s*s+e*e);n[0]+=c*i,n[1]+=s*i,n[2]+=e*i}export{p as binarySearchSortedArray,m as calculateNormalFromVertices,d as createUintArray,l as distancePointLine,x as distancePointPlane,M as distancePointSegment,A as distancePointTriangle,v as elevationAlignVertexGlobal,j as elevationAlignVertexLocal,w as generateTriangleAabbsGlobal,U as generateTriangleAabbsLocal,g as getConstructorForValueCount,h as getNearestPointOnLine,b as getRayTriangleIntersectionDistance,a as getTriangleNormal,y as getTrianglePlane,i as isPointInPlane,f as isPointInTriangle};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{Float16Array as e}from"@petamoriken/float16";import{i as t,
|
|
5
|
+
import{Float16Array as e}from"@petamoriken/float16";import{i as t,H as r,t as i}from"../../../../chunks/vec32.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newLayout as s}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as n,isColor as o,isDepth as h,isColorHighlightOrDepth as c,isColorOrColorEmission as p}from"../core/shaderLibrary/ShaderOutput.js";import m from"../lib/GLMaterial.js";import{Material as l,RenderOccludedFlag as u}from"../lib/Material.js";import{RenderSlot as T}from"../lib/RenderSlot.js";import{VertexAttribute as f}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as d}from"./VisualVariablePassParameters.js";import{vertexAttributeLocations as A,LineMarkerTechnique as v}from"../shaders/LineMarkerTechnique.js";import{LineMarkerTechniqueConfiguration as _,LineMarkerSpace as E,LineMarkerAnchor as g}from"../shaders/LineMarkerTechniqueConfiguration.js";import{CapType as O}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as S}from"../../../../webscene/support/AlphaCutoff.js";class R extends l{constructor(e){super(e,L),this._configuration=new _,this.vertexAttributeLocations=A,this.produces=new Map([[T.OPAQUE_MATERIAL,e=>e===n.Highlight||o(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>h(e)],[T.OCCLUDER_MATERIAL,e=>c(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.TRANSPARENT_OCCLUDER_MATERIAL,e=>c(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[T.TRANSPARENT_MATERIAL,e=>o(e)&&this.parameters.writeDepth],[T.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>o(e)&&!this.parameters.writeDepth],[T.DRAPED_MATERIAL,e=>p(e)||e===n.Highlight]]),this._layout=this.createLayout()}getConfiguration(e,t){return this._configuration.output=e,this._configuration.space=t.slot===T.DRAPED_MATERIAL?E.Draped:this.parameters.worldSpace?E.World:E.Screen,this._configuration.hideOnShortSegments=this.parameters.hideOnShortSegments,this._configuration.hasCap=this.parameters.cap!==O.BUTT,this._configuration.anchor=this.parameters.anchor,this._configuration.hasTip=this.parameters.hasTip,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=t.hasOccludees,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.occluder=this.parameters.renderOccluded===u.OccludeAndTransparentStencil,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest&&p(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}get visible(){return this.parameters.color[3]>=S}intersect(){}createLayout(){const e=s().vec3f(f.POSITION).vec3f(f.PREVPOSITION).vec2f16(f.UV0);return this.parameters.worldSpace&&e.vec3f16(f.NORMAL),this.parameters.vvSize?e.f16(f.SIZEFEATUREATTRIBUTE):e.f16(f.SIZE),this.parameters.vvColor?e.f16(f.COLORFEATUREATTRIBUTE):e.vec4u8(f.COLOR),this.parameters.vvOpacity&&e.f16(f.OPACITYFEATUREATTRIBUTE),e}createBufferWriter(){return new P(this._layout,this.parameters)}createGLMaterial(e){return new I(e)}}class I extends m{constructor(){super(...arguments),this._markerPrimitive=null}dispose(){super.dispose(),this._markerTextures.release(this._markerPrimitive),this._markerPrimitive=null}beginSlot(e){const t=this._material.parameters.markerPrimitive;return t!==this._markerPrimitive&&(this._material.setParameters({markerTexture:this._markerTextures.swap(t,this._markerPrimitive)}),this._markerPrimitive=t),this.getTechnique(v,e)}}class L extends d{constructor(){super(...arguments),this.width=0,this.color=[1,1,1,1],this.markerPrimitive="arrow",this.placement="end",this.cap=O.BUTT,this.anchor=g.Center,this.hasTip=!1,this.worldSpace=!1,this.hideOnShortSegments=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.markerTexture=null}}class P{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t}elementCount(){return"begin-end"===this._parameters.placement?12:6}write(a,s,n,o,h,c){const p=n.get(f.POSITION).data,m=p.length/3;let l=[1,0,0];const u=n.get(f.NORMAL);this._parameters.worldSpace&&null!=u&&(l=u.data);let T=1,d=0;this._parameters.vvSize?d=n.get(f.SIZEFEATUREATTRIBUTE).data[0]:n.has(f.SIZE)&&(T=n.get(f.SIZE).data[0]);let A=[1,1,1,1],v=0;this._parameters.vvColor?v=n.get(f.COLORFEATUREATTRIBUTE).data[0]:n.has(f.COLOR)&&(A=n.get(f.COLOR).data);let _=0;this._parameters.vvOpacity&&(_=n.get(f.OPACITYFEATUREATTRIBUTE).data[0]);const E=new Float32Array(h.buffer),g=new e(h.buffer),O=new Uint8Array(h.buffer);let S=c*(this.vertexBufferLayout.stride/4);const R=(e,t,r,i)=>{E[S++]=e[0],E[S++]=e[1],E[S++]=e[2],E[S++]=t[0],E[S++]=t[1],E[S++]=t[2];let a=2*S;if(g[a++]=r[0],g[a++]=r[1],this._parameters.worldSpace&&(g[a++]=l[0],g[a++]=l[1],g[a++]=l[2]),this._parameters.vvSize?g[a++]=d:g[a++]=T,this._parameters.vvColor)g[a++]=v;else{const e=Math.min(4*i,A.length-4),t=2*a;a+=2,O[t]=A[e],O[t+1]=A[e+1],O[t+2]=A[e+2],O[t+3]=A[e+3]}this._parameters.vvOpacity&&(g[a++]=_),S=Math.ceil(.5*a)};let I;!function(e){e[e.ASCENDING=1]="ASCENDING",e[e.DESCENDING=-1]="DESCENDING"}(I||(I={}));const L=(e,s)=>{const n=t(C,p[3*e],p[3*e+1],p[3*e+2]),o=b;let h=e+s;do{t(o,p[3*h],p[3*h+1],p[3*h+2]),h+=s}while(r(n,o)&&h>=0&&h<m);a&&(i(n,n,a),i(o,o,a)),R(n,o,[-1,-1],e),R(n,o,[1,-1],e),R(n,o,[1,1],e),R(n,o,[-1,-1],e),R(n,o,[1,1],e),R(n,o,[-1,1],e)},P=this._parameters.placement;return"begin"!==P&&"begin-end"!==P||L(0,I.ASCENDING),"end"!==P&&"begin-end"!==P||L(m-1,I.DESCENDING),null}}const C=a(),b=a();export{R as LineMarkerMaterial,L as Parameters};
|