WebScene.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  2. // See https://js.arcgis.com/4.7/esri/copyright.txt for details.
  3. //>>built
  4. require({cache:{"esri/core/accessorSupport/originUtils":function(){define(["require","exports","../MultiOriginJSONSupport"],function(q,h,l){Object.defineProperty(h,"__esModule",{value:!0});h.updateOrigins=function(a){a&&a.writtenProperties&&a.writtenProperties.forEach(function(a){var c=a.target;a.newOrigin&&a.oldOrigin!==a.newOrigin&&c.isInstanceOf(l)&&c.updateOrigin(a.propName,a.newOrigin)})}})},"esri/support/webSceneUtils":function(){define(["require","exports","../core/Error"],function(q,h,l){Object.defineProperty(h,
  5. "__esModule",{value:!0});h.createCopyError=function(){return new l("webscene:failed-to-copy-embedded-resources","Copying of embedded resources is currently not supported")};h.isCopyError=function(a){return a&&"webscene:failed-to-copy-embedded-resources"===a.name};h.createSchemaValidationError=function(a){return new l("webscene:schema-validation","Failed to save webscene due to schema validation errors. See 'details.errors' for more detailed information",{errors:a})};h.isSchemaValidationError=function(a){return a&&
  6. "webscene:schema-validation"===a.name}})},"esri/webscene/ApplicationProperties":function(){define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../core/JSONSupport ../core/accessorSupport/decorators ./applicationProperties/Viewing".split(" "),function(q,h,l,a,k,c,d){return function(b){function f(a){a=b.call(this,a)||this;a.viewing=null;return a}l(f,b);g=f;f.prototype.clone=function(){return new g({viewing:this.viewing?this.viewing.clone():null})};a([c.property({type:d,
  7. json:{write:!0}})],f.prototype,"viewing",void 0);return f=g=a([c.subclass("esri.webscene.ApplicationProperties")],f);var g}(c.declared(k))})},"esri/webscene/applicationProperties/Viewing":function(){define("require exports ../../core/tsSupport/declareExtendsHelper ../../core/tsSupport/decorateHelper ../../core/JSONSupport ../../core/accessorSupport/decorators ./Search".split(" "),function(q,h,l,a,k,c,d){return function(b){function f(a){a=b.call(this,a)||this;a.search=null;return a}l(f,b);g=f;f.prototype.clone=
  8. function(){return new g({search:this.search?this.search.clone():null})};a([c.property({type:d,json:{write:!0}})],f.prototype,"search",void 0);return f=g=a([c.subclass("esri.webscene.applicationProperties.Viewing")],f);var g}(c.declared(k))})},"esri/webscene/applicationProperties/Search":function(){define("require exports ../../core/tsSupport/declareExtendsHelper ../../core/tsSupport/decorateHelper ../../core/Collection ../../core/JSONSupport ../../core/accessorSupport/decorators ./SearchLayer".split(" "),
  9. function(q,h,l,a,k,c,d,b){var f=k.ofType(b);return function(c){function b(a){a=c.call(this,a)||this;a.enabled=!1;a.hintText=null;a.layers=new f;return a}l(b,c);g=b;b.prototype.clone=function(){return new g({enabled:this.enabled,hintText:this.hintText,layers:this.layers?this.layers.clone():null})};a([d.property({type:Boolean,json:{write:!0}})],b.prototype,"enabled",void 0);a([d.property({type:String,json:{write:!0}})],b.prototype,"hintText",void 0);a([d.property({type:f,json:{write:{enabled:!0,isRequired:!0}}})],
  10. b.prototype,"layers",void 0);return b=g=a([d.subclass("esri.webscene.applicationProperties.Search")],b);var g}(d.declared(c))})},"esri/webscene/applicationProperties/SearchLayer":function(){define("require exports ../../core/tsSupport/declareExtendsHelper ../../core/tsSupport/decorateHelper ../../core/JSONSupport ../../core/accessorSupport/decorators ../../core/accessorSupport/ensureType ./SearchLayerField".split(" "),function(q,h,l,a,k,c,d,b){return function(f){function g(a){a=f.call(this,a)||this;
  11. a.field=null;a.id=null;a.subLayer=null;return a}l(g,f);y=g;g.prototype.clone=function(){return new y({field:this.field?this.field.clone():null,id:this.id,subLayer:this.subLayer})};a([c.property({type:b,json:{write:{enabled:!0,isRequired:!0}}})],g.prototype,"field",void 0);a([c.property({type:String,json:{write:{enabled:!0,isRequired:!0}}})],g.prototype,"id",void 0);a([c.property({type:d.Integer,json:{write:!0}})],g.prototype,"subLayer",void 0);return g=y=a([c.subclass("esri.webscene.applicationProperties.SearchLayer")],
  12. g);var y}(c.declared(k))})},"esri/webscene/applicationProperties/SearchLayerField":function(){define("require exports ../../core/tsSupport/declareExtendsHelper ../../core/tsSupport/decorateHelper ../../core/JSONSupport ../../core/accessorSupport/decorators ../../layers/support/fieldType".split(" "),function(q,h,l,a,k,c,d){return function(b){function f(a){a=b.call(this,a)||this;a.exactMatch=!1;a.name=null;a.type=null;return a}l(f,b);g=f;f.prototype.clone=function(){return new g({exactMatch:this.exactMatch,
  13. type:this.type,name:this.name})};a([c.property({type:Boolean,json:{write:!0}})],f.prototype,"exactMatch",void 0);a([c.property({type:String,json:{write:!0}})],f.prototype,"name",void 0);a([c.property({type:String,json:{read:d.kebabDict.read,write:d.kebabDict.write}})],f.prototype,"type",void 0);return f=g=a([c.subclass("esri.webscene.applicationProperties.SearchLayerField")],f);var g}(c.declared(k))})},"esri/webscene/Environment":function(){define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../core/JSONSupport ../core/accessorSupport/decorators ./Lighting".split(" "),
  14. function(q,h,l,a,k,c,d){return function(b){function f(a){a=b.call(this,a)||this;a.lighting=new d;return a}l(f,b);g=f;f.prototype.clone=function(){return new g({lighting:d.prototype.clone.call(this.lighting)})};f.sanitizeJSON=function(a){return{lighting:a.lighting?d.sanitizeJSON(a.lighting):(new d).toJSON()}};a([c.property({type:d,json:{write:!0}})],f.prototype,"lighting",void 0);return f=g=a([c.subclass("esri.webscene.Environment")],f);var g}(c.declared(k))})},"esri/webscene/Lighting":function(){define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../core/JSONSupport ../core/accessorSupport/decorators".split(" "),
  15. function(q,h,l,a,k,c){return function(d){function b(a){a=d.call(this,a)||this;a.date=null;a.directShadowsEnabled=!1;a.displayUTCOffset=null;return a}l(b,d);f=b;b.prototype.readDate=function(a,b){return null!=b.datetime&&new Date(b.datetime)||null};b.prototype.writeDate=function(a,b,c){b[c]=a.getTime()};b.prototype.readDirectShadowsEnabled=function(a,b){return!!b.directShadows};b.prototype.writedirectShadowsEnabled=function(a,b,c){a&&(b[c]=a)};b.prototype.writeDisplayUTCOffset=function(a,b){null!=
  16. a&&(b.displayUTCOffset=a)};b.prototype.clone=function(){return new f({date:null!=this.date?new Date(this.date.getTime()):null,directShadowsEnabled:this.directShadowsEnabled,displayUTCOffset:null!=this.displayUTCOffset?this.displayUTCOffset:null})};b.sanitizeJSON=function(a){var b={datetime:a.datetime};void 0!==a.directShadows&&(b.directShadows=!!a.directShadows);void 0!==a.displayUTCOffset&&(b.displayUTCOffset=a.displayUTCOffset);return b};a([c.property({type:Date,json:{type:Number,write:{target:"datetime"}}})],
  17. b.prototype,"date",void 0);a([c.reader("date",["datetime"])],b.prototype,"readDate",null);a([c.writer("date")],b.prototype,"writeDate",null);a([c.property({type:Boolean,json:{write:{target:"directShadows"}}})],b.prototype,"directShadowsEnabled",void 0);a([c.reader("directShadowsEnabled",["directShadows"])],b.prototype,"readDirectShadowsEnabled",null);a([c.writer("directShadowsEnabled")],b.prototype,"writedirectShadowsEnabled",null);a([c.property({type:Number,json:{write:!0}})],b.prototype,"displayUTCOffset",
  18. void 0);a([c.writer("displayUTCOffset")],b.prototype,"writeDisplayUTCOffset",null);return b=f=a([c.subclass("esri.webscene.Lighting")],b);var f}(c.declared(k))})},"esri/webscene/InitialViewProperties":function(){define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../Viewpoint ../core/Accessor ../core/accessorSupport/decorators ../geometry/SpatialReference ./Environment".split(" "),function(q,h,l,a,k,c,d,b,f){return function(c){function g(a){a=c.call(this,
  19. a)||this;a.environment=new f;a.spatialReference=null;a.viewpoint=null;return a}l(g,c);h=g;Object.defineProperty(g.prototype,"viewingMode",{set:function(a){"local"!==a&&"global"!==a||this._set("viewingMode",a)},enumerable:!0,configurable:!0});g.prototype.clone=function(){return new h({environment:this.environment.clone(),spatialReference:this.spatialReference?this.spatialReference.clone():null,viewingMode:this.viewingMode,viewpoint:this.viewpoint?this.viewpoint.clone():null})};a([d.property({type:f,
  20. json:{write:{isRequired:!0}}})],g.prototype,"environment",void 0);a([d.property({type:b})],g.prototype,"spatialReference",void 0);a([d.property()],g.prototype,"viewingMode",null);a([d.property({type:k,json:{write:{isRequired:!0}}})],g.prototype,"viewpoint",void 0);return g=h=a([d.subclass("esri.webscene.InitialViewProperties")],g);var h}(d.declared(c))})},"esri/webscene/Presentation":function(){define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../core/Collection ../core/collectionUtils ../core/JSONSupport ../core/accessorSupport/decorators ./Slide".split(" "),
  21. function(q,h,l,a,k,c,d,b,f){var g=k.ofType(f);return function(d){function k(a){a=d.call(this,a)||this;a.slides=new g;return a}l(k,d);Object.defineProperty(k.prototype,"slides",{set:function(a){this._set("slides",c.referenceSetter(a,this._get("slides"),g))},enumerable:!0,configurable:!0});k.prototype.clone=function(){return new this.constructor({slides:this.slides.clone()})};k.sanitizeJSON=function(a){return{slides:void 0!==a.slides&&Array.isArray(a.slides)?a.slides.filter(function(a){return a&&!!a.viewpoint}).map(function(a){return f.sanitizeJSON(a)}):
  22. []}};a([b.property({type:g,json:{write:!0}}),b.cast(c.castForReferenceSetter)],k.prototype,"slides",null);return k=a([b.subclass("esri.webscene.Presentation")],k)}(b.declared(d))})},"esri/webscene/Slide":function(){define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper dojo/_base/lang dojo/promise/all ../Basemap ../Viewpoint ../core/Collection ../core/collectionUtils ../core/JSONSupport ../core/lang ../core/Logger ../core/promiseUtils ../core/accessorSupport/decorators ../core/accessorSupport/ensureType ../support/basemapUtils ../views/3d/lib/glMatrix ./Environment ./Lighting ./support/Description ./support/Thumbnail ./support/Title".split(" "),
  23. function(q,h,l,a,k,c,d,b,f,g,y,u,G,A,t,r,B,p,D,L,E,C,w){var M=0,H=function(b){function c(){var a=null!==b&&b.apply(this,arguments)||this;a.id="";return a}l(c,b);x=c;c.prototype.clone=function(){return new x({id:this.id})};a([t.property({type:String,json:{write:!0}})],c.prototype,"id",void 0);return c=x=a([t.subclass()],c);var x}(t.declared(y)),z=f.ofType(H),I=G.getLogger("esri.webscene.Slide");return function(h){function m(a){a=h.call(this,a)||this;a._currentAnimation=null;a.id=Date.now().toString(16)+
  24. "-slide-"+M++;a.title=new w.default;a.description=new E.default;a.thumbnail=new C.default;a.viewpoint=null;a.basemap=null;a.environment=new D;a.visibleLayers=new z;return a}l(m,h);m.prototype.castTitle=function(a){return"string"===typeof a?new w.default({text:a}):r.ensureType(w.default,a)};m.prototype.castDescription=function(a){return"string"===typeof a?new E.default({text:a}):r.ensureType(E.default,a)};m.prototype.castThumbnail=function(a){return"string"===typeof a?new C.default({url:a}):r.ensureType(C.default,
  25. a)};m.prototype.castBasemap=function(a){return B.ensureType(a)};Object.defineProperty(m.prototype,"visibleLayers",{set:function(a){this._set("visibleLayers",g.referenceSetter(a,this._get("visibleLayers"),z))},enumerable:!0,configurable:!0});m.prototype.castVisibleLayers=function(a){return a&&"function"===typeof a.map?a.map(function(a){if("string"===typeof a)return{id:a};if(a.id)return{id:a.id};I.warn('Invalid visible layer, expected { id }, Layer or "id"');return a}):a};m.prototype.clone=function(){return new this.constructor({id:this.id,
  26. 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&&this.basemap.clone()||null,visibleLayers:this.visibleLayers.clone(),environment:this.environment&&this.environment.clone()||null})};m.prototype._updateVisibleLayersFrom=function(a){var b=this,c=[];return A.eachAlways(this._allLayers(a.map).map(function(b){return a.whenLayerView(b).then(function(a){a.visible&&
  27. c.push(new H({id:a.layer.id}))})}).toArray()).then(function(){b.visibleLayers.removeAll();b.visibleLayers.addMany(c)})};m.prototype.updateFrom=function(a,b){var c=this;b=k.mixin({screenshot:k.mixin({format:"jpeg",quality:80,width:120,height:75},b&&b.screenshot)},b);return a.when(function(){c.viewpoint=a.viewpoint.clone();c.environment.lighting=L.prototype.clone.apply(a.environment.lighting);c.basemap=a.map.basemap&&a.map.basemap.clone()||null;return c._updateVisibleLayersFrom(a)}).then(function(){return a.takeScreenshot(b.screenshot)}).then(function(a){c.thumbnail=
  28. new C.default({url:a.dataURL});return c})};m.prototype.applyTo=function(a,b){var d=this,x=k.mixin({animate:!0},b);return this._applyBasemap(a).then(function(){return c([d._applyViewpoint(a,x),d._applyLayerVisibility(a,x)])}).then(function(){return d})};m.prototype._applyBasemap=function(a){var b=this;return this.basemap?this.basemap.load().always(function(){a.map.basemap=B.clonePreservingTiledLayers(b.basemap,a.map.basemap)}):A.resolve()};m.prototype._allLayers=function(a){var b=new f;this._collectLayers(a,
  29. b);this._collectLayers(a.ground,b);return b};m.prototype._collectLayers=function(a,b){var c=this;a.layers.forEach(function(a){b.add(a);a.layers&&c._collectLayers(a,b)})};m.prototype._applyLayerVisibility=function(a,b){var c=this;if(this.visibleLayers){var d=this._allLayers(a.map);if(b.applyToLayerViews)return A.eachAlways(d.map(function(b){return a.whenLayerView(b).then(function(a){a.visible=c.visibleLayers.some(function(b){return b.id===a.layer.id})})}).toArray());d.forEach(function(a){return a.visible=
  30. c.visibleLayers.some(function(b){return b.id===a.id})});return A.resolve()}};m.prototype._applyViewpoint=function(a,b){if(this.viewpoint){this.viewpoint.camera.fov=a.camera.fov;if(b.animate){if(this.get("environment.lighting.date"))return this._animateToLighting(a,b);a.environment.lighting=this.environment.lighting.clone();return a.goTo(this.viewpoint,b)}a.viewpoint=this.viewpoint;a.environment.lighting=this.environment.lighting.clone()}return A.resolve()};m.prototype._animateToLighting=function(a,
  31. b){var c=this,d;"global"===a.viewingMode&&(d=this._animateLightingWithCamera(a));this._currentAnimation&&(this._currentAnimation.cancel(),this._currentAnimation=null);a.environment.lighting.cameraTrackingEnabled=!1;a.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled;null!=this.environment.lighting.displayUTCOffset&&(a.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);var f=a.goTo(this.viewpoint,b);this._currentAnimation=f;this._currentAnimation.always(function(){d&&
  32. d.remove();c._currentAnimation===f&&(a.environment.lighting.cameraTrackingEnabled=!0)});this._currentAnimation.then(function(){a.environment.lighting=c.environment.lighting.clone()});return this._currentAnimation};m.prototype._getTime=function(a){var b=a.getTime();a=3600*a.getUTCHours()+60*a.getUTCMinutes()+a.getUTCSeconds();return[b,a]};m.prototype._setTime=function(a,b,c){a.setTime(b);a.setUTCHours(c/3600);a.setUTCMinutes(c%3600/60);a.setUTCSeconds(c%3600%60);return a};m.prototype._animateLightingWithCamera=
  33. function(a){var b=this,c=p.vec3d,d=this._getTime(new Date(a.environment.lighting.date.toString())),f=d[0],g=d[1],d=this._getTime(this.environment.lighting.date),k=d[0],e=d[1],n=a.renderCoordsHelper,v=[0,0,0];n.toRenderCoords(a.camera.position,v);var S=[0,0,0];n.toRenderCoords(this.viewpoint.camera.position,S);var N=[0,0,0],h=new Date;return a.watch("camera",function(d){n.toRenderCoords(d.position,N);d=c.dist2(v,N);var T=c.dist2(S,N),O=0;0!==d+T&&(O=d/(d+T));a.environment.lighting.date=b._setTime(h,
  34. f+(k-f)*O,g+(e-g)*O)})};m.createFrom=function(a,b){return(new this).updateFrom(a,b)};m.sanitizeJSON=function(a){var b;b=void 0!==a.visibleLayers&&Array.isArray(a.visibleLayers)?u.clone(a.visibleLayers):[];b={id:a.id||"",title:a.title||{text:""},thumbnail:a.thumbnail||{url:""},viewpoint:a.viewpoint,baseMap:a.baseMap,visibleLayers:b};void 0!==a.description&&(b.description=a.description);void 0!==a.environment&&(b.environment=D.sanitizeJSON(a.environment));return b};a([t.property({type:String,json:{write:{isRequired:!0}}})],
  35. m.prototype,"id",void 0);a([t.property({type:w.default,json:{write:{isRequired:!0}}})],m.prototype,"title",void 0);a([t.cast("title")],m.prototype,"castTitle",null);a([t.property({type:E.default,json:{write:{overridePolicy:function(a){return{enabled:!(!a||!a.text)}}}}})],m.prototype,"description",void 0);a([t.cast("description")],m.prototype,"castDescription",null);a([t.property({type:C.default,json:{write:{isRequired:!0}}})],m.prototype,"thumbnail",void 0);a([t.cast("thumbnail")],m.prototype,"castThumbnail",
  36. null);a([t.property({type:b,json:{write:{isRequired:!0}}})],m.prototype,"viewpoint",void 0);a([t.property({type:d,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],m.prototype,"basemap",void 0);a([t.cast("basemap")],m.prototype,"castBasemap",null);a([t.property({type:z,json:{write:{isRequired:!0}}})],m.prototype,"visibleLayers",null);a([t.cast("visibleLayers")],m.prototype,"castVisibleLayers",null);a([t.property({type:D,json:{write:!0}})],m.prototype,"environment",void 0);return m=a([t.subclass("esri.webscene.Slide")],
  37. m)}(t.declared(y))})},"esri/webscene/support/Description":function(){define("require exports ../../core/tsSupport/declareExtendsHelper ../../core/tsSupport/decorateHelper ../../core/JSONSupport ../../core/accessorSupport/decorators".split(" "),function(q,h,l,a,k,c){Object.defineProperty(h,"__esModule",{value:!0});q=function(d){function b(){var a=null!==d&&d.apply(this,arguments)||this;a.text="";return a}l(b,d);f=b;b.prototype.clone=function(){return new f({text:this.text})};a([c.property({type:String,
  38. json:{write:!0}})],b.prototype,"text",void 0);return b=f=a([c.subclass("esri.webscene.support.Description")],b);var f}(c.declared(k));h.default=q})},"esri/webscene/support/Thumbnail":function(){define("require exports ../../core/tsSupport/declareExtendsHelper ../../core/tsSupport/decorateHelper ../../core/JSONSupport ../../core/accessorSupport/decorators".split(" "),function(q,h,l,a,k,c){Object.defineProperty(h,"__esModule",{value:!0});q=function(d){function b(){var a=null!==d&&d.apply(this,arguments)||
  39. this;a.url="";return a}l(b,d);f=b;b.prototype.clone=function(){return new f({url:this.url})};a([c.property({type:String,json:{write:{isRequired:!0}}})],b.prototype,"url",void 0);return b=f=a([c.subclass("esri.webscene.support.Thumbnail")],b);var f}(c.declared(k));h.default=q})},"esri/webscene/support/Title":function(){define("require exports ../../core/tsSupport/declareExtendsHelper ../../core/tsSupport/decorateHelper ../../core/JSONSupport ../../core/accessorSupport/decorators".split(" "),function(q,
  40. h,l,a,k,c){Object.defineProperty(h,"__esModule",{value:!0});q=function(d){function b(){var a=null!==d&&d.apply(this,arguments)||this;a.text="";return a}l(b,d);f=b;b.prototype.clone=function(){return new f({text:this.text})};a([c.property({type:String,json:{write:{isRequired:!0}}})],b.prototype,"text",void 0);return b=f=a([c.subclass("esri.webscene.support.Title")],b);var f}(c.declared(k));h.default=q})},"esri/webscene/Version":function(){define(["require","exports","../core/tsSupport/extendsHelper",
  41. "../core/Version"],function(q,h,l,a){Object.defineProperty(h,"__esModule",{value:!0});q=function(a){function c(c,b){return a.call(this,c,b,"webscene")||this}l(c,a);Object.defineProperty(c.prototype,"supportsGround",{get:function(){return this.since(1,8)},enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"supportsVisibleElevationLayersInSlides",{get:function(){return this.lessThan(1,8)},enumerable:!0,configurable:!0});return c}(a.Version);h.Version=q;h.default=q})},"esri/core/Version":function(){define(["require",
  42. "exports","./Error"],function(q,h,l){Object.defineProperty(h,"__esModule",{value:!0});q=function(){function a(a,c,d){void 0===d&&(d="");this.major=a;this.minor=c;this._context=d}a.prototype.lessThan=function(a,c){return this.major<a||a===this.major&&this.minor<c};a.prototype.since=function(a,c){return!this.lessThan(a,c)};a.prototype.validate=function(a){if(this.major!==a.major)throw new l((this._context&&this._context+":")+"unsupported-version","Required major "+(this._context&&this._context+" ")+
  43. "version is '"+this.major+"', but got '${version.major}.${version.minor}'",{version:a});};a.prototype.clone=function(){return new a(this.major,this.minor,this._context)};a.parse=function(k,c){void 0===c&&(c="");var d=k.split("."),b=d[0],d=d[1],f=/^\s*\d+\s*$/;if(!b||!b.match||!b.match(f))throw new l((c&&c+":")+"invalid-version","Expected major version to be a number, but got '${version}'",{version:k});if(!d||!d.match||!d.match(f))throw new l((c&&c+":")+"invalid-version","Expected minor version to be a number, but got '${version}'",
  44. {version:k});k=parseInt(b,10);b=parseInt(d,10);return new a(k,b,c)};return a}();h.Version=q})},"*noref":1}});
  45. define("require exports ./core/tsSupport/declareExtendsHelper ./core/tsSupport/decorateHelper ./core/tsSupport/paramHelper dojo/has dojo/_base/lang ./kernel ./Map ./Viewpoint ./core/Collection ./core/Error ./core/JSONSupport ./core/Loadable ./core/Logger ./core/promiseUtils ./core/urlUtils ./core/accessorSupport/decorators ./core/accessorSupport/originUtils ./core/accessorSupport/read ./geometry/Extent ./geometry/HeightModelInfo ./geometry/SpatialReference ./geometry/support/heightModelInfoUtils ./geometry/support/jsonUtils ./portal/Portal ./portal/PortalItem ./support/webSceneUtils ./webscene/ApplicationProperties ./webscene/Environment ./webscene/InitialViewProperties ./webscene/Presentation ./webscene/Version".split(" "),function(q,
  46. h,l,a,k,c,d,b,f,g,y,u,G,A,t,r,B,p,D,L,E,C,w,M,H,z,I,P,m,x,Q,R,J){var F=t.getLogger("esri.WebScene"),K=new J.default(1,10);return function(c){function e(a){a=c.call(this)||this;a.applicationProperties=null;a.clippingArea=null;a.clippingEnabled=!1;a.heightModelInfo=null;a.sourceVersion=null;a.supportsHeightModelInfo=!0;a.presentation=null;a.initialViewProperties=null;a.portalItem=null;a.resourceInfo=null;a.authoringApp=null;a.authoringAppVersion=null;a._isAuthoringAppSetByUser=!1;a._isAuthoringAppVersionSetByUser=
  47. !1;return a}l(e,c);e.prototype.initialize=function(){this.when().catch(function(a){F.error("#load()","Failed to load web scene",a)});if(this.resourceInfo){var a=void 0;try{a=this._validateJSON(this.resourceInfo)}catch(v){this.addResolvingPromise(r.reject(v));return}this.read(a);this.addResolvingPromise(this._validateSpatialReference());this.addResolvingPromise(this._validateHeightModelInfo())}};e.prototype.getDefaults=function(a){return d.mixin(this.inherited(arguments),{presentation:{},initialViewProperties:{}})};
  48. e.prototype.writeClippingArea=function(a,b){b.clippingArea||(b.clippingArea={});b.clippingArea.geometry=a.toJSON()};e.prototype.readClippingEnabled=function(a,b){return b.clippingArea?!!b.clippingArea.clip:!1};e.prototype.writeClippingEnabled=function(a,b){this.clippingArea&&(b.clippingArea||(b.clippingArea={}),b.clippingArea.clip=a)};e.prototype.writeLayers=function(a,b,c,e){var n=this,v=d.mixin({},e,{layerContainerType:"operational-layers"});a=a.filter(function(a){return n.verifyWriteLayer(a,v)}).map(function(a){return a.write(null,
  49. v)}).filter(function(a){return!!a});b[c]=a.toArray()};e.prototype.verifyWriteLayer=function(a,b){return a.write?!0:(b&&b.messages&&b.messages.push(new u("layer:unsupported","Layers ("+a.title+", "+a.id+") of type '"+a.declaredClass+"' cannot be persisted in web scenes",{layer:a})),!1)};e.prototype.readSourceVersion=function(a,b){a=b.version.split(".");b=a[1];return new J.default(parseInt(a[0],10),parseInt(b,10))};e.prototype.writeSourceVersion=function(a,b,c){b[c]=K.major+"."+K.minor};Object.defineProperty(e.prototype,
  50. "authoringApp",{set:function(a){this._isAuthoringAppSetByUser=!0;this._set("authoringApp",a)},enumerable:!0,configurable:!0});e.prototype.writeAuthoringApp=function(a,b){b.authoringApp=a&&this._isAuthoringAppSetByUser?a:"ArcGIS API for JavaScript"};Object.defineProperty(e.prototype,"authoringAppVersion",{set:function(a){this._isAuthoringAppVersionSetByUser=!0;this._set("authoringAppVersion",a)},enumerable:!0,configurable:!0});e.prototype.writeAuthoringAppVersion=function(a,c){c.authoringAppVersion=
  51. a&&this._isAuthoringAppVersionSetByUser?a:b.version};e.prototype.writeGround=function(a,b,c,d){b[c]=a?a.write(null,d):{layers:[]}};e.prototype.readInitialViewProperties=function(a,b){a={};b.initialState&&b.initialState.environment&&(a.environment=x.fromJSON(b.initialState.environment));b.spatialReference&&(a.spatialReference=w.fromJSON(b.spatialReference));a.viewingMode=b.viewingMode||"global";b.initialState&&b.initialState.viewpoint&&(a.viewpoint=g.fromJSON(b.initialState.viewpoint));return new Q(a)};
  52. e.prototype.writeInitialViewProperties=function(a,b,c,d){a&&(c={},a.environment&&(c.environment=a.environment.write({},d)),a.viewpoint&&(c.viewpoint=a.viewpoint.write({},d)),0!==Object.keys(c).length&&(b.initialState=c),b.spatialReference=a.spatialReference?a.spatialReference.write({},d):w.WebMercator.toJSON(),b.viewingMode=null!=a.viewingMode?a.viewingMode:"global")};e.prototype.load=function(){this.addResolvingPromise(this._loadFromSource());return this.when()};e.prototype.read=function(a,b){var c=
  53. this;b=d.mixin({},b,{origin:"web-scene"});var n=this._isAuthoringAppVersionSetByUser,v=this._isAuthoringAppSetByUser,e=arguments;L.readLoadable(this,a,function(b){return c.inherited(e,[a,b])},b);v||(this._isAuthoringAppSetByUser=!1);n||(this._isAuthoringAppVersionSetByUser=!1);if(a.baseMap&&Array.isArray(a.baseMap.elevationLayers)&&this.sourceVersion.supportsVisibleElevationLayersInSlides){var n=a.baseMap.elevationLayers.map(function(a){return{id:a.id}}),f=this.presentation.slides,g=function(a,b){return a.visibleLayers.some(function(a){return a.id===
  54. b})},k=n.filter(function(a){return!f.some(function(b){return g(b,a.id)})});f.forEach(function(a){a.visibleLayers.addMany(k)})}return this};e.prototype._writeBasemapElevationLayers=function(a){var b=a.ground&&a.ground.layers;!a.baseMap&&b&&b.length&&(a.baseMap={title:"Basemap",baseMapLayers:[]});a.baseMap&&(a.baseMap.elevationLayers=d.clone(b))};e.prototype.write=function(a,b){if("loaded"!==this.loadStatus){var c=new u("webscene:not-loaded","Web scene must be loaded before it can be serialized");F.error("#toJSON()",
  55. "Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus);throw c;}b=d.mixin({},b,{origin:"web-scene"});c=this.inherited(arguments,[a,b]);this._writeBasemapElevationLayers(c);return c};e.prototype.save=function(a){var b=this;if(!this.portalItem)return F.error("save(): requires the .portalItem property to be set"),r.reject(new u("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene"));if("Web Scene"!==this.portalItem.type)return r.reject(new u("webscene:portal-item-wrong-type",
  56. 'Portal item needs to have type "Web Scene"'));var c,n;return this.load().then(function(){return b._loadObjectsWithLayers()}).then(function(){c=b._enableVerifyItemRelativeUrls({origin:"web-scene",url:b.portalItem.itemUrl&&B.urlToObject(b.portalItem.itemUrl),messages:[],portal:b.portalItem.portal||z.getDefault(),writtenProperties:[],blockedRelativeUrls:[]});n=b.write(null,c);return b._verifySave(n,c,a).then(function(){b._updateTypeKeywords(b.portalItem);return b.portalItem.update({data:n})})}).then(function(){D.updateOrigins(c);
  57. return r.resolve(b.portalItem)})};e.prototype.saveAs=function(a,b){var c=this;if(!a)return F.error("saveAs(portalItem): requires a portal item parameter"),r.reject(new u("webscene:portal-item-required","saveAs requires a portal item to save to"));if(a.type&&"Web Scene"!==a.type||a.id)return r.reject(new u("webscene:portal-item-already-exists","WebScene can only saveAs to a new and empty portal item"));var n=a.portal||z.getDefault(),d,e;return this.load().then(function(){return c._loadObjectsWithLayers()}).then(function(){d=
  58. c._enableVerifyItemRelativeUrls({origin:"web-scene",url:null,messages:[],portal:n,writtenProperties:[],blockedRelativeUrls:[]});e=c.write(null,d);return c._verifySaveAs(e,d,b).then(function(){return n._signIn()})}).then(function(){a.type="Web Scene";a.portal=n;c._updateTypeKeywords(a);return n.user.addItem({item:a,folder:b&&b.folder,data:e})}).then(function(){c.portalItem=a;G.prototype.read.call(c,{version:e.version,authoringApp:e.authoringApp,authoringAppVersion:e.authoringAppVersion},{name:"web-scene",
  59. url:a.itemUrl&&B.urlToObject(a.itemUrl)});D.updateOrigins(d);return r.resolve(a)})};e.prototype._verifySave=function(a,b,c,d){void 0===d&&(d=!1);var n=b.messages.filter(function(a){return"error"===a.type}).map(function(a){return new u(a.name,a.message,a.details)});b.blockedRelativeUrls&&(n=n.concat(b.blockedRelativeUrls.map(function(a){return new u("url:unsupported","Relative url '"+a+"' is not supported in Web Scene")})));c&&c.ignoreUnsupported&&(n=n.filter(function(a){return"layer:unsupported"!==
  60. a.name&&"symbol:unsupported"!==a.name&&"symbol-layer:unsupported"!==a.name&&"property:unsupported"!==a.name}));c&&c.strictSchemaValidationEnabled||(n=n.filter(function(a){return"web-document-write:property-required"!==a.name}));var e=c&&c.strictSchemaValidationEnabled;return(e?r.create(function(a){return q(["./webscene/validator"],a)}).then(function(b){b=b.validate(a);if(0<b.length){var c="webscene did not validate:\n"+b.join("\n");F.error((d?"saveAs":"save")+"(): "+c)}return b.map(function(a){return new u("webscene:schema-validation",
  61. a)})}).then(function(a){return e&&0<a.length?(a=P.createSchemaValidationError(a.concat(n)),r.reject(a)):n}):r.resolve(n)).then(function(a){if(0<a.length)return r.reject(new u("webscene:save","Failed to save webscene due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:a}))})};e.prototype._verifySaveAs=function(a,b,c){return this.canSaveAs(b)?r.reject(P.createCopyError()):this._verifySave(a,b,c,!0)};e.prototype.verifySaveAs=function(a){var b=this._enableVerifyItemRelativeUrls({origin:"web-scene",
  62. messages:[]}),c=this.write(null,b);return this._verifySaveAs(c,b,a)};e.prototype.canSaveAs=function(a){a||(a=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write(null,a));return a.verifyItemRelativeUrls&&0<a.verifyItemRelativeUrls.writtenUrls.length};e.prototype.updateFrom=function(a,b){void 0===b&&(b={});b.environmentExcluded||(this.initialViewProperties.environment=x.prototype.clone.apply(a.environment));b.viewpointExcluded||(this.initialViewProperties.viewpoint=a.viewpoint.clone());
  63. this.initialViewProperties.spatialReference=a.spatialReference.clone();this.initialViewProperties.viewingMode=a.viewingMode;a.clippingArea?a.clippingArea!==this.clippingArea&&(this.clippingArea=a.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1;a.heightModelInfo&&(this.heightModelInfo=a.heightModelInfo.clone());a.map===this&&a.allLayerViews.forEach(function(a){a.layer.visible=a.visible})};e.prototype._loadFromSource=function(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,
  64. {origin:"web-scene"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()};e.prototype._readAndLoadFromJSON=function(a,b){a=this._validateJSON(a,b&&b.url&&b.url.path);this.read(a,b);return this._loadFromJSON(a,b)};e.prototype._extractOperationalLayers=function(a){var b=this,c=[];if(!this.sourceVersion.supportsGround&&a.baseMap&&Array.isArray(a.baseMap.elevationLayers))for(var d=0,n=a.baseMap.elevationLayers;d<n.length;d++)c.push(n[d]);var e=[],f=function(a){a.layers&&
  65. (a.layers=a.layers.filter(f));return"ArcGISTiledElevationServiceLayer"===a.layerType?(b.sourceVersion.supportsGround||e.push(a),!1):!0};return{operationalLayers:a.operationalLayers?a.operationalLayers.filter(f):[],operationalElevationLayers:e,basemapElevationLayers:c}};e.prototype._loadFromJSON=function(a,b){var c=this,n=new y;return this._validateSpatialReference().then(function(){return c._validateHeightModelInfo()}).then(function(){return r.create(function(a){return q(["./portal/support/layersCreator"],
  66. a)})}).then(function(e){var f=c._extractOperationalLayers(a),g=f.operationalLayers,k=f.operationalElevationLayers,f=f.basemapElevationLayers,v=[],h={context:d.mixin({},b,{layerContainerType:"operational-layers"})};c.portalItem&&(h.context.portal=c.portalItem.portal||z.getDefault());if(0<f.length){var l=d.mixin({},h,{context:d.mixin({},h.context,{layerContainerType:"ground"})});l.defaultLayerType="ArcGISTiledElevationServiceLayer";v.push.apply(v,e.populateOperationalLayers(c.ground.layers,f,l))}0<
  67. k.length&&(l=d.mixin({},h,{context:d.mixin({},h.context,{layerContainerType:"ground"})}),l.defaultLayerType="ArcGISTiledElevationServiceLayer",v.push.apply(v,e.populateOperationalLayers(n,k,l)));g&&0<g.length&&v.push.apply(v,e.populateOperationalLayers(c.layers,g,h));return r.eachAlways(v).then(function(){})}).then(function(){return c._loadObjectsWithLayers()}).then(function(){c.ground.layers.addMany(n)})};e.prototype._loadObjectsWithLayers=function(){var a=[];this.ground&&a.push(this.ground.load());
  68. this.basemap&&a.push(this.basemap.load());this.presentation.slides.forEach(function(b){b.basemap&&a.push(b.basemap.load())});return r.eachAlways(a).then(function(){})};e.prototype._loadFromItem=function(a){var b=this;return a.load().catch(function(a){throw new u("webscene:load-portal-item","Failed to load portal item",{error:a});}).then(function(){if("Web Scene"!==a.type)throw new u("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:a.type});}).then(function(){return a.fetchData()}).then(function(c){b.resourceInfo=
  69. c;return b._readAndLoadFromJSON(c,{origin:"web-scene",url:B.urlToObject(a.itemUrl),portal:a.portal||z.getDefault()})})};e.prototype._validateSpatialReference=function(){var a=this.initialViewProperties,b=this._sceneSpatialReference,c;if("local"!==a.viewingMode){if(!b.isWGS84&&!b.isWebMercator)return r.reject(new u("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator or WGS84 GCS are supported",{spatialReference:b,viewingMode:a.viewingMode}));
  70. c=function(a){return!a||a.isWGS84||a.isWebMercator}}else{if(b.isGeographic)return r.reject(new u("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:b,viewingMode:a.viewingMode}));c=function(a){return!a||a.equals(b)}}var d=function(a){return a&&(a.camera&&a.camera.position&&a.camera.position.spatialReference||a.targetGeometry&&a.targetGeometry.spatialReference)},e=d(a.viewpoint);
  71. return e&&!c(e)?r.reject(new u("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:e,sceneSpatialReference:b,viewingMode:a.viewingMode})):(e=this.presentation.slides.find(function(a){return!c(d(a.viewpoint))}))?(e=d(e.viewpoint),r.reject(new u("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",
  72. {slideSpatialReference:e,sceneSpatialReference:b,viewingMode:a.viewingMode}))):r.resolve()};e.prototype._validateHeightModelInfo=function(){var a=M.validateWebSceneError(this.heightModelInfo,this._sceneSpatialReference);return a?r.reject(a):r.resolve()};e.prototype._validateJSON=function(a,b){void 0===b&&(b=null);a=this._sanitizeJSON(a,b);b=J.default.parse(a.version,"webscene");K.validate(b);a.version=b.major+"."+b.minor;1===b.major&&2>=b.minor&&(a.spatialReference=w.WebMercator.toJSON());return a};
  73. e.prototype._sanitizeJSON=function(a,b){void 0===b&&(b=null);return{version:a.version||"",baseMap:a.baseMap,ground:a.ground,operationalLayers:a.operationalLayers,authoringApp:a.authoringApp||"",authoringAppVersion:a.authoringAppVersion||"",viewingMode:a.viewingMode||"global",presentation:a.presentation&&R.sanitizeJSON(a.presentation)||{},initialState:a.initialState,spatialReference:a.spatialReference||w.WebMercator.toJSON(),heightModelInfo:a.heightModelInfo||null,clippingArea:a.clippingArea,applicationProperties:a.applicationProperties}};
  74. e.prototype._updateTypeKeywords=function(a){"local"===this.initialViewProperties.viewingMode?a.typeKeywords?-1===a.typeKeywords.indexOf("ViewingMode-Local")&&a.typeKeywords.push("ViewingMode-Local"):a.typeKeywords=["ViewingMode-Local"]:"global"===this.initialViewProperties.viewingMode&&a.typeKeywords&&(a.typeKeywords=a.typeKeywords.filter(function(a){return"ViewingMode-Local"!==a}));a.typeKeywords&&(a.typeKeywords=a.typeKeywords.filter(function(a,b,c){return c.indexOf(a)===b}))};Object.defineProperty(e.prototype,
  75. "_sceneSpatialReference",{get:function(){return this.initialViewProperties.spatialReference||w.WebMercator},enumerable:!0,configurable:!0});Object.defineProperty(e.prototype,"_verifyItemRelativeRootPath",{get:function(){return this.portalItem&&this.portalItem.itemUrl?B.urlToObject(this.portalItem.itemUrl).path:null},enumerable:!0,configurable:!0});e.prototype._enableVerifyItemRelativeUrls=function(a){var b=this._verifyItemRelativeRootPath;b&&(a.verifyItemRelativeUrls={rootPath:b,writtenUrls:[]});
  76. return a};e.fromJSON=function(a){if(!a)throw new u("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:a})};e.VERSION=K;a([p.property({type:m,json:{write:!0}})],e.prototype,"applicationProperties",void 0);a([p.property({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],e.prototype,"basemap",void 0);a([p.property({type:E,json:{read:{source:"clippingArea.geometry",reader:H.fromJSON},write:{target:"clippingArea.geometry"}}})],e.prototype,"clippingArea",
  77. void 0);a([p.writer("clippingArea")],e.prototype,"writeClippingArea",null);a([p.property({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],e.prototype,"clippingEnabled",void 0);a([p.reader("clippingEnabled",["clippingArea"])],e.prototype,"readClippingEnabled",null);a([p.writer("clippingEnabled")],e.prototype,"writeClippingEnabled",null);a([p.property({type:C,json:{write:!0}})],e.prototype,"heightModelInfo",void 0);a([p.property({json:{write:{target:"operationalLayers"}}})],e.prototype,"layers",
  78. void 0);a([p.writer("layers")],e.prototype,"writeLayers",null);a([p.property({readOnly:!0,type:J.default,json:{type:String,write:{allowNull:!0,target:"version",isRequired:!0}}})],e.prototype,"sourceVersion",void 0);a([p.reader("sourceVersion",["version"])],e.prototype,"readSourceVersion",null);a([p.writer("sourceVersion")],e.prototype,"writeSourceVersion",null);a([p.property({type:String,json:{write:{allowNull:!0}}})],e.prototype,"authoringApp",null);a([p.writer("authoringApp")],e.prototype,"writeAuthoringApp",
  79. null);a([p.property({type:String,json:{write:{allowNull:!0}}})],e.prototype,"authoringAppVersion",null);a([p.writer("authoringAppVersion")],e.prototype,"writeAuthoringAppVersion",null);a([p.property({json:{write:{isRequired:!0,allowNull:!0,enabled:!0}}})],e.prototype,"ground",void 0);a([p.writer("ground")],e.prototype,"writeGround",null);a([p.property({type:R,json:{write:function(a,b,c,d){a.slides&&0<a.slides.length&&(b.presentation=a.write(null,d))}}})],e.prototype,"presentation",void 0);a([p.property({type:Q})],
  80. e.prototype,"initialViewProperties",void 0);a([p.reader("initialViewProperties",["initialState.environment","spatialReference","viewingMode","initialState.viewpoint"])],e.prototype,"readInitialViewProperties",null);a([p.writer("initialViewProperties",{"initialState.environment":{type:x},spatialReference:{type:w},viewingMode:{type:String},"initialState.viewpoint":{type:g}})],e.prototype,"writeInitialViewProperties",null);a([p.property({type:I})],e.prototype,"portalItem",void 0);a([p.property()],e.prototype,
  81. "resourceInfo",void 0);a([k(0,p.cast(I))],e.prototype,"saveAs",null);a([p.property()],e.prototype,"_sceneSpatialReference",null);a([p.property()],e.prototype,"_verifyItemRelativeRootPath",null);return e=a([p.subclass("esri.WebScene")],e)}(p.declared(f,A,G))});