@arcgis/core 4.26.0-next.20230220 → 4.26.0
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/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0923c0641ca9d9a52efc.js +1 -0
- package/assets/esri/core/workers/chunks/{985ffb4dfa8e598c94b5.js → 0d0bca75414f15371baf.js} +1 -1
- package/assets/esri/core/workers/chunks/253a3e9ce0521a005134.js +1 -0
- package/assets/esri/core/workers/chunks/{5b2bd5829b3831bf9bce.js → 636b4e080d701d5856c7.js} +1 -1
- package/assets/esri/core/workers/chunks/{c6265aea465769ff758b.js → 995ea389fb778b25d927.js} +1 -1
- package/assets/esri/core/workers/chunks/{5d946cee3dc0e7311f98.js → aa864f9ad6b9a92ab328.js} +1 -1
- package/assets/esri/core/workers/chunks/{173febea598431b4e444.js → f3b59aa3b33e3ee70bec.js} +1 -1
- package/assets/esri/core/workers/chunks/{37893e24e4eead6dcec9.js → fd03ba4613f8973f8c86.js} +1 -1
- package/config.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/lazyLayerLoader.js +1 -1
- package/package.json +1 -1
- package/smartMapping/heuristics/clusterMinSize.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/52a06c5eb51ea1d79000.js +0 -1
- package/assets/esri/core/workers/chunks/a7d2caa47df34a66445a.js +0 -1
package/config.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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"./core/has.js";import{deepMerge as e}from"./core/object.js";
|
|
5
|
+
import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={analysisTheme:{accentColor:[255,128,0],textColor:"white"},apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!1,portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.26.0";s.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{id as e}from"../../kernel.js";import t from"../../request.js";import{isSome as n}from"../../core/maybe.js";function r(e){const t=e?.type;return"imagery-tile"===t||"tile"===t||"open-street-map"===t||"vector-tile"===t||"web-tile"===t||"wmts"===t}function i(e){const t=e?.type;return"base-tile"===t||"tile"===t||"elevation"===t||"imagery-tile"===t||"base-elevation"===t||"open-street-map"===t||"wcs"===t||"web-tile"===t||"wmts"===t||"vector-tile"===t}function s(e){return null!=e&&"type"in e&&"group"===e.type}const a={Point:"SceneLayer","3DObject":"SceneLayer",IntegratedMesh:"IntegratedMeshLayer",PointCloud:"PointCloudLayer",Building:"BuildingSceneLayer"};function u(e){const t=e?.type;return"building-scene"===t||"integrated-mesh"===t||"point-cloud"===t||"scene"===t}function c(e){return"voxel"===e?.type}function o(e){return"imagery-tile"===e?.type}function l(e){return null!=e&&null!=e.parent&&"declaredClass"in e.parent&&"esri.Basemap"===e.parent.declaredClass&&e.parent.baseLayers.includes(e)}function f(e){return"feature"===e?.type&&!e.url&&"memory"===e.source?.type}function
|
|
5
|
+
import{id as e}from"../../kernel.js";import t from"../../request.js";import{isSome as n}from"../../core/maybe.js";function r(e){const t=e?.type;return"imagery-tile"===t||"tile"===t||"open-street-map"===t||"vector-tile"===t||"web-tile"===t||"wmts"===t}function i(e){const t=e?.type;return"base-tile"===t||"tile"===t||"elevation"===t||"imagery-tile"===t||"base-elevation"===t||"open-street-map"===t||"wcs"===t||"web-tile"===t||"wmts"===t||"vector-tile"===t}function s(e){return null!=e&&"type"in e&&"group"===e.type}const a={Point:"SceneLayer","3DObject":"SceneLayer",IntegratedMesh:"IntegratedMeshLayer",PointCloud:"PointCloudLayer",Building:"BuildingSceneLayer"};function u(e){const t=e?.type;return"building-scene"===t||"integrated-mesh"===t||"point-cloud"===t||"scene"===t}function c(e){return"voxel"===e?.type}function o(e){return"imagery-tile"===e?.type}function l(e){return null!=e&&null!=e.parent&&"declaredClass"in e.parent&&"esri.Basemap"===e.parent.declaredClass&&e.parent.baseLayers.includes(e)}function f(e){return"feature"===e?.type&&!e.url&&"memory"===e.source?.type}function y(e){return"feature"===e?.type&&"feature-layer"===e.source?.type}function p(e){const t=/[:;]/,n=[];let r=!1;if(e&&(e.forEach(((e,i)=>{n.push([i,e]),!r&&t.test(e)&&(r=!0)})),n.length>0)){let e;if(r){const t={};n.forEach((e=>{t[e[0]]=e[1]})),e=JSON.stringify(t)}else{const t=[];n.forEach((e=>{t.push(e[0]+":"+e[1])})),e=t.join(";")}return e}return null}function g(e){if(!e)return;const t=[];return e.forEach(((e,n)=>{t.push('"'+n+'":'+JSON.stringify(e))})),t.length?"{"+t.join(",")+"}":void 0}function d(e){if(e.activeLayer){const t=e.activeLayer.tileMatrixSet;if(t)return t;const n=e.activeLayer.tileMatrixSets;if(n)return n}return null}async function b(r,i){const s=e?.findServerInfo(r);if(null!=s?.currentVersion)return s.owningSystemUrl||null;const a=r.toLowerCase().indexOf("/rest/services");if(-1===a)return null;const u=`${r.substring(0,a)}/rest/info`,c=n(i)?i.signal:null,{data:o}=await t(u,{query:{f:"json"},responseType:"json",signal:c});return o?.owningSystemUrl||null}function m(e){if(!("capabilities"in e))return!1;switch(e.type){case"csv":case"feature":case"geojson":case"imagery":case"knowledge-graph-sublayer":case"ogc-feature":case"oriented-imagery":case"scene":case"subtype-group":case"subtype-sublayer":case"wfs":return!0;default:return!1}}function v(e){return m(e)?"effectiveCapabilities"in e?e.effectiveCapabilities:e.capabilities:null}function h(e){if(!("editingEnabled"in e))return!1;switch(e.type){case"csv":case"feature":case"geojson":case"oriented-imagery":case"scene":case"subtype-group":case"subtype-sublayer":return!0;default:return!1}}function w(e){return!!h(e)&&("effectiveEditingEnabled"in e?e.effectiveEditingEnabled:e.editingEnabled)}export{w as getEffectiveEditingEnabled,v as getEffectiveLayerCapabilities,b as getOwningPortalUrl,d as getTileMaxtrixSetFromActiveLayer,l as isBaseLayer,r as isBasemapSupportedLayer,f as isFeatureCollectionLayer,y as isFeatureServiceLayer,s as isGroupLayer,o as isImageryTileLayer,u as isSceneServiceLayer,i as isTiledLayer,c as isVoxelLayer,a as sceneServiceLayerTypeToClassName,p as serializeLayerDefinitions,g as serializeTimeOptions};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const a={BingMapsLayer:async()=>(await import("../BingMapsLayer.js")).default,BuildingSceneLayer:async()=>(await import("../BuildingSceneLayer.js")).default,CSVLayer:async()=>(await import("../CSVLayer.js")).default,DimensionLayer:async()=>(await import("../DimensionLayer.js")).default,ElevationLayer:async()=>(await import("../ElevationLayer.js")).default,FeatureLayer:async()=>(await import("../FeatureLayer.js")).default,
|
|
5
|
+
const a={BingMapsLayer:async()=>(await import("../BingMapsLayer.js")).default,BuildingSceneLayer:async()=>(await import("../BuildingSceneLayer.js")).default,CSVLayer:async()=>(await import("../CSVLayer.js")).default,DimensionLayer:async()=>(await import("../DimensionLayer.js")).default,ElevationLayer:async()=>(await import("../ElevationLayer.js")).default,FeatureLayer:async()=>(await import("../FeatureLayer.js")).default,GeoJSONLayer:async()=>(await import("../GeoJSONLayer.js")).default,GeoRSSLayer:async()=>(await import("../GeoRSSLayer.js")).default,GroupLayer:async()=>(await import("../GroupLayer.js")).default,ImageryLayer:async()=>(await import("../ImageryLayer.js")).default,ImageryTileLayer:async()=>(await import("../ImageryTileLayer.js")).default,IntegratedMeshLayer:async()=>(await import("../IntegratedMeshLayer.js")).default,KMLLayer:async()=>(await import("../KMLLayer.js")).default,LineOfSightLayer:async()=>(await import("../LineOfSightLayer.js")).default,MapImageLayer:async()=>(await import("../MapImageLayer.js")).default,MapNotesLayer:async()=>(await import("../MapNotesLayer.js")).default,MediaLayer:async()=>(await import("../MediaLayer.js")).default,OGCFeatureLayer:async()=>(await import("../OGCFeatureLayer.js")).default,OpenStreetMapLayer:async()=>(await import("../OpenStreetMapLayer.js")).default,OrientedImageryLayer:async()=>(await import("../OrientedImageryLayer.js")).default,PointCloudLayer:async()=>(await import("../PointCloudLayer.js")).default,RouteLayer:async()=>(await import("../RouteLayer.js")).default,SceneLayer:async()=>(await import("../SceneLayer.js")).default,StreamLayer:async()=>(await import("../StreamLayer.js")).default,SubtypeGroupLayer:async()=>(await import("../SubtypeGroupLayer.js")).default,TileLayer:async()=>(await import("../TileLayer.js")).default,UnknownLayer:async()=>(await import("../UnknownLayer.js")).default,UnsupportedLayer:async()=>(await import("../UnsupportedLayer.js")).default,VectorTileLayer:async()=>(await import("../VectorTileLayer.js")).default,VoxelLayer:async()=>(await import("../VoxelLayer.js")).default,WFSLayer:async()=>(await import("../WFSLayer.js")).default,WMSLayer:async()=>(await import("../WMSLayer.js")).default,WMTSLayer:async()=>(await import("../WMTSLayer.js")).default,WebTileLayer:async()=>(await import("../WebTileLayer.js")).default};export{a as layerLookupMap};
|
package/package.json
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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{px2pt as t}from"../../core/screenUtils.js";import{getTextBounds as e}from"../../views/2d/support/engineHelpers.js";async function n(n,o){await o.when();const r=n.clone();r.text="
|
|
5
|
+
import{px2pt as t}from"../../core/screenUtils.js";import{getTextBounds as e}from"../../views/2d/support/engineHelpers.js";async function n(n,o){await o.when();const r=n.clone();r.text="999";const s=await e(r,o);return t(s.width)}export{n as default};
|
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const b="20230222",d="f17172bab03d767d6c0b1299b23ed7d4aba5edea";export{b as buildDate,d as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import i from"../../../../Graphic.js";import"../../../../symbols.js";import{getAccentColor as o}from"../../../../core/analysisThemeUtils.js";import{isNone as r,unwrap as s,destroyMaybe as a}from"../../../../core/maybe.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{project as l}from"../../../../geometry/projection.js";import{isValid as p}from"../../../../geometry/support/spatialReferenceUtils.js";import d from"../../../../layers/GraphicsLayer.js";import{applyCIMSymbolColor as m}from"../../../../symbols/support/cimSymbolUtils.js";import{ViewingMode as y}from"../../../ViewingMode.js";import{DragManipulation as _}from"./manipulations/DragManipulation.js";import{primaryKey as g}from"../../../input/keys.js";import{InteractiveToolBase as f}from"../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as u}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as P}from"../../../interactive/editGeometry/interfaces.js";import v from"../../../../symbols/CIMSymbol.js";const S={up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",toggleOpacity:"t",shift:"Shift",primaryKey:g},k=1,b=10,G=new e("#009AF2");let M=class extends f{constructor(t){super(t),this._isOpacityToggled=!1,this._isModifierActive=!1,this._factor=1,this._initialControlPoints=null,this._graphicsLayer=new d({internal:!0,listMode:"hide",visible:!1,effect:"drop-shadow(0px, 0px, 3px)"}),this._undoStack=[],this._redoStack=[],this._sharedUndoStack=[],this._sharedRedoStack=[],this._highlightHandle=null,this.activeHandle=0}initialize(){const{view:t,mediaElement:e}=this;if(r(e.georeference))return;const a=e.georeference;"control-points"!==a.type||r(a.coords)||(this._georeference=a,this._initialControlPoints=s(this._georeference.controlPoints),this._controlPointEditGeometryOperations=s(this._georeference.controlPoints).map((({mapPoint:e})=>u.fromGeometry(l(e,t.spatialReference),y.Local))),this._controlPointGraphics=this._controlPointEditGeometryOperations.map(((t,e)=>new i({symbol:new v({data:{type:"CIMSymbolReference",symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,colorLocked:!0,anchorPoint:{x:0,y:-15.75},anchorPointUnits:"Absolute",dominantSizeAxis3D:"Y",size:9,billboardMode3D:"FaceNearPlane",frame:{xmin:0,ymin:0,xmax:84.3,ymax:84.3},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[83.2,32.5],[84.3,40.7],[83.8,48.9],[81.7,56.9],[78.1,64.3],[73,70.9],[66.9,76.4],[59.7,80.5],[51.9,83.2],[43.7,84.3],[35.4,83.8],[27.4,81.7],[20,78],[13.4,73],[7.9,66.8],[3.8,59.7],[1.1,51.9],[0,43.7],[.5,35.4],[2.6,27.4],[6.3,20],[11.3,13.4],[17.5,7.9],[24.7,3.8],[32.5,1.1],[39.8,.1],[47.1,.3],[54.3,1.8],[61.1,4.5],[67.4,8.4],[72.9,13.3],[77.4,19.1],[80.9,25.5],[83.2,32.5]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]}}],scaleSymbolsProportionally:!0,respectFrame:!0,clippingPath:{type:"CIMClippingPath",clippingType:"Intersect",path:{rings:[[[0,0],[84.3,0],[84.3,84.3],[0,84.3],[0,0]]]}},rotation:0},{type:"CIMVectorMarker",enable:!0,anchorPoint:{x:0,y:-11.25},anchorPointUnits:"Absolute",dominantSizeAxis3D:"Y",size:22.5,billboardMode3D:"FaceNearPlane",frame:{xmin:0,ymin:0,xmax:197.7,ymax:294.7},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[98.9,0],[119.4,23.2],[139.4,49.3],[156.8,75.2],[171.2,100.8],[182.4,125.3],[190.6,148.8],[195.7,171.4],[197.7,192.9],[197.7,195.8],[197.7,200.3],[197.6,202.5],[197.5,204.8],[197.3,207.1],[197,209.4],[196.7,211.7],[196.4,214.1],[196,216.4],[195.5,218.7],[195,221.1],[194.4,223.4],[193.7,225.8],[193,228.1],[192.2,230.5],[191.4,232.8],[190.5,235.1],[189.5,237.5],[188.5,239.7],[187.4,242],[186.2,244.3],[185,246.5],[183.7,248.7],[182.4,250.9],[181,253.1],[179.5,255.2],[178,257.3],[176.4,259.4],[174.7,261.4],[173.1,263.3],[171.3,265.3],[169.5,267.2],[167.7,269],[165.8,270.8],[163.9,272.5],[161.9,274.2],[159.9,275.8],[157.8,277.4],[155.7,278.9],[153.6,280.4],[151.4,281.7],[149.2,283.1],[147,284.4],[144.8,285.6],[142.5,286.7],[140.3,287.8],[138,288.8],[135.7,289.8],[133.4,290.7],[131,291.5],[128.7,292.3],[126.4,293],[124,293.6],[121.7,294.2],[119.4,294.7],[117,295.2],[114.7,295.6],[112.4,296],[110.1,296.3],[107.8,296.5],[105.5,296.7],[103.3,296.8],[101.1,296.9],[98.8,296.9],[83.1,295.7],[67.8,292],[53.3,285.9],[39.9,277.5],[28.1,267.2],[18,255.1],[10,241.5],[4.2,226.9],[.9,211.5],[0,195.8],[.1,192.9],[2.1,171.4],[7.2,148.8],[15.4,125.3],[26.6,100.8],[41,75.2],[58.4,49.3],[78.4,23.2],[98.9,0]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:e===this.activeHandle?G.toArray():o().toArray()}]}}],scaleSymbolsProportionally:!0,respectFrame:!0,clippingPath:{type:"CIMClippingPath",clippingType:"Intersect",path:{rings:[[[0,0],[197.7,0],[197.7,294.7],[0,294.7],[0,0]]]}},rotation:0}],haloSize:1,scaleX:1,angleAlignment:"Display",angle:0}}}),geometry:t.data.geometry}))),this._graphicsLayer.graphics.addMany([...this._controlPointGraphics]),this._controlPointManipulations=this._controlPointGraphics.map((e=>new _({tool:this,view:t,graphic:e}))),this.addHandles([...this._controlPointManipulations.map(((t,e)=>t.createDragPipeline(this._getInfo.bind(this,e),((t,i)=>{"start"===t.action&&(this._undoStack.push(e),this._redoStack=[],this._sharedUndoStack.push({tool:this,operation:i}),this._sharedRedoStack.length=0),this.updateGraphics()})))),n((()=>this.view.scale),(()=>this.active?this.updateGraphics():null))]),this._controlPointManipulations.forEach(((t,e)=>{const i=t=>{this.addHandles([t.events.on(["click","grab-changed"],(t=>this.updateActiveHandle(e)))])};t.forEachManipulator(i)})),this.addHandles([t.on("key-down",(i=>{t.activeTool===this&&(i.key!==S.shift||i.repeat||(this._isModifierActive=!0,i.stopPropagation()),i.key!==S.toggleOpacity||i.repeat||(e.opacity*=this._isOpacityToggled?2:.5,this._isOpacityToggled=!this._isOpacityToggled,i.stopPropagation()),i.key!==S.primaryKey||i.repeat||(this._factor=b,i.stopPropagation()),this._isModifierActive&&(i.key===S.up&&(this._move(0,this._factor),i.stopPropagation()),i.key===S.down&&(this._move(0,-this._factor),i.stopPropagation()),i.key===S.left&&(this._move(-this._factor,0),i.stopPropagation()),i.key===S.right&&(this._move(this._factor,0),i.stopPropagation())))})),t.on("key-up",(e=>{t.activeTool===this&&(e.key===S.shift&&(this._isModifierActive=!1,e.stopPropagation()),e.key===S.primaryKey&&(this._factor=k,e.stopPropagation()))}))]),t.map.addMany([this._graphicsLayer]),t.focus(),this.visible=!1,this.finishToolCreation())}destroy(){const{map:t}=this.view;this._controlPointManipulations.forEach((t=>t.destroy())),this._controlPointEditGeometryOperations.forEach((t=>t.destroy())),t.removeMany([this._graphicsLayer]),this._graphicsLayer.removeAll(),this._graphicsLayer=a(this._graphicsLayer),this._georeference=null,this._controlPointGraphics=null,this._controlPointManipulations=null,this._graphicsLayer=null,this._controlPointEditGeometryOperations=null,this._undoStack=null,this._redoStack=null,this._initialControlPoints=null,this._sharedUndoStack=null,this._sharedRedoStack=null}get _hasValidSpatialReference(){return p(this.view.spatialReference)}onActivate(){this.visible=!0}onDeactivate(){this.visible=!1}onShow(){this._graphicsLayer.visible=!0}onHide(){this._graphicsLayer.visible=!1}canUndo(){const t=this._undoStack[this._undoStack.length-1];return null!=t&&this._controlPointEditGeometryOperations[t].canUndo}canRedo(){const t=this._redoStack[this._redoStack.length-1];return null!=t&&this._controlPointEditGeometryOperations[t].canRedo}undo(){if(this._undoStack.length>0){const t=this._undoStack.pop();this._controlPointEditGeometryOperations[t].undo(),this.updateGraphics(),this._redoStack.push(t)}}redo(){if(this._redoStack.length>0){const t=this._redoStack.pop();this._controlPointEditGeometryOperations[t].redo(),this.updateGraphics(),this._undoStack.push(t)}}refresh(){const{mediaElement:t}=this;if(r(t.georeference))return;const e=t.georeference;"control-points"!==e.type||r(e.coords)||(this._georeference=e,s(this._georeference.controlPoints).forEach((({mapPoint:t},e)=>{const i=this._controlPointEditGeometryOperations[e],o=i.data.components[0].vertices[0];i.setVertexPosition(o,i.data.coordinateHelper.pointToVector(t))})),this.updateGraphics())}reset(){this._georeference.controlPoints=this._initialControlPoints,this.refresh(),this._sharedUndoStack.length=0,this._sharedRedoStack.length=0}updateGraphics(){const t=this._georeference,e=s(t.controlPoints),i=s(e[0].mapPoint).spatialReference,o=this._hasValidSpatialReference;this._georeference.controlPoints=this._controlPointEditGeometryOperations.map(((r,a)=>{const n=r.data.geometry;return this._controlPointGraphics[a].geometry=n,{mapPoint:l(n,i),sourcePoint:o?s(e[a]).sourcePoint:t.toSource(n)}}))}updateActiveHandle(t){if(this.activeHandle===t)return;const e=s(this._controlPointGraphics[this.activeHandle].symbol).clone();m(e,o()),this._controlPointGraphics[this.activeHandle].symbol=e;const i=s(this._controlPointGraphics[t].symbol).clone();m(i,G),this._controlPointGraphics[t].symbol=i,this.activeHandle=t,this.view.surface===document.activeElement&&this.highlightActiveHandle()}async highlightActiveHandle(){this.removeHighlightActiveHandle();const t=await this.view.whenLayerView(this._graphicsLayer);this._highlightHandle=t.highlight(this._controlPointGraphics[this.activeHandle])}removeHighlightActiveHandle(){this._highlightHandle&&this._highlightHandle.remove()}setSharedUndoStack(t){this._sharedUndoStack=t}setSharedRedoStack(t){this._sharedRedoStack=t}_getInfo(t){return{editGeometryOperations:this._controlPointEditGeometryOperations[t],constraints:this._hasValidSpatialReference?null:{xmin:0,ymin:0,xmax:this._georeference.width,ymax:this._georeference.height}}}_move(t,e){const i=this._controlPointEditGeometryOperations[this.activeHandle],o=[];for(const s of i.data.components)o.push(...s.vertices);const r=i.moveVertices(o,t*this.view.resolution,e*this.view.resolution,0,P.NEW_STEP);this._sharedUndoStack.push({tool:this,operation:r}),this._sharedRedoStack.length=0,this.updateGraphics()}};t([h()],M.prototype,"_hasValidSpatialReference",null),t([h()],M.prototype,"activeHandle",void 0),t([h({constructOnly:!0,nonNullable:!0})],M.prototype,"mediaElement",void 0),t([h({constructOnly:!0})],M.prototype,"view",void 0),M=t([c("esri.views.2d.interactive.editingTools.ControlPointsTransformTool")],M);export{M as ControlPointsTransformTool,S as KEYS};
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import i from"../../../../Graphic.js";import"../../../../symbols.js";import{getAccentColor as o}from"../../../../core/analysisThemeUtils.js";import{destroyMaybe as r,isNone as s,unwrap as a}from"../../../../core/maybe.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{project as l,initializeProjection as p}from"../../../../geometry/projection.js";import{isValid as d}from"../../../../geometry/support/spatialReferenceUtils.js";import m from"../../../../layers/GraphicsLayer.js";import{applyCIMSymbolColor as y}from"../../../../symbols/support/cimSymbolUtils.js";import{ViewingMode as _}from"../../../ViewingMode.js";import{DragManipulation as g}from"./manipulations/DragManipulation.js";import{primaryKey as f}from"../../../input/keys.js";import{InteractiveToolBase as u}from"../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as P}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as v}from"../../../interactive/editGeometry/interfaces.js";import S from"../../../../symbols/CIMSymbol.js";const k={up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",toggleOpacity:"t",shift:"Shift",primaryKey:f},b=1,G=10,M=new e("#009AF2");let w=class extends u{constructor(t){super(t),this._isOpacityToggled=!1,this._isModifierActive=!1,this._factor=1,this._initialControlPoints=null,this._graphicsLayer=new m({internal:!0,listMode:"hide",visible:!1,effect:"drop-shadow(0px, 0px, 3px)"}),this._undoStack=[],this._redoStack=[],this._sharedUndoStack=[],this._sharedRedoStack=[],this._highlightHandle=null,this.activeHandle=0}initialize(){this._initialize()}destroy(){const{map:t}=this.view;this._controlPointManipulations.forEach((t=>t.destroy())),this._controlPointEditGeometryOperations.forEach((t=>t.destroy())),t.removeMany([this._graphicsLayer]),this._graphicsLayer.removeAll(),this._graphicsLayer=r(this._graphicsLayer),this._georeference=null,this._controlPointGraphics=null,this._controlPointManipulations=null,this._graphicsLayer=null,this._controlPointEditGeometryOperations=null,this._undoStack=null,this._redoStack=null,this._initialControlPoints=null,this._sharedUndoStack=null,this._sharedRedoStack=null}get _hasValidSpatialReference(){return d(this.view.spatialReference)}onActivate(){this.visible=!0}onDeactivate(){this.visible=!1}onShow(){this._graphicsLayer.visible=!0}onHide(){this._graphicsLayer.visible=!1}canUndo(){const t=this._undoStack[this._undoStack.length-1];return null!=t&&this._controlPointEditGeometryOperations[t].canUndo}canRedo(){const t=this._redoStack[this._redoStack.length-1];return null!=t&&this._controlPointEditGeometryOperations[t].canRedo}undo(){if(this._undoStack.length>0){const t=this._undoStack.pop();this._controlPointEditGeometryOperations[t].undo(),this.updateGraphics(),this._redoStack.push(t)}}redo(){if(this._redoStack.length>0){const t=this._redoStack.pop();this._controlPointEditGeometryOperations[t].redo(),this.updateGraphics(),this._undoStack.push(t)}}refresh(){const{mediaElement:t}=this;if(s(t.georeference))return;const e=t.georeference;"control-points"!==e.type||s(e.coords)||(this._georeference=e,a(this._georeference.controlPoints).forEach((({mapPoint:t},e)=>{const i=this._controlPointEditGeometryOperations[e],o=i.data.components[0].vertices[0];i.setVertexPosition(o,i.data.coordinateHelper.pointToVector(t))})),this.updateGraphics())}reset(){this._georeference.controlPoints=this._initialControlPoints,this.refresh(),this._sharedUndoStack.length=0,this._sharedRedoStack.length=0}updateGraphics(){const t=this._georeference,e=a(t.controlPoints),i=a(e[0].mapPoint).spatialReference,o=this._hasValidSpatialReference;this._georeference.controlPoints=this._controlPointEditGeometryOperations.map(((r,s)=>{const n=r.data.geometry;return this._controlPointGraphics[s].geometry=n,{mapPoint:l(n,i),sourcePoint:o?a(e[s]).sourcePoint:t.toSource(n)}}))}updateActiveHandle(t){if(this.activeHandle===t)return;const e=a(this._controlPointGraphics[this.activeHandle].symbol).clone();y(e,o()),this._controlPointGraphics[this.activeHandle].symbol=e;const i=a(this._controlPointGraphics[t].symbol).clone();y(i,M),this._controlPointGraphics[t].symbol=i,this.activeHandle=t,this.view.surface===document.activeElement&&this.highlightActiveHandle()}async highlightActiveHandle(){this.removeHighlightActiveHandle();const t=await this.view.whenLayerView(this._graphicsLayer);this._highlightHandle=t.highlight(this._controlPointGraphics[this.activeHandle])}removeHighlightActiveHandle(){this._highlightHandle&&this._highlightHandle.remove()}setSharedUndoStack(t){this._sharedUndoStack=t}setSharedRedoStack(t){this._sharedRedoStack=t}async _initialize(){const{view:t,mediaElement:e}=this;if(s(e.georeference))return;const r=e.georeference;"control-points"!==r.type||s(r.coords)||(this._georeference=r,this._initialControlPoints=a(this._georeference.controlPoints),t.map.addMany([this._graphicsLayer]),t.focus(),this.visible=!1,this.finishToolCreation(),await this._loadProjectionEngine(),this._controlPointEditGeometryOperations=a(this._georeference.controlPoints).map((({mapPoint:e})=>P.fromGeometry(l(e,t.spatialReference),_.Local))),this._controlPointGraphics=this._controlPointEditGeometryOperations.map(((t,e)=>new i({symbol:new S({data:{type:"CIMSymbolReference",symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,colorLocked:!0,anchorPoint:{x:0,y:-15.75},anchorPointUnits:"Absolute",dominantSizeAxis3D:"Y",size:9,billboardMode3D:"FaceNearPlane",frame:{xmin:0,ymin:0,xmax:84.3,ymax:84.3},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[83.2,32.5],[84.3,40.7],[83.8,48.9],[81.7,56.9],[78.1,64.3],[73,70.9],[66.9,76.4],[59.7,80.5],[51.9,83.2],[43.7,84.3],[35.4,83.8],[27.4,81.7],[20,78],[13.4,73],[7.9,66.8],[3.8,59.7],[1.1,51.9],[0,43.7],[.5,35.4],[2.6,27.4],[6.3,20],[11.3,13.4],[17.5,7.9],[24.7,3.8],[32.5,1.1],[39.8,.1],[47.1,.3],[54.3,1.8],[61.1,4.5],[67.4,8.4],[72.9,13.3],[77.4,19.1],[80.9,25.5],[83.2,32.5]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]}}],scaleSymbolsProportionally:!0,respectFrame:!0,clippingPath:{type:"CIMClippingPath",clippingType:"Intersect",path:{rings:[[[0,0],[84.3,0],[84.3,84.3],[0,84.3],[0,0]]]}},rotation:0},{type:"CIMVectorMarker",enable:!0,anchorPoint:{x:0,y:-11.25},anchorPointUnits:"Absolute",dominantSizeAxis3D:"Y",size:22.5,billboardMode3D:"FaceNearPlane",frame:{xmin:0,ymin:0,xmax:197.7,ymax:294.7},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[98.9,0],[119.4,23.2],[139.4,49.3],[156.8,75.2],[171.2,100.8],[182.4,125.3],[190.6,148.8],[195.7,171.4],[197.7,192.9],[197.7,195.8],[197.7,200.3],[197.6,202.5],[197.5,204.8],[197.3,207.1],[197,209.4],[196.7,211.7],[196.4,214.1],[196,216.4],[195.5,218.7],[195,221.1],[194.4,223.4],[193.7,225.8],[193,228.1],[192.2,230.5],[191.4,232.8],[190.5,235.1],[189.5,237.5],[188.5,239.7],[187.4,242],[186.2,244.3],[185,246.5],[183.7,248.7],[182.4,250.9],[181,253.1],[179.5,255.2],[178,257.3],[176.4,259.4],[174.7,261.4],[173.1,263.3],[171.3,265.3],[169.5,267.2],[167.7,269],[165.8,270.8],[163.9,272.5],[161.9,274.2],[159.9,275.8],[157.8,277.4],[155.7,278.9],[153.6,280.4],[151.4,281.7],[149.2,283.1],[147,284.4],[144.8,285.6],[142.5,286.7],[140.3,287.8],[138,288.8],[135.7,289.8],[133.4,290.7],[131,291.5],[128.7,292.3],[126.4,293],[124,293.6],[121.7,294.2],[119.4,294.7],[117,295.2],[114.7,295.6],[112.4,296],[110.1,296.3],[107.8,296.5],[105.5,296.7],[103.3,296.8],[101.1,296.9],[98.8,296.9],[83.1,295.7],[67.8,292],[53.3,285.9],[39.9,277.5],[28.1,267.2],[18,255.1],[10,241.5],[4.2,226.9],[.9,211.5],[0,195.8],[.1,192.9],[2.1,171.4],[7.2,148.8],[15.4,125.3],[26.6,100.8],[41,75.2],[58.4,49.3],[78.4,23.2],[98.9,0]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:e===this.activeHandle?M.toArray():o().toArray()}]}}],scaleSymbolsProportionally:!0,respectFrame:!0,clippingPath:{type:"CIMClippingPath",clippingType:"Intersect",path:{rings:[[[0,0],[197.7,0],[197.7,294.7],[0,294.7],[0,0]]]}},rotation:0}],haloSize:1,scaleX:1,angleAlignment:"Display",angle:0}}}),geometry:t.data.geometry}))),this._graphicsLayer.graphics.addMany([...this._controlPointGraphics]),this._controlPointManipulations=this._controlPointGraphics.map((e=>new g({tool:this,view:t,graphic:e}))),this.addHandles([...this._controlPointManipulations.map(((t,e)=>t.createDragPipeline(this._getInfo.bind(this,e),((t,i)=>{"start"===t.action&&(this._undoStack.push(e),this._redoStack=[],this._sharedUndoStack.push({tool:this,operation:i}),this._sharedRedoStack.length=0),this.updateGraphics()})))),n((()=>this.view.scale),(()=>this.active?this.updateGraphics():null))]),this._controlPointManipulations.forEach(((t,e)=>{const i=t=>{this.addHandles([t.events.on(["click","grab-changed"],(t=>this.updateActiveHandle(e)))])};t.forEachManipulator(i)})),this.addHandles([t.on("key-down",(i=>{t.activeTool===this&&(i.key!==k.shift||i.repeat||(this._isModifierActive=!0,i.stopPropagation()),i.key!==k.toggleOpacity||i.repeat||(e.opacity*=this._isOpacityToggled?2:.5,this._isOpacityToggled=!this._isOpacityToggled,i.stopPropagation()),i.key!==k.primaryKey||i.repeat||(this._factor=G,i.stopPropagation()),this._isModifierActive&&(i.key===k.up&&(this._move(0,this._factor),i.stopPropagation()),i.key===k.down&&(this._move(0,-this._factor),i.stopPropagation()),i.key===k.left&&(this._move(-this._factor,0),i.stopPropagation()),i.key===k.right&&(this._move(this._factor,0),i.stopPropagation())))})),t.on("key-up",(e=>{t.activeTool===this&&(e.key===k.shift&&(this._isModifierActive=!1,e.stopPropagation()),e.key===k.primaryKey&&(this._factor=b,e.stopPropagation()))}))]))}async _loadProjectionEngine(){const t=a(a(this._georeference.controlPoints)[0].mapPoint);return p(t.spatialReference,this.view.spatialReference)}_getInfo(t){return{editGeometryOperations:this._controlPointEditGeometryOperations[t],constraints:this._hasValidSpatialReference?null:{xmin:0,ymin:0,xmax:this._georeference.width,ymax:this._georeference.height}}}_move(t,e){const i=this._controlPointEditGeometryOperations[this.activeHandle],o=[];for(const s of i.data.components)o.push(...s.vertices);const r=i.moveVertices(o,t*this.view.resolution,e*this.view.resolution,0,v.NEW_STEP);this._sharedUndoStack.push({tool:this,operation:r}),this._sharedRedoStack.length=0,this.updateGraphics()}};t([c()],w.prototype,"_hasValidSpatialReference",null),t([c()],w.prototype,"activeHandle",void 0),t([c({constructOnly:!0,nonNullable:!0})],w.prototype,"mediaElement",void 0),t([c({constructOnly:!0})],w.prototype,"view",void 0),w=t([h("esri.views.2d.interactive.editingTools.ControlPointsTransformTool")],w);export{w as ControlPointsTransformTool,k as KEYS};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import e from"../../../../Graphic.js";import"../../../../symbols.js";import{getAccentColor as i,getContrastColor as s}from"../../../../core/analysisThemeUtils.js";import{unwrap as o,isSome as r,destroyMaybe as a}from"../../../../core/maybe.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as h}from"../../../../core/unitUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as l,f as _}from"../../../../chunks/vec2.js";import{a as m,U as d}from"../../../../chunks/vec2f64.js";import{g as y,l as u,n as g,a as f,h as v,b as G}from"../../../../chunks/vec3.js";import{c as w}from"../../../../chunks/vec3f64.js";import{project as R}from"../../../../geometry/projection.js";import{a as b,c as k}from"../../../../chunks/boundedPlane.js";import{equals as j}from"../../../../geometry/support/spatialReferenceUtils.js";import P from"../../../../layers/GraphicsLayer.js";import{ViewingMode as A}from"../../../ViewingMode.js";import{DragManipulation as C}from"./manipulations/DragManipulation.js";import{RotateManipulation as S}from"./manipulations/RotateManipulation.js";import{ScaleManipulation as M}from"./manipulations/ScaleManipulation.js";import{PreserveAspectRatio as T,SnapRotation as O}from"./manipulations/utils.js";import{primaryKey as U}from"../../../input/keys.js";import{InteractiveToolBase as D}from"../../../interactive/InteractiveToolBase.js";import{EditGeometry as x}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as E}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as L}from"../../../interactive/editGeometry/interfaces.js";import{AccumulationType as B}from"../../../interactive/editGeometry/operations/UpdateVertices.js";import{calculateOrientedBounds as H}from"../../../interactive/editGeometry/support/editPlaneUtils.js";import{findFirstGraphicHit as V}from"../../../support/hitTestSelectUtils.js";import{createScreenPointFromEvent as I}from"../../../support/screenUtils.js";import K from"../../../../symbols/SimpleFillSymbol.js";import N from"../../../../symbols/SimpleMarkerSymbol.js";import z from"../../../../geometry/Polygon.js";import W from"../../../../geometry/Point.js";const q={up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",plus:"+",minus:"-",toggleOpacity:"t",shift:"Shift",primaryKey:U},F=80,J=10,Q=30,X=[[1,1],[1,-1],[-1,-1],[-1,1],[1,0],[0,-1],[-1,0],[0,1]],Y=1,Z=10;let $=class extends D{constructor(t){super(t),this._initialControlPoints=null,this._initialGeometry=null,this._graphic=null,this._planeCache=b(),this._displayPlaneCache=b(),this._mainAxisCache=m(),this._rotationHandleCache=w(),this._cornerA=w(),this._cornerB=w(),this._cornerC=w(),this._cornerD=w(),this._avgAB=w(),this._avgBC=w(),this._avgCD=w(),this._avgDA=w(),this._preserveAspectRatio=new T,this._snapRotation=new O,this._graphicsLayer=new P({internal:!0,listMode:"hide",visible:!1}),this._sharedUndoStack=[],this._sharedRedoStack=[],this._isOpacityToggled=!1,this._isModifierActive=!1,this._factor=1,this.preserveAspectRatio=null,this.snapRotation=null}initialize(){const{view:t,target:a}=this;if("georeference"in a){const t=o(a.georeference);this._graphic=new e({geometry:o(t.coords)}),this._initialControlPoints="control-points"===t.type?t.controlPoints:null}else this._graphic=a,this._initialGeometry=o(a.geometry);const h=this._graphic.geometry;this._editGeometryOperations=E.fromGeometry(R(h,t.spatialReference),A.Local),this._backgroundGraphic=new e({symbol:new K({color:"transparent",outline:{type:"simple-line",color:i(),width:2}}),geometry:this._backgroundGraphicGeometry}),this._rotateGraphic=new e({symbol:new N({color:s(),outline:{type:"simple-line",color:i(),width:1}}),geometry:this._rotateGraphicGeometry}),this._scaleGraphics=this._scaleGraphicGeometries.map((t=>new e({symbol:new N({size:6,style:"square",color:s(),outline:{type:"simple-line",color:i(),width:1}}),geometry:t}))),this._graphicsLayer.graphics.addMany([this._backgroundGraphic,this._rotateGraphic,...this._scaleGraphics]),this._dragManipulation=new C({tool:this,view:t,graphic:this._graphic}),this._rotateManipulation=new S({tool:this,view:t,graphic:this._rotateGraphic,snapRotation:this._snapRotation}),this._scaleManipulations=this._scaleGraphics.map(((e,i)=>new M({tool:this,view:t,graphic:e,direction:X[i],preserveAspectRatio:this._preserveAspectRatio}))),this.addHandles([this._dragManipulation.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)),this._rotateManipulation.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)),...this._scaleManipulations.map((t=>t.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)))),n((()=>this.view.scale),(()=>this.active?this.updateGraphics():null)),t.on("click",(async e=>{if(null!=t.activeTool&&t.activeTool!==this)return;const i=I(e),s=[];t.map.allLayers.forEach((t=>{"vector-tile"!==t.type&&"imagery"!==t.type||s.push(t)}));const o=await this.view.hitTest(i,{exclude:s}),n=o.results;if(0===n.length)t.activeTool=null;else{const e=V(o.results),i="georeference"in a,s=n.map((t=>"media"===t.type?t.element:null)).filter(Boolean),h=[...this._graphicsLayer.graphics,i?null:a].filter(Boolean);i&&s.includes(a)||r(e)&&h.includes(e.graphic)?null==t.activeTool&&(t.activeTool=this):t.activeTool=null}}))]);const p=t=>{this.addHandles(t.events.on("grab-changed",(t=>{"georeference"in a&&("start"===t.action?a.opacity*=.5:"end"===t.action&&(a.opacity*=2))})))};this._dragManipulation.forEachManipulator(p),this._rotateManipulation.forEachManipulator(p),this._scaleManipulations.forEach((t=>t.forEachManipulator(p))),this.addHandles([t.on("key-down",(e=>{t.activeTool===this&&(e.key!==q.shift||e.repeat||(null==this.preserveAspectRatio&&(this._preserveAspectRatio.enabled=!this._preserveAspectRatio.enabled),null==this.snapRotation&&(this._snapRotation.enabled=!this._snapRotation.enabled),this._isModifierActive=!0,e.stopPropagation()),e.key!==q.toggleOpacity||e.repeat||("georeference"in a&&(a.opacity*=this._isOpacityToggled?2:.5,this._isOpacityToggled=!this._isOpacityToggled),e.stopPropagation()),e.key!==q.primaryKey||e.repeat||(this._factor=Z,e.stopPropagation()),this._isModifierActive&&(e.key===q.plus&&(this._scale(this._factor),e.stopPropagation()),e.key===q.minus&&(this._scale(-this._factor),e.stopPropagation()),e.key===q.up&&(this._move(0,this._factor),e.stopPropagation()),e.key===q.down&&(this._move(0,-this._factor),e.stopPropagation()),e.key===q.left&&(this._move(-this._factor,0),e.stopPropagation()),e.key===q.right&&(this._move(this._factor,0),e.stopPropagation())))})),t.on("key-up",(e=>{t.activeTool===this&&(e.key===q.shift&&(null==this.preserveAspectRatio&&(this._preserveAspectRatio.enabled=!this._preserveAspectRatio.enabled),null==this.snapRotation&&(this._snapRotation.enabled=!this._snapRotation.enabled),this._isModifierActive=!1,e.stopPropagation()),e.key===q.primaryKey&&(this._factor=Y,e.stopPropagation()))}))]),t.map.addMany([this._graphicsLayer]),t.focus(),this.visible=!1,this.finishToolCreation()}destroy(){const{map:t}=this.view;this._dragManipulation.destroy(),this._rotateManipulation.destroy(),this._scaleManipulations.forEach((t=>t.destroy())),this._editGeometryOperations.destroy(),t.removeMany([this._graphicsLayer]),this._graphicsLayer.removeAll(),this._graphicsLayer=a(this._graphicsLayer),this._initialControlPoints=null,this._initialGeometry=null,this._graphic=null,this._preserveAspectRatio=null,this._snapRotation=null,this._planeCache=null,this._displayPlaneCache=null,this._rotationHandleCache=null,this._mainAxisCache=null,this._cornerA=null,this._cornerB=null,this._cornerC=null,this._cornerD=null,this._avgAB=null,this._avgBC=null,this._avgCD=null,this._avgDA=null,this._sharedUndoStack=null,this._sharedRedoStack=null}get _plane(){const t=this._graphic.geometry;if(!r(t))return null;const e=this._editGeometryOperations.data,i=e.components[0].edges[0],s=l(this._mainAxisCache,i.leftVertex.pos,i.rightVertex.pos);_(s,s);let o=F*this.view.resolution;const a=this.view.spatialReference;return j(a,t.spatialReference)&&(o*=h(a)/h(t.spatialReference)),H(s,e,o,this._planeCache)}get _displayPlane(){const t=this._plane;if(!t)return null;const e=this._displayPlaneCache;k(t,e);const i=J*this.view.resolution;return y(e.basis1,e.basis1,1+i/u(e.basis1)),y(e.basis2,e.basis2,1+i/u(e.basis2)),e}get _backgroundGraphicGeometry(){const t=this._displayPlane;if(!t)return null;const e=this.view.spatialReference;return this._updateDisplayPlaneConrers(t),new z({spatialReference:e,rings:[[this._cornerA,this._cornerB,this._cornerC,this._cornerD,this._cornerA]]})}get _rotateGraphicGeometry(){const t=this._plane;if(!t)return null;const e=this._rotationHandleCache;return g(e,t.basis1),y(e,e,Q*this.view.resolution),f(e,e,t.origin),f(e,e,t.basis1),new W({x:e[0],y:e[1],spatialReference:this.view.spatialReference})}get _scaleGraphicGeometries(){const t=this._displayPlane;if(!t)return[];const e=this.view.spatialReference;this._updateDisplayPlaneConrers(t);const{_cornerA:i,_cornerB:s,_cornerC:o,_cornerD:r}=this,a=v(this._avgAB,i,s,.5),n=v(this._avgBC,s,o,.5),h=v(this._avgCD,o,r,.5),p=v(this._avgDA,r,i,.5);return[new W({x:i[0],y:i[1],spatialReference:e}),new W({x:s[0],y:s[1],spatialReference:e}),new W({x:o[0],y:o[1],spatialReference:e}),new W({x:r[0],y:r[1],spatialReference:e}),new W({x:a[0],y:a[1],spatialReference:e}),new W({x:n[0],y:n[1],spatialReference:e}),new W({x:h[0],y:h[1],spatialReference:e}),new W({x:p[0],y:p[1],spatialReference:e})]}onActivate(){this.visible=!0}onDeactivate(){this.visible=!1}onShow(){this._graphicsLayer.visible=!0}onHide(){this._graphicsLayer.visible=!1}canUndo(){return this._editGeometryOperations.canUndo}canRedo(){return this._editGeometryOperations.canRedo}undo(){this._editGeometryOperations.undo(),this.updateGraphics()}redo(){this._editGeometryOperations.redo(),this.updateGraphics()}refresh(){const{view:t,target:e}=this,i="georeference"in e?o(o(e.georeference).coords):e.geometry,s=this._editGeometryOperations,r=s.data.components[0].vertices,a=x.fromGeometry(R(i,t.spatialReference),A.Local).components[0].vertices;r.forEach(((t,e)=>{s.setVertexPosition(t,a[e].pos)})),this.updateGraphics()}reset(){const{target:t}=this;if("georeference"in t){const e=o(t.georeference);"control-points"===e.type&&(e.controlPoints=this._initialControlPoints)}else t.geometry=this._initialGeometry;this.refresh(),this._sharedUndoStack.length=0,this._sharedRedoStack.length=0}updateGraphics(){const t=this._editGeometryOperations.data.geometry;if("georeference"in this.target){o(this.target.georeference).coords=t}this._graphic.geometry=t,this._backgroundGraphic.geometry=this._backgroundGraphicGeometry,this._rotateGraphic.geometry=this._rotateGraphicGeometry,this._scaleGraphicGeometries.forEach(((t,e)=>{this._scaleGraphics[e].geometry=t}))}setSharedUndoStack(t){this._sharedUndoStack=t}setSharedRedoStack(t){this._sharedRedoStack=t}_updateDisplayPlaneConrers(t){const{basis1:e,basis2:i,origin:s}=t,o=this._cornerA;f(o,s,e),f(o,o,i);const r=this._cornerB;f(r,s,e),G(r,r,i);const a=this._cornerC;G(a,s,e),G(a,a,i);const n=this._cornerD;G(n,s,e),f(n,n,i)}_getInfo(){return{editGeometryOperations:this._editGeometryOperations,plane:this._plane,displayPlane:this._displayPlane}}_updateGraphics(t,e){"start"===t.action&&(this._sharedUndoStack.push({tool:this,operation:e}),this._sharedRedoStack.length=0),this.updateGraphics()}_scale(t){const e=this._editGeometryOperations,i=[];for(const a of e.data.components)i.push(...a.vertices);const s=e.data.geometry.extent?.width,o=(s+t*this.view.resolution)/s,r=e.scaleVertices(i,this._plane.origin,d,o,o,L.NEW_STEP,B.REPLACE);this._sharedUndoStack.push({tool:this,operation:r}),this._sharedRedoStack.length=0,this.updateGraphics()}_move(t,e){const i=this._editGeometryOperations,s=[];for(const r of i.data.components)s.push(...r.vertices);const o=i.moveVertices(s,t*this.view.resolution,e*this.view.resolution,0,L.NEW_STEP);this._sharedUndoStack.push({tool:this,operation:o}),this._sharedRedoStack.length=0,this.updateGraphics()}};t([p()],$.prototype,"_plane",null),t([p()],$.prototype,"_backgroundGraphicGeometry",null),t([p()],$.prototype,"_rotateGraphicGeometry",null),t([p()],$.prototype,"_scaleGraphicGeometries",null),t([p()],$.prototype,"preserveAspectRatio",void 0),t([p()],$.prototype,"snapRotation",void 0),t([p({constructOnly:!0,nonNullable:!0})],$.prototype,"target",void 0),t([p({constructOnly:!0})],$.prototype,"view",void 0),$=t([c("esri.views.2d.interactive.editingTools.TransformTool")],$);export{q as KEYS,$ as TransformTool};
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import e from"../../../../Graphic.js";import"../../../../symbols.js";import{getAccentColor as i,getContrastColor as s}from"../../../../core/analysisThemeUtils.js";import{destroyMaybe as o,isSome as r,unwrap as a}from"../../../../core/maybe.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as h}from"../../../../core/unitUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as l,f as _}from"../../../../chunks/vec2.js";import{a as m,U as d}from"../../../../chunks/vec2f64.js";import{g as y,l as u,n as g,a as f,h as v,b as G}from"../../../../chunks/vec3.js";import{c as w}from"../../../../chunks/vec3f64.js";import{project as R,initializeProjection as b}from"../../../../geometry/projection.js";import{a as k,c as j}from"../../../../chunks/boundedPlane.js";import{equals as P}from"../../../../geometry/support/spatialReferenceUtils.js";import A from"../../../../layers/GraphicsLayer.js";import{ViewingMode as C}from"../../../ViewingMode.js";import{DragManipulation as S}from"./manipulations/DragManipulation.js";import{RotateManipulation as M}from"./manipulations/RotateManipulation.js";import{ScaleManipulation as T}from"./manipulations/ScaleManipulation.js";import{PreserveAspectRatio as O,SnapRotation as U}from"./manipulations/utils.js";import{primaryKey as D}from"../../../input/keys.js";import{InteractiveToolBase as x}from"../../../interactive/InteractiveToolBase.js";import{EditGeometry as E}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as L}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as B}from"../../../interactive/editGeometry/interfaces.js";import{AccumulationType as H}from"../../../interactive/editGeometry/operations/UpdateVertices.js";import{calculateOrientedBounds as V}from"../../../interactive/editGeometry/support/editPlaneUtils.js";import{findFirstGraphicHit as I}from"../../../support/hitTestSelectUtils.js";import{createScreenPointFromEvent as z}from"../../../support/screenUtils.js";import K from"../../../../geometry/Polygon.js";import N from"../../../../geometry/Point.js";import W from"../../../../symbols/SimpleFillSymbol.js";import q from"../../../../symbols/SimpleMarkerSymbol.js";const F={up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",plus:"+",minus:"-",toggleOpacity:"t",shift:"Shift",primaryKey:D},J=80,Q=10,X=30,Y=[[1,1],[1,-1],[-1,-1],[-1,1],[1,0],[0,-1],[-1,0],[0,1]],Z=1,$=10;let tt=class extends x{constructor(t){super(t),this._initialControlPoints=null,this._initialGeometry=null,this._graphic=null,this._planeCache=k(),this._displayPlaneCache=k(),this._mainAxisCache=m(),this._rotationHandleCache=w(),this._cornerA=w(),this._cornerB=w(),this._cornerC=w(),this._cornerD=w(),this._avgAB=w(),this._avgBC=w(),this._avgCD=w(),this._avgDA=w(),this._preserveAspectRatio=new O,this._snapRotation=new U,this._graphicsLayer=new A({internal:!0,listMode:"hide",visible:!1}),this._sharedUndoStack=[],this._sharedRedoStack=[],this._isOpacityToggled=!1,this._isModifierActive=!1,this._factor=1,this.preserveAspectRatio=null,this.snapRotation=null}initialize(){this._initialize()}destroy(){const{map:t}=this.view;this._dragManipulation.destroy(),this._rotateManipulation.destroy(),this._scaleManipulations.forEach((t=>t.destroy())),this._editGeometryOperations.destroy(),t.removeMany([this._graphicsLayer]),this._graphicsLayer.removeAll(),this._graphicsLayer=o(this._graphicsLayer),this._initialControlPoints=null,this._initialGeometry=null,this._graphic=null,this._preserveAspectRatio=null,this._snapRotation=null,this._planeCache=null,this._displayPlaneCache=null,this._rotationHandleCache=null,this._mainAxisCache=null,this._cornerA=null,this._cornerB=null,this._cornerC=null,this._cornerD=null,this._avgAB=null,this._avgBC=null,this._avgCD=null,this._avgDA=null,this._sharedUndoStack=null,this._sharedRedoStack=null}get _plane(){const t=this._graphic.geometry;if(!r(t))return null;const e=this._editGeometryOperations.data,i=e.components[0].edges[0],s=l(this._mainAxisCache,i.leftVertex.pos,i.rightVertex.pos);_(s,s);let o=J*this.view.resolution;const a=this.view.spatialReference;return P(a,t.spatialReference)&&(o*=h(a)/h(t.spatialReference)),V(s,e,o,this._planeCache)}get _displayPlane(){const t=this._plane;if(!t)return null;const e=this._displayPlaneCache;j(t,e);const i=Q*this.view.resolution;return y(e.basis1,e.basis1,1+i/u(e.basis1)),y(e.basis2,e.basis2,1+i/u(e.basis2)),e}get _backgroundGraphicGeometry(){const t=this._displayPlane;if(!t)return null;const e=this.view.spatialReference;return this._updateDisplayPlaneConrers(t),new K({spatialReference:e,rings:[[this._cornerA,this._cornerB,this._cornerC,this._cornerD,this._cornerA]]})}get _rotateGraphicGeometry(){const t=this._plane;if(!t)return null;const e=this._rotationHandleCache;return g(e,t.basis1),y(e,e,X*this.view.resolution),f(e,e,t.origin),f(e,e,t.basis1),new N({x:e[0],y:e[1],spatialReference:this.view.spatialReference})}get _scaleGraphicGeometries(){const t=this._displayPlane;if(!t)return[];const e=this.view.spatialReference;this._updateDisplayPlaneConrers(t);const{_cornerA:i,_cornerB:s,_cornerC:o,_cornerD:r}=this,a=v(this._avgAB,i,s,.5),n=v(this._avgBC,s,o,.5),h=v(this._avgCD,o,r,.5),c=v(this._avgDA,r,i,.5);return[new N({x:i[0],y:i[1],spatialReference:e}),new N({x:s[0],y:s[1],spatialReference:e}),new N({x:o[0],y:o[1],spatialReference:e}),new N({x:r[0],y:r[1],spatialReference:e}),new N({x:a[0],y:a[1],spatialReference:e}),new N({x:n[0],y:n[1],spatialReference:e}),new N({x:h[0],y:h[1],spatialReference:e}),new N({x:c[0],y:c[1],spatialReference:e})]}onActivate(){this.visible=!0}onDeactivate(){this.visible=!1}onShow(){this._graphicsLayer.visible=!0}onHide(){this._graphicsLayer.visible=!1}canUndo(){return this._editGeometryOperations.canUndo}canRedo(){return this._editGeometryOperations.canRedo}undo(){this._editGeometryOperations.undo(),this.updateGraphics()}redo(){this._editGeometryOperations.redo(),this.updateGraphics()}refresh(){const{view:t,target:e}=this,i="georeference"in e?a(a(e.georeference).coords):e.geometry,s=this._editGeometryOperations,o=s.data.components[0].vertices,r=E.fromGeometry(R(i,t.spatialReference),C.Local).components[0].vertices;o.forEach(((t,e)=>{s.setVertexPosition(t,r[e].pos)})),this.updateGraphics()}reset(){const{target:t}=this;if("georeference"in t){const e=a(t.georeference);"control-points"===e.type&&(e.controlPoints=this._initialControlPoints)}else t.geometry=this._initialGeometry;this.refresh(),this._sharedUndoStack.length=0,this._sharedRedoStack.length=0}updateGraphics(){const t=this._editGeometryOperations.data.geometry;if("georeference"in this.target){a(this.target.georeference).coords=t}this._graphic.geometry=t,this._backgroundGraphic.geometry=this._backgroundGraphicGeometry,this._rotateGraphic.geometry=this._rotateGraphicGeometry,this._scaleGraphicGeometries.forEach(((t,e)=>{this._scaleGraphics[e].geometry=t}))}setSharedUndoStack(t){this._sharedUndoStack=t}setSharedRedoStack(t){this._sharedRedoStack=t}async _initialize(){const{view:t,target:o}=this;if("georeference"in o){const t=a(o.georeference);this._graphic=new e({geometry:a(t.coords)}),this._initialControlPoints="control-points"===t.type?t.controlPoints:null}else this._graphic=o,this._initialGeometry=a(o.geometry);t.map.addMany([this._graphicsLayer]),t.focus(),this.visible=!1,this.finishToolCreation(),await this._loadProjectionEngine(),this._editGeometryOperations=L.fromGeometry(R(this._graphic.geometry,t.spatialReference),C.Local),this._backgroundGraphic=new e({symbol:new W({color:"transparent",outline:{type:"simple-line",color:i(),width:2}}),geometry:this._backgroundGraphicGeometry}),this._rotateGraphic=new e({symbol:new q({color:s(),outline:{type:"simple-line",color:i(),width:1}}),geometry:this._rotateGraphicGeometry}),this._scaleGraphics=this._scaleGraphicGeometries.map((t=>new e({symbol:new q({size:6,style:"square",color:s(),outline:{type:"simple-line",color:i(),width:1}}),geometry:t}))),this._graphicsLayer.graphics.addMany([this._backgroundGraphic,this._rotateGraphic,...this._scaleGraphics]),this._dragManipulation=new S({tool:this,view:t,graphic:this._graphic}),this._rotateManipulation=new M({tool:this,view:t,graphic:this._rotateGraphic,snapRotation:this._snapRotation}),this._scaleManipulations=this._scaleGraphics.map(((e,i)=>new T({tool:this,view:t,graphic:e,direction:Y[i],preserveAspectRatio:this._preserveAspectRatio}))),this.addHandles([this._dragManipulation.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)),this._rotateManipulation.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)),...this._scaleManipulations.map((t=>t.createDragPipeline(this._getInfo.bind(this),this._updateGraphics.bind(this)))),n((()=>this.view.scale),(()=>this.active?this.updateGraphics():null)),t.on("click",(async e=>{if(null!=t.activeTool&&t.activeTool!==this)return;const i=z(e),s=[];t.map.allLayers.forEach((t=>{"vector-tile"!==t.type&&"imagery"!==t.type||s.push(t)}));const a=await this.view.hitTest(i,{exclude:s}),n=a.results;if(0===n.length)t.activeTool=null;else{const e=I(a.results),i="georeference"in o,s=n.map((t=>"media"===t.type?t.element:null)).filter(Boolean),h=[...this._graphicsLayer.graphics,i?null:o].filter(Boolean);i&&s.includes(o)||r(e)&&h.includes(e.graphic)?null==t.activeTool&&(t.activeTool=this):t.activeTool=null}}))]);const h=t=>{this.addHandles(t.events.on("grab-changed",(t=>{"georeference"in o&&("start"===t.action?o.opacity*=.5:"end"===t.action&&(o.opacity*=2))})))};this._dragManipulation.forEachManipulator(h),this._rotateManipulation.forEachManipulator(h),this._scaleManipulations.forEach((t=>t.forEachManipulator(h))),this.addHandles([t.on("key-down",(e=>{t.activeTool===this&&(e.key!==F.shift||e.repeat||(null==this.preserveAspectRatio&&(this._preserveAspectRatio.enabled=!this._preserveAspectRatio.enabled),null==this.snapRotation&&(this._snapRotation.enabled=!this._snapRotation.enabled),this._isModifierActive=!0,e.stopPropagation()),e.key!==F.toggleOpacity||e.repeat||("georeference"in o&&(o.opacity*=this._isOpacityToggled?2:.5,this._isOpacityToggled=!this._isOpacityToggled),e.stopPropagation()),e.key!==F.primaryKey||e.repeat||(this._factor=$,e.stopPropagation()),this._isModifierActive&&(e.key===F.plus&&(this._scale(this._factor),e.stopPropagation()),e.key===F.minus&&(this._scale(-this._factor),e.stopPropagation()),e.key===F.up&&(this._move(0,this._factor),e.stopPropagation()),e.key===F.down&&(this._move(0,-this._factor),e.stopPropagation()),e.key===F.left&&(this._move(-this._factor,0),e.stopPropagation()),e.key===F.right&&(this._move(this._factor,0),e.stopPropagation())))})),t.on("key-up",(e=>{t.activeTool===this&&(e.key===F.shift&&(null==this.preserveAspectRatio&&(this._preserveAspectRatio.enabled=!this._preserveAspectRatio.enabled),null==this.snapRotation&&(this._snapRotation.enabled=!this._snapRotation.enabled),this._isModifierActive=!1,e.stopPropagation()),e.key===F.primaryKey&&(this._factor=Z,e.stopPropagation()))}))])}async _loadProjectionEngine(){const t=a(this._graphic.geometry);return b(t.spatialReference,this.view.spatialReference)}_updateDisplayPlaneConrers(t){const{basis1:e,basis2:i,origin:s}=t,o=this._cornerA;f(o,s,e),f(o,o,i);const r=this._cornerB;f(r,s,e),G(r,r,i);const a=this._cornerC;G(a,s,e),G(a,a,i);const n=this._cornerD;G(n,s,e),f(n,n,i)}_getInfo(){return{editGeometryOperations:this._editGeometryOperations,plane:this._plane,displayPlane:this._displayPlane}}_updateGraphics(t,e){"start"===t.action&&(this._sharedUndoStack.push({tool:this,operation:e}),this._sharedRedoStack.length=0),this.updateGraphics()}_scale(t){const e=this._editGeometryOperations,i=[];for(const a of e.data.components)i.push(...a.vertices);const s=e.data.geometry.extent?.width,o=(s+t*this.view.resolution)/s,r=e.scaleVertices(i,this._plane.origin,d,o,o,B.NEW_STEP,H.REPLACE);this._sharedUndoStack.push({tool:this,operation:r}),this._sharedRedoStack.length=0,this.updateGraphics()}_move(t,e){const i=this._editGeometryOperations,s=[];for(const r of i.data.components)s.push(...r.vertices);const o=i.moveVertices(s,t*this.view.resolution,e*this.view.resolution,0,B.NEW_STEP);this._sharedUndoStack.push({tool:this,operation:o}),this._sharedRedoStack.length=0,this.updateGraphics()}};t([c()],tt.prototype,"_plane",null),t([c()],tt.prototype,"_backgroundGraphicGeometry",null),t([c()],tt.prototype,"_rotateGraphicGeometry",null),t([c()],tt.prototype,"_scaleGraphicGeometries",null),t([c()],tt.prototype,"preserveAspectRatio",void 0),t([c()],tt.prototype,"snapRotation",void 0),t([c({constructOnly:!0,nonNullable:!0})],tt.prototype,"target",void 0),t([c({constructOnly:!0})],tt.prototype,"view",void 0),tt=t([p("esri.views.2d.interactive.editingTools.TransformTool")],tt);export{F as KEYS,tt as TransformTool};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{isSome as r}from"../../../../core/maybe.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as i}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as o}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as a}from"../support/util.js";let n=class extends o{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new i(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&a(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const{rasterFunction:
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{isSome as r}from"../../../../core/maybe.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as i}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as o}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as a}from"../support/util.js";let n=class extends o{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new i(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&a(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:o}=e,a=i.supportsGPU&&(!o||o.rasters.length<=1),n=a?i.getFlatWebGLFunctionChain():null,{renderer:l}=this.layer,c=!a||!n?.functions.length||"raster-stretch"===l.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();t.rasterFunctionChain=c?null:n;const u=null==i?"na":t.rasterFunctionChain?"gpu":"cpu";t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=s!==u,r.processed=!1,r.processedTexture=null)})),this._rasterFunctionState=u}async updateTileSource(e,t){const s=this._getBandIds(),i=this._getLayerInterpolation(),o=this.canUseWebGLForProcessing(),{source:a,globalSymbolizerParams:n,suspended:l,coords:c,resolution:u}=t,p=this.layerView.hasTilingEffects?n:t.symbolizerParams,{bitmap:d}=e;if([d.x,d.y]=c,d.resolution=u,a&&r(a)&&r(a.pixelBlock)){const e={extent:a.extent,pixelBlock:a.pixelBlock};if(d.rawPixelData=e,o)d.source=a.pixelBlock,d.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===n?.type?n:void 0);d.source=r,d.isRendereredSource=!0}d.symbolizerParameters=o?p:null,o?d.transformGrid||(d.transformGrid=a.transformGrid):d.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();d.source=e,d.symbolizerParameters=o?p:null,d.transformGrid=null}d.bandIds=o?s:null,d.width=this._tileInfoView.tileInfo.size[0],d.height=this._tileInfoView.tileInfo.size[1],d.interpolation=i,d.suspended=l,d.invalidateTexture()}async updateTileSymbolizerParameters(e,t){const{local:s,global:i}=t,o=this._getBandIds(),a=this._getLayerInterpolation(),n=this.canUseWebGLForProcessing(),{bitmap:l}=e,{rawPixelData:c}=l;!n&&r(c)?(l.source=await this.layer.applyRenderer(c,"stretch"===i?.type?i:void 0),l.isRendereredSource=!0):(l.isRendereredSource&&r(c)&&(l.source=c.pixelBlock),l.isRendereredSource=!1),l.symbolizerParameters=n?this.layerView.hasTilingEffects?i:s:null,l.bandIds=n?o:null,l.interpolation=a,l.suspended=!1}_getLayerInterpolation(){const e=this.layer.renderer.type;if("raster-colormap"===e||"unique-value"===e||"class-breaks"===e)return"nearest";const{interpolation:r}=this.layer,{renderer:t}=this.layer;return"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===r||"cubic"===r?"bilinear":"nearest":r}};e([t()],n.prototype,"container",void 0),e([t()],n.prototype,"layer",void 0),e([t()],n.prototype,"type",void 0),n=e([s("esri.views.2d.layers.imagery.ImageryTileView2D")],n);const l=n;export{l as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s}from"../../../core/arrayUtils.js";import{ByteSizeUnit as r}from"../../../core/byteSizeEstimations.js";import o from"../../../core/Collection.js";import has from"../../../core/has.js";import a from"../../../core/Logger.js";import{someMap as n}from"../../../core/MapUtils.js";import{unwrapOr as l,destroyMaybe as d,isSome as h,isNone as c,applySome as u}from"../../../core/maybe.js";import _ from"../../../core/PooledArray.js";import{isAbortError as m,throwIfAborted as g,createResolver as p}from"../../../core/promiseUtils.js";import{initial as f,watch as b}from"../../../core/reactiveUtils.js";import{schedule as y}from"../../../core/scheduling.js";import{isArrayBuffer as v}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as I}from"../../../core/unitUtils.js";import{property as M}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as C}from"../../../core/accessorSupport/decorators/subclass.js";import{f as x}from"../../../chunks/mat3.js";import{c as O}from"../../../chunks/mat3f32.js";import{m as E,D as S}from"../../../chunks/mat4.js";import{b as j,c as w}from"../../../chunks/mat4f64.js";import{f as T}from"../../../chunks/quatf64.js";import{m as A,s as D,t as R,a as N,c as P,g as F,b as V}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{s as H}from"../../../chunks/vec4.js";import{f as G}from"../../../chunks/vec4f64.js";import{projectBuffer as L,getProjectorName as k,localLinearScaleFactors as B,projectVectorToVector as q,projectBoundingSphere as z}from"../../../geometry/projection.js";import{create as K,empty as W,expandWithBuffer as $,toRect as X}from"../../../geometry/support/aaBoundingBox.js";import{create as Y,intersects as Q}from"../../../geometry/support/aaBoundingRect.js";import{fallbackObjectIDAttribute as J}from"../../../layers/LayerConstants.js";import Z from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ee}from"../../../layers/support/fieldUtils.js";import te from"../../../layers/support/SceneModification.js";import{getColor as ie,getOpacity as se}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as re}from"../../../support/arcadeOnDemand.js";import oe from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as ae}from"../../../symbols/support/unitConversionUtils.js";import ne from"./I3SMeshViewLabeler.js";import{I3SMeshWorkerHandle as le,toWasmModification as de}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesReturnType as he,ForAllFeaturesVisibilityMode as ce}from"./II3SMeshView3D.js";import{initialize as ue,setModificationsSync as _e,filterObbsForModificationsSync as me,interpretObbModificationResults as ge}from"./SceneLayerWorker.js";import{overrideColor as pe}from"./graphics/graphicUtils.js";import{areLabelsVisible as fe}from"./graphics/Labeler.js";import{TextureUsage as be,TextureEncoding as ye}from"./i3s/enums.js";import ve from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Ie}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Me,NodeCrossfadeMetaData as Ce}from"./i3s/I3SCrossfadeHelper.js";import xe from"./i3s/I3SElevationProvider.js";import{boundingBoxCornerPoints as Oe}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ee}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Se,selectEncoding as je,defaultMaterial as we,createTexture as Te,configureMaterial as Ae}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as De,NodeState as Re}from"./i3s/I3SNode.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe,getLocalOrigin as Fe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ve,checkSceneLayerValid as Ue,checkSceneLayerCompatibleWithView as He,getCacheKeySuffix as Ge,whenGraphicAttributes as Le,computeVisibilityObb as ke,filterInPlace as Be,getCachedAttributeValue as qe,intersectBoundingRectWithMbs as ze,MbsIntersectResult as Ke,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Xe,getClipRect as Ye}from"./i3s/I3SUtil.js";import{IDBCache as Qe}from"./i3s/IDBCache.js";import{IDBMockCache as Je}from"./i3s/IDBMockCache.js";import{attributeLookup as Ze}from"./support/attributeUtils.js";import{ColorMixModeEnum as et}from"./support/symbolColorUtils.js";import tt from"../support/debugFlags.js";import{toBoundingRect as it}from"../support/extentUtils.js";import{create as st,clone as rt}from"../support/orientedBoundingBox.js";import{updatingProgress as ot}from"../support/updatingProperties.js";import{glLayout as at}from"../support/buffer/glUtil.js";import{State as nt}from"../webgl-engine/collections/Component/ComponentObject.js";import{createVertexBufferLayout as lt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as dt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as ht}from"../webgl-engine/lib/BasisUtil.js";import{newDoubleArray as ct}from"../webgl-engine/lib/DoubleArray.js";import{Transparency as ut}from"../webgl-engine/lib/edgeRendering/interfaces.js";const _t="esri.views.3d.layers.I3SMeshView3D",mt=a.getLogger(_t),gt=[1,1,1,1];class pt extends Ce{constructor(e,t,i,s,r,o,a){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.cachedMidsTerrainSR=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbology=null}}var ft;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(ft||(ft={}));const bt=19,yt=100*r.MEGABYTES,vt=t=>{let r=class extends t{constructor(...e){super(e),this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._idbCache=has("enable-feature:idb-mock-cache")?new Je:new Qe("esri-scenelayer-cache","geometries"),this._hasComponentData=!1,this._hasVertexColors=!1,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this._layerUrl="",this._cacheKeySuffix=null,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Me(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Ve(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?be.AllTexturesPBR:be.AllTextures:this._usePBR||this._hasLoadedPBRTextures?be.GeometryTexturesPBR:be.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=I(this.i3slayer.spatialReference),i=ae(e.unit);return l(e.offset,0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return{mode:Ut.Absolute,offset:0};const t=I(this.i3slayer.spatialReference),i=ae(e.unit),s=l(e.offset,0)*i/t;switch(e.mode){case"absolute-height":return{mode:Ut.Absolute,offset:s};case"relative-to-ground":return{mode:Ut.RelativeToGround,offset:s};case"on-the-ground":return{mode:Ut.OnTheGround,offset:0};default:return{mode:Ut.Absolute,offset:0}}}get supportedTextureEncodings(){return Se(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&ye.DDS_S3TC);return e&&t}initialize(){this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const e=this.view.resourceController,t=e.memoryController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:t}),this._worker=new le((t=>e.immediate.schedule(t))),this.addResolvingPromise(this._worker.promise);const i=this.i3slayer.store;this._worker.setLegacySchema(this.uid,i.defaultGeometrySchema),Ue(this.i3slayer),He(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new Z({layerView:this}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const s=i.defaultGeometrySchema;if(this._isIntegratedMesh||!s)this._hasComponentData=!1;else{const e=s.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(s?.vertexAttributes.color??null)&&(null==this.i3slayer.cachedDrawingInfo||!this.i3slayer.cachedDrawingInfo.color),this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const r=this.view.resourceController.memoryController.newCache(this.uid,(e=>this._deleteComponentObject(e)));this._memCache=r;const o=e=>h(this._controller.index)&&h(this._controller.index.rootNode)?this._controller.index.traverse(this._controller.index.rootNode,(t=>{const i=t.index,s=this._nodeId2Meta.get(i)||this._nodeId2MetaReloading.get(i);return e(t,h(s)?s.objectHandle:null)})):()=>{};this._intersectionHandler=new Ee({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:o}),this.updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this.updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new xe({layerView:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this.updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),f),this.updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this.updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this.updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),f),this.updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Ut.Absolute),((e,t)=>{e?this.handles.add(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Lt):t&&this.handles.remove(Lt)}),f),this.updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const a=()=>{this._reloadAll(),this.clearMemCache()};this.updatingHandles.add((()=>this.rendererTextureUsage),a),this.updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),a),this.updatingHandles.add((()=>this.suspended),(e=>this._suspendedChange(e)),f),this.updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),f),this.updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),f),this.updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),f),this.handles.add([b((()=>tt.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&tt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||tt.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),f),b((()=>tt.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),f)]),this._cacheKeySuffix=Ge(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>mt.warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.layerChanged(),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_memEstimateTextureAdded(e){const t=e.estimatedTexMemRequired;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(h(e)){const t=e.estimatedTexMemRequired;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}getUsedMemory(){let e=h(this._labeler)?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=h(t)?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=h(t)?t.node.memory:0)),e}getUnloadedMemory(){return(h(this._controller)?this._controller.unloadedMemoryEstimate:0)+(h(this._labeler)?this._labeler.unloadedMemoryEstimate:0)}ignoresMemoryFactor(){return!1}_labelingChanged(){if(!(fe(this.i3slayer)&&this._supportsLabeling))return void(h(this._labeler)&&(this._labeler.destroy(),this._labeler=null));if(h(this._labeler))return;const e=new ne({view:this.view,layer:this.i3slayer,collection:this._collection});this._nodeId2Meta.forEach((t=>h(t)&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=ue().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=de(this._layerClippingArea,this._modifications,t);_e({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new _:null;this._nodeId2Meta.forEach(((e,t)=>{c(e)?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):h(s)&&s.push(e.node)})),h(s)&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),h(s)&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==De.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),h(t)?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t)):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(h(this._modificationGraphics)&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!tt.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_suspendedChange(e){e?(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler)):(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(h(t)&&h(t.attributeInfo))return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(h(t)&&h(t.attributeInfo))return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);h(i)&&h(i.attributeInfo)&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);h(s)&&(await this.i3sOverrides.apply(s.featureIds,t,i),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{m(e)||mt.warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,h(this._labeler)&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){h(this._memCache)&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>h(t)&&e.push(t.node))),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return h(t)?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&ye.Basis)&&u(this.i3slayer.textureSetDefinitions,(e=>e.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))))&&ht()}_getVertexBufferLayout(e,t){const i={hasTexture:Tt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return at(lt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||J}_findGraphicNodeAndIndex(e){const t=Ze(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return n(this._nodeId2Meta,(e=>{if(c(e))return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(c(i))return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=Ze(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return c(i)?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(c(i)||null==i.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Oe(t,this._collection,s,ct(24)),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!L(r,o,0,r,a,0,8))return null;const n=W();return $(n,r,0,8),n}whenGraphicAttributes(e,t){return Le(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(h)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return c(t)||null==t.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${bt}/${e.id}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return h(this._memCache)?this._memCache.pop(this._getMemCacheKey(e.index)):null}deleteCachedGPUData(e){h(e)&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(c(this._memCache))return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(c(t))return!0;const s=je(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(c(r)||null==r.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e)),null):(this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=s.geometryObb),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&h(s.textureData)&&(s.byteSize=Rt(s.transformedGeometry,s.textureData),s.textureData.every(Dt)&&Nt(e,s)&&this._idbCache.put(this._getCacheKey(e),s).catch((t=>mt.warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),g(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return At(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(c(s))return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:a,transformedGeometry:n}=s,l=this._controller.crsIndex,d=this.view.renderSpatialReference,u=Pe(e.mbs,this.elevationOffset,l,d),_=st([r.center.x,r.center.y,r.center.z],[r.extents.x,r.extents.y,r.extents.z],T(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));A(_.center,_.center,u),this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=_),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a));const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:n,globalTrafo:u,geometryObb:_,byteSize:Rt(n,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Nt(e,m)){const t=h(m.textureData)?m.textureData.map((e=>Dt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e),{...m,textureData:t}).catch((t=>mt.warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}computeVisibilityObb(e){return ke(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let c=0;c<s.length;++c)r[c]=this._getVertexBufferLayout(s[c],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Fe(o,a,n),u=Pe(o,a,n,d),_=k(n,l),m=k(l,d);if(c(_)||c(m))return Promise.resolve(null);const g={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:u,mbs:o,obb:e.serviceObb,elevationOffset:a,needNormals:!this._isIntegratedMesh&&this._controller.isMeshPyramid,normalReferenceFrame:this.i3slayer.normalReferenceFrame||"none",indexToVertexProjector:_,vertexToRenderProjector:m};return this._worker.invoke(g,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=rt(this._collection.getComponentObb(t.objectHandle))),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);h(this._labeler)&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,nt.Visible),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Ut.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),h(this._treeDebugger)&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async _addCachedNodeData(e,t,i){if(this.suspended||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(c(t))return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.apply(r.featureIds,s.attributeInfo,i);const n=h(t.textureData)?t.textureData.filter((e=>h(e)&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>h(e)&&(e.encoding===ye.Basis||e.encoding===ye.KTX2)))&&await ht(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:u}=r,_=this._collection,m=d[0],{layout:g,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,v=this._materialParameters(m,g),I=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),M={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:v.geometryParams},positionData:{positions:b.data,indices:b.indices},indices:p,componentOffsets:I},C=m.transformation?j(m.transformation):w();E(C,a,C);const T=S(U(),C),A=x(O(),C),D=this.view.renderSpatialReference,R=this.view.basemapTerrain.spatialReference,N=U(),P=[1,1,1];B(T,D,P,R)||mt.errorOnce("Unsupported coordinate system for IM overlay"),q(T,D,N,R);const F=_.createObject({toMapSpace:G(N[0],N[1],P[0],P[1]),geometry:M,obb:t.geometryObb,transform:{position:T,rotationScale:A}}),V=v.geometryParams.textureCoordinates===dt.Atlas,{textures:H,texturePromise:L}=this._initMaterialAndTextures(F,v.material,n,V);e.memory+=this._memEstimateGeometryAdded(F),e.memory+=H.reduce(((e,t)=>e+(h(t)?this._memEstimateTextureAdded(t):0)),0);const k=!!v.material.hasParametersFromSource,z="blend"!==v.material.alphaMode&&v.material.metallicRoughness.baseColorFactor[3]>=1,K=new pt(e,u,F,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:k,isOpaque:z},H);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&be.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const W=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),L]).then((([t,s])=>(h(t)&&t.updateObjectVisibility(K.objectHandle,!1).catch((e=>It(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,K),i.meta=null,this.suspended)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(F,nt.Visible),h(t)&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>It(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=W!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const a=this._applyFiltersToNode(K);(s||h(t)&&(r||a||o))&&this._addOrUpdateEdgeRendering(K),h(this._labeler)&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Mt.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),h(this._treeDebugger)&&this._treeDebugger.update()}),i)))).catch((e=>{throw h(s.meta)&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){mt.error("Removing duplicated node");const t=this._nodeId2Meta.get(e);h(t)&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);h(t)&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Vt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t)}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this.elevationInfo,s=this.view.basemapTerrain,r=s.spatialReference,o=i.mode;if(c(t)||c(r)||o===Ut.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const n=Ht,l=Gt,d=o===Ut.OnTheGround,u=this.view.renderCoordsHelper,_=!!e.cachedMidsTerrainSR,m=e.featureIds.length;if(!_){e.cachedMidsTerrainSR=ct(3*m);const i=e.cachedMidsTerrainSR;for(let s=0;s<m;s++){this._collection.getComponentAabb(e.objectHandle,s,l,!0),D(n,(l[0]+l[3])/2,(l[1]+l[4])/2,l[2]),R(n,n,a.rotationScale),N(n,n,a.position);const o=3*s;i[o+2]=u.getAltitude(n),q(n,t,n,r),i[o+0]=n[0],i[o+1]=n[1]}}const g=e.cachedMidsTerrainSR,p=i.offset,f=e.elevationOffsets,b=(e,t)=>{const i=d?g[3*e+2]:0;f[e]=p+(h(t)?t-i:0)};s.getElevations(g,m,b)}_ensureElevationTask(){return h(this._elevationTask)||(this._elevationTask=new Ie(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return h(t)?t.filterInPlace((e=>h(this._nodeId2Meta.get(e)))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Ut.Absolute,s=!!t&&t!==e&&t.mode!==Ut.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){c(e)||(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),h(this._labeler)&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Mt.UPDATE))}_safeReschedule(e,t){return g(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=h(e.params.material)?e.params.material:we(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Tt(i);return{geometryParams:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Te(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Ae(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:a}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?dt.Atlas:dt.Default:dt.None,colors:this._hasVertexColors,normals:e.hasNormals&&!this._isIntegratedMesh}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...p(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{h(e.meta)&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Y();this._renderClippingArea=it(this.view.clippingArea,i,e)?i:null;const s=Y();this._layerClippingArea=it(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{h(e)&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Mt.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return h(t)&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(h(t)){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=h(t.attributeInfo)&&t.attributeInfo.attributeData;s.every((e=>e===n||d&&null!=d[e]))&&Be(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?qe(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return z(e.node.mbs,this._controller.crsIndex,wt,this.view.renderSpatialReference),ze(t,wt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Ct),X(Ct,xt),Q(i,xt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Ke.INSIDE)return;if(r===Ke.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(Ot,i,t.objectHandle);Be(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(c(i))return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:a}=this._getFilteredEdgeMaterials(e),n={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Vt(a,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,a,n,t).catch((e=>It(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>It(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>It(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,a,n).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>It(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(h(this._labeler)&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=0===t.getComponentCount(e.objectHandle).invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!i;if(this._updateCachedFilteredIds(e),e.filteredIds===e.featureIds)return!i;const s=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,s),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return h(i)&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=d(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),h(this._elevationTask)&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);c(s)?i.delete(e):(this._collection.setObjectVisibility(s.objectHandle,nt.Hidden),h(this._edgeView)&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>It(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Mt.REMOVE),h(this._labeler)&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),h(this._treeDebugger)&&this._treeDebugger.update())}_deleteComponentObject(e){if(h(this._edgeView)&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);h(i)&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===Re.Hole))}_invalidateAllSymbols(){this._rendererVersion=We(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await re()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:mt.warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&mt.error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(H(s.externalColor,t[r+0]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),h(this._stage.renderView.objectAndLayerIdRenderHelper)){const t=e.featureIds[i];this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid,this.layerPopupEnabled,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid})}s.externalColorMixMode=t[r+4]&(1<<ft.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<ft.CastShadows),s.pickable=0!=(t[r+4]&1<<ft.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e&&e.getSymbol(t,{arcade:this._arcade});if(!(i instanceof oe))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=$e(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=h(this._symbologyOverrideFields)&&this._symbologyOverrideFields.length>0?h(this._rendererFields)&&this._rendererFields.length>0?ee(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=h(e.attributeInfo)&&e.attributeInfo.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&h(this._symbologyFields)&&this._symbologyFields.length>0;let n=null,l=null;if(a&&h(this._symbologyFields)){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=new Uint8Array(5*e.featureIds.length));const d={color:St,castShadows:!0,pickable:!0,colorMixMode:et.Multiply,edgeMaterial:null},u=this.fullOpacity,_=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):u;let m=null,g=ut.OPAQUE,p=Xe,f=0;for(let b=0;b<e.featureIds.length;b++){if(null!=o&&(i[o]=e.featureIds[b]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=qe(l[e],b);const r=s?this._getSymbolInfo(s,t):null;let u=null,y=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=ie(this._colorVariable,t,{color:jt,arcade:this._arcade});e&&(u=St,u[0]=e.r/255,u[1]=e.g/255,u[2]=e.b/255,this._opacityVariable||null===e.a||(y=e.a))}this._opacityVariable&&(y=se(this._opacityVariable,t,{arcade:this._arcade}))}if(r&&r.material){const e=r.material;u=c(u)||c(y)?pe(u,y,e.color,e.alpha,gt,St):pe(u,y,null,null,gt,St)}if(c(u)&&(u=St,u[0]=1,u[1]=1,u[2]=1,u[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r&&r.material?r.material.colorMixMode:et.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,h(this._symbologyOverride)&&(d.color=u,this._symbologyOverride(t,d),u=d.color),h(d.edgeMaterial)){const t=u[3]<=0?ut.INVISIBLE:u[3]>=1&&(e.material.isOpaque||d.colorMixMode===et.Replace)?ut.OPAQUE:ut.TRANSPARENT;d.edgeMaterial===m&&t===g||(p={...d.edgeMaterial,opacity:_,objectTransparency:t},m=d.edgeMaterial,g=t),e.cachedEdgeMaterials[b]=p}else e.cachedEdgeMaterials[b]=Xe;e.cachedSymbology[f+0]=Math.round(255*u[0]),e.cachedSymbology[f+1]=Math.round(255*u[1]),e.cachedSymbology[f+2]=Math.round(255*u[2]),e.cachedSymbology[f+3]=Math.round(255*u[3]),e.cachedSymbology[f+4]=d.colorMixMode|+d.castShadows<<ft.CastShadows|+d.pickable<<ft.Pickable,f+=5}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Vt(t,this.fullOpacity);const i=e.filteredIds;if(c(i)){return{hasEdges:t.some((e=>e!==Xe)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?Xe:(r=r||t!==Xe,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{c(t)||(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Vt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Mt.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),h(this._labeler)&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{c(t)||(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{c(t)||this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return!this._isIntegratedMesh&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){h(this._edgeView)&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_forAllFeatures(e,t,i=ce.VISIBLE_ONLY){n(this._nodeId2Meta,(s=>{if(c(s))return!1;if(h(t)){switch(t(s)){case he.EXIT:return!0;case he.SKIP:return!1}}let r=he.CONTINUE;switch(i){case ce.ALL:r=this._forAllFeaturesOfNode(s,e);break;case ce.VISIBLE_ONLY:r=this._forVisibleFeaturesOfNode(s,e);break;case ce.ALL_IN_CLIPPING_AREA:r=this._forAllFeaturesOfNodeInClippingArea(s,e)}return r===he.EXIT}))}_forAllFeaturesOfNode(e,t){let i=he.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===he.EXIT)return i;return i}_forVisibleFeaturesOfNode(e,t){let i=he.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===he.CONTINUE))),i}_forAllFeaturesOfNodeInClippingArea(e,t){if(c(this._renderClippingArea))return this._forAllFeaturesOfNode(e,t);const i=this._boundingRectNodeTest(e,this._renderClippingArea);if(i===Ke.OUTSIDE)return he.CONTINUE;if(i===Ke.INSIDE)return this._forAllFeaturesOfNode(e,t);const s=he.CONTINUE,r=e.featureIds,o=e.objectHandle,a=Ye(this._renderClippingArea,this._collection.getObjectTransform(o));for(let n=0;n<r.length;n++){if(!this._boundingRectFeatureTest(e,n,a))continue;const i=t(r[n],n,e);if(i===he.EXIT)return i}return s}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=h(t.attributeInfo)&&t.attributeInfo.attributeData;if(h(s))for(const r of Object.keys(s))i[r]=qe(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){const t=this._highlights;if("number"==typeof e||e instanceof i?e=[e]:e instanceof o&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>Ze(s,e.attributes,r))),{set:a,handle:n}=t.acquireSet();return t.setFeatureIds(a,o),n}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=t.acquireSet();return t.setFeatureIds(s,i),r}}return Ft}resetHighlights(){d(this._highlights),this._highlights=new ve({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,ce.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._elevationProvider.objectChanged(e.node),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=y((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t))}get performanceInfo(){const e={displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null,index:0,nodes:this._nodeId2Meta.size,"Total GPU Memory Estimate":(this._gpuMemoryEstimate/1048576).toFixed(1)+"MB","Geometry Memory Estimate":(this._geoMemoryEstimate/1048576).toFixed(1)+"MB","Texture Memory Estimate":(this._texMemoryEstimate/1048576).toFixed(1)+"MB","Unloaded Memory Estimate":(this.getUnloadedMemory()/1048576).toFixed(1)+"MB"};return h(this._memCache)&&(e.MemCache=Math.round(100*this._memCache.hitRate)+"% hit"),this._controller&&(this._idbCacheEnabled&&(e.IDBCache=Math.round(100*this._idbCache.getHitRate())+"% hit"),this._controller.updateStats(e)),e}get test(){const e=this;return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),he.CONTINUE)),null,ce.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return h(e)?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(((t,i)=>e(i,t)))}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);h(s)&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);h(i)&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(c(this._edgeView)||!e.cachedEdgeMaterials)return;Vt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>It(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&h(this._layerClippingArea)||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Pt(e);if(h(s)){const t={context:i,buffer:s.buffer};me(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=ge(i);e.imModificationImpact=s,s!==De.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||h(this._labeler)&&this._labeler.updating||this._crossfadeHelper.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||h(this._elevationTask)&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(c(s))throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>{s(this._snappingSourcesTrackers,t)}};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(c(t))return;const s=this._controller.getRenderMbs(t.node);h(s)&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Ut.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=U(),n=U(),l=(e,t)=>{N(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),N(e,e,F(n,n,t)),V(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(!c(s))for(const r of this._snappingSourcesTrackers)t!==Mt.REMOVE&&t!==Mt.UPDATE||r.events.remove(i),t!==Mt.ADD&&t!==Mt.UPDATE||r.events.add(i,s)}};return e([M()],r.prototype,"_hasLoadedPBRTextures",void 0),e([M()],r.prototype,"_asyncModuleLoading",void 0),e([M()],r.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([M()],r.prototype,"view",void 0),e([M()],r.prototype,"i3slayer",void 0),e([M()],r.prototype,"_controller",void 0),e([M()],r.prototype,"_labeler",void 0),e([M()],r.prototype,"updating",void 0),e([M()],r.prototype,"suspended",void 0),e([M()],r.prototype,"holeFilling",void 0),e([M(ot)],r.prototype,"updatingProgress",void 0),e([M()],r.prototype,"updatingProgressValue",null),e([M()],r.prototype,"hasTexturesOrVertexColors",null),e([M()],r.prototype,"rendererTextureUsage",null),e([M()],r.prototype,"elevationOffset",null),e([M()],r.prototype,"elevationInfo",null),e([M({type:Boolean})],r.prototype,"slicePlaneEnabled",void 0),e([M()],r.prototype,"supportedTextureEncodings",null),e([M()],r.prototype,"uncompressedTextureDownsamplingEnabled",null),e([M({type:[te]})],r.prototype,"_modifications",void 0),e([M()],r.prototype,"_elevationTask",void 0),e([M({readOnly:!0})],r.prototype,"_usePBR",null),r=e([C(_t)],r),r};function It(e,t){m(e)||mt.warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Mt;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Mt||(Mt={}));const Ct=K(),xt=Y(),Ot=Y(),Et=st(),St=[0,0,0,0],jt=new t([0,0,0,0]),wt=[0,0,0,0];function Tt(e){if(c(e))return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function At(e){return"geometryData"in e}function Dt(e){return h(e)&&v(e.data)}function Rt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(h(t))for(const s of t)h(s)&&v(s.data)&&(i+=s.data.byteLength);return i}function Nt(e,t){return t.byteSize>yt?(mt.warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Pt(e){if(0===e.length)return null;const t=10*e.length,i=new Float64Array(t);return e.forAll(((e,t)=>{let s=e.serviceObb;c(s)&&(s=Et,P(s.center,e.mbs),s.halfSize[0]=s.halfSize[1]=s.halfSize[2]=e.mbs[3]);const r=10*t;i[r+0]=s.center[0],i[r+1]=s.center[1],i[r+2]=s.center[2],i[r+3]=s.halfSize[0],i[r+4]=s.halfSize[1],i[r+5]=s.halfSize[2],i[r+6]=s.quaternion[0],i[r+7]=s.quaternion[1],i[r+8]=s.quaternion[2],i[r+9]=s.quaternion[3]})),i}const Ft={remove(){},pause(){},resume(){}};function Vt(e,t){e.forEach((e=>e.opacity=t))}var Ut;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(Ut||(Ut={}));const Ht=U(),Gt=K(),Lt="elevation-change";export{Ut as ElevationMode,vt as I3SMeshView3D};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s}from"../../../core/arrayUtils.js";import{ByteSizeUnit as r}from"../../../core/byteSizeEstimations.js";import o from"../../../core/Collection.js";import has from"../../../core/has.js";import a from"../../../core/Logger.js";import{someMap as n}from"../../../core/MapUtils.js";import{unwrapOr as l,destroyMaybe as d,isSome as h,isNone as c,applySome as u}from"../../../core/maybe.js";import _ from"../../../core/PooledArray.js";import{isAbortError as m,throwIfAborted as g,createResolver as p}from"../../../core/promiseUtils.js";import{initial as f,watch as b}from"../../../core/reactiveUtils.js";import{schedule as y}from"../../../core/scheduling.js";import{isArrayBuffer as v}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as I}from"../../../core/unitUtils.js";import{property as M}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as C}from"../../../core/accessorSupport/decorators/subclass.js";import{f as x}from"../../../chunks/mat3.js";import{c as O}from"../../../chunks/mat3f32.js";import{m as E,D as S}from"../../../chunks/mat4.js";import{b as j,c as w}from"../../../chunks/mat4f64.js";import{f as T}from"../../../chunks/quatf64.js";import{m as A,s as D,t as R,a as N,c as P,g as F,b as V}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{s as H}from"../../../chunks/vec4.js";import{f as G}from"../../../chunks/vec4f64.js";import{projectBuffer as L,getProjectorName as k,localLinearScaleFactors as B,projectVectorToVector as q,projectBoundingSphere as z}from"../../../geometry/projection.js";import{create as K,empty as W,expandWithBuffer as $,toRect as X}from"../../../geometry/support/aaBoundingBox.js";import{create as Y,intersects as Q}from"../../../geometry/support/aaBoundingRect.js";import{fallbackObjectIDAttribute as J}from"../../../layers/LayerConstants.js";import Z from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ee}from"../../../layers/support/fieldUtils.js";import te from"../../../layers/support/SceneModification.js";import{getColor as ie,getOpacity as se}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as re}from"../../../support/arcadeOnDemand.js";import oe from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as ae}from"../../../symbols/support/unitConversionUtils.js";import ne from"./I3SMeshViewLabeler.js";import{I3SMeshWorkerHandle as le,toWasmModification as de}from"./I3SMeshWorkerHandle.js";import{ForAllFeaturesReturnType as he,ForAllFeaturesVisibilityMode as ce}from"./II3SMeshView3D.js";import{initialize as ue,setModificationsSync as _e,filterObbsForModificationsSync as me,interpretObbModificationResults as ge}from"./SceneLayerWorker.js";import{overrideColor as pe}from"./graphics/graphicUtils.js";import{areLabelsVisible as fe}from"./graphics/Labeler.js";import{TextureUsage as be,TextureEncoding as ye}from"./i3s/enums.js";import ve from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Ie}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Me,NodeCrossfadeMetaData as Ce}from"./i3s/I3SCrossfadeHelper.js";import xe from"./i3s/I3SElevationProvider.js";import{boundingBoxCornerPoints as Oe}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ee}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Se,selectEncoding as je,defaultMaterial as we,createTexture as Te,configureMaterial as Ae}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as De,NodeState as Re}from"./i3s/I3SNode.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe,getLocalOrigin as Fe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ve,checkSceneLayerValid as Ue,checkSceneLayerCompatibleWithView as He,getCacheKeySuffix as Ge,whenGraphicAttributes as Le,computeVisibilityObb as ke,filterInPlace as Be,getCachedAttributeValue as qe,intersectBoundingRectWithMbs as ze,MbsIntersectResult as Ke,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Xe,getClipRect as Ye}from"./i3s/I3SUtil.js";import{IDBCache as Qe}from"./i3s/IDBCache.js";import{IDBMockCache as Je}from"./i3s/IDBMockCache.js";import{attributeLookup as Ze}from"./support/attributeUtils.js";import{ColorMixModeEnum as et}from"./support/symbolColorUtils.js";import tt from"../support/debugFlags.js";import{toBoundingRect as it}from"../support/extentUtils.js";import{create as st,clone as rt}from"../support/orientedBoundingBox.js";import{updatingProgress as ot}from"../support/updatingProperties.js";import{glLayout as at}from"../support/buffer/glUtil.js";import{State as nt}from"../webgl-engine/collections/Component/ComponentObject.js";import{createVertexBufferLayout as lt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as dt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as ht}from"../webgl-engine/lib/BasisUtil.js";import{newDoubleArray as ct}from"../webgl-engine/lib/DoubleArray.js";import{Transparency as ut}from"../webgl-engine/lib/edgeRendering/interfaces.js";const _t="esri.views.3d.layers.I3SMeshView3D",mt=a.getLogger(_t),gt=[1,1,1,1];class pt extends Ce{constructor(e,t,i,s,r,o,a){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=a,this.cachedMidsTerrainSR=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0,this.cachedSymbology=null}}var ft;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(ft||(ft={}));const bt=19,yt=100*r.MEGABYTES,vt=t=>{let r=class extends t{constructor(...e){super(e),this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._idbCache=has("enable-feature:idb-mock-cache")?new Je:new Qe("esri-scenelayer-cache","geometries"),this._hasComponentData=!1,this._hasVertexColors=!1,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this._layerUrl="",this._cacheKeySuffix=null,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Me(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Ve(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?be.AllTexturesPBR:be.AllTextures:this._usePBR||this._hasLoadedPBRTextures?be.GeometryTexturesPBR:be.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=I(this.i3slayer.spatialReference),i=ae(e.unit);return l(e.offset,0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return{mode:Ut.Absolute,offset:0};const t=I(this.i3slayer.spatialReference),i=ae(e.unit),s=l(e.offset,0)*i/t;switch(e.mode){case"absolute-height":return{mode:Ut.Absolute,offset:s};case"relative-to-ground":return{mode:Ut.RelativeToGround,offset:s};case"on-the-ground":return{mode:Ut.OnTheGround,offset:0};default:return{mode:Ut.Absolute,offset:0}}}get supportedTextureEncodings(){return Se(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&ye.DDS_S3TC);return e&&t}initialize(){this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const e=this.view.resourceController,t=e.memoryController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:t}),this._worker=new le((t=>e.immediate.schedule(t))),this.addResolvingPromise(this._worker.promise);const i=this.i3slayer.store;this._worker.setLegacySchema(this.uid,i.defaultGeometrySchema),Ue(this.i3slayer),He(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new Z({layerView:this}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const s=i.defaultGeometrySchema;if(this._isIntegratedMesh||!s)this._hasComponentData=!1;else{const e=s.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(s?.vertexAttributes.color??null)&&(null==this.i3slayer.cachedDrawingInfo||!this.i3slayer.cachedDrawingInfo.color),this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const r=this.view.resourceController.memoryController.newCache(this.uid,(e=>this._deleteComponentObject(e)));this._memCache=r;const o=e=>h(this._controller.index)&&h(this._controller.index.rootNode)?this._controller.index.traverse(this._controller.index.rootNode,(t=>{const i=t.index,s=this._nodeId2Meta.get(i)||this._nodeId2MetaReloading.get(i);return e(t,h(s)?s.objectHandle:null)})):()=>{};this._intersectionHandler=new Ee({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:o}),this.updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this.updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new xe({layerView:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this.updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),f),this.updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this.updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this.updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this.updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),f),this.updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==Ut.Absolute),((e,t)=>{e?this.handles.add(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Lt):t&&this.handles.remove(Lt)}),f),this.updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const a=()=>{this._reloadAll(),this.clearMemCache()};this.updatingHandles.add((()=>this.rendererTextureUsage),a),this.updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),a),this.updatingHandles.add((()=>this.suspended),(e=>this._suspendedChange(e)),f),this.updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),f),this.updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),f),this.updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),f),this.handles.add([b((()=>tt.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&tt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||tt.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),f),b((()=>tt.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),f)]),this._cacheKeySuffix=Ge(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>mt.warn(`Failed to initialize IndexedDB cache: ${e}`)))}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.layerChanged(),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_memEstimateTextureAdded(e){const t=e.estimatedTexMemRequired;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(h(e)){const t=e.estimatedTexMemRequired;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}getUsedMemory(){let e=h(this._labeler)?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=h(t)?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=h(t)?t.node.memory:0)),e}getUnloadedMemory(){return(h(this._controller)?this._controller.unloadedMemoryEstimate:0)+(h(this._labeler)?this._labeler.unloadedMemoryEstimate:0)}ignoresMemoryFactor(){return!1}_labelingChanged(){if(!(fe(this.i3slayer)&&this._supportsLabeling))return void(h(this._labeler)&&(this._labeler.destroy(),this._labeler=null));if(h(this._labeler))return;const e=new ne({view:this.view,layer:this.i3slayer,collection:this._collection});this._nodeId2Meta.forEach((t=>h(t)&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=ue().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=de(this._layerClippingArea,this._modifications,t);_e({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new _:null;this._nodeId2Meta.forEach(((e,t)=>{c(e)?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):h(s)&&s.push(e.node)})),h(s)&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),h(s)&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==De.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),h(t)?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t)):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(h(this._modificationGraphics)&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!tt.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_suspendedChange(e){e?(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler)):(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(h(t)&&h(t.attributeInfo))return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(h(t)&&h(t.attributeInfo))return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);h(i)&&h(i.attributeInfo)&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);h(s)&&(await this.i3sOverrides.apply(s.featureIds,t,i),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{m(e)||mt.warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,h(this._labeler)&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){h(this._memCache)&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>h(t)&&e.push(t.node))),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return h(t)?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&ye.Basis)&&u(this.i3slayer.textureSetDefinitions,(e=>e.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))))&&ht()}_getVertexBufferLayout(e,t){const i={hasTexture:Tt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return at(lt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||J}_findGraphicNodeAndIndex(e){const t=Ze(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return n(this._nodeId2Meta,(e=>{if(c(e))return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(c(i))return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const a of t){const e=Ze(o,a.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return c(i)?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(c(i)||null==i.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Oe(t,this._collection,s,ct(24)),o=this.view.renderSpatialReference,a=this.view.spatialReference;if(!L(r,o,0,r,a,0,8))return null;const n=W();return $(n,r,0,8),n}whenGraphicAttributes(e,t){return Le(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(h)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return c(t)||null==t.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${bt}/${e.id}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return h(this._memCache)?this._memCache.pop(this._getMemCacheKey(e.index)):null}deleteCachedGPUData(e){h(e)&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(c(this._memCache))return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(c(t))return!0;const s=je(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(c(r)||null==r.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e)),null):(this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=s.geometryObb),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&h(s.textureData)&&(s.byteSize=Rt(s.transformedGeometry,s.textureData),s.textureData.every(Dt)&&Nt(e,s)&&this._idbCache.put(this._getCacheKey(e),s).catch((t=>mt.warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),g(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return At(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(c(s))return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:a,transformedGeometry:n}=s,l=this._controller.crsIndex,d=this.view.renderSpatialReference,u=Pe(e.mbs,this.elevationOffset,l,d),_=st([r.center.x,r.center.y,r.center.z],[r.extents.x,r.extents.y,r.extents.z],T(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));A(_.center,_.center,u),this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=_),t.geometryData.componentOffsets=o,a&&(t.geometryData.featureIds=Array.from(a));const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:n,globalTrafo:u,geometryObb:_,byteSize:Rt(n,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Nt(e,m)){const t=h(m.textureData)?m.textureData.map((e=>Dt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e),{...m,textureData:t}).catch((t=>mt.warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}computeVisibilityObb(e){return ke(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let c=0;c<s.length;++c)r[c]=this._getVertexBufferLayout(s[c],t.geometryDescriptor);const o=e.mbs,a=this.elevationOffset,n=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=Fe(o,a,n),u=Pe(o,a,n,d),_=k(n,l),m=k(l,d);if(c(_)||c(m))return Promise.resolve(null);const g={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:u,mbs:o,obb:e.serviceObb,elevationOffset:a,needNormals:!this._isIntegratedMesh&&this._controller.isMeshPyramid,normalReferenceFrame:this.i3slayer.normalReferenceFrame||"none",indexToVertexProjector:_,vertexToRenderProjector:m};return this._worker.invoke(g,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===Ut.Absolute&&(e.geometryObb=rt(this._collection.getComponentObb(t.objectHandle))),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);h(this._labeler)&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,nt.Visible),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==Ut.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),h(this._treeDebugger)&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async _addCachedNodeData(e,t,i){if(this.suspended||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(c(t))return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:a}=t;await this.i3sOverrides.apply(r.featureIds,s.attributeInfo,i);const n=h(t.textureData)?t.textureData.filter((e=>h(e)&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&n.some((e=>h(e)&&(e.encoding===ye.Basis||e.encoding===ye.KTX2)))&&await ht(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:u}=r,_=this._collection,m=d[0],{layout:g,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,v=this._materialParameters(m,g),I=l||new Uint32Array([0,p?p.length:f.byteLength/g[0].stride]),M={vertices:{data:f,count:f.byteLength/g[0].stride,layoutParameters:v.geometryParams},positionData:{positions:b.data,indices:b.indices},indices:p,componentOffsets:I},C=m.transformation?j(m.transformation):w();E(C,a,C);const T=S(U(),C),A=x(O(),C),D=this.view.renderSpatialReference,R=this.view.basemapTerrain.spatialReference,N=U(),P=[1,1,1];B(T,D,P,R)||mt.errorOnce("Unsupported coordinate system for IM overlay"),q(T,D,N,R);const F=_.createObject({toMapSpace:G(N[0],N[1],P[0],P[1]),geometry:M,obb:t.geometryObb,transform:{position:T,rotationScale:A}}),V=v.geometryParams.textureCoordinates===dt.Atlas,{textures:H,texturePromise:L}=this._initMaterialAndTextures(F,v.material,n,V);e.memory+=this._memEstimateGeometryAdded(F),e.memory+=H.reduce(((e,t)=>e+(h(t)?this._memEstimateTextureAdded(t):0)),0);const k=!!v.material.hasParametersFromSource,z="blend"!==v.material.alphaMode&&v.material.metallicRoughness.baseColorFactor[3]>=1,K=new pt(e,u,F,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:k,isOpaque:z},H);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&be.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const W=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),L]).then((([t,s])=>(h(t)&&t.updateObjectVisibility(K.objectHandle,!1).catch((e=>It(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,K),i.meta=null,this.suspended)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(F,nt.Visible),h(t)&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>It(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=W!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const a=this._applyFiltersToNode(K);(s||h(t)&&(r||a||o))&&this._addOrUpdateEdgeRendering(K),h(this._labeler)&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Mt.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),h(this._treeDebugger)&&this._treeDebugger.update()}),i)))).catch((e=>{throw h(s.meta)&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){mt.error("Removing duplicated node");const t=this._nodeId2Meta.get(e);h(t)&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);h(t)&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Vt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t)}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this.elevationInfo,s=this.view.basemapTerrain,r=s.spatialReference,o=i.mode;if(c(t)||c(r)||o===Ut.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const n=Ht,l=Gt,d=o===Ut.OnTheGround,u=this.view.renderCoordsHelper,_=!!e.cachedMidsTerrainSR,m=e.featureIds.length;if(!_){e.cachedMidsTerrainSR=ct(3*m);const i=e.cachedMidsTerrainSR;for(let s=0;s<m;s++){this._collection.getComponentAabb(e.objectHandle,s,l,!0),D(n,(l[0]+l[3])/2,(l[1]+l[4])/2,l[2]),R(n,n,a.rotationScale),N(n,n,a.position);const o=3*s;i[o+2]=u.getAltitude(n),q(n,t,n,r),i[o+0]=n[0],i[o+1]=n[1]}}const g=e.cachedMidsTerrainSR,p=i.offset,f=e.elevationOffsets,b=(e,t)=>{const i=d?g[3*e+2]:0;f[e]=p+(h(t)?t-i:0)};s.getElevations(g,m,b)}_ensureElevationTask(){return h(this._elevationTask)||(this._elevationTask=new Ie(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return h(t)?t.filterInPlace((e=>h(this._nodeId2Meta.get(e)))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==Ut.Absolute,s=!!t&&t!==e&&t.mode!==Ut.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){c(e)||(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),h(this._labeler)&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Mt.UPDATE))}_safeReschedule(e,t){return g(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=h(e.params.material)?e.params.material:we(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Tt(i);return{geometryParams:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Te(e,t,s,r)));this._stage.addMany(o);let a=null;return this._collection.updateMaterial(e,(e=>{a=Ae(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:a}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?dt.Atlas:dt.Default:dt.None,colors:this._hasVertexColors,normals:e.hasNormals&&!this._isIntegratedMesh}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...p(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{h(e.meta)&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Y();this._renderClippingArea=it(this.view.clippingArea,i,e)?i:null;const s=Y();this._layerClippingArea=it(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{h(e)&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Mt.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return h(t)&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(h(t)){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},a=this._createLayerGraphic(o),n=this.i3slayer.objectIdField,l=t.featureIds,d=h(t.attributeInfo)&&t.attributeInfo.attributeData;s.every((e=>e===n||d&&null!=d[e]))&&Be(e,l,(e=>{o[n]=l[e];for(const i of s)i!==n&&(o[i]=d?qe(d[i],e):null);try{return i.testFeature(a)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return z(e.node.mbs,this._controller.crsIndex,wt,this.view.renderSpatialReference),ze(t,wt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Ct),X(Ct,xt),Q(i,xt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===Ke.INSIDE)return;if(r===Ke.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const a=this._transformClippingArea(Ot,i,t.objectHandle);Be(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,a)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(c(i))return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:a}=this._getFilteredEdgeMaterials(e),n={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Vt(a,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,a,n,t).catch((e=>It(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>It(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>It(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,a,n).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>It(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(h(this._labeler)&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=0===t.getComponentCount(e.objectHandle).invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!i;if(this._updateCachedFilteredIds(e),e.filteredIds===e.featureIds)return!i;const s=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,s),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return h(i)&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=d(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),h(this._elevationTask)&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);c(s)?i.delete(e):(this._collection.setObjectVisibility(s.objectHandle,nt.Hidden),h(this._edgeView)&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>It(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Mt.REMOVE),h(this._labeler)&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),h(this._treeDebugger)&&this._treeDebugger.update())}_deleteComponentObject(e){if(h(this._edgeView)&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);h(i)&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===Re.Hole))}_invalidateAllSymbols(){this._rendererVersion=We(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await re()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:mt.warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&mt.error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(H(s.externalColor,t[r+0]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),h(this._stage.renderView.objectAndLayerIdRenderHelper)){const t=e.featureIds[i];this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabled,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<ft.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<ft.CastShadows),s.pickable=0!=(t[r+4]&1<<ft.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e&&e.getSymbol(t,{arcade:this._arcade});if(!(i instanceof oe))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=$e(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=h(this._symbologyOverrideFields)&&this._symbologyOverrideFields.length>0?h(this._rendererFields)&&this._rendererFields.length>0?ee(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=h(e.attributeInfo)&&e.attributeInfo.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,a=null!=r&&h(this._symbologyFields)&&this._symbologyFields.length>0;let n=null,l=null;if(a&&h(this._symbologyFields)){n=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(n.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=new Uint8Array(5*e.featureIds.length));const d={color:St,castShadows:!0,pickable:!0,colorMixMode:et.Multiply,edgeMaterial:null},u=this.fullOpacity,_=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):u;let m=null,g=ut.OPAQUE,p=Xe,f=0;for(let b=0;b<e.featureIds.length;b++){if(null!=o&&(i[o]=e.featureIds[b]),a&&n)for(let e=0;e<n.length;e++)i[n[e]]=qe(l[e],b);const r=s?this._getSymbolInfo(s,t):null;let u=null,y=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=ie(this._colorVariable,t,{color:jt,arcade:this._arcade});e&&(u=St,u[0]=e.r/255,u[1]=e.g/255,u[2]=e.b/255,this._opacityVariable||null===e.a||(y=e.a))}this._opacityVariable&&(y=se(this._opacityVariable,t,{arcade:this._arcade}))}if(r&&r.material){const e=r.material;u=c(u)||c(y)?pe(u,y,e.color,e.alpha,gt,St):pe(u,y,null,null,gt,St)}if(c(u)&&(u=St,u[0]=1,u[1]=1,u[2]=1,u[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r&&r.material?r.material.colorMixMode:et.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,h(this._symbologyOverride)&&(d.color=u,this._symbologyOverride(t,d),u=d.color),h(d.edgeMaterial)){const t=u[3]<=0?ut.INVISIBLE:u[3]>=1&&(e.material.isOpaque||d.colorMixMode===et.Replace)?ut.OPAQUE:ut.TRANSPARENT;d.edgeMaterial===m&&t===g||(p={...d.edgeMaterial,opacity:_,objectTransparency:t},m=d.edgeMaterial,g=t),e.cachedEdgeMaterials[b]=p}else e.cachedEdgeMaterials[b]=Xe;e.cachedSymbology[f+0]=Math.round(255*u[0]),e.cachedSymbology[f+1]=Math.round(255*u[1]),e.cachedSymbology[f+2]=Math.round(255*u[2]),e.cachedSymbology[f+3]=Math.round(255*u[3]),e.cachedSymbology[f+4]=d.colorMixMode|+d.castShadows<<ft.CastShadows|+d.pickable<<ft.Pickable,f+=5}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Vt(t,this.fullOpacity);const i=e.filteredIds;if(c(i)){return{hasEdges:t.some((e=>e!==Xe)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?Xe:(r=r||t!==Xe,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{c(t)||(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Vt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Mt.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),h(this._labeler)&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{c(t)||(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{c(t)||this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return!this._isIntegratedMesh&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){h(this._edgeView)&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_forAllFeatures(e,t,i=ce.VISIBLE_ONLY){n(this._nodeId2Meta,(s=>{if(c(s))return!1;if(h(t)){switch(t(s)){case he.EXIT:return!0;case he.SKIP:return!1}}let r=he.CONTINUE;switch(i){case ce.ALL:r=this._forAllFeaturesOfNode(s,e);break;case ce.VISIBLE_ONLY:r=this._forVisibleFeaturesOfNode(s,e);break;case ce.ALL_IN_CLIPPING_AREA:r=this._forAllFeaturesOfNodeInClippingArea(s,e)}return r===he.EXIT}))}_forAllFeaturesOfNode(e,t){let i=he.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===he.EXIT)return i;return i}_forVisibleFeaturesOfNode(e,t){let i=he.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===he.CONTINUE))),i}_forAllFeaturesOfNodeInClippingArea(e,t){if(c(this._renderClippingArea))return this._forAllFeaturesOfNode(e,t);const i=this._boundingRectNodeTest(e,this._renderClippingArea);if(i===Ke.OUTSIDE)return he.CONTINUE;if(i===Ke.INSIDE)return this._forAllFeaturesOfNode(e,t);const s=he.CONTINUE,r=e.featureIds,o=e.objectHandle,a=Ye(this._renderClippingArea,this._collection.getObjectTransform(o));for(let n=0;n<r.length;n++){if(!this._boundingRectFeatureTest(e,n,a))continue;const i=t(r[n],n,e);if(i===he.EXIT)return i}return s}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=h(t.attributeInfo)&&t.attributeInfo.attributeData;if(h(s))for(const r of Object.keys(s))i[r]=qe(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){const t=this._highlights;if("number"==typeof e||e instanceof i?e=[e]:e instanceof o&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>Ze(s,e.attributes,r))),{set:a,handle:n}=t.acquireSet();return t.setFeatureIds(a,o),n}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=t.acquireSet();return t.setFeatureIds(s,i),r}}return Ft}resetHighlights(){d(this._highlights),this._highlights=new ve({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,ce.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){this._elevationProvider&&(this._elevationProvider.objectChanged(e.node),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=y((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t))}get performanceInfo(){const e={displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null,index:0,nodes:this._nodeId2Meta.size,"Total GPU Memory Estimate":(this._gpuMemoryEstimate/1048576).toFixed(1)+"MB","Geometry Memory Estimate":(this._geoMemoryEstimate/1048576).toFixed(1)+"MB","Texture Memory Estimate":(this._texMemoryEstimate/1048576).toFixed(1)+"MB","Unloaded Memory Estimate":(this.getUnloadedMemory()/1048576).toFixed(1)+"MB"};return h(this._memCache)&&(e.MemCache=Math.round(100*this._memCache.hitRate)+"% hit"),this._controller&&(this._idbCacheEnabled&&(e.IDBCache=Math.round(100*this._idbCache.getHitRate())+"% hit"),this._controller.updateStats(e)),e}get test(){const e=this;return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),he.CONTINUE)),null,ce.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return h(e)?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(((t,i)=>e(i,t)))}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);h(s)&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);h(i)&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(c(this._edgeView)||!e.cachedEdgeMaterials)return;Vt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>It(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&h(this._layerClippingArea)||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Pt(e);if(h(s)){const t={context:i,buffer:s.buffer};me(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=ge(i);e.imModificationImpact=s,s!==De.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||h(this._labeler)&&this._labeler.updating||this._crossfadeHelper.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||h(this._elevationTask)&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(c(s))throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>{s(this._snappingSourcesTrackers,t)}};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(c(t))return;const s=this._controller.getRenderMbs(t.node);h(s)&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===Ut.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,a=U(),n=U(),l=(e,t)=>{N(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,n),N(e,e,F(n,n,t)),V(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,a),l(a,t),s.setVec(d,a),r.getVec(d,a),l(a,t),r.setVec(d,a)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(!c(s))for(const r of this._snappingSourcesTrackers)t!==Mt.REMOVE&&t!==Mt.UPDATE||r.events.remove(i),t!==Mt.ADD&&t!==Mt.UPDATE||r.events.add(i,s)}};return e([M()],r.prototype,"_hasLoadedPBRTextures",void 0),e([M()],r.prototype,"_asyncModuleLoading",void 0),e([M()],r.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([M()],r.prototype,"view",void 0),e([M()],r.prototype,"i3slayer",void 0),e([M()],r.prototype,"_controller",void 0),e([M()],r.prototype,"_labeler",void 0),e([M()],r.prototype,"updating",void 0),e([M()],r.prototype,"suspended",void 0),e([M()],r.prototype,"holeFilling",void 0),e([M(ot)],r.prototype,"updatingProgress",void 0),e([M()],r.prototype,"updatingProgressValue",null),e([M()],r.prototype,"hasTexturesOrVertexColors",null),e([M()],r.prototype,"rendererTextureUsage",null),e([M()],r.prototype,"elevationOffset",null),e([M()],r.prototype,"elevationInfo",null),e([M({type:Boolean})],r.prototype,"slicePlaneEnabled",void 0),e([M()],r.prototype,"supportedTextureEncodings",null),e([M()],r.prototype,"uncompressedTextureDownsamplingEnabled",null),e([M({type:[te]})],r.prototype,"_modifications",void 0),e([M()],r.prototype,"_elevationTask",void 0),e([M({readOnly:!0})],r.prototype,"_usePBR",null),r=e([C(_t)],r),r};function It(e,t){m(e)||mt.warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Mt;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Mt||(Mt={}));const Ct=K(),xt=Y(),Ot=Y(),Et=st(),St=[0,0,0,0],jt=new t([0,0,0,0]),wt=[0,0,0,0];function Tt(e){if(c(e))return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function At(e){return"geometryData"in e}function Dt(e){return h(e)&&v(e.data)}function Rt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(h(t))for(const s of t)h(s)&&v(s.data)&&(i+=s.data.byteLength);return i}function Nt(e,t){return t.byteSize>yt?(mt.warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Pt(e){if(0===e.length)return null;const t=10*e.length,i=new Float64Array(t);return e.forAll(((e,t)=>{let s=e.serviceObb;c(s)&&(s=Et,P(s.center,e.mbs),s.halfSize[0]=s.halfSize[1]=s.halfSize[2]=e.mbs[3]);const r=10*t;i[r+0]=s.center[0],i[r+1]=s.center[1],i[r+2]=s.center[2],i[r+3]=s.halfSize[0],i[r+4]=s.halfSize[1],i[r+5]=s.halfSize[2],i[r+6]=s.quaternion[0],i[r+7]=s.quaternion[1],i[r+8]=s.quaternion[2],i[r+9]=s.quaternion[3]})),i}const Ft={remove(){},pause(){},resume(){}};function Vt(e,t){e.forEach((e=>e.opacity=t))}var Ut;!function(e){e[e.Absolute=0]="Absolute",e[e.RelativeToGround=1]="RelativeToGround",e[e.OnTheGround=2]="OnTheGround"}(Ut||(Ut={}));const Ht=U(),Gt=K(),Lt="elevation-change";export{Ut as ElevationMode,vt as I3SMeshView3D};
|