You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
10 KiB
23 lines
10 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("require ../chunks/tslib.es6 ../Basemap ../Viewpoint ../core/asyncUtils ../core/Collection ../core/collectionUtils ../core/JSONSupport ../core/Logger ../core/mathUtils ../core/maybe ../core/promiseUtils ../core/reactiveUtils ../core/accessorSupport/decorators/property ../core/accessorSupport/decorators/cast ../core/RandomLCG ../core/has ../core/accessorSupport/decorators/subclass ../core/accessorSupport/ensureType ../chunks/vec32 ../core/libs/gl-matrix-2/factories/vec3f64 ../layers/Layer ../support/basemapUtils ../views/support/Scheduler ../webdoc/support/SlideThumbnail ../webdoc/support/timeProperties ./SunLighting ./VirtualLighting ./support/Description ./support/SlideEnvironment ./support/SlideGround ./support/SlideVisibleLayer ./support/Title".split(" "), |
|
function(O,e,P,Q,R,B,S,d,T,U,C,w,D,h,p,ea,fa,V,x,E,y,W,F,X,n,Y,Z,aa,u,G,H,I,q){function J(a){if("building-scene"===a.type||"map-image"===a.type)return a.allSublayers.toArray()}function K(a){if(a=J(a))return a.filter(b=>b.visible).map(b=>b.id)}function ba(a,b){a=b-a;43200<a&&(a-=86400);-43200>a&&(a+=86400);return a}let ca=0;const z=B.ofType(I.SlideVisibleLayer);d=class extends d.JSONSupport{constructor(a){super(a);this.id=Date.now().toString(16)+"-slide-"+ca++;this.title=new q;this.description=new u; |
|
this.hidden=!1;this.thumbnail=new n.SlideThumbnail;this.ground=this.basemap=this.viewpoint=null;this.environment=new G.SlideEnvironment;this.timeExtent=null;this.visibleLayers=new z}destroy(){this.visibleLayers.removeAll();this.basemap=null;this.thumbnail=C.destroyMaybe(this.thumbnail);this.thumbnail=this.title=this.description=null}castTitle(a){return"string"===typeof a?new q({text:a}):x.ensureType(q,a)}castDescription(a){return"string"===typeof a?new u({text:a}):x.ensureType(u,a)}castThumbnail(a){return"string"=== |
|
typeof a?new n.SlideThumbnail({url:a}):x.ensureType(n.SlideThumbnail,a)}castBasemap(a){return F.ensureType(a)}set visibleLayers(a){this._set("visibleLayers",S.referenceSetter(a,this._get("visibleLayers"),z))}castVisibleLayers(a){return a&&"function"===typeof a.map?a.map(b=>{if("string"===typeof b)return{id:b};if(b instanceof W){const c=K(b);return{id:b.id,sublayerIds:c}}if(b.id)return{id:b.id,sublayerIds:"sublayerIds"in b?b.sublayerIds:void 0};T.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'); |
|
return b}):null}clone(){return new this.constructor({id:this.id,title:this.title.clone(),thumbnail:this.thumbnail.clone(),description:this.description&&this.description.clone()||null,viewpoint:this.viewpoint&&this.viewpoint.clone()||null,basemap:this.basemap?.clone()||null,ground:this.ground?.clone()||null,visibleLayers:this.visibleLayers.clone(),environment:this.environment&&this.environment.clone()||null,hidden:this.hidden,timeExtent:this.timeExtent?.clone()??null})}async _updateVisibleLayersFrom(a){const b= |
|
[];await Promise.allSettled(this._getLayers(a.map).map(c=>a.whenLayerView(c).then(f=>{if(f.visible){const g=K(c);b.push(new I.SlideVisibleLayer({id:f.layer.id,sublayerIds:g}))}})).toArray());this.visibleLayers.removeAll();this.visibleLayers.addMany(b)}updateFrom(a,b){const c={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...b?.screenshot};return a.when(()=>{this.viewpoint=a.viewpoint.clone();this.environment.lighting="virtual"===a.environment.lighting.type?aa.prototype.clone.apply(a.environment.lighting): |
|
Z.prototype.clone.apply(a.environment.lighting);this.environment.weather=a.environment.weather.clone();this.basemap=a.map.basemap&&a.map.basemap.clone()||null;this.ground=a.map.ground?H.fromGround(a.map.ground):null;this.timeExtent=a.timeExtent?.clone()??null;return this._updateVisibleLayersFrom(a)}).then(()=>a.takeScreenshot(c)).then(f=>{this.thumbnail=new n.SlideThumbnail({url:f.dataUrl});return this})}async applyTo(a,b){null!=this._applyToController&&this._applyToController.abort();let c=new AbortController; |
|
this._applyToController=c;const f=w.onAbortOrThrow(b,()=>c?.abort()),g=()=>{this._applyToController===c&&(this._applyToController=null);c=null;f?.remove()};try{await D.whenOnce(()=>a.ready,c.signal)}catch(r){throw g(),r;}if(c.signal.aborted)throw g(),w.createAbortError();const k=a.resourceController.scheduler.registerTask(X.TaskPriority.SLIDE);let v=!1;const l={animate:!0,...b,signal:this._applyToController.signal};b=await R.result(a.addUpdatingPromise((async()=>{await Promise.all([k.schedule(async()=> |
|
v=await this._setViewpointOfInterest(a,l)),k.schedule(()=>this._applyBasemap(a,l),l.signal)]);await this._loadLayersWithSublayerVisibility(a);await Promise.all([k.schedule(()=>this._applyLayerVisibility(a),l.signal),k.schedule(()=>this._applyGround(a),l.signal),k.schedule(()=>this._applyViewpoint(a,l),l.signal),k.schedule(()=>a.timeExtent=this.timeExtent?.clone()??null,l.signal)]);await k.schedule(()=>a.environment.weather=this.environment.weather.clone())})()));v&&(a.contentCamera=null);k.remove(); |
|
g();if(!1===b.ok)throw b.error;return this}async _applyBasemap(a,b){if(this.basemap){try{await this.basemap.load(b)}catch(c){if(w.isAbortError(c))throw c;}a.map.basemap=F.clonePreservingTiledLayers(this.basemap,a.map.basemap)}}_applyGround(a){this.ground&&(a.map.ground=this.ground.cloneAndApplyTo(a.map.ground))}_getLayers(a){const b=new B;this._collectLayers(a,b);this._collectLayers(a.ground,b);return b}_collectLayers(a,b){a.layers.forEach(c=>{c.persistenceEnabled&&(b.add(c),"layers"in c&&this._collectLayers(c, |
|
b))})}async _loadLayersWithSublayerVisibility(a){this.visibleLayers&&await Promise.allSettled(this._getLayers(a.map).items.map(b=>this.visibleLayers.find(c=>c.id===b.id)?.sublayerIds?b.load():null))}_applyLayerVisibility(a){this.visibleLayers&&this._getLayers(a.map).forEach(b=>{var c=this.visibleLayers.find(g=>g.id===b.id);b.visible=null!=c;const f=c?.sublayerIds;c=J(b);f&&c&&c.forEach(g=>g.visible=f.includes(g.id))})}async _setViewpointOfInterest(a,b){if(a.state.fixedContentCamera||!this.viewpoint|| |
|
b?.ignoreViewpoint||!b?.useDestinationCamera)return!1;({toCameraAsync:b}=await new Promise((c,f)=>O(["../views/3d/support/viewpointUtils"],c,f)));b=await b(a,this.viewpoint);a.contentCamera=b;return null!=b}async _applyViewpoint(a,b){this._applyCachedCameraTrackingEnabled(a);if(this.viewpoint&&!b.ignoreViewpoint){null!=this.viewpoint.camera&&(this.viewpoint.camera.fov=a.camera.fov);const c=this.environment.lighting;if(b.animate&&"sun"===c.type&&c.date)return this._animateToLighting(a,b);b.animate&& |
|
(a.environment.applyLighting(c.clone()),await a.goTo(this.viewpoint,b));a.viewpoint=this.viewpoint}a.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(a,b){let c=null;"virtual"!==a.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===a.viewingMode&&(c=this._animateLightingWithCamera(a,a.environment.lighting,this.environment.lighting)),a.environment.cachedCameraTrackingEnabled=a.environment.lighting.cameraTrackingEnabled,a.environment.lighting.cameraTrackingEnabled= |
|
!1);a.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled;"virtual"===this.environment.lighting.type||"virtual"===a.environment.lighting.type?(a.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==a.environment.lighting.type&&(a.environment.cachedCameraTrackingEnabled=a.environment.lighting.cameraTrackingEnabled,a.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(a.environment.lighting.displayUTCOffset= |
|
this.environment.lighting.displayUTCOffset);return a.goTo(this.viewpoint,b).then(()=>{this._applyCachedCameraTrackingEnabled(a);a.environment.applyLighting(this.environment.lighting.clone())}).catch(f=>{null==a.animation&&this._applyCachedCameraTrackingEnabled(a);throw f;}).finally(()=>{C.removeMaybe(c)})}_applyCachedCameraTrackingEnabled(a){null!=a.environment.cachedCameraTrackingEnabled&&(a.environment.lighting.cameraTrackingEnabled=a.environment.cachedCameraTrackingEnabled,a.environment.cachedCameraTrackingEnabled= |
|
null)}_getTime(a){const b=a.getTime();a=3600*a.getUTCHours()+60*a.getUTCMinutes()+a.getUTCSeconds();return[b,a]}_setTime(a,b,c){a.setTime(b);a.setUTCHours(c/3600);a.setUTCMinutes(c%3600/60);a.setUTCSeconds(c%3600%60);return a}_animateLightingWithCamera(a,b,c){const [f,g]=this._getTime(new Date(b.date.toString())),[k,v]=this._getTime(c.date),l=ba(g,v),r=a.renderCoordsHelper,L=y.create();r.toRenderCoords(a.camera.position,L);const M=y.create(),A=y.create();null!=this.viewpoint.camera&&r.toRenderCoords(this.viewpoint.camera.position, |
|
M);const da=new Date;return D.when(()=>a.camera,m=>{r.toRenderCoords(m.position,A);var t=E.squaredDistance(L,A);const N=E.squaredDistance(M,A);m=0;0!==t+N&&(m=t/(t+N));t=f+(k-f)*m;m=U.moduloPositive(g+l*m,86400);b.date=this._setTime(da,t,m)})}static createFrom(a,b){return(new this).updateFrom(a,b)}};e.__decorate([h.property({type:String,json:{write:{isRequired:!0}}})],d.prototype,"id",void 0);e.__decorate([h.property({type:q,json:{default:()=>new q({text:""}),write:{isRequired:!0}}})],d.prototype, |
|
"title",void 0);e.__decorate([p.cast("title")],d.prototype,"castTitle",null);e.__decorate([h.property({type:u,json:{write:{overridePolicy(a){return{enabled:!(!a||!a.text)}}}}})],d.prototype,"description",void 0);e.__decorate([p.cast("description")],d.prototype,"castDescription",null);e.__decorate([h.property({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],d.prototype,"hidden",void 0);e.__decorate([h.property({type:n.SlideThumbnail,json:{default:()=>new n.SlideThumbnail({url:""}),write:{isRequired:!0}}})], |
|
d.prototype,"thumbnail",void 0);e.__decorate([p.cast("thumbnail")],d.prototype,"castThumbnail",null);e.__decorate([h.property({type:Q,nonNullable:!0,json:{write:{isRequired:!0}}})],d.prototype,"viewpoint",void 0);e.__decorate([h.property({type:P,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],d.prototype,"basemap",void 0);e.__decorate([p.cast("basemap")],d.prototype,"castBasemap",null);e.__decorate([h.property({type:H,json:{write:!0}})],d.prototype,"ground",void 0);e.__decorate([h.property({type:z, |
|
json:{write:{isRequired:!0}}})],d.prototype,"visibleLayers",null);e.__decorate([p.cast("visibleLayers")],d.prototype,"castVisibleLayers",null);e.__decorate([h.property({type:G.SlideEnvironment,json:{write:!0}})],d.prototype,"environment",void 0);e.__decorate([h.property(Y.timeExtent)],d.prototype,"timeExtent",void 0);return d=e.__decorate([V.subclass("esri.webscene.Slide")],d)}); |