@arcgis/core 4.26.0-next.20230121 → 4.26.0-next.20230123
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/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/006af87392d7136fb8c7.js +1 -0
- package/assets/esri/core/workers/chunks/5c8fd7842bdfe912eef2.js +1 -0
- package/assets/esri/core/workers/chunks/{d75f1c8f8dcabdf32021.js → c49510a48cdf64a0d9fc.js} +1 -1
- package/assets/esri/themes/base/widgets/_Tooltip.scss +29 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip.json +1 -1
- package/assets/esri/views/interactive/tooltip/t9n/Tooltip_en.json +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/voxel/VoxelIsosurface.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectStates.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/support/SceneLayerViewRequiredFields.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/webgl-engine/lib/AppleAmdDriverHelper.js +5 -0
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/interactive/sketch/SketchTooltipVisibleElements.js +1 -1
- package/views/interactive/tooltip/DrawTooltipInfos.js +1 -1
- package/views/interactive/tooltip/SketchTooltipInfo.js +1 -1
- package/views/interactive/tooltip/content/TooltipContent.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawCircle.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPoint.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentDrawRectangle.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentExtentRotate.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentExtentScale.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentReshapeEdgeOffset.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTransformAbsolute.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTransformRotate.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTransformScale.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateGraphic.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateGraphicXY.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateGraphicZ.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateVertexXY.js +1 -1
- package/views/interactive/tooltip/content/TooltipContentTranslateVertexZ.js +1 -1
- package/views/interactive/tooltip/css.js +1 -1
- package/views/interactive/tooltip/support/TooltipContentWithHelpMessage.js +5 -0
- package/views/webgl/WebGLDriverTest.js +1 -1
- package/views/webgl/testAppleAmdDrawArrays.js +5 -0
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/assets/esri/core/workers/chunks/1363e647f3b0bca07e09.js +0 -1
- package/assets/esri/core/workers/chunks/fa52b97a76b2b4170c5d.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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Graphic.js";import{XXH as i}from"../../../../arcade/functions/hash.js";import{neverReached as s}from"../../../../core/compilerUtils.js";import{HandleOwner as r}from"../../../../core/HandleOwner.js";import{destroyMaybe as n,isSome as a,isNone as o,unwrap as l}from"../../../../core/maybe.js";import{logOnError as p}from"../../../../core/promiseUtils.js";import{watch as u,initial as d,when as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as y}from"../../../../core/accessorSupport/diffUtils.js";import{canProject as g,project as b}from"../../../../geometry/support/webMercatorUtils.js";import{matchRandomRotationExpression as f}from"../../../../renderers/support/randomRotationExpression.js";import{getRenderingInfo as E,getRenderingInfoAsync as C}from"../../../../renderers/support/renderingInfoUtils.js";import x from"../../../../rest/support/Query.js";import{DrapeSourceType as v}from"../interfaces.js";import{SUSPEND_RESUME_EXTENT_OPTIMISM as w}from"./constants.js";import{Graphics3DCore as V}from"./Graphics3DCore.js";import j from"./Graphics3DElevationAlignment.js";import S from"./Graphics3DFrustumVisibility.js";import{Graphics3DObjectStates as R}from"./Graphics3DObjectStates.js";import O from"./Graphics3DScaleVisibility.js";import{enlargeExtent as I}from"./graphicUtils.js";import{attributeLookup as G}from"../support/attributeUtils.js";import{FeatureVisibilityFilter as _}from"../support/FeatureVisibilityFilter.js";import{Object3DState as A}from"../../webgl-engine/lib/basicInterfaces.js";import{UpdatePolicy as P}from"../../webgl-engine/lib/UpdatePolicy.js";let U=class extends r{constructor(e){super(e),this.type="graphics-3d",this._randomRotationRenderers=null,this.elevationFeatureExpressionEnabled=!1,this.scaleVisibilityEnabled=!1,this.filterVisibilityEnabled=!1,this.frustumVisibilityEnabled=!1,this.elevationAlignmentEnabled=!1,this.timeExtentEnabled=!1,this.setUidToIdOnAdd=!0,this.dataExtent=null,this.drapeSourceType=v.Features,this.preferredUpdatePolicy=P.ASYNC,this._suspendResumeExtent=null}initialize(){const e=this.owner,t=(this.filterVisibilityEnabled||this.timeExtentEnabled)&&"multipatch"!==e.layer.geometryType,i=new V({owner:this,layer:this.layer,preferredUpdatePolicy:this.preferredUpdatePolicy,elevationFeatureExpressionEnabled:this.elevationFeatureExpressionEnabled,graphicSymbolSupported:!1,hasZ:e.hasZ,hasM:e.hasM,setUidToIdOnAdd:this.setUidToIdOnAdd,componentFactories:{deconflictor:t=>e.view.deconflictor.addGraphicsOwner(t),labeler:(t,i)=>e.view.labeler.addGraphicsOwner(t,i),elevationAlignment:this.elevationAlignmentEnabled?(t,i)=>new j({graphicsCoreOwner:this,graphicsCore:t,queryGraphicUIDsInExtent:i,elevationProvider:e.view.elevationProvider}):null,scaleVisibility:this.scaleVisibilityEnabled?(t,i)=>new O({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:i,graphicsCore:t,basemapTerrain:e.view.basemapTerrain}):null,filterVisibility:t?t=>new _({context:{layerView:e,...t}}):null,objectStates:e=>new R(e)}});this._set("graphicsCore",i),this.frustumVisibilityEnabled&&this._set("frustumVisibility",new S({graphicsCoreOwner:this})),this.elevationAlignment&&this.updatingHandles.add((()=>this.layer.elevationInfo),((e,t)=>{y(e,t)&&this.updatingHandles.addPromise(this.graphicsCore.elevationInfoChange())})),this.updatingHandles.add((()=>this.layer.labelsVisible),(()=>this.graphicsCore.updateVisibilityInfo())),this.updatingHandles.add((()=>this.layer.labelingInfo),((e,t)=>{y(e,t)&&this.graphicsCore.updateLabelingInfo()})),this.updatingHandles.add((()=>this.preferredUpdatePolicy),(e=>this.graphicsCore.preferredUpdatePolicy=e)),this._set("initializePromise",this._initializeAsync()),this.updatingHandles.addPromise(this.initializePromise)}async _initializeAsync(){await p(this.graphicsCore.initializePromise);const e=this.owner;this.updatingHandles.add((()=>this.renderer),(e=>this.updatingHandles.addPromise(this.graphicsCore.rendererChange(e)))),this.updatingHandles.add((()=>e.fullOpacity),(()=>this.graphicsCore.opacityChange())),this._setupSuspendResumeExtent(),this.updateClippingExtent&&(this.updatingHandles.add((()=>e.view.clippingArea),(()=>this._updateClippingExtent())),this._updateClippingExtent()),this.graphicsCore.startCreateGraphics(),this.graphicsCore.labelsEnabled&&await p(this.graphicsCore.updateLabelingInfo())}destroy(){this.handles.removeAll(),this.updatingHandles.removeAll(),this._set("frustumVisibility",n(this.frustumVisibility)),this._set("graphicsCore",n(this.graphicsCore)),this._set("owner",null)}get layer(){return this.owner.layer}get renderer(){const{renderer:e,objectIdField:t}=this.layer;if(!e||!t||"heatmap"===e.type||!e.visualVariables)return e;const i=e.visualVariables.findIndex((e=>"rotation"===e.type&&null!=e.valueExpression&&f(e.valueExpression)===t&&(null==e.axis||"heading"===e.axis)&&"geographic"===e.rotationType));if(i<0)return e;const s=e.clone();return s.visualVariables.splice(i,1),this._randomRotationRenderers||(this._randomRotationRenderers=new WeakMap),this._randomRotationRenderers.set(s,t),s}get scaleVisibility(){return this.graphicsCore?.scaleVisibility}get filterVisibility(){return this.graphicsCore?.filterVisibility}get elevationAlignment(){return this.graphicsCore?.elevationAlignment}get objectStates(){return this.graphicsCore?.objectStates}get suspendResumeExtentMode(){return"suspendResumeExtentMode"in this.owner?this.owner.suspendResumeExtentMode:"computed"}get scaleVisibilitySuspended(){return a(this.scaleVisibility)&&this.scaleVisibility.suspended}get suspended(){return this.owner.suspended}get legendEnabled(){return o(this.frustumVisibility)||!this.frustumVisibility.suspended}get suspendInfo(){const e={};return this.scaleVisibilitySuspended&&(e.outsideScaleRange=!0),a(this.frustumVisibility)&&this.frustumVisibility.suspended&&(e.outsideOfView=!0),e}get updating(){return!!(this.graphicsCore?.updating||a(this.frustumVisibility)&&this.frustumVisibility.updating||this.updatingHandles?.updating)}get updatingRemaining(){return this.graphicsCore?.updatingRemaining??0}get featureStore(){return this.graphicsCore?.featureStore}get view(){return this.owner.view}get loadedGraphics(){return this.owner.loadedGraphics}get fullOpacity(){return this.owner?.fullOpacity}get filter(){return"filter"in this.owner?this.owner.filter:null}get slicePlaneEnabled(){return this.owner.slicePlaneEnabled}get updatePolicy(){return this.owner.updatePolicy}get featureSpatialReference(){return"featureSpatialReference"in this.owner?this.owner.featureSpatialReference:this.owner.view.spatialReference}get graphics3DGraphics(){return this.graphicsCore?.graphics3DGraphics}get graphics3DGraphicsByObjectID(){return this.graphicsCore?.graphics3DGraphicsByObjectID}get symbolUpdateType(){return this.graphicsCore?.symbolUpdateType}get displayFeatureLimit(){const e=this.view.resourceController.memoryController.memoryFactor,t=this.graphicsCore?.displayFeatureLimit;if(1===e)return t;const i=Math.ceil(t.maximumNumberOfFeatures*e),s=Math.ceil(t.maximumTotalNumberOfFeatures*e),r=Math.ceil(t.minimumTotalNumberOfFeatures*e);return{...t,maximumNumberOfFeatures:i,maximumTotalNumberOfFeatures:s,minimumTotalNumberOfFeatures:r}}get usedMemory(){return this.graphicsCore?.usedMemory??0}get loadedFeatures(){return this.graphicsCore?.numberOfGraphics??0}get usedMemoryPerFeature(){return this.graphicsCore?.usedMemoryPerGraphic??0}get unprocessedMemoryEstimate(){return this.graphicsCore?.unprocessedMemoryEstimate??0}get performanceInfo(){return{core:this.graphicsCore.performanceInfo,elevationUpdating:this.elevationAlignment.updating,visibilityFrustum:o(this.frustumVisibility)||!this.frustumVisibility.suspended,visibilityScale:!this.scaleVisibilitySuspended}}maskOccludee(e){const{set:t,handle:i}=this.objectStates.acquireSet(A.MaskOccludee,null);return this.objectStates.setUid(t,e.uid),i}highlight(e,i){if(e instanceof x){const{set:t,handle:s}=this.objectStates.acquireSet(A.Highlight,i);return this.owner.queryObjectIds(e).then((e=>this.objectStates.setObjectIds(t,e))),s}if("number"==typeof e||"string"==typeof e)return this.highlight([e],i);if(e instanceof t)return this.highlight([e],i);if("toArray"in e&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof t){const t=e;if(null==G(this.layer.fieldsIndex,t[0].attributes,i)){const e=t.map((e=>e.uid)),{set:i,handle:s}=this.objectStates.acquireSet(A.Highlight,null);return this.objectStates.setUids(i,e),s}e=t.map((e=>G(this.layer.fieldsIndex,e.attributes,i)))}if("number"==typeof e[0]||"string"==typeof e[0]){const t=e,{set:s,handle:r}=this.objectStates.acquireSet(A.Highlight,i);return this.objectStates.setObjectIds(s,t),r}}return T}whenGraphicBounds(e,t){return this.graphicsCore?.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.graphicsCore?.computeAttachmentOrigin(e,t)}notifyGraphicGeometryChanged(e){this.graphicsCore.notifyGraphicGeometryChanged(e)}notifyGraphicVisibilityChanged(e){this.graphicsCore.notifyGraphicVisibilityChanged(e)}getRenderingInfo(e,t,s){const r=E(e,{renderer:t,arcade:s});if(a(r)&&r.color){const e=r.color;e[0]=e[0]/255,e[1]=e[1]/255,e[2]=e[2]/255}if(a(r)&&a(t)&&this._randomRotationRenderers?.has(t)){const s=this._randomRotationRenderers.get(t),n=e.attributes[s],a=new i(0);a.updateFloatArray([n]),a.updateUint8Array([173]),r.heading=8.381e-8*a.digest()}return r}getRenderingInfoAsync(e,t,i,s){return C(e,{renderer:t,arcade:i,...s})}getSymbolLayerSize(e,t){return this.graphicsCore?.getSymbolLayerSize(e,t)}setObjectIdVisibility(e,t){this.graphicsCore?.setObjectIdVisibility(e,t)}refreshFilter(){a(this.filterVisibility)&&this.filterVisibility.reapply()}getGraphics3DGraphicByObjectId(e){return this.graphicsCore?.getGraphics3DGraphicByObjectId(e)}_updateClippingExtent(){const e=this.owner.view.clippingArea;this.graphicsCore.setClippingExtent(e,this.owner.view.spatialReference)&&(this.updateClippingExtent(e)||this.graphicsCore.recreateAllGraphics())}_setupSuspendResumeExtent(){(this.frustumVisibility||this.scaleVisibility)&&this.handles.add(u((()=>this.suspendResumeExtentMode),(()=>{switch(this.handles.remove(M),this.suspendResumeExtentMode){case"computed":this.handles.add([u((()=>this.graphicsCore.computedExtent),(e=>this._updateSuspendResumeExtent(e)),d),u((()=>this.graphicsCore.extentPadding),(()=>this._updateSuspendResumeExtent(this.graphicsCore.computedExtent)))],M);break;case"data":this.handles.add([h((()=>this.dataExtent),(e=>this._updateSuspendResumeExtent(e)),d),u((()=>this.graphicsCore.extentPadding),(()=>this._updateSuspendResumeExtent(l(this.dataExtent))))],M);break;default:s(this.suspendResumeExtentMode)}}),d))}_updateSuspendResumeExtent(e){e?this._suspendResumeExtentChanged(this._extentToSuspendResumeRect(e,this._suspendResumeExtent)):this._suspendResumeExtentChanged(null)}_extentToSuspendResumeRect(e,t){const i=this.owner.view.spatialReference;if(!e.spatialReference.equals(i)){if(!g(e,i))return;e=b(e,i)}return I(e,t,w,this.graphicsCore.extentPadding)}_suspendResumeExtentChanged(e){a(this.frustumVisibility)&&this.frustumVisibility.setExtent(e),a(this.scaleVisibility)&&this.scaleVisibility.setExtent(e)}};e([c()],U.prototype,"type",void 0),e([c({constructOnly:!0})],U.prototype,"owner",void 0),e([c()],U.prototype,"layer",null),e([c()],U.prototype,"renderer",null),e([c({constructOnly:!0})],U.prototype,"updateClippingExtent",void 0),e([c({constructOnly:!0})],U.prototype,"elevationFeatureExpressionEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"graphicsCore",void 0),e([c({constructOnly:!0})],U.prototype,"scaleVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"filterVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"frustumVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"elevationAlignmentEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"timeExtentEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"setUidToIdOnAdd",void 0),e([c()],U.prototype,"scaleVisibility",null),e([c()],U.prototype,"filterVisibility",null),e([c()],U.prototype,"elevationAlignment",null),e([c({constructOnly:!0})],U.prototype,"frustumVisibility",void 0),e([c()],U.prototype,"objectStates",null),e([c()],U.prototype,"initializePromise",void 0),e([c()],U.prototype,"suspendResumeExtentMode",null),e([c()],U.prototype,"dataExtent",void 0),e([c()],U.prototype,"scaleVisibilitySuspended",null),e([c()],U.prototype,"suspended",null),e([c()],U.prototype,"legendEnabled",null),e([c()],U.prototype,"suspendInfo",null),e([c()],U.prototype,"updating",null),e([c()],U.prototype,"updatingRemaining",null),e([c()],U.prototype,"featureStore",null),e([c()],U.prototype,"view",null),e([c()],U.prototype,"loadedGraphics",null),e([c()],U.prototype,"fullOpacity",null),e([c()],U.prototype,"filter",null),e([c()],U.prototype,"slicePlaneEnabled",null),e([c()],U.prototype,"drapeSourceType",void 0),e([c()],U.prototype,"updatePolicy",null),e([c()],U.prototype,"preferredUpdatePolicy",void 0),e([c()],U.prototype,"displayFeatureLimit",null),U=e([m("esri.views.3d.layers.graphics.Graphics3DFeatureProcessor")],U);const F=U,M="suspendResumeExtentMode",T={remove(){},pause(){},resume(){}};export{F as default};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Graphic.js";import{XXH as i}from"../../../../arcade/functions/hash.js";import{neverReached as s}from"../../../../core/compilerUtils.js";import{HandleOwner as r}from"../../../../core/HandleOwner.js";import{destroyMaybe as n,isSome as a,isNone as o,unwrap as l}from"../../../../core/maybe.js";import{logOnError as p}from"../../../../core/promiseUtils.js";import{watch as u,initial as d,when as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as y}from"../../../../core/accessorSupport/diffUtils.js";import{canProject as g,project as b}from"../../../../geometry/support/webMercatorUtils.js";import{matchRandomRotationExpression as f}from"../../../../renderers/support/randomRotationExpression.js";import{getRenderingInfo as E,getRenderingInfoAsync as C}from"../../../../renderers/support/renderingInfoUtils.js";import x from"../../../../rest/support/Query.js";import{DrapeSourceType as v}from"../interfaces.js";import{SUSPEND_RESUME_EXTENT_OPTIMISM as w}from"./constants.js";import{Graphics3DCore as V}from"./Graphics3DCore.js";import j from"./Graphics3DElevationAlignment.js";import S from"./Graphics3DFrustumVisibility.js";import{Graphics3DObjectStates as R}from"./Graphics3DObjectStates.js";import O from"./Graphics3DScaleVisibility.js";import{enlargeExtent as I}from"./graphicUtils.js";import{attributeLookup as G}from"../support/attributeUtils.js";import{FeatureVisibilityFilter as _}from"../support/FeatureVisibilityFilter.js";import{Object3DState as A}from"../../webgl-engine/lib/basicInterfaces.js";import{UpdatePolicy as P}from"../../webgl-engine/lib/UpdatePolicy.js";let U=class extends r{constructor(e){super(e),this.type="graphics-3d",this._randomRotationRenderers=null,this.elevationFeatureExpressionEnabled=!1,this.scaleVisibilityEnabled=!1,this.filterVisibilityEnabled=!1,this.frustumVisibilityEnabled=!1,this.elevationAlignmentEnabled=!1,this.timeExtentEnabled=!1,this.setUidToIdOnAdd=!0,this.dataExtent=null,this.drapeSourceType=v.Features,this.preferredUpdatePolicy=P.ASYNC,this._suspendResumeExtent=null}initialize(){const e=this.owner,t=(this.filterVisibilityEnabled||this.timeExtentEnabled)&&"multipatch"!==e.layer.geometryType,i=new V({owner:this,layer:this.layer,preferredUpdatePolicy:this.preferredUpdatePolicy,elevationFeatureExpressionEnabled:this.elevationFeatureExpressionEnabled,graphicSymbolSupported:!1,hasZ:e.hasZ,hasM:e.hasM,setUidToIdOnAdd:this.setUidToIdOnAdd,componentFactories:{deconflictor:t=>e.view.deconflictor.addGraphicsOwner(t),labeler:(t,i)=>e.view.labeler.addGraphicsOwner(t,i),elevationAlignment:this.elevationAlignmentEnabled?(t,i)=>new j({graphicsCoreOwner:this,graphicsCore:t,queryGraphicUIDsInExtent:i,elevationProvider:e.view.elevationProvider}):null,scaleVisibility:this.scaleVisibilityEnabled?(t,i)=>new O({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:i,graphicsCore:t,basemapTerrain:e.view.basemapTerrain}):null,filterVisibility:t?t=>new _({context:{layerView:e,...t}}):null,objectStates:e=>new R(e)}});this._set("graphicsCore",i),this.frustumVisibilityEnabled&&this._set("frustumVisibility",new S({graphicsCoreOwner:this})),this.elevationAlignment&&this.updatingHandles.add((()=>this.layer.elevationInfo),((e,t)=>{y(e,t)&&this.updatingHandles.addPromise(this.graphicsCore.elevationInfoChange())})),this.updatingHandles.add((()=>this.layer.labelsVisible),(()=>this.graphicsCore.updateVisibilityInfo())),this.updatingHandles.add((()=>this.layer.labelingInfo),((e,t)=>{y(e,t)&&this.graphicsCore.updateLabelingInfo()})),this.updatingHandles.add((()=>this.preferredUpdatePolicy),(e=>this.graphicsCore.preferredUpdatePolicy=e)),this._set("initializePromise",this._initializeAsync()),this.updatingHandles.addPromise(this.initializePromise)}async _initializeAsync(){await p(this.graphicsCore.initializePromise);const e=this.owner;this.updatingHandles.add((()=>this.renderer),(e=>this.updatingHandles.addPromise(this.graphicsCore.rendererChange(e)))),this.updatingHandles.add((()=>e.fullOpacity),(()=>this.graphicsCore.opacityChange())),this._setupSuspendResumeExtent(),this.updateClippingExtent&&(this.updatingHandles.add((()=>e.view.clippingArea),(()=>this._updateClippingExtent())),this._updateClippingExtent()),this.graphicsCore.startCreateGraphics(),this.graphicsCore.labelsEnabled&&await p(this.graphicsCore.updateLabelingInfo())}destroy(){this.handles.removeAll(),this.updatingHandles.removeAll(),this._set("frustumVisibility",n(this.frustumVisibility)),this._set("graphicsCore",n(this.graphicsCore)),this._set("owner",null)}get layer(){return this.owner.layer}get renderer(){const{renderer:e,objectIdField:t}=this.layer;if(!e||!t||"heatmap"===e.type||!e.visualVariables)return e;const i=e.visualVariables.findIndex((e=>"rotation"===e.type&&null!=e.valueExpression&&f(e.valueExpression)===t&&(null==e.axis||"heading"===e.axis)&&"geographic"===e.rotationType));if(i<0)return e;const s=e.clone();return s.visualVariables.splice(i,1),this._randomRotationRenderers||(this._randomRotationRenderers=new WeakMap),this._randomRotationRenderers.set(s,t),s}get scaleVisibility(){return this.graphicsCore?.scaleVisibility}get filterVisibility(){return this.graphicsCore?.filterVisibility}get elevationAlignment(){return this.graphicsCore?.elevationAlignment}get objectStates(){return this.graphicsCore?.objectStates}get suspendResumeExtentMode(){return"suspendResumeExtentMode"in this.owner?this.owner.suspendResumeExtentMode:"computed"}get scaleVisibilitySuspended(){return a(this.scaleVisibility)&&this.scaleVisibility.suspended}get suspended(){return this.owner.suspended}get legendEnabled(){return o(this.frustumVisibility)||!this.frustumVisibility.suspended}get suspendInfo(){const e={};return this.scaleVisibilitySuspended&&(e.outsideScaleRange=!0),a(this.frustumVisibility)&&this.frustumVisibility.suspended&&(e.outsideOfView=!0),e}get updating(){return!!(this.graphicsCore?.updating||a(this.frustumVisibility)&&this.frustumVisibility.updating||this.updatingHandles?.updating)}get updatingRemaining(){return this.graphicsCore?.updatingRemaining??0}get featureStore(){return this.graphicsCore?.featureStore}get view(){return this.owner.view}get loadedGraphics(){return this.owner.loadedGraphics}get fullOpacity(){return this.owner?.fullOpacity}get filter(){return"filter"in this.owner?this.owner.filter:null}get slicePlaneEnabled(){return this.owner.slicePlaneEnabled}get updatePolicy(){return this.owner.updatePolicy}get featureSpatialReference(){return"featureSpatialReference"in this.owner?this.owner.featureSpatialReference:this.owner.view.spatialReference}get graphics3DGraphics(){return this.graphicsCore?.graphics3DGraphics}get graphics3DGraphicsByObjectID(){return this.graphicsCore?.graphics3DGraphicsByObjectID}get symbolUpdateType(){return this.graphicsCore?.symbolUpdateType}get displayFeatureLimit(){const e=this.view.resourceController.memoryController.memoryFactor,t=this.graphicsCore?.displayFeatureLimit;if(1===e)return t;const i=Math.ceil(t.maximumNumberOfFeatures*e),s=Math.ceil(t.maximumTotalNumberOfFeatures*e),r=Math.ceil(t.minimumTotalNumberOfFeatures*e);return{...t,maximumNumberOfFeatures:i,maximumTotalNumberOfFeatures:s,minimumTotalNumberOfFeatures:r}}get usedMemory(){return this.graphicsCore?.usedMemory??0}get loadedFeatures(){return this.graphicsCore?.numberOfGraphics??0}get usedMemoryPerFeature(){return this.graphicsCore?.usedMemoryPerGraphic??0}get unprocessedMemoryEstimate(){return this.graphicsCore?.unprocessedMemoryEstimate??0}get performanceInfo(){return{core:this.graphicsCore.performanceInfo,elevationUpdating:this.elevationAlignment.updating,visibilityFrustum:o(this.frustumVisibility)||!this.frustumVisibility.suspended,visibilityScale:!this.scaleVisibilitySuspended}}maskOccludee(e){const{set:t,handle:i}=this.objectStates.acquireSet(A.MaskOccludee,null);return this.objectStates.setUid(t,e.uid),i}highlight(e,i){if(e instanceof x){const{set:t,handle:s}=this.objectStates.acquireSet(A.Highlight,i);return this.owner.queryObjectIds(e).then((e=>this.objectStates.setObjectIds(t,e))),s}if("number"==typeof e||"string"==typeof e)return this.highlight([e],i);if(e instanceof t)return this.highlight([e],i);if("toArray"in e&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof t){const t=e;if(null==G(this.layer.fieldsIndex,t[0].attributes,i)){const e=t.map((e=>e.uid)),{set:i,handle:s}=this.objectStates.acquireSet(A.Highlight,null);return this.objectStates.setUids(i,e),s}e=t.map((e=>G(this.layer.fieldsIndex,e.attributes,i)))}if("number"==typeof e[0]||"string"==typeof e[0]){const t=e,{set:s,handle:r}=this.objectStates.acquireSet(A.Highlight,i);return this.objectStates.setObjectIds(s,t),r}}return T}resetObjectStates(){this.objectStates.reset()}whenGraphicBounds(e,t){return this.graphicsCore?.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.graphicsCore?.computeAttachmentOrigin(e,t)}notifyGraphicGeometryChanged(e){this.graphicsCore.notifyGraphicGeometryChanged(e)}notifyGraphicVisibilityChanged(e){this.graphicsCore.notifyGraphicVisibilityChanged(e)}getRenderingInfo(e,t,s){const r=E(e,{renderer:t,arcade:s});if(a(r)&&r.color){const e=r.color;e[0]=e[0]/255,e[1]=e[1]/255,e[2]=e[2]/255}if(a(r)&&a(t)&&this._randomRotationRenderers?.has(t)){const s=this._randomRotationRenderers.get(t),n=e.attributes[s],a=new i(0);a.updateFloatArray([n]),a.updateUint8Array([173]),r.heading=8.381e-8*a.digest()}return r}getRenderingInfoAsync(e,t,i,s){return C(e,{renderer:t,arcade:i,...s})}getSymbolLayerSize(e,t){return this.graphicsCore?.getSymbolLayerSize(e,t)}setObjectIdVisibility(e,t){this.graphicsCore?.setObjectIdVisibility(e,t)}refreshFilter(){a(this.filterVisibility)&&this.filterVisibility.reapply()}getGraphics3DGraphicByObjectId(e){return this.graphicsCore?.getGraphics3DGraphicByObjectId(e)}_updateClippingExtent(){const e=this.owner.view.clippingArea;this.graphicsCore.setClippingExtent(e,this.owner.view.spatialReference)&&(this.updateClippingExtent(e)||this.graphicsCore.recreateAllGraphics())}_setupSuspendResumeExtent(){(this.frustumVisibility||this.scaleVisibility)&&this.handles.add(u((()=>this.suspendResumeExtentMode),(()=>{switch(this.handles.remove(M),this.suspendResumeExtentMode){case"computed":this.handles.add([u((()=>this.graphicsCore.computedExtent),(e=>this._updateSuspendResumeExtent(e)),d),u((()=>this.graphicsCore.extentPadding),(()=>this._updateSuspendResumeExtent(this.graphicsCore.computedExtent)))],M);break;case"data":this.handles.add([h((()=>this.dataExtent),(e=>this._updateSuspendResumeExtent(e)),d),u((()=>this.graphicsCore.extentPadding),(()=>this._updateSuspendResumeExtent(l(this.dataExtent))))],M);break;default:s(this.suspendResumeExtentMode)}}),d))}_updateSuspendResumeExtent(e){e?this._suspendResumeExtentChanged(this._extentToSuspendResumeRect(e,this._suspendResumeExtent)):this._suspendResumeExtentChanged(null)}_extentToSuspendResumeRect(e,t){const i=this.owner.view.spatialReference;if(!e.spatialReference.equals(i)){if(!g(e,i))return;e=b(e,i)}return I(e,t,w,this.graphicsCore.extentPadding)}_suspendResumeExtentChanged(e){a(this.frustumVisibility)&&this.frustumVisibility.setExtent(e),a(this.scaleVisibility)&&this.scaleVisibility.setExtent(e)}};e([c()],U.prototype,"type",void 0),e([c({constructOnly:!0})],U.prototype,"owner",void 0),e([c()],U.prototype,"layer",null),e([c()],U.prototype,"renderer",null),e([c({constructOnly:!0})],U.prototype,"updateClippingExtent",void 0),e([c({constructOnly:!0})],U.prototype,"elevationFeatureExpressionEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"graphicsCore",void 0),e([c({constructOnly:!0})],U.prototype,"scaleVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"filterVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"frustumVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"elevationAlignmentEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"timeExtentEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"setUidToIdOnAdd",void 0),e([c()],U.prototype,"scaleVisibility",null),e([c()],U.prototype,"filterVisibility",null),e([c()],U.prototype,"elevationAlignment",null),e([c({constructOnly:!0})],U.prototype,"frustumVisibility",void 0),e([c()],U.prototype,"objectStates",null),e([c()],U.prototype,"initializePromise",void 0),e([c()],U.prototype,"suspendResumeExtentMode",null),e([c()],U.prototype,"dataExtent",void 0),e([c()],U.prototype,"scaleVisibilitySuspended",null),e([c()],U.prototype,"suspended",null),e([c()],U.prototype,"legendEnabled",null),e([c()],U.prototype,"suspendInfo",null),e([c()],U.prototype,"updating",null),e([c()],U.prototype,"updatingRemaining",null),e([c()],U.prototype,"featureStore",null),e([c()],U.prototype,"view",null),e([c()],U.prototype,"loadedGraphics",null),e([c()],U.prototype,"fullOpacity",null),e([c()],U.prototype,"filter",null),e([c()],U.prototype,"slicePlaneEnabled",null),e([c()],U.prototype,"drapeSourceType",void 0),e([c()],U.prototype,"updatePolicy",null),e([c()],U.prototype,"preferredUpdatePolicy",void 0),e([c()],U.prototype,"displayFeatureLimit",null),U=e([m("esri.views.3d.layers.graphics.Graphics3DFeatureProcessor")],U);const F=U,M="suspendResumeExtentMode",T={remove(){},pause(){},resume(){}};export{F 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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{makeHandle as t}from"../../../../core/handleUtils.js";import{Graphics3DObjectStateSet as e}from"./Graphics3DObjectStateSet.js";class s{constructor(t){this._graphicsCore=t,this._stateSets=new Array}destroy(){this._stateSets&&this._stateSets.forEach((t=>t.objectStateSet.removeAll())),this._stateSets=
|
|
5
|
+
import{makeHandle as t}from"../../../../core/handleUtils.js";import{Graphics3DObjectStateSet as e}from"./Graphics3DObjectStateSet.js";class s{constructor(t){this._graphicsCore=t,this._stateSets=new Array}destroy(){this.reset(),this._stateSets=null}reset(){this._stateSets&&(this._stateSets.forEach((t=>t.objectStateSet.removeAll())),this._stateSets.length=0)}acquireSet(s,a){const i=new e(s,a);this._stateSets.push(i);const h=t((()=>this.releaseSet(i)));return{set:i,handle:h}}releaseSet(t){t.objectStateSet.removeAll();const e=this._stateSets?this._stateSets.indexOf(t):-1;-1!==e&&this._stateSets.splice(e,1)}_addObjectStateSet(t,e){t.addObjectStateSet(e.stateType,e.objectStateSet)}_removeObjectStateSet(t,e){t.removeObjectState(e.objectStateSet)}setUid(t,e){t.ids.add(e);const s=this._graphicsCore.graphics3DGraphics.get(e);s&&this._addObjectStateSet(s,t)}setUids(t,e){e.forEach((e=>this.setUid(t,e)))}setObjectIds(t,e){e.forEach((e=>t.ids.add(e))),this._initializeSet(t)}addGraphic(t){this._stateSets.forEach((e=>{!e.paused&&e.hasGraphic(t)&&this._addObjectStateSet(t,e)}))}removeGraphic(t){this._stateSets.forEach((e=>{e.hasGraphic(t)&&this._removeObjectStateSet(t,e)}))}allGraphicsDeleted(){this._stateSets&&this._stateSets.forEach((t=>t.objectStateSet.removeAll()))}_initializeSet(t){const e=this._graphicsCore.graphics3DGraphics;t.objectIdField?e.forEach((e=>{e&&t.hasGraphic(e)&&this._addObjectStateSet(e,t)})):t.ids.forEach((s=>{const a=e.get(s);a&&this._addObjectStateSet(a,t)}))}get test(){return{states:this._stateSets}}}export{s as Graphics3DObjectStates};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e,isNone as t}from"../../../../core/maybe.js";import{ViewingMode as r}from"../../../ViewingMode.js";import{isValidObb as i,isValidMbs as s}from"./I3SUtil.js";import{I3sTarget as n}from"./Intersector.js";import{intersectLine as o}from"../../support/orientedBoundingBox.js";import{newIntersectorResult as l}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as c,StoreResults as d}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{getVerticalOffsetI3S as a}from"../../webgl-engine/lib/verticalOffsetUtils.js";class f{constructor(e){this.type=c.I3S,this._needVerticalOffset=!1,this.layerUid=e.layerUid,this.
|
|
5
|
+
import{isSome as e,isNone as t}from"../../../../core/maybe.js";import{ViewingMode as r}from"../../../ViewingMode.js";import{isValidObb as i,isValidMbs as s}from"./I3SUtil.js";import{I3sTarget as n}from"./Intersector.js";import{intersectLine as o}from"../../support/orientedBoundingBox.js";import{newIntersectorResult as l}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as c,StoreResults as d}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{getVerticalOffsetI3S as a}from"../../webgl-engine/lib/verticalOffsetUtils.js";class f{constructor(e){this.type=c.I3S,this._needVerticalOffset=!1,this.layerUid=e.layerUid,this.sublayerUid=e.sublayerUid,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,t){this._needVerticalOffset=e&&t===r.Global}intersect(r,c,f,u){const m=r.results,h=r.options.store===d.ALL,p=r.ray.direction,y=r.tolerance;let g=e=>e,O=e=>e;const v=a(e(r.verticalOffset)?r.verticalOffset:this._needVerticalOffset?0:null);e(r.verticalOffset)&&e(v)&&(g=e=>v.applyToMbs(e),O=e=>v.applyToObb(e)),this._traverseNodeHierarchy(((d,a)=>{if(0===d.childrenLoaded)return!1;const I=e(d.serviceObbInRenderSR)&&i(d.serviceObbInRenderSR)?d.serviceObbInRenderSR:null;return!(e(I)&&!o(O(I),f,p,y))&&(a&&(e(I)||!s(d.renderMbs)||b(g(d.renderMbs),f,p,y))&&(t(d.geometryObb)||o(O(d.geometryObb),f,p,y))&&this._collection.intersect(a,f,u,y,v,((e,t,i,s)=>{if(t>=0){if(null!=c&&!c(f,u,t))return;const o=r=>{const o=new n(this.layerUid,this.sublayerUid,d.index,e,s);r.set(this.type,o,t,i)};if(this.isGround&&(null==m.ground.dist||t<m.ground.dist)&&o(m.ground),r.options.isFiltered)return;if((null==m.min.dist||t<m.min.dist)&&o(m.min),(null==m.max.dist||t>m.max.dist)&&o(m.max),h){const e=l(r.ray);o(e),r.results.all.push(e)}}})),!0)}))}}function b(e,t,r,i=0){const s=e[3]+i,n=t[0]-e[0],o=t[1]-e[1],l=t[2]-e[2],c=r[0],d=r[1],a=r[2],f=c*n+d*o+a*l;return f*f-(c*c+d*d+a*a)*(n*n+o*o+l*l-s*s)>=0}export{f as I3SIntersectionHandler};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{remove as i,splitIntoChunks as r}from"../../../../core/arrayUtils.js";import{resultOrAbort as a,result as n}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as o,estimateNumberByteSize as c}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Logger.js";import{isSome as h,unwrap as l,destroyMaybe as u,abortMaybe as m,isNone as g,get as p}from"../../../../core/maybe.js";import{whenOrAbort as _}from"../../../../core/promiseUtils.js";import{watch as y,initial as b}from"../../../../core/reactiveUtils.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as O}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as j}from"../../../../intl/number.js";import{getMaximumQuerySize as I,queryAllJSON as C}from"../../../../layers/support/featureQueryAll.js";import{sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import E from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this.
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{remove as i,splitIntoChunks as r}from"../../../../core/arrayUtils.js";import{resultOrAbort as a,result as n}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as o,estimateNumberByteSize as c}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Logger.js";import{isSome as h,unwrap as l,destroyMaybe as u,abortMaybe as m,isNone as g,get as p}from"../../../../core/maybe.js";import{whenOrAbort as _}from"../../../../core/promiseUtils.js";import{watch as y,initial as b}from"../../../../core/reactiveUtils.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as O}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as j}from"../../../../intl/number.js";import{getMaximumQuerySize as I,queryAllJSON as C}from"../../../../layers/support/featureQueryAll.js";import{sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import E from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._interactiveEditingSessions=null,this._maximumNumberOfEditOVerrides=F,this._original3DOFLDefinitionExpression=null,this._associatedLayerView=null,this._changedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`${this.layer.uid}-attribute-overrides`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),v()&&h(this._associatedLayer)&&h(this._associatedLayer.infoFor3D)&&this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(y((()=>this._definitionExpression),(t=>e.definitionExpression=t),b)),this._associatedLayerView=new E({layer:this._associatedLayer,view:this.view}))}))}destroy(){v()&&h(this._associatedLayer)&&h(this._associatedLayer.infoFor3D)&&h(this._associatedLayerView)&&(this._associatedLayer.definitionExpression=l(this._original3DOFLDefinitionExpression)),this._set("layer",null),this._memCache=u(this._memCache),this._pendingFetchAbortController=m(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get geometryChangedObjectIds(){return[...this._changedObjectIds]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.geometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!v())return!1;if(!(h(this._associatedLayer)&&h(this._associatedLayer.infoFor3D)))return!1;return!h(this._associatedLayerView)||h(this._associatedLayerView)&&this._associatedLayerView.updating}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._changedObjectIds.size}createInteractiveEditSession(e){this._changedObjectIds.add(e),this.notifyChange("_changedObjectIds"),g(this._interactiveEditingSessions)&&(this._interactiveEditingSessions=[]);const t=this._interactiveEditingSessions,s=new L(e,{rollback:()=>{i(t,s),0===t.length&&(this._interactiveEditingSessions=null)},commit:t=>{for(const[s,i]of t)this.updateAttributeValue(e,s,i)}});return t.unshift(s),s}async apply(e,t,s){if(g(t))return;const{loadedAttributes:i,attributeData:r}=t;if(g(i)||0===i.length||g(r))return;if(this._pendingFetchChangedObjectIds&&await _(this._pendingFetchChangedObjectIds,s),0===this._changedObjectIds.size)return;const a={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,a,this._changedObjectIds),{objectIds:o,fieldNames:c}=n;if(0===o.length||0===c.length)return;const d=await this._queryOverridesFromAssociatedLayer(o,c,s);g(d)||this._processOverridesFromAssociatedLayer(e,d,c,a)}updateGeometry(e){this._changedObjectIds.add(e),this.notifyChange("_changedObjectIds")}updateAttributeValue(e,t,s){this._changedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_changedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,a=new Array;for(const o of t)a[o.index]=s[o.name];const n=new Set;for(let o=0;o<e.length;o++){const s=e[o];if(i.has(s))for(const e of t){const t=this._fromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):a[e.index][o]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_fromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(!g(this._interactiveEditingSessions))for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.get(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryOverridesFromAssociatedLayer(e,t,s){if(0===e.length||0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const i=this.layer.associatedLayer;if(g(i))return null;const n=i.createQuery();n.where="1=1",n.returnGeometry=!1,n.outFields=[i.objectIdField,...t],n.cacheHint=!0,n.objectIds=e;const o=I(i),c=e.length>o?r(e,o).map((e=>{const t=n.clone();return t.objectIds=e,a(C(i,t,{signal:s}))})):[a(C(i,n,{signal:s}))];return(await Promise.all(c)).reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${j(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,d.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const a=this.layer.associatedLayer;if(g(a))return;const n=a.objectIdField,o=s.map((e=>r[e])),c=new Map(i.map((e=>[e.name,e.index]))),d=s.map((e=>c.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=d[t],r=h.get(e),a=l.attributes[s[t]];o[t][r]=a,this._cacheAttributeValue(e,i,a)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?o(e):c()}async _fetchChangedObjectIds(e){const s=this.layer;if(await s.load({signal:e}),this._changedObjectIds.clear(),g(s.associatedLayer)||!s.associatedLayer.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(g(i))return;const r=s.associatedLayer.layerId,a=h(s.associatedLayer.infoFor3D),o=await n(t(`${s.associatedLayer.url}/extractChanges`,{method:"post",query:{f:"json",returnIdsOnly:!0,layers:`[${r}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:r,serverGen:i}])},timeout:w,signal:e}));if(o.ok&&o.value.data?.edits&&1===o.value.data.edits.length){const e=o.value.data.edits[0],t=p(e,"objectIds","adds"),s=p(e,"objectIds","updates"),i=p(e,"objectIds","deletes");let r=[];h(t)&&(r=r.concat(t)),h(s)&&(r=r.concat(s)),h(i)&&(r=r.concat(i));const a=Math.min(this._maximumNumberOfEditOVerrides,r.length);a<r.length&&(this._warnMaximumChangedObjectsExceeded=!0);const n=r.sort(((e,t)=>e-t));for(let o=0;o<a;o++)this._changedObjectIds.add(n[o])}this.notifyChange("_changedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(h(e.serviceUpdateTimeStamp)&&h(e.serviceUpdateTimeStamp.lastUpdate))return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return h(t)&&h(t.serverGens)&&h(t.serverGens.minServerGen)?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._changedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([f({constructOnly:!0})],A.prototype,"view",void 0),e([f({constructOnly:!0})],A.prototype,"layer",void 0),e([f({readOnly:!0})],A.prototype,"geometryChangedObjectIds",null),e([f()],A.prototype,"_associatedLayer",null),e([f()],A.prototype,"_associatedLayerView",void 0),e([f({constructOnly:!0})],A.prototype,"memoryController",void 0),e([f()],A.prototype,"_changedObjectIds",void 0),e([f()],A.prototype,"_pendingFetchChangedObjectIds",void 0),e([f()],A.prototype,"_definitionExpression",null),e([f()],A.prototype,"updating",null),e([f()],A.prototype,"isEmpty",null),A=e([O("esri.views.3d.layers.i3s.I3SOverrides")],A);class L{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._state=x.ACTIVE}get(e){return this._updates.get(e)}set(e,t){this._isActive&&this._updates.set(e,t)}rollback(){this._isActive&&(this._state=x.ROLLED_BACK,this._options.rollback())}commit(){this._isActive&&(this._state=x.COMMITTED,this._options.commit(this._updates),this._updates.clear())}get _isActive(){return this._state===x.ACTIVE}}var x;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(x||(x={}));const w=1e4,F=5e4;export{A as I3SOverrides};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../request.js";import{binaryIndexOf as t,splitIntoChunks as r}from"../../../../core/arrayUtils.js";import n from"../../../../core/Error.js";import has from"../../../../core/has.js";import{isSome as o,isNone as a}from"../../../../core/maybe.js";import{eachAlways as i}from"../../../../core/promiseUtils.js";import{isInt16Array as s,isInt32Array as l}from"../../../../core/typedArrayUtil.js";import{c}from"../../../../chunks/mat3.js";import{c as u}from"../../../../chunks/mat3f64.js";import{a as f}from"../../../../chunks/mat4.js";import{c as p}from"../../../../chunks/mat4f64.js";import{a as m,m as h,c as d}from"../../../../chunks/quat.js";import{c as y}from"../../../../chunks/quatf32.js";import{s as b,c as g,w as S,q as w,g as T,a as E,m as v}from"../../../../chunks/vec3.js";import{c as M}from"../../../../chunks/vec3f64.js";import{getReferenceEllipsoid as I}from"../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as R,projectBuffer as x,computeTranslationToOriginAndRotation as j,projectVectorToVector as q}from"../../../../geometry/projection.js";import k from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as C}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{create as N,empty as U,expandPointInPlace as z,intersects as W}from"../../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as A}from"../../../../geometry/support/spatialReferenceUtils.js";import D from"../../../../rest/support/Query.js";import{readBinaryAttribute as F}from"./I3SBinaryReader.js";import{computeGlobalTransformation as _}from"./I3SProjectionUtil.js";import{createSolidEdgeMaterial as O,createMaterialFromEdges as G}from"../support/edgeUtils.js";import{parseColorMixMode as K,ColorMixModeEnum as L}from"../support/symbolColorUtils.js";import{create as B,compute as P,corners as $}from"../../support/orientedBoundingBox.js";import{Attribute as Q}from"../../webgl-engine/lib/Attribute.js";function Z(e){return e?parseInt(e.substring(e.lastIndexOf("/")+1,e.length),10):void 0}function H(e){if(has("disable-feature:i3s-draco")||!e)return!1;for(const t of e)for(const e of t.geometryBuffers)if("draco"===e.compressedAttributes?.encoding)return!0;return!1}function J(e,t,r,n){r.traverse(t,(t=>{const r=t.mbs;return(null!=r&&re(e,r))!==te.OUTSIDE&&(n(t),!0)}))}function V(e,t,r){let n=0,o=0;for(let a=0;a<t.length&&n<e.length;a++)e[n]===t[a]&&(r(a)&&(e[o]=e[n],o++),n++);e.length=o}function X(e,r,n){let o=0,a=0;for(;o<n.length;){t(e,n[o])>=0===r&&(n[a]=n[o],a++),o++}n.length=a}const Y=N();function ee(e,t){if(0===t.rotationScale[1]&&0===t.rotationScale[2]&&0===t.rotationScale[3]&&0===t.rotationScale[5]&&0===t.rotationScale[6]&&0===t.rotationScale[7])return Y[0]=(e[0]-t.position[0])/t.rotationScale[0],Y[1]=(e[1]-t.position[1])/t.rotationScale[4],Y[2]=(e[2]-t.position[0])/t.rotationScale[0],Y[3]=(e[3]-t.position[1])/t.rotationScale[4],Y}var te;function re(e,t){const r=t[0],n=t[1],o=t[3],a=e[0]-r,i=r-e[2],s=e[1]-n,l=n-e[3],c=Math.max(a,i,0),u=Math.max(s,l,0),f=c*c+u*u;if(f>o*o)return te.OUTSIDE;if(f>0)return te.INTERSECTS_CENTER_OUTSIDE;return-Math.max(a,i,s,l)>o?te.INSIDE:te.INTERSECTS_CENTER_INSIDE}function ne(e,t,r){const n=[],o=r&&r.missingFields,a=r&&r.originalFields;for(const i of e){const e=i.toLowerCase();let r=!1;for(const o of t)if(e===o.name.toLowerCase()){n.push(o.name),r=!0,a&&a.push(i);break}!r&&o&&o.push(i)}return n}async function oe(e,t,r,i,s){if(0===t.length)return[];const l=e.attributeStorageInfo;if(o(e.associatedLayer))try{return await ie(e.associatedLayer,t,r,i)}catch(c){if(e.associatedLayer.loaded)throw c}if(l){const o=ae(t,r,s);if(a(o))throw new n("scenelayer:features-not-loaded","Tried to query attributes for unloaded features");const c=e.parsedUrl.path;return(await Promise.all(o.map((e=>le(c,l,e.node,e.indices,i).then((t=>{for(let r=0;r<e.graphics.length;r++){const n=e.graphics[r],o=t[r];if(n.attributes)for(const e in n.attributes)e in o||(o[e]=n.attributes[e]);n.attributes=o}return e.graphics})))))).flat()}throw new n("scenelayer:no-attribute-source","This scene layer does not have a source for attributes available")}function ae(e,t,r){const n=new Map,o=[],a=r();for(const i of e){const e=i.attributes[t];for(let t=0;t<a.length;t++){const r=a[t],s=r.featureIds.indexOf(e);if(s>=0){let e=n.get(r.node);e||(e={node:r.node,indices:[],graphics:[]},o.push(e),n.set(r.node,e)),e.indices.push(s),e.graphics.push(i);for(let r=t;r>0;r--)a[r]=a[r-1];a[0]=r;break}}}return o}async function ie(e,t,r,n){t.sort(((e,t)=>e.attributes[r]-t.attributes[r]));const o=t.map((e=>e.attributes[r])),a=[],i=ne(n,e.fields,{originalFields:a}),s=await se(e,o,i);for(let l=0;l<t.length;l++){const e=t[l],r=s[l],n={};if(e.attributes)for(const t in e.attributes)n[t]=e.attributes[t];for(let t=0;t<a.length;t++)n[a[t]]=r[i[t]];e.attributes=n}return t}function se(e,t,o){const a=e.capabilities.query.maxRecordCount;if(null!=a&&t.length>a){const n=r(t,a);return Promise.all(n.map((t=>se(e,t,o)))).then((e=>e.flat()))}const i=new D({objectIds:t,outFields:o,orderByFields:[e.objectIdField]});return e.queryFeatures(i).then((e=>{if(e&&e.features&&e.features.length===t.length)return e.features.map((e=>e.attributes));throw new n("scenelayer:feature-not-in-associated-layer","Feature not found in associated feature layer")}))}function le(e,t,r,n,o){return ce(e,t,r.resources.attributes,n,o)}function ce(t,r,n,o,a){const s=[];for(const e of r)if(e&&a.includes(e.name)){const r=`${t}/nodes/${n}/attributes/${e.key}/0`;s.push({url:r,storageInfo:e})}return i(s.map((t=>e(t.url,{responseType:"array-buffer"}).then((e=>F(t.storageInfo,e.data)))))).then((e=>{const t=[];for(const r of o){const n={};for(let t=0;t<e.length;t++){const o=e[t].value;null!=o&&(n[s[t].storageInfo.name]=pe(o,r))}t.push(n)}return t}))}!function(e){e[e.OUTSIDE=0]="OUTSIDE",e[e.INTERSECTS_CENTER_OUTSIDE=1]="INTERSECTS_CENTER_OUTSIDE",e[e.INTERSECTS_CENTER_INSIDE=2]="INTERSECTS_CENTER_INSIDE",e[e.INSIDE=3]="INSIDE"}(te||(te={}));const ue=-32768,fe=-(2**31);function pe(e,t){if(!e)return null;const r=e[t];if(s(e))return r===ue?null:r;if(l(e))return r===fe?null:r;return r!=r?null:r}function me(e){const t=e.store,r=t.indexCRS||t.geographicCRS,o=void 0===r?t.indexWKT:void 0;if(o){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference","Found indeWKT in the scene layer store but no layer spatial reference",{});if(o!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-index-incompatible","The indeWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const a=r?new k(Z(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function he(e){const t=e.store,r=t.vertexCRS||t.projectedCRS,o=void 0===r?t.vertexWKT:void 0;if(o){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference","Found vertexWKT in the scene layer store but no layer spatial reference",{});if(o!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-vertex-incompatible","The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const a=r?new k(Z(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function de(e,t){return a(t)?"@null":t===C(t)?"@ECEF":e.equals(t)?"":null!=t.wkid?"@"+t.wkid:null}function ye(e,t,r){if(!R(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});if("local"===r&&!be(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{})}function be(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function ge(e,t,r){const n=me(e),o=he(e);ye(n,t,r),ye(o,t,r)}function Se(e){return(null==e.geometryType||"triangles"===e.geometryType)&&((null==e.topology||"PerAttributeArray"===e.topology)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position))}function we(e){if(null==e.store||null==e.store.defaultGeometrySchema||!Se(e.store.defaultGeometrySchema))throw new n("scenelayer:unsupported-geometry-schema","The geometry schema of this scene layer is not supported.",{url:e.parsedUrl.path})}function Te(e,t){ge(e,t.spatialReference,t.viewingMode)}function Ee(e){return null!=e.geometryType&&"points"===e.geometryType&&((null==e.topology||"PerAttributeArray"===e.topology)&&((null==e.encoding||""===e.encoding||"lepcc-xyz"===e.encoding)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position)))}function ve(e){if(null==e.store||null==e.store.defaultGeometrySchema||!Ee(e.store.defaultGeometrySchema))throw new n("pointcloud:unsupported-geometry-schema","The geometry schema of this point cloud scene layer is not supported.",{})}function Me(e,t){ye(e.spatialReference,t.spatialReference,t.viewingMode)}function Ie(e){return"simple"===e.type||"class-breaks"===e.type||"unique-value"===e.type}function Re(e){return"mesh-3d"===e.type}function xe(e){if(null==e||!Ie(e))return!0;if(("unique-value"===e.type||"class-breaks"===e.type)&&null==e.defaultSymbol)return!0;const t=e.getSymbols();if(0===t.length)return!0;for(const r of t){if(!Re(r)||0===r.symbolLayers.length)return!0;for(const e of r.symbolLayers.items)if("fill"!==e.type||a(e.material)||a(e.material.color)||"replace"!==e.material.colorMixMode)return!0}return!1}const je=O({color:[0,0,0,0],opacity:0});class qe{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function ke(e){const t=new qe;let r=!1,n=!1;for(const a of e.symbolLayers.items)if("fill"===a.type&&a.enabled){const e=a.material,i=a.edges;if(o(e)&&!r){const n=e.color,i=K(e.colorMixMode);o(n)?t.material={color:[n.r/255,n.g/255,n.b/255],alpha:n.a,colorMixMode:i}:t.material={color:[1,1,1],alpha:1,colorMixMode:L.Multiply},t.castShadows=a.castShadows,r=!0}o(i)&&!n&&(t.edgeMaterial=G(i,{}),n=!0)}return t.material||(t.material={color:[1,1,1],alpha:1,colorMixMode:L.Multiply}),t}function Ce(e,t){return(0|e)+(0|t)|0}function Ne(e,t,r,n,o=0){n===C(n)?t.isGeographic?Ke(e,r,t,o):Ge(e,r,t,o):t.isWGS84&&(n.isWebMercator||A(n))?Ue(t,e,n,r,o):t.isWebMercator&&A(n)?_e(t,e,n,r,o):e===r?(r.center[2]+=o,x(r.center,t,0,r.center,n,0,1)):(b(r.center,e.center[0],e.center[1],e.center[2]+o),x(r.center,t,0,r.center,n,0,1),m(r.quaternion,e.quaternion),g(r.halfSize,e.halfSize))}function Ue(e,t,r,n,o){g(De,t.center),De[2]+=o;const a=C(r);x(De,e,0,De,a,0,1),Oe(a,t,De,r,n)}const ze=new Array(24),We=new Q(ze,3,!0),Ae=M(),De=M(),Fe=u();function _e(e,t,r,n,o){g(De,t.center),De[2]+=o,Oe(e,t,De,r,n)}function Oe(e,t,r,n,o){const a=c(Fe,t.quaternion);for(let i=0;i<8;++i){for(let e=0;e<3;++e)Ae[e]=t.halfSize[e]*(0!=(i&1<<e)?-1:1);for(let e=0;e<3;++e){let t=r[e];for(let r=0;r<3;++r)t+=Ae[r]*a[3*r+e];ze[3*i+e]=t}}x(ze,e,0,ze,n,0,8),P(We,o)}function Ge(e,t,r,n){$(e,Je),b(t.center,e.center[0],e.center[1],e.center[2]+n),j(r,t.center,Ze,C(r)),b(t.center,Ze[12],Ze[13],Ze[14]);const o=2*Math.sqrt(1+Ze[0]+Ze[5]+Ze[10]);He[0]=(Ze[6]-Ze[9])/o,He[1]=(Ze[8]-Ze[2])/o,He[2]=(Ze[1]-Ze[4])/o,He[3]=.25*o,h(t.quaternion,He,e.quaternion),d(He,t.quaternion);let a=0,i=0,s=0;for(const l of Je)l[2]+=n,x(l,r,0,l,C(r),0,1),S(et,l,t.center),w(et,et,He),a=Math.max(a,Math.abs(et[0])),i=Math.max(i,Math.abs(et[1])),s=Math.max(s,Math.abs(et[2]));b(t.halfSize,a,i,s)}function Ke(e,t,r,n){const o=I(r),a=1+Math.max(0,n)/(o.radius+e.center[2]);b(t.center,e.center[0],e.center[1],e.center[2]+n),x(t.center,r,0,t.center,C(r),0,1),m(t.quaternion,e.quaternion),d(He,e.quaternion),b(et,0,0,1),w(et,et,He),b(et,e.halfSize[0]*Math.abs(et[0]),e.halfSize[1]*Math.abs(et[1]),e.halfSize[2]*Math.abs(et[2])),T(et,et,o.inverseFlattening),E(t.halfSize,e.halfSize,et),T(t.halfSize,t.halfSize,a)}function Le(e,t,r,n,i,s){if(!s||0===s.length||a(t)||!e.mbs)return null;const l=_(e.mbs,i,r,t);f(rt,l);let c=null;const u=()=>{if(!c)if(c=Je,U(Xe),o(e.serviceObb)){Ne(e.serviceObb,r,Ye,t,i),$(Ye,c);for(const e of c)v(e,e,rt),z(Xe,e)}else{const n=e.mbs;if(!n)return;const o=n[3];q(n,r,et,t),v(et,et,rt),et[2]+=i;for(let e=0;e<8;++e){const t=1&e?o:-o,r=2&e?o:-o,n=4&e?o:-o,a=c[e];g(a,[et[0]+t,et[1]+r,et[2]+n]),z(Xe,a)}}};let p=1/0,m=-1/0;const h=e=>{if("replace"!==e.type)return;const r=e.geometry;if(!r?.hasZ)return;U(Ve);const o=r.spatialReference||n,a=r.rings.reduce(((e,r)=>r.reduce(((e,r)=>(q(r,o,et,t),v(et,et,rt),z(Ve,et),Math.min(et[2],e))),e)),1/0);u(),W(Xe,Ve)&&(p=Math.min(p,a),m=Math.max(m,a))};if(s.forEach((e=>h(e))),p===1/0)return null;const d=(e,t,r)=>{v(et,r,l),e[t+0]=et[0],e[t+1]=et[1],e[t+2]=et[2],t+=24,r[2]=p,v(et,r,l),e[t+0]=et[0],e[t+1]=et[1],e[t+2]=et[2],t+=24,r[2]=m,v(et,r,l),e[t+0]=et[0],e[t+1]=et[1],e[t+2]=et[2]};for(let o=0;o<8;++o)d(tt.data,3*o,c[o]);return P(tt)}function Be(e){return o(e)&&e.halfSize[0]>=0}function Pe(e){return e[3]>=0}function $e(e){o(e)&&(e.halfSize[0]=-1)}function Qe(e){o(e)&&(e[3]=-1)}const Ze=p(),He=y(),Je=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Ve=N(),Xe=N(),Ye=B(),et=M(),tt={data:new Array(72),size:3,exclusive:!0,stride:3},rt=p();export{te as MbsIntersectResult,qe as SymbolInfo,Ce as addWraparound,Me as checkPointCloudLayerCompatibleWithView,ve as checkPointCloudLayerValid,Te as checkSceneLayerCompatibleWithView,we as checkSceneLayerValid,ye as checkSpatialReference,ge as checkSpatialReferences,Le as computeVisibilityObb,H as containsDraco,Z as extractWkid,V as filterInPlace,ne as findFieldsCaseInsensitive,J as findIntersectingNodes,de as getCacheKeySuffix,pe as getCachedAttributeValue,ee as getClipRect,me as getIndexCrs,ke as getSymbolInfo,he as getVertexCrs,re as intersectBoundingRectWithMbs,Qe as invalidateMbs,$e as invalidateObb,be as isSupportedLocalModeProjection,Pe as isValidMbs,Be as isValidObb,X as objectIdFilter,ce as queryAttributesFromCachedAttributesId,xe as rendererNeedsTextures,Ne as transformObb,je as transparentEdgeMaterial,oe as whenGraphicAttributes};
|
|
5
|
+
import e from"../../../../request.js";import{binaryIndexOf as t,splitIntoChunks as r}from"../../../../core/arrayUtils.js";import n from"../../../../core/Error.js";import has from"../../../../core/has.js";import{isSome as o,isNone as a,applySome as i}from"../../../../core/maybe.js";import{eachAlways as s}from"../../../../core/promiseUtils.js";import{isInt16Array as l,isInt32Array as c}from"../../../../core/typedArrayUtil.js";import{c as u}from"../../../../chunks/mat3.js";import{c as f}from"../../../../chunks/mat3f64.js";import{a as p}from"../../../../chunks/mat4.js";import{c as m}from"../../../../chunks/mat4f64.js";import{a as h,m as d,c as y}from"../../../../chunks/quat.js";import{c as b}from"../../../../chunks/quatf32.js";import{s as g,c as S,w,q as T,g as E,a as v,m as M}from"../../../../chunks/vec3.js";import{c as I}from"../../../../chunks/vec3f64.js";import{getReferenceEllipsoid as R}from"../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as x,projectBuffer as j,computeTranslationToOriginAndRotation as q,projectVectorToVector as U}from"../../../../geometry/projection.js";import k from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as C}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{create as N,empty as z,expandPointInPlace as W,intersects as A}from"../../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as D}from"../../../../geometry/support/spatialReferenceUtils.js";import F from"../../../../rest/support/Query.js";import{readBinaryAttribute as _}from"./I3SBinaryReader.js";import{computeGlobalTransformation as O}from"./I3SProjectionUtil.js";import{createSolidEdgeMaterial as L,createMaterialFromEdges as G}from"../support/edgeUtils.js";import{parseColorMixMode as K,ColorMixModeEnum as B}from"../support/symbolColorUtils.js";import{create as P,compute as $,corners as Q}from"../../support/orientedBoundingBox.js";import{Attribute as Z}from"../../webgl-engine/lib/Attribute.js";function H(e){return e?parseInt(e.substring(e.lastIndexOf("/")+1,e.length),10):void 0}function J(e){if(has("disable-feature:i3s-draco")||!e)return!1;for(const t of e)for(const e of t.geometryBuffers)if("draco"===e.compressedAttributes?.encoding)return!0;return!1}function V(e,t,r,n){r.traverse(t,(t=>{const r=t.mbs;return(null!=r&&ne(e,r))!==re.OUTSIDE&&(n(t),!0)}))}function X(e,t,r){let n=0,o=0;for(let a=0;a<t.length&&n<e.length;a++)e[n]===t[a]&&(r(a)&&(e[o]=e[n],o++),n++);e.length=o}function Y(e,r,n){let o=0,a=0;for(;o<n.length;){t(e,n[o])>=0===r&&(n[a]=n[o],a++),o++}n.length=a}const ee=N();function te(e,t){if(0===t.rotationScale[1]&&0===t.rotationScale[2]&&0===t.rotationScale[3]&&0===t.rotationScale[5]&&0===t.rotationScale[6]&&0===t.rotationScale[7])return ee[0]=(e[0]-t.position[0])/t.rotationScale[0],ee[1]=(e[1]-t.position[1])/t.rotationScale[4],ee[2]=(e[2]-t.position[0])/t.rotationScale[0],ee[3]=(e[3]-t.position[1])/t.rotationScale[4],ee}var re;function ne(e,t){const r=t[0],n=t[1],o=t[3],a=e[0]-r,i=r-e[2],s=e[1]-n,l=n-e[3],c=Math.max(a,i,0),u=Math.max(s,l,0),f=c*c+u*u;if(f>o*o)return re.OUTSIDE;if(f>0)return re.INTERSECTS_CENTER_OUTSIDE;return-Math.max(a,i,s,l)>o?re.INSIDE:re.INTERSECTS_CENTER_INSIDE}function oe(e,t,r){const n=[],o=r&&r.missingFields,a=r&&r.originalFields;for(const i of e){const e=i.toLowerCase();let r=!1;for(const o of t)if(e===o.name.toLowerCase()){n.push(o.name),r=!0,a&&a.push(i);break}!r&&o&&o.push(i)}return n}async function ae(e,t,r,i,s){if(0===t.length)return[];const l=e.attributeStorageInfo;if(o(e.associatedLayer))try{return await se(e.associatedLayer,t,r,i)}catch(c){if(e.associatedLayer.loaded)throw c}if(l){const o=ie(t,r,s);if(a(o))throw new n("scenelayer:features-not-loaded","Tried to query attributes for unloaded features");const c=e.parsedUrl.path;return(await Promise.all(o.map((e=>ce(c,l,e.node,e.indices,i).then((t=>{for(let r=0;r<e.graphics.length;r++){const n=e.graphics[r],o=t[r];if(n.attributes)for(const e in n.attributes)e in o||(o[e]=n.attributes[e]);n.attributes=o}return e.graphics})))))).flat()}throw new n("scenelayer:no-attribute-source","This scene layer does not have a source for attributes available")}function ie(e,t,r){const n=new Map,o=[],a=r();for(const i of e){const e=i.attributes[t];for(let t=0;t<a.length;t++){const r=a[t],s=r.featureIds.indexOf(e);if(s>=0){let e=n.get(r.node);e||(e={node:r.node,indices:[],graphics:[]},o.push(e),n.set(r.node,e)),e.indices.push(s),e.graphics.push(i);for(let r=t;r>0;r--)a[r]=a[r-1];a[0]=r;break}}}return o}async function se(e,t,r,n){t.sort(((e,t)=>e.attributes[r]-t.attributes[r]));const o=t.map((e=>e.attributes[r])),a=[],i=oe(n,e.fields,{originalFields:a}),s=await le(e,o,i);for(let l=0;l<t.length;l++){const e=t[l],r=s[l],n={};if(e.attributes)for(const t in e.attributes)n[t]=e.attributes[t];for(let t=0;t<a.length;t++)n[a[t]]=r[i[t]];e.attributes=n}return t}function le(e,t,o){const a=e.capabilities.query.maxRecordCount;if(null!=a&&t.length>a){const n=r(t,a);return Promise.all(n.map((t=>le(e,t,o)))).then((e=>e.flat()))}const i=new F({objectIds:t,outFields:o,orderByFields:[e.objectIdField]});return e.queryFeatures(i).then((e=>{if(e&&e.features&&e.features.length===t.length)return e.features.map((e=>e.attributes));throw new n("scenelayer:feature-not-in-associated-layer","Feature not found in associated feature layer")}))}function ce(e,t,r,n,o){return ue(e,t,r.resources.attributes,n,o)}function ue(t,r,n,o,a){const i=[];for(const e of r)if(e&&a.includes(e.name)){const r=`${t}/nodes/${n}/attributes/${e.key}/0`;i.push({url:r,storageInfo:e})}return s(i.map((t=>e(t.url,{responseType:"array-buffer"}).then((e=>_(t.storageInfo,e.data)))))).then((e=>{const t=[];for(const r of o){const n={};for(let t=0;t<e.length;t++){const o=e[t].value;null!=o&&(n[i[t].storageInfo.name]=me(o,r))}t.push(n)}return t}))}!function(e){e[e.OUTSIDE=0]="OUTSIDE",e[e.INTERSECTS_CENTER_OUTSIDE=1]="INTERSECTS_CENTER_OUTSIDE",e[e.INTERSECTS_CENTER_INSIDE=2]="INTERSECTS_CENTER_INSIDE",e[e.INSIDE=3]="INSIDE"}(re||(re={}));const fe=-32768,pe=-(2**31);function me(e,t){if(!e)return null;const r=e[t];if(l(e))return r===fe?null:r;if(c(e))return r===pe?null:r;return r!=r?null:r}function he(e){const t=e.store,r=t.indexCRS||t.geographicCRS,o=void 0===r?t.indexWKT:void 0;if(o){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference","Found indeWKT in the scene layer store but no layer spatial reference",{});if(o!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-index-incompatible","The indeWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const a=r?new k(H(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function de(e){const t=e.store,r=t.vertexCRS||t.projectedCRS,o=void 0===r?t.vertexWKT:void 0;if(o){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference","Found vertexWKT in the scene layer store but no layer spatial reference",{});if(o!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-vertex-incompatible","The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const a=r?new k(H(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function ye(e,t){return a(t)?"@null":t===C(t)?"@ECEF":e.equals(t)?"":null!=t.wkid?"@"+t.wkid:null}function be(e,t,r){if(!x(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});if("local"===r&&!Se(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{})}function ge(e,t,r){if(e.serviceUpdateTimeStamp?.lastUpdate!==t.serviceUpdateTimeStamp?.lastUpdate||!r.isEmpty||i(e.associatedLayer,(e=>e.url))!==i(t.associatedLayer,(e=>e.url)))throw new n("layerview:recycle-failed")}function Se(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function we(e,t,r){const n=he(e),o=de(e);be(n,t,r),be(o,t,r)}function Te(e){return(null==e.geometryType||"triangles"===e.geometryType)&&((null==e.topology||"PerAttributeArray"===e.topology)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position))}function Ee(e){if(null==e.store||null==e.store.defaultGeometrySchema||!Te(e.store.defaultGeometrySchema))throw new n("scenelayer:unsupported-geometry-schema","The geometry schema of this scene layer is not supported.",{url:e.parsedUrl.path})}function ve(e,t){we(e,t.spatialReference,t.viewingMode)}function Me(e){return null!=e.geometryType&&"points"===e.geometryType&&((null==e.topology||"PerAttributeArray"===e.topology)&&((null==e.encoding||""===e.encoding||"lepcc-xyz"===e.encoding)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position)))}function Ie(e){if(null==e.store||null==e.store.defaultGeometrySchema||!Me(e.store.defaultGeometrySchema))throw new n("pointcloud:unsupported-geometry-schema","The geometry schema of this point cloud scene layer is not supported.",{})}function Re(e,t){be(e.spatialReference,t.spatialReference,t.viewingMode)}function xe(e){return"simple"===e.type||"class-breaks"===e.type||"unique-value"===e.type}function je(e){return"mesh-3d"===e.type}function qe(e){if(null==e||!xe(e))return!0;if(("unique-value"===e.type||"class-breaks"===e.type)&&null==e.defaultSymbol)return!0;const t=e.getSymbols();if(0===t.length)return!0;for(const r of t){if(!je(r)||0===r.symbolLayers.length)return!0;for(const e of r.symbolLayers.items)if("fill"!==e.type||a(e.material)||a(e.material.color)||"replace"!==e.material.colorMixMode)return!0}return!1}const Ue=L({color:[0,0,0,0],opacity:0});class ke{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function Ce(e){const t=new ke;let r=!1,n=!1;for(const a of e.symbolLayers.items)if("fill"===a.type&&a.enabled){const e=a.material,i=a.edges;if(o(e)&&!r){const n=e.color,i=K(e.colorMixMode);o(n)?t.material={color:[n.r/255,n.g/255,n.b/255],alpha:n.a,colorMixMode:i}:t.material={color:[1,1,1],alpha:1,colorMixMode:B.Multiply},t.castShadows=a.castShadows,r=!0}o(i)&&!n&&(t.edgeMaterial=G(i,{}),n=!0)}return t.material||(t.material={color:[1,1,1],alpha:1,colorMixMode:B.Multiply}),t}function Ne(e,t){return(0|e)+(0|t)|0}function ze(e,t,r,n,o=0){n===C(n)?t.isGeographic?Be(e,r,t,o):Ke(e,r,t,o):t.isWGS84&&(n.isWebMercator||D(n))?We(t,e,n,r,o):t.isWebMercator&&D(n)?Le(t,e,n,r,o):e===r?(r.center[2]+=o,j(r.center,t,0,r.center,n,0,1)):(g(r.center,e.center[0],e.center[1],e.center[2]+o),j(r.center,t,0,r.center,n,0,1),h(r.quaternion,e.quaternion),S(r.halfSize,e.halfSize))}function We(e,t,r,n,o){S(_e,t.center),_e[2]+=o;const a=C(r);j(_e,e,0,_e,a,0,1),Ge(a,t,_e,r,n)}const Ae=new Array(24),De=new Z(Ae,3,!0),Fe=I(),_e=I(),Oe=f();function Le(e,t,r,n,o){S(_e,t.center),_e[2]+=o,Ge(e,t,_e,r,n)}function Ge(e,t,r,n,o){const a=u(Oe,t.quaternion);for(let i=0;i<8;++i){for(let e=0;e<3;++e)Fe[e]=t.halfSize[e]*(0!=(i&1<<e)?-1:1);for(let e=0;e<3;++e){let t=r[e];for(let r=0;r<3;++r)t+=Fe[r]*a[3*r+e];Ae[3*i+e]=t}}j(Ae,e,0,Ae,n,0,8),$(De,o)}function Ke(e,t,r,n){Q(e,Xe),g(t.center,e.center[0],e.center[1],e.center[2]+n),q(r,t.center,Je,C(r)),g(t.center,Je[12],Je[13],Je[14]);const o=2*Math.sqrt(1+Je[0]+Je[5]+Je[10]);Ve[0]=(Je[6]-Je[9])/o,Ve[1]=(Je[8]-Je[2])/o,Ve[2]=(Je[1]-Je[4])/o,Ve[3]=.25*o,d(t.quaternion,Ve,e.quaternion),y(Ve,t.quaternion);let a=0,i=0,s=0;for(const l of Xe)l[2]+=n,j(l,r,0,l,C(r),0,1),w(rt,l,t.center),T(rt,rt,Ve),a=Math.max(a,Math.abs(rt[0])),i=Math.max(i,Math.abs(rt[1])),s=Math.max(s,Math.abs(rt[2]));g(t.halfSize,a,i,s)}function Be(e,t,r,n){const o=R(r),a=1+Math.max(0,n)/(o.radius+e.center[2]);g(t.center,e.center[0],e.center[1],e.center[2]+n),j(t.center,r,0,t.center,C(r),0,1),h(t.quaternion,e.quaternion),y(Ve,e.quaternion),g(rt,0,0,1),T(rt,rt,Ve),g(rt,e.halfSize[0]*Math.abs(rt[0]),e.halfSize[1]*Math.abs(rt[1]),e.halfSize[2]*Math.abs(rt[2])),E(rt,rt,o.inverseFlattening),v(t.halfSize,e.halfSize,rt),E(t.halfSize,t.halfSize,a)}function Pe(e,t,r,n,i,s){if(!s||0===s.length||a(t)||!e.mbs)return null;const l=O(e.mbs,i,r,t);p(ot,l);let c=null;const u=()=>{if(!c)if(c=Xe,z(et),o(e.serviceObb)){ze(e.serviceObb,r,tt,t,i),Q(tt,c);for(const e of c)M(e,e,ot),W(et,e)}else{const n=e.mbs;if(!n)return;const o=n[3];U(n,r,rt,t),M(rt,rt,ot),rt[2]+=i;for(let e=0;e<8;++e){const t=1&e?o:-o,r=2&e?o:-o,n=4&e?o:-o,a=c[e];S(a,[rt[0]+t,rt[1]+r,rt[2]+n]),W(et,a)}}};let f=1/0,m=-1/0;const h=e=>{if("replace"!==e.type)return;const r=e.geometry;if(!r?.hasZ)return;z(Ye);const o=r.spatialReference||n,a=r.rings.reduce(((e,r)=>r.reduce(((e,r)=>(U(r,o,rt,t),M(rt,rt,ot),W(Ye,rt),Math.min(rt[2],e))),e)),1/0);u(),A(et,Ye)&&(f=Math.min(f,a),m=Math.max(m,a))};if(s.forEach((e=>h(e))),f===1/0)return null;const d=(e,t,r)=>{M(rt,r,l),e[t+0]=rt[0],e[t+1]=rt[1],e[t+2]=rt[2],t+=24,r[2]=f,M(rt,r,l),e[t+0]=rt[0],e[t+1]=rt[1],e[t+2]=rt[2],t+=24,r[2]=m,M(rt,r,l),e[t+0]=rt[0],e[t+1]=rt[1],e[t+2]=rt[2]};for(let o=0;o<8;++o)d(nt.data,3*o,c[o]);return $(nt)}function $e(e){return o(e)&&e.halfSize[0]>=0}function Qe(e){return e[3]>=0}function Ze(e){o(e)&&(e.halfSize[0]=-1)}function He(e){o(e)&&(e[3]=-1)}const Je=m(),Ve=b(),Xe=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Ye=N(),et=N(),tt=P(),rt=I(),nt={data:new Array(72),size:3,exclusive:!0,stride:3},ot=m();export{re as MbsIntersectResult,ke as SymbolInfo,Ne as addWraparound,Re as checkPointCloudLayerCompatibleWithView,Ie as checkPointCloudLayerValid,ge as checkRecyclable,ve as checkSceneLayerCompatibleWithView,Ee as checkSceneLayerValid,be as checkSpatialReference,we as checkSpatialReferences,Pe as computeVisibilityObb,J as containsDraco,H as extractWkid,X as filterInPlace,oe as findFieldsCaseInsensitive,V as findIntersectingNodes,ye as getCacheKeySuffix,me as getCachedAttributeValue,te as getClipRect,he as getIndexCrs,Ce as getSymbolInfo,de as getVertexCrs,ne as intersectBoundingRectWithMbs,He as invalidateMbs,Ze as invalidateObb,Se as isSupportedLocalModeProjection,Qe as isValidMbs,$e as isValidObb,Y as objectIdFilter,ue as queryAttributesFromCachedAttributesId,qe as rendererNeedsTextures,ze as transformObb,Ue as transparentEdgeMaterial,ae as whenGraphicAttributes};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{AsyncUpdateMixin as r}from"../../../../core/AsyncUpdate.js";import{HandleOwner as s}from"../../../../core/HandleOwner.js";import t from"../../../../core/Logger.js";import{unwrapOr as i}from"../../../../core/maybe.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{fixFields as n,collectLabelingFields as a,collectFilterFields as d}from"../../../../layers/support/fieldUtils.js";const p="esri.views.3d.layers.support.SceneLayerViewRequiredFields";let c=class extends(r(s)){get requiredFields(){const{layerView:{layer:{fieldsIndex:e},definitionExpressionFields:r},rendererFields:s,labelingFields:t,viewFilterFields:o}=this;return n(e,[...i(r,[]),...i(s,[]),...i(t,[]),...i(o,[])])}constructor(e){super(e)}initialize(){
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{AsyncUpdateMixin as r}from"../../../../core/AsyncUpdate.js";import{HandleOwner as s}from"../../../../core/HandleOwner.js";import t from"../../../../core/Logger.js";import{unwrapOr as i}from"../../../../core/maybe.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{fixFields as n,collectLabelingFields as a,collectFilterFields as d}from"../../../../layers/support/fieldUtils.js";const p="esri.views.3d.layers.support.SceneLayerViewRequiredFields";let c=class extends(r(s)){get layer(){return this.layerView.layer}get requiredFields(){const{layerView:{layer:{fieldsIndex:e},definitionExpressionFields:r},rendererFields:s,labelingFields:t,viewFilterFields:o}=this;return n(e,[...i(r,[]),...i(s,[]),...i(t,[]),...i(o,[])])}constructor(e){super(e)}initialize(){this.handles.add([this.autoUpdateAsync("rendererFields",(async()=>{const{fieldsIndex:e,renderer:r}=this.layer;return r?y((s=>r.collectRequiredFields(s,e))):null})),this.autoUpdateAsync("labelingFields",(async()=>{const{layer:e}=this;return e.labelsVisible?y((r=>a(r,e))):null})),this.autoUpdateAsync("viewFilterFields",(()=>{const{layer:e,filter:r}=this.layerView;return y((s=>d(s,e,r)))}))])}};async function y(e){const r=new Set;try{return await e(r),Array.from(r).sort()}catch(s){return t.getLogger(p).error(s),null}}e([o()],c.prototype,"layerView",void 0),e([o()],c.prototype,"layer",null),e([o()],c.prototype,"requiredFields",null),e([o()],c.prototype,"rendererFields",void 0),e([o()],c.prototype,"labelingFields",void 0),e([o()],c.prototype,"viewFilterFields",void 0),c=e([l(p)],c);export{c as SceneLayerViewRequiredFields};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isPowerOfTwo as t,clamp as e}from"../../../core/mathUtils.js";import{isNone as n,isSome as o}from"../../../core/maybe.js";import{s}from"../../../chunks/vec4.js";import{empty as i}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as r}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as a}from"./ElevationData.js";import{PatchType as c,NeighborIndex as l}from"./interfaces.js";import{acquireTerrainAttributes as u,minMaxBoundingBox as f,encodeUVInBuffer as d,encodeNormalToBufferFromValues as g,EdgeDescriptor as m}from"./PatchGeometry.js";import{PatchGeometryLUT as p}from"./PatchGeometryLUT.js";import{neighborTileIfLoadedOrSelf as h}from"./PatchRenderData.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as M,internalAssert as x,neighborEdgeIndices as y,almostEquals as S}from"./terrainUtils.js";import{isCornerNeighbor as v}from"./Tile.js";import{compareTilesByLij as b}from"./tileUtils.js";const L=65536;function R(t,e){const n=t.tile,{extent:o,extentInRadians:s,surface:r}=n,a=t.localOrigin,l=t.geometryState,m=r.isWebMercator,p=r.shading||rt,h=l.numVerticesPerSide,y=h-1,S=(h-2)**2,v=m&&(e===c.HAS_SOUTH_POLE||e===c.HAS_BOTH_POLES),b=m&&(e===c.HAS_NORTH_POLE||e===c.HAS_BOTH_POLES),L=6,R=((v?1:0)+(b?1:0))*L*(y+1),O=l.neighborData,T=O.edgeResolutions.reduce(((t,e)=>t+e+1),0),P=u(S+R+T),D=t.geometryInfo;D.numVerticesPerSide=l.numVerticesPerSide,D.vertexAttributes=P;const I=D.boundingBox;i(I);const U=j(t);nt.update(y,s,U),B(t),X(t,S),V(t);const E=[];if((()=>{let t=S+T;const e=a[0],s=a[1],i=a[2],r=n.ellipsoid.radius,c=o[1],l=o[3],u=(n,o)=>{const a=o*h;f(-e,-s,n*r-i,I),E.push({connectedRowOffset:a,connectedOuterEdgeOffset:1===n?0:2,rowOffset:t,latitudeResolution:L});const u=A(-1===n?c:l,r),m=n*Math.PI/2-u,M=.99*(1===n?1:-1),x=r+0,S=P.position,v=P.uv0,b=P.normalCompressed;for(let r=1;r<=L;++r){const n=u+m*(r/L),o=Math.cos(n),a=Math.sin(n);for(let r=0;r<=y;r++){const n=r/y,c=nt.sinLonLUT[r],l=nt.cosLonLUT[r]*o,u=c*o,m=a,h=l*x-e,L=u*x-s,R=m*x-i;f(h,L,R,I),S.setValues(t,h,L,R),d(v,t,n,M),p&&g(b,t,l,u,m),++t}}};v&&u(-1,0),b&&u(1,y)})(),Q(D,l.numVerticesPerSide,E,[0,h-1],[0,h-1],l.wireframe),t.intersectionData=null,M)for(let i=0;i<4;++i)x(D.outerEdges[i].count===O.edgeResolutions[i]+1)}function B(t){const e=t.tile;e.intersectsClippingArea&&(e.surface.shading||rt?T(t):O(t))}function O(t){const e=t.geometryState,n=e.numVerticesPerSide,o=n-2,s=n-1,i=t.geometryInfo,r=i.vertexAttributes,c=r.position,l=r.uv0,u=t.tile,g=u.extent,m=g[0],p=g[2],h=g[1],M=g[3],x=u.ellipsoid.radius,y=e.samplerData,S=t.localOrigin,v=S[0],b=S[1],L=S[2],R=i.boundingBox,B=c.typedBuffer,O=c.typedBufferStride;let T=0;for(let P=1;P<=o;P++){const t=P/s,e=h*(1-t)+M*t,n=nt.sinLatLUT[P],i=nt.cosLatLUT[P];for(let r=1;r<=o;r++){const o=r/s,c=m*(1-o)+p*o,u=nt.sinLonLUT[r],g=nt.cosLonLUT[r],h=x+a(c,e,y),M=g*i*h-v,S=u*i*h-b,P=n*h-L;f(M,S,P,R);const D=T*O;B[D]=M,B[D+1]=S,B[D+2]=P,d(l,T,o,t),++T}}}function T(t){const e=t.geometryState,n=e.numVerticesPerSide,o=n-2,s=n-1,i=t.geometryInfo,r=i.vertexAttributes,c=r.position,l=r.uv0,u=r.normalCompressed,m=t.tile,p=m.extent,h=p[0],M=p[2],x=p[1],y=p[3],S=m.ellipsoid.radius,v=e.samplerData,b=t.localOrigin,L=b[0],R=b[1],B=b[2],O=c.typedBuffer,T=c.typedBufferStride,P=1/s,D=i.boundingBox;let V=0;if(1<=o){const t=P,e=x*(1-t)+y*t,n=nt.sinLatLUT[1],s=nt.cosLatLUT[1];for(let i=1;i<=o;i++){const o=i*P,r=h*(1-o)+M*o,c=nt.sinLonLUT[i],u=nt.cosLonLUT[i],g=S+a(r,e,v),m=g*u*s-L,p=g*c*s-R,x=g*n-B;f(m,p,x,D);const y=(i-1)*T;O[y]=m,O[y+1]=p,O[y+2]=x,d(l,i-1,o,t)}}for(let I=1;I<=o;I++){const t=I*P,e=x*(1-t)+y*t,n=nt.sinLatLUT[I],i=nt.cosLatLUT[I],r=I+1,c=r*P,m=x*(1-c)+y*c,p=nt.sinLatLUT[r],b=nt.cosLatLUT[r],U=nt.sinLonLUT[0],A=nt.cosLonLUT[0],E=S+a(h,e,v);let C=A*i*E-L,j=U*i*E-R,w=n*E-B;const N=V*T;let H=O[N],_=O[N+1],W=O[N+2];for(let y=1;y<=o;y++){const t=y*P,r=h*(1-t)+M*t,U=nt.sinLonLUT[y],A=nt.cosLonLUT[y],E=A*i,N=U*i,q=n;let F=0,z=0,G=0;{let t=0,r=0,c=0;if(y<o){const e=(V+1)*T;t=O[e],r=O[e+1],c=O[e+2]}else{const o=nt.sinLonLUT[s],l=nt.cosLonLUT[s],u=S+a(M,e,v);t=l*i*u-L,r=o*i*u-R,c=n*u-B}const l=C,u=j,f=w;C=H,j=_,w=W,H=t,_=r,W=c;const d=t-l,g=r-u,m=c-f,p=g*q-m*N,h=m*E-d*q,x=d*N-g*E;F=h*m-x*g,z=x*d-p*m,G=p*g-h*d}{let e=0,n=0,s=0;if(I>1){const t=(V-o)*T;e=O[t],n=O[t+1],s=O[t+2]}else{const t=nt.sinLatLUT[0],o=nt.cosLatLUT[0],i=S+a(r,x,v);e=A*o*i-L,n=U*o*i-R,s=t*i-B}{const i=S+a(r,m,v),u=A*b*i-L,g=U*b*i-R,h=p*i-B;if(I<o){const e=V+o,n=e*T;O[n]=u,O[n+1]=g,O[n+2]=h,f(u,g,h,D),d(l,e,t,c)}const M=e-u,x=n-g,y=s-h,P=x*q-y*N,C=y*E-M*q,j=M*N-x*E;F+=C*y-j*x,z+=j*M-P*y,G+=P*x-C*M}}const k=1/Math.sqrt(F*F+z*z+G*G);g(u,V,F*k,z*k,G*k),++V}}}function P(t){t.tile.intersectsClippingArea&&(V(t),tt(t))}function D(t){t.tile.intersectsClippingArea&&(U(t),I(t,!0),tt(t))}function V(t){t.tile.intersectsClippingArea&&(U(t),I(t))}function I(e,s=!1){const i=e.geometryState,r=e.geometryInfo,c=i.neighborData,l=e.tile,u=l.level,g=l.extent,m=l.ellipsoid.radius,p=l.extentInRadians,v=p[0],L=p[2],R=p[1],B=p[3],O=i.samplerData,T=g[0],P=g[2],D=g[1],V=g[3],I=j(e),U=r.boundingBox,A=e.localOrigin,E=A[0],C=A[1],w=A[2],N=l.surface.shading||rt,H=r.vertexAttributes,_=H.position,W=_.typedBuffer,q=_.typedBufferStride,F=H.uv0;for(let j=0;j<4;++j){const i=1===j||3===j,p=c.edgeResolutions[j];x(t(p));const A=p+1,H=h(l,c.edgePeerNeighbors[j]);if(it(l,H,j)){Y(e,j,H);continue}const _=o(H);x(!_||H.level===l.level),x(!_||b(l,H)<=0);const z=H?.renderData,G=z?.geometryState;if(M){const t=l.surface;if(!H&&t&&!t.updatingRootTiles){const e=y[j],o=l.findNeighborTile(e,(t=>t.isLoaded||t.isLeaf||t.level===l.level));o?o.intersectsClippingArea&&(x(!o.isLoaded),x(!o.isLeaf),x(o.level===u)):x(n(t?.rootTiles)||!l.shouldHaveNeighbor(e))}}const k=1===j?g[2]:g[0],J=H?.extent,K=J&&i?1===j?J[0]:J[2]:k,Q=0===j?g[3]:g[1],X=1===j?1:0,Z=0===j?1:0,$=1===j?L:v,tt=0===j?B:R,et=Math.sin($),nt=Math.cos($),ot=Math.sin(tt),st=Math.cos(tt),rt=G?.samplerData,at=_?(t,e,n)=>.5*(a(t,e,O)+a(n,e,rt)):(t,e,n)=>a(t,e,O),ct=r.outerEdges[j],lt=s&&A>3?A-3:1,ut=o(O)&&O.some((t=>null!=t)),ft=o(rt)&&rt.some((t=>null!=t)),dt=ut||ft,gt=1/p,mt=ct.index0;if(N){x(!J||S(J[2]-J[0],g[2]-g[0]));(()=>{const t=1===j?-1:3===j?1:0,e=0===j?-1:2===j?1:0,n=(g[2]-g[0])*gt,o=t*n,s=e*n,r=i?t*((L-v)*gt):0,c=i?0:e*gt,l=Z,u=i?$+r:$,p=i?Math.sin(u):et,h=i?Math.cos(u):nt,M=i?$-r:$,x=i?Math.sin(M):et,y=i?Math.cos(M):nt,S=i?tt:I(l+c),b=i?ot:Math.sin(S),R=i?st:Math.cos(S),B=i?tt:I(l-c),N=i?ot:Math.sin(B),H=i?st:Math.cos(B),z=(mt+0)*q;let G=W[z]+E,J=W[z+1]+C,Y=W[z+2]+w,it=0,ut=0,ft=0;{const t=1*gt,e=i?k:T*(1-t)+P*t,n=i?K:e,o=i?D*(1-t)+V*t:Q,s=i?$:v*(1-t)+L*t,r=i?et:Math.sin(s),a=i?nt:Math.cos(s),c=i?I(t):tt,l=i?Math.sin(c):ot,u=i?Math.cos(c):st,f=m+at(e,o,n);it=a*u*f,ut=r*u*f,ft=l*f}for(let g=1;g<A-1;g+=lt){let t=0,e=0,n=0;{const o=(mt+g+1)*q;if(g<A-2){const o=(g+1)*gt,s=i?k:T*(1-o)+P*o,r=i?K:s,a=i?D*(1-o)+V*o:Q,c=i?$:v*(1-o)+L*o,l=i?et:Math.sin(c),u=i?nt:Math.cos(c),f=i?I(o):tt,d=i?Math.sin(f):ot,p=i?Math.cos(f):st,h=m+at(s,a,r);t=u*p*h,e=l*p*h,n=d*h}else t=W[o]+E,e=W[o+1]+C,n=W[o+2]+w}const r=t,c=e,l=n,u=it,M=ut,S=ft;it=r,ut=c,ft=l;{const t=mt+g,e=t*q,n=u-E,o=M-C,s=S-w;W[e]=n,W[e+1]=o,W[e+2]=s,f(n,o,s,U);const r=g*gt;d(F,t,i?X:r,i?r:Z)}const B=G,j=J,z=Y;G=u,J=M,Y=S;const lt=u,pt=M,ht=S;let Mt=0,xt=0,yt=0;if(dt){const t=1/Math.sqrt(lt*lt+pt*pt+ht*ht),e=lt*t,n=pt*t,u=ht*t;{const t=r-B,o=c-j,s=l-z,i=o*u-s*n,a=s*e-t*u,f=t*n-o*e;Mt+=a*s-f*o,xt+=f*t-i*s,yt+=i*o-a*t}{const t=g*gt,r=i?k:T*(1-t)+P*t,c=i?K:r,l=i?D*(1-t)+V*t:Q,f=i?$:v*(1-t)+L*t,d=i?et:Math.sin(f),M=i?nt:Math.cos(f),S=i?I(t):tt,B=i?Math.sin(S):ot,U=i?Math.cos(S):st;let A=lt,E=pt,C=ht;if(_){const t=m+a(c-o,l-s,rt),e=i?U:H;A=(i?y:M)*e*t,E=(i?x:d)*e*t,C=(i?B:N)*t}{const t=m+a(r+o,l+s,O),c=i?U:R,f=(i?h:M)*c*t,g=(i?p:d)*c*t,x=(i?B:b)*t;_||(A=2*lt-f,E=2*pt-g,C=2*ht-x);const y=A-f,S=E-g,v=C-x,L=S*u-v*n,T=v*e-y*u,P=y*n-S*e;Mt+=T*v-P*S,xt+=P*y-L*v,yt+=L*S-T*y}}}else Mt=lt,xt=pt,yt=ht;const St=1/Math.sqrt(Mt*Mt+xt*xt+yt*yt);ct.setNormalFromValues(g,Mt*St,xt*St,yt*St)}})()}else{(()=>{for(let t=1;t<A-1;t+=lt){const e=t*gt,n=i?X:e,o=i?e:Z,s=i?k:T*(1-e)+P*e,r=i?D*(1-e)+V*e:Q,a=i?K:s,c=i?$:v*(1-e)+L*e,l=i?et:Math.sin(c),u=i?nt:Math.cos(c),g=i?I(e):tt,p=i?Math.sin(g):ot,h=i?Math.cos(g):st,M=at(s,r,a),x=m+M,y=u*h*x-E,S=l*h*x-C,b=p*x-w;f(y,S,b,U);const R=mt+t,B=R*q;W[B]=y,W[B+1]=S,W[B+2]=b,d(F,R,n,o)}})()}}}function U(t){Z(t)}function A(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function E(t,e,n,o){return A(t*(1-o)+e*o,n)}function C(t,e,n){return t*(1-n)+e*n}function j(t){const e=t.tile;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>E(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>C(n[1],n[3],t)}function w(t,e){const n=t.tile.extent,r=t.geometryState,a=n[0],c=n[1],l=n[2]-a,f=n[3]-c,d=r.clippingArea,g=o(d)?Math.max(0,(d[0]-a)/l):0,m=o(d)?Math.max(0,(d[1]-c)/f):0,p=o(d)?Math.min(1,(d[2]-a)/l):1,h=o(d)?Math.min(1,(d[3]-c)/f):1,M=r.numVerticesPerSide,x=(M-2)**2,y=r.neighborData.edgeResolutions.reduce(((t,e)=>t+e+1),0),S=u(x+y),v=t.geometryInfo,b=v.boundingBox;i(b),v.numVerticesPerSide=r.numVerticesPerSide,v.vertexAttributes=S,s(v.uvRange,g,m,p,h),N(t),X(t,x),F(t),Q(v,r.numVerticesPerSide,[],[0,M-1],[0,M-1],r.wireframe),t.intersectionData=null}function N(t){const e=t.tile;e.intersectsClippingArea&&(e.surface.shading?_(t):H(t))}function H(t){const n=t.geometryState,s=n.samplerData,i=t.tile,r=i.surface,c=t.localOrigin,l=r.isWebMercatorOnPlateeCarree,u=n.clippingArea,g=o(u)?u:ot,m=i.extent,p=m[0],h=m[1],M=m[2],x=m[3],y=Math.max(p,g[0]),S=Math.min(M,g[2]),v=Math.max(h,g[1]),b=Math.min(x,g[3]),L=c[0],R=c[1],B=c[2],O=i.ellipsoid.radius,T=i.horizontalScale,P=K(l,O,T),D=n.numVerticesPerSide,V=D-1,I=D-2,U=t.geometryInfo,A=U.uvRange,E=A[0],C=A[1],j=A[2],w=A[3],N=U.boundingBox,H=U.vertexAttributes,_=H.position,W=H.uv0;let q=0;for(let o=1;o<=I;o++){const t=o/V,n=e(h*(1-t)+x*t,v,b),i=e(t,C,w),r=P(n)-R;for(let o=1;o<=I;o++){const t=o/V,c=e(p*(1-t)+M*t,y,S),l=e(t,E,j),u=c*T-L,g=a(c,n,s)-B;f(u,r,g,N),_.setValues(q,u,r,g),d(W,q,l,i),++q}}}function _(t){const n=t.tile,s=n.surface;if(!(s.shading||rt))return;const i=t.geometryState,r=i.samplerData,c=t.localOrigin,l=s.isWebMercatorOnPlateeCarree,u=i.clippingArea,m=o(u)?u:ot,p=n.extent,h=p[0],M=p[1],x=p[2],y=p[3],S=Math.max(h,m[0]),v=Math.min(x,m[2]),b=Math.max(M,m[1]),L=Math.min(y,m[3]),R=n.ellipsoid.radius,B=n.horizontalScale,O=i.numVerticesPerSide,T=O-1,P=O-2,D=t.geometryInfo,V=D.vertexAttributes,I=V.position,U=V.uv0,A=V.normalCompressed,E=D.uvRange,C=E[0],j=E[1],w=E[2],N=E[3],H=D.boundingBox,_=c[0],W=c[1],q=c[2],F=I.typedBuffer,z=I.typedBufferStride;let G=0;const k=e(M,b,L),J=l?(Math.PI/2-2*Math.atan(Math.exp(-k/R)))*R:k*B,K=1/T,Q=e(M*(1-K)+y*K,b,L);let X=J,Y=l?(Math.PI/2-2*Math.atan(Math.exp(-Q/R)))*R:Q*B;for(let o=1;o<=P;o++){const t=o/T,n=e(M*(1-t)+y*t,b,L),s=e(t,j,N),i=Y,c=(o-1)/T,u=e(M*(1-c)+y*c,b,L),m=X,p=(o+1)/T,O=e(M*(1-p)+y*p,b,L),D=l?(Math.PI/2-2*Math.atan(Math.exp(-O/R)))*R:O*B,V=e(p,j,N);X=Y,Y=D;const I=e(h,S,v);let E=I*B,k=a(I,n,r);const J=1/T,K=e(J,C,w),Q=e(h*(1-K)+x*K,S,v);let Z=K,$=Q,tt=Q*B,et=a(Q,n,r);if(1===o){const t=tt-_,n=X-W,o=et-q,i=0*z;F[i]=t,F[i+1]=n,F[i+2]=o,f(t,n,o,H);const r=e(J,C,w);d(U,G,r,s)}for(let l=1;l<=P;l++){const t=tt,c=et,p=(l+1)/T,M=e(p,C,w),y=e(h*(1-p)+x*p,S,v),b=$;$=y;{const t=G+1,e=t*z;if(1===o||l===P){const c=y*B,u=a(y,n,r);if(1===o&&l<P){const n=c-_,o=i-W,r=u-q;F[e]=n,F[e+1]=o,F[e+2]=r,f(n,o,r,H),d(U,t,M,s)}tt=c,et=u}else tt=F[e]+_,et=F[e+2]+q}const L=tt,R=et,I=E,j=k;E=t,k=c;const N=(G-P)*z,J=1===o?a(b,u,r):F[N+2]+q,K=a(b,O,r);if(o<P){const e=G+P,n=e*z,o=t-_,s=D-W,i=K-q;F[n]=o,F[n+1]=s,F[n+2]=i,f(o,s,i,H);const r=Z;Z=M,d(U,e,r,V)}{const t=L-I,e=-t*(R-j),n=m-D,o=-n*(J-K),s=t*t+n*n,i=e*e+o*o+s*s;if(0===i)g(A,G,0,0,1);else{const t=1/Math.sqrt(i);g(A,G,e*t,o*t,s*t)}}++G}}}function W(t,e){t.tile.intersectsClippingArea&&(G(t),z(t,!0),tt(t))}function q(t,e){t.tile.intersectsClippingArea&&(F(t),tt(t))}function F(t,e){t.tile.intersectsClippingArea&&(G(t),z(t,!1))}function z(s,i){const r=s.geometryState,c=r.neighborData,l=s.tile,u=l.surface,d=u.shading||rt,g=l.extent,m=r.clippingArea,p=o(m)?m:ot,S=g[0],v=g[2],L=g[1],R=g[3],B=[R>p[3],v>p[2],L<p[1],S<p[0]],O=s.geometryInfo,T=l.horizontalScale,P=K(u.isWebMercatorOnPlateeCarree,l.ellipsoid.radius,T),D=O.boundingBox,V=O.uvRange[0],I=O.uvRange[1],U=O.uvRange[2],A=O.uvRange[3],E=Math.max(S,p[0]),C=Math.min(v,p[2]),j=Math.max(L,p[1]),w=Math.min(R,p[3]),N=s.localOrigin,H=N[0],_=N[1],W=N[2],q=r.samplerData;for(let F=0;F<4;++F){const r=1===F||3===F,g=c.edgeResolutions[F];x(t(g));const m=g+1,p=B[F],N=h(l,c.edgePeerNeighbors[F]);if(!p&&it(l,N,F)){Y(s,F,N);continue}const z=o(N)&&!p,G=N?.renderData,k=G?.geometryState;if(M&&(x(!z||N.level===l.level),x(!z||b(l,N)<=0),l&&!N&&!u.updatingRootTiles)){const t=y[F],e=l.findNeighborTile(t,(t=>t.isLoaded||t.isLeaf||t.level===l.level));u.updatingRootTiles||(e?e.intersectsClippingArea&&(x(!e.isLoaded),x(!e.isLeaf),x(e.level===l.level)):x(n(u?.rootTiles)||!l.shouldHaveNeighbor(t)))}const J=e(1===F?v:S,E,C),K=e(0===F?R:L,j,w),Q=k?.samplerData,X=O.outerEdges[F],Z=i&&m>3?m-3:1,$=e(1===F?1:0,V,U),tt=e(0===F?1:0,I,A),et=z?(t,e)=>.5*(a(t,e,Q)+a(t,e,q)):(t,e)=>a(t,e,q);if(d){const t=(v-S)/g,n=r?1===F?t:-t:0,o=r?0:0===F?t:-t,s=-n,i=-o,c=X.attributes.position.typedBuffer,l=X.attributes.position.typedBufferStride,u=X.index0,d=X.stride,p=u*l;let h=c[p]+H,M=c[p+1]+_,x=c[p+2]+W,y=0,b=0,B=0;{const t=1/g,n=r?J:e(S*(1-t)+v*t,E,C),o=r?e(L*(1-t)+R*t,j,w):K,s=et(n,o);y=n*T,b=P(o),B=s}for(let O=1;O<m-1;O+=Z){const t=O/g,p=y,N=b,F=B;{const n=r?$:e(t,V,U),o=r?e(t,I,A):tt,s=p-H,i=N-_,a=F-W;f(p,i,a,D),X.setVertexFromValuesRawPositionUV(O,s,i,a,n,o)}const G=O+1;if(O===m-1){const t=(u+G*d)*l;y=c[t]+H,b=c[t+1]+_,B=c[t+2]+W}else{const t=G/g,n=r?J:e(S*(1-t)+v*t,E,C),o=r?e(L*(1-t)+R*t,j,w):K,s=et(n,o);y=n*T,b=P(o),B=s}const k=y,Y=B,Z=h,nt=M,ot=x;h=p,M=N,x=F;let st=0,it=0,rt=0;if(r){{const t=b-N,e=nt-N;it-=e*(ot-F)+t*(Y-F),rt+=e*e+t*t}{const o=e(L*(1-t)+R*t,j,w),i=J+s,r=i*T-p;if(st-=r*(a(i,o,q)-F),rt+=r*r,z){const t=J+n,e=t*T-p;st-=e*(a(t,o,Q)-F),rt+=e*e}}}else{{const t=k-p,e=Z-p;st-=t*(Y-F)+e*(ot-F),rt+=t*t+e*e}{const n=e(S*(1-t)+v*t,E,C),s=K+i,r=a(n,s,q)-F,c=P(s)-N;if(it-=c*r,rt+=c*c,z){const t=n,e=K+o,s=P(e)-N;it-=s*(a(t,e,Q)-F),rt+=s*s}}}const at=1/Math.sqrt(st*st+it*it+rt*rt);X.setNormalFromValues(O,st*at,it*at,rt*at)}}else for(let t=1;t<m-1;t+=Z){const n=t/g,o=r?J:e(S*(1-n)+v*n,E,C),s=r?e(L*(1-n)+R*n,j,w):K,i=r?$:e(n,V,U),a=r?e(n,I,A):tt,c=et(o,s),l=o*T-H,u=P(s)-_,d=c-W;f(l,u,d,D),X.setVertexFromValuesRawPositionUV(t,l,u,d,i,a)}}}function G(t,e){Z(t)}function k(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function J(t,e){return t*e}function K(t,e,n){return t?t=>k(t,e):t=>J(t,n)}function Q(t,e,n,o,s,i){const r=e-1,a=t.vertexAttributes.count,c=2*(Math.min(e-2,o[1])-Math.max(1,o[0]))*(Math.min(e-2,s[1])-Math.max(1,s[0])),l=y.map(((t,n)=>0===n&&s[1]<e-2||1===n&&o[1]<e-2||2===n&&s[0]>1||3===n&&o[0]>1)),u=t.outerEdges.reduce(((t,e,n)=>t+(l[n]?0:r-2+e.count-1)),0),f=n.reduce(((t,e)=>t+r*(2*(e.latitudeResolution-1)+1)),0),d=i?2:1,g=3*(c+u+f)*d,m=a>=L?new Uint32Array(g):new Uint16Array(g);let p=0;const h=e-2,S=r-2;if(x(S>=0),i){const i=(t,e,n)=>{m[p++]=t,m[p++]=e,m[p++]=e,m[p++]=n,m[p++]=n,m[p++]=t,M&&(x(t<a),x(e<a),x(n<a),x(p<=g))};(()=>{for(let t=Math.max(s[0],1)-1;t<Math.min(s[1],e-2)-1;++t)for(let n=Math.max(o[0],1)-1;n<Math.min(o[1],e-2)-1;++n){const e=t*h+n,o=e+1,s=o+h,r=s-1;i(e,o,s),i(s,r,e)}})(),x(p===3*c*d);(()=>{for(let e=0;e<4;++e){const n=p;if(l[e])continue;const o=t.outerEdges[e],s=t.innerEdges[e];let a=0,c=0;const u=o.count,f=s.count;x(f===r-1);let g=0;const m=1===e||2===e?(t,e,n)=>i(t,e,n):(t,e,n)=>i(t,n,e);for(;a<u-1||c<f-1;){const t=s.getVertexIndex(c),e=o.getVertexIndex(a),n=a<u-1,i=c<f-1;if(n&&(!i||(n?0+r*(a+.5)/(u-1):0)<=(i?1+S*(c+.5)/(f-1):0))){++a,M&&x(a<u);m(t,e,o.getVertexIndex(a)),g++}else{++c,M&&x(c<f);m(t,e,s.getVertexIndex(c)),g++}}M&&(x(a===u-1),x(c===f-1),x(g===u+f-2),x(g===r-2+o.count-1),x(p===n+3*g*d))}})(),x(p===3*(c+u)*d);const f=n=>{const o=t.outerEdges[n.connectedOuterEdgeOffset];let s=o.getVertexIndex(0),a=o.stride;for(let t=0;t<n.latitudeResolution;++t){const o=0===t?n.rowOffset:s+e;for(let e=0;e<r;e++)i(s,s+1,o+e),t<n.latitudeResolution-1&&i(s+1,o+e+1,o+e),s+=a;s=o,a=1}};(()=>n.forEach(f))()}else{(()=>{const t=Math.max(s[0],1)-1,n=Math.min(s[1],e-2)-1,i=Math.max(o[0],1)-1,r=Math.min(o[1],e-2)-1;for(let e=t;e<n;++e){const t=e*h;for(let e=i;e<r;++e){const n=t+e,o=n+1,s=o+h,i=s-1;m[p]=n,m[p+1]=o,m[p+2]=s,m[p+3]=s,m[p+4]=i,m[p+5]=n,p+=6}}})(),x(p===3*c*d);(()=>{for(let e=0;e<4;++e){if(l[e])continue;const n=t.outerEdges[e],o=t.innerEdges[e];let s=0,i=0;const a=n.count,c=o.count;x(c===r-1);const u=1===e||2===e,f=u?1:2,d=u?2:1,g=n.index0,h=n.stride,M=o.index0,y=o.stride;for(;s<a-1||i<c-1;){const t=M+i*y,e=g+s*h,n=s<a-1,o=i<c-1,l=n&&(!o||(n?0+r*(s+.5)/(a-1):0)<=(o?1+S*(i+.5)/(c-1):0));l?++s:++i;const u=l?e+h:t+y;m[p]=t,m[p+f]=e,m[p+d]=u,p+=3}}})(),x(p===3*(c+u)*d);const i=n=>{const o=t.outerEdges[n.connectedOuterEdgeOffset];let s=o.getVertexIndex(0),i=o.stride;for(let t=0;t<n.latitudeResolution;++t){const o=0===t?n.rowOffset:s+e;for(let e=0;e<r;e++){const r=o+e;m[p]=s,m[p+1]=s+1,m[p+2]=r,t<n.latitudeResolution-1?(m[p+3]=s+1,m[p+4]=r+1,m[p+5]=r,p+=6):p+=3,s+=i}s=o,i=1}};(()=>n.forEach(i))()}x(p===g),t.indices=m,t.indexCount=g}function X(t,e){const n=t.localOrigin,o=t.geometryInfo,s=t.geometryState.neighborData.edgeResolutions,i=o.numVerticesPerSide-2,r=o.vertexAttributes;let a=e;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),s=(t?0:1)*i+(t?1:0);o.innerEdges[c]=new m(r,n,e,s,i)}{const t=a,e=s[c]+1;o.outerEdges[c]=new m(r,n,t,1,e),a+=e}}}function Y(n,o,s){const i=(o+2)%4,r=n.geometryState,a=n.tile,c=r.neighborData,l=a.level-s.level,u=1===o||3===o,g=c.edgeResolutions[o];x(t(g));const m=g+1,p=n.geometryInfo,h=p.boundingBox,M=p.outerEdges[o],y=p.uvRange[0],S=p.uvRange[1],v=p.uvRange[2],b=p.uvRange[3],L=e(1===o?1:0,y,v),R=e(0===o?1:0,S,b),B=s.renderData,O=B.geometryState,T=B.geometryInfo.outerEdges[i],P=a.getNeighborEdgeStartVertexIndex(o,s)*g,D=g*2**l;x(O.neighborData.edgeResolutions[i]===D),x(T.count-1===D);const V=B.localOrigin[0]-n.localOrigin[0],I=B.localOrigin[1]-n.localOrigin[1],U=B.localOrigin[2]-n.localOrigin[2],A=M.attributes,E=M.index0,C=M.stride,j=A.position.typedBuffer,w=A.position.typedBufferStride,N=A.normalCompressed.typedBuffer,H=A.normalCompressed.typedBufferStride,_=A.uv0,W=T.attributes,q=T.index0,F=T.stride,z=W.position.typedBuffer,G=W.position.typedBufferStride,k=W.normalCompressed.typedBuffer,J=W.normalCompressed.typedBufferStride;for(let t=1;t<m-1;++t){const n=E+C*t,o=q+F*(P+t),s=n*w,i=o*G,r=z[i]+V,a=z[i+1]+I,c=z[i+2]+U;j[s]=r,j[s+1]=a,j[s+2]=c,f(r,a,c,h);const l=n*H,m=o*J;N[l]=k[m],N[l+1]=k[m+1];const p=t/g,M=u?L:e(p,y,v),x=u?e(p,S,b):R;d(_,n,M,x)}}function Z(t){const n=t.geometryState,s=n.neighborData,i=t.localOrigin,r=s.cornerNeighborData,c=t.geometryInfo,l=c.outerEdges,u=c.boundingBox,g=t.tile,m="local"===t.tile.surface.view?.viewingMode,p=g.ellipsoid.radius,h=g.extentInRadians,M=g.horizontalScale;let y=0,S=0,v=0,L=0,R=0,B=0;const O=(t,e,n)=>{const o=h[0===e?1:3],s=h[0===t?0:2],i=Math.cos(o),r=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=p+n;y=c*i*l,S=a*i*l,v=r*l},T=m?(()=>{const n=t.geometryState.clippingArea,s=g.extent,i=o(n)&&(s[3]>n[3]||s[2]>n[2]||s[1]<n[1]||s[0]<n[0]),r=K(g.surface.isWebMercatorOnPlateeCarree,g.ellipsoid.radius,M);return(t,o,s)=>{const a=0===t?A[0]:A[2],c=0===o?A[1]:A[3],l=i?e(a,n[0],n[2]):a,u=i?e(c,n[1],n[3]):c,f=s;y=l*M,S=r(u),v=f}})():O;let P=0,D=0,V=0;const I=m&&t.tile.surface.isWebMercatorOnPlateeCarree,U=(t,e,n,o)=>{if(m){const t=e*M,s=I?(Math.PI/2-2*Math.atan(Math.exp(-n/p)))*p:n*M,i=t-y,r=s-S,a=o-v;P+=-i*a,D+=-r*a,V+=i*i+r*r}else{const s=j(t),i=t.tile,r=i.extent,a=i.extentInRadians,c=(e-r[0])/(r[2]-r[0]),l=(n-r[1])/(r[3]-r[1]),u=a[0]*(1-c)+a[2]*c,f=s(l),d=Math.cos(f),g=Math.sin(f),m=Math.sin(u),h=Math.cos(u),M=p+o,x=h*d*M-y,b=m*d*M-S,O=g*M-v,T=b*B-O*R,I=O*L-x*B,U=x*R-b*L;P+=I*O-U*b,D+=U*x-T*O,V+=T*b-I*x}},A=g.extent,E=n.clippingArea,C=o(E)?E:ot,w=A[0],N=A[2],H=A[1],_=A[3],W=[_>C[3],N>C[2],H<C[1],w<C[0]],q=Math.max(w,C[0]),F=Math.min(N,C[2]),z=Math.max(H,C[1]),G=Math.min(_,C[3]),k=c.uvRange[0],J=c.uvRange[1],Q=c.uvRange[2],X=c.uvRange[3],Y=g.surface.shading||rt,Z=t=>{if(!m){const t=1/Math.sqrt(y*y+S*S+v*v);L=y*t,R=S*t,B=v*t}const e=r[t].cornerTiles;P=0,D=0,V=0;let n=1/0;for(let r=0;r<4;++r)n=Math.min(n,e[r]?.level??1/0);for(let r=0;r<4;++r){const t=e[r];st[r]=t?.level===n?t:null}let o=1,s=0;for(let r=0;r<4;++r){const t=st[r];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),s=t.extent[2]-t.extent[0])}const i=s,c=o;x(c>1);const l=i/c;for(let r=0;r<4;++r){const t=st[(r+3)%4],e=st[r%4];if(!t&&!e)continue;const n=0===r?1:1===r?2:2===r?3:0,o=0===r?2:1===r?3:2===r?0:1;if(t&&e){const s=et[r][0]*l,i=et[r][1]*l,c=t.extent,u=c[0===n||1===n?2:0]+s,f=c[0===n||3===n?3:1]+i,d=e.extent,g=d[0===o||1===o?2:0]+s,m=d[0===o||3===o?3:1]+i,p=t.renderData,h=e.renderData,M=a(u,f,p.geometryState.samplerData),x=a(g,m,h.geometryState.samplerData);U(p,u,f,.5*(M+x))}else{const s=t??e,i=t?n:o,c=s.extent,u=et[r],f=c[0===i||1===i?2:0]+u[0]*l,d=c[0===i||3===i?3:1]+u[1]*l,g=s.renderData,m=a(f,d,g.geometryState.samplerData);U(g,f,d,m)}}const u=1/Math.sqrt(P*P+D*D+V*V);P*=u,D*=u,V*=u};for(let o=0;o<4;++o){const s=o,c=(o+1)%4,m=0===o||1===o?1:0,p=0===o||3===o?1:0,h=e(m,k,Q),M=e(p,J,X),L=l[s],R=0===o||3===o?L.count-1:0,B=l[c],O=0===o||1===o?B.count-1:0,I=r[o].cornerTiles;let U=-1;for(let t=0;t<4;++t){const e=I[t];e&&(-1===U||b(I[U],e)>0)&&(U=t)}const A=U,E=I[A];if(P=0,D=0,V=1,E!==g){const e=g.level-E.level,n=2**e,s=[E.lij[0]+e,E.lij[1]*n,E.lij[2]*n],i=[s[1]+n===g.lij[1],0===o&&(1===A||0===A&&E!==I[3])||1===o&&(0===A||1===A&&E!==I[2]),s[1]===g.lij[1]+1,2===o&&(3===A||2===A&&E!==I[1])||3===o&&(2===A||3===A&&E!==I[0])],r=i.reduce(((t,e)=>t+(e?1:0)),0);x(1===r||2===r);let a=-1,c=-1;const l=E.renderData;if(1===r){const e=i.findIndex((t=>t));x(0<=e&&e<=3),a=(e+2)%4;const n=t.geometryState.neighborData.edgeResolutions[e];c=g.getNeighborEdgeStartVertexIndex(e,E)*n+n*(0===e&&0===o||1===e&&0===o||2===e&&1===o||3===e&&3===o?1:0)}else{x(i[1]||i[3]),a=i[1]?3:1;const t=l.geometryState.neighborData.edgeResolutions[a];c=0===o||3===o?0:t}const m=l.geometryInfo.outerEdges[a];{const e=L.index0+R*L.stride,n=B.index0+O*B.stride,o=m.index0+c*m.stride;{const s=m.attributes.position,i=s.typedBuffer,r=o*s.typedBufferStride,a=t.localOrigin,c=m.localOrigin,l=i[r]+c[0]-a[0],d=i[r+1]+c[1]-a[1],g=i[r+2]+c[2]-a[2];f(l,d,g,u);{const t=L.attributes.position,n=t.typedBuffer,o=e*t.typedBufferStride;n[o]=l,n[o+1]=d,n[o+2]=g}{const t=B.attributes.position,e=t.typedBuffer,o=n*t.typedBufferStride;e[o]=l,e[o+1]=d,e[o+2]=g}}d(L.attributes.uv0,e,h,M),d(B.attributes.uv0,n,h,M);{const t=m.attributes.normalCompressed.typedBuffer,s=o*m.attributes.normalCompressed.typedBufferStride;{const n=L.attributes.normalCompressed,o=n.typedBuffer,i=e*n.typedBufferStride;o[i]=t[s],o[i+1]=t[s+1]}{const e=B.attributes.normalCompressed,o=e.typedBuffer,i=n*e.typedBufferStride;o[i]=t[s],o[i+1]=t[s+1]}}}}else{const t=W[s],r=W[c];let l;if(t||r){const t=e(w*(1-m)+N*m,q,F),o=e(H*(1-p)+_*p,z,G),s=n.samplerData;l=a(t,o,s)}else l=$(I);T(m,p,l),(Y||rt)&&Z(o);const d=y-i[0],g=S-i[1],x=v-i[2];f(d,g,x,u),L.setVertexFromValuesRawPositionUVNormal(R,d,g,x,h,M,P,D,V),B.setVertexFromValuesRawPositionUVNormal(O,d,g,x,h,M,P,D,V)}}for(let e=0;e<4;++e)st[e]=null}function $(t){const e=t.reduce(((t,e)=>Math.min(t,e?.level??1/0)),1/0);M&&(x(!t[0]||!t[2]||v(t[0],t[2],l.SOUTH_WEST)),x(!t[1]||!t[3]||v(t[1],t[3],l.NORTH_WEST)));let n=0,o=0;for(let i=0;i<4;++i){const s=t[i];if(s&&s.level===e){const t=0===i||1===i,e=0===i||3===i,r=s.extent,c=r[t?0:2],l=r[e?1:3],u=s.renderData?.geometryState?.samplerData;o+=a(c,l,u),n++}}const s=n?o/n:0;return x(null!=s),s}function tt(t){const e=t.vao,n=t.geometryInfo.vertexAttributes.position.typedBuffer;e.vertexBuffers.geometry.setSubData(n,0,0,n.length)}const et=[[0,1],[1,0],[0,-1],[-1,0]],nt=new p,ot=r(-1/0,-1/0,1/0,1/0),st=[null,null,null,null];function it(t,e,n){if(!e)return!1;const o=b(t,e);return o>0||0===o&&n>=2}const rt=!0;export{O as createInternalVerticesPositionsSpherical,w as createPlanarGlobePatch,R as createSphericalGlobePatch,D as updateCornerSpherical,W as updateCornersPlanar,q as updateEdgesAndCornersPlanar,P as updateEdgesAndCornersSpherical};
|
|
5
|
+
import{isPowerOfTwo as t,clamp as e}from"../../../core/mathUtils.js";import{isNone as n,isSome as o}from"../../../core/maybe.js";import{s}from"../../../chunks/vec4.js";import{empty as i}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as r}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as a}from"./ElevationData.js";import{PatchType as c,NeighborIndex as l}from"./interfaces.js";import{acquireTerrainAttributes as u,minMaxBoundingBox as f,encodeUVInBuffer as d,encodeNormalToBufferFromValues as g,EdgeDescriptor as m}from"./PatchGeometry.js";import{PatchGeometryLUT as h}from"./PatchGeometryLUT.js";import{neighborTileIfLoadedOrSelf as p}from"./PatchRenderData.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as M,internalAssert as x,neighborEdgeIndices as y,almostEquals as S}from"./terrainUtils.js";import{isCornerNeighbor as b}from"./Tile.js";import{compareTilesByLij as v}from"./tileUtils.js";const L=65536;function R(t,e){const n=t.tile,{extent:o,extentInRadians:s,surface:r}=n,a=t.localOrigin,l=t.geometryState,m=r.isWebMercator,h=r.shading||rt,p=l.numVerticesPerSide,y=p-1,S=(p-2)**2,b=m&&(e===c.HAS_SOUTH_POLE||e===c.HAS_BOTH_POLES),v=m&&(e===c.HAS_NORTH_POLE||e===c.HAS_BOTH_POLES),L=6,R=((b?1:0)+(v?1:0))*L*(y+1),O=l.neighborData,T=O.edgeResolutions.reduce(((t,e)=>t+e+1),0),P=u(S+R+T),D=t.geometryInfo;D.numVerticesPerSide=l.numVerticesPerSide,D.vertexAttributes=P;const I=D.boundingBox;i(I);const U=j(t);nt.update(y,s,U),B(t),X(t,S),V(t);const E=[];if((()=>{let t=S+T;const e=a[0],s=a[1],i=a[2],r=n.ellipsoid.radius,c=o[1],l=o[3],u=(n,o)=>{const a=o*p;f(-e,-s,n*r-i,I),E.push({connectedRowOffset:a,connectedOuterEdgeOffset:1===n?0:2,rowOffset:t,latitudeResolution:L});const u=A(-1===n?c:l,r),m=n*Math.PI/2-u,M=.99*(1===n?1:-1),x=r+0,S=P.position,b=P.uv0,v=P.normalCompressed;for(let r=1;r<=L;++r){const n=u+m*(r/L),o=Math.cos(n),a=Math.sin(n);for(let r=0;r<=y;r++){const n=r/y,c=nt.sinLonLUT[r],l=nt.cosLonLUT[r]*o,u=c*o,m=a,p=l*x-e,L=u*x-s,R=m*x-i;f(p,L,R,I),S.setValues(t,p,L,R),d(b,t,n,M),h&&g(v,t,l,u,m),++t}}};b&&u(-1,0),v&&u(1,y)})(),Q(D,l.numVerticesPerSide,E,[0,p-1],[0,p-1],l.wireframe),t.intersectionData=null,M)for(let i=0;i<4;++i)x(D.outerEdges[i].count===O.edgeResolutions[i]+1)}function B(t){const e=t.tile;e.intersectsClippingArea&&(e.surface.shading||rt?T(t):O(t))}function O(t){const e=t.geometryState,n=e.numVerticesPerSide,o=n-2,s=n-1,i=t.geometryInfo,r=i.vertexAttributes,c=r.position,l=r.uv0,u=t.tile,g=u.extent,m=g[0],h=g[2],p=g[1],M=g[3],x=u.ellipsoid.radius,y=e.samplerData,S=t.localOrigin,b=S[0],v=S[1],L=S[2],R=i.boundingBox,B=c.typedBuffer,O=c.typedBufferStride;let T=0;for(let P=1;P<=o;P++){const t=P/s,e=p*(1-t)+M*t,n=nt.sinLatLUT[P],i=nt.cosLatLUT[P];for(let r=1;r<=o;r++){const o=r/s,c=m*(1-o)+h*o,u=nt.sinLonLUT[r],g=nt.cosLonLUT[r],p=x+a(c,e,y),M=g*i*p-b,S=u*i*p-v,P=n*p-L;f(M,S,P,R);const D=T*O;B[D]=M,B[D+1]=S,B[D+2]=P,d(l,T,o,t),++T}}}function T(t){const e=t.geometryState,n=e.numVerticesPerSide,o=n-2,s=n-1,i=t.geometryInfo,r=i.vertexAttributes,c=r.position,l=r.uv0,u=r.normalCompressed,m=t.tile,h=m.extent,p=h[0],M=h[2],x=h[1],y=h[3],S=m.ellipsoid.radius,b=e.samplerData,v=t.localOrigin,L=v[0],R=v[1],B=v[2],O=c.typedBuffer,T=c.typedBufferStride,P=1/s,D=i.boundingBox;let V=0;if(1<=o){const t=P,e=x*(1-t)+y*t,n=nt.sinLatLUT[1],s=nt.cosLatLUT[1];for(let i=1;i<=o;i++){const o=i*P,r=p*(1-o)+M*o,c=nt.sinLonLUT[i],u=nt.cosLonLUT[i],g=S+a(r,e,b),m=g*u*s-L,h=g*c*s-R,x=g*n-B;f(m,h,x,D);const y=(i-1)*T;O[y]=m,O[y+1]=h,O[y+2]=x,d(l,i-1,o,t)}}for(let I=1;I<=o;I++){const t=I*P,e=x*(1-t)+y*t,n=nt.sinLatLUT[I],i=nt.cosLatLUT[I],r=I+1,c=r*P,m=x*(1-c)+y*c,h=nt.sinLatLUT[r],v=nt.cosLatLUT[r],U=nt.sinLonLUT[0],A=nt.cosLonLUT[0],E=S+a(p,e,b);let C=A*i*E-L,j=U*i*E-R,w=n*E-B;const N=V*T;let H=O[N],_=O[N+1],q=O[N+2];for(let y=1;y<=o;y++){const t=y*P,r=p*(1-t)+M*t,U=nt.sinLonLUT[y],A=nt.cosLonLUT[y];let E=A*i,N=U*i,W=n,F=0,k=0,z=0;{let t=0,r=0,c=0;if(y<o){const e=(V+1)*T;t=O[e],r=O[e+1],c=O[e+2]}else{const o=nt.sinLonLUT[s],l=nt.cosLonLUT[s],u=S+a(M,e,b);t=l*i*u-L,r=o*i*u-R,c=n*u-B}const l=C,u=j,f=w;C=H,j=_,w=q,H=t,_=r,q=c,F=t-l,k=r-u,z=c-f}{let e=0,n=0,s=0;if(I>1){const t=(V-o)*T;e=O[t],n=O[t+1],s=O[t+2]}else{const t=nt.sinLatLUT[0],o=nt.cosLatLUT[0],i=S+a(r,x,b);e=A*o*i-L,n=U*o*i-R,s=t*i-B}{const i=S+a(r,m,b),u=A*v*i-L,g=U*v*i-R,p=h*i-B;if(I<o){const e=V+o,n=e*T;O[n]=u,O[n+1]=g,O[n+2]=p,f(u,g,p,D),d(l,e,t,c)}const M=e-u,x=n-g,y=s-p;W*W<.999&&(E=z*x-k*y,N=F*y-z*M,W=k*M-F*x)}}const G=1/Math.sqrt(E*E+N*N+W*W);g(u,V,E*G,N*G,W*G),++V}}}function P(t){t.tile.intersectsClippingArea&&(V(t),tt(t))}function D(t){t.tile.intersectsClippingArea&&(U(t),I(t,!0),tt(t))}function V(t){t.tile.intersectsClippingArea&&(U(t),I(t))}function I(e,s=!1){const i=e.geometryState,r=e.geometryInfo,c=i.neighborData,l=e.tile,u=l.level,g=l.extent,m=l.ellipsoid.radius,h=l.extentInRadians,b=h[0],L=h[2],R=h[1],B=h[3],O=i.samplerData,T=g[0],P=g[2],D=g[1],V=g[3],I=j(e),U=r.boundingBox,A=e.localOrigin,E=A[0],C=A[1],w=A[2],N=l.surface.shading||rt,H=r.vertexAttributes,_=H.position,q=_.typedBuffer,W=_.typedBufferStride,F=H.uv0;for(let j=0;j<4;++j){const i=1===j||3===j,h=c.edgeResolutions[j];x(t(h));const A=h+1,H=p(l,c.edgePeerNeighbors[j]);if(it(l,H,j)){Y(e,j,H);continue}const _=o(H);x(!_||H.level===l.level),x(!_||v(l,H)<=0);const k=H?.renderData,z=k?.geometryState;if(M){const t=l.surface;if(!H&&t&&!t.updatingRootTiles){const e=y[j],o=l.findNeighborTile(e,(t=>t.isLoaded||t.isLeaf||t.level===l.level));o?o.intersectsClippingArea&&(x(!o.isLoaded),x(!o.isLeaf),x(o.level===u)):x(n(t?.rootTiles)||!l.shouldHaveNeighbor(e))}}const G=1===j?g[2]:g[0],J=H?.extent,K=J&&i?1===j?J[0]:J[2]:G,Q=0===j?g[3]:g[1],X=1===j?1:0,Z=0===j?1:0,$=1===j?L:b,tt=0===j?B:R,et=Math.sin($),nt=Math.cos($),ot=Math.sin(tt),st=Math.cos(tt),rt=z?.samplerData,at=_?(t,e,n)=>.5*(a(t,e,O)+a(n,e,rt)):(t,e,n)=>a(t,e,O),ct=r.outerEdges[j],lt=s&&A>3?A-3:1,ut=o(O)&&O.some((t=>null!=t)),ft=o(rt)&&rt.some((t=>null!=t)),dt=ut||ft,gt=1/h,mt=ct.index0;if(N){x(!J||S(J[2]-J[0],g[2]-g[0]));(()=>{const t=1===j?-1:3===j?1:0,e=0===j?-1:2===j?1:0,n=(g[2]-g[0])*gt,o=t*n,s=e*n,r=i?t*((L-b)*gt):0,c=i?0:e*gt,l=Z,u=i?$+r:$,h=i?Math.sin(u):et,p=i?Math.cos(u):nt,M=i?$-r:$,x=i?Math.sin(M):et,y=i?Math.cos(M):nt,S=i?tt:I(l+c),v=i?ot:Math.sin(S),R=i?st:Math.cos(S),B=i?tt:I(l-c),N=i?ot:Math.sin(B),H=i?st:Math.cos(B),k=(mt+0)*W;let z=q[k]+E,J=q[k+1]+C,Y=q[k+2]+w,it=0,ut=0,ft=0;{const t=1*gt,e=i?G:T*(1-t)+P*t,n=i?K:e,o=i?D*(1-t)+V*t:Q,s=i?$:b*(1-t)+L*t,r=i?et:Math.sin(s),a=i?nt:Math.cos(s),c=i?I(t):tt,l=i?Math.sin(c):ot,u=i?Math.cos(c):st,f=m+at(e,o,n);it=a*u*f,ut=r*u*f,ft=l*f}for(let g=1;g<A-1;g+=lt){let t=0,e=0,n=0;{const o=(mt+g+1)*W;if(g<A-2){const o=(g+1)*gt,s=i?G:T*(1-o)+P*o,r=i?K:s,a=i?D*(1-o)+V*o:Q,c=i?$:b*(1-o)+L*o,l=i?et:Math.sin(c),u=i?nt:Math.cos(c),f=i?I(o):tt,d=i?Math.sin(f):ot,h=i?Math.cos(f):st,p=m+at(s,a,r);t=u*h*p,e=l*h*p,n=d*p}else t=q[o]+E,e=q[o+1]+C,n=q[o+2]+w}const r=t,c=e,l=n,u=it,M=ut,S=ft;it=r,ut=c,ft=l;{const t=mt+g,e=t*W,n=u-E,o=M-C,s=S-w;q[e]=n,q[e+1]=o,q[e+2]=s,f(n,o,s,U);const r=g*gt;d(F,t,i?X:r,i?r:Z)}const B=z,k=J,lt=Y;z=u,J=M,Y=S;const ht=u,pt=M,Mt=S,xt=1/Math.sqrt(ht*ht+pt*pt+Mt*Mt),yt=Mt*xt;let St=0,bt=0,vt=0;if(dt&&yt*yt<.999){let t=0,e=0,n=0;{const o=0===j?-1:1;t=o*(r-B),e=o*(c-k),n=o*(l-lt)}{const r=g*gt,c=i?G:T*(1-r)+P*r,l=i?K:c,u=i?D*(1-r)+V*r:Q,f=i?$:b*(1-r)+L*r,d=i?et:Math.sin(f),M=i?nt:Math.cos(f),S=i?I(r):tt,B=i?Math.sin(S):ot,U=i?Math.cos(S):st;let A=ht,E=pt,C=Mt;if(_){const t=m+a(l-o,u-s,rt),e=i?U:H;A=(i?y:M)*e*t,E=(i?x:d)*e*t,C=(i?B:N)*t}{const r=m+a(c+o,u+s,O),l=i?U:R,f=(i?p:M)*l*r,g=(i?h:d)*l*r,x=(i?B:v)*r;_||(A=2*ht-f,E=2*pt-g,C=2*Mt-x);const y=3===j?-1:1,S=y*(A-f),b=y*(E-g),L=y*(C-x);St=n*b-e*L,bt=t*L-n*S,vt=e*S-t*b;const T=1/Math.sqrt(St*St+bt*bt+vt*vt);St*=T,bt*=T,vt*=T}}}else St=ht*xt,bt=pt*xt,vt=Mt*xt;ct.setNormalFromValues(g,St,bt,vt)}})()}else{(()=>{for(let t=1;t<A-1;t+=lt){const e=t*gt,n=i?X:e,o=i?e:Z,s=i?G:T*(1-e)+P*e,r=i?D*(1-e)+V*e:Q,a=i?K:s,c=i?$:b*(1-e)+L*e,l=i?et:Math.sin(c),u=i?nt:Math.cos(c),g=i?I(e):tt,h=i?Math.sin(g):ot,p=i?Math.cos(g):st,M=at(s,r,a),x=m+M,y=u*p*x-E,S=l*p*x-C,v=h*x-w;f(y,S,v,U);const R=mt+t,B=R*W;q[B]=y,q[B+1]=S,q[B+2]=v,d(F,R,n,o)}})()}}}function U(t){Z(t)}function A(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function E(t,e,n,o){return A(t*(1-o)+e*o,n)}function C(t,e,n){return t*(1-n)+e*n}function j(t){const e=t.tile;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>E(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>C(n[1],n[3],t)}function w(t,e){const n=t.tile.extent,r=t.geometryState,a=n[0],c=n[1],l=n[2]-a,f=n[3]-c,d=r.clippingArea,g=o(d)?Math.max(0,(d[0]-a)/l):0,m=o(d)?Math.max(0,(d[1]-c)/f):0,h=o(d)?Math.min(1,(d[2]-a)/l):1,p=o(d)?Math.min(1,(d[3]-c)/f):1,M=r.numVerticesPerSide,x=(M-2)**2,y=r.neighborData.edgeResolutions.reduce(((t,e)=>t+e+1),0),S=u(x+y),b=t.geometryInfo,v=b.boundingBox;i(v),b.numVerticesPerSide=r.numVerticesPerSide,b.vertexAttributes=S,s(b.uvRange,g,m,h,p),N(t),X(t,x),F(t),Q(b,r.numVerticesPerSide,[],[0,M-1],[0,M-1],r.wireframe),t.intersectionData=null}function N(t){const e=t.tile;e.intersectsClippingArea&&(e.surface.shading?_(t):H(t))}function H(t){const n=t.geometryState,s=n.samplerData,i=t.tile,r=i.surface,c=t.localOrigin,l=r.isWebMercatorOnPlateeCarree,u=n.clippingArea,g=o(u)?u:ot,m=i.extent,h=m[0],p=m[1],M=m[2],x=m[3],y=Math.max(h,g[0]),S=Math.min(M,g[2]),b=Math.max(p,g[1]),v=Math.min(x,g[3]),L=c[0],R=c[1],B=c[2],O=i.ellipsoid.radius,T=i.horizontalScale,P=K(l,O,T),D=n.numVerticesPerSide,V=D-1,I=D-2,U=t.geometryInfo,A=U.uvRange,E=A[0],C=A[1],j=A[2],w=A[3],N=U.boundingBox,H=U.vertexAttributes,_=H.position,q=H.uv0;let W=0;for(let o=1;o<=I;o++){const t=o/V,n=e(p*(1-t)+x*t,b,v),i=e(t,C,w),r=P(n)-R;for(let o=1;o<=I;o++){const t=o/V,c=e(h*(1-t)+M*t,y,S),l=e(t,E,j),u=c*T-L,g=a(c,n,s)-B;f(u,r,g,N),_.setValues(W,u,r,g),d(q,W,l,i),++W}}}function _(t){const n=t.tile,s=n.surface;if(!(s.shading||rt))return;const i=t.geometryState,r=i.samplerData,c=t.localOrigin,l=s.isWebMercatorOnPlateeCarree,u=i.clippingArea,m=o(u)?u:ot,h=n.extent,p=h[0],M=h[1],x=h[2],y=h[3],S=Math.max(p,m[0]),b=Math.min(x,m[2]),v=Math.max(M,m[1]),L=Math.min(y,m[3]),R=n.ellipsoid.radius,B=n.horizontalScale,O=i.numVerticesPerSide,T=O-1,P=O-2,D=t.geometryInfo,V=D.vertexAttributes,I=V.position,U=V.uv0,A=V.normalCompressed,E=D.uvRange,C=E[0],j=E[1],w=E[2],N=E[3],H=D.boundingBox,_=c[0],q=c[1],W=c[2],F=I.typedBuffer,k=I.typedBufferStride;let z=0;const G=e(M,v,L),J=l?(Math.PI/2-2*Math.atan(Math.exp(-G/R)))*R:G*B,K=1/T,Q=e(M*(1-K)+y*K,v,L);let X=J,Y=l?(Math.PI/2-2*Math.atan(Math.exp(-Q/R)))*R:Q*B;for(let o=1;o<=P;o++){const t=o/T,n=e(M*(1-t)+y*t,v,L),s=e(t,j,N),i=Y,c=(o-1)/T,u=e(M*(1-c)+y*c,v,L),m=X,h=(o+1)/T,O=e(M*(1-h)+y*h,v,L),D=l?(Math.PI/2-2*Math.atan(Math.exp(-O/R)))*R:O*B,V=e(h,j,N);X=Y,Y=D;const I=e(p,S,b);let E=I*B,G=a(I,n,r);const J=1/T,K=e(J,C,w),Q=e(p*(1-K)+x*K,S,b);let Z=K,$=Q,tt=Q*B,et=a(Q,n,r);if(1===o){const t=tt-_,n=X-q,o=et-W,i=0*k;F[i]=t,F[i+1]=n,F[i+2]=o,f(t,n,o,H);const r=e(J,C,w);d(U,z,r,s)}for(let l=1;l<=P;l++){const t=tt,c=et,h=(l+1)/T,M=e(h,C,w),y=e(p*(1-h)+x*h,S,b),v=$;$=y;{const t=z+1,e=t*k;if(1===o||l===P){const c=y*B,u=a(y,n,r);if(1===o&&l<P){const n=c-_,o=i-q,r=u-W;F[e]=n,F[e+1]=o,F[e+2]=r,f(n,o,r,H),d(U,t,M,s)}tt=c,et=u}else tt=F[e]+_,et=F[e+2]+W}const L=tt,R=et,I=E,j=G;E=t,G=c;const N=(z-P)*k,J=1===o?a(v,u,r):F[N+2]+W,K=a(v,O,r);if(o<P){const e=z+P,n=e*k,o=t-_,s=D-q,i=K-W;F[n]=o,F[n+1]=s,F[n+2]=i,f(o,s,i,H);const r=Z;Z=M,d(U,e,r,V)}{const t=L-I,e=m-D,n=e*(R-j),o=t*(J-K),s=-e*t,i=n*n+o*o+s*s;if(0===i)g(A,z,0,0,1);else{const t=1/Math.sqrt(i);g(A,z,n*t,o*t,s*t)}}++z}}}function q(t,e){t.tile.intersectsClippingArea&&(z(t),k(t,!0),tt(t))}function W(t,e){t.tile.intersectsClippingArea&&(F(t),tt(t))}function F(t,e){t.tile.intersectsClippingArea&&(z(t),k(t,!1))}function k(s,i){const r=s.geometryState,c=r.neighborData,l=s.tile,u=l.surface,d=u.shading||rt,g=l.extent,m=r.clippingArea,h=o(m)?m:ot,S=g[0],b=g[2],L=g[1],R=g[3],B=[R>h[3],b>h[2],L<h[1],S<h[0]],O=s.geometryInfo,T=l.horizontalScale,P=K(u.isWebMercatorOnPlateeCarree,l.ellipsoid.radius,T),D=O.boundingBox,V=O.uvRange[0],I=O.uvRange[1],U=O.uvRange[2],A=O.uvRange[3],E=Math.max(S,h[0]),C=Math.min(b,h[2]),j=Math.max(L,h[1]),w=Math.min(R,h[3]),N=s.localOrigin,H=N[0],_=N[1],q=N[2],W=r.samplerData;for(let F=0;F<4;++F){const r=1===F||3===F,g=c.edgeResolutions[F];x(t(g));const m=g+1,h=B[F],N=p(l,c.edgePeerNeighbors[F]);if(!h&&it(l,N,F)){Y(s,F,N);continue}const k=o(N)&&!h,z=N?.renderData,G=z?.geometryState;if(M&&(x(!k||N.level===l.level),x(!k||v(l,N)<=0),l&&!N&&!u.updatingRootTiles)){const t=y[F],e=l.findNeighborTile(t,(t=>t.isLoaded||t.isLeaf||t.level===l.level));u.updatingRootTiles||(e?e.intersectsClippingArea&&(x(!e.isLoaded),x(!e.isLeaf),x(e.level===l.level)):x(n(u?.rootTiles)||!l.shouldHaveNeighbor(t)))}const J=e(1===F?b:S,E,C),K=e(0===F?R:L,j,w),Q=G?.samplerData,X=O.outerEdges[F],Z=i&&m>3?m-3:1,$=e(1===F?1:0,V,U),tt=e(0===F?1:0,I,A),et=k?(t,e)=>.5*(a(t,e,Q)+a(t,e,W)):(t,e)=>a(t,e,W);if(d){const t=(b-S)/g,n=r?1===F?t:-t:0,o=r?0:0===F?t:-t,s=-n,i=-o,c=X.attributes.position.typedBuffer,l=X.attributes.position.typedBufferStride,u=X.index0,d=X.stride,h=u*l;let p=c[h]+H,M=c[h+1]+_,x=c[h+2]+q,y=0,v=0,B=0;{const t=1/g,n=r?J:e(S*(1-t)+b*t,E,C),o=r?e(L*(1-t)+R*t,j,w):K,s=et(n,o);y=n*T,v=P(o),B=s}for(let O=1;O<m-1;O+=Z){const t=O/g,h=y,N=v,z=B;{const n=r?$:e(t,V,U),o=r?e(t,I,A):tt,s=h-H,i=N-_,a=z-q;f(h,i,a,D),X.setVertexFromValuesRawPositionUV(O,s,i,a,n,o)}const G=O+1;if(O===m-1){const t=(u+G*d)*l;y=c[t]+H,v=c[t+1]+_,B=c[t+2]+q}else{const t=G/g,n=r?J:e(S*(1-t)+b*t,E,C),o=r?e(L*(1-t)+R*t,j,w):K,s=et(n,o);y=n*T,v=P(o),B=s}const Y=y,Z=B,nt=p,ot=M,st=x;p=h,M=N,x=z;let it=0,rt=0,at=0;if(r){const o=v-N,i=Z-z,r=ot-N,c=st-z,l=e(L*(1-t)+R*t,j,w),u=J+s,f=u*T-h,d=a(u,l,W)-z,g=3===F?-1:1;if(it=g*(-r+o)*d,rt=g*f*(-c+i),at=-g*f*(-r+o),k){const t=J+n,e=t*T-h;it=(-r+o)*(d-(a(t,l,Q)-z)),rt=(f-e)*(-c+i),at=-(f-e)*(-r+o)}}else{const n=Y-h,s=Z-z,r=nt-h,c=st-z,l=e(S*(1-t)+b*t,E,C),u=K+i,f=a(l,u,W)-z,d=P(u)-N,g=2===F?-1:1;if(it=g*d*(-c+s),rt=g*(-r+n)*f,at=-g*d*(-r+n),k){const t=l,e=K+o,i=P(e)-N;it=(-d+i)*(-c+s),rt=(-r+n)*(-f+(a(t,e,Q)-z)),at=-(-d+i)*(-r+n)}}const ct=1/Math.sqrt(it*it+rt*rt+at*at);X.setNormalFromValues(O,it*ct,rt*ct,at*ct)}}else for(let t=1;t<m-1;t+=Z){const n=t/g,o=r?J:e(S*(1-n)+b*n,E,C),s=r?e(L*(1-n)+R*n,j,w):K,i=r?$:e(n,V,U),a=r?e(n,I,A):tt,c=et(o,s),l=o*T-H,u=P(s)-_,d=c-q;f(l,u,d,D),X.setVertexFromValuesRawPositionUV(t,l,u,d,i,a)}}}function z(t,e){Z(t)}function G(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function J(t,e){return t*e}function K(t,e,n){return t?t=>G(t,e):t=>J(t,n)}function Q(t,e,n,o,s,i){const r=e-1,a=t.vertexAttributes.count,c=2*(Math.min(e-2,o[1])-Math.max(1,o[0]))*(Math.min(e-2,s[1])-Math.max(1,s[0])),l=y.map(((t,n)=>0===n&&s[1]<e-2||1===n&&o[1]<e-2||2===n&&s[0]>1||3===n&&o[0]>1)),u=t.outerEdges.reduce(((t,e,n)=>t+(l[n]?0:r-2+e.count-1)),0),f=n.reduce(((t,e)=>t+r*(2*(e.latitudeResolution-1)+1)),0),d=i?2:1,g=3*(c+u+f)*d,m=a>=L?new Uint32Array(g):new Uint16Array(g);let h=0;const p=e-2,S=r-2;if(x(S>=0),i){const i=(t,e,n)=>{m[h++]=t,m[h++]=e,m[h++]=e,m[h++]=n,m[h++]=n,m[h++]=t,M&&(x(t<a),x(e<a),x(n<a),x(h<=g))};(()=>{for(let t=Math.max(s[0],1)-1;t<Math.min(s[1],e-2)-1;++t)for(let n=Math.max(o[0],1)-1;n<Math.min(o[1],e-2)-1;++n){const e=t*p+n,o=e+1,s=o+p,r=s-1;i(e,o,s),i(s,r,e)}})(),x(h===3*c*d);(()=>{for(let e=0;e<4;++e){const n=h;if(l[e])continue;const o=t.outerEdges[e],s=t.innerEdges[e];let a=0,c=0;const u=o.count,f=s.count;x(f===r-1);let g=0;const m=1===e||2===e?(t,e,n)=>i(t,e,n):(t,e,n)=>i(t,n,e);for(;a<u-1||c<f-1;){const t=s.getVertexIndex(c),e=o.getVertexIndex(a),n=a<u-1,i=c<f-1;if(n&&(!i||(n?0+r*(a+.5)/(u-1):0)<=(i?1+S*(c+.5)/(f-1):0))){++a,M&&x(a<u);m(t,e,o.getVertexIndex(a)),g++}else{++c,M&&x(c<f);m(t,e,s.getVertexIndex(c)),g++}}M&&(x(a===u-1),x(c===f-1),x(g===u+f-2),x(g===r-2+o.count-1),x(h===n+3*g*d))}})(),x(h===3*(c+u)*d);const f=n=>{const o=t.outerEdges[n.connectedOuterEdgeOffset];let s=o.getVertexIndex(0),a=o.stride;for(let t=0;t<n.latitudeResolution;++t){const o=0===t?n.rowOffset:s+e;for(let e=0;e<r;e++)i(s,s+1,o+e),t<n.latitudeResolution-1&&i(s+1,o+e+1,o+e),s+=a;s=o,a=1}};(()=>n.forEach(f))()}else{(()=>{const t=Math.max(s[0],1)-1,n=Math.min(s[1],e-2)-1,i=Math.max(o[0],1)-1,r=Math.min(o[1],e-2)-1;for(let e=t;e<n;++e){const t=e*p;for(let e=i;e<r;++e){const n=t+e,o=n+1,s=o+p,i=s-1;m[h]=n,m[h+1]=o,m[h+2]=s,m[h+3]=s,m[h+4]=i,m[h+5]=n,h+=6}}})(),x(h===3*c*d);(()=>{for(let e=0;e<4;++e){if(l[e])continue;const n=t.outerEdges[e],o=t.innerEdges[e];let s=0,i=0;const a=n.count,c=o.count;x(c===r-1);const u=1===e||2===e,f=u?1:2,d=u?2:1,g=n.index0,p=n.stride,M=o.index0,y=o.stride;for(;s<a-1||i<c-1;){const t=M+i*y,e=g+s*p,n=s<a-1,o=i<c-1,l=n&&(!o||(n?0+r*(s+.5)/(a-1):0)<=(o?1+S*(i+.5)/(c-1):0));l?++s:++i;const u=l?e+p:t+y;m[h]=t,m[h+f]=e,m[h+d]=u,h+=3}}})(),x(h===3*(c+u)*d);const i=n=>{const o=t.outerEdges[n.connectedOuterEdgeOffset];let s=o.getVertexIndex(0),i=o.stride;for(let t=0;t<n.latitudeResolution;++t){const o=0===t?n.rowOffset:s+e;for(let e=0;e<r;e++){const r=o+e;m[h]=s,m[h+1]=s+1,m[h+2]=r,t<n.latitudeResolution-1?(m[h+3]=s+1,m[h+4]=r+1,m[h+5]=r,h+=6):h+=3,s+=i}s=o,i=1}};(()=>n.forEach(i))()}x(h===g),t.indices=m,t.indexCount=g}function X(t,e){const n=t.localOrigin,o=t.geometryInfo,s=t.geometryState.neighborData.edgeResolutions,i=o.numVerticesPerSide-2,r=o.vertexAttributes;let a=e;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),s=(t?0:1)*i+(t?1:0);o.innerEdges[c]=new m(r,n,e,s,i)}{const t=a,e=s[c]+1;o.outerEdges[c]=new m(r,n,t,1,e),a+=e}}}function Y(n,o,s){const i=(o+2)%4,r=n.geometryState,a=n.tile,c=r.neighborData,l=a.level-s.level,u=1===o||3===o,g=c.edgeResolutions[o];x(t(g));const m=g+1,h=n.geometryInfo,p=h.boundingBox,M=h.outerEdges[o],y=h.uvRange[0],S=h.uvRange[1],b=h.uvRange[2],v=h.uvRange[3],L=e(1===o?1:0,y,b),R=e(0===o?1:0,S,v),B=s.renderData,O=B.geometryState,T=B.geometryInfo.outerEdges[i],P=a.getNeighborEdgeStartVertexIndex(o,s)*g,D=g*2**l;x(O.neighborData.edgeResolutions[i]===D),x(T.count-1===D);const V=B.localOrigin[0]-n.localOrigin[0],I=B.localOrigin[1]-n.localOrigin[1],U=B.localOrigin[2]-n.localOrigin[2],A=M.attributes,E=M.index0,C=M.stride,j=A.position.typedBuffer,w=A.position.typedBufferStride,N=A.normalCompressed.typedBuffer,H=A.normalCompressed.typedBufferStride,_=A.uv0,q=T.attributes,W=T.index0,F=T.stride,k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,J=q.normalCompressed.typedBufferStride;for(let t=1;t<m-1;++t){const n=E+C*t,o=W+F*(P+t),s=n*w,i=o*z,r=k[i]+V,a=k[i+1]+I,c=k[i+2]+U;j[s]=r,j[s+1]=a,j[s+2]=c,f(r,a,c,p);const l=n*H,m=o*J;N[l]=G[m],N[l+1]=G[m+1];const h=t/g,M=u?L:e(h,y,b),x=u?e(h,S,v):R;d(_,n,M,x)}}function Z(t){const n=t.geometryState,s=n.neighborData,i=t.localOrigin,r=s.cornerNeighborData,c=t.geometryInfo,l=c.outerEdges,u=c.boundingBox,g=t.tile,m="local"===t.tile.surface.view?.viewingMode,h=g.ellipsoid.radius,p=g.extentInRadians,M=g.horizontalScale;let y=0,S=0,b=0;const L=(t,e,n)=>{const o=p[0===e?1:3],s=p[0===t?0:2],i=Math.cos(o),r=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=h+n;y=c*i*l,S=a*i*l,b=r*l},R=m?(()=>{const n=t.geometryState.clippingArea,s=g.extent,i=o(n)&&(s[3]>n[3]||s[2]>n[2]||s[1]<n[1]||s[0]<n[0]),r=K(g.surface.isWebMercatorOnPlateeCarree,g.ellipsoid.radius,M);return(t,o,s)=>{const a=0===t?w[0]:w[2],c=0===o?w[1]:w[3],l=i?e(a,n[0],n[2]):a,u=i?e(c,n[1],n[3]):c,f=s;y=l*M,S=r(u),b=f}})():L;let B=0,O=0,T=0,P=0,D=0,V=0,I=0,U=0,A=0;const E=m&&t.tile.surface.isWebMercatorOnPlateeCarree,C=(t,e,n,o,s)=>{let i=0,r=0,a=0;if(m){const t=e*M,s=E?(Math.PI/2-2*Math.atan(Math.exp(-n/h)))*h:n*M;i=t-y,r=s-S,a=o-b}else{const s=j(t),c=t.tile,l=c.extent,u=c.extentInRadians,f=(e-l[0])/(l[2]-l[0]),d=(n-l[1])/(l[3]-l[1]),g=u[0]*(1-f)+u[2]*f,m=s(d),p=Math.cos(m),M=Math.sin(m),x=Math.sin(g),v=Math.cos(g),L=h+o;i=v*p*L-y,r=x*p*L-S,a=M*L-b}switch(s){case 0:I+=i,U+=r,A+=a;break;case 1:P-=i,D-=r,V-=a;break;case 2:I-=i,U-=r,A-=a;break;case 3:P+=i,D+=r,V+=a}},w=g.extent,N=n.clippingArea,H=o(N)?N:ot,_=w[0],q=w[2],W=w[1],F=w[3],k=[F>H[3],q>H[2],W<H[1],_<H[0]],z=Math.max(_,H[0]),G=Math.min(q,H[2]),J=Math.max(W,H[1]),Q=Math.min(F,H[3]),X=c.uvRange[0],Y=c.uvRange[1],Z=c.uvRange[2],tt=c.uvRange[3],nt=g.surface.shading||rt,it=t=>{const e=r[t].cornerTiles;B=0,O=0,T=1;let n=1/0;for(let r=0;r<4;++r)n=Math.min(n,e[r]?.level??1/0);for(let r=0;r<4;++r){const t=e[r];st[r]=t?.level===n?t:null}let o=1,s=0;for(let r=0;r<4;++r){const t=st[r];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),s=t.extent[2]-t.extent[0])}const i=s,c=o;x(c>1);const l=i/c;for(let r=0;r<4;++r){const t=st[(r+3)%4],e=st[r%4];if(!t&&!e)continue;const n=0===r?1:1===r?2:2===r?3:0,o=0===r?2:1===r?3:2===r?0:1;if(t&&e){const s=et[r][0]*l,i=et[r][1]*l,c=t.extent,u=c[0===n||1===n?2:0]+s,f=c[0===n||3===n?3:1]+i,d=e.extent,g=d[0===o||1===o?2:0]+s,m=d[0===o||3===o?3:1]+i,h=t.renderData,p=e.renderData,M=a(u,f,h.geometryState.samplerData),x=a(g,m,p.geometryState.samplerData);C(h,u,f,.5*(M+x),r)}else{const s=t??e,i=t?n:o,c=s.extent,u=et[r],f=c[0===i||1===i?2:0]+u[0]*l,d=c[0===i||3===i?3:1]+u[1]*l,g=s.renderData,m=a(f,d,g.geometryState.samplerData);C(g,f,d,m,r)}}if(!m){const t=Math.sqrt(y*y+S*S+b*b);B=y/t,O=S/t,T=b/t}const u=Math.sqrt(P*P+D*D+V*V);P/=u,D/=u,V/=u;const f=Math.sqrt(I*I+U*U+A*A);if(I/=f,U/=f,A/=f,m||T*T<.999){B=V*U-D*A,O=P*A-V*I,T=D*I-P*U;const t=1/Math.sqrt(B*B+O*O+T*T);B*=t,O*=t,T*=t}};for(let o=0;o<4;++o){const s=o,c=(o+1)%4,m=0===o||1===o?1:0,h=0===o||3===o?1:0,p=e(m,X,Z),M=e(h,Y,tt),L=l[s],P=0===o||3===o?L.count-1:0,D=l[c],V=0===o||1===o?D.count-1:0,I=r[o].cornerTiles;let U=-1;for(let t=0;t<4;++t){const e=I[t];e&&(-1===U||v(I[U],e)>0)&&(U=t)}const A=U,E=I[A];if(B=0,O=0,T=1,E!==g){const e=g.level-E.level,n=2**e,s=[E.lij[0]+e,E.lij[1]*n,E.lij[2]*n],i=[s[1]+n===g.lij[1],0===o&&(1===A||0===A&&E!==I[3])||1===o&&(0===A||1===A&&E!==I[2]),s[1]===g.lij[1]+1,2===o&&(3===A||2===A&&E!==I[1])||3===o&&(2===A||3===A&&E!==I[0])],r=i.reduce(((t,e)=>t+(e?1:0)),0);x(1===r||2===r);let a=-1,c=-1;const l=E.renderData;if(1===r){const e=i.findIndex((t=>t));x(0<=e&&e<=3),a=(e+2)%4;const n=t.geometryState.neighborData.edgeResolutions[e];c=g.getNeighborEdgeStartVertexIndex(e,E)*n+n*(0===e&&0===o||1===e&&0===o||2===e&&1===o||3===e&&3===o?1:0)}else{x(i[1]||i[3]),a=i[1]?3:1;const t=l.geometryState.neighborData.edgeResolutions[a];c=0===o||3===o?0:t}const m=l.geometryInfo.outerEdges[a];{const e=L.index0+P*L.stride,n=D.index0+V*D.stride,o=m.index0+c*m.stride;{const s=m.attributes.position,i=s.typedBuffer,r=o*s.typedBufferStride,a=t.localOrigin,c=m.localOrigin,l=i[r]+c[0]-a[0],d=i[r+1]+c[1]-a[1],g=i[r+2]+c[2]-a[2];f(l,d,g,u);{const t=L.attributes.position,n=t.typedBuffer,o=e*t.typedBufferStride;n[o]=l,n[o+1]=d,n[o+2]=g}{const t=D.attributes.position,e=t.typedBuffer,o=n*t.typedBufferStride;e[o]=l,e[o+1]=d,e[o+2]=g}}d(L.attributes.uv0,e,p,M),d(D.attributes.uv0,n,p,M);{const t=m.attributes.normalCompressed.typedBuffer,s=o*m.attributes.normalCompressed.typedBufferStride;{const n=L.attributes.normalCompressed,o=n.typedBuffer,i=e*n.typedBufferStride;o[i]=t[s],o[i+1]=t[s+1]}{const e=D.attributes.normalCompressed,o=e.typedBuffer,i=n*e.typedBufferStride;o[i]=t[s],o[i+1]=t[s+1]}}}}else{const t=k[s],r=k[c];let l;if(t||r){const t=e(_*(1-m)+q*m,z,G),o=e(W*(1-h)+F*h,J,Q),s=n.samplerData;l=a(t,o,s)}else l=$(I);R(m,h,l),(nt||rt)&&it(o);const d=y-i[0],g=S-i[1],x=b-i[2];f(d,g,x,u),L.setVertexFromValuesRawPositionUVNormal(P,d,g,x,p,M,B,O,T),D.setVertexFromValuesRawPositionUVNormal(V,d,g,x,p,M,B,O,T)}}for(let e=0;e<4;++e)st[e]=null}function $(t){const e=t.reduce(((t,e)=>Math.min(t,e?.level??1/0)),1/0);M&&(x(!t[0]||!t[2]||b(t[0],t[2],l.SOUTH_WEST)),x(!t[1]||!t[3]||b(t[1],t[3],l.NORTH_WEST)));let n=0,o=0;for(let i=0;i<4;++i){const s=t[i];if(s&&s.level===e){const t=0===i||1===i,e=0===i||3===i,r=s.extent,c=r[t?0:2],l=r[e?1:3],u=s.renderData?.geometryState?.samplerData;o+=a(c,l,u),n++}}const s=n?o/n:0;return x(null!=s),s}function tt(t){const e=t.vao,n=t.geometryInfo.vertexAttributes.position.typedBuffer;e.vertexBuffers.geometry.setSubData(n,0,0,n.length)}const et=[[0,1],[1,0],[0,-1],[-1,0]],nt=new h,ot=r(-1/0,-1/0,1/0,1/0),st=[null,null,null,null];function it(t,e,n){if(!e)return!1;const o=v(t,e);return o>0||0===o&&n>=2}const rt=!0;export{O as createInternalVerticesPositionsSpherical,w as createPlanarGlobePatch,R as createSphericalGlobePatch,D as updateCornerSpherical,q as updateCornersPlanar,W as updateEdgesAndCornersPlanar,P as updateEdgesAndCornersSpherical};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,mapOr as s}from"../../../core/maybe.js";import{i as a,j as n,u as o,b as l,n as h,e as d,w as g,F as c}from"../../../chunks/vec3.js";import{c as u,a as m}from"../../../chunks/vec3f64.js";import{empty as p}from"../../../geometry/support/aaBoundingBox.js";import{containsXY as f}from"../../../geometry/support/aaBoundingRect.js";import{earth as y}from"../../../geometry/support/Ellipsoid.js";import{glLayout as _}from"../support/buffer/glUtil.js";import{GeometryState as x}from"./GeometryState.js";import{NeighborIndex as C}from"./interfaces.js";import{LayerClass as D}from"./LayerClass.js";import{PatchGeometry as v,releaseGeometry as S}from"./PatchGeometry.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as $,internalAssert as E,neighborEdgeIndices as b,oppositeEdge as T,neighborCornerIndices as j,v32s as A,lij2s as V}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as w}from"./TextureFader.js";import{isEdgeNeighbor as L}from"./Tile.js";import P from"./TileOverlayData.js";import{fallsWithinLayer as N}from"./tileUtils.js";import{VertexArrayObject as I}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as G}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as M}from"../../webgl/BufferObject.js";class O{constructor(){this.geometryInfo=new v,this.intersectionData=null,this.geometryState=null,this._textureRef=new R((()=>this.tile.surface.textureFadeDuration)),this.overlay=new P,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1,this._shadingChanged=!1,this._dirtyEdgeResolutions=15,this._dirtyEdges=15,this._dirtyCorners=15}get tile(){return this._tile}init(e){this.clear(),this._tile=e;const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,p(t.boundingBox),t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new x,this.localOrigin=null,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._shadingChanged||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)E(this.geometryInfo.outerEdges[t].count===this.geometryState.neighborData.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const s=this.tile,a=this.geometryState.numVerticesPerSide-1;if(!s.surface.isGlobal){const t=s.surface.extent;if(r(t)&&(0===e&&s.extent[3]>t[3]||1===e&&s.extent[2]>t[2]||2===e&&s.extent[1]<t[1]||3===e&&s.extent[0]<t[0]))return a}const n=s.level,o=b[e];if(!t)return E(i(s.surface?.rootTiles)||s.surface.updatingRootTiles||!s.shouldHaveNeighbor(o)),a;if(t.isLoaded){const r=t,i=r.renderData.geometryState,s=n-r.level;if(E(s>=0),0===s){const e=i.numVerticesPerSide-1;return Math.max(e,a)}const o=2**s,l=i.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,l)}E(!t.isLeaf);let l=a;return t.forAllSubtreeOnSide(T(o),(e=>e===s||(e.isLoaded?(l=Math.max(l,2**(e.level-n)),!0):(E(!e.isLeaf),!1)))),l}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState.neighborData,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<4;++o){const n=e.findNeighborTile(b[o],i),l=z(e,n),h=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[o],g=l!==z(e,d),c=a[o]!==h;s[o]=n,(g||c)&&(a[o]=h,this._markEdgeDirty(o));const u=r.edgeResolutions[o],m=this._calculateEdgeResolution(o,n);E(t(m)),E(m>=1),r.edgeResolutions[o]=m,u!==m&&this._markEdgeResolutionDirty(o)}const n=r.cornerPeerNeighbors;for(let t=0;t<4;++t){const a=e.findNeighborTile(j[t],i);n[t]=a;const o=z(e,s[t]),l=z(e,s[(t+1)%4]),h=z(e,a);q[t]=h,q[(t+1)%4]=l,q[(t+2)%4]=e,q[(t+3)%4]=o,E(q.some((t=>t?.isLoaded||t===e)));const d=q.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);q.forEach(((e,t)=>{e&&e?.level>d&&(q[t]=null)})),E(q.some((t=>t?.isLoaded||t===e)));const g=r.cornerNeighborData[t].cornerTiles,c=r.cornerNeighborData[t].cornerTileSamplerVersions;for(let e=0;e<4;++e){const r=q[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=g[e]!==r,a=!s&&c[e]!==i;(s||a)&&(g[e]=r,c[e]=i,this._markCornerDirty(t))}E(g.some((t=>t?.isLoaded||t===e)))}$&&E(this.geometryState.neighborData.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)q[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&E(!this.tile.intersectsClippingArea||this.geometryState.neighborData.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const t=this.tile,r=this._vao,i=this.geometryInfo.vertexAttributes,s=!r||!i||this._wireframeChanged||this._shadingChanged||this._numVerticesPerSideChanged||this._samplerDataChanged||this._clippingAreaChanged||this._dirtyEdgeResolutions,a=!s&&(0!==this._dirtyEdges||0!==this._dirtyEdgeResolutions),n=!a&&0!==this._dirtyCorners;s?(this.releaseGeometry(),this._createGeometry(e)):a||n?t.updateEdgeElevations():n?t.updateCornerElevations():console.warn("Update for no reason?"),this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._dirtyEdgeResolutions=0,this._dirtyEdges=0,this._dirtyCorners=0,this._clippingAreaChanged=!1,this._wireframeChanged=!1,this._shadingChanged=!1}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao.dispose(),this._vao=null,S(this.geometryInfo),!0)}ensureTexture(e,t){return r(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),i(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){r(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}_markCornerDirty(e){const t=1<<e;this._dirtyCorners|=t}_markEdgeDirty(e){const t=1<<e;this._dirtyEdges|=t}_markEdgeResolutionDirty(e){const t=1<<e;this._dirtyEdgeResolutions|=t,this._dirtyEdges|=t}_markAllEdgesAndCornersDirty(){this._dirtyCorners=15,this._dirtyEdges=15,this._dirtyEdgeResolutions=15}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(a=null);const n=this.geometryState;let o=!1;n.numVerticesPerSide!==s&&(this._numVerticesPerSideChanged=!0,n.numVerticesPerSide=s,n.samplerDataVersion++,o=!0),t.changed&&(this._samplerDataChanged=!0,n.samplerData=t.samplerData,n.samplerDataVersion++,o=!0),e(n.clippingArea,a)||(this._clippingAreaChanged=!0,n.clippingArea=a,o=!0);const l=r.surface,h=l.wireframe;n.wireframe!==h&&(this._wireframeChanged=!0,n.wireframe=h,o=!0);const d=l.shading;return n.shading!==d&&(this._shadingChanged=d,n.shading=d,o=d),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=o),o&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new I(e,G,{geometry:_(t.layout)},{geometry:M.createVertex(e,i.STATIC_DRAW,t.buffer)},M.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=w.Immediate){r(e)&&e.texture!==this._texture&&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}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[D.ELEVATION],i=t.length,s=new Array(i);let a=0,n=0,o=!1;for(let d=0;d<i;d++){const i=t[d];if(r(i.upsampleInfo)){const t=i.upsampleInfo.tile,r=t.layerInfo[D.ELEVATION][d].data,l=r&&r.samplerData;e&&e[a]===l||(o=!0),s[a++]=l,n=Math.max(n,t.lij[0])}else if(i.data){const t=this.tile.surface.layerViewByIndex(d,D.ELEVATION);if(N(this.tile,t.layer,!1)){const t=i.data;e&&e[a]===t.samplerData||(o=!0),s[a++]=t.samplerData,n=this.tile.level}}}r(e)&&e.length!==a&&(o=!0);const l=a>0,h=l?s:null;return l&&(s.length=a),{changed:o,samplerData:h,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=s(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return(this.geometryInfo.indices?.byteLength??0)+(this.geometryInfo.vertexAttributes?.byteLength??0)+e}get textureDescriptor(){return r(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!$)return;const e=this.tile;if(E(e?.isLoaded),!e.isLoaded||!e.intersectsClippingArea)return;const s=e.renderData;if(0===e.level)return;const p=e.surface.extent;if(r(p)&&!e.intersectsExtent(p))return;const _=b.map(((t,i)=>!!r(p)&&(i<2?-1:1)*(e.extent[3-i]-p[3-i])<0)),x=e.level;E(0===this._dirtyCorners),E(0===this._dirtyEdges),E(0===this._dirtyEdgeResolutions),E(!this._numVerticesPerSideChanged),E(!this._samplerDataChanged),E(!this._clippingAreaChanged),E(!this._wireframeChanged);const D=j.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),v=this.geometryState.neighborData;for(let t=0;t<4;++t){const r=v.cornerPeerNeighbors[t],i=D[t];E(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}b.forEach(((p,D)=>{if(_[D])return;const v=e.findNeighborTile(p,(e=>(e.level===x||e?.isLoaded)&&e?.intersectsClippingArea));if(!v){const t=!e.surface.updatingRootTiles&&r(e.surface.rootTiles)&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(p);return void E(!t)}E(v.isLoaded||v.level===e.level),E(v===this.geometryState.neighborData.edgePeerNeighbors[D]);const S=x-v.level;if(!v.isLoaded)return E(!v.isLeaf),void E(0===S);const $=v.renderData;E(L(e,v,p)),E(S>=0);const b=2**S;if(S<0)return void E(!1);const T=s.geometryInfo,j=T.outerEdges[D],R=T.numVerticesPerSide-1,w=$.geometryInfo;if(!w)return void E(!1);{const e=this.geometryState.neighborData.edgePeerNeighbors[D];if(e?.isLoaded){const t=e.renderData;E(e==e),E(s.geometryState.neighborData.edgePeerNeighborSamplerVersions[D]===t.geometryState.samplerDataVersion),E(this.geometryState.neighborData.edgePeerNeighborSamplerVersions[D]===t.geometryState.samplerDataVersion)}}const P=(D+2)%4,N=w.outerEdges[P],I=j.count-1,G=N.count-1;E(I*b===G,`Tile[${e.lij}]:e${D},res=${I} edgeRes mismatch with Neighbor[${v.lij}]:e${P},res=${G} (expected:${I*b})`);const M=e.extent,O=p===C.NORTH||p===C.SOUTH,q=N.count-1,z=q/2**S,J=j.count-1;if(z<1)return void E(1===J);E(z===J),E(t(z));const K=w.numVerticesPerSide-1;E(S>0||z===Math.max(K,R));const Q=e.getNeighborEdgeStartVertexIndex(D,v);E(0<=Q&&Q<b);const Y=Q*z;E(0<=Y&&Y<=q-z);let Z=0,ee=Y;j.getVertexPos(U,0),j.getVertexPos(k,j.count-1);const te=a(U,k),re=Math.max(W,1e-4*te);for(let t=0;t<=z;++t){j.getVertexPos(U,Z),N.getVertexPos(k,ee);const a=t/z,_=O?M[0]+a*(M[2]-M[0]):p===C.WEST?M[0]:M[2],x=O?p===C.SOUTH?M[1]:M[3]:M[1]+a*(M[3]-M[1]),S=e.surface.extent;if(i(S)||f(S,_,x)){const t=n(U,k),i=o(U)-y.radius,a=o(k)-y.radius,p=t<re;if(!p){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${D}[${Z}/${j.count}] and [${v.lij}].edge${P}[${ee}/${N.count}]`),r(S)&&console.warn(" surface extent= ",S," x,y=",_,",",x);const n=u();l(n,s.localOrigin,$.localOrigin),o(n)>0&&console.warn(` localOrigins: ${s.localOrigin} vs ${$.localOrigin} d=${o(n)} [${n}]`);(()=>{const t=m(U),r=m(k);e.updateEdgeElevations(),v.updateEdgeElevations(),j.getVertexPos(U,Z),N.getVertexPos(k,ee);const i=u();g(i,U,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${U} d=${o(i)} [${i}]`),g(i,k,r),o(i)>0&&console.warn(` XXX Neighbor[${v.lij}] edge out of date: ${r} vs ${k} d=${o(i)} [${i}]`)})(),E(p,`Mismatch in tile [${e.lij}].edge[${D}][${Z}/${j.count}] vs neighbor [${v.lij}].edge[${P}][${ee}/${N.count}] ${A(U)} vs ${A(k)} dist=${t} h(t|n|d)=${i}|${a}|${a-i}`)}if(e.surface.shading){j.getNormal(F,Z),N.getNormal(B,ee),h(X,F),h(H,B);const t=d(X,H),r=1-t<.01||!1||e===v;if(!r){const i=u();g(i,F,B);const s=()=>`Mismatch in tile edge normal ${V(e.lij)} (${Z}/${j.count-1}) edge ${D} vs neighbor ${V(v.lij)} (${ee}/${N.count-1}) nedge ${P} :${A(F)} vs ${A(B)} dot = ${t} : ${A(i)}`;console.warn("Mismatch in tile edge normal: ",s());{e.updateEdgeElevations(),v.updateEdgeElevations();const t=u(),r=u();j.getNormal(t,Z),N.getNormal(r,ee),c(F,t)||console.warn("Missing update in tile normal: ",A(F)," => ",A(t)),c(B,r)||console.warn("Missing update in neighbor normal: ",A(B)," => ",A(r))}E(r,s())}}}Z+=1,ee+=1}}))}}const U=u(),k=u(),F=u(),B=u(),X=u(),H=u(),W=1,q=[null,null,null,null];function z(e,t){return t?.isLoaded||t===e?t:null}export{w as ActivationTime,O as PatchRenderData,z as neighborTileIfLoadedOrSelf};
|
|
5
|
+
import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{isSome as r,isNone as i,mapOr as s}from"../../../core/maybe.js";import{i as a,j as n,u as o,b as l,n as h,e as d,w as g,F as c}from"../../../chunks/vec3.js";import{c as u,a as m}from"../../../chunks/vec3f64.js";import{empty as p}from"../../../geometry/support/aaBoundingBox.js";import{containsXY as f}from"../../../geometry/support/aaBoundingRect.js";import{earth as y}from"../../../geometry/support/Ellipsoid.js";import{glLayout as _}from"../support/buffer/glUtil.js";import{GeometryState as x}from"./GeometryState.js";import{NeighborIndex as C}from"./interfaces.js";import{LayerClass as D}from"./LayerClass.js";import{PatchGeometry as v,releaseGeometry as S}from"./PatchGeometry.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as $,internalAssert as E,neighborEdgeIndices as b,oppositeEdge as T,neighborCornerIndices as j,v32s as A,lij2s as V}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as w}from"./TextureFader.js";import{isEdgeNeighbor as L}from"./Tile.js";import P from"./TileOverlayData.js";import{fallsWithinLayer as N}from"./tileUtils.js";import{VertexArrayObject as I}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as G}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as M}from"../../webgl/BufferObject.js";class O{constructor(){this.geometryInfo=new v,this.intersectionData=null,this.geometryState=null,this._textureRef=new R((()=>this.tile.surface.textureFadeDuration)),this.overlay=new P,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1,this._shadingChanged=!1,this._dirtyEdgeResolutions=15,this._dirtyEdges=15,this._dirtyCorners=15}get tile(){return this._tile}init(e){this.clear(),this._tile=e;const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,p(t.boundingBox),t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new x,this.localOrigin=null,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._shadingChanged||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)E(this.geometryInfo.outerEdges[t].count===this.geometryState.neighborData.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const s=this.tile,a=this.geometryState.numVerticesPerSide-1;if(!s.surface.isGlobal){const t=s.surface.extent;if(r(t)&&(0===e&&s.extent[3]>t[3]||1===e&&s.extent[2]>t[2]||2===e&&s.extent[1]<t[1]||3===e&&s.extent[0]<t[0]))return a}const n=s.level,o=b[e];if(!t)return E(i(s.surface?.rootTiles)||s.surface.updatingRootTiles||!s.shouldHaveNeighbor(o)),a;if(t.isLoaded){const r=t,i=r.renderData.geometryState,s=n-r.level;if(E(s>=0),0===s){const e=i.numVerticesPerSide-1;return Math.max(e,a)}const o=2**s,l=i.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,l)}E(!t.isLeaf);let l=a;return t.forAllSubtreeOnSide(T(o),(e=>e===s||(e.isLoaded?(l=Math.max(l,2**(e.level-n)),!0):(E(!e.isLeaf),!1)))),l}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState.neighborData,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let o=0;o<4;++o){const n=e.findNeighborTile(b[o],i),l=z(e,n),h=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[o],g=l!==z(e,d),c=a[o]!==h;s[o]=n,(g||c)&&(a[o]=h,this._markEdgeDirty(o));const u=r.edgeResolutions[o],m=this._calculateEdgeResolution(o,n);E(t(m)),E(m>=1),r.edgeResolutions[o]=m,u!==m&&this._markEdgeResolutionDirty(o)}const n=r.cornerPeerNeighbors;for(let t=0;t<4;++t){const a=e.findNeighborTile(j[t],i);n[t]=a;const o=z(e,s[t]),l=z(e,s[(t+1)%4]),h=z(e,a);q[t]=h,q[(t+1)%4]=l,q[(t+2)%4]=e,q[(t+3)%4]=o,E(q.some((t=>t?.isLoaded||t===e)));const d=q.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);q.forEach(((e,t)=>{e&&e?.level>d&&(q[t]=null)})),E(q.some((t=>t?.isLoaded||t===e)));const g=r.cornerNeighborData[t].cornerTiles,c=r.cornerNeighborData[t].cornerTileSamplerVersions;for(let e=0;e<4;++e){const r=q[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=g[e]!==r,a=!s&&c[e]!==i;(s||a)&&(g[e]=r,c[e]=i,this._markCornerDirty(t))}E(g.some((t=>t?.isLoaded||t===e)))}$&&E(this.geometryState.neighborData.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)q[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&E(!this.tile.intersectsClippingArea||this.geometryState.neighborData.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const t=this.tile,r=this._vao,i=this.geometryInfo.vertexAttributes,s=!r||!i||this._wireframeChanged||this._shadingChanged||this._numVerticesPerSideChanged||this._samplerDataChanged||this._clippingAreaChanged||this._dirtyEdgeResolutions,a=!s&&(0!==this._dirtyEdges||0!==this._dirtyEdgeResolutions),n=!a&&0!==this._dirtyCorners;s?(this.releaseGeometry(),this._createGeometry(e)):a||n?t.updateEdgeElevations():n?t.updateCornerElevations():console.warn("Update for no reason?"),this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._dirtyEdgeResolutions=0,this._dirtyEdges=0,this._dirtyCorners=0,this._clippingAreaChanged=!1,this._wireframeChanged=!1,this._shadingChanged=!1}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao.dispose(),this._vao=null,S(this.geometryInfo),!0)}ensureTexture(e,t){return r(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),i(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){r(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}_markCornerDirty(e){const t=1<<e;this._dirtyCorners|=t}_markEdgeDirty(e){const t=1<<e;this._dirtyEdges|=t}_markEdgeResolutionDirty(e){const t=1<<e;this._dirtyEdgeResolutions|=t,this._dirtyEdges|=t}_markAllEdgesAndCornersDirty(){this._dirtyCorners=15,this._dirtyEdges=15,this._dirtyEdgeResolutions=15}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(a=null);const n=this.geometryState;let o=!1;n.numVerticesPerSide!==s&&(this._numVerticesPerSideChanged=!0,n.numVerticesPerSide=s,n.samplerDataVersion++,o=!0),t.changed&&(this._samplerDataChanged=!0,n.samplerData=t.samplerData,n.samplerDataVersion++,o=!0),e(n.clippingArea,a)||(this._clippingAreaChanged=!0,n.clippingArea=a,o=!0);const l=r.surface,h=l.wireframe;n.wireframe!==h&&(this._wireframeChanged=!0,n.wireframe=h,o=!0);const d=l.shading;return n.shading!==d&&(this._shadingChanged=d,n.shading=d,o=d),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=o),o&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new I(e,G,{geometry:_(t.layout)},{geometry:M.createVertex(e,i.STATIC_DRAW,t.buffer)},M.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=w.Immediate){r(e)&&e.texture!==this._texture&&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}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[D.ELEVATION],i=t.length,s=new Array(i);let a=0,n=0,o=!1;for(let d=0;d<i;d++){const i=t[d];if(r(i.upsampleInfo)){const t=i.upsampleInfo.tile,r=t.layerInfo[D.ELEVATION][d].data,l=r&&r.samplerData;e&&e[a]===l||(o=!0),s[a++]=l,n=Math.max(n,t.lij[0])}else if(i.data){const t=this.tile.surface.layerViewByIndex(d,D.ELEVATION);if(N(this.tile,t.layer,!1)){const t=i.data;e&&e[a]===t.samplerData||(o=!0),s[a++]=t.samplerData,n=this.tile.level}}}r(e)&&e.length!==a&&(o=!0);const l=a>0,h=l?s:null;return l&&(s.length=a),{changed:o,samplerData:h,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=s(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return(this.geometryInfo.indices?.byteLength??0)+(this.geometryInfo.vertexAttributes?.byteLength??0)+e}get textureDescriptor(){return r(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!$)return;const e=this.tile;if(E(e?.isLoaded),!e.isLoaded||!e.intersectsClippingArea)return;const s=e.renderData;if(0===e.level)return;const p=e.surface.extent;if(r(p)&&!e.intersectsExtent(p))return;const _=b.map(((t,i)=>!!r(p)&&(i<2?-1:1)*(e.extent[3-i]-p[3-i])<0)),x=e.level;E(0===this._dirtyCorners),E(0===this._dirtyEdges),E(0===this._dirtyEdgeResolutions),E(!this._numVerticesPerSideChanged),E(!this._samplerDataChanged),E(!this._clippingAreaChanged),E(!this._wireframeChanged);const D=j.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),v=this.geometryState.neighborData;for(let t=0;t<4;++t){const r=v.cornerPeerNeighbors[t],i=D[t];E(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}b.forEach(((p,D)=>{if(_[D])return;const v=e.findNeighborTile(p,(e=>(e.level===x||e?.isLoaded)&&e?.intersectsClippingArea));if(!v){const t=!e.surface.updatingRootTiles&&r(e.surface.rootTiles)&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(p);return void E(!t)}E(v.isLoaded||v.level===e.level),E(v===this.geometryState.neighborData.edgePeerNeighbors[D]);const S=x-v.level;if(!v.isLoaded)return E(!v.isLeaf),void E(0===S);const $=v.renderData;E(L(e,v,p)),E(S>=0);const b=2**S;if(S<0)return void E(!1);const T=s.geometryInfo,j=T.outerEdges[D],R=T.numVerticesPerSide-1,w=$.geometryInfo;if(!w)return void E(!1);{const e=this.geometryState.neighborData.edgePeerNeighbors[D];if(e?.isLoaded){const t=e.renderData;E(e==e),E(s.geometryState.neighborData.edgePeerNeighborSamplerVersions[D]===t.geometryState.samplerDataVersion),E(this.geometryState.neighborData.edgePeerNeighborSamplerVersions[D]===t.geometryState.samplerDataVersion)}}const P=(D+2)%4,N=w.outerEdges[P],I=j.count-1,G=N.count-1;E(I*b===G,`Tile[${e.lij}]:e${D},res=${I} edgeRes mismatch with Neighbor[${v.lij}]:e${P},res=${G} (expected:${I*b})`);const M=e.extent,O=p===C.NORTH||p===C.SOUTH,q=N.count-1,z=q/2**S,J=j.count-1;if(z<1)return void E(1===J);E(z===J),E(t(z));const K=w.numVerticesPerSide-1;E(S>0||z===Math.max(K,R));const Q=e.getNeighborEdgeStartVertexIndex(D,v);E(0<=Q&&Q<b);const Y=Q*z;E(0<=Y&&Y<=q-z);let Z=0,ee=Y;j.getVertexPos(U,0),j.getVertexPos(k,j.count-1);const te=a(U,k),re=Math.max(W,1e-4*te);for(let t=0;t<=z;++t){j.getVertexPos(U,Z),N.getVertexPos(k,ee);const a=t/z,_=O?M[0]+a*(M[2]-M[0]):p===C.WEST?M[0]:M[2],x=O?p===C.SOUTH?M[1]:M[3]:M[1]+a*(M[3]-M[1]),S=e.surface.extent;if(i(S)||f(S,_,x)){const t=n(U,k),i=o(U)-y.radius,a=o(k)-y.radius,p=t<re;if(!p){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${D}[${Z}/${j.count}] and [${v.lij}].edge${P}[${ee}/${N.count}]`),r(S)&&console.warn(" surface extent= ",S," x,y=",_,",",x);const n=u();l(n,s.localOrigin,$.localOrigin),o(n)>0&&console.warn(` localOrigins: ${s.localOrigin} vs ${$.localOrigin} d=${o(n)} [${n}]`);(()=>{const t=m(U),r=m(k);e.updateEdgeElevations(),v.updateEdgeElevations(),j.getVertexPos(U,Z),N.getVertexPos(k,ee);const i=u();g(i,U,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${U} d=${o(i)} [${i}]`),g(i,k,r),o(i)>0&&console.warn(` XXX Neighbor[${v.lij}] edge out of date: ${r} vs ${k} d=${o(i)} [${i}]`)})(),E(p,`Mismatch in tile [${e.lij}].edge[${D}][${Z}/${j.count}] vs neighbor [${v.lij}].edge[${P}][${ee}/${N.count}] ${A(U)} vs ${A(k)} dist=${t} h(t|n|d)=${i}|${a}|${a-i}`)}if(e.surface.shading){j.getNormal(F,Z),N.getNormal(B,ee),h(X,F),h(H,B);const t=d(X,H),r=1-t<.02||!1||e===v;if(!r){const i=u();g(i,F,B);const s=()=>`Mismatch in tile edge normal ${V(e.lij)} (${Z}/${j.count-1}) edge ${D} vs neighbor ${V(v.lij)} (${ee}/${N.count-1}) nedge ${P} :${A(F)} vs ${A(B)} dot = ${t} : ${A(i)}`;console.warn("Mismatch in tile edge normal: ",s());{e.updateEdgeElevations(),v.updateEdgeElevations();const t=u(),r=u();j.getNormal(t,Z),N.getNormal(r,ee),c(F,t)||console.warn("Missing update in tile normal: ",A(F)," => ",A(t)),c(B,r)||console.warn("Missing update in neighbor normal: ",A(B)," => ",A(r))}E(r,s())}}}Z+=1,ee+=1}}))}}const U=u(),k=u(),F=u(),B=u(),X=u(),H=u(),W=1,q=[null,null,null,null];function z(e,t){return t?.isLoaded||t===e?t:null}export{w as ActivationTime,O as PatchRenderData,z as neighborTileIfLoadedOrSelf};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{BufferObject as r}from"../../../webgl/BufferObject.js";import{Usage as e,BufferType as t,PrimitiveType as i,DataType as s}from"../../../webgl/enums.js";class n{constructor(r){this._rctx=r,this._indexBuffer=this._createIndexbuffer(),this._program=this._createProgram()}_createProgram(){const r="\n void main(void) {\n gl_Position = vec4(0.0, 0.0, float(gl_VertexID)-2.0, 1.0);\n }",e="\n void main(void) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }";return this._rctx.programCache.acquire(r,e,new Map([]))}_createIndexbuffer(){return r.createIndex(this._rctx,e.STATIC_DRAW,new Uint32Array([0]))}resetIndicesType(){this._program?.isCompiled&&this._indexBuffer&&(this._rctx.bindVAO(null),this._rctx.useProgram(this._program),this._rctx.bindBuffer(this._indexBuffer,t.ELEMENT_ARRAY_BUFFER),this._rctx.drawElements(i.POINTS,1,s.UNSIGNED_INT,0))}dispose(){this._program?.dispose(),this._indexBuffer?.dispose()}}export{n as AppleAmdDriverHelper};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{removeUnordered as e,filterInPlace as t}from"../../../../../core/arrayUtils.js";import{someMap as r}from"../../../../../core/MapUtils.js";import{isNone as s,isSome as i}from"../../../../../core/maybe.js";import{NestedMap as a}from"../../../../../core/NestedMap.js";import o from"../../../../../core/PooledArray.js";import{m as n,a as l,t as h}from"../../../../../chunks/mat4.js";import{c as u}from"../../../../../chunks/mat4f64.js";import{glLayout as f}from"../../../support/buffer/glUtil.js";import{ShaderOutput as c}from"../../core/shaderLibrary/ShaderOutput.js";import{
|
|
5
|
+
import{removeUnordered as e,filterInPlace as t}from"../../../../../core/arrayUtils.js";import{someMap as r}from"../../../../../core/MapUtils.js";import{isNone as s,isSome as i}from"../../../../../core/maybe.js";import{NestedMap as a}from"../../../../../core/NestedMap.js";import o from"../../../../../core/PooledArray.js";import{m as n,a as l,t as h}from"../../../../../chunks/mat4.js";import{c as u}from"../../../../../chunks/mat4f64.js";import{glLayout as f}from"../../../support/buffer/glUtil.js";import{ShaderOutput as c}from"../../core/shaderLibrary/ShaderOutput.js";import{AppleAmdDriverHelper as m}from"../../lib/AppleAmdDriverHelper.js";import{GLMaterials as d}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as g}from"../../lib/Material.js";import{DirtyState as p}from"../../lib/ModelDirtyTypes.js";import{assert as y,setMatrixTranslation3 as _}from"../../lib/Util.js";import{DrawParameters as v}from"../DrawParameters.js";import{WaterMaterial as w}from"../WaterMaterial.js";import{BufferRange as b,mergeAdjacentRanges as O}from"./BufferRange.js";import{Instance as A}from"./Instance.js";import{PerBufferData as B,hasVao as C}from"./PerBufferData.js";import{PerOriginData as E}from"./PerOriginData.js";import{VaoCache as D}from"./VaoCache.js";class H{constructor(e,t,r){this._rctx=e,this._materialRepository=t,this.material=r,this._dataByOrigin=new Map,this._appleAmdDriverHelper=null,this._hasHighlights=!1,this._hasOccludees=!1,this._glMaterials=new d(this.material,this._materialRepository),this._bufferWriter=r.createBufferWriter(),this._vaoCache=new D(e,r.vertexAttributeLocations,f(this._bufferWriter.vertexBufferLayout)),this._rctx.driverTest.drawArraysRequiresIndicesTypeReset.result&&(this._appleAmdDriverHelper=new m(this._rctx))}dispose(){this._glMaterials.destroy(),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache.dispose(),this._appleAmdDriverHelper?.dispose()}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this.material instanceof w}get rendersOccluded(){return!this.isEmpty&&this.material.renderOccluded!==g.Occlude}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const i of e){const e=i.renderGeometry,a=this._dataByOrigin.get(e.localOrigin.id)?.findBuffer(e.id);if(s(a))return;const o=a.instances.get(e.id);if(i.updateType&(p.GEOMETRY|p.TRANSFORMATION)){const s=z(t.elementCount(o.geometry.geometry)*r),i=t.vertexBufferLayout.createView(s.buffer);this._writeGeometry(e,i,0),a.vao.vertexBuffers.geometry.setSubData(s,o.from*r,0,o.numElements*r)}i.updateType&(p.HIGHLIGHT|p.OCCLUDEE|p.VISIBILITY)&&(a.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new a;for(const i of e){const e=i.localOrigin;if(s(e))continue;let t=r.get(e.id,null);s(t)&&(t=new x(e.vec3),r.set(e.id,null,t)),t.changes.push(i)}for(const i of t){const e=i.localOrigin;if(s(e))continue;const t=this._dataByOrigin.get(e.id)?.findBuffer(i.id);if(s(t))continue;let a=r.get(e.id,t);s(a)&&(a=new x(e.vec3),r.set(e.id,t,a)),a.changes.push(i)}return r}_addAndRemoveGeometries(t,r){const{_bufferWriter:a,_dataByOrigin:o}=this,n=a.vertexBufferLayout.stride/4,l=this._computeDeltas(t,r);l.forEach(((t,r)=>{const h=t.get(null),u=i(h)?h.changes:[];l.delete(r,null);let f=o.get(r);if(t.forEach(((t,i)=>{if(l.delete(r,i),s(i))return void y(!1,"No VAO for removed geometries");if(i.instances.size===t.changes.length)return this._vaoCache.deleteVao(i.vao),e(f.buffers,i),void(0===f.buffers.length&&0===u.length&&o.delete(r));const h=i.numElements,c=i.vao.size/4,m=u.reduce(((e,t)=>e+a.elementCount(t.geometry)),0),d=t.changes.reduce(((e,t)=>e+a.elementCount(t.geometry)),0),g=Math.min((h+m-d)*n,W),p=g>c;g>L&&g<c/2?(t.changes.forEach((({id:e})=>i.deleteInstance(e))),i.instances.forEach((({geometry:e})=>u.push(e))),this._vaoCache.deleteVao(i.vao),e(f.buffers,i)):p?this._applyAndRebuild(i,u,t):this._applyRemoves(i,t)})),u.length>0)for(s(f)&&(f=new E(h.origin),o.set(r,f)),f.buffers.forEach((e=>this._applyAdds(e,u)));u.length>0;)f.buffers.push(this._applyAndRebuild(new B,u,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.drawCommandsDirty&&(e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,r(e.instances,(t=>(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees))),e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)),this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(i(r))for(const i of r.changes)e.deleteInstance(i.id);const s=this._bufferWriter,a=s.vertexBufferLayout.stride,o=a/4,n=Math.floor(W/o);let l=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry);if(l+i>n&&l>0){t.push(r);break}l+=i;const a=new A(r,0,0);y(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const h=l*o,u=z(h),f=s.vertexBufferLayout.createView(u.buffer);let c=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,f,c);const i=c;c+=s.elementCount(t.geometry.geometry),e.updateInstance(r,i,c),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(N(h)),e.vao.vertexBuffers.geometry.setSubData(u,0,0,c*o),e.holes.clear();const m=e.holes.pushNew();return m.from=c,m.to=Math.floor(e.vao.size/a),e.updateDrawCommands(a),e}_applyRemoves(e,t){if(0===t.changes.length)return;for(const o of t.changes){const t=o.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const s=R.back();if(s){if(s.to===r.from){s.to=r.to;continue}if(s.from===r.to){s.from=r.from;continue}}const i=R.pushNew();i.from=r.from,i.to=r.to}O(R);const r=this._bufferWriter.vertexBufferLayout.stride/4,s=R.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,i=z(s);i.fill(0,0,s);const a=e.vao.vertexBuffers.geometry;R.forAll((e=>a.setSubData(i,e.from*r,0,e.numElements*r))),e.holes.pushArray(R.data,R.length),R.forAll(((e,t)=>R.data[t]=null)),R.clear(),e.drawCommandsDirty=!0}_applyAdds(e,r){if(0===r.length)return;if(!C(e))return void this._applyAndRebuild(e,r,null);const i=this._bufferWriter,a=i.vertexBufferLayout.stride/4,o=e.numElements,n=r.reduce(((e,t)=>e+i.elementCount(t.geometry)),0),l=Math.min((o+n)*a,W),h=4*l;if(e.vao.size<N(W-L)&&h>e.vao.size)return void this._applyAndRebuild(e,r,null);O(e.holes);const u=new Array;for(const t of r){const r=i.elementCount(t.geometry),s=M(e.holes,r);u.push(s)}const f=e.vao.vertexBuffers.geometry;let c=0,m=0,d=0;const g=z(l),p=i.vertexBufferLayout.createView(g.buffer);r.forEach(((t,r)=>{const o=u[r];if(s(o))return;if(!(d===o)){const e=d-m;e>0&&f.setSubData(g,m*a,0,e*a),m=o,c=0}const n=i.elementCount(t.geometry);this._writeGeometry(t,p,c),c+=n,d=o+n;const l=new A(t,o,o+n);y(null==e.instances.get(t.id)),e.addInstance(t.id,l),e.drawCommandsDirty=!0}));const _=d-m;_>0&&f.setSubData(g,m*a,0,_*a),t(r,((e,t)=>s(u[t])))}_writeGeometry(e,t,r){const s=e.localOrigin.vec3;_(j,-s[0],-s[1],-s[2]);const a=i(e.transformation)?n(I,j,e.transformation):j;l(S,a),h(S,S),this._bufferWriter.write(a,S,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}requiresSlot(e,t){return this.material.requiresSlot(e,t)}render(e,t){if(!this.requiresSlot(t.slot,e))return!1;const r=e===c.Highlight||e===c.ShadowHighlight;if(r&&!this._hasHighlights)return!1;const a=e===c.ShadowExcludeHighlight,o=!(r||a),n=this._rctx;let l;const h=()=>{if(i(l))return l;const r=this._glMaterials.load(n,t.slot,e);return s(r)?null:(l=r.beginSlot(t),s(l)?null:(n.bindTechnique(l,this.material.parameters,t),l))};this._appleAmdDriverHelper?.resetIndicesType();for(const i of this._dataByOrigin.values())for(const e of i.buffers){if(r&&!e.hasHighlights)continue;const l=(r?e.drawCommandsHighlight:a&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,u=o&&e.drawCommandsOccludees||null;if(l?.length||u?.length){const r=h();if(s(r))return!1;r.program.bindDraw(new v(i.origin),t,this.material.parameters),r.ensureAttributeLocations(e.vao),n.bindVAO(e.vao),l?.length&&(r.bindPipelineState(n,t.slot,!1),l.forAll((e=>n.drawArrays(r.primitiveType,e.first,e.count)))),u?.length&&(r.bindPipelineState(n,t.slot,!0),u.forAll((e=>n.drawArrays(r.primitiveType,e.first,e.count))))}}return i(l)}get test(){return{material:this.material,glMaterials:this._glMaterials,dataByOrigin:this._dataByOrigin}}}class x{constructor(e){this.origin=e,this.changes=new Array}}function M(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const j=u(),I=u(),S=u(),R=new o({allocator:e=>e||new b,deallocator:null}),L=65536,G=4*L,T=16777216,W=T/4;let V=new Float32Array(L);function z(e){return V.length<e&&(V=new Float32Array(e)),V}function N(e){const t=4*e;return t<G?G:Math.max(Math.min(Math.ceil(1.5*t/G)*G,T),t)}export{H as MergedRenderer};
|