VoxelLayer.js 9.2 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../chunks/tslib.es6.js";import i from"../core/Collection.js";import r from"../core/Error.js";import t from"../core/Logger.js";import{isSome as o,isNone as s}from"../core/maybe.js";import{MultiOriginJSONMixin as n}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as l}from"../core/promiseUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import{Integer as p}from"../core/accessorSupport/ensureType.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{n as y}from"../chunks/vec3.js";import{f as u}from"../chunks/vec3f64.js";import d from"./Layer.js";import{APIKeyMixin as v}from"./mixins/APIKeyMixin.js";import{ArcGISService as h}from"./mixins/ArcGISService.js";import{OperationalLayer as b}from"./mixins/OperationalLayer.js";import{PortalLayer as f}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as S}from"./mixins/ScaleRangeLayer.js";import{SceneService as g}from"./mixins/SceneService.js";import{sanitizeUrl as V}from"./support/arcgisLayerUrl.js";import{popupEnabled as j,legendEnabled as w,url as x}from"./support/commonProperties.js";import I from"./support/VoxelDynamicSection.js";import D from"./support/VoxelSection.js";import N from"./support/VoxelSimpleShading.js";import T from"./support/VoxelSlice.js";import L from"./support/VoxelVariable.js";import O from"./support/VoxelVariableStyle.js";import M from"./support/VoxelVolume.js";import P from"./support/VoxelVolumeIndex.js";import E from"./support/VoxelVolumeStyle.js";const A=t.getLogger(" esri.layers.VoxelLayer");let J=class extends(g(h(b(f(S(n(v(d)))))))){constructor(e){super(e),this.serviceRoot="",this.popupEnabled=!0,this.operationalLayerType="Voxel",this.legendEnabled=!0,this.title=null,this.sections=new i,this.currentVariableId=0,this.volumeStyles=null,this.renderMode="volume",this.variableStyles=null,this.enableSlices=!0,this.enableSections=!0,this.enableDynamicSections=!0,this.enableIsosurfaces=!0,this.shading=new N,this.opacity=1,this.variables=new i,this.volumes=new i,this.index=null,this.minScale=0,this.maxScale=0,this.type="voxel",this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.volumeStyles=new i,this.variableStyles=new i}set url(e){this._set("url",V(e,A))}load(e){const i=o(e)?e.signal:null,r=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(l).then((()=>this._fetchService(i))).then((()=>this.serviceRoot=this.url));return this.addResolvingPromise(r),Promise.resolve(this)}readVersion(e,i){return super.parseVersionString(e)}validateLayer(e){if(e.layerType&&e.layerType!==this.operationalLayerType)throw new r("voxel-layer:layer-type-not-supported","VoxelLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor)||this.version.major<3)throw new r("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"});if(this.version.major>3)throw new r("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"})}getConfiguration(){const e={layerType:this.operationalLayerType,version:this.version.versionString,name:this.title,spatialReference:this.spatialReference,fullExtent:this.fullExtent,volumes:this.volumes.toJSON(),variables:this.variables.toJSON(),index:this.index.toJSON(),sections:this.sections.toJSON(),style:{volumeStyles:this.volumeStyles.toJSON(),currentVariableId:this.currentVariableId,renderMode:this.renderMode,variableStyles:this.variableStyles.toJSON(),enableSections:this.enableSections,enableDynamicSections:this.enableDynamicSections,enableIsosurfaces:this.enableIsosurfaces,enableSlices:this.enableSlices,shading:this.shading}};return e.index&&this.index.isValid()?JSON.stringify(e):""}getVariableStyle(e){let i=-1;i=o(e)?e:this.currentVariableId;if(!this.variableStyles||-1===i)return null;const r=this.variableStyles.findIndex((e=>e.variableId===i));return r<0?null:this.variableStyles.getItemAt(r)}getVariable(e){let i=-1;if(i=o(e)?e:this.currentVariableId,!this.variables||-1===i)return null;const r=this.variables.findIndex((e=>e.id===i));return r<0?null:this.variables.getItemAt(r)}getSections(){const e=[];for(const i of this.sections)e.push(new D({enabled:i.enabled,href:i.href,id:i.id,label:i.label,normal:i.normal,point:i.point,sizeInPixel:i.sizeInPixel,slices:i.slices,timeId:i.timeId,variableId:i.variableId}));return e}getVolume(e){const i=this.getVariable(e);return o(i)?this.volumes.find((({id:e})=>e===i.volumeId)):null}getVolumeStyle(e){const i=this.getVariable(e);return o(i)?this.volumeStyles.find((({volumeId:e})=>e===i.volumeId)):null}getSlices(){const e=[],i=this.getVolume(null);if(s(i)||!i.isVolumeValid())return e;const r=this.getVolumeStyle(null);if(s(r))return e;for(const t of r.slices)this._isPlaneValid(t,[0,1,i.getZDimension()],i.dimensions)?e.push(new T({enabled:t.enabled,label:t.label,point:t.point,normal:t.normal})):e.push(new T({enabled:!1,label:"invalid",point:t.point,normal:t.normal}));return e}getDynamicSections(){const e=[],i=this.getVolume(null);if(s(i)||!i.isVolumeValid())return e;const r=this.getVolumeStyle(null);if(s(r))return e;for(const t of r.dynamicSections)this._isPlaneValid(t,[0,1,i.getZDimension()],i.dimensions)?e.push(new I({enabled:t.enabled,label:t.label,point:t.point,normal:t.normal})):e.push(new I({enabled:!1,label:"invalid",point:t.point,normal:t.normal}));return e}getVerticalExaggeration(){const e=1,i=this.getVolumeStyle(null);return s(i)?e:i.verticalExaggeration}getVerticalOffset(){const e=1,i=this.getVolumeStyle(null);return s(i)?e:i.verticalOffset}_isPlaneValid(e,i,r){if(!e.point)return!1;if(!Array.isArray(e.point)||3!==e.point.length)return!1;if(!e.normal)return!1;if(!Array.isArray(e.normal)||3!==e.normal.length)return!1;for(let s=0;s<3;++s){const t=e.point[s];if(t<0||t>=r[i[s]].size)return!1}const t=u(e.normal[0],e.normal[1],e.normal[2]);y(t,t);const o=1e-6;return!(Math.abs(t[0])+Math.abs(t[1])+Math.abs(t[2])<o)&&(e.normal[0]=t[0],e.normal[1]=t[1],e.normal[2]=t[2],!0)}};e([a(j)],J.prototype,"popupEnabled",void 0),e([a({type:["Voxel"]})],J.prototype,"operationalLayerType",void 0),e([a(w)],J.prototype,"legendEnabled",void 0),e([a({json:{write:!0}})],J.prototype,"title",void 0),e([a(x)],J.prototype,"url",null),e([a({type:i.ofType(D),json:{origins:{"web-scene":{name:"layerDefinition.sections",write:!0}}}})],J.prototype,"sections",void 0),e([a({type:p,json:{origins:{"web-scene":{name:"layerDefinition.style.currentVariableId",write:{enabled:!0,isRequired:!0}},service:{name:"style.currentVariableId"}}}})],J.prototype,"currentVariableId",void 0),e([a({type:i.ofType(E),json:{origins:{"web-scene":{name:"layerDefinition.style.volumeStyles",write:!0},service:{name:"style.volumeStyles"}}}})],J.prototype,"volumeStyles",void 0),e([a({type:["volume","surfaces"],json:{origins:{"web-scene":{name:"layerDefinition.style.renderMode",write:!0},service:{name:"style.renderMode"}}}})],J.prototype,"renderMode",void 0),e([a({type:i.ofType(O),json:{origins:{"web-scene":{name:"layerDefinition.style.variableStyles",write:!0},service:{name:"style.variableStyles"}}}})],J.prototype,"variableStyles",void 0),e([a({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSlices",write:!0},service:{name:"style.enableSlices"}}}})],J.prototype,"enableSlices",void 0),e([a({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSections",write:!0},service:{name:"style.enableSections"}}}})],J.prototype,"enableSections",void 0),e([a({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableDynamicSections",write:!0},service:{name:"style.enableDynamicSections"}}}})],J.prototype,"enableDynamicSections",void 0),e([a({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableIsosurfaces",write:!0},service:{name:"style.enableIsosurfaces"}}}})],J.prototype,"enableIsosurfaces",void 0),e([a({type:N,json:{origins:{"web-scene":{name:"layerDefinition.style.shading",write:!0},service:{name:"style.shading"}}}})],J.prototype,"shading",void 0),e([a({type:["show","hide"]})],J.prototype,"listMode",void 0),e([a({type:Number,range:{min:0,max:1},nonNullable:!0,json:{read:!1,write:!1,origins:{"web-scene":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],J.prototype,"opacity",void 0),e([a({type:i.ofType(L)})],J.prototype,"variables",void 0),e([a({type:i.ofType(M)})],J.prototype,"volumes",void 0),e([a({type:P})],J.prototype,"index",void 0),e([a({type:Number,json:{name:"layerDefinition.minScale",read:!1,write:!1,origins:{service:{read:!1,write:!1}}}})],J.prototype,"minScale",void 0),e([a({type:Number,json:{name:"layerDefinition.maxScale",read:!1,write:!1,origins:{service:{read:!1,write:!1}}}})],J.prototype,"maxScale",void 0),e([a({json:{read:!1},readOnly:!0})],J.prototype,"type",void 0),e([a({readOnly:!0,json:{name:"serviceVersion"}})],J.prototype,"version",void 0),e([m("service","version")],J.prototype,"readVersion",null),J=e([c("esri.layers.VoxelLayer")],J);const R=J;export{R as default};