SceneLayerView3D.js 12 KB

12345678910111213141516171819202122
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.30/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import i from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import s from"../../../core/ReactiveSet.js";import{initial as l}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{WhereClause as a}from"../../../core/sql/WhereClause.js";import d from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as u}from"../../../layers/support/floorFilterUtils.js";import h from"../../../rest/support/Query.js";import{sceneLayerEditingEnabled as p}from"../../../support/featureFlags.js";import{I3SMeshView3D as c}from"./I3SMeshView3D.js";import{ForAllFeaturesMode as y}from"./II3SMeshView3D.js";import{LayerView3D as g}from"./LayerView3D.js";import{createInteractiveEditSession as m,normalizeEditResultsEvent as f,processGeometryEdits as _,processAttributeEdits as F}from"./i3s/featureEditing.js";import{createGetFeatureExtent as b}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as j}from"./i3s/I3SMeshViewFilter.js";import{NodeFilterImpact as v}from"./i3s/I3SNode.js";import{I3SOverrides as I}from"./i3s/I3SOverrides.js";import{I3SQueryEngine as w}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as S}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as E}from"./i3s/I3SQueryFeatureStore.js";import{checkRecyclable as O,getIndexCrs as H,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as V}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as q}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as R}from"./support/TemporalSceneLayerView.js";import{updatingProgress as A}from"../support/updatingProperties.js";import L from"../../layers/SceneLayerView.js";import{hasPopupTemplate as D}from"../../layers/support/popupUtils.js";import{isInEffectiveScaleRange as U}from"../../support/layerViewUtils.js";import{TaskPriority as G}from"../../support/Scheduler.js";const P=Q();let M=class extends(c(R(C(V(g(L)))))){constructor(){super(...arguments),this.type="scene-layer-3d",this._setVisibilityHiddenObjectIds=new s,this.progressiveLoadFactor=1,this._elevationContext="scene",this._isIntegratedMesh=!1,this._supportsLabeling=!0,this._pendingEditsQueue=Promise.resolve(),this._interactiveEditingSessions=new Map,this._queryEngine=null}get i3slayer(){return this.layer}tryRecycleWith(e,t){return e.url===this.layer.url&&this.i3sOverrides.isEmpty?e.load(t).then((()=>{O(this.layer,e,this.i3sOverrides),this.layer=e,this.i3sOverrides.destroy();const t=this.view.resourceController?.memoryController;this.i3sOverrides=new I({view:this.view,layer:e,memoryController:t}),this.resetHighlights()})):null}get layerPopupEnabledAndHasTemplate(){return this.layer.popupEnabled&&D(this.layer,this.view.popup?.defaultPopupTemplateEnabled)}get filter(){return this._get("filter")}set filter(e){this._set("filter",j.checkSupport(e)?e:null)}get viewFilter(){const e=this.mergedFilter,t=this.layerFilter;if(null==e&&null==t)return null;const i=this._get("viewFilter");return null==i?new j({layerFilter:t,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError),addTimeFilter:(e,t)=>this.addTimeFilter(e,t)}):(i.viewFilter=e,i.layerFilter=t,i)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=u(this);return null!=e?a.create(e,this.layer.fieldsIndex):null}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds.toArray();return e.length?e.sort(((e,t)=>e-t)):null}get _setVisibilityHiddenObjectIdsSorted(){return this._setVisibilityHiddenObjectIds.size?Array.from(this._setVisibilityHiddenObjectIds).sort(((e,t)=>e-t)):null}get lodFactor(){return this.view?.qualitySettings?.sceneService?.object?.lodFactor??1}get lodCrossfadeUncoveredDuration(){return this.view?.qualitySettings?.fadeDuration??0}get updatingProgressValue(){return this._controller?.updatingProgress??0}get visibleAtCurrentScale(){return U(this.i3slayer.effectiveScaleRange,this.view.terrainScale)}initialize(){this._fieldsHelper=new q({layerView:this}),this._updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),l),this._updatingHandles.add((()=>this.layer.renderer),(e=>this._updatingHandles.addPromise(this._rendererChange(e))),l);const e=()=>this._filterChange();this._updatingHandles.add((()=>this.parsedDefinitionExpression),e),this._updatingHandles.add((()=>this.mergedFilter),e),this._updatingHandles.add((()=>this._floorFilterClause),e),this._updatingHandles.add((()=>this._excludeObjectIdsSorted),e),this._updatingHandles.add((()=>this._setVisibilityHiddenObjectIdsSorted),e),this._updatingHandles.add((()=>this.viewFilter?.sortedObjectIds),e),this._updatingHandles.add((()=>this.viewFilter?.parsedWhereClause),e),this._updatingHandles.add((()=>this.getTimeFilterDependencies()),e),this._updatingHandles.add((()=>[this.viewFilter?.parsedGeometry,this.mergedFilter?.spatialRelationship,this.layer.filter?.spatialRelationship]),(()=>this._geometryFilterChange())),p()&&this.i3sOverrides.is3DOFL&&this._updatingHandles.add((()=>this.i3sOverrides.sortedGeometryChangedObjectIds),e),this.addHandles(this.layer.on("apply-edits",(e=>this._updatingHandles.addPromise(e.result)))),this.addHandles(this.layer.on("edits",(e=>{const t=this._pendingEditsQueue.then((()=>this._handleEdits(e))).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)})))}destroy(){this._fieldsHelper=r(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&i.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return this.mergedFilter?.createQuery(e)??new h(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then((e=>{if(!e?.features)return e;const t=this.layer;for(const i of e.features)i.layer=t,i.sourceLayer=t;return e}))} _getComponents(objectHandle, positionData, featureIds, group) {
  6. const t = objectHandle.components.count, n = new Float32Array(6 * t), o = positionData.indices, i = positionData.positions, e = objectHandle.components.offsets; let objects = [];
  7. for (let s = 0; s < t; s++) {
  8. const t = e[s], p = e[s + 1]; let object_pos = []; for (let n = t; n < p; n++) {
  9. const t = 3 * o[n], s = i[t], e = i[t + 1], r = i[t + 2];
  10. let renderPos = new Array(3);
  11. this.transformMat3(renderPos, [s, e, r], objectHandle.transform.rotationScale);
  12. renderPos[0] = renderPos[0] + objectHandle.transform.position[0];
  13. renderPos[1] = renderPos[1] + objectHandle.transform.position[1];
  14. renderPos[2] = renderPos[2] + objectHandle.transform.position[2];
  15. object_pos.push(renderPos[0], renderPos[1], renderPos[2]);
  16. } group.push(object_pos);
  17. }
  18. }
  19. queryObjectIds(e,t) {return this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)}_ensureQueryEngine(){return this._queryEngine||(this._queryEngine=this._createQueryEngine()),this._queryEngine}_createQueryEngine(){const e=b(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new w({layerView:this,priority:G.FEATURE_QUERY_ENGINE,spatialIndex:new E({featureAdapter:new S({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo??[],getFeatureExtent:e}),forAllFeatures:(e,t)=>this._forAllFeatures(((t,i,r)=>e({id:t,index:i,meta:r})),t,y.QUERYABLE),getFeatureExtent:e,sourceSpatialReference:H(this.layer),viewSpatialReference:this.view.spatialReference})})}highlight(e){const t=this._highlights;if(e instanceof h){const{set:i,handle:r}=t.acquireSet();return this.queryObjectIds(e).then((e=>t.setFeatureIds(i,e))),r}return super.highlight(e)}createInteractiveEditSession(e){return m(this._attributeEditingContext,e)}_createLayerGraphic(e){return new t({attributes:e,layer:this.layer,sourceLayer:this.layer})}getFilters(){const e=super.getFilters();p()&&this.i3sOverrides.is3DOFL&&this.i3sOverrides.sortedGeometryChangedObjectIds.length>0&&e.push(((e,t)=>{t.node.index>=0&&x(this.i3sOverrides.sortedGeometryChangedObjectIds,!1,e)}));const t=this._setVisibilityHiddenObjectIdsSorted;null!=t&&e.push((e=>x(t,!1,e)));const i=this._excludeObjectIdsSorted;return null!=i&&e.push((e=>x(i,!1,e))),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),null!=this.viewFilter&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}setVisibility(e,t){t?this._setVisibilityHiddenObjectIds.delete(e):this._setVisibilityHiddenObjectIds.add(e)}isUpdating(){return super.isUpdating()||this.layerFilterUpdating||null!=this.viewFilter&&this.viewFilter.updating||null!=this.i3sOverrides&&this.i3sOverrides.updating}
  20. async getFeatureInfo() {let group = []; this._nodeId2Meta.forEach((node) => { let featureIds = node.featureIds; let objectHandle = node.objectHandle; let intersectionGeometry = objectHandle.intersectionGeometry; this._getComponents(objectHandle, intersectionGeometry, featureIds, group); }); return group; }
  21. _ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():h.from(e))} transformMat3(t, a, n) {var r = a[0], o = a[1], u = a[2];return t[0] = r * n[0] + o * n[3] + u * n[6], t[1] = r * n[1] + o * n[4] + u * n[7], t[2] = r * n[2] + o * n[5] + u * n[8], t}
  22. get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),globalIdField:this._getGlobalIdField(),forEachNode:e=>this._forAllNodes((t=>null!=t?e(t.node,t.featureIds):null)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this.i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}async _handleEdits(e){const t=p(),i=this._attributeEditingContext,r=await f(i,e);t&&_(i,r),F(i,r)}get hasGeometryFilter(){const e=this.viewFilter;return null!=e?.parsedGeometry}computeNodeFiltering(e){const t=this.viewFilter;return null==t||!this.view.spatialReference||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?v.Unmodified:v.Culled}};e([n()],M.prototype,"i3slayer",null),e([n(A)],M.prototype,"updatingProgress",void 0),e([n({type:d})],M.prototype,"filter",null),e([n({readOnly:!0})],M.prototype,"viewFilter",null),e([n(P.requiredFields)],M.prototype,"requiredFields",null),e([n(P.availableFields)],M.prototype,"availableFields",void 0),e([n()],M.prototype,"_fieldsHelper",void 0),e([n()],M.prototype,"_floorFilterClause",null),e([n()],M.prototype,"_excludeObjectIdsSorted",null),e([n()],M.prototype,"_setVisibilityHiddenObjectIds",void 0),e([n()],M.prototype,"_setVisibilityHiddenObjectIdsSorted",null),e([n()],M.prototype,"lodFactor",null),e([n()],M.prototype,"updatingProgressValue",null),e([n({readOnly:!0})],M.prototype,"visibleAtCurrentScale",null),M=e([o("esri.views.3d.layers.SceneLayerView3D")],M);const T=M;export{T as default};