@arcgis/core 4.25.0-next.20220707 → 4.25.0-next.20220708
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/TimeExtent.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/3a42d96ea3b59d33bfe8.js +1 -0
- package/interfaces.d.ts +379 -125
- package/package.json +1 -1
- package/rest/route/utils.js +1 -1
- package/rest/serviceArea.js +1 -1
- package/rest/support/ServiceAreaParameters.js +1 -1
- package/rest/support/ServiceAreaSolveResult.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/terrain/GeometryState.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/webscene/Slide.js +1 -1
- package/widgets/Zoom/ZoomConditions3D.js +1 -1
- package/widgets/Zoom/ZoomViewModel.js +1 -1
- package/widgets/Zoom.js +1 -1
- package/assets/esri/core/workers/chunks/d9e1fc61af9d2f08b10a.js +0 -1
- package/core/queryUtils.js +0 -5
package/package.json
CHANGED
package/rest/route/utils.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isNone as
|
|
5
|
+
import{isNone as r}from"../../core/maybe.js";import{impedanceAttributeNameJsonMap as t}from"../support/networkEnums.js";function e(e,i){if(r(e))return null;const s={},o=new RegExp(`^${i}`,"i");for(const r of Object.keys(e))if(o.test(r)){const o=r.substring(i.length);s[t.fromJSON(o)]=e[r]}return s}function i(e,i,s){if(!r(e)){i.attributes||(i.attributes={});for(const r in e){const o=t.toJSON(r);i.attributes[`${s}${o}`]=e[r]}}}function s(r){const e={};for(const i of Object.keys(r)){const s=i;e[t.fromJSON(s)]=r[i]}return e}function o(r){const e={};for(const i of Object.keys(r)){const s=i;e[t.toJSON(s)]=r[i]}return e}function a(t,e){return r(t)||r(e)?null:Math.round((t-e)/6e4)}function n(r){const t=r.toJSON(),e=t;return e.accumulateAttributeNames&&(e.accumulateAttributeNames=t.accumulateAttributeNames.join()),e.attributeParameterValues&&(e.attributeParameterValues=JSON.stringify(t.attributeParameterValues)),e.barriers&&(e.barriers=JSON.stringify(t.barriers)),e.outSR&&(e.outSR=t.outSR.wkid),e.overrides&&(e.overrides=JSON.stringify(t.overrides)),e.polygonBarriers&&(e.polygonBarriers=JSON.stringify(t.polygonBarriers)),e.polylineBarriers&&(e.polylineBarriers=JSON.stringify(t.polylineBarriers)),e.restrictionAttributeNames&&(e.restrictionAttributeNames=t.restrictionAttributeNames.join()),e.stops&&(e.stops=JSON.stringify(t.stops)),e.travelMode&&(e.travelMode=JSON.stringify(t.travelMode)),e}function u(r){const t=r.toJSON(),e=t;return e.accumulateAttributeNames&&(e.accumulateAttributeNames=t.accumulateAttributeNames.join()),e.attributeParameterValues&&(e.attributeParameterValues=JSON.stringify(t.attributeParameterValues)),e.barriers&&(e.barriers=JSON.stringify(t.barriers)),e.facilities&&(e.facilities=JSON.stringify(t.facilities)),e.incidents&&(e.incidents=JSON.stringify(t.incidents)),e.outSR&&(e.outSR=t.outSR.wkid),e.overrides&&(e.overrides=JSON.stringify(t.overrides)),e.polygonBarriers&&(e.polygonBarriers=JSON.stringify(t.polygonBarriers)),e.polylineBarriers&&(e.polylineBarriers=JSON.stringify(t.polylineBarriers)),e.restrictionAttributeNames&&(e.restrictionAttributeNames=t.restrictionAttributeNames.join()),e.travelMode&&(e.travelMode=JSON.stringify(t.travelMode)),e}function l(r){const t=r.toJSON(),e=t;return e.accumulateAttributeNames&&(e.accumulateAttributeNames=t.accumulateAttributeNames.join()),e.attributeParameterValues&&(e.attributeParameterValues=JSON.stringify(t.attributeParameterValues)),e.barriers&&(e.barriers=JSON.stringify(t.barriers)),e.defaultBreaks&&(e.defaultBreaks=t.defaultBreaks.join()),e.excludeSourcesFromPolygons&&(e.excludeSourcesFromPolygons=t.excludeSourcesFromPolygons.join()),e.facilities&&(e.facilities=JSON.stringify(t.facilities)),e.outSR&&(e.outSR=t.outSR.wkid),e.overrides&&(e.overrides=JSON.stringify(t.overrides)),e.polygonBarriers&&(e.polygonBarriers=JSON.stringify(t.polygonBarriers)),e.polylineBarriers&&(e.polylineBarriers=JSON.stringify(t.polylineBarriers)),e.restrictionAttributeNames&&(e.restrictionAttributeNames=t.restrictionAttributeNames.join()),e.travelMode&&(e.travelMode=JSON.stringify(t.travelMode)),e}export{u as closestFacilityParametersToQueryParameters,o as fromKebabImpedanceAttributes,e as getPrefixedProperties,a as getTimezoneOffset,n as routeParametersToQueryParameters,l as serviceAreaParametersToQueryParameters,i as setPrefixedProperties,s as toKebabImpedanceAttributes};
|
package/rest/serviceArea.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import r from"../request.js";import{
|
|
5
|
+
import r from"../request.js";import{normalizeCentralMeridian as e}from"../geometry/support/normalizeUtils.js";import{collectGeometries as t,isInputGeometryZAware as o,fetchServiceDescription as i,dropZValuesOffInputGeometry as s}from"./networkService.js";import{parseUrl as a}from"./utils.js";import{serviceAreaParametersToQueryParameters as n}from"./route/utils.js";import f from"./support/FeatureSet.js";import p from"./support/ServiceAreaSolveResult.js";function u(r){return r instanceof f}async function l(f,l,c){const m=[],y=[],B={},j={},g=a(f),{path:S}=g;u(l.facilities)&&t(l.facilities.features,y,"facilities.features",B),u(l.pointBarriers)&&t(l.pointBarriers.features,y,"pointBarriers.features",B),u(l.polylineBarriers)&&t(l.polylineBarriers.features,y,"polylineBarriers.features",B),u(l.polygonBarriers)&&t(l.polygonBarriers.features,y,"polygonBarriers.features",B);const h=await e(y);for(const r in B){const e=B[r];m.push(r),j[r]=h.slice(e[0],e[1])}if(o(j,m)){let r=null;try{r=await i(S,l.apiKey,c)}catch{}r&&!r.hasZ&&s(j,m)}for(const r in j)j[r].forEach(((e,t)=>{l.get(r)[t].geometry=e}));const v={...c,query:{...g.query,...n(l),f:"json"}},{data:w}=await r(`${S}/solveServiceArea`,v);return p.fromJSON(w)}export{l as solve};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{ClonableMixin as e}from"../../core/Clonable.js";import r from"../../core/Collection.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import{isNone as i,isSome as s}from"../../core/maybe.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{ensureClass as p}from"../../core/accessorSupport/ensureType.js";import{enumeration as l}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{writer as y}from"../../core/accessorSupport/decorators/writer.js";import{apiKey as m}from"./commonProperties.js";import{impedanceAttributeNameJsonMap as c,restrictionAttributeNameJsonMap as d,lengthUnitJsonMap as v,outputLineJsonMap as w,outputPolygonJsonMap as j,restrictUTurnJsonMap as h,travelDirectionJsonMap as g}from"./networkEnums.js";import B from"./TravelMode.js";import P from"../../geometry/SpatialReference.js";var f;function b(t,e,o){s(t)&&(e[o]=r.isCollection(t)?{features:t.toArray().map((t=>t.toJSON()))}:t.toJSON())}let A=f=class extends(e(o)){constructor(t){super(t),this.accumulateAttributes=null,this.apiKey=null,this.attributeParameterValues=null,this.defaultBreaks=null,this.excludeSourcesFromPolygons=null,this.facilities=null,this.geometryPrecision=null,this.geometryPrecisionM=null,this.geometryPrecisionZ=null,this.ignoreInvalidLocations=null,this.impedanceAttribute=null,this.mergeSimilarPolygonRanges=!1,this.outputGeometryPrecision=null,this.outputGeometryPrecisionUnits=null,this.outputLines=null,this.outputPolygons=null,this.outSpatialReference=null,this.overlapLines=!1,this.overlapPolygons=!1,this.overrides=null,this.pointBarriers=null,this.polygonBarriers=null,this.polylineBarriers=null,this.preserveObjectID=null,this.restrictionAttributes=null,this.restrictUTurns=null,this.returnFacilities=!1,this.returnPointBarriers=!1,this.returnPolygonBarriers=!1,this.returnPolylineBarriers=!1,this.splitLinesAtBreaks=!1,this.splitPolygonsAtBreaks=!1,this.timeOfDay=null,this.timeOfDayIsUTC=null,this.travelDirection=null,this.travelMode=null,this.trimOuterPolygon=!1,this.trimPolygonDistance=null,this.trimPolygonDistanceUnits=null,this.useHierarchy=null}static from(t){return p(f,t)}readAccumulateAttributes(t){return i(t)?null:t.map((t=>c.fromJSON(t)))}writeAccumulateAttributes(t,e,r){!i(t)&&t.length&&(e[r]=t.map((t=>c.toJSON(t))))}writeFacilities(t,e,r){b(t,e,r)}writePointBarriers(t,e,r){b(t,e,r)}writePolygonBarrier(t,e,r){b(t,e,r)}writePolylineBarrier(t,e,r){b(t,e,r)}readRestrictionAttributes(t){return i(t)?null:t.map((t=>d.fromJSON(t)))}writeRestrictionAttributes(t,e,r){!i(t)&&t.length&&(e[r]=t.map((t=>d.toJSON(t))))}readTimeOfDay(t,e){const{timeOfDay:r}=e;return i(r)?null:"now"===r?"now":new Date(r)}writeTimeOfDay(t,e){i(t)||(e.timeOfDay="now"===t?"now":t.getTime())}};t([n({type:[String],json:{name:"accumulateAttributeNames",write:!0}})],A.prototype,"accumulateAttributes",void 0),t([a("accumulateAttributes")],A.prototype,"readAccumulateAttributes",null),t([y("accumulateAttributes")],A.prototype,"writeAccumulateAttributes",null),t([n(m)],A.prototype,"apiKey",void 0),t([n({json:{write:!0}})],A.prototype,"attributeParameterValues",void 0),t([n({type:[Number],json:{write:!0}})],A.prototype,"defaultBreaks",void 0),t([n({type:[String],json:{write:!0}})],A.prototype,"excludeSourcesFromPolygons",void 0),t([n({json:{write:!0}})],A.prototype,"facilities",void 0),t([y("facilities")],A.prototype,"writeFacilities",null),t([n({type:Number,json:{write:!0}})],A.prototype,"geometryPrecision",void 0),t([n({type:Number,json:{write:!0}})],A.prototype,"geometryPrecisionM",void 0),t([n({type:Number,json:{write:!0}})],A.prototype,"geometryPrecisionZ",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"ignoreInvalidLocations",void 0),t([l(c,{name:"impedanceAttributeName",ignoreUnknown:!1})],A.prototype,"impedanceAttribute",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"mergeSimilarPolygonRanges",void 0),t([n({type:Number,json:{write:!0}})],A.prototype,"outputGeometryPrecision",void 0),t([l(v)],A.prototype,"outputGeometryPrecisionUnits",void 0),t([l(w)],A.prototype,"outputLines",void 0),t([l(j)],A.prototype,"outputPolygons",void 0),t([n({type:P,json:{name:"outSR",write:!0}})],A.prototype,"outSpatialReference",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"overlapLines",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"overlapPolygons",void 0),t([n({json:{write:!0}})],A.prototype,"overrides",void 0),t([n({json:{name:"barriers",write:!0}})],A.prototype,"pointBarriers",void 0),t([y("pointBarriers")],A.prototype,"writePointBarriers",null),t([n({json:{write:!0}})],A.prototype,"polygonBarriers",void 0),t([y("polygonBarriers")],A.prototype,"writePolygonBarrier",null),t([n({json:{write:!0}})],A.prototype,"polylineBarriers",void 0),t([y("polylineBarriers")],A.prototype,"writePolylineBarrier",null),t([n({type:Boolean,json:{write:!0}})],A.prototype,"preserveObjectID",void 0),t([n({type:[String],json:{name:"restrictionAttributeNames",write:!0}})],A.prototype,"restrictionAttributes",void 0),t([a("restrictionAttributes")],A.prototype,"readRestrictionAttributes",null),t([y("restrictionAttributes")],A.prototype,"writeRestrictionAttributes",null),t([l(h)],A.prototype,"restrictUTurns",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"returnFacilities",void 0),t([n({type:Boolean,json:{name:"returnBarriers",write:!0}})],A.prototype,"returnPointBarriers",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"returnPolygonBarriers",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"returnPolylineBarriers",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"splitLinesAtBreaks",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"splitPolygonsAtBreaks",void 0),t([n({type:Date,json:{type:Number,write:!0}})],A.prototype,"timeOfDay",void 0),t([a("timeOfDay")],A.prototype,"readTimeOfDay",null),t([y("timeOfDay")],A.prototype,"writeTimeOfDay",null),t([n({type:Boolean,json:{write:!0}})],A.prototype,"timeOfDayIsUTC",void 0),t([l(g)],A.prototype,"travelDirection",void 0),t([n({type:B,json:{write:!0}})],A.prototype,"travelMode",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"trimOuterPolygon",void 0),t([n({type:Number,json:{write:!0}})],A.prototype,"trimPolygonDistance",void 0),t([l(v)],A.prototype,"trimPolygonDistanceUnits",void 0),t([n({type:Boolean,json:{write:!0}})],A.prototype,"useHierarchy",void 0),A=f=t([u("esri.rest.support.ServiceAreaParameters")],A);const S=A;export{S 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.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as r}from"../../chunks/tslib.es6.js";import
|
|
5
|
+
import{_ as r}from"../../chunks/tslib.es6.js";import{JSONSupport as e}from"../../core/JSONSupport.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import t from"./FeatureSet.js";import i from"./NAMessage.js";let p=class extends e{constructor(r){super(r),this.facilities=null,this.messages=null,this.pointBarriers=null,this.polylineBarriers=null,this.polygonBarriers=null,this.serviceAreaPolylines=null,this.serviceAreaPolygons=null}};r([o({type:t})],p.prototype,"facilities",void 0),r([o({type:[i]})],p.prototype,"messages",void 0),r([o({type:t,json:{read:{source:"barriers"}}})],p.prototype,"pointBarriers",void 0),r([o({type:t})],p.prototype,"polylineBarriers",void 0),r([o({type:t})],p.prototype,"polygonBarriers",void 0),r([o({type:t,json:{read:{source:"saPolylines"}}})],p.prototype,"serviceAreaPolylines",void 0),r([o({type:t,json:{read:{source:"saPolygons"}}})],p.prototype,"serviceAreaPolygons",void 0),p=r([s("esri.rest.support.ServiceAreaSolveResult")],p);const l=p;export{l as default};
|
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const a="20220708",b="736a7d84a104bb98f0d24e137a1a98fb9e771053";export{a as buildDate,b as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Handles.js";import s from"../../../core/Logger.js";import{isNone as o,isSome as n}from"../../../core/maybe.js";import{watch as h,on as l,when as p}from"../../../core/reactiveUtils.js";import{addFrameTask as c}from"../../../core/scheduling.js";import{createScreenPoint as m}from"../../../core/screenUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{d as u}from"../../../chunks/vec3.js";import{d as w}from"../../../chunks/vec3f64.js";import{s as g}from"../../../chunks/vec4.js";import{c as y}from"../../../chunks/vec4f64.js";import C from"../../../geometry/Extent.js";import f from"../../../geometry/Point.js";import{canProject as _}from"../../../geometry/support/webMercatorUtils.js";import{ViewingMode as x}from"../../ViewingMode.js";import{applyAll as R}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as P,surfaceElevationBelowRenderLocation as O}from"../camera/intersectionUtils.js";import{ConstraintsManager as T}from"./ConstraintsManager.js";import{Frustum as b}from"./Frustum.js";import{GoToOperation as S}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as j}from"./controllers/SurfaceCollisionCorrectionController.js";import{internalToExternal as M,externalToInternal as I,toExtent as B,distanceToScale as L,scaleToZoom as U,fromExtent as k,OrientationMode as z,getObserverForPointAtDistance as E,scaleToDistance as V,zoomToScale as A}from"../support/cameraUtils.js";import{PropertiesPool as D}from"../support/PropertiesPool.js";import{fromCamera as H,toCamera as N}from"../support/viewpointUtils.js";import{Camera as F,PaddingSide as G}from"../webgl-engine/lib/Camera.js";let q=class extends r{constructor(e){super(e),this.propertiesPool=new D({frustum:b},this),this.handles=new a,this.cameraSetByUser=!1,this.gotoOperation=null,this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._maximumPixelRatioOverride=null,this.test={contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,setMaximumPixelRatio:e=>this._maximumPixelRatioOverride=e}}get camera(){const e=this._get("camera");if(!this.ready)return e;const t=M(this.view,this.view.state.camera);return t&&e&&t.equals(e)?e:t}set camera(e){this._updatePropertyBeforeReady("camera",e)||(this.view.elevationProvider.enableElevationCache(!0),this.setStateCamera(I(this.view,e),{applyConstraints:!1})||s.getLogger(this.declaredClass).error("#camera=","Invalid camera",e),this.view.elevationProvider.enableElevationCache(!1))}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=M(this.view,this.view.state.contentCamera);return t&&e&&t.equals(e)?e:t}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=I(this.view,e);o(t)?this.view.state.contentCamera=null:(this._updateElevation(t),this.view.state.contentCamera=t)}installContentCameraReset(e){if(this.handles.remove("contentCameraReset"),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=w(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.handles.add([h((()=>this.contentCamera),(()=>{e.sticky||(this.handles.remove("contentCameraReset"),this.test.contentCameraResetState.clear())})),h((()=>this.zoom),(e=>{this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)})),h((()=>this.view.state.camera),(e=>{const t=u(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)}))],"contentCameraReset"),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():s.getLogger(this.declaredClass).error("#center=","Invalid center",e):s.getLogger(this.declaredClass).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference.wkid+")",e):s.getLogger(this.declaredClass).error("#center=","Center may not be null or undefined"))}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=B(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return n(t)?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||s.getLogger(this.declaredClass).error("#extent=","Invalid extent",e):s.getLogger(this.declaredClass).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference.wkid+")",e):s.getLogger(this.declaredClass).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this.propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get hasInitialView(){return!!this.view.get("map.initialViewProperties.viewpoint")}get scale(){if(this.ready){const e=this.view.pointsOfInterest.centerOnContent;return L(this.view,e.distance,e.location.latitude)}return this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||s.getLogger(this.declaredClass).error("#scale=","Invalid scale",e)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[G.TOP]/i),s=Math.round(t[G.RIGHT]/i),o=Math.round(t[G.BOTTOM]/i),n=Math.round(t[G.LEFT]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===o&&r.left===n?r:{top:a,right:s,bottom:o,left:n}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,Z),this.view.state.updateCamera((e=>e.padding=Z)))}_paddingToArray(e,t,i){e?g(i,e.top||0,e.right||0,e.bottom||0,e.left||0):g(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return m((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?H(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e)if(this.isCompatible(e))this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||s.getLogger(this.declaredClass).error("#viewpoint=","Invalid viewpoint",e);else{const t=n(e.camera)?e.camera.position:e.targetGeometry,i=n(t)&&t.spatialReference;s.getLogger(this.declaredClass).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference.wkid+")",e)}else s.getLogger(this.declaredClass).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?U(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||s.getLogger(this.declaredClass).error("#zoom=","Invalid zoom",e)}get maximumPixelRatio(){if(n(this._maximumPixelRatioOverride))return this._maximumPixelRatioOverride;let e=1/0;const{maximumPixelRatio:t,maximumRenderResolution:i}=this.view.qualitySettings;if(null!=t&&(e=Math.min(e,t)),null!=i){const t=i/Math.max(this.view.width,this.view.height);e=Math.min(e,t)}return e}get _devicePixelRatio(){return o(this._devicePixelRatioOverride)?Math.min(this._windowDevicePixelRatio,this.maximumPixelRatio):this._devicePixelRatioOverride}initialize(){this.handles.add([l((()=>this.view.state.events),"before-camera-change",(e=>this._updateElevation(e.camera)))]),h((()=>this.view.state.camera),(e=>this._updateElevation(e)),{once:!0,sync:!0}),this.handles.add(c({prepare:()=>this._prepareFrame()})),this.handles.add(h((()=>this.view.state.cameraController),(()=>{this.cameraSetByUser=!0,this.handles.remove($)}))),this.handles.add(l((()=>this.view.state.events),"camera-projection-changed",(()=>this.notifyChange("scale"))))}destroy(){this.deinit(),this.handles&&(this.handles.destroy(),this.handles=null),this.propertiesPool&&(this.propertiesPool.destroy(),this.propertiesPool=null)}init(){this.constraintsManager=new T({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this.cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this.cameraSetByUser){const e=this.view.get("map.initialViewProperties.viewpoint")||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):this.view.state.viewingMode===x.Local&&this.handles.add(p((()=>this.view.basemapTerrain.ready),(()=>{this.handles.remove($),this._setInitialView(this.view.dataExtent)}),{once:!0,initial:!0}),$)}}deinit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this.cameraSetByUser=!1,this.handles.remove($),this.constraintsManager&&(this.constraintsManager.destroy(),this.constraintsManager=null))}async goTo(e,t){const i={animate:!0,...t};return n(this.gotoOperation)&&this.gotoOperation.abort(i.animate),this.gotoOperation=new S(e,i,this.view),this.view.resourceController.scheduler.stopFrame(),this.gotoOperation}debugSetCameraOnContent(){this.setStateCamera(P(this.view),{applyConstraints:!1})}step(e){const t=this.view.state,i=t&&this.view.state.cameraController;i&&(t.updateCamera((t=>{i.stepController(e,t)})),i.steppingFinished&&i.finishController())}_cancelGoToOperation(){n(this.gotoOperation)&&(this.gotoOperation.abort(),this.gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of K){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach((t=>e.add(t)))}return t}_setInitialView(e){if(o(e)||this.cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(I(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof C){const t=k(this.view,e.targetGeometry,0,.5,z.LOCKED);return void(n(t)&&this.setStateCamera(I(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=k(this.view,e,0,.5,z.LOCKED);n(r)&&this.setStateCamera(I(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&J.includes(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return!o(e)&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&_(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=Q){return this.cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=Y){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),s=E(this.view,r,a,e,t,z.ADJUST);return o(s)?null:(i.copyFrom(this.view.state.camera),i.eye=s.eye,i.center=s.center,i.up=s.up,i)}_centerToCamera(e){const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.distance;return this._centerPointAtDistanceToCamera(e,i)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=k(this.view,e,t,i,z.ADJUST,X);return n(r)?I(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.renderLocation,r=t.location.latitude,a=V(this.view,e,r);return this._centerPointAtDistanceToCamera(i,a)}_zoomToCamera(e){return this._scaleToCamera(A(this.view,e))}_viewpointToCamera(e){return I(this.view,N(this.view,e))}setStateCamera(e,t){return!(o(e)||!this.view.state.stopActiveCameraController())&&(this.cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera((i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up):i.copyFrom(e),t.applyConstraints&&R(this.view,i)})),t.applyConstraints||(this.view.state.cameraController=new j({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t}=this.view;if(!e||!t)return;this._windowDevicePixelRatio=window.devicePixelRatio;const i=this._devicePixelRatio,r=Math.round(e.clientWidth*i),a=Math.round(e.clientHeight*i);if(0!==r&&0!==a&&(t.width===r&&t.height===a||(t.width=r,t.height=a),this.view.state)){const e=this.view.state.camera;e.fullWidth===r&&e.fullHeight===a&&e.pixelRatio===i||(Y.copyFrom(e),Y.pixelRatio!==i&&(this._paddingToArray(this.padding,i,Z),Y.padding=Z),Y.fullWidth=r,Y.fullHeight=a,Y.pixelRatio=i,this.view.state.camera=Y)}}_updateElevation(e){const t=this.view.basemapTerrain&&this.view.basemapTerrain.spatialReference,i=this.view.renderCoordsHelper.getAltitude(e.eye),r=t?O(this.view,e.eye):0;e.relativeElevation=i-r}};e([d({type:t,dependsOn:["view.state.camera","ready"]})],q.prototype,"camera",null),e([d({type:t,dependsOn:["view.state.contentCamera","ready"]})],q.prototype,"contentCamera",null),e([d({type:f})],q.prototype,"center",null),e([d({type:C})],q.prototype,"extent",null),e([d({readOnly:!0})],q.prototype,"frustum",null),e([d({readOnly:!0})],q.prototype,"hasInitialView",null),e([d({readOnly:!0,type:Boolean})],q.prototype,"ready",void 0),e([d({type:Number})],q.prototype,"scale",null),e([d()],q.prototype,"padding",null),e([d({readOnly:!0})],q.prototype,"screenCenter",null),e([d({constructOnly:!0})],q.prototype,"view",void 0),e([d({type:i})],q.prototype,"viewpoint",null),e([d({type:Number})],q.prototype,"zoom",null),e([d()],q.prototype,"maximumPixelRatio",null),e([d()],q.prototype,"_devicePixelRatio",null),e([d()],q.prototype,"_windowDevicePixelRatio",void 0),e([d()],q.prototype,"_devicePixelRatioOverride",void 0),e([d()],q.prototype,"_maximumPixelRatioOverride",void 0),q=e([v("esri.views.3d.state.ViewStateManager")],q);const W=q,J=["camera","viewpoint","extent","scale","center","zoom"],K=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],Q={heading:0,tilt:0},X=new t,Y=new F,Z=y(),$="pending-initial-view";export{W as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Handles.js";import s from"../../../core/Logger.js";import{isNone as o,isSome as n}from"../../../core/maybe.js";import{watch as h,on as l,when as p}from"../../../core/reactiveUtils.js";import{addFrameTask as c}from"../../../core/scheduling.js";import{createScreenPoint as m}from"../../../core/screenUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{d as u}from"../../../chunks/vec3.js";import{d as w}from"../../../chunks/vec3f64.js";import{s as g}from"../../../chunks/vec4.js";import{c as y}from"../../../chunks/vec4f64.js";import C from"../../../geometry/Extent.js";import f from"../../../geometry/Point.js";import{canProject as _}from"../../../geometry/support/webMercatorUtils.js";import{ViewingMode as x}from"../../ViewingMode.js";import{applyAll as R}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as P,surfaceElevationBelowRenderLocation as O}from"../camera/intersectionUtils.js";import{ConstraintsManager as T}from"./ConstraintsManager.js";import{Frustum as b}from"./Frustum.js";import{GoToOperation as S}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as j}from"./controllers/SurfaceCollisionCorrectionController.js";import{internalToExternal as M,externalToInternal as I,toExtent as B,distanceToScale as L,scaleToZoom as U,fromExtent as k,OrientationMode as z,getObserverForPointAtDistance as E,scaleToDistance as V,zoomToScale as A}from"../support/cameraUtils.js";import{PropertiesPool as D}from"../support/PropertiesPool.js";import{fromCamera as H,toCamera as N}from"../support/viewpointUtils.js";import{Camera as F,PaddingSide as G}from"../webgl-engine/lib/Camera.js";let q=class extends r{constructor(e){super(e),this.propertiesPool=new D({frustum:b},this),this.handles=new a,this.cameraSetByUser=!1,this.gotoOperation=null,this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._maximumPixelRatioOverride=null,this.test={contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,setMaximumPixelRatio:e=>this._maximumPixelRatioOverride=e}}get camera(){const e=this._get("camera");if(!this.ready)return e;const t=M(this.view,this.view.state.camera);return t&&e&&t.equals(e)?e:t}set camera(e){this._updatePropertyBeforeReady("camera",e)||(this.view.elevationProvider.enableElevationCache(!0),this.setStateCamera(I(this.view,e),{applyConstraints:!1})||s.getLogger(this.declaredClass).error("#camera=","Invalid camera",e),this.view.elevationProvider.enableElevationCache(!1))}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=M(this.view,this.view.state.contentCamera);return t&&e&&t.equals(e)?e:t}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=I(this.view,e);o(t)?this.view.state.contentCamera=null:(this._updateElevation(t),this.view.state.contentCamera=t)}installContentCameraReset(e){if(this.handles.remove("contentCameraReset"),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=w(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.handles.add([h((()=>this.contentCamera),(()=>{e.sticky||(this.handles.remove("contentCameraReset"),this.test.contentCameraResetState.clear())})),h((()=>this.zoom),(e=>{this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)})),h((()=>this.view.state.camera),(e=>{const t=u(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)}))],"contentCameraReset"),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():s.getLogger(this.declaredClass).error("#center=","Invalid center",e):s.getLogger(this.declaredClass).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference.wkid+")",e):s.getLogger(this.declaredClass).error("#center=","Center may not be null or undefined"))}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=B(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return n(t)?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||s.getLogger(this.declaredClass).error("#extent=","Invalid extent",e):s.getLogger(this.declaredClass).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference.wkid+")",e):s.getLogger(this.declaredClass).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this.propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get hasInitialView(){return!!this.view.get("map.initialViewProperties.viewpoint")}get scale(){if(this.ready){const e=this.view.pointsOfInterest.centerOnContent;return L(this.view,e.distance,e.location.latitude)}return this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||s.getLogger(this.declaredClass).error("#scale=","Invalid scale",e)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[G.TOP]/i),s=Math.round(t[G.RIGHT]/i),o=Math.round(t[G.BOTTOM]/i),n=Math.round(t[G.LEFT]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===o&&r.left===n?r:{top:a,right:s,bottom:o,left:n}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,Z),this.view.state.updateCamera((e=>e.padding=Z)))}_paddingToArray(e,t,i){e?g(i,e.top||0,e.right||0,e.bottom||0,e.left||0):g(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return m((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?H(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e)if(this.isCompatible(e))this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||s.getLogger(this.declaredClass).error("#viewpoint=","Invalid viewpoint",e);else{const t=n(e.camera)?e.camera.position:e.targetGeometry,i=n(t)&&t.spatialReference;s.getLogger(this.declaredClass).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference.wkid+")",e)}else s.getLogger(this.declaredClass).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?U(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||s.getLogger(this.declaredClass).error("#zoom=","Invalid zoom",e)}get maximumPixelRatio(){if(n(this._maximumPixelRatioOverride))return this._maximumPixelRatioOverride;let e=1/0;const{maximumPixelRatio:t,maximumRenderResolution:i}=this.view.qualitySettings;if(null!=t&&(e=Math.min(e,t)),null!=i){const t=i/Math.max(this.view.width,this.view.height);e=Math.min(e,t)}return e}get _devicePixelRatio(){return o(this._devicePixelRatioOverride)?Math.min(this._windowDevicePixelRatio,this.maximumPixelRatio):this._devicePixelRatioOverride}initialize(){this.handles.add([l((()=>this.view.state.events),"before-camera-change",(e=>this._updateElevation(e.camera)))]),h((()=>this.view.state.camera),(e=>this._updateElevation(e)),{once:!0,sync:!0}),this.handles.add(c({prepare:()=>this._prepareFrame()})),this.handles.add(h((()=>this.view.state.cameraController),(()=>{this.cameraSetByUser=!0,this.handles.remove($)}))),this.handles.add(l((()=>this.view.state.events),"camera-projection-changed",(()=>this.notifyChange("scale"))))}destroy(){this.deinit(),this.handles&&(this.handles.destroy(),this.handles=null),this.propertiesPool&&(this.propertiesPool.destroy(),this.propertiesPool=null)}init(){this.constraintsManager=new T({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this.cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this.cameraSetByUser){const e=this.view.get("map.initialViewProperties.viewpoint")||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):this.view.state.viewingMode===x.Local&&this.handles.add(p((()=>this.view.basemapTerrain.ready),(()=>{this.handles.remove($),this._setInitialView(this.view.dataExtent)}),{once:!0,initial:!0}),$)}}deinit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this.cameraSetByUser=!1,this.handles.remove($),this.constraintsManager&&(this.constraintsManager.destroy(),this.constraintsManager=null))}async goTo(e,t){const i={animate:!0,...t};return n(this.gotoOperation)&&this.gotoOperation.abort(i.animate),this.gotoOperation=new S(e,i,this.view),this.view.resourceController.scheduler.stopFrame(),this.gotoOperation}debugSetCameraOnContent(){this.setStateCamera(P(this.view),{applyConstraints:!1})}step(e){const t=this.view.state,i=t&&this.view.state.cameraController;i&&(t.updateCamera((t=>{i.stepController(e,t)})),i.steppingFinished&&i.finishController())}_cancelGoToOperation(){n(this.gotoOperation)&&(this.gotoOperation.abort(),this.gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of K){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach((t=>e.add(t)))}return t}_setInitialView(e){if(o(e)||this.cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(I(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof C){const t=k(this.view,e.targetGeometry,0,.5,z.LOCKED);return void(n(t)&&this.setStateCamera(I(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=k(this.view,e,0,.5,z.LOCKED);n(r)&&this.setStateCamera(I(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&J.includes(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return!o(e)&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&_(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=Q){return this.cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=Y){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),s=E(this.view,r,a,e,t,z.ADJUST);return o(s)?null:(i.copyFrom(this.view.state.camera),i.eye=s.eye,i.center=s.center,i.up=s.up,i)}_centerToCamera(e){const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.distance;return this._centerPointAtDistanceToCamera(e,i)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=k(this.view,e,t,i,z.ADJUST,X);return n(r)?I(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.renderLocation,r=t.location.latitude,a=V(this.view,e,r);return this._centerPointAtDistanceToCamera(i,a)}_zoomToCamera(e){return this._scaleToCamera(A(this.view,e))}_viewpointToCamera(e){return I(this.view,N(this.view,e))}setStateCamera(e,t){return!(o(e)||!this.view.state.stopActiveCameraController())&&(this.cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera((i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up):i.copyFrom(e),t.applyConstraints&&R(this.view,i)})),t.applyConstraints||(this.view.state.cameraController=new j({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t}=this.view;if(!e||!t)return;this._windowDevicePixelRatio=window.devicePixelRatio;const i=this._devicePixelRatio,r=Math.round(e.clientWidth*i),a=Math.round(e.clientHeight*i);if(0!==r&&0!==a&&(t.width===r&&t.height===a||(t.width=r,t.height=a),this.view.state)){const e=this.view.state.camera;e.fullWidth===r&&e.fullHeight===a&&e.pixelRatio===i||(Y.copyFrom(e),Y.pixelRatio!==i&&(this._paddingToArray(this.padding,i,Z),Y.padding=Z),Y.fullWidth=r,Y.fullHeight=a,Y.pixelRatio=i,this.view.state.camera=Y)}}_updateElevation(e){const t=this.view.basemapTerrain&&this.view.basemapTerrain.spatialReference,i=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,r=t?O(this.view,e.eye):0;e.relativeElevation=i-r}};e([d({type:t,dependsOn:["view.state.camera","ready"]})],q.prototype,"camera",null),e([d({type:t,dependsOn:["view.state.contentCamera","ready"]})],q.prototype,"contentCamera",null),e([d({type:f})],q.prototype,"center",null),e([d({type:C})],q.prototype,"extent",null),e([d({readOnly:!0})],q.prototype,"frustum",null),e([d({readOnly:!0})],q.prototype,"hasInitialView",null),e([d({readOnly:!0,type:Boolean})],q.prototype,"ready",void 0),e([d({type:Number})],q.prototype,"scale",null),e([d()],q.prototype,"padding",null),e([d({readOnly:!0})],q.prototype,"screenCenter",null),e([d({constructOnly:!0})],q.prototype,"view",void 0),e([d({type:i})],q.prototype,"viewpoint",null),e([d({type:Number})],q.prototype,"zoom",null),e([d()],q.prototype,"maximumPixelRatio",null),e([d()],q.prototype,"_devicePixelRatio",null),e([d()],q.prototype,"_windowDevicePixelRatio",void 0),e([d()],q.prototype,"_devicePixelRatioOverride",void 0),e([d()],q.prototype,"_maximumPixelRatioOverride",void 0),q=e([v("esri.views.3d.state.ViewStateManager")],q);const W=q,J=["camera","viewpoint","extent","scale","center","zoom"],K=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],Q={heading:0,tilt:0},X=new t,Y=new F,Z=y(),$="pending-initial-view";export{W 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.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
class s{}class e{constructor(){this.elevation=0,this.normal=[0,0,1],this.cornerTiles=[null,null,null,null]}}class l{constructor(){this.edgeNeighbours=[null,null,null,null],this.cornerNeighborData=[new e,new e,new e,new e],this.edgeResolutions=[1,1,1,1],this.modifiedEdgeResolutions=[!1,!1,!1,!1]}}class i{constructor(){this.numVerticesPerSide=0,this.samplerData=null,this.clippingArea=null,this.wireframe=!1,this.samplerDataVersion=0,this.neighborData=new l}}export{e as CornerNeighborData,s as EdgeNeighborData,i as GeometryState,l as NeighborhoodData};
|
|
5
|
+
class s{}class e{constructor(){this.elevation=0,this.normal=[0,0,1],this.cornerTiles=[null,null,null,null],this.cornerTileSamplerVersions=[-1,-1,-1,-1]}}class l{constructor(){this.edgeNeighbours=[null,null,null,null],this.cornerNeighborData=[new e,new e,new e,new e],this.edgeResolutions=[1,1,1,1],this.modifiedEdgeResolutions=[!1,!1,!1,!1]}}class i{constructor(){this.numVerticesPerSide=0,this.samplerData=null,this.clippingArea=null,this.wireframe=!1,this.samplerDataVersion=0,this.neighborData=new l}}export{e as CornerNeighborData,s as EdgeNeighborData,i as GeometryState,l as NeighborhoodData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isPowerOfTwo as e,clamp as t}from"../../../core/mathUtils.js";import{isNone as n,isSome as o,unwrapOr as r}from"../../../core/maybe.js";import{s as a,n as s,w as i,f as l,a as c}from"../../../chunks/vec3.js";import{c as u}from"../../../chunks/vec3f64.js";import{s as f}from"../../../chunks/vec4.js";import{empty as d}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as g,containsXYWithMargin as m}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevationOrZero as h}from"./ElevationData.js";import{PatchType as x}from"./interfaces.js";import{acquireTerrainAttributes as p,EdgeDescriptor as b}from"./PatchGeometry.js";import{PatchGeometryLUT as M}from"./PatchGeometryLUT.js";import{isElevationSampleIn as S}from"./PatchRenderData.js";import{GEOMETRY_VERTEX_STRIDE as v}from"./TerrainConst.js";import{internalAssert as y,ENABLE_TERRAIN_INTERNAL_CHECKS as D,neighborEdgeIndices as O,almostEquals as V}from"./terrainUtils.js";const R=65536;function E(e,t){const n=e.tile,{extent:o,extentInRadians:r,surface:i}=n,l=e.localOrigin,u=e.geometryState,g=i.isWebMercator,m=i.shadingEnabled,b=u.numVerticesPerSide,M=b-1,S=(b-2)**2,D=g&&(t===x.HAS_SOUTH_POLE||t===x.HAS_BOTH_POLES),O=g&&(t===x.HAS_NORTH_POLE||t===x.HAS_BOTH_POLES),V=6,R=((D?1:0)+(O?1:0))*V*(M+1),E=u.neighborData,L=E.edgeResolutions.reduce(((e,t)=>e+t+1),0),T=p(S+R+L),P=e.geometryInfo;P.numVerticesPerSide=u.numVerticesPerSide,P.vertexAttributes=T,f(P.uvOffsetAndScale,0,0,1,1);const B=T.position.typedBuffer,I=T.uv0.typedBuffer,N=T.normal.typedBuffer,w=P.boundingBox;d(w);const U=l[0],H=l[1],Z=l[2];xe.update(M,r);const W=u.samplerData,X=n.ellipsoid.radius,Y=C(e),q=b-2,k=o[0],G=o[2],z=o[1],F=o[3];(()=>{if((()=>{let e=0;for(let t=1;t<=q;t++){const n=t/M,o=z*(1-n)+F*n,r=Y(n),a=Math.cos(r),s=Math.sin(r);for(let t=1;t<=q;t++){const r=t/M,i=k*(1-r)+G*r,l=xe.sinLonLUT[t],c=xe.cosLonLUT[t],u=X+h(i,o,W),f=c*a*u-U,d=l*a*u-H,g=s*u-Z;me(f,d,g,w);const m=v*e;B[m+0]=f,B[m+1]=d,B[m+2]=g,I[m+0]=r,I[m+1]=n,++e}}})(),m){(()=>{const t=T.position,n=T.normal;let o=0;const r=e=>{t.getVec(e,Me),_()},i=(e,t)=>{{const n=e/M,o=k*(1-n)+G*n,r=xe.sinLonLUT[e],s=xe.cosLonLUT[e],i=t/M,l=z*(1-i)+F*i,c=Y(i),u=Math.cos(c),f=Math.sin(c),d=X+h(o,l,W);a(Me,s*u*d-U,r*u*d-H,f*d-Z)}_()},l=(e,t,n)=>{e>1&&t>1&&e<q&&t<q?r(o+n):i(e,t)};for(let u=1;u<=q;u++)for(let r=1;r<=q;r++)t.getVec(o,De),c(Oe,De,e.localOrigin),s(Ve,Oe),a(Re,0,0,0),l(r-1,u,-1),l(r+1,u,1),l(r,u-1,-q),l(r,u+1,+q),s(Re,Re),n.setVec(o,Re),++o})()}})(),ue(e,S),A(e);const J=[];(()=>{let e=S+L;const t=(t,n)=>{const o=n*b;me(-U,-H,t*X-Z,w),J.push({connectedRowOffset:o,connectedOuterEdgeOffset:1===t?0:2,rowOffset:e,latitudeResolution:V});const r=j(-1===t?z:F,X),a=t*Math.PI/2-r,s=.99*(1===t?1:-1),i=X+0;for(let l=1;l<=V;++l){const t=r+a*(l/V),n=Math.cos(t),o=Math.sin(t);for(let r=0;r<=M;r++){const t=r/M,a=xe.sinLonLUT[r],l=xe.cosLonLUT[r]*n*i-U,c=a*n*i-H,u=o*i-Z;me(l,c,u,w);const f=v*e;if(B[f+0]=l,B[f+1]=c,B[f+2]=u,I[f+0]=t,I[f+1]=s,m){const e=1/Math.sqrt(l*l+c*c+u*u);N[f+0]=e*l,N[f+1]=e*c,N[f+2]=e*u}++e}}};D&&t(-1,0),O&&t(1,M)})(),ce(P,u.numVerticesPerSide,J,[0,b-1],[0,b-1],u.wireframe),e.intersectionData=null;for(let a=0;a<4;++a)y(P.outerEdges[a].count===E.edgeResolutions[a]+1)}function L(e){A(e),de(e)}function T(e){B(e),I(e);const t=e.vao,n=e.geometryInfo.vertexAttributes;t?.vertexBuffers?.geometry?.setSubData(n.position.typedBuffer)}function A(e){B(e);for(let t=0;t<4;++t)P(e,t);I(e)}function P(t,r){const i=t.geometryState,l=i.neighborData,c=t.tile,u=c.level,f=c.extent,d=c.ellipsoid.radius,g=l.edgeNeighbours[r],m=l.edgeResolutions[r];if(D){const e=c.surface;if(!g&&e&&!e.updatingRootTiles){const t=O[r],o=c.findNeighborTile(t,(e=>e.isLoaded||e.isLeaf||e.level===c.level));o?(y(!o.isLoaded),y(!o.isLeaf),y(o.level===u)):y(n(e?.rootTiles)||!c.shouldHaveNeighbor(t))}}const x=m;y(e(x));const p=1===r||3===r,b=c.extentInRadians,M=b[0],S=b[2],V=b[1],R=b[3],E=1===r?S:M,L=0===r?R:V,T=g?.neighborTile,A=c.level-(T?.level??c.level),P=x*2**A,B=c.getNeighborEdgeStartVertexIndex(r,T)*x,I=i.samplerData,N=T?.renderData?.geometryState?.samplerData,w=o(g),U=w&&0===A,j=T?.extent,H=w?j:f,Z=H[0],W=H[2],X=H[1],Y=H[3],q=w?T.extentInRadians:b,k=q[0],G=q[2],z=w?B:0,F=w?P:x,J=C(w?T.renderData:t),K=1===r?1:0,Q=0===r?1:0,$=1===r?f[2]:f[0],ee=0===r?f[3]:f[1];let te=K,ne=$,oe=w&&p?1===r?j[0]:j[2]:$,re=E,ae=Q,se=ee,ie=L,le=Math.sin(re),ce=Math.cos(re),ue=Math.cos(ie),fe=Math.sin(ie);const de=(e,t)=>{ae=e,se=X*(1-t)+Y*t,ie=J(t),ue=Math.cos(ie),fe=Math.sin(ie)},ge=(e,t)=>{te=e,ne=Z*(1-t)+W*t,oe=ne,re=k*(1-t)+G*t,le=Math.sin(re),ce=Math.cos(re)},he=p?de:ge,xe=t.geometryInfo,pe=xe.boundingBox,be=xe.vertexAttributes,Se=be.position.typedBuffer,ve=be.uv0.typedBuffer,ye=be.normal.typedBuffer,Oe=xe.outerEdges[r],Ee=x+1,Le=t.localOrigin,Te=Le[0],Ae=Le[1],Pe=Le[2],Be=()=>h(oe,se,N),Ie=()=>h(ne,se,I),Ne=w?U?()=>.5*(Be()+Ie()):Be:Ie,we=c.surface.shadingEnabled;let Ue=z/F;const je=w?j:f,He=w?P:x,Ze=1===r?-1:3===r?1:0,Ce=0===r?-1:2===r?1:0,We=(je[2]-je[0])/He,_e=Ze*We,Xe=Ce*We,Ye=w?T.extentInRadians:c.extentInRadians,qe=Ye[2]-Ye[0],ke=p?Ze*(qe/He):0,Ge=p?0:Ce*(1/He),ze=w?1-Q:Q,Fe=(e,t)=>{const n=h(ne+e*_e,se+e*Xe,t),o=d+n,r=p?re+e*ke:re,s=p?Math.sin(r):le,i=p?Math.cos(r):ce,l=p?ie:J(ze+e*Ge),c=p?fe:Math.sin(l),u=p?ue:Math.cos(l);a(Me,i*u*o,s*u*o,c*o),_()};let Je=Oe.getVertexOffset(1);for(let e=1;e<Ee-1;++e){const t=e/x;if(Ue=(z+e)/F,he(t,Ue),D){y(0!==e||0===t),y(e!==Ee-1||1===t);const n=.001;y(f[0]<=ne&&ne<=f[2]),y(f[1]<=se&&se<=f[3]),y(M-n<=re&&re<=S+n),y(V-n<=ie&&ie<=R+n),y(0<=te&&te<=1),y(0<=ae&&ae<=1)}const n=Ne(),o=d+n,r=ce*ue*o,i=le*ue*o,l=fe*o,c=r-Te,u=i-Ae,g=l-Pe;me(c,u,g,pe);const m=v*Je;Se[m+0]=c,Se[m+1]=u,Se[m+2]=g,ve[m+0]=te,ve[m+1]=ae,we&&(a(Re,0,0,0),a(De,r,i,l),s(Ve,De),T&&Fe(-1,N),T&&!U||Fe(1,I),ye[m+0]=Re[0],ye[m+1]=Re[1],ye[m+2]=Re[2]),++Je}if(we)for(let e=1;e<Ee-1;++e)Oe.getVertexRawNormal(Re,e),Oe.getVertex(De,e),s(Ve,De),Oe.getVertex(Me,e-1),_(),Oe.getVertex(Me,e+1),_(),s(Re,Re),Oe.setVertexRawNormal(e,Re[0],Re[1],Re[2])}function B(e){fe(e,((t,n,o,r)=>U(t,n,o,r,e.tile.extentInRadians,e.tile.ellipsoid.radius)))}function I(e){e.tile.surface.shadingEnabled&&ge(e,((e,t,n,o)=>W(e,t,n,o)))}function N(e,t,n,o,r){const a=C(e),s=e.tile,i=s.extent;y(m(i,n,o,1));const l=(n-i[0])/(i[2]-i[0]),c=(o-i[1])/(i[3]-i[1]),u=s.extentInRadians;w(t,u[0]*(1-l)+u[2]*l,a(c),r,s.ellipsoid.radius)}function w(e,t,n,o,r){const a=Math.cos(n),s=Math.sin(n),i=Math.sin(t),l=Math.cos(t),c=r+o;e[0]=l*a*c,e[1]=i*a*c,e[2]=s*c}function U(e,t,n,o,r,a){const s=r[0===n?1:3];w(e,r[0===t?0:2],s,o,a)}function j(e,t){return Math.PI/2-2*Math.atan(Math.exp(-e/t))}function H(e,t,n,o){return j(e*(1-o)+t*o,n)}function Z(e,t,n){return e*(1-n)+t*n}function C(e){const t=e.tile;if(t.surface.isWebMercator){const e=t.extent,n=t.ellipsoid.radius;return t=>H(e[1],e[3],n,t)}const n=t.extentInRadians;return e=>Z(n[1],n[3],e)}function W(e,t,n,o){N(e,Me,t,n,o),_()}function _(){i(Se,Me,De),l(ve,Se,Ve),l(ye,ve,Se),c(Re,Re,ye)}function X(e,n){const r=e.tile,a=r.extent,s=e.localOrigin,i=e.geometryState,l=r.surface,c=l.isWebMercatorOnPlateeCarree,u=l.shadingEnabled,m=a[0],x=a[1],b=a[2]-m,M=a[3]-x,S=i.clippingArea,y=o(S)?Math.max(0,(S[0]-a[0])/b):0,D=o(S)?Math.max(0,(S[1]-a[1])/M):0,O=o(S)?Math.min(1,(S[2]-a[0])/b):1,V=o(S)?Math.min(1,(S[3]-a[1])/M):1,R=O-y,E=V-D,L=R>0?1/R:1,T=E>0?1/E:1,A=-y*L,P=-D*T,B=i.numVerticesPerSide,I=B-1,N=(B-2)**2,w=i.neighborData.edgeResolutions.reduce(((e,t)=>e+t+1),0),U=p(N+w),j=U.position.typedBuffer,H=U.uv0.typedBuffer,Z=U.normal.typedBuffer,C=e.geometryInfo,W=C.boundingBox;d(W);const _=r.ellipsoid.radius,X=i.samplerData,Y=o(S)?S:pe,q=g(Math.max(a[0],Y[0]),Math.max(a[1],Y[1]),Math.min(a[2],Y[2]),Math.min(a[3],Y[3])),G=s[0],z=s[1],F=s[2],J=te(c,_,n);(()=>{let e=0;for(let o=1;o<=I-1;o++){const r=o/I,a=P+r*T,s=t(x+r*M,q[1],q[3]),i=t(a,0,1),l=J(s)-z,c=b/I;for(let o=1;o<=I-1;o++){const r=o/I,a=A+r*L,f=t(m+r*b,q[0],q[2]),d=t(a,0,1),g=h(f,s,X),x=f*n-G,p=g-F;me(x,l,p,W);const M=v*e;if(j[M+0]=x,j[M+1]=l,j[M+2]=p,H[M+0]=d,H[M+1]=i,u){const e=h(f+c,s,X),t=h(f-c,s,X),n=h(f,s+c,X),o=.25*(t-e),r=.25*(h(f,s-c,X)-n),a=c,i=Math.sqrt(o*o+r*r+a*a);Z[M+0]=o/i,Z[M+1]=r/i,Z[M+2]=a/i}++e}}})(),C.numVerticesPerSide=i.numVerticesPerSide,C.vertexAttributes=U,f(e.geometryInfo.uvOffsetAndScale,y,D,O-y,V-D),ue(e,N),k(e,n),ce(C,i.numVerticesPerSide,[],[0,B-1],[0,B-1],i.wireframe),e.intersectionData=null}function Y(e,t){J(e,t),Q(e,t),de(e)}function q(e,t){k(e,t),de(e)}function k(e,t){J(e,t),G(e,t),Q(e,t)}function G(e,t){const n=e.geometryState.clippingArea,r=e.tile.extent,a=o(n)&&(r[0]<n[0]||r[2]>n[2]||r[1]<n[1]||r[3]>n[3])?F:z;for(let o=0;o<4;++o)a(e,o,t)}function z(t,r,a){const s=t.geometryState.neighborData,i=s.edgeNeighbours,l=t.tile,c=l.level,u=l.surface,f=u.shadingEnabled,d=i[r],g=s.edgeResolutions[r];if(D&&!d&&l&&!u.updatingRootTiles){const e=O[r],t=l.findNeighborTile(e,(e=>e.isLoaded||e.isLeaf||e.level===c));u.updatingRootTiles||(t?(y(!t.isLoaded),y(!t.isLeaf),y(t.level===c)):y(n(u?.rootTiles)||!l.shouldHaveNeighbor(e)))}const m=g;y(e(m));const x=l.extent,p=t.geometryState,b=m+1,M=d,S=t.localOrigin,v=p.samplerData,V=(e,t)=>h(e,t,v),R=(e,t)=>.5*(h(e,t,M.neighborSamplerData)+h(e,t,v)),E=(e,t)=>h(e,t,M.neighborSamplerData),L=M?.neighborTile.level===c,T=L?R:E,A=o(M)?T:V,P=t.geometryInfo,B=P.outerEdges[r],I=te(u.isWebMercatorOnPlateeCarree,l.ellipsoid.radius,a),N=P.boundingBox,w=1===r||3===r,U=1===r?x[2]:x[0],j=0===r?x[3]:x[1],H=1===r?1:0,Z=0===r?1:0,C=(x[2]-x[0])/g,W=M?.neighborSamplerData,_=o(M),X=(e,t)=>oe(_,L,v,W,e,t,r),Y=re(w,!0,C,X),q=re(w,!1,C,X);for(let e=1;e<b-1;++e){const t=e/m,n=w?U:x[0]*(1-t)+x[2]*t,o=w?x[1]*(1-t)+x[3]*t:j,r=w?H:t,s=w?t:Z,i=A(n,o),l=n*a-S[0],c=I(o)-S[1],u=i-S[2];if(me(l,c,u,N),f){const t=Y(n,o,i),a=q(n,o,i),f=C;B.setVertexRawXYZUVN(e,l,c,u,r,s,t,a,f)}else B.setVertexRawXYZUV(e,l,c,u,r,s)}if(f){const e=w?0:1,t=w?1:0;for(let n=1;n<b-1;++n){B.getNormal(Ee,n);const o=B.getVertexZ(n-1)-B.getVertexZ(n+1),r=Ee[0]+.5*e*o,a=Ee[1]+.5*t*o,s=2*C,i=1/Math.sqrt(r*r+a*a+s*s);B.setVertexRawNormal(n,i*r,i*a,i*s)}}}function F(a,s,i){const l=a.geometryState.neighborData,c=l.edgeNeighbours,u=a.tile,f=u.level,d=u.surface,g=d.shadingEnabled,m=c[s],x=l.edgeResolutions[s];if(D&&!m&&u&&!d.updatingRootTiles){const e=O[s],t=u.findNeighborTile(e,(e=>e.isLoaded||e.isLeaf||e.level===f));d.updatingRootTiles||(t?(y(!t.isLoaded),y(!t.isLeaf),y(t.level===f)):y(n(d?.rootTiles)||!u.shouldHaveNeighbor(e)))}const p=x;y(e(p));const b=u.extent,M=a.geometryState,v=r(M.clippingArea,pe),R=a.geometryInfo,E=R.uvOffsetAndScale[0],L=R.uvOffsetAndScale[1],T=E+R.uvOffsetAndScale[2],A=L+R.uvOffsetAndScale[3],P=T>E?1/(T-E):1,B=A>L?1/(A-L):1,I=-E*P,N=-L*B,w=p+1,U=[b[3]>v[3],b[2]>v[2],b[1]<v[1],b[0]<v[0]],j=m,H=M.samplerData,Z=(e,t)=>h(e,t,H),C=j?.neighborTile.level===f,W=(e,t)=>{if(D){const r=o(v)?v:pe;y(n(j.neighborSamplerData)||S(e,t,j.neighborSamplerData)),y(0!==s||V(t,Math.min(b[3],r[3]))),y(1!==s||V(e,Math.min(b[2],r[2]))),y(2!==s||V(t,Math.max(b[1],r[1]))),y(3!==s||V(e,Math.max(b[0],r[0])))}const r=h(e,t,j.neighborSamplerData);return C?.5*(r+h(e,t,H)):r},_=Z,X=o(j)?W:Z,Y=U[s]?_:X,q=R.outerEdges[s],k=R.boundingBox,G=1===s||3===s,z=t(1===s?b[2]:b[0],v[0],v[2]),F=t(0===s?b[3]:b[1],v[1],v[3]),J=1===s?1:0,K=0===s?1:0,Q=a.localOrigin,$=te(d.isWebMercatorOnPlateeCarree,u.ellipsoid.radius,i),ee=(b[2]-b[0])/x,ne=j?.neighborSamplerData,ae=o(j),se=j?.neighborTile.level===f,ie=(e,t)=>oe(ae,se,H,ne,e,t,s),le=re(G,!0,ee,ie),ce=re(G,!1,ee,ie);for(let e=1;e<w-1;++e){const n=e/p,o=G?z:t(b[0]*(1-n)+b[2]*n,v[0],v[2]),r=G?t(b[1]*(1-n)+b[3]*n,v[1],v[3]):F,a=G?J:t(I+n*P,0,1),s=G?t(N+n*B,0,1):K,l=Y(o,r),c=o*i-Q[0],u=$(r)-Q[1],f=l-Q[2];if(me(c,u,f,k),g){const t=le(o,r,l),n=ce(o,r,l),i=ee;q.setVertexRawXYZUVN(e,c,u,f,a,s,t,n,i)}else q.setVertexRawXYZUV(e,c,u,f,a,s)}if(g){const e=G?0:1,t=G?1:0;for(let n=1;n<w-1;++n){q.getNormal(Ee,n);const o=q.getVertexZ(n-1)-q.getVertexZ(n+1),r=Ee[0]+.5*e*o,a=Ee[1]+.5*t*o,s=2*ee,i=1/Math.sqrt(r*r+a*a+s*s);q.setVertexRawNormal(n,i*r,i*a,i*s)}}}function J(e,t){const n=e.tile;o(n.renderData.geometryState.clippingArea)?K(e,t):fe(e,((o,r,a,s)=>ne(o,r,a,s,e.tile.extent,t,te(n.surface.isWebMercatorOnPlateeCarree,n.ellipsoid.radius,t))))}function K(e,n){const a=e.geometryState,s=e.tile,i=s.extent,l=r(a.clippingArea,i),c=e.geometryInfo,u=c.boundingBox,f=c.outerEdges,d=a.neighborData.cornerNeighborData,g=c.uvOffsetAndScale[0],m=c.uvOffsetAndScale[1],x=c.uvOffsetAndScale[2],p=c.uvOffsetAndScale[3],b=x>0?1/x:1,M=p>0?1/p:1,S=-g*b,v=-m*M,y=s.surface.isWebMercatorOnPlateeCarree,D=te(y,y?s.ellipsoid.radius:0,n),O=a.samplerData,V=a.neighborData.edgeNeighbours,R=e.localOrigin,E=(e,r,a,c,f)=>{const g=i[0]*(1-c)+i[2]*c,m=i[1]*(1-f)+i[3]*f,x=t(g,l[0],l[2]),p=t(m,l[1],l[3]),y=[p===i[3],x===i[2],p===i[1],x===i[0]],E=!y[3]&&!y[1]||!y[0]&&!y[2],L=E?y[0]&&o(V[0])?V[0]:y[1]&&o(V[1])?V[1]:y[2]&&o(V[2])?V[2]:y[3]&&o(V[3])?V[3]:null:null,T=E?L?L.neighborTile.level===s.level?.5*(h(x,p,O)+h(x,p,L.neighborSamplerData)):h(x,p,L.neighborSamplerData):h(x,p,O):d[a].elevation,A=x*n-R[0],P=D(p)-R[1],B=T-R[2];me(A,P,B,u);const I=t(S+c*b,0,1),N=t(v+f*M,0,1);e.setVertexRawXYZUV(r,A,P,B,I,N)};for(let t=0;t<4;++t){const e=f[t];E(e,0,0===t?3:1===t?1:2,1===t?1:0,0===t?1:0);const n=2===t?1:3===t?3:0,o=3===t?0:1,r=2===t?0:1;E(e,e.count-1,n,o,r)}}function Q(e,t){e.tile.surface.shadingEnabled&&ge(e,((e,n,o,r)=>ae(se(e,t),n,o,r)))}function $(e,t){return(Math.PI/2-2*Math.atan(Math.exp(-e/t)))*t}function ee(e,t){return e*t}function te(e,t,n){return e?e=>$(e,t):e=>ee(e,n)}function ne(e,t,n,o,r,a,s){const i=0===t?r[0]:r[2],l=0===n?r[1]:r[3],c=o;e[0]=i*a,e[1]=s(l),e[2]=c}function oe(e,t,n,o,r,a,s){return s===r?!e||t?(e,t)=>h(e,t,n):null:s===a?e?(e,t)=>h(e,t,o):null:null}function re(e,t,n,o){if(t!==e)return()=>0;const r=t?3:2,a=t?1:0,s=o(r,a),i=o(a,r),l=(null!=s?1:0)+(null!=i?1:0),c=t?n:0,u=t?0:n;return(e,t,n)=>((null!=s?-(s(e+c,t+u)-n):0)+(null!=i?+(i(e-c,t-u)-n):0))/l}function ae(e,t,n,o){e(Me,t,n,o);const r=Me[0]-De[0],a=Me[1]-De[1],s=Me[2]-De[2];ye[0]=-r*s,ye[1]=-a*s,ye[2]=r*r+a*a,c(Re,Re,ye)}function se(e,t){return e.tile.surface.isWebMercatorOnPlateeCarree?(n,o,r,a)=>le(t,e.tile.ellipsoid.radius,n,o,r,a):(e,n,o,r)=>ie(t,e,n,o,r)}function ie(e,t,n,o,r){t[0]=n*e,t[1]=o*e,t[2]=r}function le(e,t,n,o,r,a){n[0]=o*e,n[1]=(Math.PI/2-2*Math.atan(Math.exp(-r/t)))*t,n[2]=a}function ce(e,t,n,o,r,a){const s=t-1,i=e.vertexAttributes.count,l=2*(Math.min(t-2,o[1])-Math.max(1,o[0]))*(Math.min(t-2,r[1])-Math.max(1,r[0])),c=O.map(((e,n)=>0===n&&r[1]<t-2||1===n&&o[1]<t-2||2===n&&r[0]>1||3===n&&o[0]>1)),u=e.outerEdges.reduce(((e,t,n)=>e+(c[n]?0:s-2+t.count-1)),0),f=n.reduce(((e,t)=>e+s*(2*(t.latitudeResolution-1)+1)),0),d=a?2:1,g=3*(l+u+f)*d,m=new(i>R?Uint32Array:Uint16Array)(g);let h=0;const x=a?(e,t,n)=>{m[h++]=e,m[h++]=t,m[h++]=t,m[h++]=n,m[h++]=n,m[h++]=e,D&&(y(e<i),y(t<i),y(n<i),y(h<=g))}:(e,t,n)=>{m[h++]=e,m[h++]=t,m[h++]=n,D&&(y(e<i),y(t<i),y(n<i),y(h<=g))},p=t-2,b=s-2;y(b>=0);(()=>{for(let e=Math.max(r[0],1)-1;e<Math.min(r[1],t-2)-1;++e)for(let n=Math.max(o[0],1)-1;n<Math.min(o[1],t-2)-1;++n){const t=e*p+n,o=t+1,r=o+p,a=r-1;x(t,o,r),x(r,a,t)}})(),y(h===3*l*d);(()=>{for(let t=0;t<4;++t){const n=h;if(c[t])continue;const o=e.outerEdges[t],r=e.innerEdges[t];let a=0,i=0;const l=o.count,u=r.count;y(u===s-1);const f=s-2+o.count-1;let g=0;const m=1===t||2===t?(e,t,n)=>x(e,t,n):(e,t,n)=>x(e,n,t);for(;a<l-1||i<u-1;){const e=r.getVertexOffset(i),t=o.getVertexOffset(a),n=a<l-1,c=i<u-1,f=n?0+s*(a+.5)/(l-1):0,d=c?1+b*(i+.5)/(u-1):0;if(n&&(!c||f<=d)){++a,D&&y(a<l);m(e,t,o.getVertexOffset(a)),g++}else{++i,D&&y(i<u);m(e,t,r.getVertexOffset(i)),g++}}D&&(y(a===l-1),y(i===u-1),y(g===l+u-2),y(f===g),y(h===n+3*g*d))}})(),y(h===3*(l+u)*d);const M=n=>{let o=e.outerEdges[n.connectedOuterEdgeOffset].offset0;for(let e=0;e<n.latitudeResolution;++e){const r=0===e?n.rowOffset:o+t;for(let t=0;t<s;t++)x(o,o+1,r+t),e<n.latitudeResolution-1&&x(o+1,r+t+1,r+t),++o;o=r}};(()=>{n.forEach(M)})(),y(h===g),e.indices=m,e.indexCount=g}function ue(e,t){const n=e.localOrigin,o=e.geometryInfo,r=e.geometryState.neighborData.edgeResolutions,a=o.numVerticesPerSide-2,s=o.vertexAttributes.position.typedBuffer;let i=t;for(let l=0;l<4;++l){{const e=0===l||2===l,t=(0===l?a-1:0)*a+(1===l?a-1:0),r=(e?0:1)*a+(e?1:0);o.innerEdges[l]=new b(s,n,t,r,a)}{const e=i,t=r[l]+1;o.outerEdges[l]=new b(s,n,e,1,t),i+=t}}}function fe(e,t){const n=e.geometryInfo,o=n.outerEdges,r=e.geometryState.neighborData.cornerNeighborData,a=n.boundingBox,s=e.localOrigin,i=(e,n,o,i,l)=>{t(be,o,i,r[n].elevation);for(let t=0;t<3;++t)be[t]-=s[t];me(be[0],be[1],be[2],a),e.setVertexRawXYZUV(l,be[0],be[1],be[2],o,i)};for(let l=0;l<4;++l){const e=o[l];i(e,0===l?3:1===l?1:2,1===l?1:0,0===l?1:0,0);i(e,2===l?1:3===l?3:0,3===l?0:1,2===l?0:1,e.count-1)}}function de(e){const t=e.vao,n=e.geometryInfo.vertexAttributes;t?.vertexBuffers?.geometry?.setSubData(n.position.typedBuffer)}function ge(e,t){if(!e.tile.surface.shadingEnabled)return;const n=e.geometryState.neighborData.cornerNeighborData,o=e.tile,r=o.extent,i="local"===e.tile.surface.view?.viewingMode;i&&a(Ve,0,0,1);{const l=1,c=(e,n,o,r,a,s)=>{const i=1===s?a.extent[0]:3===s?a.extent[2]:e,c=0===s?a.extent[1]:2===s?a.extent[3]:n,u=i+he[o][0]*r,f=c+he[o][1]*r;y(m(a.extent,u,f,l));const d=a.renderData,g=h(u,f,d.geometryState.samplerData);t(d,u,f,g)},u=(e,t,n)=>e.extent[0===t||1===t?2:0]+n,f=(e,t,n)=>e.extent[0===t||3===t?3:1]+n,d=(e,n,o,r)=>{const a=u(o,r,he[e][0]*n),s=f(o,r,he[e][1]*n);y(m(o.extent,a,s,l));const i=o.renderData,c=h(a,s,i.geometryState.samplerData);t(i,a,s,c)},g=(e,n,o,r,a,s)=>{const i=he[e][0]*n,c=he[e][1]*n,d=u(o,r,i),g=f(o,r,c),x=u(a,s,i),p=f(a,s,c);y(m(o.extent,d,g,l)),y(m(a.extent,x,p,l));const b=o.renderData,M=a.renderData,S=h(d,g,b.geometryState.samplerData),v=h(x,p,M.geometryState.samplerData);t(b,d,g,.5*(S+v))},x=e=>{const t=0===e||1===e?r[2]:r[0],a=0===e||3===e?r[3]:r[1],s=n[e].cornerTiles,i=s.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);for(let n=0;n<4;++n){const e=s[n];Te[n]=e?.level===i?e:null}for(let n=0;n<4;++n){const e=Te[(n+3)%4],r=Te[n];if(null!=e&&e!==o&&e===r){const r=e,s=(n+2)%4,i=r.renderData.geometryState.neighborData.edgeResolutions[s],l=Math.max(i,2**(o.level-r.level)),u=(r.extent[2]-r.extent[0])/l,f=(n+0)%4,d=(n+1)%4;return c(t,a,(n+3)%4,u,r,n),c(t,a,f,u,r,n),c(t,a,d,u,r,n),Re}}{y(Te.some((e=>e?.isLoaded||e===o)));const e=Te.reduce(((e,t)=>t?t.extent[2]-t.extent[0]:e),0);y(e>0);const t=Te.reduce(((e,t)=>Math.max(e,t?.renderData.geometryState.numVerticesPerSide??1)),1);y(t>1);const n=e/t;for(let o=0;o<4;++o){const e=Te[(o+3)%4],t=Te[(o+0)%4];if(!e&&!t)continue;const r=0===o?1:1===o?2:2===o?3:0,a=0===o?2:1===o?3:2===o?0:1;if(e&&t)g(o,n,e,r,t,a);else{d(o,n,e??t,e?r:a)}}}return Re};for(let t=0;t<4;++t){const n=e.geometryInfo.outerEdges[t],o=1===t||2===t?0:n.count-1;n.getVertex(De,o),i||s(Ve,De),a(Re,0,0,0);const r=x(t);s(Le[t],r)}}{const t=(e,t,n,o,r)=>{e.setVertexRawNormal(r,t,n,o)},n=e.geometryInfo.outerEdges;for(let e=0;e<4;++e){const o=n[e];{const n=Le[0===e?3:1===e?1:2];t(o,n[0],n[1],n[2],0)}{const n=Le[2===e?1:3===e?3:0];t(o,n[0],n[1],n[2],o.count-1)}}}}function me(e,t,n,o){e<o[0]?o[0]=e:e>o[3]&&(o[3]=e),t<o[1]?o[1]=t:t>o[4]&&(o[4]=t),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}const he=[[0,1],[1,0],[0,-1],[-1,0]],xe=new M,pe=g(-1/0,-1/0,1/0,1/0),be=u(),Me=u(),Se=u(),ve=u(),ye=u(),De=u(),Oe=u(),Ve=u(),Re=u(),Ee=u(),Le=[u(),u(),u(),u()],Te=[null,null,null,null];export{X as createPlanarGlobePatch,E as createSphericalGlobePatch,Y as updateCornerElevationsPlanar,T as updateCornerElevationsSpherical,q as updateEdgesElevationsAndNormalsPlanar,L as updateEdgesElevationsSpherical};
|
|
5
|
+
import{isPowerOfTwo as e,clamp as t}from"../../../core/mathUtils.js";import{isNone as n,isSome as o,unwrapOr as r}from"../../../core/maybe.js";import{s as a,n as s,w as i,f as l,a as c}from"../../../chunks/vec3.js";import{c as u}from"../../../chunks/vec3f64.js";import{s as f}from"../../../chunks/vec4.js";import{empty as d}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as g,containsXYWithMargin as m}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevationOrZero as h}from"./ElevationData.js";import{PatchType as x}from"./interfaces.js";import{acquireTerrainAttributes as p,EdgeDescriptor as b}from"./PatchGeometry.js";import{PatchGeometryLUT as M}from"./PatchGeometryLUT.js";import{isElevationSampleIn as S}from"./PatchRenderData.js";import{GEOMETRY_VERTEX_STRIDE as v}from"./TerrainConst.js";import{internalAssert as y,ENABLE_TERRAIN_INTERNAL_CHECKS as D,neighborEdgeIndices as V,almostEquals as O}from"./terrainUtils.js";const R=65536;function E(e,t){const n=e.tile,{extent:o,extentInRadians:r,surface:i}=n,l=e.localOrigin,u=e.geometryState,g=i.isWebMercator,m=i.shadingEnabled,b=u.numVerticesPerSide,M=b-1,S=(b-2)**2,D=g&&(t===x.HAS_SOUTH_POLE||t===x.HAS_BOTH_POLES),V=g&&(t===x.HAS_NORTH_POLE||t===x.HAS_BOTH_POLES),O=6,R=((D?1:0)+(V?1:0))*O*(M+1),E=u.neighborData,L=E.edgeResolutions.reduce(((e,t)=>e+t+1),0),I=p(S+R+L),A=e.geometryInfo;A.numVerticesPerSide=u.numVerticesPerSide,A.vertexAttributes=I,f(A.uvOffsetAndScale,0,0,1,1);const P=I.position.typedBuffer,B=I.uv0.typedBuffer,N=I.normal.typedBuffer,w=A.boundingBox;d(w);const U=l[0],H=l[1],Z=l[2];xe.update(M,r);const W=u.samplerData,X=n.ellipsoid.radius,Y=C(e),q=b-2,k=o[0],G=o[2],z=o[1],F=o[3];(()=>{if((()=>{let e=0;for(let t=1;t<=q;t++){const n=t/M,o=z*(1-n)+F*n,r=Y(n),a=Math.cos(r),s=Math.sin(r);for(let t=1;t<=q;t++){const r=t/M,i=k*(1-r)+G*r,l=xe.sinLonLUT[t],c=xe.cosLonLUT[t],u=X+h(i,o,W),f=c*a*u-U,d=l*a*u-H,g=s*u-Z;me(f,d,g,w);const m=v*e;P[m+0]=f,P[m+1]=d,P[m+2]=g,B[m+0]=r,B[m+1]=n,++e}}})(),m){(()=>{const t=I.position,n=I.normal;let o=0;const r=e=>{t.getVec(e,Me),_()},i=(e,t)=>{{const n=e/M,o=k*(1-n)+G*n,r=xe.sinLonLUT[e],s=xe.cosLonLUT[e],i=t/M,l=z*(1-i)+F*i,c=Y(i),u=Math.cos(c),f=Math.sin(c),d=X+h(o,l,W);a(Me,s*u*d-U,r*u*d-H,f*d-Z)}_()},l=(e,t,n)=>{e>1&&t>1&&e<q&&t<q?r(o+n):i(e,t)};for(let u=1;u<=q;u++)for(let r=1;r<=q;r++)t.getVec(o,De),c(Ve,De,e.localOrigin),s(Oe,Ve),a(Re,0,0,0),l(r-1,u,-1),l(r+1,u,1),l(r,u-1,-q),l(r,u+1,+q),s(Re,Re),n.setVec(o,Re),++o})()}})(),ue(e,S),T(e);const J=[];(()=>{let e=S+L;const t=(t,n)=>{const o=n*b;me(-U,-H,t*X-Z,w),J.push({connectedRowOffset:o,connectedOuterEdgeOffset:1===t?0:2,rowOffset:e,latitudeResolution:O});const r=j(-1===t?z:F,X),a=t*Math.PI/2-r,s=.99*(1===t?1:-1),i=X+0;for(let l=1;l<=O;++l){const t=r+a*(l/O),n=Math.cos(t),o=Math.sin(t);for(let r=0;r<=M;r++){const t=r/M,a=xe.sinLonLUT[r],l=xe.cosLonLUT[r]*n*i-U,c=a*n*i-H,u=o*i-Z;me(l,c,u,w);const f=v*e;if(P[f+0]=l,P[f+1]=c,P[f+2]=u,B[f+0]=t,B[f+1]=s,m){const e=1/Math.sqrt(l*l+c*c+u*u);N[f+0]=e*l,N[f+1]=e*c,N[f+2]=e*u}++e}}};D&&t(-1,0),V&&t(1,M)})(),ce(A,u.numVerticesPerSide,J,[0,b-1],[0,b-1],u.wireframe),e.intersectionData=null;for(let a=0;a<4;++a)y(A.outerEdges[a].count===E.edgeResolutions[a]+1)}function L(e){T(e),de(e)}function I(e){P(e),B(e);for(let o=0;o<4;++o)A(e,o,!0);const t=e.vao,n=e.geometryInfo.vertexAttributes;t?.vertexBuffers?.geometry?.setSubData(n.position.typedBuffer)}function T(e){P(e);for(let t=0;t<4;++t)A(e,t,!1);B(e)}function A(t,r,i){const l=t.geometryState,c=l.neighborData,u=t.tile,f=u.level,d=u.extent,g=u.ellipsoid.radius,m=c.edgeNeighbours[r],x=c.edgeResolutions[r];if(D){const e=u.surface;if(!m&&e&&!e.updatingRootTiles){const t=V[r],o=u.findNeighborTile(t,(e=>e.isLoaded||e.isLeaf||e.level===u.level));o?(y(!o.isLoaded),y(!o.isLeaf),y(o.level===f)):y(n(e?.rootTiles)||!u.shouldHaveNeighbor(t))}}const p=x;y(e(p));const b=1===r||3===r,M=u.extentInRadians,S=M[0],O=M[2],R=M[1],E=M[3],L=1===r?O:S,I=0===r?E:R,T=m?.neighborTile,A=u.level-(T?.level??u.level),P=p*2**A,B=u.getNeighborEdgeStartVertexIndex(r,T)*p,N=l.samplerData,w=T?.renderData?.geometryState?.samplerData,U=o(m),j=U&&0===A,H=T?.extent,Z=U?H:d,W=Z[0],X=Z[2],Y=Z[1],q=Z[3],k=U?T.extentInRadians:M,G=k[0],z=k[2],F=U?B:0,J=U?P:p,K=C(U?T.renderData:t),Q=1===r?1:0,$=0===r?1:0,ee=1===r?d[2]:d[0],te=0===r?d[3]:d[1];let ne=Q,oe=ee,re=U&&b?1===r?H[0]:H[2]:ee,ae=L,se=$,ie=te,le=I,ce=Math.sin(ae),ue=Math.cos(ae),fe=Math.cos(le),de=Math.sin(le);const ge=(e,t)=>{se=e,ie=Y*(1-t)+q*t,le=K(t),fe=Math.cos(le),de=Math.sin(le)},he=(e,t)=>{ne=e,oe=W*(1-t)+X*t,re=oe,ae=G*(1-t)+z*t,ce=Math.sin(ae),ue=Math.cos(ae)},xe=b?ge:he,pe=t.geometryInfo,be=pe.boundingBox,Se=pe.vertexAttributes,ve=Se.position.typedBuffer,ye=Se.uv0.typedBuffer,Ve=Se.normal.typedBuffer,Ee=pe.outerEdges[r],Le=p+1,Ie=t.localOrigin,Te=Ie[0],Ae=Ie[1],Pe=Ie[2],Be=()=>h(re,ie,w),Ne=()=>h(oe,ie,N),we=U?j?()=>.5*(Be()+Ne()):Be:Ne,Ue=u.surface.shadingEnabled;let je=F/J;const He=U?H:d,Ze=U?P:p,Ce=1===r?-1:3===r?1:0,We=0===r?-1:2===r?1:0,_e=(He[2]-He[0])/Ze,Xe=Ce*_e,Ye=We*_e,qe=U?T.extentInRadians:u.extentInRadians,ke=qe[2]-qe[0],Ge=b?Ce*(ke/Ze):0,ze=b?0:We*(1/Ze),Fe=U?1-$:$,Je=e=>{const t=e?-1:1,n=h((e?re:oe)+t*Xe,ie+t*Ye,e?w:N),o=g+n,r=b?ae+t*Ge:ae,s=b?Math.sin(r):ce,i=b?Math.cos(r):ue,l=b?le:K(Fe+t*ze),c=b?de:Math.sin(l),u=b?fe:Math.cos(l);a(Me,i*u*o,s*u*o,c*o),_()},Ke=Ee.getVertexOffset(0),Qe=i&&Le>3?Le-3:1;for(let e=1;e<Le-1;e+=Qe){const t=e/p;if(je=(F+e)/J,xe(t,je),D){y(0!==e||0===t),y(e!==Le-1||1===t);const n=.001;y(d[0]<=oe&&oe<=d[2]),y(d[1]<=ie&&ie<=d[3]),y(S-n<=ae&&ae<=O+n),y(R-n<=le&&le<=E+n),y(0<=ne&&ne<=1),y(0<=se&&se<=1)}const n=we(),o=g+n,r=ue*fe*o,i=ce*fe*o,l=de*o,c=r-Te,u=i-Ae,f=l-Pe;me(c,u,f,be);const m=v*(Ke+e);ve[m+0]=c,ve[m+1]=u,ve[m+2]=f,ye[m+0]=ne,ye[m+1]=se,Ue&&(a(Re,0,0,0),a(De,r,i,l),s(Oe,De),T&&Je(!0),T&&!j||Je(!1),Ve[m+0]=Re[0],Ve[m+1]=Re[1],Ve[m+2]=Re[2])}if(Ue){const e=U?u.getNeighborEdgeStartVertexIndex(r,T)*p:0,t=!U||0===e,n=U?(Le-1)*2**(u.level-T.level)+1:0;y(!U||0<=e&&e<=n-p);const o=!U||e+Le===n;for(let r=1;r<Le-1;r+=Qe)Ee.getVertexRawNormal(Re,r),Ee.getVertex(De,r),s(Oe,De),(!t||r>1)&&(Ee.getVertex(Me,r-1),_()),(!o||r<Le-2)&&(Ee.getVertex(Me,r+1),_()),s(Re,Re),Ee.setVertexRawNormal(r,Re[0],Re[1],Re[2])}}function P(e){fe(e,((t,n,o,r)=>U(t,n,o,r,e.tile.extentInRadians,e.tile.ellipsoid.radius)))}function B(e){e.tile.surface.shadingEnabled&&ge(e,((e,t,n,o)=>W(e,t,n,o)))}function N(e,t,n,o,r){const a=C(e),s=e.tile,i=s.extent;y(m(i,n,o,1));const l=(n-i[0])/(i[2]-i[0]),c=(o-i[1])/(i[3]-i[1]),u=s.extentInRadians;w(t,u[0]*(1-l)+u[2]*l,a(c),r,s.ellipsoid.radius)}function w(e,t,n,o,r){const a=Math.cos(n),s=Math.sin(n),i=Math.sin(t),l=Math.cos(t),c=r+o;e[0]=l*a*c,e[1]=i*a*c,e[2]=s*c}function U(e,t,n,o,r,a){const s=r[0===n?1:3];w(e,r[0===t?0:2],s,o,a)}function j(e,t){return Math.PI/2-2*Math.atan(Math.exp(-e/t))}function H(e,t,n,o){return j(e*(1-o)+t*o,n)}function Z(e,t,n){return e*(1-n)+t*n}function C(e){const t=e.tile;if(t.surface.isWebMercator){const e=t.extent,n=t.ellipsoid.radius;return t=>H(e[1],e[3],n,t)}const n=t.extentInRadians;return e=>Z(n[1],n[3],e)}function W(e,t,n,o){N(e,Me,t,n,o),_()}function _(){i(Se,Me,De),l(ve,Se,Oe),l(ye,ve,Se),c(Re,Re,ye)}function X(e,n){const r=e.tile,a=r.extent,s=e.localOrigin,i=e.geometryState,l=r.surface,c=l.isWebMercatorOnPlateeCarree,u=l.shadingEnabled,m=a[0],x=a[1],b=a[2]-m,M=a[3]-x,S=i.clippingArea,y=o(S)?Math.max(0,(S[0]-a[0])/b):0,D=o(S)?Math.max(0,(S[1]-a[1])/M):0,V=o(S)?Math.min(1,(S[2]-a[0])/b):1,O=o(S)?Math.min(1,(S[3]-a[1])/M):1,R=V-y,E=O-D,L=R>0?1/R:1,I=E>0?1/E:1,T=-y*L,A=-D*I,P=i.numVerticesPerSide,B=P-1,N=(P-2)**2,w=i.neighborData.edgeResolutions.reduce(((e,t)=>e+t+1),0),U=p(N+w),j=U.position.typedBuffer,H=U.uv0.typedBuffer,Z=U.normal.typedBuffer,C=e.geometryInfo,W=C.boundingBox;d(W);const _=r.ellipsoid.radius,X=i.samplerData,Y=o(S)?S:pe,q=g(Math.max(a[0],Y[0]),Math.max(a[1],Y[1]),Math.min(a[2],Y[2]),Math.min(a[3],Y[3])),G=s[0],z=s[1],F=s[2],J=te(c,_,n);(()=>{let e=0;for(let o=1;o<=B-1;o++){const r=o/B,a=A+r*I,s=t(x+r*M,q[1],q[3]),i=t(a,0,1),l=J(s)-z,c=b/B;for(let o=1;o<=B-1;o++){const r=o/B,a=T+r*L,f=t(m+r*b,q[0],q[2]),d=t(a,0,1),g=h(f,s,X),x=f*n-G,p=g-F;me(x,l,p,W);const M=v*e;if(j[M+0]=x,j[M+1]=l,j[M+2]=p,H[M+0]=d,H[M+1]=i,u){const e=h(f+c,s,X),t=h(f-c,s,X),n=h(f,s+c,X),o=.25*(t-e),r=.25*(h(f,s-c,X)-n),a=c,i=Math.sqrt(o*o+r*r+a*a);Z[M+0]=o/i,Z[M+1]=r/i,Z[M+2]=a/i}++e}}})(),C.numVerticesPerSide=i.numVerticesPerSide,C.vertexAttributes=U,f(e.geometryInfo.uvOffsetAndScale,y,D,V-y,O-D),ue(e,N),k(e,n),ce(C,i.numVerticesPerSide,[],[0,P-1],[0,P-1],i.wireframe),e.intersectionData=null}function Y(e,t){J(e,t),Q(e,t),de(e)}function q(e,t){k(e,t),de(e)}function k(e,t){J(e,t),G(e,t),Q(e,t)}function G(e,t){const n=e.geometryState.clippingArea,r=e.tile.extent,a=o(n)&&(r[0]<n[0]||r[2]>n[2]||r[1]<n[1]||r[3]>n[3])?F:z;for(let o=0;o<4;++o)a(e,o,t)}function z(t,r,a){const s=t.geometryState.neighborData,i=s.edgeNeighbours,l=t.tile,c=l.level,u=l.surface,f=u.shadingEnabled,d=i[r],g=s.edgeResolutions[r];if(D&&!d&&l&&!u.updatingRootTiles){const e=V[r],t=l.findNeighborTile(e,(e=>e.isLoaded||e.isLeaf||e.level===c));u.updatingRootTiles||(t?(y(!t.isLoaded),y(!t.isLeaf),y(t.level===c)):y(n(u?.rootTiles)||!l.shouldHaveNeighbor(e)))}const m=g;y(e(m));const x=l.extent,p=t.geometryState,b=m+1,M=d,S=t.localOrigin,v=p.samplerData,O=(e,t)=>h(e,t,v),R=(e,t)=>.5*(h(e,t,M.neighborSamplerData)+h(e,t,v)),E=(e,t)=>h(e,t,M.neighborSamplerData),L=M?.neighborTile.level===c,I=L?R:E,T=o(M)?I:O,A=t.geometryInfo,P=A.outerEdges[r],B=te(u.isWebMercatorOnPlateeCarree,l.ellipsoid.radius,a),N=A.boundingBox,w=1===r||3===r,U=1===r?x[2]:x[0],j=0===r?x[3]:x[1],H=1===r?1:0,Z=0===r?1:0,C=(x[2]-x[0])/g,W=M?.neighborSamplerData,_=o(M),X=(e,t)=>oe(_,L,v,W,e,t,r),Y=re(w,!0,C,X),q=re(w,!1,C,X);for(let e=1;e<b-1;++e){const t=e/m,n=w?U:x[0]*(1-t)+x[2]*t,o=w?x[1]*(1-t)+x[3]*t:j,r=w?H:t,s=w?t:Z,i=T(n,o),l=n*a-S[0],c=B(o)-S[1],u=i-S[2];if(me(l,c,u,N),f){const t=Y(n,o,i),a=q(n,o,i),f=C;P.setVertexRawXYZUVN(e,l,c,u,r,s,t,a,f)}else P.setVertexRawXYZUV(e,l,c,u,r,s)}if(f){const e=w?0:1,t=w?1:0;for(let n=1;n<b-1;++n){P.getNormal(Ee,n);const o=P.getVertexZ(n-1)-P.getVertexZ(n+1),r=Ee[0]+.5*e*o,a=Ee[1]+.5*t*o,s=2*C,i=1/Math.sqrt(r*r+a*a+s*s);P.setVertexRawNormal(n,i*r,i*a,i*s)}}}function F(a,s,i){const l=a.geometryState.neighborData,c=l.edgeNeighbours,u=a.tile,f=u.level,d=u.surface,g=d.shadingEnabled,m=c[s],x=l.edgeResolutions[s];if(D&&!m&&u&&!d.updatingRootTiles){const e=V[s],t=u.findNeighborTile(e,(e=>e.isLoaded||e.isLeaf||e.level===f));d.updatingRootTiles||(t?(y(!t.isLoaded),y(!t.isLeaf),y(t.level===f)):y(n(d?.rootTiles)||!u.shouldHaveNeighbor(e)))}const p=x;y(e(p));const b=u.extent,M=a.geometryState,v=r(M.clippingArea,pe),R=a.geometryInfo,E=R.uvOffsetAndScale[0],L=R.uvOffsetAndScale[1],I=E+R.uvOffsetAndScale[2],T=L+R.uvOffsetAndScale[3],A=I>E?1/(I-E):1,P=T>L?1/(T-L):1,B=-E*A,N=-L*P,w=p+1,U=[b[3]>v[3],b[2]>v[2],b[1]<v[1],b[0]<v[0]],j=m,H=M.samplerData,Z=(e,t)=>h(e,t,H),C=j?.neighborTile.level===f,W=(e,t)=>{if(D){const r=o(v)?v:pe;y(n(j.neighborSamplerData)||S(e,t,j.neighborSamplerData)),y(0!==s||O(t,Math.min(b[3],r[3]))),y(1!==s||O(e,Math.min(b[2],r[2]))),y(2!==s||O(t,Math.max(b[1],r[1]))),y(3!==s||O(e,Math.max(b[0],r[0])))}const r=h(e,t,j.neighborSamplerData);return C?.5*(r+h(e,t,H)):r},_=Z,X=o(j)?W:Z,Y=U[s]?_:X,q=R.outerEdges[s],k=R.boundingBox,G=1===s||3===s,z=t(1===s?b[2]:b[0],v[0],v[2]),F=t(0===s?b[3]:b[1],v[1],v[3]),J=1===s?1:0,K=0===s?1:0,Q=a.localOrigin,$=te(d.isWebMercatorOnPlateeCarree,u.ellipsoid.radius,i),ee=(b[2]-b[0])/x,ne=j?.neighborSamplerData,ae=o(j),se=j?.neighborTile.level===f,ie=(e,t)=>oe(ae,se,H,ne,e,t,s),le=re(G,!0,ee,ie),ce=re(G,!1,ee,ie);for(let e=1;e<w-1;++e){const n=e/p,o=G?z:t(b[0]*(1-n)+b[2]*n,v[0],v[2]),r=G?t(b[1]*(1-n)+b[3]*n,v[1],v[3]):F,a=G?J:t(B+n*A,0,1),s=G?t(N+n*P,0,1):K,l=Y(o,r),c=o*i-Q[0],u=$(r)-Q[1],f=l-Q[2];if(me(c,u,f,k),g){const t=le(o,r,l),n=ce(o,r,l),i=ee;q.setVertexRawXYZUVN(e,c,u,f,a,s,t,n,i)}else q.setVertexRawXYZUV(e,c,u,f,a,s)}if(g){const e=G?0:1,t=G?1:0;for(let n=1;n<w-1;++n){q.getNormal(Ee,n);const o=q.getVertexZ(n-1)-q.getVertexZ(n+1),r=Ee[0]+.5*e*o,a=Ee[1]+.5*t*o,s=2*ee,i=1/Math.sqrt(r*r+a*a+s*s);q.setVertexRawNormal(n,i*r,i*a,i*s)}}}function J(e,t){const n=e.tile;o(n.renderData.geometryState.clippingArea)?K(e,t):fe(e,((o,r,a,s)=>ne(o,r,a,s,e.tile.extent,t,te(n.surface.isWebMercatorOnPlateeCarree,n.ellipsoid.radius,t))))}function K(e,n){const a=e.geometryState,s=e.tile,i=s.extent,l=r(a.clippingArea,i),c=e.geometryInfo,u=c.boundingBox,f=c.outerEdges,d=a.neighborData.cornerNeighborData,g=c.uvOffsetAndScale[0],m=c.uvOffsetAndScale[1],x=c.uvOffsetAndScale[2],p=c.uvOffsetAndScale[3],b=x>0?1/x:1,M=p>0?1/p:1,S=-g*b,v=-m*M,y=s.surface.isWebMercatorOnPlateeCarree,D=te(y,y?s.ellipsoid.radius:0,n),V=a.samplerData,O=a.neighborData.edgeNeighbours,R=e.localOrigin,E=(e,r,a,c,f)=>{const g=i[0]*(1-c)+i[2]*c,m=i[1]*(1-f)+i[3]*f,x=t(g,l[0],l[2]),p=t(m,l[1],l[3]),y=[p===i[3],x===i[2],p===i[1],x===i[0]],E=!y[3]&&!y[1]||!y[0]&&!y[2],L=E?y[0]&&o(O[0])?O[0]:y[1]&&o(O[1])?O[1]:y[2]&&o(O[2])?O[2]:y[3]&&o(O[3])?O[3]:null:null,I=E?L?L.neighborTile.level===s.level?.5*(h(x,p,V)+h(x,p,L.neighborSamplerData)):h(x,p,L.neighborSamplerData):h(x,p,V):d[a].elevation,T=x*n-R[0],A=D(p)-R[1],P=I-R[2];me(T,A,P,u);const B=t(S+c*b,0,1),N=t(v+f*M,0,1);e.setVertexRawXYZUV(r,T,A,P,B,N)};for(let t=0;t<4;++t){const e=f[t];E(e,0,0===t?3:1===t?1:2,1===t?1:0,0===t?1:0);const n=2===t?1:3===t?3:0,o=3===t?0:1,r=2===t?0:1;E(e,e.count-1,n,o,r)}}function Q(e,t){e.tile.surface.shadingEnabled&&ge(e,((e,n,o,r)=>ae(se(e,t),n,o,r)))}function $(e,t){return(Math.PI/2-2*Math.atan(Math.exp(-e/t)))*t}function ee(e,t){return e*t}function te(e,t,n){return e?e=>$(e,t):e=>ee(e,n)}function ne(e,t,n,o,r,a,s){const i=0===t?r[0]:r[2],l=0===n?r[1]:r[3],c=o;e[0]=i*a,e[1]=s(l),e[2]=c}function oe(e,t,n,o,r,a,s){return s===r?!e||t?(e,t)=>h(e,t,n):null:s===a?e?(e,t)=>h(e,t,o):null:null}function re(e,t,n,o){if(t!==e)return()=>0;const r=t?3:2,a=t?1:0,s=o(r,a),i=o(a,r),l=(null!=s?1:0)+(null!=i?1:0),c=t?n:0,u=t?0:n;return(e,t,n)=>((null!=s?-(s(e+c,t+u)-n):0)+(null!=i?+(i(e-c,t-u)-n):0))/l}function ae(e,t,n,o){e(Me,t,n,o);const r=Me[0]-De[0],a=Me[1]-De[1],s=Me[2]-De[2];ye[0]=-r*s,ye[1]=-a*s,ye[2]=r*r+a*a,c(Re,Re,ye)}function se(e,t){return e.tile.surface.isWebMercatorOnPlateeCarree?(n,o,r,a)=>le(t,e.tile.ellipsoid.radius,n,o,r,a):(e,n,o,r)=>ie(t,e,n,o,r)}function ie(e,t,n,o,r){t[0]=n*e,t[1]=o*e,t[2]=r}function le(e,t,n,o,r,a){n[0]=o*e,n[1]=(Math.PI/2-2*Math.atan(Math.exp(-r/t)))*t,n[2]=a}function ce(e,t,n,o,r,a){const s=t-1,i=e.vertexAttributes.count,l=2*(Math.min(t-2,o[1])-Math.max(1,o[0]))*(Math.min(t-2,r[1])-Math.max(1,r[0])),c=V.map(((e,n)=>0===n&&r[1]<t-2||1===n&&o[1]<t-2||2===n&&r[0]>1||3===n&&o[0]>1)),u=e.outerEdges.reduce(((e,t,n)=>e+(c[n]?0:s-2+t.count-1)),0),f=n.reduce(((e,t)=>e+s*(2*(t.latitudeResolution-1)+1)),0),d=a?2:1,g=3*(l+u+f)*d,m=new(i>R?Uint32Array:Uint16Array)(g);let h=0;const x=a?(e,t,n)=>{m[h++]=e,m[h++]=t,m[h++]=t,m[h++]=n,m[h++]=n,m[h++]=e,D&&(y(e<i),y(t<i),y(n<i),y(h<=g))}:(e,t,n)=>{m[h++]=e,m[h++]=t,m[h++]=n,D&&(y(e<i),y(t<i),y(n<i),y(h<=g))},p=t-2,b=s-2;y(b>=0);(()=>{for(let e=Math.max(r[0],1)-1;e<Math.min(r[1],t-2)-1;++e)for(let n=Math.max(o[0],1)-1;n<Math.min(o[1],t-2)-1;++n){const t=e*p+n,o=t+1,r=o+p,a=r-1;x(t,o,r),x(r,a,t)}})(),y(h===3*l*d);(()=>{for(let t=0;t<4;++t){const n=h;if(c[t])continue;const o=e.outerEdges[t],r=e.innerEdges[t];let a=0,i=0;const l=o.count,u=r.count;y(u===s-1);const f=s-2+o.count-1;let g=0;const m=1===t||2===t?(e,t,n)=>x(e,t,n):(e,t,n)=>x(e,n,t);for(;a<l-1||i<u-1;){const e=r.getVertexOffset(i),t=o.getVertexOffset(a),n=a<l-1,c=i<u-1,f=n?0+s*(a+.5)/(l-1):0,d=c?1+b*(i+.5)/(u-1):0;if(n&&(!c||f<=d)){++a,D&&y(a<l);m(e,t,o.getVertexOffset(a)),g++}else{++i,D&&y(i<u);m(e,t,r.getVertexOffset(i)),g++}}D&&(y(a===l-1),y(i===u-1),y(g===l+u-2),y(f===g),y(h===n+3*g*d))}})(),y(h===3*(l+u)*d);const M=n=>{let o=e.outerEdges[n.connectedOuterEdgeOffset].offset0;for(let e=0;e<n.latitudeResolution;++e){const r=0===e?n.rowOffset:o+t;for(let t=0;t<s;t++)x(o,o+1,r+t),e<n.latitudeResolution-1&&x(o+1,r+t+1,r+t),++o;o=r}};(()=>{n.forEach(M)})(),y(h===g),e.indices=m,e.indexCount=g}function ue(e,t){const n=e.localOrigin,o=e.geometryInfo,r=e.geometryState.neighborData.edgeResolutions,a=o.numVerticesPerSide-2,s=o.vertexAttributes.position.typedBuffer;let i=t;for(let l=0;l<4;++l){{const e=0===l||2===l,t=(0===l?a-1:0)*a+(1===l?a-1:0),r=(e?0:1)*a+(e?1:0);o.innerEdges[l]=new b(s,n,t,r,a)}{const e=i,t=r[l]+1;o.outerEdges[l]=new b(s,n,e,1,t),i+=t}}}function fe(e,t){const n=e.geometryInfo,o=n.outerEdges,r=e.geometryState.neighborData.cornerNeighborData,a=n.boundingBox,s=e.localOrigin,i=(e,n,o,i,l)=>{t(be,o,i,r[n].elevation);for(let t=0;t<3;++t)be[t]-=s[t];me(be[0],be[1],be[2],a),e.setVertexRawXYZUV(l,be[0],be[1],be[2],o,i)};for(let l=0;l<4;++l){const e=o[l];i(e,0===l?3:1===l?1:2,1===l?1:0,0===l?1:0,0);i(e,2===l?1:3===l?3:0,3===l?0:1,2===l?0:1,e.count-1)}}function de(e){const t=e.vao,n=e.geometryInfo.vertexAttributes;t?.vertexBuffers?.geometry?.setSubData(n.position.typedBuffer)}function ge(e,t){if(!e.tile.surface.shadingEnabled)return;const n=e.geometryState.neighborData.cornerNeighborData,o=e.tile,r=o.extent,i="local"===e.tile.surface.view?.viewingMode;i&&a(Oe,0,0,1);{const l=1,c=(e,n,o,r,a,s)=>{const i=1===s?a.extent[0]:3===s?a.extent[2]:e,c=0===s?a.extent[1]:2===s?a.extent[3]:n,u=i+he[o][0]*r,f=c+he[o][1]*r;y(m(a.extent,u,f,l));const d=a.renderData,g=h(u,f,d.geometryState.samplerData);t(d,u,f,g)},u=(e,t,n)=>e.extent[0===t||1===t?2:0]+n,f=(e,t,n)=>e.extent[0===t||3===t?3:1]+n,d=(e,n,o,r)=>{const a=u(o,r,he[e][0]*n),s=f(o,r,he[e][1]*n);y(m(o.extent,a,s,l));const i=o.renderData,c=h(a,s,i.geometryState.samplerData);t(i,a,s,c)},g=(e,n,o,r,a,s)=>{const i=he[e][0]*n,c=he[e][1]*n,d=u(o,r,i),g=f(o,r,c),x=u(a,s,i),p=f(a,s,c);y(m(o.extent,d,g,l)),y(m(a.extent,x,p,l));const b=o.renderData,M=a.renderData,S=h(d,g,b.geometryState.samplerData),v=h(x,p,M.geometryState.samplerData);t(b,d,g,.5*(S+v))},x=e=>{a(Re,0,0,0);const t=0===e||1===e?r[2]:r[0],s=0===e||3===e?r[3]:r[1],i=n[e].cornerTiles,l=i.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);for(let n=0;n<4;++n){const e=i[n];Ie[n]=e?.level===l?e:null}for(let n=0;n<4;++n){const r=Ie[(n+3)%4],a=Ie[n];if(null!=r&&r!==o&&r===a){const a=r,i=a.renderData,l=(n+2)%4,u=o.renderData.geometryState.neighborData.edgeResolutions[n],f=u*2**(o.level-a.level),d=(a.extent[2]-a.extent[0])/f,g=(n+3)%4,m=(n+0)%4,h=(n+1)%4,x=i.geometryInfo.outerEdges[l],p=o.getNeighborEdgeStartVertexIndex(n,a)*u;y(0<=p&&p<f);const b=p+(0===e||1===e&&2===n||3===e&&3===n?u:0);y(0<b&&b<f);const M=0===n||3===n,S=1===b,v=b===x.count-2;!(M&&S||!M&&v)&&c(t,s,g,d,a,n),c(t,s,m,d,a,n);return!(!M&&S||M&&v)&&c(t,s,h,d,a,n),Re}}y(Ie.some((e=>e?.isLoaded||e===o)));const u=Ie.reduce(((e,t)=>t?t.extent[2]-t.extent[0]:e),0);y(u>0);const f=Ie.reduce(((e,t)=>Math.max(e,t?.renderData.geometryState.numVerticesPerSide??1)),1);y(f>1);const m=u/f;for(let n=0;n<4;++n){const e=Ie[(n+3)%4],t=Ie[(n+0)%4];if(!e&&!t)continue;const o=0===n?1:1===n?2:2===n?3:0,r=0===n?2:1===n?3:2===n?0:1;if(e&&t)g(n,m,e,o,t,r);else{d(n,m,e??t,e?o:r)}}return Re};for(let t=0;t<4;++t){const n=e.geometryInfo.outerEdges[t],o=1===t||2===t?0:n.count-1;n.getVertex(De,o),i||s(Oe,De),x(t),s(Le[t],Re)}}{const t=(e,t,n,o,r)=>{e.setVertexRawNormal(r,t,n,o)},n=e.geometryInfo.outerEdges;for(let e=0;e<4;++e){const o=n[e];{const n=Le[0===e?3:1===e?1:2];t(o,n[0],n[1],n[2],0)}{const n=Le[2===e?1:3===e?3:0];t(o,n[0],n[1],n[2],o.count-1)}}}}function me(e,t,n,o){e<o[0]?o[0]=e:e>o[3]&&(o[3]=e),t<o[1]?o[1]=t:t>o[4]&&(o[4]=t),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}const he=[[0,1],[1,0],[0,-1],[-1,0]],xe=new M,pe=g(-1/0,-1/0,1/0,1/0),be=u(),Me=u(),Se=u(),ve=u(),ye=u(),De=u(),Ve=u(),Oe=u(),Re=u(),Ee=u(),Le=[u(),u(),u(),u()],Ie=[null,null,null,null];export{X as createPlanarGlobePatch,E as createSphericalGlobePatch,Y as updateCornerElevationsPlanar,I as updateCornerElevationsSpherical,q as updateEdgesElevationsAndNormalsPlanar,L as updateEdgesElevationsSpherical};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t,lerp as r}from"../../../core/mathUtils.js";import{isSome as i,isNone as o,mapOr as s}from"../../../core/maybe.js";import{i as n,j as a,u as l,b as h,w as d}from"../../../chunks/vec3.js";import{c as g,a as u}from"../../../chunks/vec3f64.js";import{empty as c}from"../../../geometry/support/aaBoundingBox.js";import{containsXY as m}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{sampleElevationOrZero as x}from"./ElevationData.js";import{GeometryState as y}from"./GeometryState.js";import{NeighborIndex as _}from"./interfaces.js";import{LayerClass as v}from"./LayerClass.js";import{PatchGeometry as b,releaseGeometry as D}from"./PatchGeometry.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as S,internalAssert as T,neighborEdgeIndices as C,oppositeEdge as E,neighborCornerIndices as j,oppositeCorner as L,v32s as R,lij2s as V,eps as G}from"./terrainUtils.js";import{TextureFader as N,ActivationTime as I}from"./TextureFader.js";export{ActivationTime}from"./TextureFader.js";import{isCornerNeighbor as A,isEdgeNeighbor as $}from"./Tile.js";import w from"./TileOverlayData.js";import{fallsWithinLayer as O}from"./tileUtils.js";import{Default3D as P}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{BufferObject as U}from"../../webgl/BufferObject.js";import{VertexArrayObject as M}from"../../webgl/VertexArrayObject.js";class F{constructor(){this.geometryInfo=new b,this.intersectionData=null,this.geometryState=null,this._textureRef=new N((()=>this.tile.surface.textureFadeDuration)),this.overlay=new w,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._edgeResolutionChanged=!1,this._edgeNeighborChanged=!1,this._cornerElevationChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1}get tile(){return this._tile}init(e){this._tile=e,this.clear();const t=this.geometryInfo;t.indices=null,t.vertexAttributes=null,c(t.boundingBox),t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new y,this.localOrigin=null,this.overlay.clear()}clear(){this._releaseGeometry(),this.releaseTexture(),this._textureRef.clear()}updateGeometryIfChanged(e,t){const r=this.updateGeometryStateAndPrepareForGeometryGeneration(t);this._hasGeometry=!0;return this.updateNeighborDataAndGeometryIfNeeded(r,e)}updateNeighborDataAndGeometryIfNeeded(e=!1,t=this.vao.context){const r=this._updateNeighborData(),i=e||this._geometryStateChangedSinceLastUpdate||r;if(i&&(this._updateGeometry(t),this._geometryStateChangedSinceLastUpdate=!1),S)for(let o=0;o<4;++o)T(this.geometryInfo.outerEdges[o].count===this.geometryState.neighborData.edgeResolutions[o]+1);return i}_calculateEdgeResolution(e,t){const r=this.tile,s=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(i(t)&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return s}const n=r.level,a=C[e],l=t||r.findNeighborTile(a,(e=>e.isLoaded||e.level===n));if(!l||l.isLeaf&&!l.isLoaded)return T(o(r.surface?.rootTiles)||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(a)),s;if(l.isLoaded){const t=l,r=t.renderData.geometryState,i=n-t.level;if(T(i>=0),0===i){const e=r.numVerticesPerSide-1;return Math.max(e,s)}const o=2**i,a=r.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,a)}T(!l.isLeaf);let h=s;return l.forAllSubtreeOnSide(E(a),(e=>e===r||(e.isLoaded?(h=Math.max(h,2**(e.level-n)),!0):(T(!e.isLeaf),!1)))),h}_updateNeighborData(){const e=this.tile,i=t=>t.isLoaded||t.level===e.level,o=e=>e.isLoaded,s=[null,null,null,null],n=[null,null,null,null];(()=>{for(let t=0;t<4;++t){const r=e.findNeighborTile(C[t],i);s[t]=r,n[t]=r?.isLoaded?r:null}})();const a=[null,null,null,null];if((()=>{for(let t=0;t<4;++t)a[t]=e.findNeighborTile(j[t],o)})(),S){const t=t=>t?.isLoaded||t?.isLeaf||t?.lij[0]===e.lij[0];j.forEach((r=>{const i=e.findNeighborTile(r,t);T(!i||A(e,i,r));const o=i?.findCorner(L(r),(e=>e?.isLoaded||e?.isLeaf));T(!o||A(e,o,r))}))}const l=this.geometryState.neighborData;let h=!1;(()=>{for(let r=0;r<4;++r){const i=l.edgeResolutions[r],o=s[r],n=this._calculateEdgeResolution(r,o);T(t(n)),T(n>=1),l.edgeResolutions[r]=n,i!==n&&(h=!0,this._edgeResolutionChanged=!0,o&&o!==e&&!o.isLoaded&&o.level===e.level&&(l.modifiedEdgeResolutions[r]=!0))}})();(()=>{const t=(t,i)=>{const o=t.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);S&&(T(!t[0]||!t[2]||A(t[0],t[2],_.SOUTH_WEST)),T(!t[1]||!t[3]||A(t[1],t[3],_.NORTH_WEST)));for(let l=0;l<4;++l){const o=t[(l+3)%4],s=t[l];if(o&&o.level<e.level&&o===s){T(!S||o!==e);const t=1==(1&l),s=0===i||1===i&&!t||3===i&&t,n=e.getNeighborEdgeStartVertexIndex(l,o)+(s?1:0),a=2**(e.level-o.level);T(!S||0<=n&&n<=a);const h=n/a,d=t?0===i||1===i?o.extent[0]:o.extent[2]:r(o.extent[0],o.extent[2],h),g=t?r(o.extent[1],o.extent[3],h):0===i||3===i?o.extent[1]:o.extent[3];return x(d,g,o.renderData.geometryState.samplerData)}}let s=0,n=0;for(let e=0;e<4;++e){const r=t[e];if(r&&r.level===o){const t=0===e||1===e,i=0===e||3===e,o=r.extent;n+=x(o[t?0:2],o[i?1:3],r.renderData?.geometryState?.samplerData),s++}}const a=s?n/s:0;return T(null!=a),a},i=l.cornerNeighborData,o=(r,o)=>{const s=i[r],n=s.cornerTiles;for(let t=0;t<4;++t){const r=j[t],i=o[t]?.findCorner(L(r),(t=>t?.isLoaded||t===e));n[t]=i}const a=t(n,r);return s.elevation!==a&&(T(null!=a),s.elevation=a,!0)};for(let r=0;r<4;++r){const t=a[r],i=n[r],s=[t,n[(r+1)%4],e,i],l=s.map(((e,t)=>s[(t+4-r)%4]));o(r,l)&&(this._cornerElevationChanged=!0,h=!0)}})();return(()=>{const t=(t,r)=>{if(!t?.isLoaded||t.lij[0]>e.lij[0])return null;const i=t.renderData.geometryState;return{neighborSamplerData:i.samplerData,neighborEdgeOverlapResolution:i.neighborData.edgeResolutions[r+2],version:i.samplerDataVersion,neighborVerticesPerSide:i.numVerticesPerSide,neighborTile:t}},r=l.edgeNeighbours;for(let i=0;i<4;++i){const o=n[i];o&&(T(o?.isLoaded),T(o?.lij[0]<=e.lij[0]));const s=r[i],a=s?.version,l=t(o,i),d=l?.version??null,g=null!=s!=(null!=l),u=s&&l&&a!==d,c=s&&l&&s?.neighborTile!==l?.neighborTile,m=g||u||c;this._edgeNeighborChanged||(this._edgeNeighborChanged=m),h||(h=m),!m&&a||(r[i]=l)}})(),h}updateEdgeAfterResolutionChange(e){const t=this._calculateEdgeResolution(e),r=this.geometryState.neighborData.edgeResolutions,i=r[e];T((this.geometryState.neighborData.edgeNeighbours[e]?.neighborTile.level??0)<=this.tile.level),t!==i&&(r[e]=t,this._edgeResolutionChanged=!0,this._updateGeometry(this.vao.context))}_updateGeometry(e){this.intersectionData=null;const t=this.tile,r=this._vao,i=this.geometryInfo.vertexAttributes,o=!r||!i||this._wireframeChanged||this._numVerticesPerSideChanged||this._samplerDataChanged||this._clippingAreaChanged||this._edgeResolutionChanged,s=!o&&this._edgeNeighborChanged,n=!s&&this._cornerElevationChanged;this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._edgeResolutionChanged=!1,this._edgeNeighborChanged=!1,this._cornerElevationChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1,o?(this._releaseGeometry(),this._createGeometry(e)):s?t.updateEdgeElevations():n?t.updateCornerElevations():console.warn("Update for no reason?")}releaseGeometry(){return this._releaseGeometry()}get hasGeometry(){return this._hasGeometry}ensureTexture(e,t){return i(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),o(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){i(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}updateGeometryStateAndPrepareForGeometryGeneration(t){const r=this._getElevationInfo(),i=r.samplerData?this.tile.getElevationBasedVerticesPerSide(r.maxTileLevel):this.tile.getDefaultVerticesPerRowOnLevel(),o=Math.max(i,5);let s=this.tile.clippingArea;this.tile.intersectsClippingArea&&!this.tile.isWithinClippingArea||(s=null);const n=this.geometryState;let a=!1;return n.numVerticesPerSide!==o&&(this._numVerticesPerSideChanged=!0,n.numVerticesPerSide=o,n.samplerDataVersion++,a=!0),r.changed&&(this._samplerDataChanged=!0,n.samplerData=r.samplerData,n.samplerDataVersion++,a=!0),e(n.clippingArea,s)||(this._clippingAreaChanged=!0,n.clippingArea=s,a=!0),n.wireframe!==t&&(this._wireframeChanged=!0,n.wireframe=t,a=!0),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=a),this._hasGeometry=!0,a}_createGeometry(e){this.tile.createGeometry();const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new M(e,P,{geometry:p(t.layout)},{geometry:U.createVertex(e,i.STATIC_DRAW,t.buffer)},U.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}_releaseGeometry(){return this._hasGeometry=!1,!!this._vao&&(this._vao.dispose(),this._vao=null,D(this.geometryInfo),!0)}get vao(){return this._vao}setTextureReference(e,t=I.Immediate){i(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[v.ELEVATION],r=t.length;let o=new Array(r),s=0,n=0,a=!1;for(let l=0;l<r;l++){const r=t[l];if(i(r.upsampleInfo)){const t=r.upsampleInfo.tile,i=t.layerInfo[v.ELEVATION][l].data,h=i&&i.samplerData;e&&e[s]===h||(a=!0),o[s++]=h,n=Math.max(n,t.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(l,v.ELEVATION);if(O(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),o[s++]=t.samplerData,n=this.tile.level}}}return i(e)&&e.length!==s&&(a=!0),s>0?o.length=s:o=null,{changed:a,samplerData:o,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=s(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return this.geometryInfo.indices.byteLength+this.geometryInfo.vertexAttributes.byteLength+e}get textureDescriptor(){return i(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(T(e?.isLoaded),!e.isLoaded)return;const r=e.surface.extent;if(i(r)&&!e.intersectsExtent(r))return;const s=C.map(((t,o)=>!!i(r)&&(o<2?-1:1)*(e.extent[3-o]-r[3-o])<0)),c=e.level;C.forEach(((r,p)=>{if(s[p])return;const x=e.findNeighborTile(r,(e=>e.level===c||e?.isLoaded));if(!x){const t=!e.surface.updatingRootTiles&&i(e.surface.rootTiles)&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void T(!t)}const y=c-x.level;if(!x.isLoaded)return T(!x.isLeaf),void T(0===y);T($(e,x,r)),T(y>=0);const v=2**y;if(y<0)return void T(!1);const b=e.renderData.geometryInfo,D=b.outerEdges[p],S=b.numVerticesPerSide-1,C=x.renderData.geometryInfo;if(T(!!C),!C)return;{const t=e.renderData.geometryState.neighborData.edgeNeighbours[p];t&&(T(t.neighborTile===x),T(t.version===x.renderData.geometryState.samplerDataVersion))}const E=C.outerEdges[(p+2)%4];T(D.count-1==(E.count-1)/v);const j=e.extent,L=r===_.NORTH||r===_.SOUTH,G=E.count-1,N=G/2**y,I=D.count-1;if(N<1)return void T(1===I);T(N===I),T(t(N));const A=C.numVerticesPerSide-1;T(y>0||N===Math.max(A,S));const w=e.getNeighborEdgeStartVertexIndex(p,x);T(0<=w&&w<v);const O=w*N;T(0<=O&&O<=G-N);let P=0,U=O;D.getVertex(B,P),D.getVertex(H,P);const M=n(B,H),F=Math.max(q,1e-5*M),k=(p+2)%4;for(let t=0;t<=N;++t){D.getVertex(B,P),E.getVertex(H,U);const s=t/N,c=L?j[0]+s*(j[2]-j[0]):r===_.WEST?j[0]:j[2],y=L?r===_.SOUTH?j[1]:j[3]:j[1]+s*(j[3]-j[1]),v=e.surface.extent;if(o(v)||m(v,c,y)){const t=a(B,H),r=l(B)-f.radius,o=l(H)-f.radius,s=t<F;if(!s){console.log("Tile edge vertex position mismatch: between ",e.lij,": ",p,"[",P,"]"," and ",x.lij,": ",k,"[",U,"]"),i(v)&&console.log(" surface extent= ",v," x,y=",c,",",y);const a=g();h(a,e.renderData.localOrigin,x.renderData.localOrigin),a.length>0&&console.log(" localOrigins:",R(e.renderData.localOrigin)," vs ",R(x.renderData.localOrigin));(()=>{const t=u(B),r=u(H);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getVertex(B,P),E.getVertex(H,U),n(B,t)>0&&console.log(" XXX Tile edge out of date: ",R(t)," vs ",R(B)),n(H,r)>0&&console.log(" XXX Neighbor edge out of date: ",R(r)," vs ",R(H))})(),T(s,`Mismatch in tile ${V(e.lij)} (${P}/${D.count-1}) edge ${p} vs neighbor ${V(x.lij)} (${U}/${E.count-1}) nedge ${k} : ${R(B)} vs ${R(H)} dist=${t} h(t|n|d)=${r}|${o}|${o-r}`)}if(e.surface.shadingEnabled){D.getNormal(W,P),E.getNormal(X,U);const t=a(W,X),r=P<=1||U<=1||P>=D.count-2||U>=E.count-2,i=t<.01||r;if(!i){const r=g();d(r,W,X),T(i,`Mismatch in tile edge normal ${V(e.lij)} (${P}/${D.count-1}) edge ${p} vs neighbor ${V(x.lij)} (${U}/${E.count-1}) nedge ${k} :${R(W)} vs ${R(X)} dist = ${t} : ${R(r)}`)}}}P+=1,U+=1}}))}}const B=g(),H=g(),W=g(),X=g();function k(e,t,r){if(i(r))for(const i of r)if(i){const r=i.x0,o=i.width,s=r+(o-1)/i.dx,n=i.y1,a=n-(o-1)/i.dy;if(e>=r-G&&e<=s+G&&a-G<=t&&t<=n+G)return!0}return!1}const q=1;export{F as PatchRenderData,k as isElevationSampleIn};
|
|
5
|
+
import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t,lerp as r}from"../../../core/mathUtils.js";import{isSome as i,isNone as o,mapOr as s}from"../../../core/maybe.js";import{i as n,j as a,u as l,b as h,n as d,e as g,w as u,z as c}from"../../../chunks/vec3.js";import{c as m,a as f}from"../../../chunks/vec3f64.js";import{empty as p}from"../../../geometry/support/aaBoundingBox.js";import{containsXY as x}from"../../../geometry/support/aaBoundingRect.js";import{earth as y}from"../../../geometry/support/Ellipsoid.js";import{glLayout as _}from"../support/buffer/glUtil.js";import{sampleElevationOrZero as v}from"./ElevationData.js";import{GeometryState as b}from"./GeometryState.js";import{NeighborIndex as D}from"./interfaces.js";import{LayerClass as S}from"./LayerClass.js";import{PatchGeometry as T,releaseGeometry as C}from"./PatchGeometry.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as E,internalAssert as j,neighborEdgeIndices as L,oppositeEdge as V,neighborCornerIndices as R,oppositeCorner as N,v32s as G,lij2s as I,eps as A}from"./terrainUtils.js";import{TextureFader as $,ActivationTime as w}from"./TextureFader.js";export{ActivationTime}from"./TextureFader.js";import{isCornerNeighbor as O,isEdgeNeighbor as P}from"./Tile.js";import M from"./TileOverlayData.js";import{fallsWithinLayer as U}from"./tileUtils.js";import{Default3D as F}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{BufferObject as B}from"../../webgl/BufferObject.js";import{VertexArrayObject as H}from"../../webgl/VertexArrayObject.js";class W{constructor(){this.geometryInfo=new T,this.intersectionData=null,this.geometryState=null,this._textureRef=new $((()=>this.tile.surface.textureFadeDuration)),this.overlay=new M,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._edgeResolutionChanged=!1,this._edgeNeighborChanged=!1,this._cornerChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1}get tile(){return this._tile}init(e){this._tile=e,this.clear();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 b,this.localOrigin=null,this.overlay.clear()}clear(){this._releaseGeometry(),this.releaseTexture(),this._textureRef.clear()}updateGeometryIfChanged(e,t){const r=this.updateGeometryStateAndPrepareForGeometryGeneration(t);this._hasGeometry=!0;return this.updateNeighborDataAndGeometryIfNeeded(r,e)}updateNeighborDataAndGeometryIfNeeded(e=!1,t=this.vao.context){const r=this._updateNeighborData(),i=e||this._geometryStateChangedSinceLastUpdate||r;if(i&&(this._updateGeometry(t),this._geometryStateChangedSinceLastUpdate=!1),E)for(let o=0;o<4;++o)j(this.geometryInfo.outerEdges[o].count===this.geometryState.neighborData.edgeResolutions[o]+1);return i}_calculateEdgeResolution(e,t){const r=this.tile,s=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(i(t)&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return s}const n=r.level,a=L[e],l=t||r.findNeighborTile(a,(e=>e.isLoaded||e.level===n));if(!l||l.isLeaf&&!l.isLoaded)return j(o(r.surface?.rootTiles)||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(a)),s;if(l.isLoaded){const t=l,r=t.renderData.geometryState,i=n-t.level;if(j(i>=0),0===i){const e=r.numVerticesPerSide-1;return Math.max(e,s)}const o=2**i,a=r.neighborData.edgeResolutions[(e+2)%4]/o;return Math.max(1,a)}j(!l.isLeaf);let h=s;return l.forAllSubtreeOnSide(V(a),(e=>e===r||(e.isLoaded?(h=Math.max(h,2**(e.level-n)),!0):(j(!e.isLeaf),!1)))),h}_updateNeighborData(){const e=this.tile,i=t=>t.isLoaded||t.level===e.level,o=e=>e.isLoaded,s=[null,null,null,null],n=[null,null,null,null];(()=>{for(let t=0;t<4;++t){const r=e.findNeighborTile(L[t],i);s[t]=r,n[t]=r?.isLoaded?r:null}})();const a=[null,null,null,null];if((()=>{for(let t=0;t<4;++t)a[t]=e.findNeighborTile(R[t],o)})(),E){const t=t=>t?.isLoaded||t?.isLeaf||t?.lij[0]===e.lij[0];R.forEach((r=>{const i=e.findNeighborTile(r,t);j(!i||O(e,i,r));const o=i?.findCorner(N(r),(e=>e?.isLoaded||e?.isLeaf));j(!o||O(e,o,r))}))}const l=this.geometryState.neighborData;let h=!1;(()=>{for(let r=0;r<4;++r){const i=l.edgeResolutions[r],o=s[r],n=this._calculateEdgeResolution(r,o);j(t(n)),j(n>=1),l.edgeResolutions[r]=n,i!==n&&(h=!0,this._edgeResolutionChanged=!0,o&&o!==e&&!o.isLoaded&&o.level===e.level&&(l.modifiedEdgeResolutions[r]=!0))}})();(()=>{const t=(t,i)=>{const o=t.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);E&&(j(!t[0]||!t[2]||O(t[0],t[2],D.SOUTH_WEST)),j(!t[1]||!t[3]||O(t[1],t[3],D.NORTH_WEST)));for(let l=0;l<4;++l){const o=t[(l+3)%4],s=t[l];if(o&&o.level<e.level&&o===s){j(!E||o!==e);const t=1==(1&l),s=0===i||1===i&&!t||3===i&&t,n=e.getNeighborEdgeStartVertexIndex(l,o)+(s?1:0),a=2**(e.level-o.level);j(!E||0<=n&&n<=a);const h=n/a,d=t?0===i||1===i?o.extent[0]:o.extent[2]:r(o.extent[0],o.extent[2],h),g=t?r(o.extent[1],o.extent[3],h):0===i||3===i?o.extent[1]:o.extent[3];return v(d,g,o.renderData.geometryState.samplerData)}}let s=0,n=0;for(let e=0;e<4;++e){const r=t[e];if(r&&r.level===o){const t=0===e||1===e,i=0===e||3===e,o=r.extent;n+=v(o[t?0:2],o[i?1:3],r.renderData?.geometryState?.samplerData),s++}}const a=s?n/s:0;return j(null!=a),a},i=l.cornerNeighborData,o=(r,o)=>{const s=i[r],n=s.cornerTiles,a=s.cornerTileSamplerVersions;for(let t=0;t<4;++t){const r=R[t],i=o[t]?.findCorner(N(r),(t=>t?.isLoaded||t===e));if(n[t]!==i&&(this._cornerChanged=!0,h=!0,n[t]=i),i){const e=i.renderData.geometryState.samplerDataVersion??-1;e!==a[t]&&(a[t]=e,this._cornerChanged=!0,h=!0)}}const l=t(n,r);return s.elevation!==l&&(j(null!=l),s.elevation=l,!0)};for(let r=0;r<4;++r){const t=a[r],i=n[r],s=[t,n[(r+1)%4],e,i],l=s.map(((e,t)=>s[(t+4-r)%4]));o(r,l)&&(this._cornerChanged=!0,h=!0)}})();return(()=>{const t=(t,r)=>{if(!t?.isLoaded||t.lij[0]>e.lij[0])return null;const i=t.renderData.geometryState;return{neighborSamplerData:i.samplerData,neighborEdgeOverlapResolution:i.neighborData.edgeResolutions[r+2],version:i.samplerDataVersion,neighborVerticesPerSide:i.numVerticesPerSide,neighborTile:t}},r=l.edgeNeighbours;for(let i=0;i<4;++i){const o=n[i];o&&(j(o?.isLoaded),j(o?.lij[0]<=e.lij[0]));const s=r[i],a=s?.version,l=t(o,i),d=l?.version??null,g=null!=s!=(null!=l),u=s&&l&&a!==d,c=s&&l&&s?.neighborTile!==l?.neighborTile,m=g||u||c;this._edgeNeighborChanged||(this._edgeNeighborChanged=m),h||(h=m),!m&&a||(r[i]=l)}})(),h}updateEdgeAfterResolutionChange(e){const t=this._calculateEdgeResolution(e),r=this.geometryState.neighborData.edgeResolutions,i=r[e];j((this.geometryState.neighborData.edgeNeighbours[e]?.neighborTile.level??0)<=this.tile.level),t!==i&&(r[e]=t,this._edgeResolutionChanged=!0,this._updateGeometry(this.vao.context))}_updateGeometry(e){this.intersectionData=null;const t=this.tile,r=this._vao,i=this.geometryInfo.vertexAttributes,o=!r||!i||this._wireframeChanged||this._numVerticesPerSideChanged||this._samplerDataChanged||this._clippingAreaChanged||this._edgeResolutionChanged,s=!o&&this._edgeNeighborChanged,n=!s&&this._cornerChanged;this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._edgeResolutionChanged=!1,this._edgeNeighborChanged=!1,this._cornerChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1,o?(this._releaseGeometry(),this._createGeometry(e)):s?t.updateEdgeElevations():n?t.updateCornerElevations():console.warn("Update for no reason?")}releaseGeometry(){return this._releaseGeometry()}get hasGeometry(){return this._hasGeometry}ensureTexture(e,t){return i(this._texture)&&this._texture.descriptor.width!==e&&this.releaseTexture(),o(this._texture)&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){i(this._texture)&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}updateGeometryStateAndPrepareForGeometryGeneration(t){const r=this._getElevationInfo(),i=r.samplerData?this.tile.getElevationBasedVerticesPerSide(r.maxTileLevel):this.tile.getDefaultVerticesPerRowOnLevel(),o=Math.max(i,5);let s=this.tile.clippingArea;this.tile.intersectsClippingArea&&!this.tile.isWithinClippingArea||(s=null);const n=this.geometryState;let a=!1;return n.numVerticesPerSide!==o&&(this._numVerticesPerSideChanged=!0,n.numVerticesPerSide=o,n.samplerDataVersion++,a=!0),r.changed&&(this._samplerDataChanged=!0,n.samplerData=r.samplerData,n.samplerDataVersion++,a=!0),e(n.clippingArea,s)||(this._clippingAreaChanged=!0,n.clippingArea=s,a=!0),n.wireframe!==t&&(this._wireframeChanged=!0,n.wireframe=t,a=!0),this._geometryStateChangedSinceLastUpdate||(this._geometryStateChangedSinceLastUpdate=a),this._hasGeometry=!0,a}_createGeometry(e){this.tile.createGeometry();const t=this.geometryInfo.vertexAttributes,r=this.geometryInfo.indices,i=e.gl;this._vao=new H(e,F,{geometry:_(t.layout)},{geometry:B.createVertex(e,i.STATIC_DRAW,t.buffer)},B.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}_releaseGeometry(){return this._hasGeometry=!1,!!this._vao&&(this._vao.dispose(),this._vao=null,C(this.geometryInfo),!0)}get vao(){return this._vao}setTextureReference(e,t=w.Immediate){i(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[S.ELEVATION],r=t.length;let o=new Array(r),s=0,n=0,a=!1;for(let l=0;l<r;l++){const r=t[l];if(i(r.upsampleInfo)){const t=r.upsampleInfo.tile,i=t.layerInfo[S.ELEVATION][l].data,h=i&&i.samplerData;e&&e[s]===h||(a=!0),o[s++]=h,n=Math.max(n,t.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(l,S.ELEVATION);if(U(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),o[s++]=t.samplerData,n=this.tile.level}}}return i(e)&&e.length!==s&&(a=!0),s>0?o.length=s:o=null,{changed:a,samplerData:o,maxTileLevel:n}}get estimatedGeometryMemoryUsage(){const e=s(this.intersectionData,0,(e=>e.estimatedMemoryUsage));return this.geometryInfo.indices.byteLength+this.geometryInfo.vertexAttributes.byteLength+e}get textureDescriptor(){return i(this._texture)?this._texture.descriptor:null}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!E)return;const e=this.tile;if(j(e?.isLoaded),!e.isLoaded)return;const r=e.surface.extent;if(i(r)&&!e.intersectsExtent(r))return;const s=L.map(((t,o)=>!!i(r)&&(o<2?-1:1)*(e.extent[3-o]-r[3-o])<0)),p=e.level;L.forEach(((r,_)=>{if(s[_])return;const v=e.findNeighborTile(r,(e=>e.level===p||e?.isLoaded));if(!v){const t=!e.surface.updatingRootTiles&&i(e.surface.rootTiles)&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void j(!t)}const b=p-v.level;if(!v.isLoaded)return j(!v.isLeaf),void j(0===b);j(P(e,v,r)),j(b>=0);const S=2**b;if(b<0)return void j(!1);const T=e.renderData.geometryInfo,C=T.outerEdges[_],E=T.numVerticesPerSide-1,L=v.renderData.geometryInfo;if(j(!!L),!L)return;{const t=e.renderData.geometryState.neighborData.edgeNeighbours[_];t&&(j(t.neighborTile===v),j(t.version===v.renderData.geometryState.samplerDataVersion))}const V=L.outerEdges[(_+2)%4];j(C.count-1==(V.count-1)/S);const R=e.extent,N=r===D.NORTH||r===D.SOUTH,A=V.count-1,$=A/2**b,w=C.count-1;if($<1)return void j(1===w);j($===w),j(t($));const O=L.numVerticesPerSide-1;j(b>0||$===Math.max(O,E));const M=e.getNeighborEdgeStartVertexIndex(_,v);j(0<=M&&M<S);const U=M*$;j(0<=U&&U<=A-$);let F=0,B=U;C.getVertex(X,F),C.getVertex(k,F);const H=n(X,k),W=Math.max(Y,1e-5*H),Q=(_+2)%4;for(let t=0;t<=$;++t){C.getVertex(X,F),V.getVertex(k,B);const s=t/$,p=N?R[0]+s*(R[2]-R[0]):r===D.WEST?R[0]:R[2],b=N?r===D.SOUTH?R[1]:R[3]:R[1]+s*(R[3]-R[1]),S=e.surface.extent;if(o(S)||x(S,p,b)){const t=a(X,k),r=l(X)-y.radius,o=l(k)-y.radius,s=t<W;if(!s){console.log("Tile edge vertex position mismatch: between ",e.lij,": ",_,"[",F,"]"," and ",v.lij,": ",Q,"[",B,"]"),i(S)&&console.log(" surface extent= ",S," x,y=",p,",",b);const a=m();h(a,e.renderData.localOrigin,v.renderData.localOrigin),a.length>0&&console.log(" localOrigins:",G(e.renderData.localOrigin)," vs ",G(v.renderData.localOrigin));(()=>{const t=f(X),r=f(k);e.updateEdgeElevations(),v.updateEdgeElevations(),C.getVertex(X,F),V.getVertex(k,B),n(X,t)>0&&console.log(" XXX Tile edge out of date: ",G(t)," vs ",G(X)),n(k,r)>0&&console.log(" XXX Neighbor edge out of date: ",G(r)," vs ",G(k))})(),j(s,`Mismatch in tile ${I(e.lij)} (${F}/${C.count-1}) edge ${_} vs neighbor ${I(v.lij)} (${B}/${V.count-1}) nedge ${Q} : ${G(X)} vs ${G(k)} dist=${t} h(t|n|d)=${r}|${o}|${o-r}`)}if(e.surface.shadingEnabled){C.getNormal(z,F),V.getNormal(q,B),d(J,z),d(K,q);const t=g(J,K),r=!1,i=1-t<.01||r||e===v;if(!i){const r=m();u(r,z,q);const o=()=>`Mismatch in tile edge normal ${I(e.lij)} (${F}/${C.count-1}) edge ${_} vs neighbor ${I(v.lij)} (${B}/${V.count-1}) nedge ${Q} :${G(z)} vs ${G(q)} dot = ${t} : ${G(r)}`;console.warn("Mismatch in tile edge normal: ",o());{e.updateEdgeElevations(),v.updateEdgeElevations();const t=m(),r=m();C.getNormal(t,F),V.getNormal(r,B),c(z,t)||console.warn("Missing update in tile normal: ",G(z)," => ",G(t)),c(q,r)||console.warn("Missing update in neighbor normal: ",G(q)," => ",G(r))}j(i,o())}}}F+=1,B+=1}}))}}const X=m(),k=m(),z=m(),q=m(),J=m(),K=m();function Q(e,t,r){if(i(r))for(const i of r)if(i){const r=i.x0,o=i.width,s=r+(o-1)/i.dx,n=i.y1,a=n-(o-1)/i.dy;if(e>=r-A&&e<=s+A&&a-A<=t&&t<=n+A)return!0}return!1}const Y=1;export{W as PatchRenderData,Q as isElevationSampleIn};
|