@arcgis/core 4.30.0-next.20240313 → 4.30.0-next.20240314
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/arcade/functions/knowledgegraph.js +1 -1
- package/arcade/functions/maths.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/14b9001a3233075dd1b7.js +1 -0
- package/assets/esri/core/workers/chunks/2d0a01d0957b3e4512f6.js +1 -0
- package/assets/esri/core/workers/chunks/{cccf63c65070c6a47b16.js → 5dc63f28bc608c56d3e6.js} +1 -1
- package/assets/esri/core/workers/chunks/{a1a557cbfb0aa915f81b.js → 95d7b168991ddb3a96ca.js} +1 -1
- package/assets/esri/core/workers/chunks/{67ab6af927ea04c01a40.js → a658dd87b1b59e9cf2a3.js} +1 -1
- package/chunks/terrainUtilsPlanar.js +1 -1
- package/chunks/terrainUtilsSpherical.js +1 -1
- package/core/arrayUtils.js +1 -1
- package/interfaces.d.ts +4 -4
- package/package.json +1 -1
- package/rest/geoprocessor/utils.js +1 -1
- package/support/revision.js +1 -1
- package/undoredo/support/ApplySet.js +5 -0
- package/undoredo/support/ApplySetItem.js +5 -0
- package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/terrain/ExtentHelper.js +1 -1
- package/views/3d/terrain/TilingScheme.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/draw/DrawAction.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/GraphicMover.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/input/ViewEvents.js +1 -1
- package/views/input/gamepad/GamepadSource.js +1 -1
- package/views/input/recognizers/DoubleTapDrag.js +1 -1
- package/views/input/recognizers/PointerClickHoldAndDrag.js +1 -1
- package/views/input/recognizers/SingleAndDoubleClick.js +1 -1
- package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
- package/views/interactive/snapping/FeatureSnappingSourceInfo.js +1 -1
- package/views/interactive/snapping/LineSnapper.js +1 -1
- package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/SnappingVisualizer.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/PendingFeatureTile.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
- package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
- package/views/webgl/ContextState.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/utils.js +1 -1
- package/assets/esri/core/workers/chunks/a1978ae86e466020dd28.js +0 -1
- package/assets/esri/core/workers/chunks/bf041907bac8fae05c2b.js +0 -1
package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{estimateAttributesObjectSize as s,estimateFixedArraySize as i}from"../../../../../core/byteSizeEstimations.js";import{ByteSizeUnit as r}from"../../../../../core/ByteSizeUnit.js";import{intersection as o,isSubsetOf as n}from"../../../../../core/SetUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as u}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{estimateAttributesObjectSize as s,estimateFixedArraySize as i}from"../../../../../core/byteSizeEstimations.js";import{ByteSizeUnit as r}from"../../../../../core/ByteSizeUnit.js";import{intersection as o,isSubsetOf as n}from"../../../../../core/SetUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as u}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as c,intersects as a,fromExtent as h,area as d}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsOptimizedGeometry as f}from"../../../../../layers/graphics/featureConversionUtils.js";import{BoundsStore as _}from"../../../../../layers/graphics/data/BoundsStore.js";import p from"../../../../../layers/support/TileInfo.js";import{TileKey as m}from"../../../../../layers/support/TileKey.js";import{executeQueryForCount as g}from"../../../../../rest/query/operations/query.js";import{FeatureServiceTileCache as y}from"./FeatureServiceTileCache.js";let v=class extends t{constructor(e){super(e),this.tileInfo=null,this.extent=null,this.maximumByteSize=10*r.MEGABYTES,this._tileBounds=new _,this._tiles=new y,this._refCounts=new Map,this._tileFeatureCounts=new Map,this._tmpBoundingRect=c()}add(e,t){for(const r of t)this._referenceFeature(r.objectId);const s=this.featureStore.upsertMany(t),i=s.map((e=>new Set(Object.keys(e.attributes)))).reduce(((e,t)=>o(e,t)),new Set(Object.keys(s[0]?.attributes??[])));this._addTileStorage(e,new Set(s.map((e=>e.objectId))),S(s),i),this._tiles.applyByteSizeLimit(this.maximumByteSize,(e=>this._removeTileStorage(e)))}getAttributesForTile(e){return e?this._tiles.get(e)?.attributeKeys:null}destroy(){this.clear(),this._tileFeatureCounts.clear()}clear(){this.featureStore.clear(),this._tileBounds.clear(),this._tiles.clear(),this._refCounts.clear()}refresh(){this.clear(),this._tileFeatureCounts.clear()}processEdits(e,t,s){return this._processEditsDelete(e.deletedFeatures.concat(e.updatedFeatures)),this._processEditsRefetch(e.addedFeatures.concat(e.updatedFeatures),t,s)}_addTileStorage(e,t,s,i){const r=e.id;this._tiles.set(r,new w(e,t,s,i)),this._tileBounds.set(r,e.extent),this._tileFeatureCounts.set(r,t.size)}_remove({id:e}){const t=this._tiles.get(e);t&&this._removeTileStorage(t)}_removeTileStorage(e){const t=[];for(const i of e.objectIds)this._unreferenceFeature(i)===x.REMOVED&&t.push(i);this.featureStore.removeManyById(t);const s=e.data.id;this._tiles.delete(s),this._tileBounds.delete(s)}_processEditsDelete(e){this.featureStore.removeManyById(e);for(const[,t]of this._tiles){for(const s of e)t.objectIds.delete(s);this._tileFeatureCounts.set(t.data.id,t.objectIds.size)}for(const t of e)this._refCounts.delete(t)}async _processEditsRefetch(e,t,s){const i=(await t(e,s)).features,{hasZ:r,hasM:o}=this.featureStore;for(const n of i){const e=f(this._tmpBoundingRect,n.geometry,r,o);null!=e&&this._tileBounds.forEachInBounds(e,(e=>{const t=this._tiles.get(e);this.featureStore.add(n);const s=n.objectId;t.objectIds.has(s)||(t.objectIds.add(s),this._referenceFeature(s),this._tileFeatureCounts.set(t.data.id,t.objectIds.size))}))}}process(e,t=(()=>!0),s){if(null==this.tileInfo||!e.extent||null!=this.extent&&!a(h(this.extent,this._tmpBoundingRect),e.extent))return new j(e);const i=this.getAttributesForTile(e.id);if(n(s,i))return new j(e);const r=this._createTileTree(e,this.tileInfo);return this._simplify(r,t,null,0,1),this._collectMissingTiles(e,r,this.tileInfo,s)}get debugInfo(){return Array.from(this._tiles.values()).map((({data:e})=>({data:e,featureCount:this._tileFeatureCounts.get(e.id)||0})))}getFeatureCount(e){return this._tileFeatureCounts.get(e.id)??0}async fetchCount(e,t,s,i){const r=this._tileFeatureCounts.get(e.id);if(null!=r)return r;const o=await g(t,s,i);return this._tileFeatureCounts.set(e.id,o.data.count),o.data.count}_createTileTree(e,t){const s=new F(e.level,e.row,e.col);return t.updateTileInfo(s,p.ExtrapolateOptions.POWER_OF_TWO),this._tileBounds.forEachInBounds(e.extent,(i=>{const r=this._tiles.get(i)?.data;r&&C(e,r)&&this._populateChildren(s,r,t,this._tileFeatureCounts.get(r.id)||0)})),s}_populateChildren(e,t,s,i){const r=t.level-e.level-1;if(r<0)return void(e.isLeaf=!0);const o=t.row>>r,n=t.col>>r,l=e.row<<1,u=n-(e.col<<1)+(o-l<<1),c=e.children[u];if(null!=c)this._populateChildren(c,t,s,i);else{const r=new F(e.level+1,o,n);s.updateTileInfo(r,p.ExtrapolateOptions.POWER_OF_TWO),e.children[u]=r,this._populateChildren(r,t,s,i)}}_simplify(e,t,s,i,r){const o=r*r;if(e.isLeaf)return t(this.getFeatureCount(e),r)?0:(this._remove(e),null!=s&&(s.children[i]=null),o);const n=r/2,l=n*n;let u=0;for(let c=0;c<e.children.length;c++){const s=e.children[c];u+=null!=s?this._simplify(s,t,e,c,n):l}return 0===u?this._mergeChildren(e):1-u/o<I&&(this._purge(e),null!=s&&(s.children[i]=null),u=o),u}_mergeChildren(e){const t=new Set;let s,i=0;this._forEachLeaf(e,(e=>{const r=this._tiles.get(e.id);if(r){s=s?o(s,r.attributeKeys):new Set(r.attributeKeys),i+=r.byteSize;for(const e of r.objectIds)t.has(e)||(t.add(e),this._referenceFeature(e));this._remove(e)}})),this._addTileStorage(e,t,i,s??new Set),e.isLeaf=!0,e.children[0]=e.children[1]=e.children[2]=e.children[3]=null,this._tileFeatureCounts.set(e.id,t.size)}_forEachLeaf(e,t){for(const s of e.children)null!=s&&(s.isLeaf?t(s):this._forEachLeaf(s,t))}_purge(e){if(null!=e)if(e.isLeaf)this._remove(e);else for(let t=0;t<e.children.length;t++){const s=e.children[t];this._purge(s),e.children[t]=null}}_collectMissingTiles(e,t,s,i){const r=new b(s,e,this.extent);return this._collectMissingTilesRecurse(t,r,1,i),r.info}_collectMissingTilesRecurse(e,t,s,i){const r=this.getAttributesForTile(e.id),o=r&&!n(i,r);if(o&&t.addMissing(e.level,e.row,e.col,s),e.isLeaf)return;if(!e.hasChildren)return void(o||t.addMissing(e.level,e.row,e.col,s));const l=s/2;for(let n=0;n<e.children.length;n++){const s=e.children[n];null==s?t.addMissing(e.level+1,(e.row<<1)+((2&n)>>1),(e.col<<1)+(1&n),l):this._collectMissingTilesRecurse(s,t,l,i)}}_referenceFeature(e){const t=(this._refCounts.get(e)||0)+1;return this._refCounts.set(e,t),1===t?x.ADDED:x.UNCHANGED}_unreferenceFeature(e){const t=(this._refCounts.get(e)||0)-1;return 0===t?(this._refCounts.delete(e),x.REMOVED):(t>0&&this._refCounts.set(e,t),x.UNCHANGED)}get test(){return{tiles:Array.from(this._tiles.values()).map((e=>`${e.data.id}:[${Array.from(e.objectIds)}]`)),featureReferences:Array.from(this._refCounts.keys()).map((e=>`${e}:${this._refCounts.get(e)}`))}}};function C(e,t){if(!e||!t)return!1;if(e.level===t.level)return e.row===t.row&&e.col===t.col;const s=e.level<t.level,i=s?e:t,r=s?t:e,o=1<<r.level-i.level;return Math.floor(r.row/o)===i.row&&Math.floor(r.col/o)===i.col}function S(e){return e.reduce(((e,t)=>e+E(t)),0)}function E(e){return 32+T(e.geometry)+s(e.attributes)}function T(e){if(null==e)return 0;const t=i(e.lengths,4);return 32+i(e.coords,8)+t}e([l({constructOnly:!0})],v.prototype,"featureStore",void 0),e([l()],v.prototype,"tileInfo",void 0),e([l()],v.prototype,"extent",void 0),e([l()],v.prototype,"maximumByteSize",void 0),v=e([u("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTileStore")],v);class w{constructor(e,t,s,i){this.data=e,this.objectIds=t,this.byteSize=s,this.attributeKeys=i}}class F{constructor(e,t,s){this.level=e,this.row=t,this.col=s,this.isLeaf=!1,this.extent=null,this.children=[null,null,null,null]}get hasChildren(){return!this.isLeaf&&(null!=this.children[0]||null!=this.children[1]||null!=this.children[2]||null!=this.children[3])}}class j{constructor(e,t=[]){this.missingTiles=t,this.fullArea=0,this.coveredArea=0,this.fullArea=d(e.extent),this.coveredArea=this.fullArea}prepend(e){this.missingTiles=e.missingTiles.concat(this.missingTiles),this.coveredArea+=e.coveredArea,this.fullArea+=e.fullArea}}class b{constructor(e,t,s){this._tileInfo=e,this._extent=null,this.info=new j(t),null!=s&&(this._extent=h(s))}addMissing(e,t,s,i){const r=new m(null,e,t,s);this._tileInfo.updateTileInfo(r,p.ExtrapolateOptions.POWER_OF_TWO),null==r.extent||null!=this._extent&&!a(this._extent,r.extent)||(this.info.missingTiles.push({data:r,resolution:i}),this.info.coveredArea-=d(r.extent))}}const I=.18751;var x;!function(e){e[e.ADDED=0]="ADDED",e[e.REMOVED=1]="REMOVED",e[e.UNCHANGED=2]="UNCHANGED"}(x||(x={}));export{v as FeatureServiceTileStore,j as ProcessResult};
|
package/views/interactive/snapping/featureSources/featureServiceSource/PendingFeatureTile.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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{createTask as t,resultOrAbort as e}from"../../../../../core/asyncUtils.js";import{create as s,fromExtent as a,intersects as E}from"../../../../../geometry/support/aaBoundingRect.js";class r{constructor(t,e){this.data=t,this.resolution=e,this.state={type:
|
|
5
|
+
import{createTask as t,resultOrAbort as e}from"../../../../../core/asyncUtils.js";import{create as s,fromExtent as a,intersects as E}from"../../../../../geometry/support/aaBoundingRect.js";class r{constructor(t,e){this.data=t,this.resolution=e,this.state={type:i.CREATED},this.alive=!0}process(t){switch(this.state.type){case i.CREATED:return this.state=this._gotoFetchCount(this.state,t),this.state.task.promise.then(t.resume,t.resume);case i.FETCH_COUNT:break;case i.FETCHED_COUNT:return this.state=this._gotoFetchFeatures(this.state,t),this.state.task.promise.then(t.resume,t.resume);case i.FETCH_FEATURES:break;case i.FETCHED_FEATURES:this.state=this._goToDone(this.state,t);case i.DONE:}return null}get debugInfo(){return{data:this.data,featureCount:this._featureCount,state:this._stateToString}}get _featureCount(){switch(this.state.type){case i.CREATED:case i.FETCH_COUNT:return 0;case i.FETCHED_COUNT:return this.state.featureCount;case i.FETCH_FEATURES:return this.state.previous.featureCount;case i.FETCHED_FEATURES:return this.state.features.length;case i.DONE:return this.state.previous.features.length}}get _stateToString(){switch(this.state.type){case i.CREATED:return"created";case i.FETCH_COUNT:return"fetch-count";case i.FETCHED_COUNT:return"fetched-count";case i.FETCH_FEATURES:return"fetch-features";case i.FETCHED_FEATURES:return"fetched-features";case i.DONE:return"done"}}_gotoFetchCount(s,a){return{type:i.FETCH_COUNT,previous:s,task:t((async t=>{const s=await e(a.fetchCount(this,t));this.state.type===i.FETCH_COUNT&&(this.state=u(this.state,s.ok?s.value:1/0))}))}}_gotoFetchFeatures(s,a){return{type:i.FETCH_FEATURES,previous:s,task:t((async t=>{const E=await e(a.fetchFeatures(this,s.featureCount,t));this.state.type===i.FETCH_FEATURES&&(this.state=T(this.state,E.ok?E.value:[]))}))}}_goToDone(t,e){return e.finish(this,t.features),{type:i.DONE,previous:t}}reset(){const t=this.state;switch(this.state={type:i.CREATED},t.type){case i.CREATED:case i.FETCHED_COUNT:case i.FETCHED_FEATURES:case i.DONE:break;case i.FETCH_COUNT:case i.FETCH_FEATURES:t.task.abort()}}intersects(t){return null==t||!this.data.extent||(a(t,n),E(this.data.extent,n))}}function u(t,e){return{type:i.FETCHED_COUNT,featureCount:e,previous:t}}function T(t,e){return{type:i.FETCHED_FEATURES,previous:t,features:e}}var i;!function(t){t[t.CREATED=0]="CREATED",t[t.FETCH_COUNT=1]="FETCH_COUNT",t[t.FETCHED_COUNT=2]="FETCHED_COUNT",t[t.FETCH_FEATURES=3]="FETCH_FEATURES",t[t.FETCHED_FEATURES=4]="FETCHED_FEATURES",t[t.DONE=5]="DONE"}(i||(i={}));const n=s();export{r as PendingFeatureTile,i as StateType};
|
package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{g as s,q as n}from"../../../../../chunks/vec32.js";import{create as i,clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{throwIfAborted as t}from"../../../../../core/promiseUtils.js";import"../../../../../core/Logger.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import"../../../../../core/Error.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{g as s,q as n}from"../../../../../chunks/vec32.js";import{create as i,clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c,fromPoints as d,projectPoint as a}from"../../../../../geometry/support/lineSegment.js";import{g as p,n as m}from"../../../../../chunks/sphere.js";import u from"../../../../3d/webgl-engine/lib/Octree.js";import{extractComponentsEdgeLocationsLayout as h}from"../../../../3d/webgl-engine/lib/edgeRendering/edgeProcessing.js";import{maxCandidateCount as g,boundsFromEdge as l}from"./sceneLayerSnappingUtils.js";let f=class{constructor(){this._idToComponent=new Map,this._components=new u((e=>e.bounds)),this._edges=new u((e=>e.bounds)),this._tmpLineSegment=c(),this._tmpP1=i(),this._tmpP2=i(),this._tmpP3=i(),this.remoteClient=null}async fetchCandidates(e,o){await Promise.resolve(),t(o),await this._ensureEdgeLocations(e,o);const s=[];return this._edges.forEachNeighbor((t=>(this._addCandidates(e,t,s),s.length<g)),e.bounds),{result:{candidates:s}}}async _ensureEdgeLocations(e,t){const o=[];if(this._components.forEachNeighbor((e=>{if(null==e.info){const{id:t,uid:s}=e;o.push({id:t,uid:s})}return!0}),e.bounds),!o.length)return;const s={components:o},n=await this.remoteClient.invoke("fetchAllEdgeLocations",s,t??{});for(const i of n.components)this._setFetchEdgeLocations(i)}async add(e){const t=new j(e.id,e.bounds);return this._idToComponent.set(t.id,t),this._components.add([t]),{result:{}}}async remove(e){const t=this._idToComponent.get(e.id);if(t){const e=[];this._edges.forEachNeighbor((o=>(o.component===t&&e.push(o),!0)),t.bounds),this._edges.remove(e),this._components.remove([t]),this._idToComponent.delete(t.id)}return{result:{}}}_setFetchEdgeLocations(e){const t=this._idToComponent.get(e.id);if(null==t||e.uid!==t.uid)return;const o=h.createView(e.locations),s=new Array(o.count),n=i(),r=i();for(let i=0;i<o.count;i++){o.position0.getVec(i,n),o.position1.getVec(i,r);const c=l(n,r,e.origin),d=new w(t,i,c);s[i]=d}this._edges.add(s);const{objectIds:c,origin:d}=e;t.info={locations:o,objectIds:c,origin:d}}_addCandidates(e,t,o){const{info:n}=t.component,{origin:i,objectIds:r}=n,c=n.locations,d=c.position0.getVec(t.index,this._tmpP1),a=c.position1.getVec(t.index,this._tmpP2);s(d,d,i),s(a,a,i);const p=r[c.componentIndex.get(t.index)];this._addEdgeCandidate(e,p,d,a,o),b(e,p,d,o),b(e,p,a,o)}_addEdgeCandidate(e,t,o,s,i){if(!e.returnEdge)return;const c=p(e.bounds),u=d(o,s,this._tmpLineSegment),h=a(u,c,this._tmpP3);m(e.bounds,h)&&i.push({type:"edge",objectId:t,target:r(h),distance:n(c,h),start:r(o),end:r(s)})}};f=e([o("esri.views.interactive.snapping.featureSources.sceneLayerSource.SceneLayerSnappingSourceWorker")],f);const _=f;function b(e,t,o,s){if(!e.returnVertex||!m(e.bounds,o))return;const i=p(e.bounds);s.push({type:"vertex",objectId:t,target:r(o),distance:n(i,o)})}class j{constructor(e,t){this.id=e,this.bounds=t,this.info=null,this.uid=++j.uid}}j.uid=0;class w{constructor(e,t,o){this.component=e,this.index=t,this.bounds=o}}export{_ 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s}=t;return new c(e,s)}return new a}class a{async alignCandidates(e,t,s){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s){this._elevationInfo=t,this._alignPointsInFeatures=s,this._alignmentsCache=new e(r),this._cacheVersion=0}async alignCandidates(e,t,s){const n=this._elevationInfo;return null==n||"absolute-height"!==n.mode||n.featureExpressionInfo?this._alignComputedElevationCandidates(e,t,s):(
|
|
5
|
+
import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s}=t;return new c(e,s)}return new a}class a{async alignCandidates(e,t,s){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s){this._elevationInfo=t,this._alignPointsInFeatures=s,this._alignmentsCache=new e(r),this._cacheVersion=0}async alignCandidates(e,t,s){const n=this._elevationInfo;return null==n||"absolute-height"!==n.mode||n.featureExpressionInfo?this._alignComputedElevationCandidates(e,t,s):(l(e,t,n),e)}notifyElevationSourceChange(){this._alignmentsCache.clear(),this._cacheVersion++}async _alignComputedElevationCandidates(e,n,o){const i=new Map;for(const s of e)t(i,s.objectId,d).push(s);const[a,r,c]=this._prepareQuery(i,n),h=await this._alignPointsInFeatures(a,o);s(o);if(c!==this._cacheVersion)return this._alignComputedElevationCandidates(e,n,o);this._applyCacheAndResponse(a,h,r);const{drapedObjectIds:u,failedObjectIds:l}=h,p=[];for(const t of e){const{objectId:e}=t;u.has(e)&&"edge"===t.type&&(t.draped=!0),l.has(e)||p.push(t)}return p}_prepareQuery(e,t){const s=[],n=[];for(const[o,i]of e){const e=[];for(const t of i)this._addToQueriesOrCachedResult(o,t.target,e,n),"edge"===t.type&&(this._addToQueriesOrCachedResult(o,t.start,e,n),this._addToQueriesOrCachedResult(o,t.end,e,n));0!==e.length&&s.push({objectId:o,points:e})}return[{spatialReference:t.toJSON(),pointsInFeatures:s},n,this._cacheVersion]}_addToQueriesOrCachedResult(e,t,s,n){const o=u(e,t),i=this._alignmentsCache.get(o);null==i?s.push(t):n.push(new h(t,i))}_applyCacheAndResponse(e,{elevations:t,drapedObjectIds:s,failedObjectIds:n},o){for(const r of o)r.apply();let i=0;const a=this._alignmentsCache;for(const{objectId:r,points:c}of e.pointsInFeatures){if(n.has(r)){i+=c.length;continue}const e=!s.has(r);for(const s of c){const n=u(r,s),o=t[i++];s.z=o,e&&a.put(n,o,1)}}}}class h{constructor(e,t){this.point=e,this.z=t}apply(){this.point.z=this.z}}function u(e,{x:t,y:s,z:n,spatialReference:o}){return`${e}-${t}-${s}-${n??0}}-wkid:${o?.wkid}`}function l(e,t,s){const{offset:i,unit:a}=s;if(null==i)return;const r=n(t),c=i*(o(a??"meters")/r);for(const n of e)switch(n.type){case"edge":n.start.z+=c,n.end.z+=c;continue;case"vertex":n.target.z+=c;continue}}function d(){return[]}export{i as getSnappingCandidateElevationAligner};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import{watch as e}from"../../../../core/reactiveUtils.js";import{waitAnimationFrame as i}from"../../../../core/scheduling.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{tooltipKeys as s}from"../../keybindings.js";import{base as l}from"../css.js";import a from"../../../../widgets/Widget.js";import{loadCalciteComponents as c}from"../../../../widgets/support/componentsUtils.js";import"../../../../widgets/support/widgetUtils.js";import{tsx as r}from"../../../../widgets/support/jsxFactory.js";const u=`${l}-editable-field`,p={base:u,inputMode:`${u}--input`,locked:`${u}--locked`,title:`${u}__title`,titleContent:`${u}__title__content`,value:`${u}__value`,valueContent:`${u}__value__content`,valueContentReadOnly:`${u}__value__content--read-only`,input:`${u}__input`,inputSuffix:`${u}__input-suffix`,button:`${u}__button`};let d=class extends a{constructor(){super(...arguments),this._input=null,this._selectText=()=>{const t=()=>{this._input===document.activeElement&&this._input?.selectText()};t(),i().then(t)},this._onKeyDown=t=>{t.key===s.discard&&this._discard()},this._onInputKeyDown=t=>{switch(t.key){case s.commit:return this._commit({type:"commit-and-exit",allowLockingCurrentValue:!0});case s.next:return t.preventDefault(),t.stopPropagation(),this._commit({type:t.shiftKey?"commit-and-previous":"commit-and-next",allowLockingCurrentValue:!1})}},this._onInput=t=>{this.field.inputValue=t.target.value},this._onLockClick=()=>{const{field:t}=this;t.locked?t.unlock():this._lock()}}initialize(){this.addHandles(e((()=>this._rawDisplayValue),(()=>{const{committed:t,inputValue:e}=this.field;t||e||this._input!==document.activeElement||this._selectText()})))}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js")})}render(){const{mode:t,field:e}=this,i="input"===t,{locked:n}=e;return r("div",{class:this.classes({[p.base]:!0,[p.inputMode]:"input"===t,[p.locked]:n})},r("div",{class:p.title,key:"title"},r("div",{class:p.titleContent,key:"title-content"},this._title,n&&!i?r("calcite-icon",{icon:"lock",key:"icon",scale:"s"}):null)),r("div",{class:p.value,key:"value"},i?this._renderInputModeValue():this._renderFeedbackModeValue()))}get _initialValue(){const{field:t}=this;return null!=t.actual?t.toInputUnits(t.actual,this.context).value:null}get _formattedValue(){const{context:t,field:e}=this,{actual:i,committed:n,format:o}=e;return null!=n?o(n,t):null!=i?o(i,t):
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import{watch as e}from"../../../../core/reactiveUtils.js";import{waitAnimationFrame as i}from"../../../../core/scheduling.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{tooltipKeys as s}from"../../keybindings.js";import{base as l}from"../css.js";import a from"../../../../widgets/Widget.js";import{loadCalciteComponents as c}from"../../../../widgets/support/componentsUtils.js";import"../../../../widgets/support/widgetUtils.js";import{tsx as r}from"../../../../widgets/support/jsxFactory.js";const u=`${l}-editable-field`,p={base:u,inputMode:`${u}--input`,locked:`${u}--locked`,title:`${u}__title`,titleContent:`${u}__title__content`,value:`${u}__value`,valueContent:`${u}__value__content`,valueContentReadOnly:`${u}__value__content--read-only`,input:`${u}__input`,inputSuffix:`${u}__input-suffix`,button:`${u}__button`};let d=class extends a{constructor(){super(...arguments),this._input=null,this._selectText=()=>{const t=()=>{this._input===document.activeElement&&this._input?.selectText()};t(),i().then(t)},this._onKeyDown=t=>{t.key===s.discard&&this._discard()},this._onInputKeyDown=t=>{switch(t.key){case s.commit:return this._commit({type:"commit-and-exit",allowLockingCurrentValue:!0});case s.next:return t.preventDefault(),t.stopPropagation(),this._commit({type:t.shiftKey?"commit-and-previous":"commit-and-next",allowLockingCurrentValue:!1})}},this._onInput=t=>{this.field.inputValue=t.target.value},this._onLockClick=()=>{const{field:t}=this;t.locked?t.unlock():this._lock()}}initialize(){this.addHandles(e((()=>this._rawDisplayValue),(()=>{const{committed:t,inputValue:e}=this.field;t||e||this._input!==document.activeElement||this._selectText()})))}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js")})}render(){const{mode:t,field:e}=this,i="input"===t,{locked:n}=e;return r("div",{class:this.classes({[p.base]:!0,[p.inputMode]:"input"===t,[p.locked]:n})},r("div",{class:p.title,key:"title"},r("div",{class:p.titleContent,key:"title-content"},this._title,n&&!i?r("calcite-icon",{icon:"lock",key:"icon",scale:"s"}):null)),r("div",{class:p.value,key:"value"},i?this._renderInputModeValue():this._renderFeedbackModeValue()))}get _initialValue(){const{field:t}=this;return null!=t.actual?t.toInputUnits(t.actual,this.context).value:null}get _formattedValue(){const{context:t,field:e}=this,{actual:i,committed:n,format:o}=e;return null!=n?o(n,t):null!=i?o(i,t):h}get _rawDisplayValue(){const{field:t}=this,{inputValue:e,committed:i}=t;return null!=e?e:m(null!=i?t.toInputUnits(i,this.context).value:this._initialValue)}get _suffix(){const{suffix:t}=this.field;return"string"==typeof t?t:t(this.context)}get _title(){const{title:t}=this.field;return"string"==typeof t?t:t(this.context)}_renderFeedbackModeValue(){return r("span",{key:"value-feedback"},this._formattedValue)}_renderInputModeValue(){return this.field.readOnly?this._renderValueReadOnly():this._renderValueWritable()}_renderValueReadOnly(){return r("span",{class:p.valueContentReadOnly,key:"value-readonly"},this._formattedValue)}_renderValueWritable(){const{locked:t,name:e}=this.field,i=this.context?.messages.sketch??{},n=t?i.unlockConstraint:i.lockConstraint;return r("div",{class:p.valueContent,key:"value-writable",onkeydown:this._onKeyDown},r("calcite-input",{afterCreate:t=>{this._input=t},class:p.input,"data-field-name":e,onfocus:this._selectText,onkeydown:this._onInputKeyDown,scale:"s",type:"text",value:this._rawDisplayValue,onCalciteInputInput:this._onInput}),r("div",{class:p.inputSuffix,key:"suffix"},this._suffix),r("calcite-action",{alignment:"center",appearance:"transparent",class:p.button,compact:!0,icon:t?"lock":"unlock",label:n,onclick:this._onLockClick,scale:"s",tabIndex:-1,text:"",title:n}))}_commit({type:t,allowLockingCurrentValue:e}){const{_input:i,field:n}=this;if(!i)return;const{locked:o,inputValue:s}=n;o&&""===s?n.unlock():(e&&!o||null!=s)&&this._lock(),this.context.onCommit(i,t)}_discard(){this._input&&(this.field.inputValue=null,this.context.onDiscard(this._input))}_lock(){const{field:t}=this,e=_(t.inputValue),i=null!=e?t.createQuantity(e,this.context):null;t.lock(i)}};function _(t){if(null==t)return null;const e=parseFloat(t);return isNaN(e)||!isFinite(e)?null:e}function m(t){return null!=t?t.toFixed(2):h}t([n()],d.prototype,"field",void 0),t([n()],d.prototype,"context",void 0),t([n()],d.prototype,"mode",void 0),t([n()],d.prototype,"_initialValue",null),t([n()],d.prototype,"_formattedValue",null),t([n()],d.prototype,"_input",void 0),t([n()],d.prototype,"_rawDisplayValue",null),t([n()],d.prototype,"_suffix",null),t([n()],d.prototype,"_title",null),d=t([o("esri.views.interactive.tooltip.components.TooltipEditableField")],d);const h="—";export{d as TooltipEditableField};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{BlendFactor as t,BlendOperation as e,Face as i,CullMode as s,CompareFunction as r,StencilOperation as l}from"./enums.js";class
|
|
5
|
+
import{BlendFactor as t,BlendOperation as e,Face as i,CullMode as s,CompareFunction as r,StencilOperation as l,SpecialDrawBuffers as n}from"./enums.js";class h{constructor(){this.blend=!1,this.blendColor={r:0,g:0,b:0,a:0},this.blendFunction={srcRGB:t.ONE,dstRGB:t.ZERO,srcAlpha:t.ONE,dstAlpha:t.ZERO},this.blendEquation={mode:e.ADD,modeAlpha:e.ADD},this.colorMask={r:!0,g:!0,b:!0,a:!0},this.faceCulling=!1,this.cullFace=i.BACK,this.frontFace=s.CCW,this.scissorTest=!1,this.scissorRect={x:0,y:0,width:0,height:0},this.depthTest=!1,this.depthFunction=r.LESS,this.clearDepth=1,this.depthWrite=!0,this.depthRange={zNear:0,zFar:1},this.viewport=null,this.stencilTest=!1,this.polygonOffsetFill=!1,this.polygonOffset=[0,0],this.stencilFunction={face:i.FRONT_AND_BACK,func:r.ALWAYS,ref:0,mask:1},this.clearStencil=0,this.stencilWriteMask=1,this.stencilOperation={face:i.FRONT_AND_BACK,fail:l.KEEP,zFail:l.KEEP,zPass:l.KEEP},this.clearColor={r:0,g:0,b:0,a:0},this.program=null,this.vertexBuffer=null,this.indexBuffer=null,this.uniformBuffer=null,this.pixelPackBuffer=null,this.pixelUnpackBuffer=null,this.copyReadBuffer=null,this.copyWriteBuffer=null,this.transformFeedbackBuffer=null,this.uniformBufferBindingPoints=new Array,this.transformBufferBindingPoints=new Array,this.readFramebuffer=null,this.drawFramebuffer=null,this.drawBuffers={defaultFramebuffer:[n.BACK],fbos:new WeakMap},this.renderbuffer=null,this.activeTexture=0,this.textureUnitMap=new Array,this.vertexArrayObject=null}}export{h as ContextState};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as t}from"../../core/maybe.js";import{after as e}from"../../core/promiseUtils.js";import{Milliseconds as s}from"../../core/time.js";import{webglDebugEnabled as i,checkWebGLError as a}from"./checkWebGLError.js";import{ContextState as r}from"./ContextState.js";import{SpecialDrawBuffers as n,ColorAttachment as l,BufferType as h,Face as f,baseTextureUnit as o,ClearBufferBit as u,FramebufferTarget as c,TextureSamplingMode as _,SyncCondition as d,ResourceType as b,ClientWaitSyncStatus as F,BlendFactor as g,BlendOperation as B,CullMode as p,CompareFunction as E,StencilOperation as m,TextureType as R,PrimitiveType as T}from"./enums.js";import{InstanceCounter as A}from"./InstanceCounter.js";import{Parameters as C}from"./Parameters.js";import{ProgramCache as O}from"./ProgramCache.js";import{StateTracker as x}from"./renderState.js";import{Texture as U}from"./Texture.js";import{getErrorString as k}from"./Util.js";import{WebGLDriverTest as S}from"./WebGLDriverTest.js";import{Capabilities as w}from"./capabilities/Capabilities.js";let y=class{constructor(t,e){this.gl=t,this.instanceCounter=new A,this.programCache=new O(this),this._transformFeedbackRequestInfo=null,this._state=new r,this._numOfDrawCalls=0,this._numOfTriangles=0,this._loadExtensions(),this.configure(e)}configure(e){this._capabilities=new w(this.gl,e),this._parameters=new C(this.gl,this._capabilities,e),U.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new r,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new x({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)},setDrawBuffers:t=>{if(t)this.setDrawBuffers(t.buffers);else{const{drawFramebuffer:t}=this._state;null===t?this.setDrawBuffers([n.BACK]):0===t.colorAttachments.length?this.setDrawBuffers([n.NONE]):this.setDrawBuffers([l.COLOR_ATTACHMENT0])}}}),this.enforceState(),t(this._driverTest),this._driverTest=new S(this)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER),this._state.textureUnitMap.length=0,i()&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}setPipelineState(t){this._stateTracker.setPipeline(t)}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s)this._state.textureUnitMap[t[s]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null),this._state.vertexArrayObject=null,this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=f.FRONT_AND_BACK,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){this._state.stencilOperation.face===f.FRONT_AND_BACK&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=f.FRONT_AND_BACK,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(o+t),this._state.activeTexture=t),s}setDrawBuffers(t){if(this._state.drawBuffers?.length!==t.length||!this._state.drawBuffers.every(((e,s)=>e===t[s])))if(t.length>this.parameters.maxDrawBuffers)console.error("Setting more active draw buffers than GL.MAX_DRAW_BUFFERS allows.");else{if(null===this._state.drawFramebuffer){if(t.length>1)return void console.error("The default framebuffer can only have one active draw buffer.");if(t[0]!==n.BACK&&t[0]!==n.NONE)return void console.error("The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers.")}null!==this._state.drawFramebuffer&&t.includes(n.BACK)?console.error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTi or GL.NONE as draw buffers."):(this.gl.drawBuffers(t),this._state.drawBuffers=t,this._stateTracker.invalidateDrawBuffers())}}clear(t,e=255){if(t){if(t&u.COLOR_BUFFER_BIT){const t=this._state.drawFramebuffer?.colorAttachments;t&&this.setDrawBuffers(t),this.setColorMask(!0,!0,!0,!0)}t&u.DEPTH_BUFFER_BIT&&this.setDepthWriteEnabled(!0),t&u.STENCIL_BUFFER_BIT&&this.setStencilWriteMask(e),this.gl.clear(t)}}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=u.COLOR_BUFFER_BIT}e&&(i|=u.DEPTH_BUFFER_BIT),!1===s?s=0:(!0===s&&(s=255),i|=u.STENCIL_BUFFER_BIT),i&&this.clear(i,s)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(i()){this._numOfDrawCalls++,this._numOfTriangles+=D(t,s);const e=this._state.textureUnitMap;for(let t=0;t<e.length;t++){const s=e[t];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${t}`)}}this.gl.drawArrays(t,e,s),a(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),a(this.gl)}drawElements(t,e,s,a){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,e)),this.gl.drawElements(t,e,s,a),i()){const i=k(this);if(i){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.vertexBuffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:a},o=n?.size??0,u=a+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";console.error(`drawElements: ${i}${c}`,{args:f,vao:h})}}}logInfo(){i()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){i()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(t,e,s,i)}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){this._state.program!==t&&(this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null))}bindTexture(t,e,s=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const i=this._state.textureUnitMap[e];return null==t?.glName?(null!=i&&(this.setActiveTexture(e,s),this.gl.bindTexture(i.descriptor.target,null)),this._state.textureUnitMap[e]=null,i):s||i!==t?(this.setActiveTexture(e,s),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,i):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),i)}unbindTexture(t){if(null!=t)for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(this._stateTracker.invalidateDrawBuffers(),null==t)return this.gl.bindFramebuffer(c.FRAMEBUFFER,null),void(this._state.readFramebuffer=this._state.drawFramebuffer=null);t.initializeAndBind(c.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,s=!1){const i=e===c.READ_FRAMEBUFFER,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._stateTracker.invalidateDrawBuffers(),this._state.drawFramebuffer=t??null))}blitFramebuffer(t,e,s=0,i=0,a=t.width,r=t.height,n=0,l=0,h=e.width,f=e.height,o=u.COLOR_BUFFER_BIT,d=_.NEAREST){this.bindFramebufferSeparate(t,c.READ_FRAMEBUFFER),this.bindFramebufferSeparate(e,c.DRAW_FRAMEBUFFER),this.gl.blitFramebuffer(s,i,a,r,n,l,h,f,o,d)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,t,e,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,t,e,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,t,e,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,t,e,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,t,e,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,t,e,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,t,e,this._state.copyWriteBuffer);break;case h.TRANSFORM_FEEDBACK_BUFFER:this._state.transformFeedbackBuffer=N(this.gl,t,e,this._state.transformFeedbackBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const s=t===h.UNIFORM_BUFFER?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment==0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):console.error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,a){null!=e?(i()&&(a??e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==a?this.bindBufferRange(h.UNIFORM_BUFFER,t,e.buffer,s,a):this.bindBufferBase(h.UNIFORM_BUFFER,t,e.buffer)):this.bindBufferBase(h.UNIFORM_BUFFER,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(h.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,null,t,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,null,t,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,null,t,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,null,t,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,null,t,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,null,t,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){null!=t?this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t):this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=s(10)){const{gl:i}=this,a=i.fenceSync(d.SYNC_GPU_COMMANDS_COMPLETE,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(b.Sync,a),i.flush();do{await e(t),r=i.clientWaitSync(a,0,0)}while(r===F.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(b.Sync,a),i.deleteSync(a),r===F.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=c.FRAMEBUFFER){return t===c.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER);for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(g.ONE,g.ZERO),this.setBlendEquation(B.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(f.BACK),this.setFrontFace(p.CCW),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(E.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(E.ALWAYS,0,0),this.setStencilOp(m.KEEP,m.KEEP,m.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setDrawBuffers([n.BACK]),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(h.ARRAY_BUFFER,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(h.UNIFORM_BUFFER,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(h.UNIFORM_BUFFER,s,i.glName):t.bindBufferRange(h.UNIFORM_BUFFER,s,i.glName,a,r):t.bindBufferBase(h.UNIFORM_BUFFER,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(h.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(h.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(h.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(h.COPY_WRITE_BUFFER,null),t.bindFramebuffer(c.READ_FRAMEBUFFER,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(c.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),t.readBuffer(l.COLOR_ATTACHMENT0)),t.bindFramebuffer(c.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null),this._state.drawBuffers&&t.drawBuffers(this._state.drawBuffers),this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?.glName??null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(o+s),t.bindTexture(R.TEXTURE_2D,null),t.bindTexture(R.TEXTURE_CUBE_MAP,null),t.bindTexture(R.TEXTURE_3D,null),t.bindTexture(R.TEXTURE_2D_ARRAY,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(o+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}_loadExtensions(){this.gl.getExtension("KHR_parallel_shader_compile")}};function N(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function D(t,e){switch(t){case T.POINTS:return 2*e;case T.TRIANGLES:return e/3;case T.TRIANGLE_STRIP:case T.TRIANGLE_FAN:return e-2;default:return 0}}export{y as RenderingContext};
|
|
5
|
+
import{disposeMaybe as t}from"../../core/maybe.js";import{after as e}from"../../core/promiseUtils.js";import{Milliseconds as s}from"../../core/time.js";import{webglDebugEnabled as i,checkWebGLError as a}from"./checkWebGLError.js";import{ContextState as r}from"./ContextState.js";import{SpecialDrawBuffers as n,ColorAttachment as l,BufferType as h,Face as f,baseTextureUnit as o,ClearBufferBit as u,FramebufferTarget as c,TextureSamplingMode as _,SyncCondition as d,ResourceType as b,ClientWaitSyncStatus as F,BlendFactor as g,BlendOperation as B,CullMode as E,CompareFunction as p,StencilOperation as m,TextureType as R,PrimitiveType as T}from"./enums.js";import{InstanceCounter as A}from"./InstanceCounter.js";import{Parameters as C}from"./Parameters.js";import{ProgramCache as O}from"./ProgramCache.js";import{StateTracker as x}from"./renderState.js";import{Texture as U}from"./Texture.js";import{getErrorString as k}from"./Util.js";import{WebGLDriverTest as w}from"./WebGLDriverTest.js";import{Capabilities as S}from"./capabilities/Capabilities.js";let y=class{constructor(t,e){this.gl=t,this.instanceCounter=new A,this.programCache=new O(this),this._transformFeedbackRequestInfo=null,this._state=new r,this._numOfDrawCalls=0,this._numOfTriangles=0,this._loadExtensions(),this.configure(e)}configure(e){this._capabilities=new S(this.gl,e),this._parameters=new C(this.gl,this._capabilities,e),U.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new r,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new x({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)},setDrawBuffers:t=>{if(t)this.setDrawBuffers(t.buffers);else{const{drawFramebuffer:t}=this._state;null===t?this.setDrawBuffers([n.BACK]):0===t.colorAttachments.length?this.setDrawBuffers([n.NONE]):this.setDrawBuffers([l.COLOR_ATTACHMENT0])}}}),this.enforceState(),t(this._driverTest),this._driverTest=new w(this)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER),this._state.textureUnitMap.length=0,i()&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}setPipelineState(t){this._stateTracker.setPipeline(t)}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s)this._state.textureUnitMap[t[s]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null),this._state.vertexArrayObject=null,this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=f.FRONT_AND_BACK,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){this._state.stencilOperation.face===f.FRONT_AND_BACK&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=f.FRONT_AND_BACK,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(o+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e);if(s?.length!==t.length||!s.every(((e,s)=>e===t[s])))if(t.length>this.parameters.maxDrawBuffers)console.error("Setting more active draw buffers than GL.MAX_DRAW_BUFFERS allows.");else{if(null===e){if(t.length>1)return void console.error("The default framebuffer can only have one active draw buffer.");if(t[0]!==n.BACK&&t[0]!==n.NONE)return void console.error("The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers.")}null!==e&&t.includes(n.BACK)?console.error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTi or GL.NONE as draw buffers."):(this.gl.drawBuffers(t),null===e?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),this._stateTracker.invalidateDrawBuffers())}}clear(t,e=255){if(t){if(t&u.COLOR_BUFFER_BIT){const t=this._state.drawFramebuffer?.colorAttachments;t&&this.setDrawBuffers(t),this.setColorMask(!0,!0,!0,!0)}t&u.DEPTH_BUFFER_BIT&&this.setDepthWriteEnabled(!0),t&u.STENCIL_BUFFER_BIT&&this.setStencilWriteMask(e),this.gl.clear(t)}}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=u.COLOR_BUFFER_BIT}e&&(i|=u.DEPTH_BUFFER_BIT),!1===s?s=0:(!0===s&&(s=255),i|=u.STENCIL_BUFFER_BIT),i&&this.clear(i,s)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(i()){this._numOfDrawCalls++,this._numOfTriangles+=D(t,s);const e=this._state.textureUnitMap;for(let t=0;t<e.length;t++){const s=e[t];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${t}`)}}this.gl.drawArrays(t,e,s),a(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),a(this.gl)}drawElements(t,e,s,a){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,e)),this.gl.drawElements(t,e,s,a),i()){const i=k(this);if(i){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.vertexBuffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:a},o=n?.size??0,u=a+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";console.error(`drawElements: ${i}${c}`,{args:f,vao:h})}}}logInfo(){i()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){i()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(t,e,s,i)}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){this._state.program!==t&&(this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null))}bindTexture(t,e,s=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const i=this._state.textureUnitMap[e];return null==t?.glName?(null!=i&&(this.setActiveTexture(e,s),this.gl.bindTexture(i.descriptor.target,null)),this._state.textureUnitMap[e]=null,i):s||i!==t?(this.setActiveTexture(e,s),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,i):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),i)}unbindTexture(t){if(null!=t)for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(null==t)return this.gl.bindFramebuffer(c.FRAMEBUFFER,null),void(this._state.readFramebuffer=this._state.drawFramebuffer=null);t.initializeAndBind(c.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,s=!1){const i=e===c.READ_FRAMEBUFFER,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:this._state.drawFramebuffer=t??null)}blitFramebuffer(t,e,s=0,i=0,a=t.width,r=t.height,n=0,l=0,h=e.width,f=e.height,o=u.COLOR_BUFFER_BIT,d=_.NEAREST){this.bindFramebufferSeparate(t,c.READ_FRAMEBUFFER),this.bindFramebufferSeparate(e,c.DRAW_FRAMEBUFFER),this.gl.blitFramebuffer(s,i,a,r,n,l,h,f,o,d)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,t,e,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,t,e,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,t,e,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,t,e,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,t,e,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,t,e,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,t,e,this._state.copyWriteBuffer);break;case h.TRANSFORM_FEEDBACK_BUFFER:this._state.transformFeedbackBuffer=N(this.gl,t,e,this._state.transformFeedbackBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const s=t===h.UNIFORM_BUFFER?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment==0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):console.error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,a){null!=e?(i()&&(a??e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==a?this.bindBufferRange(h.UNIFORM_BUFFER,t,e.buffer,s,a):this.bindBufferBase(h.UNIFORM_BUFFER,t,e.buffer)):this.bindBufferBase(h.UNIFORM_BUFFER,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(h.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,null,t,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,null,t,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,null,t,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,null,t,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,null,t,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,null,t,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){null!=t?this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t):this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=s(10)){const{gl:i}=this,a=i.fenceSync(d.SYNC_GPU_COMMANDS_COMPLETE,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(b.Sync,a),i.flush();do{await e(t),r=i.clientWaitSync(a,0,0)}while(r===F.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(b.Sync,a),i.deleteSync(a),r===F.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=c.FRAMEBUFFER){return t===c.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER);for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(g.ONE,g.ZERO),this.setBlendEquation(B.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(f.BACK),this.setFrontFace(E.CCW),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(p.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(p.ALWAYS,0,0),this.setStencilOp(m.KEEP,m.KEEP,m.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setDrawBuffers([n.BACK]),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(h.ARRAY_BUFFER,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(h.UNIFORM_BUFFER,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(h.UNIFORM_BUFFER,s,i.glName):t.bindBufferRange(h.UNIFORM_BUFFER,s,i.glName,a,r):t.bindBufferBase(h.UNIFORM_BUFFER,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(h.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(h.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(h.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(h.COPY_WRITE_BUFFER,null),t.bindFramebuffer(c.READ_FRAMEBUFFER,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(c.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),t.readBuffer(l.COLOR_ATTACHMENT0)),t.bindFramebuffer(c.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[n.BACK])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[l.COLOR_ATTACHMENT0])}if(this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?.glName??null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(o+s),t.bindTexture(R.TEXTURE_2D,null),t.bindTexture(R.TEXTURE_CUBE_MAP,null),t.bindTexture(R.TEXTURE_3D,null),t.bindTexture(R.TEXTURE_2D_ARRAY,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(o+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}_loadExtensions(){this.gl.getExtension("KHR_parallel_shader_compile")}};function N(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function D(t,e){switch(t){case T.POINTS:return 2*e;case T.TRIANGLES:return e/3;case T.TRIANGLE_STRIP:case T.TRIANGLE_FAN:return e-2;default:return 0}}export{y as RenderingContext};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r,equals as i}from"../../core/arrayUtils.js";import o from"../../core/Collection.js";import{deprecatedProperty as s}from"../../core/deprecate.js";import a from"../../core/Error.js";import n from"../../core/Evented.js";import{isSerializable as l}from"../../core/JSONSupport.js";import{clone as c,equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as g}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as m,waitTick as p}from"../../core/promiseUtils.js";import{watch as y,initial as f,syncAndInitial as v,when as _}from"../../core/reactiveUtils.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{geographicToWebMercator as P}from"../../geometry/support/webMercatorUtils.js";import C from"../../layers/GraphicsLayer.js";import{searchImages as F}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as I}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as S,computePolygonForInspection as V,resizePolygon as O,checkIfPolygonContainsSelectedPoint as A}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as B,transformPoints as j}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as G}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as M,convertPixelToHeadingPitch as R,convertHeadingPitchToSphereVertex as x}from"../../layers/orientedImagery/transformations/utils.js";import L from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as k}from"../../views/input/InputManager.js";import D from"../PanoramicViewer.js";import{sectorsInOrder as E,sectorsRadii as H}from"./constants.js";import{activePolygonSymbol as U,crossSymbol as N,crossSymbol3D as T,diamondSymbol as z,diamondSymbol3D as W,polygonSymbol as J,activeSourcePointSymbol as q,sourcePointSymbol as $}from"./symbols.js";import{isNoAttachmentError as Q,isTifOrMrf as Z,isSceneView as K,isGraphic as X,calculateSegment as Y,calculateDirection as ee}from"./utils.js";import te from"./components/ImageViewer.js";import re from"../../geometry/Point.js";import ie from"../../geometry/Polygon.js";import oe from"../../geometry/SpatialReference.js";const se={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ae=new Set(["JPG","JPEG"]),ne=e=>"FA"===e;let le=class extends n.EventedAccessor{constructor(e){super(e),this.additionalFeatures=new o,this.determineWorkflowForFeature=async()=>{const{currentBestFeature:e,selectedPoint:t}=this;if(e&&t){this._initialCurrentCoverageUpdate=!0,this._updatePointsAndPolygons(),this._fetchFeaturesController??=new AbortController;const{signal:e}=this._fetchFeaturesController;try{await this._loadImage({signal:e})}catch(r){m(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}this._fetchFeaturesController=null}},this.drawFootprint=()=>{this._initialCurrentCoveragePolygon&&this.updateCurrentCoveragePolygon(this._initialCurrentCoveragePolygon)},this.layer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=new o,this.coveragePolygons=new o,this.currentCoverageVisible=!0,this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.pointSources=new o,this.previousFeatureAngle=0,this.currentBestFeature=null,this.bestFeatureAngle=0,this.selectedPoint=null,this.features=new o,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.updateFootprint=async e=>{if("image-loaded"!==this.state)return;const t=new AbortController,{signal:r}=t;if(this._updateCoverageController=t,"default"===this.mode)try{const t=await G(e,{feature:this.currentBestFeature,imageProperties:this._imageViewer.viewModel.image.serviceRasterInfo,options:{signal:r},footprintExtent:this._footprintExtent});await this._updateCurrentFootprint(t,r)}catch(i){m(i)||u.getLogger(this).error("#updateFootprint()",i)}},this._additionalCoveragePolygons=new o,this._additionalFeatureGraphics=new o,this._currentCoveragePolygon=null,this._fetchFeaturesController=null,this._imageViewer=new te,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0}),this._panoramicViewer=new D,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this._footprintExtent=null,this._suitabilities=null,this._transformController=new AbortController,this._updateCoverageController=null,this.loadImageFromSource=async(e,t)=>{const{mode:r,imageRotation:i,options:o}=t,s="string"==typeof e,a=s?e.split(".").pop():e.datasetFormat,n=s?e:e.url,l=ae.has(a.toUpperCase());switch(r){case"default":this._imageViewer.imageSource=e,this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(o);break;case"panoramic":if(l){const{pitch:e,yaw:r,cameraLocation:i}=t;this._panoramicViewer.imageSource=n;const s=await M(i,this.selectedPoint)-(r??0);this._panoramicViewer.pitch=e??0,this._panoramicViewer.yaw=s,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:a})}},this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this._getImageSourceFromAttachment=async(e,t,r)=>{const i=new L({objectIds:[t]}),o=await e.queryAttachments(i,r),s=o[`${t}`]?.[0],n=s?.url;if(!n)throw new a("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:n}},this._loadImage=async e=>{const{currentBestFeature:t,layer:r,mode:i}=this;if(this.clearGraphics(),!r||!t||"none"===i)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:g,location:d}=o,p=(l??0)+(a??0),y=d.spatialReference.isWGS84&&4!==g?.type?P(d):new re(d);let f=s;if(ne(s))try{f=await this._getImageSourceFromAttachment(r,h,e)}catch(v){if(m(v))return;return Q(v)?(u.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${r.objectIdField}: ${h}`)):(u.getLogger(this).error(v,{[r.objectIdField]:h,layer:r}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${r.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:c,yaw:n,mode:i,cameraLocation:y}),this.transformAndPlotSelectedLocation(e)}catch(v){m(v)||this.loadImageError(v)}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._updateCurrentFootprint=async(e,i)=>{await p(i);const o=e.filter(r);if(o.length){const e=[o.map((({x:e,y:t})=>[e,t,1]))];e[0].push(e[0][0]);const r=new ie({hasZ:!0,rings:e,spatialReference:o[0].spatialReference});this.updateCurrentCoveragePolygon(new t({attributes:{imageID:this.currentBestFeature?.attributes.objectId},geometry:r,symbol:U,visible:this.currentCoverageVisible}))}},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.loadBestImage(e.mapPoint))},this.plotSelectedPointOnImage=async(e,r)=>{if(await p(r),!e)return;const i=new re({...l(e)?e.toJSON():e,spatialReference:oe.WebMercator});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,this._crossSymbol=new t({geometry:i,symbol:N}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,o]=r,{heading:s,pitch:a}=R(e,i,o),n=x(s,a);this._crossSymbol=new t({geometry:new re(n,oe.WebMercator),symbol:T}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.updateFootprintPanorama=async()=>{const{yaw:e,pitch:r,fov:i,imageSize:o,imageRenderer:{size:s}}=this._panoramicViewer,a=this.currentBestFeature?.clone();if(!o||!a)return;const n=i/(s[0]/s[1]),{attributes:l}=a;l.orientedImageryType=null,l.cameraHeading=(e+l.cameraHeading)%360,l.cameraPitch=r,l.horizontalFieldOfView=i,l.verticalFieldOfView=n,l.cameraRoll=0;const{polygon:c}=S(a);this.updateCurrentCoveragePolygon(new t({attributes:{imageID:l.objectId},geometry:c,symbol:U,visible:this.currentCoverageVisible}))},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.updateCoverage=this.updateCoverage.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([y((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),f),y((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),f),y((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{if(this.removeHandles(se.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,k.WIDGET),se.click),this.removeHandles(se.imageClick);const{mapImageConversionToolState:t,mode:r}=this;if(t&&"none"!==r)switch(r){case"default":this._imageViewer.clickAction="pixel-location",this.addHandles(this._imageViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature;if(t){const r=(await G([e.toJSON()],{feature:t,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},options:{signal:this._transformController?.signal},footprintExtent:this._footprintExtent}))[0];r&&this.plotReferencePointOnGround(r)}})),se.imageClick);break;case"panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature,{imageSize:r}=this._panoramicViewer;if(t&&e&&r){const i=(await G([e],{feature:t,imageProperties:{width:r[0],height:r[1]},options:{signal:this._transformController?.signal},footprintExtent:this._footprintExtent}))[0];i&&this.plotReferencePointOnGround(i)}})),se.imageClick)}}),v),y((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),v),y((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),y((()=>this.mode),(e=>{switch(this.removeHandles(se.interactionHandles),e){case"default":this.addHandles(y((()=>this._imageViewer.imagePointsInView),(e=>{e&&this.updateCoverage()}),{...v,equals:(e,t)=>i(e,t,h)}),se.interactionHandles);break;case"panoramic":this.addHandles(_((()=>this._panoramicViewer.imageSize),(()=>{this._createFootprintHandles()})),se.interactionHandles)}}),v),y((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:r,mode:i,sharpness:o}=this;"default"===i&&(e.brightness=t,e.contrast=r,e.sharpness=o)}),v)])}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this._additionalCoveragePolygons.destroy(),this._additionalFeatureGraphics.destroy(),this._initialCurrentCoveragePolygon=d(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=d(this._currentCoveragePolygon),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._overlays&&this.view?.map.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return s(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:r}=e;return 360===t||r?"panoramic":"default"}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",e>10?10:e<-10?-10:e)}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",g(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return Z(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return s(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get referencePoint(){return this._referencePointOnGround?.geometry}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",g(e,0,1))}get sectorData(){const{_sectorData:e}=this;return e?E.map((t=>e[t])):null}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(this._loading)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new o(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:r,imageRotation:i}})=>{const o=e.trim();return Z(o)?{url:o,objectId:t,rotation:(r??0)+(i??0)}:null})).filter(r)):null}set view(e){this._set("view",e)}filterByFootprints(e,t){const r=[],i=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:c,frustum:h}=S(e);if(n=c,a.isInspection&&(n=V(a)),s&&(n=O(n,s)),A(n,t)){o.push(e);const t=n.toJSON(),s=h?.toJSON(),{cameraHeight:c,cameraHeading:u,location:g,objectId:d}=a,m=l(g)?g.toJSON():g;t.imageID=m.imageID=d,s&&(s.imageID=d),m.z=c,this.pointSources?.push(m),r.push(u>0?t:void 0),i.push(u>0?s:void 0)}})),{features:o,polygons:r,frustums:i}}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getCurrentBestFeaturePolygon(){return this._initialCurrentCoveragePolygon}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[E[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:r}=e;if(isNaN(r))return;const i=this._sectorData?.[t];i?.length&&this._updateCurrentBestFeature(i.at(r))}async loadBestImage(e){this._loading=!0,this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?P(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon=d(this._currentCoveragePolygon),this._overlays?.removeAll(),await this._fetchFeaturesWithController(e)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:z}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const r=l(e)?e.toJSON():e;r.x-=.5,r.y=.5-r.y,this._referencePointOnImage=new t({geometry:{type:"point",spatialReference:this._imageViewer.imageRenderer.spatialReference,...r},symbol:z}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,o]=r,{heading:s,pitch:a}=R(e,i,o),n=x(s,a);this._referencePointOnImage=new t({geometry:new re(n,oe.WebMercator),symbol:W}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const r=await F(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){m(r)||(this.setMessage("imageLoadError","error",r.message),u.getLogger(this).error("error occurred while finding best image",r))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this._additionalFeatureGraphics.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this._additionalCoveragePolygons.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=e),this._currentBestFeatureGraphic&&(this._currentBestFeatureGraphic.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:r}=e,i=this._initialCurrentCoveragePolygon?.geometry;if(!i?.contains(t))return;const o=await this.transformPoint(t,r);return o?(this.plotReferencePointOnImage(o),{x:o.x,y:o.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._updateFeatures(t),this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}_createFootprintHandles(){this.removeHandles(se.footprintHandles),this.addHandles(y((()=>[this._panoramicViewer.fov,this._panoramicViewer.yaw,this._panoramicViewer.pitch]),(()=>{this.updateFootprintPanorama()}),v),se.footprintHandles)}async _fetchFeatures(e,t){if(!this.view)return;const r=this.layer;if(r){const i={include:r},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,i);this._processHitTestResults(r,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:r}).finally((()=>{this._fetchFeaturesController=null}))}catch(i){this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:r,features:i}=this;if(!(e&&t&&r&&i))return void(this._sectorData=null);this._sectorData={};for(const l of E)this._sectorData[l]=new o;const s=e.map(((e,t)=>({...e,featureIndex:t})));s.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=s.map((({distance:e})=>e)),n=Math.max(...a);s.forEach((e=>{const{distance:t,angle:r,featureIndex:o}=e,s=t/n*H[2],a=Y(t,n),l=ee(r);if(!this._sectorData)return;const c=H[3]+s*Math.sin(r*Math.PI/180),h=H[3]+s*Math.cos(r*Math.PI/180);let u;const g=i.at(o),d=g===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=c-H[3],t=h-H[3],r=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(r)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),u=i}const p=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:c,y:h,direction:l});const y=this._sectorData[p];y.add({angle:r,featureIndex:o,x:c,y:h,objectID:g.attributes.objectId,sector:p,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t){const{selectedPoint:i}=this;if(!i)return;if(!e)return;const o=e;if(!o)return;const{features:s}=o;if(!s.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:a,polygons:n,frustums:l}=this.filterByFootprints(s,i),c=a;this.coveragePolygons.addMany(n),this.coverageFrustums.addMany(l);const h=n.filter(r).reduce(((e,t)=>(e.push(...t.rings.flat()),e)),new Array),u=new ie({rings:h,spatialReference:n[0]?.spatialReference}).extent;if(!c.length)return void this.setMessage("noImageError","error");if(this._footprintExtent=u,c[0].attributes.elevationSource&&!i.z&&u){const e=await B([i],{feature:c[0],footprintExtent:u,options:t});if(e[0]){const t=e[0];i.elevation=t.z}c[0].elevationSample&&c.forEach((e=>{e.elevationSample=c[0].elevationSample}))}this._suitabilities=I({features:c,selectedPoint:i,camera:K(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const g=this._suitabilities.map((e=>e.feature));this.currentBestFeature=g[0],this._loading=!1}async _processHitTestResults(e,t,r){const{screenPoint:i,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a={layerInstanceOrURL:e,point:o?.mapPoint??this.view?.toMap(i),queryParams:{maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0},queryFeatures:null};await this.searchBestImage(a,r)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.currentBestFeature=e[0],e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll()}_updatePointsAndPolygons(){const{coveragePolygons:e,pointSources:r,currentBestFeature:i,currentCoverageVisible:o,isAdditionalCoverageVisible:s,isAdditionalPointSourcesVisible:a}=this;if(e&&r&&i){this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const r of e)r?.imageID===i.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:U,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:J,visible:s}));for(const e of r)e.imageID===i.attributes.objectId?this._currentBestFeatureGraphic=new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:q,visible:o}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:$,visible:a}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let r;if(t)r=-90;else{const t=e.x-H[3],i=e.y-H[3],o=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(o)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),r=s}r===this.bestFeatureAngle?this.previousFeatureAngle=r:this.bestFeatureAngle=r,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,r,i){this._loading=!1,this.displayMessage={key:e,type:t,data:r,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:r,state:i}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!r||!t||"image-loaded"!==i)return;let o;try{o=await this.transformPoint(r,e),await this.plotSelectedPointOnImage(o,e)}catch(s){m(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:r,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const r=this.currentBestFeature,i=await j([e],{feature:r,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t});if(!i.length)return;return i[0]}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&this._currentCoveragePolygon.destroy(),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e),this.view){const e=this.selectedPoint?new t({geometry:this.selectedPoint.clone(),symbol:N,attributes:{imageID:this.currentBestFeature?.attributes.objectId}}):null;this._overlays?.graphics.addMany([...this._additionalCoveragePolygons,...this._additionalFeatureGraphics,this._currentCoveragePolygon,this._currentBestFeatureGraphic,e].filter(X))}}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}}async updateCoverage(){if("default"===this.mode){this._cancelCurrentCoverageUpdate();const{imagePointsInView:e,state:t}=this._imageViewer,r=c(e);if(!r||"image-loaded"!==t)return;this.updateFootprint(r)}}};e([w()],le.prototype,"activeLayer",null),e([w()],le.prototype,"additionalFeatures",void 0),e([w({json:{write:!1}})],le.prototype,"determineWorkflowForFeature",void 0),e([w()],le.prototype,"drawFootprint",void 0),e([w({readOnly:!0,value:"none"})],le.prototype,"mode",null),e([w()],le.prototype,"imagePointsInView",null),e([w()],le.prototype,"layer",void 0),e([w()],le.prototype,"shouldShowSelectedImage",void 0),e([w({type:Number})],le.prototype,"brightness",null),e([w({type:Number})],le.prototype,"contrast",null),e([w()],le.prototype,"coverageFrustums",void 0),e([w()],le.prototype,"coveragePolygons",void 0),e([w()],le.prototype,"currentCoverageVisible",void 0),e([w()],le.prototype,"disabled",void 0),e([w()],le.prototype,"displayMessage",void 0),e([w()],le.prototype,"pointSources",void 0),e([w()],le.prototype,"previousFeatureAngle",void 0),e([w()],le.prototype,"currentBestFeature",void 0),e([w()],le.prototype,"bestFeatureAngle",void 0),e([w()],le.prototype,"selectedPoint",void 0),e([w({readOnly:!0})],le.prototype,"featureCount",null),e([w()],le.prototype,"features",void 0),e([w({readOnly:!0})],le.prototype,"imageGalleryEnabled",null),e([w({readOnly:!0})],le.prototype,"imageLoaded",null),e([w()],le.prototype,"isAdditionalCoverageVisible",void 0),e([w()],le.prototype,"isAdditionalPointSourcesVisible",void 0),e([w({type:Number})],le.prototype,"localPort",void 0),e([w()],le.prototype,"mapImageConversionToolState",void 0),e([w()],le.prototype,"navigatorCurrentBestFeature",void 0),e([w()],le.prototype,"referencePoint",null),e([w({type:Number})],le.prototype,"sharpness",null),e([w({readOnly:!0})],le.prototype,"sectorData",null),e([w({readOnly:!0})],le.prototype,"state",null),e([w({readOnly:!0})],le.prototype,"thumbnails",null),e([w()],le.prototype,"updateFootprint",void 0),e([w({value:null})],le.prototype,"view",null),e([w()],le.prototype,"_additionalCoveragePolygons",void 0),e([w()],le.prototype,"_additionalFeatureGraphics",void 0),e([w()],le.prototype,"_currentCoveragePolygon",void 0),e([w()],le.prototype,"_fetchFeaturesController",void 0),e([w()],le.prototype,"_imageViewer",void 0),e([w()],le.prototype,"_initialCurrentCoveragePolygon",void 0),e([w()],le.prototype,"_initialCurrentCoverageUpdate",void 0),e([w()],le.prototype,"_loading",void 0),e([w()],le.prototype,"_overlays",void 0),e([w()],le.prototype,"_panoramicViewer",void 0),e([w()],le.prototype,"_referencePointOnGround",void 0),e([w()],le.prototype,"_referencePointOnImage",void 0),e([w()],le.prototype,"_currentBestFeatureGraphic",void 0),e([w()],le.prototype,"_sectorData",void 0),le=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],le);const ce=le;export{ce as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r,equals as i}from"../../core/arrayUtils.js";import o from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{isSerializable as l}from"../../core/JSONSupport.js";import{clone as c,equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as g}from"../../core/mathUtils.js";import{destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as d,waitTick as p}from"../../core/promiseUtils.js";import{watch as y,initial as f,syncAndInitial as v,when as _}from"../../core/reactiveUtils.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{geographicToWebMercator as P}from"../../geometry/support/webMercatorUtils.js";import C from"../../layers/GraphicsLayer.js";import{searchImages as F}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as I}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as S,computePolygonForInspection as V,resizePolygon as O,checkIfPolygonContainsSelectedPoint as A}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as B,transformPoints as j}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as G}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as M,convertPixelToHeadingPitch as R,convertHeadingPitchToSphereVertex as x}from"../../layers/orientedImagery/transformations/utils.js";import L from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as k}from"../../views/input/InputManager.js";import D from"../PanoramicViewer.js";import{sectorsInOrder as E,sectorsRadii as H}from"./constants.js";import{activePolygonSymbol as U,crossSymbol as N,crossSymbol3D as T,diamondSymbol as z,diamondSymbol3D as W,polygonSymbol as J,activeSourcePointSymbol as q,sourcePointSymbol as $}from"./symbols.js";import{getContentType as K,isNoAttachmentError as Q,isTifOrMrf as Z,isSceneView as X,isGraphic as Y,calculateSegment as ee,calculateDirection as te}from"./utils.js";import re from"./components/ImageViewer.js";import ie from"../../geometry/Point.js";import oe from"../../geometry/Polygon.js";import ae from"../../geometry/SpatialReference.js";const se={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ne=new Set(["JPG","JPEG"]),le=/\.(\w+)$/,ce=e=>"FA"===e;let he=class extends n.EventedAccessor{constructor(e){super(e),this.additionalFeatures=new o,this.determineWorkflowForFeature=async()=>{const{currentBestFeature:e,selectedPoint:t}=this;if(e&&t){this._initialCurrentCoverageUpdate=!0,this._updatePointsAndPolygons(),this._fetchFeaturesController??=new AbortController;const{signal:e}=this._fetchFeaturesController;try{await this._loadImage({signal:e})}catch(r){d(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}this._fetchFeaturesController=null}},this.drawFootprint=()=>{this._initialCurrentCoveragePolygon&&this.updateCurrentCoveragePolygon(this._initialCurrentCoveragePolygon)},this.layer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=new o,this.coveragePolygons=new o,this.currentCoverageVisible=!0,this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.pointSources=new o,this.previousFeatureAngle=0,this.currentBestFeature=null,this.bestFeatureAngle=0,this.selectedPoint=null,this.features=new o,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.updateFootprint=async e=>{if("image-loaded"!==this.state)return;const t=new AbortController,{signal:r}=t;if(this._updateCoverageController=t,"default"===this.mode)try{const t=await G(e,{feature:this.currentBestFeature,imageProperties:this._imageViewer.viewModel.image.serviceRasterInfo,options:{signal:r},footprintExtent:this._footprintExtent});await this._updateCurrentFootprint(t,r)}catch(i){d(i)||u.getLogger(this).error("#updateFootprint()",i)}},this._additionalCoveragePolygons=new o,this._additionalFeatureGraphics=new o,this._currentCoveragePolygon=null,this._fetchFeaturesController=null,this._imageViewer=new re,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0}),this._panoramicViewer=new D,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this._footprintExtent=null,this._suitabilities=null,this._transformController=new AbortController,this._updateCoverageController=null,this.loadImageFromSource=async(e,t)=>{const{mode:r,imageRotation:i,options:o}=t,a="string"==typeof e,s=a?e:e.url;let n=a?e.match(le)?.[1]??"":e.datasetFormat;if(!n){const e=await K(s,{...t.options});e&&(n=e.split("/")[1]),n="UNKNOWN FORMAT"}switch(r){case"default":this._imageViewer.imageSource=e,this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(o);break;case"panoramic":if(ne.has(n.toUpperCase())){const{pitch:e,yaw:r,cameraLocation:i}=t;this._panoramicViewer.imageSource=s;const a=await M(i,this.selectedPoint)-(r??0);this._panoramicViewer.pitch=e??0,this._panoramicViewer.yaw=a,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:n});break}},this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this._getImageSourceFromAttachment=async(e,t,r)=>{const i=new L({objectIds:[t]}),o=await e.queryAttachments(i,r),a=o[`${t}`]?.[0],n=a?.url;if(!n)throw new s("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:a.contentType.split("/")[1].toUpperCase(),url:n}},this._loadImage=async e=>{const{currentBestFeature:t,layer:r,mode:i}=this;if(this.clearGraphics(),!r||!t||"none"===i)return;const{attributes:o}=t,{imagePath:a,imageRotation:s,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:g,location:m}=o,p=(l??0)+(s??0),y=m.spatialReference.isWGS84&&4!==g?.type?P(m):new ie(m);let f=a;if(ce(a))try{f=await this._getImageSourceFromAttachment(r,h,e)}catch(v){if(d(v))return;return Q(v)?(u.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${r.objectIdField}: ${h}`)):(u.getLogger(this).error(v,{[r.objectIdField]:h,layer:r}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${r.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:c,yaw:n,mode:i,cameraLocation:y}),this.transformAndPlotSelectedLocation(e)}catch(v){d(v)||this.loadImageError(v)}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._updateCurrentFootprint=async(e,i)=>{await p(i);const o=e.filter(r);if(o.length){const e=[o.map((({x:e,y:t})=>[e,t,1]))];e[0].push(e[0][0]);const r=new oe({hasZ:!0,rings:e,spatialReference:o[0].spatialReference});this.updateCurrentCoveragePolygon(new t({attributes:{imageID:this.currentBestFeature?.attributes.objectId},geometry:r,symbol:U,visible:this.currentCoverageVisible}))}},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.loadBestImage(e.mapPoint))},this.plotSelectedPointOnImage=async(e,r)=>{if(await p(r),!e)return;const i=new ie({...l(e)?e.toJSON():e,spatialReference:ae.WebMercator});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,this._crossSymbol=new t({geometry:i,symbol:N}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,o]=r,{heading:a,pitch:s}=R(e,i,o),n=x(a,s);this._crossSymbol=new t({geometry:new ie(n,ae.WebMercator),symbol:T}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.updateFootprintPanorama=async()=>{const{yaw:e,pitch:r,fov:i,imageSize:o,imageRenderer:{size:a}}=this._panoramicViewer,s=this.currentBestFeature?.clone();if(!o||!s)return;const n=i/(a[0]/a[1]),{attributes:l}=s;l.orientedImageryType=null,l.cameraHeading=(e+l.cameraHeading)%360,l.cameraPitch=r,l.horizontalFieldOfView=i,l.verticalFieldOfView=n,l.cameraRoll=0;const{polygon:c}=S(s);this.updateCurrentCoveragePolygon(new t({attributes:{imageID:l.objectId},geometry:c,symbol:U,visible:this.currentCoverageVisible}))},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.updateCoverage=this.updateCoverage.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([y((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),f),y((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),f),y((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{if(this.removeHandles(se.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,k.WIDGET),se.click),this.removeHandles(se.imageClick);const{mapImageConversionToolState:t,mode:r}=this;if(t&&"none"!==r)switch(r){case"default":this._imageViewer.clickAction="pixel-location",this.addHandles(this._imageViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature;if(t){const r=(await G([e.toJSON()],{feature:t,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},options:{signal:this._transformController?.signal},footprintExtent:this._footprintExtent}))[0];r&&this.plotReferencePointOnGround(r)}})),se.imageClick);break;case"panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature,{imageSize:r}=this._panoramicViewer;if(t&&e&&r){const i=(await G([e],{feature:t,imageProperties:{width:r[0],height:r[1]},options:{signal:this._transformController?.signal},footprintExtent:this._footprintExtent}))[0];i&&this.plotReferencePointOnGround(i)}})),se.imageClick)}}),v),y((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),v),y((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),y((()=>this.mode),(e=>{switch(this.removeHandles(se.interactionHandles),e){case"default":this.addHandles(y((()=>this._imageViewer.imagePointsInView),(e=>{e&&this.updateCoverage()}),{...v,equals:(e,t)=>i(e,t,h)}),se.interactionHandles);break;case"panoramic":this.addHandles(_((()=>this._panoramicViewer.imageSize),(()=>{this._createFootprintHandles()})),se.interactionHandles)}}),v),y((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:r,mode:i,sharpness:o}=this;"default"===i&&(e.brightness=t,e.contrast=r,e.sharpness=o)}),v)])}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this._additionalCoveragePolygons.destroy(),this._additionalFeatureGraphics.destroy(),this._initialCurrentCoveragePolygon=m(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=m(this._currentCoveragePolygon),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:r}=e;return 360===t||r?"panoramic":"default"}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",e>10?10:e<-10?-10:e)}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",g(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return Z(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get referencePoint(){return this._referencePointOnGround?.geometry}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",g(e,0,1))}get sectorData(){const{_sectorData:e}=this;return e?E.map((t=>e[t])):null}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(this._loading)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new o(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:r,imageRotation:i}})=>{const o=e.trim();return Z(o)?{url:o,objectId:t,rotation:(r??0)+(i??0)}:null})).filter(r)):null}set view(e){this._set("view",e)}filterByFootprints(e,t){const r=[],i=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:a},attributes:s}=e;let n;const{polygon:c,frustum:h}=S(e);if(n=c,s.isInspection&&(n=V(s)),a&&(n=O(n,a)),A(n,t)){o.push(e);const t=n.toJSON(),a=h?.toJSON(),{cameraHeight:c,cameraHeading:u,location:g,objectId:m}=s,d=l(g)?g.toJSON():g;t.imageID=d.imageID=m,a&&(a.imageID=m),d.z=c,this.pointSources?.push(d),r.push(u>0?t:void 0),i.push(u>0?a:void 0)}})),{features:o,polygons:r,frustums:i}}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getCurrentBestFeaturePolygon(){return this._initialCurrentCoveragePolygon}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[E[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:r}=e;if(isNaN(r))return;const i=this._sectorData?.[t];i?.length&&this._updateCurrentBestFeature(i.at(r))}async loadBestImage(e){this._loading=!0,this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?P(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon=m(this._currentCoveragePolygon),this._overlays?.removeAll(),await this._fetchFeaturesWithController(e)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:z}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const r=l(e)?e.toJSON():e;r.x-=.5,r.y=.5-r.y,this._referencePointOnImage=new t({geometry:{type:"point",spatialReference:this._imageViewer.imageRenderer.spatialReference,...r},symbol:z}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:r}=this._panoramicViewer;if(!r)return;const[i,o]=r,{heading:a,pitch:s}=R(e,i,o),n=x(a,s);this._referencePointOnImage=new t({geometry:new ie(n,ae.WebMercator),symbol:W}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const r=await F(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){d(r)||(this.setMessage("imageLoadError","error",r.message),u.getLogger(this).error("error occurred while finding best image",r))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this._additionalFeatureGraphics.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this._additionalCoveragePolygons.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=e),this._currentBestFeatureGraphic&&(this._currentBestFeatureGraphic.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:r}=e,i=this._initialCurrentCoveragePolygon?.geometry;if(!i?.contains(t))return;const o=await this.transformPoint(t,r);return o?(this.plotReferencePointOnImage(o),{x:o.x,y:o.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._updateFeatures(t),this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}_createFootprintHandles(){this.removeHandles(se.footprintHandles),this.addHandles(y((()=>[this._panoramicViewer.fov,this._panoramicViewer.yaw,this._panoramicViewer.pitch]),(()=>{this.updateFootprintPanorama()}),v),se.footprintHandles)}async _fetchFeatures(e,t){if(!this.view)return;const r=this.layer;if(r){const i={include:r},o=this.view.toScreen(e);if(!o)return;const a=await this.view.hitTest(o,i);this._processHitTestResults(r,a,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:r}).finally((()=>{this._fetchFeaturesController=null}))}catch(i){this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:r,features:i}=this;if(!(e&&t&&r&&i))return void(this._sectorData=null);this._sectorData={};for(const l of E)this._sectorData[l]=new o;const a=e.map(((e,t)=>({...e,featureIndex:t})));a.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const s=a.map((({distance:e})=>e)),n=Math.max(...s);a.forEach((e=>{const{distance:t,angle:r,featureIndex:o}=e,a=t/n*H[2],s=ee(t,n),l=te(r);if(!this._sectorData)return;const c=H[3]+a*Math.sin(r*Math.PI/180),h=H[3]+a*Math.cos(r*Math.PI/180);let u;const g=i.at(o),m=g===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-H[3],t=h-H[3],r=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(r)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),u=i}const p=""===s?l:`${s}_${l}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:l});const y=this._sectorData[p];y.add({angle:r,featureIndex:o,x:c,y:h,objectID:g.attributes.objectId,sector:p,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t){const{selectedPoint:i}=this;if(!i)return;if(!e)return;const o=e;if(!o)return;const{features:a}=o;if(!a.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:s,polygons:n,frustums:l}=this.filterByFootprints(a,i),c=s;this.coveragePolygons.addMany(n),this.coverageFrustums.addMany(l);const h=n.filter(r).reduce(((e,t)=>(e.push(...t.rings.flat()),e)),new Array),u=new oe({rings:h,spatialReference:n[0]?.spatialReference}).extent;if(!c.length)return void this.setMessage("noImageError","error");if(this._footprintExtent=u,c[0].attributes.elevationSource&&!i.z&&u){const e=await B([i],{feature:c[0],footprintExtent:u,options:t});if(e[0]){const t=e[0];i.elevation=t.z}c[0].elevationSample&&c.forEach((e=>{e.elevationSample=c[0].elevationSample}))}this._suitabilities=I({features:c,selectedPoint:i,camera:X(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const g=this._suitabilities.map((e=>e.feature));this.currentBestFeature=g[0],this._loading=!1}async _processHitTestResults(e,t,r){const{screenPoint:i,results:[o]}=t,a="graphic"===o?.type&&this.shouldShowSelectedImage,s={layerInstanceOrURL:e,point:o?.mapPoint??this.view?.toMap(i),queryParams:{maximumDistance:e.maximumDistance,objectIds:a?[o.graphic.getAttribute(e.objectIdField)]:void 0},queryFeatures:null};await this.searchBestImage(s,r)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.currentBestFeature=e[0],e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll()}_updatePointsAndPolygons(){const{coveragePolygons:e,pointSources:r,currentBestFeature:i,currentCoverageVisible:o,isAdditionalCoverageVisible:a,isAdditionalPointSourcesVisible:s}=this;if(e&&r&&i){this._additionalCoveragePolygons.removeAll(),this._additionalFeatureGraphics.removeAll(),this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const r of e)r?.imageID===i.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:U,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:r?.imageID},geometry:{type:"polygon",...r},symbol:J,visible:a}));for(const e of r)e.imageID===i.attributes.objectId?this._currentBestFeatureGraphic=new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:q,visible:o}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:e.imageID},geometry:{type:"point",...e},symbol:$,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let r;if(t)r=-90;else{const t=e.x-H[3],i=e.y-H[3],o=i/Math.sqrt(t**2+i**2);let a=180*Math.acos(o)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(a*=-1),r=a}r===this.bestFeatureAngle?this.previousFeatureAngle=r:this.bestFeatureAngle=r,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,r,i){this._loading=!1,this.displayMessage={key:e,type:t,data:r,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:r,state:i}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!r||!t||"image-loaded"!==i)return;let o;try{o=await this.transformPoint(r,e),await this.plotSelectedPointOnImage(o,e)}catch(a){d(a)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:a,selectedPoint:r,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const r=this.currentBestFeature,i=await j([e],{feature:r,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t});if(!i.length)return;return i[0]}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&this._currentCoveragePolygon.destroy(),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e),this.view){const e=this.selectedPoint?new t({geometry:this.selectedPoint.clone(),symbol:N,attributes:{imageID:this.currentBestFeature?.attributes.objectId}}):null;this._overlays?.graphics.addMany([...this._additionalCoveragePolygons,...this._additionalFeatureGraphics,this._currentCoveragePolygon,this._currentBestFeatureGraphic,e].filter(Y))}}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.currentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}}async updateCoverage(){if("default"===this.mode){this._cancelCurrentCoverageUpdate();const{imagePointsInView:e,state:t}=this._imageViewer,r=c(e);if(!r||"image-loaded"!==t)return;this.updateFootprint(r)}}};e([w()],he.prototype,"activeLayer",null),e([w()],he.prototype,"additionalFeatures",void 0),e([w({json:{write:!1}})],he.prototype,"determineWorkflowForFeature",void 0),e([w()],he.prototype,"drawFootprint",void 0),e([w({readOnly:!0,value:"none"})],he.prototype,"mode",null),e([w()],he.prototype,"imagePointsInView",null),e([w()],he.prototype,"layer",void 0),e([w()],he.prototype,"shouldShowSelectedImage",void 0),e([w({type:Number})],he.prototype,"brightness",null),e([w({type:Number})],he.prototype,"contrast",null),e([w()],he.prototype,"coverageFrustums",void 0),e([w()],he.prototype,"coveragePolygons",void 0),e([w()],he.prototype,"currentCoverageVisible",void 0),e([w()],he.prototype,"disabled",void 0),e([w()],he.prototype,"displayMessage",void 0),e([w()],he.prototype,"pointSources",void 0),e([w()],he.prototype,"previousFeatureAngle",void 0),e([w()],he.prototype,"currentBestFeature",void 0),e([w()],he.prototype,"bestFeatureAngle",void 0),e([w()],he.prototype,"selectedPoint",void 0),e([w({readOnly:!0})],he.prototype,"featureCount",null),e([w()],he.prototype,"features",void 0),e([w({readOnly:!0})],he.prototype,"imageGalleryEnabled",null),e([w({readOnly:!0})],he.prototype,"imageLoaded",null),e([w()],he.prototype,"isAdditionalCoverageVisible",void 0),e([w()],he.prototype,"isAdditionalPointSourcesVisible",void 0),e([w({type:Number})],he.prototype,"localPort",void 0),e([w()],he.prototype,"mapImageConversionToolState",void 0),e([w()],he.prototype,"navigatorCurrentBestFeature",void 0),e([w()],he.prototype,"referencePoint",null),e([w({type:Number})],he.prototype,"sharpness",null),e([w({readOnly:!0})],he.prototype,"sectorData",null),e([w({readOnly:!0})],he.prototype,"state",null),e([w({readOnly:!0})],he.prototype,"thumbnails",null),e([w()],he.prototype,"updateFootprint",void 0),e([w({value:null})],he.prototype,"view",null),e([w()],he.prototype,"_additionalCoveragePolygons",void 0),e([w()],he.prototype,"_additionalFeatureGraphics",void 0),e([w()],he.prototype,"_currentCoveragePolygon",void 0),e([w()],he.prototype,"_fetchFeaturesController",void 0),e([w()],he.prototype,"_imageViewer",void 0),e([w()],he.prototype,"_initialCurrentCoveragePolygon",void 0),e([w()],he.prototype,"_initialCurrentCoverageUpdate",void 0),e([w()],he.prototype,"_loading",void 0),e([w()],he.prototype,"_overlays",void 0),e([w()],he.prototype,"_panoramicViewer",void 0),e([w()],he.prototype,"_referencePointOnGround",void 0),e([w()],he.prototype,"_referencePointOnImage",void 0),e([w()],he.prototype,"_currentBestFeatureGraphic",void 0),e([w()],he.prototype,"_sectorData",void 0),he=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],he);const ue=he;export{ue 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import r from"../../core/Logger.js";import{sectorsRadii as
|
|
5
|
+
import r from"../../request.js";import t from"../../core/Logger.js";import{sectorsRadii as e}from"./constants.js";function n(r){return"3d"===r?.type}function o(r){return"esri.Graphic"===r?.declaredClass}function i(r){return/.*.(tif|mrf)$/i.test(r??"")}function s(r){return Math.abs(r)>=135?"WEST":r<-45&&r>-135?"SOUTH":r<=45?"EAST":"NORTH"}function u(r,t){const n=r/t*e[2];return n<=e[0]?"NEAR":n<=e[1]?"":"FAR"}function a(r){return r&&r.url&&r.datasetFormat?r:null}function c(r){return"string"==typeof r&&r.length?r:a(r)}function g(r){return"NoAttachmentError"===r?.name}const f=r=>`${r}:missing-property`,m=(r,t)=>`Property ${t} is missing in ${r}`,d=(r="esri.widgets.OrientedImageryViewer",e)=>{throw t.getLogger(r).error(e),e},p=async(e,n)=>{try{const t=await r(e,{...n,method:"head"});return t?.getHeader?.("Content-Type")}catch(o){return t.getLogger("esri.widgets.OrientedImagery").error("failed to fetch Content-Type",o),null}};export{s as calculateDirection,u as calculateSegment,c as castImageSource,a as castURLWithDatasetFormat,p as getContentType,m as getMissingPropertyErrorMessage,f as getMissingPropertyErrorName,o as isGraphic,g as isNoAttachmentError,n as isSceneView,i as isTifOrMrf,d as logAndThrow};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[2288],{92288:(e,t,r)=>{r.r(t),r.d(t,{registerFunctions:()=>F});var n=r(92602),o=(r(59456),r(47609)),i=r(66395),a=r(85935),s=r(78878),l=r(80672),u=r(91075),p=r(57251),c=r(28735),f=r(20655),d=r(80812),h=r(78888),y=r(56507),m=r(65864),g=r(2272),w=r(92300),v=r(90237),S=r(25482),A=r(10107),R=(r(44208),r(53966),r(87811),r(40608)),_=r(21325);let G=class extends S.oY{constructor(e){super(e),this.geometries=[],this.outSpatialReference=null,this.transformation=null,this.transformForward=null}toJSON(){const e=this.geometries.map((e=>e.toJSON())),t=this.geometries[0],r={};return r.outSR=(0,_.YX)(this.outSpatialReference),r.inSR=(0,_.YX)(t.spatialReference),r.geometries=JSON.stringify({geometryType:(0,m.$B)(t),geometries:e}),this.transformation&&(r.transformation=this.transformation.wkid||JSON.stringify(this.transformation)),null!=this.transformForward&&(r.transformForward=this.transformForward),r}};(0,v._)([(0,A.MZ)()],G.prototype,"geometries",void 0),(0,v._)([(0,A.MZ)({json:{read:{source:"outSR"}}})],G.prototype,"outSpatialReference",void 0),(0,v._)([(0,A.MZ)()],G.prototype,"transformation",void 0),(0,v._)([(0,A.MZ)()],G.prototype,"transformForward",void 0),G=(0,v._)([(0,R.$)("esri.rest.support.ProjectParameters")],G);const j=G,b=(0,y.dp)(j);var x=r(25927),k=r(42538),M=r(40662),N=r(42095),$=r(23150),Z=r(16930);let T=null;async function D(e){const t=n.A.geometryServiceUrl??"";if(!t){(0,p.isLoaded)()||await(0,p.load)();for(const t of e)t.container[t.indexer]=(0,p.project)(t.container[t.indexer],Z.A.WGS84);return}const r=e.map((e=>e.container[e.indexer])),o=new j({geometries:r,outSpatialReference:Z.A.WGS84}),i=await async function(e,t,r){t=b(t);const n=(0,g.Dl)(e),o={...n.query,f:"json",...t.toJSON()},i=t.outSpatialReference,a=(0,m.$B)(t.geometries[0]),s=(0,g.jV)(o,void 0);return(0,h.A)(n.path+"/project",s).then((({data:{geometries:e}})=>(0,w.V)(e,a,i)))}(t,o);for(let t=0;t<i.length;t++){const r=e[t];r.container[r.indexer]=i[t]}}async function P(e,t){const n=new d.default({portal:e,id:t});return await n.load(),null===T&&(T=await r.e(3709).then(r.bind(r,43709))),await T.fetchKnowledgeGraph(n.url)}function J(e,t,r,n,o){if(null===e)return null;if((0,s.c)(e)||(0,s.b)(e))return e;if((0,s.k)(e))return e.toJSDate();if((0,s.k)(e))return e.toJSDate();if((0,s.m)(e))return e.toStorageFormat();if((0,s.n)(e))return e.toStorageString();if((0,s.v)(e)){const i={};for(const a of e.keys())i[a]=J(e.field(a),t,r,n,o),i[a]instanceof u.A&&o.push({container:i,indexer:a});return i}if((0,s.o)(e)){const i=e.map((e=>J(e,t,r,n,o)));for(let e=0;e<i.length;e++)i[e]instanceof u.A&&o.push({container:i,indexer:e});return i}if((0,s.p)(e)){if(e.spatialReference.isWGS84)return e;if(e.spatialReference.isWebMercator&&t)return(0,c.ci)(e);if(!t||!r)return e;throw new a.D$(n,a.TX.WrongSpatialReference,null)}}function O(e,t){if(!e)return null;const r={};for(const n in e)r[n]=I(e[n],t);return r}function I(e,t){return null===e?null:(0,s.o)(e)?e.map((e=>I(e,t))):e instanceof x.A?{graphTypeName:e.typeName,id:e.id,graphType:"entity",properties:O(e.properties,t)}:e instanceof M.A?{graphType:"object",properties:O(e.properties,t)}:e instanceof $.A?{graphTypeName:e.typeName,id:e.id,graphType:"relationship",originId:e.originId??null,destinationId:e.destinationId??null,properties:O(e.properties,t)}:e instanceof N.A?{graphType:"path",path:e.path?e.path.map((e=>I(e,t))):null}:(0,s.p)(e)?function(e,t){if(!e)return e;if(e.spatialReference.isWGS84&&t.spatialReference.isWebMercator)return(0,c.Gh)(e);if(e.spatialReference.equals(t.spatialReference))return e;throw new a.D$(t,a.TX.WrongSpatialReference,null)}(e,t):(0,s.c)(e)||(0,s.b)(e)||(0,s.a6)(e)?e:null}function F(e){"async"===e.mode&&(e.functions.knowledgegraphbyportalitem=function(t,r){return e.standardFunctionAsync(t,r,((e,n,i)=>{if((0,s.H)(i,2,2,t,r),null===i[0])throw new a.D$(t,a.TX.PortalRequired,r);if(i[0]instanceof o.A){const e=(0,s.j)(i[1]);let r=null;return r=t.services?.portal?t.services.portal:f.A.getDefault(),P((0,l.R)(i[0],r),e)}if(!1===(0,s.c)(i[0]))throw new a.D$(t,a.TX.InvalidParameter,r);const u=(0,s.j)(i[0]);return P(t.services?.portal??f.A.getDefault(),u)}))},e.signatures.push({name:"knowledgegraphbyportalitem",min:2,max:2}),e.functions.querygraph=function(t,n){return e.standardFunctionAsync(t,n,(async(e,o,l)=>{(0,s.H)(l,2,4,t,n);const u=l[0];if(!(0,s.w)(u))throw new a.D$(t,a.TX.InvalidParameter,n);const p=l[1];if(!(0,s.c)(p))throw new a.D$(t,a.TX.InvalidParameter,n);null===T&&(T=await r.e(3709).then(r.bind(r,43709)));let c=null;const f=(0,s.K)(l[2],null);if(!(f instanceof i.A||null===f))throw new a.D$(t,a.TX.InvalidParameter,n);if(f){let e=[];c=J(f,!0,!1,t,e),e=e.filter((e=>!e.container[e.indexer].spatialReference.isWGS84)),e.length>0&&await D(e)}const d=new k.A({openCypherQuery:p,bindParameters:c});(u?.serviceDefinition?.currentVersion??11.3)>11.2&&(d.outputSpatialReference=t.spatialReference);const h=(await T.executeQueryStreaming(u,d)).resultRowsStream.getReader(),y=[];try{for(;;){const{done:e,value:r}=await h.read();if(e)break;if((0,s.o)(r))for(const e of r)y.push(I(e,t));else{const e=[];for(const n of r)e.push(I(r[n],t));y.push(e)}}}catch(e){throw e}return i.A.convertJsonToArcade(y,(0,s.N)(t),!1,!0)}))},e.signatures.push({name:"querygraph",min:2,max:4}))}},80672:(e,t,r)=>{r.d(t,{R:()=>o});var n=r(20655);function o(e,t){return null===e?t:new n.A({url:e.field("url")})}},92300:(e,t,r)=>{r.d(t,{V:()=>i,X:()=>o});var n=r(65864);function o(e){return{geometryType:(0,n.$B)(e[0]),geometries:e.map((e=>e.toJSON()))}}function i(e,t,r){const o=(0,n.xD)(t);return e.map((e=>{const t=o.fromJSON(e);return t.spatialReference=r,t}))}},25927:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(90237),o=(r(59456),r(10107)),i=(r(44208),r(53966),r(87811),r(40608)),a=r(54238),s=r(86738);let l=class extends a.A{constructor(e){super(e),this.layoutGeometry=null}};(0,n._)([(0,o.MZ)({type:s.A,json:{write:!0}})],l.prototype,"layoutGeometry",void 0),l=(0,n._)([(0,i.$)("esri.rest.knowledgeGraph.Entity")],l);const u=l},54238:(e,t,r)=>{r.d(t,{A:()=>l});var n=r(90237),o=r(10107),i=(r(44208),r(53966),r(87811),r(40608)),a=r(77901);let s=class extends a.A{constructor(e){super(e),this.typeName=null,this.id=null}};(0,n._)([(0,o.MZ)({type:String,json:{write:!0}})],s.prototype,"typeName",void 0),(0,n._)([(0,o.MZ)({type:String,json:{write:!0}})],s.prototype,"id",void 0),s=(0,n._)([(0,i.$)("esri.rest.knowledgeGraph.GraphNamedObject")],s);const l=s},77901:(e,t,r)=>{r.d(t,{A:()=>l});var n=r(90237),o=r(25482),i=r(10107),a=(r(44208),r(53966),r(87811),r(40608));let s=class extends o.oY{constructor(e){super(e),this.properties=null}};(0,n._)([(0,i.MZ)({json:{write:!0}})],s.prototype,"properties",void 0),s=(0,n._)([(0,a.$)("esri.rest.knowledgeGraph.GraphObject")],s);const l=s},42538:(e,t,r)=>{r.d(t,{A:()=>p});var n=r(90237),o=r(10107),i=(r(44208),r(53966),r(87811),r(40608)),a=r(69622);let s=class extends a.A{constructor(e){super(e),this.openCypherQuery=""}};(0,n._)([(0,o.MZ)()],s.prototype,"openCypherQuery",void 0),s=(0,n._)([(0,i.$)("esri.rest.knowledgeGraph.GraphQuery")],s);const l=s;let u=class extends l{constructor(e){super(e),this.bindParameters=null,this.bindGeometryQuantizationParameters=null,this.outputQuantizationParameters=null,this.outputSpatialReference=null}};(0,n._)([(0,o.MZ)()],u.prototype,"bindParameters",void 0),(0,n._)([(0,o.MZ)()],u.prototype,"bindGeometryQuantizationParameters",void 0),(0,n._)([(0,o.MZ)()],u.prototype,"outputQuantizationParameters",void 0),(0,n._)([(0,o.MZ)()],u.prototype,"outputSpatialReference",void 0),u=(0,n._)([(0,i.$)("esri.rest.knowledgeGraph.GraphQueryStreaming")],u);const p=u},40662:(e,t,r)=>{r.d(t,{A:()=>s});var n=r(90237),o=(r(53966),r(44208),r(87811),r(49186),r(40608)),i=r(77901);let a=class extends i.A{constructor(e){super(e)}};a=(0,n._)([(0,o.$)("esri.rest.knowledgeGraph.ObjectValue")],a);const s=a},42095:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(90237),o=r(25482),i=r(10107),a=(r(44208),r(53966),r(87811),r(40608)),s=r(77901);let l=class extends o.oY{constructor(e){super(e),this.path=null}};(0,n._)([(0,i.MZ)({type:[s.A],json:{write:!0}})],l.prototype,"path",void 0),l=(0,n._)([(0,a.$)("esri.rest.knowledgeGraph.Path")],l);const u=l},23150:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(90237),o=(r(59456),r(10107)),i=(r(44208),r(53966),r(87811),r(40608)),a=r(54238),s=r(82799);let l=class extends a.A{constructor(e){super(e),this.originId=null,this.destinationId=null,this.layoutGeometry=null}};(0,n._)([(0,o.MZ)({type:String,json:{write:!0}})],l.prototype,"originId",void 0),(0,n._)([(0,o.MZ)({type:String,json:{write:!0}})],l.prototype,"destinationId",void 0),(0,n._)([(0,o.MZ)({type:s.A,json:{write:!0}})],l.prototype,"layoutGeometry",void 0),l=(0,n._)([(0,i.$)("esri.rest.knowledgeGraph.Relationship")],l);const u=l},2272:(e,t,r)=>{r.d(t,{Dl:()=>a,jV:()=>i,lF:()=>s}),r(92602),r(70333);var n=r(4718),o=r(84952);function i(e,t){return t?{...t,query:{...e??{},...t.query}}:{query:e}}function a(e){return"string"==typeof e?(0,o.An)(e):(0,n.o8)(e)}function s(e,t,r){const n={};for(const o in e){if("declaredClass"===o)continue;const i=e[o];if(null!=i&&"function"!=typeof i)if(Array.isArray(i))n[o]=i.map((e=>s({item:e},t,r).item));else if("object"==typeof i)if(i.toJSON){const e=i.toJSON(r?.[o]);n[o]=t?e:JSON.stringify(e)}else n[o]=t?i:JSON.stringify(i);else n[o]=i}return n}r(926)}}]);
|