2 lines
82 KiB
JavaScript
2 lines
82 KiB
JavaScript
define(["./Color-82ef4a75","./ComponentDatatype-aaeec80f","./defaultValue-81eec7ed","./Check-741c5f3c","./GeometryInstance-1b39c9e8","./PolygonGeometry-95e6b579","./PolygonOutlineGeometry-29f6cf19","./VertexFormat-d50a69ba","./Resource-8ae1a924","./combine-3c023bda","./WebGLConstants-508b9636","./Cartesian2-bd414876","./when-422ea0ae","./Transforms-5b829630","./RuntimeError-26acdd3b","./Matrix2-dc0c61cc","./Matrix4-4c545f70","./Math-e73894ab","./PixelFormat-bd725b72","./GeometryAttribute-2b42a913","./GeometryAttributes-32b29525","./PrimitivePipeline-d5bc2e2a","./GeographicProjection-c931c7fb","./BoundingSphere-9a3b5656","./Cartesian3-e0307675","./GetRidingLanternGeometry","./ArcType-fc72c06c","./GeometryOffsetAttribute-ed56ff58","./BoundingRectangle-0e36efc3","./Rectangle-cf3e0e3e","./EllipsoidGeodesic-e7a5ca44","./EllipsoidTangentPlane-4d138901","./AxisAlignedBoundingBox-8774439c","./IntersectionTests-80510c7b","./Plane-bc8b6777","./GeometryPipeline-e7083fea","./AttributeCompression-8f752c03","./EncodedCartesian3-aafcc30f","./IndexDatatype-3f3c99e8","./PolygonGeometryLibrary-231711c2","./arrayRemoveDuplicates-cea3b206","./EllipsoidRhumbLine-592e8885","./PolygonPipeline-04baeb41","./WebMercatorProjection-44373a3d"],(function(e,t,a,r,n,i,o,l,s,u,m,c,f,p,d,_,h,g,x,T,y,C,v,E,b,A,P,I,S,M,L,D,R,w,N,O,z,F,B,V,U,G,W,k){"use strict";function Y(t,r,n,i){t=a.defaultValue(t,1),r=a.defaultValue(r,1),n=a.defaultValue(n,1),i=a.defaultValue(i,1),this.value=new Uint8Array([e.Color.floatToByte(t),e.Color.floatToByte(r),e.Color.floatToByte(n),e.Color.floatToByte(i)])}Object.defineProperties(Y.prototype,{componentDatatype:{get:function(){return t.ComponentDatatype.UNSIGNED_BYTE}},componentsPerAttribute:{get:function(){return 4}},normalize:{get:function(){return!0}}}),Y.fromColor=function(e){return new Y(e.red,e.green,e.blue,e.alpha)},Y.toValue=function(e,t){return a.defined(t)?e.toBytes(t):new Uint8Array(e.toBytes())},Y.equals=function(e,t){return e===t||a.defined(e)&&a.defined(t)&&e.value[0]===t.value[0]&&e.value[1]===t.value[1]&&e.value[2]===t.value[2]&&e.value[3]===t.value[3]};const H={ADD:m.WebGLConstants.FUNC_ADD,SUBTRACT:m.WebGLConstants.FUNC_SUBTRACT,REVERSE_SUBTRACT:m.WebGLConstants.FUNC_REVERSE_SUBTRACT,MIN:m.WebGLConstants.MIN,MAX:m.WebGLConstants.MAX};var X=Object.freeze(H);const K={ZERO:m.WebGLConstants.ZERO,ONE:m.WebGLConstants.ONE,SOURCE_COLOR:m.WebGLConstants.SRC_COLOR,ONE_MINUS_SOURCE_COLOR:m.WebGLConstants.ONE_MINUS_SRC_COLOR,DESTINATION_COLOR:m.WebGLConstants.DST_COLOR,ONE_MINUS_DESTINATION_COLOR:m.WebGLConstants.ONE_MINUS_DST_COLOR,SOURCE_ALPHA:m.WebGLConstants.SRC_ALPHA,ONE_MINUS_SOURCE_ALPHA:m.WebGLConstants.ONE_MINUS_SRC_ALPHA,DESTINATION_ALPHA:m.WebGLConstants.DST_ALPHA,ONE_MINUS_DESTINATION_ALPHA:m.WebGLConstants.ONE_MINUS_DST_ALPHA,CONSTANT_COLOR:m.WebGLConstants.CONSTANT_COLOR,ONE_MINUS_CONSTANT_COLOR:m.WebGLConstants.ONE_MINUS_CONSTANT_COLOR,CONSTANT_ALPHA:m.WebGLConstants.CONSTANT_ALPHA,ONE_MINUS_CONSTANT_ALPHA:m.WebGLConstants.ONE_MINUS_CONSTANT_ALPHA,SOURCE_ALPHA_SATURATE:m.WebGLConstants.SRC_ALPHA_SATURATE};var j=Object.freeze(K);const Z={DISABLED:Object.freeze({enabled:!1}),ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:X.ADD,equationAlpha:X.ADD,functionSourceRgb:j.SOURCE_ALPHA,functionSourceAlpha:j.ONE,functionDestinationRgb:j.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:j.ONE_MINUS_SOURCE_ALPHA}),PRE_MULTIPLIED_ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:X.ADD,equationAlpha:X.ADD,functionSourceRgb:j.ONE,functionSourceAlpha:j.ONE,functionDestinationRgb:j.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:j.ONE_MINUS_SOURCE_ALPHA}),ADDITIVE_BLEND:Object.freeze({enabled:!0,equationRgb:X.ADD,equationAlpha:X.ADD,functionSourceRgb:j.SOURCE_ALPHA,functionSourceAlpha:j.ONE,functionDestinationRgb:j.ONE,functionDestinationAlpha:j.ONE})};var q=Object.freeze(Z);const J={FRONT:m.WebGLConstants.FRONT,BACK:m.WebGLConstants.BACK,FRONT_AND_BACK:m.WebGLConstants.FRONT_AND_BACK};var $=Object.freeze(J);function Q(e){e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT),this.material=e.material,this.translucent=a.defaultValue(e.translucent,!0),this._vertexShaderSource=e.vertexShaderSource,this._fragmentShaderSource=e.fragmentShaderSource,this._renderState=e.renderState,this._closed=a.defaultValue(e.closed,!1)}function ee(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function te(){return!0}function ae(e,t){function a(){}for(const t in e)"function"==typeof e[t]&&(e[t]=a);e.isDestroyed=te}function re(e,t,a,r,n){this._format=e,this._datatype=t,this._width=a,this._height=r,this._buffer=n}function ne(){if(!a.defined(me._canTransferArrayBuffer)){const e=new Worker(le("Workers/transferTypedArrayTest.js"));e.postMessage=a.defaultValue(e.webkitPostMessage,e.postMessage);const t=99,r=new Int8Array([t]);try{e.postMessage({array:r},[r.buffer])}catch(e){return me._canTransferArrayBuffer=!1,me._canTransferArrayBuffer}const n=f.when.defer();e.onmessage=function(r){const i=r.data.array,o=a.defined(i)&&i[0]===t;n.resolve(o),e.terminate(),me._canTransferArrayBuffer=o},me._canTransferArrayBuffer=n.promise}return me._canTransferArrayBuffer}Object.defineProperties(Q.prototype,{vertexShaderSource:{get:function(){return this._vertexShaderSource}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},renderState:{get:function(){return this._renderState}},closed:{get:function(){return this._closed}}}),Q.prototype.getFragmentShaderSource=function(){var e=[];return e.push("varying vec4 v_endPlaneNormalEcAndBatchId;"),this.flat&&e.push("#define FLAT"),this.faceForward&&e.push("#define FACE_FORWARD"),a.defined(this.material)&&e.push(this.material.shaderSource),e.push(this.fragmentShaderSource),e.join("\n")},Q.prototype.isTranslucent=function(){return a.defined(this.material)&&this.material.isTranslucent()||!a.defined(this.material)&&this.translucent},Q.prototype.getRenderState=function(){var e=this.isTranslucent(),t=s.clone(this.renderState,!1);return e?(t.depthMask=!1,t.blending=q.ALPHA_BLEND):t.depthMask=!0,t},Q.getDefaultRenderState=function(e,t,r){var n={depthTest:{enabled:!0}};return e&&(n.depthMask=!1,n.blending=q.ALPHA_BLEND),t&&(n.cull={enabled:!0,face:$.BACK}),a.defined(r)&&(n=u.combine(r,n,!0)),n},Object.defineProperties(re.prototype,{internalFormat:{get:function(){return this._format}},pixelDatatype:{get:function(){return this._datatype}},width:{get:function(){return this._width}},height:{get:function(){return this._height}},bufferView:{get:function(){return this._buffer}}}),re.clone=function(e){if(a.defined(e))return new re(e._format,e._datatype,e._width,e._height,e._buffer)},re.prototype.clone=function(){return re.clone(this)};const ie=new s.Event;function oe(e,t){--e._activeTasks;const n=t.id;if(!a.defined(n))return;const i=e._deferreds,o=i[n];if(a.defined(t.error)){let e=t.error;"RuntimeError"===e.name?(e=new d.RuntimeError(t.error.message),e.stack=t.error.stack):"DeveloperError"===e.name&&(e=new r.DeveloperError(t.error.message),e.stack=t.error.stack),ie.raiseEvent(e),o.reject(e)}else ie.raiseEvent(),o.resolve(t.result);delete i[n]}function le(e){let t=p.buildModuleUrl(e);if(s.isCrossOriginUrl(t)){const e=`importScripts("${t}");`;let a;try{a=new Blob([e],{type:"application/javascript"})}catch(t){const r=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder);r.append(e),a=r.getBlob("application/javascript")}t=(window.URL||window.webkitURL).createObjectURL(a)}return t}let se;function ue(e){const t=new Worker((a.defined(se)||(se=le("Workers/cesiumWorkerBootstrapper.js")),se));t.postMessage=a.defaultValue(t.webkitPostMessage,t.postMessage);const r={loaderConfig:{paths:{Workers:p.buildModuleUrl("Workers")},baseUrl:p.buildModuleUrl.getCesiumBaseUrl().url},workerModule:e._workerPath};return t.postMessage(r),t.onmessage=function(t){oe(e,t.data)},t}function me(e,t){const r=new s.URI(e);this._workerPath=0!==r.scheme().length&&0===r.fragment().length?e:me._workerModulePrefix+e,this._maximumActiveTasks=a.defaultValue(t,Number.POSITIVE_INFINITY),this._activeTasks=0,this._deferreds={},this._nextID=0}const ce=[];function fe(){}let pe;function de(e){let t;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))t=f.when.resolve(e);else{t=s.Resource.createIfNeeded(e).fetchArrayBuffer()}return t.then((function(e){return fe.transcode(e,pe)}))}me.prototype.scheduleTask=function(e,t){if(a.defined(this._worker)||(this._worker=ue(this)),this._activeTasks>=this._maximumActiveTasks)return;++this._activeTasks;const r=this;return f.when(ne(),(function(n){a.defined(t)?n||(t.length=0):t=ce;const i=r._nextID++,o=f.when.defer();return r._deferreds[i]=o,r._worker.postMessage({id:i,parameters:e,canTransferArrayBuffer:n},t),o.promise}))},me.prototype.initWebAssemblyModule=function(e){a.defined(this._worker)||(this._worker=ue(this));const t=f.when.defer(),r=this,n=this._worker;return function(e,t){const r={modulePath:void 0,wasmBinaryFile:void 0,wasmBinary:void 0};if(!p.FeatureDetection.supportsWebAssembly()){if(!a.defined(t.fallbackModulePath))throw new d.RuntimeError(`This browser does not support Web Assembly, and no backup module was provided for ${e._workerPath}`);return r.modulePath=p.buildModuleUrl(t.fallbackModulePath),f.when.resolve(r)}return r.modulePath=p.buildModuleUrl(t.modulePath),r.wasmBinaryFile=p.buildModuleUrl(t.wasmBinaryFile),s.Resource.fetchArrayBuffer({url:r.wasmBinaryFile}).then((function(e){return r.wasmBinary=e,r}))}(this,e).then((function(e){return f.when(ne(),(function(i){let o;const l=e.wasmBinary;a.defined(l)&&i&&(o=[l]),n.onmessage=function(e){n.onmessage=function(e){oe(r,e.data)},t.resolve(e.data)},n.postMessage({webAssemblyConfig:e},o)}))})),t},me.prototype.isDestroyed=function(){return!1},me.prototype.destroy=function(){return a.defined(this._worker)&&this._worker.terminate(),ae(this)},me.taskCompletedEvent=ie,me._defaultWorkerModulePrefix="Workers/",me._workerModulePrefix=me._defaultWorkerModulePrefix,me._canTransferArrayBuffer=void 0,fe._transcodeTaskProcessor=new me("transcodeKTX2",Number.POSITIVE_INFINITY),fe._readyPromise=void 0,fe.transcode=function(e,t){return a.defined(fe._readyPromise)||function(){const e=fe._transcodeTaskProcessor.initWebAssemblyModule({modulePath:"ThirdParty/Workers/basis_transcoder.js",wasmBinaryFile:"ThirdParty/basis_transcoder.wasm"}).then((function(){return fe._transcodeTaskProcessor}));fe._readyPromise=e}(),fe._readyPromise.then((function(a){let r;if(e instanceof ArrayBuffer){const n=new Uint8Array(e);return r={supportedTargetFormats:t,ktx2Buffer:n},a.scheduleTask(r,[e])}return r={supportedTargetFormats:t,ktx2Buffer:e},a.scheduleTask(r,[e.buffer])})).then((function(e){const t=e.length,a=Object.keys(e[0]),r=a.length;let n;for(n=0;n<t;n++){const t=e[n];for(let e=0;e<r;e++){const r=t[a[e]];t[a[e]]=new re(r.internalFormat,r.datatype,r.width,r.height,r.levelBuffer)}}if(1===r){for(n=0;n<t;++n)e[n]=e[n][a[0]];1===t&&(e=e[0])}return e})).otherwise((function(e){throw e}))},de.setKTX2SupportedFormats=function(e,t,a,r,n,i){pe={s3tc:e,pvrtc:t,astc:a,etc:r,etc1:n,bc7:i}};const _e={_maximumCombinedTextureImageUnits:0,_maximumCubeMapSize:0,_maximumFragmentUniformVectors:0,_maximumTextureImageUnits:0,_maximumRenderbufferSize:0,_maximumTextureSize:0,_maximumVaryingVectors:0,_maximumVertexAttributes:0,_maximumVertexTextureImageUnits:0,_maximumVertexUniformVectors:0,_minimumAliasedLineWidth:0,_maximumAliasedLineWidth:0,_minimumAliasedPointSize:0,_maximumAliasedPointSize:0,_maximumViewportWidth:0,_maximumViewportHeight:0,_maximumTextureFilterAnisotropy:0,_maximumDrawBuffers:0,_maximumColorAttachments:0,_maximumSamples:0,_highpFloatSupported:!1,_highpIntSupported:!1};function he(e,t,a,r,n,i,o,l,s,u,m){this._context=e,this._texture=t,this._textureTarget=a,this._targetFace=r,this._pixelDatatype=o,this._internalFormat=n,this._pixelFormat=i,this._size=l,this._preMultiplyAlpha=s,this._flipY=u,this._initialized=m}Object.defineProperties(_e,{maximumCombinedTextureImageUnits:{get:function(){return _e._maximumCombinedTextureImageUnits}},maximumCubeMapSize:{get:function(){return _e._maximumCubeMapSize}},maximumFragmentUniformVectors:{get:function(){return _e._maximumFragmentUniformVectors}},maximumTextureImageUnits:{get:function(){return _e._maximumTextureImageUnits}},maximumRenderbufferSize:{get:function(){return _e._maximumRenderbufferSize}},maximumTextureSize:{get:function(){return _e._maximumTextureSize}},maximumVaryingVectors:{get:function(){return _e._maximumVaryingVectors}},maximumVertexAttributes:{get:function(){return _e._maximumVertexAttributes}},maximumVertexTextureImageUnits:{get:function(){return _e._maximumVertexTextureImageUnits}},maximumVertexUniformVectors:{get:function(){return _e._maximumVertexUniformVectors}},minimumAliasedLineWidth:{get:function(){return _e._minimumAliasedLineWidth}},maximumAliasedLineWidth:{get:function(){return _e._maximumAliasedLineWidth}},minimumAliasedPointSize:{get:function(){return _e._minimumAliasedPointSize}},maximumAliasedPointSize:{get:function(){return _e._maximumAliasedPointSize}},maximumViewportWidth:{get:function(){return _e._maximumViewportWidth}},maximumViewportHeight:{get:function(){return _e._maximumViewportHeight}},maximumTextureFilterAnisotropy:{get:function(){return _e._maximumTextureFilterAnisotropy}},maximumDrawBuffers:{get:function(){return _e._maximumDrawBuffers}},maximumColorAttachments:{get:function(){return _e._maximumColorAttachments}},maximumSamples:{get:function(){return _e._maximumSamples}},highpFloatSupported:{get:function(){return _e._highpFloatSupported}},highpIntSupported:{get:function(){return _e._highpIntSupported}}}),Object.defineProperties(he.prototype,{pixelFormat:{get:function(){return this._pixelFormat}},pixelDatatype:{get:function(){return this._pixelDatatype}},_target:{get:function(){return this._targetFace}}}),he.prototype.copyFrom=function(e){const t=a.defaultValue(e.xOffset,0),r=a.defaultValue(e.yOffset,0),n=e.source,i=this._context._gl,o=this._textureTarget,l=this._targetFace;i.activeTexture(i.TEXTURE0),i.bindTexture(o,this._texture);const s=n.width,u=n.height;let m=n.arrayBufferView;const c=this._size,f=this._pixelFormat,p=this._internalFormat,d=this._pixelDatatype,_=this._preMultiplyAlpha,h=this._flipY,g=a.defaultValue(e.skipColorSpaceConversion,!1);let T=4;a.defined(m)&&(T=x.PixelFormat.alignmentInBytes(f,d,s)),i.pixelStorei(i.UNPACK_ALIGNMENT,T),g?i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE):i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL);let y=!1;if(!this._initialized){if(0===t&&0===r&&s===c&&u===c)a.defined(m)?(i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),h&&(m=x.PixelFormat.flipY(m,f,d,c,c)),i.texImage2D(l,0,p,c,c,0,f,x.PixelDatatype.toWebGLConstant(d,this._context),m)):(i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,h),i.texImage2D(l,0,p,f,x.PixelDatatype.toWebGLConstant(d,this._context),n)),y=!0;else{i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);const e=x.PixelFormat.createTypedArray(f,d,c,c);i.texImage2D(l,0,p,c,c,0,f,x.PixelDatatype.toWebGLConstant(d,this._context),e)}this._initialized=!0}y||(a.defined(m)?(i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),h&&(m=x.PixelFormat.flipY(m,f,d,s,u)),i.texSubImage2D(l,0,t,r,s,u,f,x.PixelDatatype.toWebGLConstant(d,this._context),m)):(i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,h),i.texSubImage2D(l,0,t,r,f,x.PixelDatatype.toWebGLConstant(d,this._context),n))),i.bindTexture(o,null)},he.prototype.copyFromFramebuffer=function(e,t,r,n,i,o){e=a.defaultValue(e,0),t=a.defaultValue(t,0),r=a.defaultValue(r,0),n=a.defaultValue(n,0),i=a.defaultValue(i,this._size),o=a.defaultValue(o,this._size);const l=this._context._gl,s=this._textureTarget;l.activeTexture(l.TEXTURE0),l.bindTexture(s,this._texture),l.copyTexSubImage2D(this._targetFace,0,e,t,r,n,i,o),l.bindTexture(s,null),this._initialized=!0};const ge={DONT_CARE:m.WebGLConstants.DONT_CARE,FASTEST:m.WebGLConstants.FASTEST,NICEST:m.WebGLConstants.NICEST,validate:function(e){return e===ge.DONT_CARE||e===ge.FASTEST||e===ge.NICEST}};var xe=Object.freeze(ge);const Te={NEAREST:m.WebGLConstants.NEAREST,LINEAR:m.WebGLConstants.LINEAR,validate:function(e){return e===Te.NEAREST||e===Te.LINEAR}};var ye=Object.freeze(Te);const Ce={NEAREST:m.WebGLConstants.NEAREST,LINEAR:m.WebGLConstants.LINEAR,NEAREST_MIPMAP_NEAREST:m.WebGLConstants.NEAREST_MIPMAP_NEAREST,LINEAR_MIPMAP_NEAREST:m.WebGLConstants.LINEAR_MIPMAP_NEAREST,NEAREST_MIPMAP_LINEAR:m.WebGLConstants.NEAREST_MIPMAP_LINEAR,LINEAR_MIPMAP_LINEAR:m.WebGLConstants.LINEAR_MIPMAP_LINEAR,validate:function(e){return e===Ce.NEAREST||e===Ce.LINEAR||e===Ce.NEAREST_MIPMAP_NEAREST||e===Ce.LINEAR_MIPMAP_NEAREST||e===Ce.NEAREST_MIPMAP_LINEAR||e===Ce.LINEAR_MIPMAP_LINEAR}};var ve=Object.freeze(Ce);const Ee={CLAMP_TO_EDGE:m.WebGLConstants.CLAMP_TO_EDGE,REPEAT:m.WebGLConstants.REPEAT,MIRRORED_REPEAT:m.WebGLConstants.MIRRORED_REPEAT,validate:function(e){return e===Ee.CLAMP_TO_EDGE||e===Ee.REPEAT||e===Ee.MIRRORED_REPEAT}};var be=Object.freeze(Ee);function Ae(e){e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT);const t=a.defaultValue(e.wrapS,be.CLAMP_TO_EDGE),r=a.defaultValue(e.wrapT,be.CLAMP_TO_EDGE),n=a.defaultValue(e.minificationFilter,ve.LINEAR),i=a.defaultValue(e.magnificationFilter,ye.LINEAR),o=a.defined(e.maximumAnisotropy)?e.maximumAnisotropy:1;this._wrapS=t,this._wrapT=r,this._minificationFilter=n,this._magnificationFilter=i,this._maximumAnisotropy=o}function Pe(e){const t=(e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT)).context,r=e.source;let n;if(a.defined(r)){const e=[r.positiveX,r.negativeX,r.positiveY,r.negativeY,r.positiveZ,r.negativeZ];n=e[0].width}else n=e.width;const i=n,o=a.defaultValue(e.pixelDatatype,x.PixelDatatype.UNSIGNED_BYTE),l=a.defaultValue(e.pixelFormat,x.PixelFormat.RGBA),s=x.PixelFormat.toInternalFormat(l,o,t),u=6*x.PixelFormat.textureSizeInBytes(l,o,i,i),m=e.preMultiplyAlpha||l===x.PixelFormat.RGB||l===x.PixelFormat.LUMINANCE,c=a.defaultValue(e.flipY,!0),f=a.defaultValue(e.skipColorSpaceConversion,!1),p=t._gl,d=p.TEXTURE_CUBE_MAP,_=p.createTexture();function h(e,r,u,m,c){let f=r.arrayBufferView;a.defined(f)||(f=r.bufferView);let d=4;a.defined(f)&&(d=x.PixelFormat.alignmentInBytes(l,o,n)),p.pixelStorei(p.UNPACK_ALIGNMENT,d),c?p.pixelStorei(p.UNPACK_COLORSPACE_CONVERSION_WEBGL,p.NONE):p.pixelStorei(p.UNPACK_COLORSPACE_CONVERSION_WEBGL,p.BROWSER_DEFAULT_WEBGL),a.defined(f)?(p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),p.pixelStorei(p.UNPACK_FLIP_Y_WEBGL,!1),m&&(f=x.PixelFormat.flipY(f,l,o,i,i)),p.texImage2D(e,0,s,i,i,0,l,x.PixelDatatype.toWebGLConstant(o,t),f)):(p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,u),p.pixelStorei(p.UNPACK_FLIP_Y_WEBGL,m),p.texImage2D(e,0,s,l,x.PixelDatatype.toWebGLConstant(o,t),r))}p.activeTexture(p.TEXTURE0),p.bindTexture(d,_),a.defined(r)?(h(p.TEXTURE_CUBE_MAP_POSITIVE_X,r.positiveX,m,c,f),h(p.TEXTURE_CUBE_MAP_NEGATIVE_X,r.negativeX,m,c,f),h(p.TEXTURE_CUBE_MAP_POSITIVE_Y,r.positiveY,m,c,f),h(p.TEXTURE_CUBE_MAP_NEGATIVE_Y,r.negativeY,m,c,f),h(p.TEXTURE_CUBE_MAP_POSITIVE_Z,r.positiveZ,m,c,f),h(p.TEXTURE_CUBE_MAP_NEGATIVE_Z,r.negativeZ,m,c,f)):(p.texImage2D(p.TEXTURE_CUBE_MAP_POSITIVE_X,0,s,i,i,0,l,x.PixelDatatype.toWebGLConstant(o,t),null),p.texImage2D(p.TEXTURE_CUBE_MAP_NEGATIVE_X,0,s,i,i,0,l,x.PixelDatatype.toWebGLConstant(o,t),null),p.texImage2D(p.TEXTURE_CUBE_MAP_POSITIVE_Y,0,s,i,i,0,l,x.PixelDatatype.toWebGLConstant(o,t),null),p.texImage2D(p.TEXTURE_CUBE_MAP_NEGATIVE_Y,0,s,i,i,0,l,x.PixelDatatype.toWebGLConstant(o,t),null),p.texImage2D(p.TEXTURE_CUBE_MAP_POSITIVE_Z,0,s,i,i,0,l,x.PixelDatatype.toWebGLConstant(o,t),null),p.texImage2D(p.TEXTURE_CUBE_MAP_NEGATIVE_Z,0,s,i,i,0,l,x.PixelDatatype.toWebGLConstant(o,t),null)),p.bindTexture(d,null),this._context=t,this._textureFilterAnisotropic=t._textureFilterAnisotropic,this._textureTarget=d,this._texture=_,this._pixelFormat=l,this._pixelDatatype=o,this._size=i,this._hasMipmap=!1,this._sizeInBytes=u,this._preMultiplyAlpha=m,this._flipY=c,this._sampler=void 0;const g=a.defined(r);this._positiveX=new he(t,_,d,p.TEXTURE_CUBE_MAP_POSITIVE_X,s,l,o,i,m,c,g),this._negativeX=new he(t,_,d,p.TEXTURE_CUBE_MAP_NEGATIVE_X,s,l,o,i,m,c,g),this._positiveY=new he(t,_,d,p.TEXTURE_CUBE_MAP_POSITIVE_Y,s,l,o,i,m,c,g),this._negativeY=new he(t,_,d,p.TEXTURE_CUBE_MAP_NEGATIVE_Y,s,l,o,i,m,c,g),this._positiveZ=new he(t,_,d,p.TEXTURE_CUBE_MAP_POSITIVE_Z,s,l,o,i,m,c,g),this._negativeZ=new he(t,_,d,p.TEXTURE_CUBE_MAP_NEGATIVE_Z,s,l,o,i,m,c,g),this.sampler=a.defined(e.sampler)?e.sampler:new Ae}function Ie(e){const t=(e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT)).context;let r=e.width,n=e.height;const i=e.source;a.defined(i)&&(a.defined(r)||(r=a.defaultValue(i.videoWidth,i.width)),a.defined(n)||(n=a.defaultValue(i.videoHeight,i.height)));const o=a.defaultValue(e.pixelFormat,x.PixelFormat.RGBA),l=a.defaultValue(e.pixelDatatype,x.PixelDatatype.UNSIGNED_BYTE),s=x.PixelFormat.toInternalFormat(o,l,t),u=x.PixelFormat.isCompressedFormat(s),m=e.preMultiplyAlpha||o===x.PixelFormat.RGB||o===x.PixelFormat.LUMINANCE,f=a.defaultValue(e.flipY,!0),p=a.defaultValue(e.skipColorSpaceConversion,!1);let d=!0;const _=t._gl,h=_.TEXTURE_2D,g=_.createTexture();_.activeTexture(_.TEXTURE0),_.bindTexture(h,g);let T,y=4;if(a.defined(i)&&a.defined(i.arrayBufferView)&&!u&&(y=x.PixelFormat.alignmentInBytes(o,l,r)),_.pixelStorei(_.UNPACK_ALIGNMENT,y),p?_.pixelStorei(_.UNPACK_COLORSPACE_CONVERSION_WEBGL,_.NONE):_.pixelStorei(_.UNPACK_COLORSPACE_CONVERSION_WEBGL,_.BROWSER_DEFAULT_WEBGL),a.defined(i))if(a.defined(i.arrayBufferView)){_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,!1);let e,m,c,p=i.arrayBufferView;if(u){if(_.compressedTexImage2D(h,0,s,r,n,0,p),a.defined(i.mipLevels))for(m=r,c=n,e=0;e<i.mipLevels.length;++e)m=0|Math.floor(m/2),m<1&&(m=1),c=0|Math.floor(c/2),c<1&&(c=1),_.compressedTexImage2D(h,e+1,s,m,c,0,i.mipLevels[e])}else if(f&&(p=x.PixelFormat.flipY(p,o,l,r,n)),_.texImage2D(h,0,s,r,n,0,o,x.PixelDatatype.toWebGLConstant(l,t),p),a.defined(i.mipLevels))for(m=r,c=n,e=0;e<i.mipLevels.length;++e)m=0|Math.floor(m/2),m<1&&(m=1),c=0|Math.floor(c/2),c<1&&(c=1),_.texImage2D(h,e+1,s,m,c,0,o,x.PixelDatatype.toWebGLConstant(l,t),i.mipLevels[e])}else a.defined(i.framebuffer)?(_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,!1),i.framebuffer!==t.defaultFramebuffer&&i.framebuffer._bind(),_.copyTexImage2D(h,0,s,i.xOffset,i.yOffset,r,n,0),i.framebuffer!==t.defaultFramebuffer&&i.framebuffer._unBind()):(_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,m),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,f),_.texImage2D(h,0,s,o,x.PixelDatatype.toWebGLConstant(l,t),i));else _.texImage2D(h,0,s,r,n,0,o,x.PixelDatatype.toWebGLConstant(l,t),null),d=!1;_.bindTexture(h,null),T=u?x.PixelFormat.compressedTextureSizeInBytes(o,r,n):x.PixelFormat.textureSizeInBytes(o,l,r,n),this._id=ee(),this._context=t,this._textureFilterAnisotropic=t._textureFilterAnisotropic,this._textureTarget=h,this._texture=g,this._internalFormat=s,this._pixelFormat=o,this._pixelDatatype=l,this._width=r,this._height=n,this._dimensions=new c.Cartesian2(r,n),this._hasMipmap=!1,this._sizeInBytes=T,this._preMultiplyAlpha=m,this._flipY=f,this._initialized=d,this._sampler=void 0,this.sampler=a.defined(e.sampler)?e.sampler:new Ae}Object.defineProperties(Ae.prototype,{wrapS:{get:function(){return this._wrapS}},wrapT:{get:function(){return this._wrapT}},minificationFilter:{get:function(){return this._minificationFilter}},magnificationFilter:{get:function(){return this._magnificationFilter}},maximumAnisotropy:{get:function(){return this._maximumAnisotropy}}}),Ae.equals=function(e,t){return e===t||a.defined(e)&&a.defined(t)&&e._wrapS===t._wrapS&&e._wrapT===t._wrapT&&e._minificationFilter===t._minificationFilter&&e._magnificationFilter===t._magnificationFilter&&e._maximumAnisotropy===t._maximumAnisotropy},Ae.NEAREST=Object.freeze(new Ae({wrapS:be.CLAMP_TO_EDGE,wrapT:be.CLAMP_TO_EDGE,minificationFilter:ve.NEAREST,magnificationFilter:ye.NEAREST})),Object.defineProperties(Pe.prototype,{positiveX:{get:function(){return this._positiveX}},negativeX:{get:function(){return this._negativeX}},positiveY:{get:function(){return this._positiveY}},negativeY:{get:function(){return this._negativeY}},positiveZ:{get:function(){return this._positiveZ}},negativeZ:{get:function(){return this._negativeZ}},sampler:{get:function(){return this._sampler},set:function(e){let t=e.minificationFilter,r=e.magnificationFilter;const n=t===ve.NEAREST_MIPMAP_NEAREST||t===ve.NEAREST_MIPMAP_LINEAR||t===ve.LINEAR_MIPMAP_NEAREST||t===ve.LINEAR_MIPMAP_LINEAR,i=this._context,o=this._pixelDatatype;(o===x.PixelDatatype.FLOAT&&!i.textureFloatLinear||o===x.PixelDatatype.HALF_FLOAT&&!i.textureHalfFloatLinear)&&(t=n?ve.NEAREST_MIPMAP_NEAREST:ve.NEAREST,r=ye.NEAREST);const l=i._gl,s=this._textureTarget;l.activeTexture(l.TEXTURE0),l.bindTexture(s,this._texture),l.texParameteri(s,l.TEXTURE_MIN_FILTER,t),l.texParameteri(s,l.TEXTURE_MAG_FILTER,r),l.texParameteri(s,l.TEXTURE_WRAP_S,e.wrapS),l.texParameteri(s,l.TEXTURE_WRAP_T,e.wrapT),a.defined(this._textureFilterAnisotropic)&&l.texParameteri(s,this._textureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.maximumAnisotropy),l.bindTexture(s,null),this._sampler=e}},pixelFormat:{get:function(){return this._pixelFormat}},pixelDatatype:{get:function(){return this._pixelDatatype}},width:{get:function(){return this._size}},height:{get:function(){return this._size}},sizeInBytes:{get:function(){return this._hasMipmap?Math.floor(4*this._sizeInBytes/3):this._sizeInBytes}},preMultiplyAlpha:{get:function(){return this._preMultiplyAlpha}},flipY:{get:function(){return this._flipY}},_target:{get:function(){return this._textureTarget}}}),Pe.prototype.generateMipmap=function(e){e=a.defaultValue(e,xe.DONT_CARE),this._hasMipmap=!0;const t=this._context._gl,r=this._textureTarget;t.hint(t.GENERATE_MIPMAP_HINT,e),t.activeTexture(t.TEXTURE0),t.bindTexture(r,this._texture),t.generateMipmap(r),t.bindTexture(r,null)},Pe.prototype.isDestroyed=function(){return!1},Pe.prototype.destroy=function(){return this._context._gl.deleteTexture(this._texture),this._positiveX=ae(this._positiveX),this._negativeX=ae(this._negativeX),this._positiveY=ae(this._positiveY),this._negativeY=ae(this._negativeY),this._positiveZ=ae(this._positiveZ),this._negativeZ=ae(this._negativeZ),ae(this)},Ie.create=function(e){return new Ie(e)},Ie.fromFramebuffer=function(e){const t=(e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT)).context,r=t._gl,n=a.defaultValue(e.pixelFormat,x.PixelFormat.RGB),i=a.defaultValue(e.framebufferXOffset,0),o=a.defaultValue(e.framebufferYOffset,0),l=a.defaultValue(e.width,r.drawingBufferWidth),s=a.defaultValue(e.height,r.drawingBufferHeight),u=e.framebuffer;return new Ie({context:t,width:l,height:s,pixelFormat:n,source:{framebuffer:a.defined(u)?u:t.defaultFramebuffer,xOffset:i,yOffset:o,width:l,height:s}})},Object.defineProperties(Ie.prototype,{id:{get:function(){return this._id}},sampler:{get:function(){return this._sampler},set:function(e){let t=e.minificationFilter,r=e.magnificationFilter;const n=this._context,i=this._pixelFormat,o=this._pixelDatatype,l=t===ve.NEAREST_MIPMAP_NEAREST||t===ve.NEAREST_MIPMAP_LINEAR||t===ve.LINEAR_MIPMAP_NEAREST||t===ve.LINEAR_MIPMAP_LINEAR;(o===x.PixelDatatype.FLOAT&&!n.textureFloatLinear||o===x.PixelDatatype.HALF_FLOAT&&!n.textureHalfFloatLinear)&&(t=l?ve.NEAREST_MIPMAP_NEAREST:ve.NEAREST,r=ye.NEAREST),n.webgl2&&x.PixelFormat.isDepthFormat(i)&&(t=ve.NEAREST,r=ye.NEAREST);const s=n._gl,u=this._textureTarget;s.activeTexture(s.TEXTURE0),s.bindTexture(u,this._texture),s.texParameteri(u,s.TEXTURE_MIN_FILTER,t),s.texParameteri(u,s.TEXTURE_MAG_FILTER,r),s.texParameteri(u,s.TEXTURE_WRAP_S,e.wrapS),s.texParameteri(u,s.TEXTURE_WRAP_T,e.wrapT),a.defined(this._textureFilterAnisotropic)&&s.texParameteri(u,this._textureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.maximumAnisotropy),s.bindTexture(u,null),this._sampler=e}},pixelFormat:{get:function(){return this._pixelFormat}},pixelDatatype:{get:function(){return this._pixelDatatype}},dimensions:{get:function(){return this._dimensions}},preMultiplyAlpha:{get:function(){return this._preMultiplyAlpha}},flipY:{get:function(){return this._flipY}},width:{get:function(){return this._width}},height:{get:function(){return this._height}},sizeInBytes:{get:function(){return this._hasMipmap?Math.floor(4*this._sizeInBytes/3):this._sizeInBytes}},_target:{get:function(){return this._textureTarget}}}),Ie.prototype.copyFrom=function(e){const t=a.defaultValue(e.xOffset,0),r=a.defaultValue(e.yOffset,0),n=e.source,i=this._context,o=i._gl,l=this._textureTarget;o.activeTexture(o.TEXTURE0),o.bindTexture(l,this._texture);const s=n.width,u=n.height;let m=n.arrayBufferView;const c=this._width,f=this._height,p=this._internalFormat,d=this._pixelFormat,_=this._pixelDatatype,h=this._preMultiplyAlpha,g=this._flipY,T=a.defaultValue(e.skipColorSpaceConversion,!1);let y=4;a.defined(m)&&(y=x.PixelFormat.alignmentInBytes(d,_,s)),o.pixelStorei(o.UNPACK_ALIGNMENT,y),T?o.pixelStorei(o.UNPACK_COLORSPACE_CONVERSION_WEBGL,o.NONE):o.pixelStorei(o.UNPACK_COLORSPACE_CONVERSION_WEBGL,o.BROWSER_DEFAULT_WEBGL);let C=!1;if(!this._initialized){if(0===t&&0===r&&s===c&&u===f)a.defined(m)?(o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,!1),g&&(m=x.PixelFormat.flipY(m,d,_,c,f)),o.texImage2D(l,0,p,c,f,0,d,x.PixelDatatype.toWebGLConstant(_,i),m)):(o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,g),o.texImage2D(l,0,p,d,x.PixelDatatype.toWebGLConstant(_,i),n)),C=!0;else{o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,!1);const e=x.PixelFormat.createTypedArray(d,_,c,f);o.texImage2D(l,0,p,c,f,0,d,x.PixelDatatype.toWebGLConstant(_,i),e)}this._initialized=!0}C||(a.defined(m)?(o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,!1),g&&(m=x.PixelFormat.flipY(m,d,_,s,u)),o.texSubImage2D(l,0,t,r,s,u,d,x.PixelDatatype.toWebGLConstant(_,i),m)):(o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,g),o.texSubImage2D(l,0,t,r,d,x.PixelDatatype.toWebGLConstant(_,i),n))),o.bindTexture(l,null)},Ie.prototype.copyFromFramebuffer=function(e,t,r,n,i,o){e=a.defaultValue(e,0),t=a.defaultValue(t,0),r=a.defaultValue(r,0),n=a.defaultValue(n,0),i=a.defaultValue(i,this._width),o=a.defaultValue(o,this._height);const l=this._context._gl,s=this._textureTarget;l.activeTexture(l.TEXTURE0),l.bindTexture(s,this._texture),l.copyTexSubImage2D(s,0,e,t,r,n,i,o),l.bindTexture(s,null),this._initialized=!0},Ie.prototype.generateMipmap=function(e){e=a.defaultValue(e,xe.DONT_CARE),this._hasMipmap=!0;const t=this._context._gl,r=this._textureTarget;t.hint(t.GENERATE_MIPMAP_HINT,e),t.activeTexture(t.TEXTURE0),t.bindTexture(r,this._texture),t.generateMipmap(r),t.bindTexture(r,null)},Ie.prototype.isDestroyed=function(){return!1},Ie.prototype.destroy=function(){return this._context._gl.deleteTexture(this._texture),ae(this)};function Se(e){this.type=void 0,this.shaderSource=void 0,this.materials=void 0,this.uniforms=void 0,this._uniforms=void 0,this.translucent=void 0,this._minificationFilter=a.defaultValue(e.minificationFilter,ve.LINEAR),this._magnificationFilter=a.defaultValue(e.magnificationFilter,ye.LINEAR),this._strict=void 0,this._template=void 0,this._count=void 0,this._texturePaths={},this._loadedImages=[],this._loadedCubeMaps=[],this._textures={},this._updateFunctions=[],this._defaultTexture=void 0,function(e,t){var r;e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT),t._strict=a.defaultValue(e.strict,!1),t._count=a.defaultValue(e.count,0),t._template=s.clone(a.defaultValue(e.fabric,a.defaultValue.EMPTY_OBJECT)),t._template.uniforms=s.clone(a.defaultValue(t._template.uniforms,a.defaultValue.EMPTY_OBJECT)),t._template.materials=s.clone(a.defaultValue(t._template.materials,a.defaultValue.EMPTY_OBJECT)),t.type=a.defined(t._template.type)?t._template.type:ee(),t.shaderSource="",t.materials={},t.uniforms={},t._uniforms={},t._translucentFunctions=[];var n=Se._materialCache.getMaterial(t.type);if(a.defined(n)){var i=s.clone(n.fabric,!0);t._template=u.combine(t._template,i,!0),r=n.translucent}(function(e){var t=e._template,a=t.uniforms,r=t.materials,n=t.components;Me(t,Re,Le,!0),Me(n,we,Le,!0);var i=[];for(var o in r)r.hasOwnProperty(o)&&i.push(o);Me(a,i,De,!1)})(t),a.defined(n)||Se._materialCache.addMaterial(t.type,t);(function(e){var t=e._template.components,r=e._template.source;if(a.defined(r))e.shaderSource+=r+"\n";else{if(e.shaderSource+="czm_material czm_getMaterial(czm_materialInput materialInput)\n{\n",e.shaderSource+="czm_material material = czm_getDefaultMaterial(materialInput);\n",a.defined(t)){var n=Object.keys(e._template.materials).length>0;for(var i in t)if(t.hasOwnProperty(i))if("diffuse"===i||"emission"===i){var o=n&&Ne(t[i],e)?t[i]:"czm_gammaCorrect("+t[i]+")";e.shaderSource+="material."+i+" = "+o+"; \n"}else e.shaderSource+="alpha"===i?"material.alpha = "+t.alpha+"; \n":"material."+i+" = "+t[i]+";\n"}e.shaderSource+="return material;\n}\n"}})(t),function(e){var t=e._template.uniforms;for(var a in t)t.hasOwnProperty(a)&&Fe(e,a)}(t),function(e){var t=e._strict,a=e._template.materials;for(var r in a)if(a.hasOwnProperty(r)){var n=new Se({strict:t,fabric:a[r],count:e._count});e._count=n._count,e._uniforms=u.combine(e._uniforms,n._uniforms,!0),e.materials[r]=n,e._translucentFunctions=e._translucentFunctions.concat(n._translucentFunctions);var i="czm_getMaterial",o=i+"_"+e._count++;Be(n,i,o),e.shaderSource=n.shaderSource+e.shaderSource,Be(e,r,o+"(materialInput)")}}(t);var o=0===t._translucentFunctions.length||void 0;if(r=a.defaultValue(r,o),r=a.defaultValue(e.translucent,r),a.defined(r))if("function"==typeof r){var l=function(){return r(t)};t._translucentFunctions.push(l)}else t._translucentFunctions.push(r)}(e,this),Object.defineProperties(this,{type:{value:this.type,writable:!1}}),a.defined(Se._uniformList[this.type])||(Se._uniformList[this.type]=Object.keys(this._uniforms))}function Me(e,t,r,n){if(a.defined(e))for(var i in e)if(e.hasOwnProperty(i)){var o=-1!==t.indexOf(i);(n&&!o||!n&&o)&&r(i,t)}}function Le(e,t){}function De(e,t){}Se._uniformList={},Se.fromType=function(e,t){var r=new Se({fabric:{type:e}});if(a.defined(t))for(var n in t)t.hasOwnProperty(n)&&(r.uniforms[n]=t[n]);return r},Se.prototype.isTranslucent=function(){if(a.defined(this.translucent))return"function"==typeof this.translucent?this.translucent():this.translucent;for(var e=!0,t=this._translucentFunctions,r=t.length,n=0;n<r;++n){var i=t[n];if(!(e="function"==typeof i?e&&i():e&&i))break}return e},Se.prototype.update=function(e){var t,r;this._defaultTexture=e.defaultTexture;var n=this._loadedImages,i=n.length;for(t=0;t<i;++t){var o=n[t];r=o.id;var l,s=o.image;Array.isArray(s)&&(l=s.slice(1,s.length).map((function(e){return e.bufferView})),s=s[0]);var u,m=new Ae({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter});u=a.defined(s.internalFormat)?new Ie({context:e,pixelFormat:s.internalFormat,width:s.width,height:s.height,source:{arrayBufferView:s.bufferView,mipLevels:l},sampler:m}):new Ie({context:e,source:s,sampler:m});var c=this._textures[r];a.defined(c)&&c!==this._defaultTexture&&c.destroy(),this._textures[r]=u;var f=r+"Dimensions";if(this.uniforms.hasOwnProperty(f)){var p=this.uniforms[f];p.x=u._width,p.y=u._height}}n.length=0;var d=this._loadedCubeMaps;for(i=d.length,t=0;t<i;++t){var _=d[t];r=_.id;var h=_.images,g=new Pe({context:e,source:{positiveX:h[0],negativeX:h[1],positiveY:h[2],negativeY:h[3],positiveZ:h[4],negativeZ:h[5]},sampler:new Ae({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter})});this._textures[r]=g}d.length=0;var x=this._updateFunctions;for(i=x.length,t=0;t<i;++t)x[t](this,e);var T=this.materials;for(var y in T)T.hasOwnProperty(y)&&T[y].update(e)},Se.prototype.isDestroyed=function(){return!1},Se.prototype.destroy=function(){var e=this._textures;for(var t in e)if(e.hasOwnProperty(t)){var a=e[t];a!==this._defaultTexture&&a.destroy()}var r=this.materials;for(var n in r)r.hasOwnProperty(n)&&r[n].destroy();return ae(this)};var Re=["type","materials","uniforms","components","source"],we=["diffuse","specular","shininess","normal","emission","alpha"];function Ne(e,t){var a=t._template.materials;for(var r in a)if(a.hasOwnProperty(r)&&e.indexOf(r)>-1)return!0;return!1}var Oe={mat2:_.Matrix2,mat3:h.Matrix3,mat4:h.Matrix4},ze=/\.ktx2$/i;function Fe(e,t){e._strict;var r=e._template.uniforms,n=r[t],i=function(e){var t=e.type;if(!a.defined(t)){var r=typeof e;if("number"===r)t="float";else if("boolean"===r)t="bool";else if("string"===r||e instanceof s.Resource||e instanceof HTMLCanvasElement||e instanceof HTMLImageElement)t=/^([rgba]){1,4}$/i.test(e)?"channels":e===Se.DefaultCubeMapId?"samplerCube":"sampler2D";else if("object"===r)if(Array.isArray(e))4!==e.length&&9!==e.length&&16!==e.length||(t="mat"+Math.sqrt(e.length));else{var n=0;for(var i in e)e.hasOwnProperty(i)&&(n+=1);n>=2&&n<=4?t="vec"+n:6===n&&(t="samplerCube")}}return t}(n);if("channels"===i)Be(e,t,n,!1);else{if("sampler2D"===i){var o=t+"Dimensions";(function(e,t,a){return Be(e,t,t,a)})(e,o)>0&&(r[o]={type:"ivec3",x:1,y:1},Fe(e,o))}if(!new RegExp("uniform\\s+"+i+"\\s+"+t+"\\s*;").test(e.shaderSource)){var l="uniform "+i+" "+t+";";e.shaderSource=l+e.shaderSource}var u=t+"_"+e._count++;if(Be(e,t,u),e.uniforms[t]=n,"sampler2D"===i)e._uniforms[u]=function(){return e._textures[t]},e._updateFunctions.push(function(e){var t;return function(r,n){var i=r.uniforms,o=i[e],l=t!==o,u=!a.defined(o)||o===Se.DefaultImageId;t=o;var m,c,f=r._textures[e];if(o instanceof HTMLVideoElement)if(o.readyState>=2){if(l&&a.defined(f)&&(f!==n.defaultTexture&&f.destroy(),f=void 0),!a.defined(f)||f===n.defaultTexture){var p=new Ae({minificationFilter:r._minificationFilter,magnificationFilter:r._magnificationFilter});return f=new Ie({context:n,source:o,sampler:p}),void(r._textures[e]=f)}f.copyFrom({source:o})}else a.defined(f)||(r._textures[e]=n.defaultTexture);else{if(o instanceof Ie&&o!==f){r._texturePaths[e]=void 0;var d=r._textures[e];return a.defined(d)&&d!==r._defaultTexture&&d.destroy(),r._textures[e]=o,m=e+"Dimensions",void(i.hasOwnProperty(m)&&((c=i[m]).x=o._width,c.y=o._height))}if(l&&a.defined(f)&&u&&(f!==r._defaultTexture&&f.destroy(),f=void 0),a.defined(f)||(r._texturePaths[e]=void 0,f=r._textures[e]=r._defaultTexture,m=e+"Dimensions",i.hasOwnProperty(m)&&((c=i[m]).x=f._width,c.y=f._height)),!u){var _=o instanceof s.Resource;if(!a.defined(r._texturePaths[e])||_&&o.url!==r._texturePaths[e].url||!_&&o!==r._texturePaths[e]){if("string"==typeof o||_){var h=_?o:s.Resource.createIfNeeded(o);(ze.test(h.url)?de(h.url):h.fetchImage()).then((function(t){r._loadedImages.push({id:e,image:t})})).otherwise((function(){a.defined(f)&&f!==r._defaultTexture&&f.destroy(),r._textures[e]=r._defaultTexture}))}else(o instanceof HTMLCanvasElement||o instanceof HTMLImageElement)&&r._loadedImages.push({id:e,image:o});r._texturePaths[e]=o}}}}}(t));else if("samplerCube"===i)e._uniforms[u]=function(){return e._textures[t]},e._updateFunctions.push(function(e){return function(t,r){var n=t.uniforms[e];if(n instanceof Pe){var i=t._textures[e];return i!==t._defaultTexture&&i.destroy(),t._texturePaths[e]=void 0,void(t._textures[e]=n)}if(a.defined(t._textures[e])||(t._texturePaths[e]=void 0,t._textures[e]=r.defaultCubeMap),n!==Se.DefaultCubeMapId){var o=n.positiveX+n.negativeX+n.positiveY+n.negativeY+n.positiveZ+n.negativeZ;if(o!==t._texturePaths[e]){var l=[s.Resource.createIfNeeded(n.positiveX).fetchImage(),s.Resource.createIfNeeded(n.negativeX).fetchImage(),s.Resource.createIfNeeded(n.positiveY).fetchImage(),s.Resource.createIfNeeded(n.negativeY).fetchImage(),s.Resource.createIfNeeded(n.positiveZ).fetchImage(),s.Resource.createIfNeeded(n.negativeZ).fetchImage()];f.when.all(l).then((function(a){t._loadedCubeMaps.push({id:e,images:a})})),t._texturePaths[e]=o}}}}(t));else if(-1!==i.indexOf("mat")){var m=new Oe[i];e._uniforms[u]=function(){return Oe[i].fromColumnMajorArray(e.uniforms[t],m)}}else e._uniforms[u]=function(){return e.uniforms[t]}}}function Be(e,t,r,n){n=a.defaultValue(n,!0);var i=0,o=new RegExp("([\\w"+(n?".":"")+"])?"+t+"([\\w])?","g");return e.shaderSource=e.shaderSource.replace(o,(function(e,t,a){return t||a?e:(i+=1,r)})),i}function Ve(e){e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT);const t=a.defaultValue(e.translucent,!0),r=a.defaultValue(e.aboveGround,!1);this.material=a.defined(e.material)?e.material:Se.fromType(Se.ColorType),this.translucent=a.defaultValue(e.translucent,!0),this._vertexShaderSource=a.defaultValue(e.vertexShaderSource,"attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec2 st;\nattribute float batchId;\nvarying vec3 v_positionMC;\nvarying vec3 v_positionEC;\nvarying vec2 v_st;\nvoid main()\n{\nvec4 p = czm_computePosition();\nv_positionMC = position3DHigh + position3DLow;\nv_positionEC = (czm_modelViewRelativeToEye * p).xyz;\nv_st = st;\ngl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n"),this._fragmentShaderSource=a.defaultValue(e.fragmentShaderSource,"varying vec3 v_positionMC;\nvarying vec3 v_positionEC;\nvarying vec2 v_st;\nvoid main()\n{\nczm_materialInput materialInput;\nvec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)));\n#ifdef FACE_FORWARD\nnormalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);\n#endif\nmaterialInput.s = v_st.s;\nmaterialInput.st = v_st;\nmaterialInput.str = vec3(v_st, 0.0);\nmaterialInput.normalEC = normalEC;\nmaterialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, materialInput.normalEC);\nvec3 positionToEyeEC = -v_positionEC;\nmaterialInput.positionToEyeEC = positionToEyeEC;\nczm_material material = czm_getMaterial(materialInput);\n#ifdef FLAT\ngl_FragColor = vec4(material.diffuse + material.emission, material.alpha);\n#else\ngl_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);\n#endif\n}\n"),this._renderState=Q.getDefaultRenderState(t,!r,e.renderState),this._closed=!1,this._flat=a.defaultValue(e.flat,!1),this._faceForward=a.defaultValue(e.faceForward,r),this._aboveGround=r}Se._materialCache={_materials:{},addMaterial:function(e,t){this._materials[e]=t},getMaterial:function(e){return this._materials[e]}},Se.DefaultImageId="czm_defaultImage",Se.DefaultCubeMapId="czm_defaultCubeMap",Se.ColorType="Color",Se._materialCache.addMaterial(Se.ColorType,{fabric:{type:Se.ColorType,uniforms:{color:new e.Color(1,0,0,.5)},components:{diffuse:"color.rgb",alpha:"color.a"}},translucent:function(e){return e.uniforms.color.alpha<1}}),Se.ImageType="Image",Se._materialCache.addMaterial(Se.ImageType,{fabric:{type:Se.ImageType,uniforms:{image:Se.DefaultImageId,repeat:new c.Cartesian2(1,1),color:new e.Color(1,1,1,1)},components:{diffuse:"texture2D(image, fract(repeat * materialInput.st)).rgb * color.rgb",alpha:"texture2D(image, fract(repeat * materialInput.st)).a * color.a"}},translucent:function(e){return e.uniforms.color.alpha<1}}),Se.DiffuseMapType="DiffuseMap",Se._materialCache.addMaterial(Se.DiffuseMapType,{fabric:{type:Se.DiffuseMapType,uniforms:{image:Se.DefaultImageId,channels:"rgb",repeat:new c.Cartesian2(1,1)},components:{diffuse:"texture2D(image, fract(repeat * materialInput.st)).channels"}},translucent:!1}),Se.AlphaMapType="AlphaMap",Se._materialCache.addMaterial(Se.AlphaMapType,{fabric:{type:Se.AlphaMapType,uniforms:{image:Se.DefaultImageId,channel:"a",repeat:new c.Cartesian2(1,1)},components:{alpha:"texture2D(image, fract(repeat * materialInput.st)).channel"}},translucent:!0}),Se.SpecularMapType="SpecularMap",Se._materialCache.addMaterial(Se.SpecularMapType,{fabric:{type:Se.SpecularMapType,uniforms:{image:Se.DefaultImageId,channel:"r",repeat:new c.Cartesian2(1,1)},components:{specular:"texture2D(image, fract(repeat * materialInput.st)).channel"}},translucent:!1}),Se.EmissionMapType="EmissionMap",Se._materialCache.addMaterial(Se.EmissionMapType,{fabric:{type:Se.EmissionMapType,uniforms:{image:Se.DefaultImageId,channels:"rgb",repeat:new c.Cartesian2(1,1)},components:{emission:"texture2D(image, fract(repeat * materialInput.st)).channels"}},translucent:!1}),Se.BumpMapType="BumpMap",Se._materialCache.addMaterial(Se.BumpMapType,{fabric:{type:Se.BumpMapType,uniforms:{image:Se.DefaultImageId,channel:"r",strength:.8,repeat:new c.Cartesian2(1,1)},source:"uniform sampler2D image;\nuniform float strength;\nuniform vec2 repeat;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec2 st = materialInput.st;\nvec2 centerPixel = fract(repeat * st);\nfloat centerBump = texture2D(image, centerPixel).channel;\nfloat imageWidth = float(imageDimensions.x);\nvec2 rightPixel = fract(repeat * (st + vec2(1.0 / imageWidth, 0.0)));\nfloat rightBump = texture2D(image, rightPixel).channel;\nfloat imageHeight = float(imageDimensions.y);\nvec2 leftPixel = fract(repeat * (st + vec2(0.0, 1.0 / imageHeight)));\nfloat topBump = texture2D(image, leftPixel).channel;\nvec3 normalTangentSpace = normalize(vec3(centerBump - rightBump, centerBump - topBump, clamp(1.0 - strength, 0.1, 1.0)));\nvec3 normalEC = materialInput.tangentToEyeMatrix * normalTangentSpace;\nmaterial.normal = normalEC;\nmaterial.diffuse = vec3(0.01);\nreturn material;\n}\n"},translucent:!1}),Se.NormalMapType="NormalMap",Se._materialCache.addMaterial(Se.NormalMapType,{fabric:{type:Se.NormalMapType,uniforms:{image:Se.DefaultImageId,channels:"rgb",strength:.8,repeat:new c.Cartesian2(1,1)},source:"uniform sampler2D image;\nuniform float strength;\nuniform vec2 repeat;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec4 textureValue = texture2D(image, fract(repeat * materialInput.st));\nvec3 normalTangentSpace = textureValue.channels;\nnormalTangentSpace.xy = normalTangentSpace.xy * 2.0 - 1.0;\nnormalTangentSpace.z = clamp(1.0 - strength, 0.1, 1.0);\nnormalTangentSpace = normalize(normalTangentSpace);\nvec3 normalEC = materialInput.tangentToEyeMatrix * normalTangentSpace;\nmaterial.normal = normalEC;\nreturn material;\n}\n"},translucent:!1}),Se.GridType="Grid",Se._materialCache.addMaterial(Se.GridType,{fabric:{type:Se.GridType,uniforms:{color:new e.Color(0,1,0,1),cellAlpha:.1,lineCount:new c.Cartesian2(8,8),lineThickness:new c.Cartesian2(1,1),lineOffset:new c.Cartesian2(0,0)},source:"#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nuniform vec4 color;\nuniform float cellAlpha;\nuniform vec2 lineCount;\nuniform vec2 lineThickness;\nuniform vec2 lineOffset;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec2 st = materialInput.st;\nfloat scaledWidth = fract(lineCount.s * st.s - lineOffset.s);\nscaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5));\nfloat scaledHeight = fract(lineCount.t * st.t - lineOffset.t);\nscaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5));\nfloat value;\n#ifdef GL_OES_standard_derivatives\nconst float fuzz = 1.2;\nvec2 thickness = (lineThickness * czm_pixelRatio) - 1.0;\nvec2 dx = abs(dFdx(st));\nvec2 dy = abs(dFdy(st));\nvec2 dF = vec2(max(dx.s, dy.s), max(dx.t, dy.t)) * lineCount;\nvalue = min(\nsmoothstep(dF.s * thickness.s, dF.s * (fuzz + thickness.s), scaledWidth),\nsmoothstep(dF.t * thickness.t, dF.t * (fuzz + thickness.t), scaledHeight));\n#else\nconst float fuzz = 0.05;\nvec2 range = 0.5 - (lineThickness * 0.05);\nvalue = min(\n1.0 - smoothstep(range.s, range.s + fuzz, scaledWidth),\n1.0 - smoothstep(range.t, range.t + fuzz, scaledHeight));\n#endif\nfloat dRim = 1.0 - abs(dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC)));\nfloat sRim = smoothstep(0.8, 1.0, dRim);\nvalue *= (1.0 - sRim);\nvec4 halfColor;\nhalfColor.rgb = color.rgb * 0.5;\nhalfColor.a = color.a * (1.0 - ((1.0 - cellAlpha) * value));\nhalfColor = czm_gammaCorrect(halfColor);\nmaterial.diffuse = halfColor.rgb;\nmaterial.emission = halfColor.rgb;\nmaterial.alpha = halfColor.a;\nreturn material;\n}\n"},translucent:function(e){var t=e.uniforms;return t.color.alpha<1||t.cellAlpha<1}}),Se.StripeType="Stripe",Se._materialCache.addMaterial(Se.StripeType,{fabric:{type:Se.StripeType,uniforms:{horizontal:!0,evenColor:new e.Color(1,1,1,.5),oddColor:new e.Color(0,0,1,.5),offset:0,repeat:5},source:"uniform vec4 evenColor;\nuniform vec4 oddColor;\nuniform float offset;\nuniform float repeat;\nuniform bool horizontal;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nfloat coord = mix(materialInput.st.s, materialInput.st.t, float(horizontal));\nfloat value = fract((coord - offset) * (repeat * 0.5));\nfloat dist = min(value, min(abs(value - 0.5), 1.0 - value));\nvec4 currentColor = mix(evenColor, oddColor, step(0.5, value));\nvec4 color = czm_antialias(evenColor, oddColor, currentColor, dist);\ncolor = czm_gammaCorrect(color);\nmaterial.diffuse = color.rgb;\nmaterial.alpha = color.a;\nreturn material;\n}\n"},translucent:function(e){var t=e.uniforms;return t.evenColor.alpha<1||t.oddColor.alpha<1}}),Se.CheckerboardType="Checkerboard",Se._materialCache.addMaterial(Se.CheckerboardType,{fabric:{type:Se.CheckerboardType,uniforms:{lightColor:new e.Color(1,1,1,.5),darkColor:new e.Color(0,0,0,.5),repeat:new c.Cartesian2(5,5)},source:"uniform vec4 lightColor;\nuniform vec4 darkColor;\nuniform vec2 repeat;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec2 st = materialInput.st;\nfloat b = mod(floor(repeat.s * st.s) + floor(repeat.t * st.t), 2.0);\nfloat scaledWidth = fract(repeat.s * st.s);\nscaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5));\nfloat scaledHeight = fract(repeat.t * st.t);\nscaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5));\nfloat value = min(scaledWidth, scaledHeight);\nvec4 currentColor = mix(lightColor, darkColor, b);\nvec4 color = czm_antialias(lightColor, darkColor, currentColor, value, 0.03);\ncolor = czm_gammaCorrect(color);\nmaterial.diffuse = color.rgb;\nmaterial.alpha = color.a;\nreturn material;\n}\n"},translucent:function(e){var t=e.uniforms;return t.lightColor.alpha<1||t.darkColor.alpha<1}}),Se.DotType="Dot",Se._materialCache.addMaterial(Se.DotType,{fabric:{type:Se.DotType,uniforms:{lightColor:new e.Color(1,1,0,.75),darkColor:new e.Color(0,1,1,.75),repeat:new c.Cartesian2(5,5)},source:"uniform vec4 lightColor;\nuniform vec4 darkColor;\nuniform vec2 repeat;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nfloat b = smoothstep(0.3, 0.32, length(fract(repeat * materialInput.st) - 0.5));\nvec4 color = mix(lightColor, darkColor, b);\ncolor = czm_gammaCorrect(color);\nmaterial.diffuse = color.rgb;\nmaterial.alpha = color.a;\nreturn material;\n}\n"},translucent:function(e){var t=e.uniforms;return t.lightColor.alpha<1||t.darkColor.alpha<1}}),Se.WaterType="Water",Se._materialCache.addMaterial(Se.WaterType,{fabric:{type:Se.WaterType,uniforms:{baseWaterColor:new e.Color(.2,.3,.6,1),blendColor:new e.Color(0,1,.699,1),specularMap:Se.DefaultImageId,normalMap:Se.DefaultImageId,frequency:10,animationSpeed:.01,amplitude:1,specularIntensity:.5,fadeFactor:1},source:"uniform sampler2D specularMap;\nuniform sampler2D normalMap;\nuniform vec4 baseWaterColor;\nuniform vec4 blendColor;\nuniform float frequency;\nuniform float animationSpeed;\nuniform float amplitude;\nuniform float specularIntensity;\nuniform float fadeFactor;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nfloat time = czm_frameNumber * animationSpeed;\nfloat fade = max(1.0, (length(materialInput.positionToEyeEC) / 10000000000.0) * frequency * fadeFactor);\nfloat specularMapValue = texture2D(specularMap, materialInput.st).r;\nvec4 noise = czm_getWaterNoise(normalMap, materialInput.st * frequency, time, 0.0);\nvec3 normalTangentSpace = noise.xyz * vec3(1.0, 1.0, (1.0 / amplitude));\nnormalTangentSpace.xy /= fade;\nnormalTangentSpace = mix(vec3(0.0, 0.0, 50.0), normalTangentSpace, specularMapValue);\nnormalTangentSpace = normalize(normalTangentSpace);\nfloat tsPerturbationRatio = clamp(dot(normalTangentSpace, vec3(0.0, 0.0, 1.0)), 0.0, 1.0);\nmaterial.alpha = mix(blendColor.a, baseWaterColor.a, specularMapValue) * specularMapValue;\nmaterial.diffuse = mix(blendColor.rgb, baseWaterColor.rgb, specularMapValue);\nmaterial.diffuse += (0.1 * tsPerturbationRatio);\nmaterial.diffuse = material.diffuse;\nmaterial.normal = normalize(materialInput.tangentToEyeMatrix * normalTangentSpace);\nmaterial.specular = specularIntensity;\nmaterial.shininess = 10.0;\nreturn material;\n}\n"},translucent:function(e){var t=e.uniforms;return t.baseWaterColor.alpha<1||t.blendColor.alpha<1}}),Se.YanMoType="YanMo",Se._materialCache.addMaterial(Se.YanMoType,{fabric:{type:Se.YanMoType,source:"uniform vec4 floodVar;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nmaterial.alpha = (materialInput.height < floodVar.y) ? 0.3 : 0.0;\nfloat rr = (materialInput.height < floodVar.y)?(materialInput.height-floodVar.x)/floodVar.w/2.0:0.0;\nmaterial.diffuse = vec3(1.0-rr,rr,0.0);\nreturn material;\n}\n"},translucent:!1}),Se.WaJueType="WaJue",Se._materialCache.addMaterial(Se.WaJueType,{fabric:{type:Se.WaJueType,source:"czm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nreturn material;\n}\n"},translucent:!1}),Se.RimLightingType="RimLighting",Se._materialCache.addMaterial(Se.RimLightingType,{fabric:{type:Se.RimLightingType,uniforms:{color:new e.Color(1,0,0,.7),rimColor:new e.Color(1,1,1,.4),width:.3},source:"uniform vec4 color;\nuniform vec4 rimColor;\nuniform float width;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nfloat d = 1.0 - dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC));\nfloat s = smoothstep(1.0 - width, 1.0, d);\nvec4 outColor = czm_gammaCorrect(color);\nvec4 outRimColor = czm_gammaCorrect(rimColor);\nmaterial.diffuse = outColor.rgb;\nmaterial.emission = outRimColor.rgb * s;\nmaterial.alpha = mix(outColor.a, outRimColor.a, s);\nreturn material;\n}\n"},translucent:function(e){var t=e.uniforms;return t.color.alpha<1||t.rimColor.alpha<1}}),Se.FadeType="Fade",Se._materialCache.addMaterial(Se.FadeType,{fabric:{type:Se.FadeType,uniforms:{fadeInColor:new e.Color(1,0,0,1),fadeOutColor:new e.Color(0,0,0,0),maximumDistance:.5,repeat:!0,fadeDirection:{x:!0,y:!0},time:new c.Cartesian2(.5,.5)},source:"uniform vec4 fadeInColor;\nuniform vec4 fadeOutColor;\nuniform float maximumDistance;\nuniform bool repeat;\nuniform vec2 fadeDirection;\nuniform vec2 time;\nfloat getTime(float t, float coord)\n{\nfloat scalar = 1.0 / maximumDistance;\nfloat q = distance(t, coord) * scalar;\nif (repeat)\n{\nfloat r = distance(t, coord + 1.0) * scalar;\nfloat s = distance(t, coord - 1.0) * scalar;\nq = min(min(r, s), q);\n}\nreturn clamp(q, 0.0, 1.0);\n}\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec2 st = materialInput.st;\nfloat s = getTime(time.x, st.s) * fadeDirection.s;\nfloat t = getTime(time.y, st.t) * fadeDirection.t;\nfloat u = length(vec2(s, t));\nvec4 color = mix(fadeInColor, fadeOutColor, u);\ncolor = czm_gammaCorrect(color);\nmaterial.emission = color.rgb;\nmaterial.alpha = color.a;\nreturn material;\n}\n"},translucent:function(e){var t=e.uniforms;return t.fadeInColor.alpha<1||t.fadeOutColor.alpha<1}}),Se.PolylineArrowType="PolylineArrow",Se._materialCache.addMaterial(Se.PolylineArrowType,{fabric:{type:Se.PolylineArrowType,uniforms:{color:new e.Color(1,1,1,1)},source:"#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nuniform vec4 color;\nfloat getPointOnLine(vec2 p0, vec2 p1, float x)\n{\nfloat slope = (p0.y - p1.y) / (p0.x - p1.x);\nreturn slope * (x - p0.x) + p0.y;\n}\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec2 st = materialInput.st;\n#ifdef GL_OES_standard_derivatives\nfloat base = 1.0 - abs(fwidth(st.s)) * 10.0 * czm_pixelRatio;\n#else\nfloat base = 0.975;\n#endif\nvec2 center = vec2(1.0, 0.5);\nfloat ptOnUpperLine = getPointOnLine(vec2(base, 1.0), center, st.s);\nfloat ptOnLowerLine = getPointOnLine(vec2(base, 0.0), center, st.s);\nfloat halfWidth = 0.15;\nfloat s = step(0.5 - halfWidth, st.t);\ns *= 1.0 - step(0.5 + halfWidth, st.t);\ns *= 1.0 - step(base, st.s);\nfloat t = step(base, materialInput.st.s);\nt *= 1.0 - step(ptOnUpperLine, st.t);\nt *= step(ptOnLowerLine, st.t);\nfloat dist;\nif (st.s < base)\n{\nfloat d1 = abs(st.t - (0.5 - halfWidth));\nfloat d2 = abs(st.t - (0.5 + halfWidth));\ndist = min(d1, d2);\n}\nelse\n{\nfloat d1 = czm_infinity;\nif (st.t < 0.5 - halfWidth && st.t > 0.5 + halfWidth)\n{\nd1 = abs(st.s - base);\n}\nfloat d2 = abs(st.t - ptOnUpperLine);\nfloat d3 = abs(st.t - ptOnLowerLine);\ndist = min(min(d1, d2), d3);\n}\nvec4 outsideColor = vec4(0.0);\nvec4 currentColor = mix(outsideColor, color, clamp(s + t, 0.0, 1.0));\nvec4 outColor = czm_antialias(outsideColor, color, currentColor, dist);\noutColor = czm_gammaCorrect(outColor);\nmaterial.diffuse = outColor.rgb;\nmaterial.alpha = outColor.a;\nreturn material;\n}\n"},translucent:!0}),Se.PolylineDashType="PolylineDash",Se._materialCache.addMaterial(Se.PolylineDashType,{fabric:{type:Se.PolylineDashType,uniforms:{color:new e.Color(1,0,1,1),gapColor:new e.Color(0,0,0,0),dashLength:16,dashPattern:255},source:"uniform vec4 color;\nuniform vec4 gapColor;\nuniform float dashLength;\nuniform float dashPattern;\nvarying float v_polylineAngle;\nconst float maskLength = 16.0;\nmat2 rotate(float rad) {\nfloat c = cos(rad);\nfloat s = sin(rad);\nreturn mat2(\nc, s,\n-s, c\n);\n}\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy;\nfloat dashPosition = fract(pos.x / (dashLength * czm_pixelRatio));\nfloat maskIndex = floor(dashPosition * maskLength);\nfloat maskTest = floor(dashPattern / pow(2.0, maskIndex));\nvec4 fragColor = (mod(maskTest, 2.0) < 1.0) ? gapColor : color;\nif (fragColor.a < 0.005) {\ndiscard;\n}\nfragColor = czm_gammaCorrect(fragColor);\nmaterial.emission = fragColor.rgb;\nmaterial.alpha = fragColor.a;\nreturn material;\n}\n"},translucent:!0}),Se.PolylineGlowType="PolylineGlow",Se._materialCache.addMaterial(Se.PolylineGlowType,{fabric:{type:Se.PolylineGlowType,uniforms:{color:new e.Color(0,.5,1,1),glowPower:.25,taperPower:1},source:"uniform vec4 color;\nuniform float glowPower;\nuniform float taperPower;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec2 st = materialInput.st;\nfloat glow = glowPower / abs(st.t - 0.5) - (glowPower / 0.5);\nif (taperPower <= 0.99999) {\nglow *= min(1.0, taperPower / (0.5 - st.s * 0.5) - (taperPower / 0.5));\n}\nvec4 fragColor;\nfragColor.rgb = max(vec3(glow - 1.0 + color.rgb), color.rgb);\nfragColor.a = clamp(0.0, 1.0, glow) * color.a;\nfragColor = czm_gammaCorrect(fragColor);\nmaterial.emission = fragColor.rgb;\nmaterial.alpha = fragColor.a;\nreturn material;\n}\n"},translucent:!0}),Se.PolylineOutlineType="PolylineOutline",Se._materialCache.addMaterial(Se.PolylineOutlineType,{fabric:{type:Se.PolylineOutlineType,uniforms:{color:new e.Color(1,1,1,1),outlineColor:new e.Color(1,0,0,1),outlineWidth:1},source:"uniform vec4 color;\nuniform vec4 outlineColor;\nuniform float outlineWidth;\nvarying float v_width;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec2 st = materialInput.st;\nfloat halfInteriorWidth = 0.5 * (v_width - outlineWidth) / v_width;\nfloat b = step(0.5 - halfInteriorWidth, st.t);\nb *= 1.0 - step(0.5 + halfInteriorWidth, st.t);\nfloat d1 = abs(st.t - (0.5 - halfInteriorWidth));\nfloat d2 = abs(st.t - (0.5 + halfInteriorWidth));\nfloat dist = min(d1, d2);\nvec4 currentColor = mix(outlineColor, color, b);\nvec4 outColor = czm_antialias(outlineColor, color, currentColor, dist);\noutColor = czm_gammaCorrect(outColor);\nmaterial.diffuse = outColor.rgb;\nmaterial.alpha = outColor.a;\nreturn material;\n}\n"},translucent:function(e){var t=e.uniforms;return t.color.alpha<1||t.outlineColor.alpha<1}}),Se.ElevationContourType="ElevationContour",Se._materialCache.addMaterial(Se.ElevationContourType,{fabric:{type:Se.ElevationContourType,uniforms:{spacing:100,color:new e.Color(1,0,0,1),width:1},source:"#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nuniform vec4 color;\nuniform float spacing;\nuniform float width;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nfloat distanceToContour = mod(materialInput.height, spacing);\n#ifdef GL_OES_standard_derivatives\nfloat dxc = abs(dFdx(materialInput.height));\nfloat dyc = abs(dFdy(materialInput.height));\nfloat dF = max(dxc, dyc) * czm_pixelRatio * width;\nfloat alpha = (distanceToContour < dF) ? 1.0 : 0.0;\n#else\nfloat alpha = (distanceToContour < (czm_pixelRatio * width)) ? 1.0 : 0.0;\n#endif\nvec4 outColor = czm_gammaCorrect(vec4(color.rgb, alpha * color.a));\nmaterial.diffuse = outColor.rgb;\nmaterial.alpha = outColor.a;\nreturn material;\n}\n"},translucent:!1}),Se.ElevationRampType="ElevationRamp",Se._materialCache.addMaterial(Se.ElevationRampType,{fabric:{type:Se.ElevationRampType,uniforms:{image:Se.DefaultImageId,minimumHeight:0,maximumHeight:1e4},source:"uniform sampler2D image;\nuniform float minimumHeight;\nuniform float maximumHeight;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nfloat scaledHeight = clamp((materialInput.height - minimumHeight) / (maximumHeight - minimumHeight), 0.0, 1.0);\nvec4 rampColor = texture2D(image, vec2(scaledHeight, 0.5));\nrampColor = czm_gammaCorrect(rampColor);\nmaterial.diffuse = rampColor.rgb;\nmaterial.alpha = rampColor.a;\nreturn material;\n}\n"},translucent:!1}),Se.SlopeRampMaterialType="SlopeRamp",Se._materialCache.addMaterial(Se.SlopeRampMaterialType,{fabric:{type:Se.SlopeRampMaterialType,uniforms:{image:Se.DefaultImageId},source:"uniform sampler2D image;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec4 rampColor = texture2D(image, vec2(materialInput.slope / (czm_pi / 2.0), 0.5));\nrampColor = czm_gammaCorrect(rampColor);\nmaterial.diffuse = rampColor.rgb;\nmaterial.alpha = rampColor.a;\nreturn material;\n}\n"},translucent:!1}),Se.AspectRampMaterialType="AspectRamp",Se._materialCache.addMaterial(Se.AspectRampMaterialType,{fabric:{type:Se.AspectRampMaterialType,uniforms:{image:Se.DefaultImageId},source:"uniform sampler2D image;\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nvec4 rampColor = texture2D(image, vec2(materialInput.aspect / (2.0 * czm_pi), 0.5));\nrampColor = czm_gammaCorrect(rampColor);\nmaterial.diffuse = rampColor.rgb;\nmaterial.alpha = rampColor.a;\nreturn material;\n}\n"},translucent:!1}),Se.ElevationBandType="ElevationBand",Se._materialCache.addMaterial(Se.ElevationBandType,{fabric:{type:Se.ElevationBandType,uniforms:{heights:Se.DefaultImageId,colors:Se.DefaultImageId},source:"uniform sampler2D heights;\nuniform sampler2D colors;\nfloat getHeight(int idx, float invTexSize)\n{\nvec2 uv = vec2((float(idx) + 0.5) * invTexSize, 0.5);\n#ifdef OES_texture_float\nreturn texture2D(heights, uv).x;\n#else\nreturn czm_unpackFloat(texture2D(heights, uv));\n#endif\n}\nczm_material czm_getMaterial(czm_materialInput materialInput)\n{\nczm_material material = czm_getDefaultMaterial(materialInput);\nfloat height = materialInput.height;\nfloat invTexSize = 1.0 / float(heightsDimensions.x);\nfloat minHeight = getHeight(0, invTexSize);\nfloat maxHeight = getHeight(heightsDimensions.x - 1, invTexSize);\nif (height < minHeight || height > maxHeight) {\nmaterial.diffuse = vec3(0.0);\nmaterial.alpha = 0.0;\nreturn material;\n}\nint idxBelow = 0;\nint idxAbove = heightsDimensions.x;\nfloat heightBelow = minHeight;\nfloat heightAbove = maxHeight;\nconst int maxIterations = 16;\nfor (int i = 0; i < maxIterations; i++) {\nif (idxBelow >= idxAbove - 1) {\nbreak;\n}\nint idxMid = (idxBelow + idxAbove) / 2;\nfloat heightTex = getHeight(idxMid, invTexSize);\nif (height > heightTex) {\nidxBelow = idxMid;\nheightBelow = heightTex;\n} else {\nidxAbove = idxMid;\nheightAbove = heightTex;\n}\n}\nfloat lerper = heightBelow == heightAbove ? 1.0 : (height - heightBelow) / (heightAbove - heightBelow);\nvec2 colorUv = vec2(invTexSize * (float(idxBelow) + 0.5 + lerper), 0.5);\nvec4 color = texture2D(colors, colorUv);\nif (color.a > 0.0)\n{\ncolor.rgb /= color.a;\n}\ncolor.rgb = czm_gammaCorrect(color.rgb);\nmaterial.diffuse = color.rgb;\nmaterial.alpha = color.a;\nreturn material;\n}\n"},translucent:!0}),Object.defineProperties(Ve.prototype,{vertexShaderSource:{get:function(){return this._vertexShaderSource}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},renderState:{get:function(){return this._renderState}},closed:{get:function(){return this._closed}},vertexFormat:{get:function(){return Ve.VERTEX_FORMAT}},flat:{get:function(){return this._flat}},faceForward:{get:function(){return this._faceForward}},aboveGround:{get:function(){return this._aboveGround}}}),Ve.VERTEX_FORMAT=l.VertexFormat.POSITION_AND_ST,Ve.prototype.getFragmentShaderSource=Q.prototype.getFragmentShaderSource,Ve.prototype.isTranslucent=Q.prototype.isTranslucent,Ve.prototype.getRenderState=Q.prototype.getRenderState;function Ue(e){e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT);const t=a.defaultValue(e.translucent,!0),r=a.defaultValue(e.closed,!1),n=a.defaultValue(e.flat,!1),i=n?"attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec4 color;\nattribute float batchId;\nvarying vec4 v_color;\nvoid main()\n{\nvec4 p = czm_computePosition();\nv_color = color;\ngl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n":"attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec3 normal;\nattribute vec4 color;\nattribute float batchId;\nvarying vec3 v_positionEC;\nvarying vec3 v_normalEC;\nvarying vec4 v_color;\nvoid main()\n{\nvec4 p = czm_computePosition();\nv_positionEC = (czm_modelViewRelativeToEye * p).xyz;\nv_normalEC = czm_normal * normal;\nv_color = color;\ngl_Position = czm_modelViewProjectionRelativeToEye * p;\n}\n",o=n?"varying vec4 v_color;\nvoid main()\n{\ngl_FragColor = czm_gammaCorrect(v_color);\n}\n":"varying vec3 v_positionEC;\nvarying vec3 v_normalEC;\nvarying vec4 v_color;\nvoid main()\n{\nvec3 positionToEyeEC = -v_positionEC;\nvec3 normalEC = normalize(v_normalEC);\n#ifdef FACE_FORWARD\nnormalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);\n#endif\nvec4 color = czm_gammaCorrect(v_color);\nczm_materialInput materialInput;\nmaterialInput.normalEC = normalEC;\nmaterialInput.positionToEyeEC = positionToEyeEC;\nczm_material material = czm_getDefaultMaterial(materialInput);\nmaterial.diffuse = color.rgb;\nmaterial.alpha = color.a;\ngl_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);\n}\n",l=n?Ue.FLAT_VERTEX_FORMAT:Ue.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=a.defaultValue(e.vertexShaderSource,i),this._fragmentShaderSource=a.defaultValue(e.fragmentShaderSource,o),this._renderState=Q.getDefaultRenderState(t,r,e.renderState),this._closed=r,this._vertexFormat=l,this._flat=n,this._faceForward=a.defaultValue(e.faceForward,!r)}function Ge(e,a,r){if(this._attributes=a,this._numberOfInstances=r,0!==a.length){var n=function(e){for(var a=!1,r=e.length,n=0;n<r;++n)if(e[n].componentDatatype!==t.ComponentDatatype.UNSIGNED_BYTE){a=!0;break}return a?x.PixelDatatype.FLOAT:x.PixelDatatype.UNSIGNED_BYTE}(a),i=e.floatingPointTexture,o=n===x.PixelDatatype.FLOAT&&!i,l=function(e,a){for(var r=new Array(e.length),n=0,i=e.length,o=0;o<i;++o){var l=e[o].componentDatatype;r[o]=n,l!==t.ComponentDatatype.UNSIGNED_BYTE&&a?n+=4:++n}return r}(a,o),s=function(e,a,r){var n=e.length,i=e[n-1];if(a[n-1].componentDatatype!==t.ComponentDatatype.UNSIGNED_BYTE&&r)return i+4;return i+1}(l,a,o),u=Math.floor(_e.maximumTextureSize/s),m=Math.min(r,u),f=s*m,p=Math.ceil(r/m),d=1/f,_=.5*d,g=1/p,T=.5*g;this._textureDimensions=new c.Cartesian2(f,p),this._textureStep=new h.Cartesian4(d,_,g,T),this._pixelDatatype=o?x.PixelDatatype.UNSIGNED_BYTE:n,this._packFloats=o,this._offsets=l,this._stride=s,this._texture=void 0;var y=4*f*p;this._batchValues=n!==x.PixelDatatype.FLOAT||o?new Uint8Array(y):new Float32Array(y),this._batchValuesDirty=!1}}function We(e,t){var a=e[t].componentsPerAttribute;return 2===a?c.Cartesian2:3===a?b.Cartesian3:4===a?h.Cartesian4:Number}Object.defineProperties(Ue.prototype,{vertexShaderSource:{get:function(){return this._vertexShaderSource}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},renderState:{get:function(){return this._renderState}},closed:{get:function(){return this._closed}},vertexFormat:{get:function(){return this._vertexFormat}},flat:{get:function(){return this._flat}},faceForward:{get:function(){return this._faceForward}}}),Ue.VERTEX_FORMAT=l.VertexFormat.POSITION_AND_NORMAL,Ue.FLAT_VERTEX_FORMAT=l.VertexFormat.POSITION_ONLY,Ue.prototype.getFragmentShaderSource=Q.prototype.getFragmentShaderSource,Ue.prototype.isTranslucent=Q.prototype.isTranslucent,Ue.prototype.getRenderState=Q.prototype.getRenderState,Object.defineProperties(Ge.prototype,{attributes:{get:function(){return this._attributes}},numberOfInstances:{get:function(){return this._numberOfInstances}}});var ke=new h.Cartesian4;var Ye=new h.Cartesian4;Ge.prototype.getBatchedAttribute=function(e,t,r){var n,i=this._attributes,o=this._offsets[t],l=4*this._stride*e+4*o;n=this._packFloats&&i[t].componentDatatype!==x.PixelDatatype.UNSIGNED_BYTE?function(e,t,a){var r=h.Cartesian4.unpack(e,t,ke),n=h.Cartesian4.unpackFloat(r);r=h.Cartesian4.unpack(e,t+4,ke);var i=h.Cartesian4.unpackFloat(r);r=h.Cartesian4.unpack(e,t+8,ke);var o=h.Cartesian4.unpackFloat(r);r=h.Cartesian4.unpack(e,t+12,ke);var l=h.Cartesian4.unpackFloat(r);return h.Cartesian4.fromElements(n,i,o,l,a)}(this._batchValues,l,Ye):h.Cartesian4.unpack(this._batchValues,l,Ye);var s=We(i,t);return a.defined(s.fromCartesian4)?s.fromCartesian4(n,r):a.defined(s.clone)?s.clone(n,r):n.x};var He=[void 0,void 0,new c.Cartesian2,new b.Cartesian3,new h.Cartesian4],Xe=new h.Cartesian4;function Ke(e){return 1===e?"float":"vec"+e}function je(e,a){var r=e._attributes[a],n=r.componentsPerAttribute,i=r.functionName,o=Ke(n),l=function(e){return 1===e?".x":2===e?".xy":3===e?".xyz":""}(n),s="v_"+i,u=o+" "+i+"(float batchId) \n{ \n vec2 st = computeSt(batchId); \n st.x += batchTextureStep.x * float("+e._offsets[a]+"); \n";return e._packFloats&&r.componentDatatype!==x.PixelDatatype.UNSIGNED_BYTE?u+="vec4 textureValue; \ntextureValue.x = czm_unpackFloat(texture2D(batchTexture, st)); \ntextureValue.y = czm_unpackFloat(texture2D(batchTexture, st + vec2(batchTextureStep.x, 0.0))); \ntextureValue.z = czm_unpackFloat(texture2D(batchTexture, st + vec2(batchTextureStep.x * 2.0, 0.0))); \ntextureValue.w = czm_unpackFloat(texture2D(batchTexture, st + vec2(batchTextureStep.x * 3.0, 0.0))); \n":u+=" vec4 textureValue = texture2D(batchTexture, st); \n",u+=" "+o+" value = textureValue"+l+"; \n",e._pixelDatatype!==x.PixelDatatype.UNSIGNED_BYTE||r.componentDatatype!==t.ComponentDatatype.UNSIGNED_BYTE||r.normalize?e._pixelDatatype===x.PixelDatatype.FLOAT&&r.componentDatatype===t.ComponentDatatype.UNSIGNED_BYTE&&r.normalize&&(u+="value /= 255.0; \n"):u+="value *= 255.0; \n","varying "+o+" "+s+";\n"+(u+=" return value; \n} \n")}function Ze(e,t){var a=e._attributes[t].functionName;return-1!=e.NOTGlslAutoAttributeArray().indexOf(a)?"":" "+("v_"+a)+" = "+a+"(batchId);\n"}Ge.prototype.setBatchedAttribute=function(e,t,r){var n=this._attributes,i=He[n[t].componentsPerAttribute],o=this.getBatchedAttribute(e,t,i),l=We(this._attributes,t);if(!(a.defined(l.equals)?l.equals(o,r):o===r)){var s=Xe;s.x=a.defined(r.x)?r.x:r,s.y=a.defined(r.y)?r.y:0,s.z=a.defined(r.z)?r.z:0,s.w=a.defined(r.w)?r.w:0;var u=this._offsets[t],m=4*this._stride*e+4*u;this._packFloats&&n[t].componentDatatype!==x.PixelDatatype.UNSIGNED_BYTE?function(e,t,a){var r=h.Cartesian4.packFloat(e.x,ke);h.Cartesian4.pack(r,t,a),r=h.Cartesian4.packFloat(e.y,r),h.Cartesian4.pack(r,t,a+4),r=h.Cartesian4.packFloat(e.z,r),h.Cartesian4.pack(r,t,a+8),r=h.Cartesian4.packFloat(e.w,r),h.Cartesian4.pack(r,t,a+12)}(s,this._batchValues,m):h.Cartesian4.pack(s,this._batchValues,m),this._batchValuesDirty=!0}},Ge.prototype.update=function(e){var t,r,n;a.defined(this._texture)&&!this._batchValuesDirty||0===this._attributes.length||(this._batchValuesDirty=!1,a.defined(this._texture)||(t=this,r=e.context,n=t._textureDimensions,t._texture=new Ie({context:r,pixelFormat:x.PixelFormat.RGBA,pixelDatatype:t._pixelDatatype,width:n.x,height:n.y,sampler:Ae.NEAREST,flipY:!1})),function(e){var t=e._textureDimensions;e._texture.copyFrom({source:{width:t.x,height:t.y,arrayBufferView:e._batchValues}})}(this))},Ge.prototype.getUniformMapCallback=function(){var e=this;return function(t){if(0===e._attributes.length)return t;var a={batchTexture:function(){return e._texture},batchTextureDimensions:function(){return e._textureDimensions},batchTextureStep:function(){return e._textureStep}};return u.combine(t,a)}},Ge.prototype.getVertexShaderCallback=function(){var e=this._attributes;if(0===e.length)return function(e){return e};var t,a,r="uniform highp sampler2D batchTexture; \n";r+=(a=(t=this)._stride,(1===t._textureDimensions.y?"uniform vec4 batchTextureStep; \nvec2 computeSt(float batchId) \n{ \n float stepX = batchTextureStep.x; \n float centerX = batchTextureStep.y; \n float numberOfAttributes = float("+a+"); \n return vec2(centerX + (batchId * numberOfAttributes * stepX), 0.5); \n} \n":"uniform vec4 batchTextureStep; \nuniform vec2 batchTextureDimensions; \nvec2 computeSt(float batchId) \n{ \n float stepX = batchTextureStep.x; \n float centerX = batchTextureStep.y; \n float stepY = batchTextureStep.z; \n float centerY = batchTextureStep.w; \n float numberOfAttributes = float("+a+"); \n float xId = mod(batchId * numberOfAttributes, batchTextureDimensions.x); \n float yId = floor(batchId * numberOfAttributes / batchTextureDimensions.x); \n return vec2(centerX + (xId * stepX), centerY + (yId * stepY)); \n} \n")+"\n");for(var n=[],i=e.length,o=0;o<i;++o)r+=je(this,o),n.push(Ze(this,o));return n=n.join(""),function(e){var t=e.indexOf("void main"),a=e.substring(0,t),i=e.substring(t),o=i.lastIndexOf("}"),l=i.substr(0,o)+n+i.substr(o);return a+"\n"+r+"\n"+l}},Ge.prototype.NOTGlslAutoAttributeArray=function(){return["czm_batchTable_color","czm_batchTable_pickColor","czm_batchTable_show","czm_batchTable_distanceDisplayCondition","czm_batchTable_width","czm_batchTable_boundingSphereCenter3DHigh","czm_batchTable_boundingSphereCenter3DLow","czm_batchTable_boundingSphereCenter2DHigh","czm_batchTable_boundingSphereCenter2DLow","czm_batchTable_boundingSphereRadius"]},Ge.prototype.setFSAttributesHeader=function(e){var t=this._attributes;if(0===t.length)return e;for(var a=[],r=0;r<t.length;++r){var n=this._attributes[r],i=n.functionName,o=Ke(n.componentsPerAttribute);if(-1==this.NOTGlslAutoAttributeArray().indexOf(i)){var l="varying "+o+" "+("v_"+i)+";";a.push(l)}}return a.join("\n")+"\n"+e},Ge.prototype.isDestroyed=function(){return!1},Ge.prototype.destroy=function(){return this._texture=this._texture&&this._texture.destroy(),ae(this)};let qe={MultiPolygon:function(e){st(e)},Polygon:st},Je=new function(e){e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT),this.componentDatatype=e.componentDatatype,this.componentsPerAttribute=e.componentsPerAttribute,this.normalize=a.defaultValue(e.normalize,!1),this.value=e.value}({componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:1,normalize:!0,value:new Float32Array([1])}),$e=[],Qe=[],et=[],tt=[],at=0,rt={},nt=2e9;function it(e){let t=[];for(let a=0;a<e.length;a++){let r=e[a];t=t.concat(r.polygons)}if(0==t.length)return;let a=new A({positions:t,height:rt.ridingLanternHeight,speed:rt.ridingLanternSpeed,type:rt.ridingLanternType,direction:1,color:Cesium.Color.fromAlpha(Cesium.Color.fromCssColorString(rt.ridingLanternColor),rt.ridingLanternAlpha),translucent:!0});tt=a.createGeometryInstances()}function ot(e){if(e.length>0){let t=e[0];(0,qe[t.type])(e)}}function lt(e){for(let t=0;t<e.length;t++){let a=e[t];for(let e=0;e<a.polygons.length;e++){let t=a.polygons[e],r=ut(a.id,a.properties,t);Qe.push(r)}}}function st(e){let t=0;for(let a=0;a<e.length;a++){let r,n,i=e[a],o=i.style,l=mt(o,"fillColor","fillOpacity"),s={color:Y.fromColor(l),display:Je};o.stroke&&(r=mt(o,"strokeColor","strokeOpacity"),n={color:Y.fromColor(r),display:Je});for(let e=0;e<i.polygons.length;e++){let a=i.polygons[e];t=i.totalHeight,t=t||rt.heightValue;let r=ct(i.id,i.properties,a,0,t,s);if($e.push(r),o.stroke){let e=ft(i.id,i.properties,a,0,t,n);et.push(e)}}}}function ut(e,t,a){return e=e+"_"+at+"_water",new n.GeometryInstance({id:e,geometry:i.PolygonGeometry.fromPositions({height:0,positions:a,vertexFormat:Ve.VERTEX_FORMAT}),attributes:{display:Je},properties:t})}function mt(t,r,n){let i,o=t[r];rt.hasOwnProperty("fillColor")&&(o=rt.fillColor),a.defined(o)&&(i=e.Color.fromCssColorString(o),a.defined(i)||(i=e.Color.fromCssColorString("#ffffff")),i.alpha=1);let l=t[n];return rt.hasOwnProperty("opacity")&&(l=rt.opacity),a.defined(l)&&1!==l&&(i.alpha=l),i}function ct(e,t,a,r,o,l){return e=e+"_"+at+"_polygon",rt.translucentMaterial?new n.GeometryInstance({id:e,geometry:i.PolygonGeometry.fromPositions({height:r,extrudedHeight:o,positions:a}),attributes:l,properties:t}):new n.GeometryInstance({id:e,geometry:i.PolygonGeometry.fromPositions({height:r,extrudedHeight:o,positions:a,vertexFormat:Ue.VERTEX_FORMAT}),attributes:l,properties:t})}function ft(e,t,a,r,i,l){return e=e+"_"+at+"_polygonOutLine",new n.GeometryInstance({id:e,geometry:o.PolygonOutlineGeometry.fromPositions({height:r,extrudedHeight:i,positions:a,vertexFormat:Ue.VERTEX_FORMAT}),attributes:l,properties:t})}function pt(e,t){let r=e.length;if(0==r)return null;var n,i,o=new Array(r),l=[],s=0;for(i=0;i<r;i++){var u,m=(n=e[i]).geometry;u=a.defined(m.attributes)&&a.defined(m.primitiveType)?ht(m):m.constructor.createGeometry(m),o[s++]=dt(n,u),l.push(n.id)}o.length=s;var f=c.Ellipsoid.WGS84,p=new v.GeographicProjection(f),d=C.PrimitivePipeline.combineGeometry({instances:o,ellipsoid:p.ellipsoid,projection:p,elementIndexUintSupported:!0,scene3DOnly:!1,vertexCacheOptimize:!1,compressVertices:!0,modelMatrix:h.Matrix4.IDENTITY,createPickOffsets:void 0});return C.PrimitivePipeline.packCombineGeometryResults(d,t)}function dt(e,t){return{geometry:t,attributes:e.attributes,modelMatrix:h.Matrix4.clone(e.modelMatrix),pickPrimitive:e.pickPrimitive,id:e.id}}function _t(e,t){t.attributes=e.attributes,t.attributeIndices=e.attributeIndices,t.batchValues=e.batchValues,t.propertiesMapBuffer=e.propertiesMapBuffer,t.pickId=e.pickId,t.ids=e.ids}function ht(e){var t,r=e.attributes,n=new y.GeometryAttributes;for(var i in r)r.hasOwnProperty(i)&&a.defined(r[i])&&(n[i]=gt(r[i]));if(a.defined(e.indices)){var o=e.indices;t=Array.isArray(o)?o.slice(0):new o.constructor(o)}return new T.Geometry({attributes:n,indices:t,primitiveType:e.primitiveType,boundingSphere:E.BoundingSphere.clone(e.boundingSphere)})}function gt(e){var t;return t=Array.isArray(e.values)?e.values.slice(0):new e.values.constructor(e.values),new T.GeometryAttribute({componentDatatype:e.componentDatatype,componentsPerAttribute:e.componentsPerAttribute,normalize:e.normalize,values:t})}function xt(r,n){var i,o,l,s=new c.Cartesian2,u=new b.Cartesian3,m=new h.Cartesian4,f=r.length,p=function(e){var t,r=e.length,n=[],i=e[0].attributes;for(t in i)if(i.hasOwnProperty(t)&&a.defined(i[t])){for(var o=i[t],l=!0,s=1;s<r;++s){var u=e[s].attributes[t];if(!a.defined(u)||o.componentDatatype!==u.componentDatatype||o.componentsPerAttribute!==u.componentsPerAttribute||o.normalize!==u.normalize){l=!1;break}}l&&n.push(t)}return n}(r),d=p.length,_=[],g=[],x={},T=r[0].attributes;for(i=0;i<d;++i)l=T[o=p[i]],x[o]=i,g.push({functionName:"czm_batchTable_"+o,componentDatatype:l.componentDatatype,componentsPerAttribute:l.componentsPerAttribute,normalize:l.normalize});-1!==p.indexOf("distanceDisplayCondition")&&(g.push({functionName:"czm_batchTable_boundingSphereCenter3DHigh",componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:3},{functionName:"czm_batchTable_boundingSphereCenter3DLow",componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:3},{functionName:"czm_batchTable_boundingSphereCenter2DHigh",componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:3},{functionName:"czm_batchTable_boundingSphereCenter2DLow",componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:3},{functionName:"czm_batchTable_boundingSphereRadius",componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:1}),g.length,g.length,g.length,g.length,g.length),-1!==p.indexOf("offset")&&(g.push({functionName:"czm_batchTable_offset2D",componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:3}),g.length),g.push({functionName:"czm_batchTable_pickColor",componentDatatype:t.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:4,normalize:!0});var y=g.length,C=new Ge({floatingPointTexture:!0},g,f);let v=nt,E={},A=!1;for(i=0;i<f;++i){var P=r[i];P.properties&&(E[P.id]=P.properties,A=!0),T=P.attributes;for(var I=0;I<d;++I){var S=Tt((l=T[o=p[I]]).value,s,u,m),M=x[o];C.setBatchedAttribute(i,M,S)}_.push(P.id),nt++;var L=e.Color.fromRgba(nt),D=m;D.x=e.Color.floatToByte(L.red),D.y=e.Color.floatToByte(L.green),D.z=e.Color.floatToByte(L.blue),D.w=e.Color.floatToByte(L.alpha),C.setBatchedAttribute(i,y-1,D)}var R,w=C._batchValues;(n.push(w.buffer),A)?R=function(e){for(var t=new ArrayBuffer(2*e.length),a=new Uint16Array(t),r=0,n=e.length;r<n;r++)a[r]=e.charCodeAt(r);return t}(JSON.stringify(E)):R=new ArrayBuffer(0);return n.push(R),{attributes:g,attributeIndices:x,batchValues:w,propertiesMapBuffer:R,ids:_,pickId:v}}function Tt(e,t,a,r){var n=e.length;return 1===n?e[0]:2===n?c.Cartesian2.unpack(e,0,t):3===n?b.Cartesian3.unpack(e,0,a):4===n?h.Cartesian4.unpack(e,0,r):void 0}return _e._maximumTextureSize=16384,function(e,t,a,r){return $e=[],Qe=[],et=[],at=t,rt=a,function(e){for(let t in e)if(rt.ridingLanternLayerId&&rt.ridingLanternLayerId.indexOf(t)>-1){it(e[t])}else if(rt.waterLayerId&&rt.waterLayerId.indexOf(t)>-1){lt(e[t])}else{ot(e[t])}}(e),function(e){var t=pt($e,e),a=pt(Qe,e),r=pt(et,e),n=pt(tt,e);let i={};if(t){_t(xt($e,e),t),i.polygon=t}if(a){_t(xt(Qe,e),a),i.water=a}if(r){_t(xt(et,e),r),i.outline=r}if(n){_t(xt(tt,e),n),i.ridingLantern=n}return i}(r)}}));
|