>>b),l[T]=p[S];else for(O=Math.ceil((A-g)/m),T=0;T >>b),l[T]=S >>64-v-P,D=w),C[D])L=C[D][1],v+=C[D][0];else for(w=Y< >>64-v-P,D=w),C[D])L=C[D][1],v+=C[D][0];else for(w=Y<
+ * All color values (diffuse, specular, emissive) are in linear color space.
+ *
+ * This uses standard position attributes,
+ * Use this version when passing in a custom pixel ratio. For example, passing in 1.0 will return meters per native device pixel.
+ *
+ * Use this version when scaling by pixel ratio.
+ *
+ * This function only handles the lighting calculations. Metallic/roughness
+ * and specular/glossy must be handled separately. See {@czm_pbrMetallicRoughnessMaterial}, {@czm_pbrSpecularGlossinessMaterial} and {@czm_defaultPbrMaterial}
+ * The conversion is described in
+ * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
+ *
+ * The order of the coefficients is [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22].
+ *
+ * This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as
+ * described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.
+ *
+ * There are also precision limitations in WebGL 1. highp int is still limited
+ * to 24 bits. Above the value of 2^24 = 16777216, precision loss may occur.
+ *
+ * An example use case for this function would be moving the vertex in window coordinates
+ * before converting back to clip coordinates. Use the original vertex clip coordinates.
+ *
+ * The shader must enable the GL_EXT_frag_depth extension.
+ *
+ * Use this when the vertex shader does not call {@link czm_vertexlogDepth}, for example, when
+ * ray-casting geometry using a full screen quad.
+ *
+ * Use this when the vertex shader calls {@link czm_vertexlogDepth}.
+ * The conversion is described in
+ * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
+ * 0?(s="",e&&(s+=`uniform bool tile_translucentCommand;
+`),s+=`uniform sampler2D tile_batchTexture;
+varying vec4 tile_featureColor;
+varying vec2 tile_featureSt;
+void main()
+{
+ vec2 st = computeSt(${t});
+ vec4 featureProperties = texture2D(tile_batchTexture, st);
+ tile_color(featureProperties);
+ float show = ceil(featureProperties.a);
+ gl_Position *= show;
+`,e&&(s+=` bool isStyleTranslucent = (featureProperties.a != 1.0);
+ if (czm_pass == czm_passTranslucent)
+ {
+ if (!isStyleTranslucent && !tile_translucentCommand)
+ {
+ gl_Position *= 0.0;
+ }
+ }
+ else
+ {
+ if (isStyleTranslucent)
+ {
+ gl_Position *= 0.0;
+ }
+ }
+`),s+=` tile_featureColor = featureProperties;
+ tile_featureSt = st;
+}`):s=`varying vec2 tile_featureSt;
+void main()
+{
+ tile_color(vec4(1.0));
+ tile_featureSt = computeSt(${t});
+}`,`${r}
+${UPe(i)}${s}`}};function M$(e,t){return e=Ue.replaceMain(e,"tile_main"),t?`${e}uniform float tile_colorBlend;
+void tile_color(vec4 tile_featureColor)
+{
+ tile_main();
+ tile_featureColor = czm_gammaCorrect(tile_featureColor);
+ gl_FragColor.a *= tile_featureColor.a;
+ float highlight = ceil(tile_colorBlend);
+ gl_FragColor.rgb *= mix(tile_featureColor.rgb, vec3(1.0), highlight);
+}
+`:`${e}void tile_color(vec4 tile_featureColor)
+{
+ tile_main();
+}
+`}function zPe(e,t){let n=`texture2D(${t}`,i=0,o=e.indexOf(n,i),r;for(;o>-1;){let s=0;for(let l=o;l0&&(r+=I.TWO_PI),i0&&(r+=I.TWO_PI),i0){let s=o.substring(0,r),a=o.substring(r+2);t[s]=a}}return t}var AS=FCe;function CK(e,t,n){this.statusCode=e,this.response=t,this.responseHeaders=n,typeof this.responseHeaders=="string"&&(this.responseHeaders=AS(this.responseHeaders))}CK.prototype.toString=function(){let e="Request has failed.";return u(this.statusCode)&&(e+=` Status Code: ${this.statusCode}`),e};var $d=CK;var CS=ho(Dl(),1);function jy(e){this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}Object.defineProperties(jy.prototype,{length:{get:function(){return this._length}},internalArray:{get:function(){return this._array}},maximumLength:{get:function(){return this._maximumLength},set:function(e){let t=this._length;if(e1/pi.
+ *
+ * @alias czm_oneOverPi
+ * @glslConstant
+ *
+ * @see CesiumMath.ONE_OVER_PI
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_oneOverPi = ...;
+ *
+ * // Example
+ * float pi = 1.0 / czm_oneOverPi;
+ */
+const float czm_oneOverPi = 0.3183098861837907;
+`;var Sw=`/**
+ * A built-in GLSL floating-point constant for 1/2pi.
+ *
+ * @alias czm_oneOverTwoPi
+ * @glslConstant
+ *
+ * @see CesiumMath.ONE_OVER_TWO_PI
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_oneOverTwoPi = ...;
+ *
+ * // Example
+ * float pi = 2.0 * czm_oneOverTwoPi;
+ */
+const float czm_oneOverTwoPi = 0.15915494309189535;
+`;var ww=`/**
+ * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE}
+ *
+ * @name czm_passCesium3DTile
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passCesium3DTile = 4.0;
+`;var vw=`/**
+ * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION}
+ *
+ * @name czm_passCesium3DTileClassification
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passCesium3DTileClassification = 5.0;
+`;var Dw=`/**
+ * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW}
+ *
+ * @name czm_passCesium3DTileClassificationIgnoreShow
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passCesium3DTileClassificationIgnoreShow = 6.0;
+`;var Pw=`/**
+ * The automatic GLSL constant for {@link Pass#CLASSIFICATION}
+ *
+ * @name czm_passClassification
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passClassification = 7.0;
+`;var Iw=`/**
+ * The automatic GLSL constant for {@link Pass#COMPUTE}
+ *
+ * @name czm_passCompute
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passCompute = 1.0;
+`;var Ow=`/**
+ * The automatic GLSL constant for {@link Pass#ENVIRONMENT}
+ *
+ * @name czm_passEnvironment
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passEnvironment = 0.0;
+`;var Bw=`/**
+ * The automatic GLSL constant for {@link Pass#GLOBE}
+ *
+ * @name czm_passGlobe
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passGlobe = 2.0;
+`;var Rw=`/**
+ * The automatic GLSL constant for {@link Pass#OPAQUE}
+ *
+ * @name czm_passOpaque
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passOpaque = 7.0;
+`;var Mw=`/**
+ * The automatic GLSL constant for {@link Pass#OVERLAY}
+ *
+ * @name czm_passOverlay
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passOverlay = 9.0;
+`;var Lw=`/**
+ * The automatic GLSL constant for {@link Pass#TERRAIN_CLASSIFICATION}
+ *
+ * @name czm_passTerrainClassification
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passTerrainClassification = 3.0;
+`;var Fw=`/**
+ * The automatic GLSL constant for {@link Pass#TRANSLUCENT}
+ *
+ * @name czm_passTranslucent
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passTranslucent = 8.0;
+`;var Nw=`/**
+ * A built-in GLSL floating-point constant for Math.PI.
+ *
+ * @alias czm_pi
+ * @glslConstant
+ *
+ * @see CesiumMath.PI
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_pi = ...;
+ *
+ * // Example
+ * float twoPi = 2.0 * czm_pi;
+ */
+const float czm_pi = 3.141592653589793;
+`;var kw=`/**
+ * A built-in GLSL floating-point constant for pi/4.
+ *
+ * @alias czm_piOverFour
+ * @glslConstant
+ *
+ * @see CesiumMath.PI_OVER_FOUR
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_piOverFour = ...;
+ *
+ * // Example
+ * float pi = 4.0 * czm_piOverFour;
+ */
+const float czm_piOverFour = 0.7853981633974483;
+`;var Vw=`/**
+ * A built-in GLSL floating-point constant for pi/6.
+ *
+ * @alias czm_piOverSix
+ * @glslConstant
+ *
+ * @see CesiumMath.PI_OVER_SIX
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_piOverSix = ...;
+ *
+ * // Example
+ * float pi = 6.0 * czm_piOverSix;
+ */
+const float czm_piOverSix = 0.5235987755982988;
+`;var Uw=`/**
+ * A built-in GLSL floating-point constant for pi/3.
+ *
+ * @alias czm_piOverThree
+ * @glslConstant
+ *
+ * @see CesiumMath.PI_OVER_THREE
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_piOverThree = ...;
+ *
+ * // Example
+ * float pi = 3.0 * czm_piOverThree;
+ */
+const float czm_piOverThree = 1.0471975511965976;
+`;var zw=`/**
+ * A built-in GLSL floating-point constant for pi/2.
+ *
+ * @alias czm_piOverTwo
+ * @glslConstant
+ *
+ * @see CesiumMath.PI_OVER_TWO
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_piOverTwo = ...;
+ *
+ * // Example
+ * float pi = 2.0 * czm_piOverTwo;
+ */
+const float czm_piOverTwo = 1.5707963267948966;
+`;var Gw=`/**
+ * A built-in GLSL floating-point constant for converting degrees to radians.
+ *
+ * @alias czm_radiansPerDegree
+ * @glslConstant
+ *
+ * @see CesiumMath.RADIANS_PER_DEGREE
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_radiansPerDegree = ...;
+ *
+ * // Example
+ * float rad = czm_radiansPerDegree * deg;
+ */
+const float czm_radiansPerDegree = 0.017453292519943295;
+`;var Hw=`/**
+ * The constant identifier for the 2D {@link SceneMode}
+ *
+ * @name czm_sceneMode2D
+ * @glslConstant
+ * @see czm_sceneMode
+ * @see czm_sceneModeColumbusView
+ * @see czm_sceneMode3D
+ * @see czm_sceneModeMorphing
+ */
+const float czm_sceneMode2D = 2.0;
+`;var Ww=`/**
+ * The constant identifier for the 3D {@link SceneMode}
+ *
+ * @name czm_sceneMode3D
+ * @glslConstant
+ * @see czm_sceneMode
+ * @see czm_sceneMode2D
+ * @see czm_sceneModeColumbusView
+ * @see czm_sceneModeMorphing
+ */
+const float czm_sceneMode3D = 3.0;
+`;var jw=`/**
+ * The constant identifier for the Columbus View {@link SceneMode}
+ *
+ * @name czm_sceneModeColumbusView
+ * @glslConstant
+ * @see czm_sceneMode
+ * @see czm_sceneMode2D
+ * @see czm_sceneMode3D
+ * @see czm_sceneModeMorphing
+ */
+const float czm_sceneModeColumbusView = 1.0;
+`;var qw=`/**
+ * The constant identifier for the Morphing {@link SceneMode}
+ *
+ * @name czm_sceneModeMorphing
+ * @glslConstant
+ * @see czm_sceneMode
+ * @see czm_sceneMode2D
+ * @see czm_sceneModeColumbusView
+ * @see czm_sceneMode3D
+ */
+const float czm_sceneModeMorphing = 0.0;
+`;var Yw=`/**
+ * A built-in GLSL floating-point constant for one solar radius.
+ *
+ * @alias czm_solarRadius
+ * @glslConstant
+ *
+ * @see CesiumMath.SOLAR_RADIUS
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_solarRadius = ...;
+ */
+const float czm_solarRadius = 695500000.0;
+`;var Xw=`/**
+ * A built-in GLSL floating-point constant for 3pi/2.
+ *
+ * @alias czm_threePiOver2
+ * @glslConstant
+ *
+ * @see CesiumMath.THREE_PI_OVER_TWO
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_threePiOver2 = ...;
+ *
+ * // Example
+ * float pi = (2.0 / 3.0) * czm_threePiOver2;
+ */
+const float czm_threePiOver2 = 4.71238898038469;
+`;var Kw=`/**
+ * A built-in GLSL floating-point constant for 2pi.
+ *
+ * @alias czm_twoPi
+ * @glslConstant
+ *
+ * @see CesiumMath.TWO_PI
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_twoPi = ...;
+ *
+ * // Example
+ * float pi = czm_twoPi / 2.0;
+ */
+const float czm_twoPi = 6.283185307179586;
+`;var Jw=`/**
+ * The maximum latitude, in radians, both North and South, supported by a Web Mercator
+ * (EPSG:3857) projection. Technically, the Mercator projection is defined
+ * for any latitude up to (but not including) 90 degrees, but it makes sense
+ * to cut it off sooner because it grows exponentially with increasing latitude.
+ * The logic behind this particular cutoff value, which is the one used by
+ * Google Maps, Bing Maps, and Esri, is that it makes the projection
+ * square. That is, the rectangle is equal in the X and Y directions.
+ *
+ * The constant value is computed as follows:
+ * czm_pi * 0.5 - (2.0 * atan(exp(-czm_pi)))
+ *
+ * @name czm_webMercatorMaxLatitude
+ * @glslConstant
+ */
+const float czm_webMercatorMaxLatitude = 1.4844222297453324;
+`;var Zw=`/**
+ * @name czm_depthRangeStruct
+ * @glslStruct
+ */
+struct czm_depthRangeStruct
+{
+ float near;
+ float far;
+};
+`;var Qw=`/**
+ * Holds material information that can be used for lighting. Returned by all czm_getMaterial functions.
+ *
+ * @name czm_material
+ * @glslStruct
+ *
+ * @property {vec3} diffuse Incoming light that scatters evenly in all directions.
+ * @property {float} specular Intensity of incoming light reflecting in a single direction.
+ * @property {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.
+ * @property {vec3} normal Surface's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface's unmodified normal.
+ * @property {vec3} emission Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
+ * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.
+ */
+struct czm_material
+{
+ vec3 diffuse;
+ float specular;
+ float shininess;
+ vec3 normal;
+ vec3 emission;
+ float alpha;
+};
+`;var $w=`/**
+ * Used as input to every material's czm_getMaterial function.
+ *
+ * @name czm_materialInput
+ * @glslStruct
+ *
+ * @property {float} s 1D texture coordinates.
+ * @property {vec2} st 2D texture coordinates.
+ * @property {vec3} str 3D texture coordinates.
+ * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.
+ * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.
+ * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.
+ * @property {float} height The height of the terrain in meters above or below the WGS84 ellipsoid. Only available for globe materials.
+ * @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.
+ * @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.
+ */
+struct czm_materialInput
+{
+ float s;
+ vec2 st;
+ vec3 str;
+ vec3 normalEC;
+ mat3 tangentToEyeMatrix;
+ vec3 positionToEyeEC;
+ float height;
+ float slope;
+ float aspect;
+};
+`;var ev=`/**
+ * Struct for representing a material for a {@link Model}. The model
+ * rendering pipeline will pass this struct between material, custom shaders,
+ * and lighting stages. This is not to be confused with {@link czm_material}
+ * which is used by the older Fabric materials system, although they are similar.
+ * color1 or color2.
+ * @param {float} dist The distance to the edge in texture coordinates.
+ * @param {float} [fuzzFactor=0.1] Controls the blurriness between the two colors.
+ * @returns {vec4} The anti-aliased color.
+ *
+ * @example
+ * // GLSL declarations
+ * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor);
+ * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist);
+ *
+ * // get the color for a material that has a sharp edge at the line y = 0.5 in texture space
+ * float dist = abs(textureCoordinates.t - 0.5);
+ * vec4 currentColor = mix(bottomColor, topColor, step(0.5, textureCoordinates.t));
+ * vec4 color = czm_antialias(bottomColor, topColor, currentColor, dist, 0.1);
+ */
+vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor)
+{
+ float val1 = clamp(dist / fuzzFactor, 0.0, 1.0);
+ float val2 = clamp((dist - 0.5) / fuzzFactor, 0.0, 1.0);
+ val1 = val1 * (1.0 - val2);
+ val1 = val1 * val1 * (3.0 - (2.0 * val1));
+ val1 = pow(val1, 0.5); //makes the transition nicer
+
+ vec4 midColor = (color1 + color2) * 0.5;
+ return mix(midColor, currentColor, val1);
+}
+
+vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist)
+{
+ return czm_antialias(color1, color2, currentColor, dist, 0.1);
+}
+`;var lv=`/**
+ * Approximately computes spherical coordinates given a normal.
+ * Uses approximate inverse trigonometry for speed and consistency,
+ * since inverse trigonometry can differ from vendor-to-vendor and when compared with the CPU.
+ *
+ * @name czm_approximateSphericalCoordinates
+ * @glslFunction
+ *
+ * @param {vec3} normal arbitrary-length normal.
+ *
+ * @returns {vec2} Approximate latitude and longitude spherical coordinates.
+ */
+vec2 czm_approximateSphericalCoordinates(vec3 normal) {
+ // Project into plane with vertical for latitude
+ float latitudeApproximation = czm_fastApproximateAtan(sqrt(normal.x * normal.x + normal.y * normal.y), normal.z);
+ float longitudeApproximation = czm_fastApproximateAtan(normal.x, normal.y);
+ return vec2(latitudeApproximation, longitudeApproximation);
+}
+`;var uv=`/**
+ * Determines if the fragment is back facing
+ *
+ * @name czm_backFacing
+ * @glslFunction
+ *
+ * @returns {bool} true if the fragment is back facing; otherwise, false.
+ */
+bool czm_backFacing()
+{
+ // !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.
+ return gl_FrontFacing == false;
+}
+`;var fv=`/**
+ * Branchless ternary operator to be used when it's inexpensive to explicitly
+ * evaluate both possibilities for a float expression.
+ *
+ * @name czm_branchFreeTernary
+ * @glslFunction
+ *
+ * @param {bool} comparison A comparison statement
+ * @param {float} a Value to return if the comparison is true.
+ * @param {float} b Value to return if the comparison is false.
+ *
+ * @returns {float} equivalent of comparison ? a : b
+ */
+float czm_branchFreeTernary(bool comparison, float a, float b) {
+ float useA = float(comparison);
+ return a * useA + b * (1.0 - useA);
+}
+
+/**
+ * Branchless ternary operator to be used when it's inexpensive to explicitly
+ * evaluate both possibilities for a vec2 expression.
+ *
+ * @name czm_branchFreeTernary
+ * @glslFunction
+ *
+ * @param {bool} comparison A comparison statement
+ * @param {vec2} a Value to return if the comparison is true.
+ * @param {vec2} b Value to return if the comparison is false.
+ *
+ * @returns {vec2} equivalent of comparison ? a : b
+ */
+vec2 czm_branchFreeTernary(bool comparison, vec2 a, vec2 b) {
+ float useA = float(comparison);
+ return a * useA + b * (1.0 - useA);
+}
+
+/**
+ * Branchless ternary operator to be used when it's inexpensive to explicitly
+ * evaluate both possibilities for a vec3 expression.
+ *
+ * @name czm_branchFreeTernary
+ * @glslFunction
+ *
+ * @param {bool} comparison A comparison statement
+ * @param {vec3} a Value to return if the comparison is true.
+ * @param {vec3} b Value to return if the comparison is false.
+ *
+ * @returns {vec3} equivalent of comparison ? a : b
+ */
+vec3 czm_branchFreeTernary(bool comparison, vec3 a, vec3 b) {
+ float useA = float(comparison);
+ return a * useA + b * (1.0 - useA);
+}
+
+/**
+ * Branchless ternary operator to be used when it's inexpensive to explicitly
+ * evaluate both possibilities for a vec4 expression.
+ *
+ * @name czm_branchFreeTernary
+ * @glslFunction
+ *
+ * @param {bool} comparison A comparison statement
+ * @param {vec3} a Value to return if the comparison is true.
+ * @param {vec3} b Value to return if the comparison is false.
+ *
+ * @returns {vec3} equivalent of comparison ? a : b
+ */
+vec4 czm_branchFreeTernary(bool comparison, vec4 a, vec4 b) {
+ float useA = float(comparison);
+ return a * useA + b * (1.0 - useA);
+}
+`;var dv=`
+vec4 czm_cascadeColor(vec4 weights)
+{
+ return vec4(1.0, 0.0, 0.0, 1.0) * weights.x +
+ vec4(0.0, 1.0, 0.0, 1.0) * weights.y +
+ vec4(0.0, 0.0, 1.0, 1.0) * weights.z +
+ vec4(1.0, 0.0, 1.0, 1.0) * weights.w;
+}
+`;var hv=`
+uniform vec4 shadowMap_cascadeDistances;
+
+float czm_cascadeDistance(vec4 weights)
+{
+ return dot(shadowMap_cascadeDistances, weights);
+}
+`;var mv=`
+uniform mat4 shadowMap_cascadeMatrices[4];
+
+mat4 czm_cascadeMatrix(vec4 weights)
+{
+ return shadowMap_cascadeMatrices[0] * weights.x +
+ shadowMap_cascadeMatrices[1] * weights.y +
+ shadowMap_cascadeMatrices[2] * weights.z +
+ shadowMap_cascadeMatrices[3] * weights.w;
+}
+`;var pv=`
+uniform vec4 shadowMap_cascadeSplits[2];
+
+vec4 czm_cascadeWeights(float depthEye)
+{
+ // One component is set to 1.0 and all others set to 0.0.
+ vec4 near = step(shadowMap_cascadeSplits[0], vec4(depthEye));
+ vec4 far = step(depthEye, shadowMap_cascadeSplits[1]);
+ return near * far;
+}
+`;var _v=`/**
+ * DOC_TBA
+ *
+ * @name czm_columbusViewMorph
+ * @glslFunction
+ */
+vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)
+{
+ // Just linear for now.
+ vec3 p = mix(position2D.xyz, position3D.xyz, time);
+ return vec4(p, 1.0);
+}
+`;var gv=`/**
+ * Returns a position in model coordinates relative to eye taking into
+ * account the current scene mode: 3D, 2D, or Columbus view.
+ * position3DHigh,
+ * position3DLow, position2DHigh, and position2DLow,
+ * and should be used when writing a vertex shader for an {@link Appearance}.
+ *
+ * The ellipsoid is assumed to be centered at the model coordinate's origin.
+ *
+ * @name czm_eastNorthUpToEyeCoordinates
+ * @glslFunction
+ *
+ * @param {vec3} positionMC The position on the ellipsoid in model coordinates.
+ * @param {vec3} normalEC The normalized ellipsoid surface normal, at positionMC, in eye coordinates.
+ *
+ * @returns {mat3} A 3x3 rotation matrix that transforms vectors from the east-north-up coordinate system to eye coordinates.
+ *
+ * @example
+ * // Transform a vector defined in the east-north-up coordinate
+ * // system, (0, 0, 1) which is the surface normal, to eye
+ * // coordinates.
+ * mat3 m = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);
+ * vec3 normalEC = m * vec3(0.0, 0.0, 1.0);
+ */
+mat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)
+{
+ vec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0)); // normalized surface tangent in model coordinates
+ vec3 tangentEC = normalize(czm_normal3D * tangentMC); // normalized surface tangent in eye coordiantes
+ vec3 bitangentEC = normalize(cross(normalEC, tangentEC)); // normalized surface bitangent in eye coordinates
+
+ return mat3(
+ tangentEC.x, tangentEC.y, tangentEC.z,
+ bitangentEC.x, bitangentEC.y, bitangentEC.z,
+ normalEC.x, normalEC.y, normalEC.z);
+}
+`;var Ev=`/**
+ * DOC_TBA
+ *
+ * @name czm_ellipsoidContainsPoint
+ * @glslFunction
+ *
+ */
+bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point)
+{
+ vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz;
+ return (dot(scaled, scaled) <= 1.0);
+}
+`;var bv=`/**
+ * DOC_TBA
+ *
+ * @name czm_ellipsoidWgs84TextureCoordinates
+ * @glslFunction
+ */
+vec2 czm_ellipsoidWgs84TextureCoordinates(vec3 normal)
+{
+ return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);
+}
+`;var Sv=`/**
+ * Compares left and right componentwise. Returns true
+ * if they are within epsilon and false otherwise. The inputs
+ * left and right can be floats, vec2s,
+ * vec3s, or vec4s.
+ *
+ * @name czm_equalsEpsilon
+ * @glslFunction
+ *
+ * @param {} left The first vector.
+ * @param {} right The second vector.
+ * @param {float} epsilon The epsilon to use for equality testing.
+ * @returns {bool} true if the components are within epsilon and false otherwise.
+ *
+ * @example
+ * // GLSL declarations
+ * bool czm_equalsEpsilon(float left, float right, float epsilon);
+ * bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon);
+ * bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon);
+ * bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon);
+ */
+bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon) {
+ return all(lessThanEqual(abs(left - right), vec4(epsilon)));
+}
+
+bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon) {
+ return all(lessThanEqual(abs(left - right), vec3(epsilon)));
+}
+
+bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon) {
+ return all(lessThanEqual(abs(left - right), vec2(epsilon)));
+}
+
+bool czm_equalsEpsilon(float left, float right, float epsilon) {
+ return (abs(left - right) <= epsilon);
+}
+`;var wv=`/**
+ * DOC_TBA
+ *
+ * @name czm_eyeOffset
+ * @glslFunction
+ *
+ * @param {vec4} positionEC DOC_TBA.
+ * @param {vec3} eyeOffset DOC_TBA.
+ *
+ * @returns {vec4} DOC_TBA.
+ */
+vec4 czm_eyeOffset(vec4 positionEC, vec3 eyeOffset)
+{
+ // This equation is approximate in x and y.
+ vec4 p = positionEC;
+ vec4 zEyeOffset = normalize(p) * eyeOffset.z;
+ p.xy += eyeOffset.xy + zEyeOffset.xy;
+ p.z += zEyeOffset.z;
+ return p;
+}
+`;var vv=`/**
+ * Transforms a position from eye to window coordinates. The transformation
+ * from eye to clip coordinates is done using {@link czm_projection}.
+ * The transform from normalized device coordinates to window coordinates is
+ * done using {@link czm_viewportTransformation}, which assumes a depth range
+ * of near = 0 and far = 1.
+ *
+ * This transform is useful when there is a need to manipulate window coordinates
+ * in a vertex shader as done by {@link BillboardCollection}.
+ *
+ * @name czm_eyeToWindowCoordinates
+ * @glslFunction
+ *
+ * @param {vec4} position The position in eye coordinates to transform.
+ *
+ * @returns {vec4} The transformed position in window coordinates.
+ *
+ * @see czm_modelToWindowCoordinates
+ * @see czm_projection
+ * @see czm_viewportTransformation
+ * @see BillboardCollection
+ *
+ * @example
+ * vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
+ */
+vec4 czm_eyeToWindowCoordinates(vec4 positionEC)
+{
+ vec4 q = czm_projection * positionEC; // clip coordinates
+ q.xyz /= q.w; // normalized device coordinates
+ q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
+ return q;
+}
+`;var Dv=`/**
+ * Approxiamtes atan over the range [0, 1]. Safe to flip output for negative input.
+ *
+ * Based on Michal Drobot's approximation from ShaderFastLibs, which in turn is based on
+ * "Efficient approximations for the arctangent function," Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006.
+ * Adapted from ShaderFastLibs under MIT License.
+ *
+ * Chosen for the following characteristics over range [0, 1]:
+ * - basically no error at 0 and 1, important for getting around range limit (naive atan2 via atan requires infinite range atan)
+ * - no visible artifacts from first-derivative discontinuities, unlike latitude via range-reduced sqrt asin approximations (at equator)
+ *
+ * The original code is x * (-0.1784 * abs(x) - 0.0663 * x * x + 1.0301);
+ * Removed the abs() in here because it isn't needed, the input range is guaranteed as [0, 1] by how we're approximating atan2.
+ *
+ * @name czm_fastApproximateAtan
+ * @glslFunction
+ *
+ * @param {float} x Value between 0 and 1 inclusive.
+ *
+ * @returns {float} Approximation of atan(x)
+ */
+float czm_fastApproximateAtan(float x) {
+ return x * (-0.1784 * x - 0.0663 * x * x + 1.0301);
+}
+
+/**
+ * Approximation of atan2.
+ *
+ * Range reduction math based on nvidia's cg reference implementation for atan2: http://developer.download.nvidia.com/cg/atan2.html
+ * However, we replaced their atan curve with Michael Drobot's (see above).
+ *
+ * @name czm_fastApproximateAtan
+ * @glslFunction
+ *
+ * @param {float} x Value between -1 and 1 inclusive.
+ * @param {float} y Value between -1 and 1 inclusive.
+ *
+ * @returns {float} Approximation of atan2(x, y)
+ */
+float czm_fastApproximateAtan(float x, float y) {
+ // atan approximations are usually only reliable over [-1, 1], or, in our case, [0, 1] due to modifications.
+ // So range-reduce using abs and by flipping whether x or y is on top.
+ float t = abs(x); // t used as swap and atan result.
+ float opposite = abs(y);
+ float adjacent = max(t, opposite);
+ opposite = min(t, opposite);
+
+ t = czm_fastApproximateAtan(opposite / adjacent);
+
+ // Undo range reduction
+ t = czm_branchFreeTernary(abs(y) > abs(x), czm_piOverTwo - t, t);
+ t = czm_branchFreeTernary(x < 0.0, czm_pi - t, t);
+ t = czm_branchFreeTernary(y < 0.0, -t, t);
+ return t;
+}
+`;var Pv=`/**
+ * Gets the color with fog at a distance from the camera.
+ *
+ * @name czm_fog
+ * @glslFunction
+ *
+ * @param {float} distanceToCamera The distance to the camera in meters.
+ * @param {vec3} color The original color.
+ * @param {vec3} fogColor The color of the fog.
+ *
+ * @returns {vec3} The color adjusted for fog at the distance from the camera.
+ */
+vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor)
+{
+ float scalar = distanceToCamera * czm_fogDensity;
+ float fog = 1.0 - exp(-(scalar * scalar));
+ return mix(color, fogColor, fog);
+}
+
+/**
+ * Gets the color with fog at a distance from the camera.
+ *
+ * @name czm_fog
+ * @glslFunction
+ *
+ * @param {float} distanceToCamera The distance to the camera in meters.
+ * @param {vec3} color The original color.
+ * @param {vec3} fogColor The color of the fog.
+ * @param {float} fogModifierConstant A constant to modify the appearance of fog.
+ *
+ * @returns {vec3} The color adjusted for fog at the distance from the camera.
+ */
+vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor, float fogModifierConstant)
+{
+ float scalar = distanceToCamera * czm_fogDensity;
+ float fog = 1.0 - exp(-((fogModifierConstant * scalar + fogModifierConstant) * (scalar * (1.0 + fogModifierConstant))));
+ return mix(color, fogColor, fog);
+}
+`;var Iv=`/**
+ * Converts a color from RGB space to linear space.
+ *
+ * @name czm_gammaCorrect
+ * @glslFunction
+ *
+ * @param {vec3} color The color in RGB space.
+ * @returns {vec3} The color in linear space.
+ */
+vec3 czm_gammaCorrect(vec3 color) {
+#ifdef HDR
+ color = pow(color, vec3(czm_gamma));
+#endif
+ return color;
+}
+
+vec4 czm_gammaCorrect(vec4 color) {
+#ifdef HDR
+ color.rgb = pow(color.rgb, vec3(czm_gamma));
+#endif
+ return color;
+}
+`;var Ov=`/**
+ * DOC_TBA
+ *
+ * @name czm_geodeticSurfaceNormal
+ * @glslFunction
+ *
+ * @param {vec3} positionOnEllipsoid DOC_TBA
+ * @param {vec3} ellipsoidCenter DOC_TBA
+ * @param {vec3} oneOverEllipsoidRadiiSquared DOC_TBA
+ *
+ * @returns {vec3} DOC_TBA.
+ */
+vec3 czm_geodeticSurfaceNormal(vec3 positionOnEllipsoid, vec3 ellipsoidCenter, vec3 oneOverEllipsoidRadiiSquared)
+{
+ return normalize((positionOnEllipsoid - ellipsoidCenter) * oneOverEllipsoidRadiiSquared);
+}
+`;var Bv=`/**
+ * An czm_material with default values. Every material's czm_getMaterial
+ * should use this default material as a base for the material it returns.
+ * The default normal value is given by materialInput.normalEC.
+ *
+ * @name czm_getDefaultMaterial
+ * @glslFunction
+ *
+ * @param {czm_materialInput} input The input used to construct the default material.
+ *
+ * @returns {czm_material} The default material.
+ *
+ * @see czm_materialInput
+ * @see czm_material
+ * @see czm_getMaterial
+ */
+czm_material czm_getDefaultMaterial(czm_materialInput materialInput)
+{
+ czm_material material;
+ material.diffuse = vec3(0.0);
+ material.specular = 0.0;
+ material.shininess = 1.0;
+ material.normal = materialInput.normalEC;
+ material.emission = vec3(0.0);
+ material.alpha = 1.0;
+ return material;
+}
+`;var Rv=`/**
+ * Calculates the intensity of diffusely reflected light.
+ *
+ * @name czm_getLambertDiffuse
+ * @glslFunction
+ *
+ * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
+ * @param {vec3} normalEC The surface normal in eye coordinates.
+ *
+ * @returns {float} The intensity of the diffuse reflection.
+ *
+ * @see czm_phong
+ *
+ * @example
+ * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC);
+ * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200);
+ * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity);
+ */
+float czm_getLambertDiffuse(vec3 lightDirectionEC, vec3 normalEC)
+{
+ return max(dot(lightDirectionEC, normalEC), 0.0);
+}
+`;var Mv=`/**
+ * Calculates the specular intensity of reflected light.
+ *
+ * @name czm_getSpecular
+ * @glslFunction
+ *
+ * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
+ * @param {vec3} toEyeEC Unit vector pointing to the eye position in eye coordinates.
+ * @param {vec3} normalEC The surface normal in eye coordinates.
+ * @param {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.
+ *
+ * @returns {float} The intensity of the specular highlight.
+ *
+ * @see czm_phong
+ *
+ * @example
+ * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC);
+ * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200);
+ * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity);
+ */
+float czm_getSpecular(vec3 lightDirectionEC, vec3 toEyeEC, vec3 normalEC, float shininess)
+{
+ vec3 toReflectedLight = reflect(-lightDirectionEC, normalEC);
+ float specular = max(dot(toReflectedLight, toEyeEC), 0.0);
+
+ // pow has undefined behavior if both parameters <= 0.
+ // Prevent this by making sure shininess is at least czm_epsilon2.
+ return pow(specular, max(shininess, czm_epsilon2));
+}
+`;var Lv=`/**
+ * @private
+ */
+vec4 czm_getWaterNoise(sampler2D normalMap, vec2 uv, float time, float angleInRadians)
+{
+ float cosAngle = cos(angleInRadians);
+ float sinAngle = sin(angleInRadians);
+
+ // time dependent sampling directions
+ vec2 s0 = vec2(1.0/17.0, 0.0);
+ vec2 s1 = vec2(-1.0/29.0, 0.0);
+ vec2 s2 = vec2(1.0/101.0, 1.0/59.0);
+ vec2 s3 = vec2(-1.0/109.0, -1.0/57.0);
+
+ // rotate sampling direction by specified angle
+ s0 = vec2((cosAngle * s0.x) - (sinAngle * s0.y), (sinAngle * s0.x) + (cosAngle * s0.y));
+ s1 = vec2((cosAngle * s1.x) - (sinAngle * s1.y), (sinAngle * s1.x) + (cosAngle * s1.y));
+ s2 = vec2((cosAngle * s2.x) - (sinAngle * s2.y), (sinAngle * s2.x) + (cosAngle * s2.y));
+ s3 = vec2((cosAngle * s3.x) - (sinAngle * s3.y), (sinAngle * s3.x) + (cosAngle * s3.y));
+
+ vec2 uv0 = (uv/103.0) + (time * s0);
+ vec2 uv1 = uv/107.0 + (time * s1) + vec2(0.23);
+ vec2 uv2 = uv/vec2(897.0, 983.0) + (time * s2) + vec2(0.51);
+ vec2 uv3 = uv/vec2(991.0, 877.0) + (time * s3) + vec2(0.71);
+
+ uv0 = fract(uv0);
+ uv1 = fract(uv1);
+ uv2 = fract(uv2);
+ uv3 = fract(uv3);
+ vec4 noise = (texture2D(normalMap, uv0)) +
+ (texture2D(normalMap, uv1)) +
+ (texture2D(normalMap, uv2)) +
+ (texture2D(normalMap, uv3));
+
+ // average and scale to between -1 and 1
+ return ((noise / 4.0) - 0.5) * 2.0;
+}
+`;var Fv=`/**
+ * Converts an HSB color (hue, saturation, brightness) to RGB
+ * HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}
+ *
+ * @name czm_HSBToRGB
+ * @glslFunction
+ *
+ * @param {vec3} hsb The color in HSB.
+ *
+ * @returns {vec3} The color in RGB.
+ *
+ * @example
+ * vec3 hsb = czm_RGBToHSB(rgb);
+ * hsb.z *= 0.1;
+ * rgb = czm_HSBToRGB(hsb);
+ */
+
+const vec4 K_HSB2RGB = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+
+vec3 czm_HSBToRGB(vec3 hsb)
+{
+ vec3 p = abs(fract(hsb.xxx + K_HSB2RGB.xyz) * 6.0 - K_HSB2RGB.www);
+ return hsb.z * mix(K_HSB2RGB.xxx, clamp(p - K_HSB2RGB.xxx, 0.0, 1.0), hsb.y);
+}
+`;var Nv=`/**
+ * Converts an HSL color (hue, saturation, lightness) to RGB
+ * HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html}
+ *
+ * @name czm_HSLToRGB
+ * @glslFunction
+ *
+ * @param {vec3} rgb The color in HSL.
+ *
+ * @returns {vec3} The color in RGB.
+ *
+ * @example
+ * vec3 hsl = czm_RGBToHSL(rgb);
+ * hsl.z *= 0.1;
+ * rgb = czm_HSLToRGB(hsl);
+ */
+
+vec3 hueToRGB(float hue)
+{
+ float r = abs(hue * 6.0 - 3.0) - 1.0;
+ float g = 2.0 - abs(hue * 6.0 - 2.0);
+ float b = 2.0 - abs(hue * 6.0 - 4.0);
+ return clamp(vec3(r, g, b), 0.0, 1.0);
+}
+
+vec3 czm_HSLToRGB(vec3 hsl)
+{
+ vec3 rgb = hueToRGB(hsl.x);
+ float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
+ return (rgb - 0.5) * c + hsl.z;
+}
+`;var kv=`/**
+ * Adjusts the hue of a color.
+ *
+ * @name czm_hue
+ * @glslFunction
+ *
+ * @param {vec3} rgb The color.
+ * @param {float} adjustment The amount to adjust the hue of the color in radians.
+ *
+ * @returns {float} The color with the hue adjusted.
+ *
+ * @example
+ * vec3 adjustHue = czm_hue(color, czm_pi); // The same as czm_hue(color, -czm_pi)
+ */
+vec3 czm_hue(vec3 rgb, float adjustment)
+{
+ const mat3 toYIQ = mat3(0.299, 0.587, 0.114,
+ 0.595716, -0.274453, -0.321263,
+ 0.211456, -0.522591, 0.311135);
+ const mat3 toRGB = mat3(1.0, 0.9563, 0.6210,
+ 1.0, -0.2721, -0.6474,
+ 1.0, -1.107, 1.7046);
+
+ vec3 yiq = toYIQ * rgb;
+ float hue = atan(yiq.z, yiq.y) + adjustment;
+ float chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);
+
+ vec3 color = vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));
+ return toRGB * color;
+}
+`;var Vv=`/**
+ * Converts a color in linear space to RGB space.
+ *
+ * @name czm_inverseGamma
+ * @glslFunction
+ *
+ * @param {vec3} color The color in linear space.
+ * @returns {vec3} The color in RGB space.
+ */
+vec3 czm_inverseGamma(vec3 color) {
+ return pow(color, vec3(1.0 / czm_gamma));
+}
+`;var Uv=`/**
+ * Determines if a time interval is empty.
+ *
+ * @name czm_isEmpty
+ * @glslFunction
+ *
+ * @param {czm_raySegment} interval The interval to test.
+ *
+ * @returns {bool} true if the time interval is empty; otherwise, false.
+ *
+ * @example
+ * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true
+ * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false
+ * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.
+ */
+bool czm_isEmpty(czm_raySegment interval)
+{
+ return (interval.stop < 0.0);
+}
+`;var zv=`/**
+ * Determines if a time interval is empty.
+ *
+ * @name czm_isFull
+ * @glslFunction
+ *
+ * @param {czm_raySegment} interval The interval to test.
+ *
+ * @returns {bool} true if the time interval is empty; otherwise, false.
+ *
+ * @example
+ * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true
+ * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false
+ * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.
+ */
+bool czm_isFull(czm_raySegment interval)
+{
+ return (interval.start == 0.0 && interval.stop == czm_infinity);
+}
+`;var Gv=`/**
+ * Computes the fraction of a Web Wercator rectangle at which a given geodetic latitude is located.
+ *
+ * @name czm_latitudeToWebMercatorFraction
+ * @glslFunction
+ *
+ * @param {float} latitude The geodetic latitude, in radians.
+ * @param {float} southMercatorY The Web Mercator coordinate of the southern boundary of the rectangle.
+ * @param {float} oneOverMercatorHeight The total height of the rectangle in Web Mercator coordinates.
+ *
+ * @returns {float} The fraction of the rectangle at which the latitude occurs. If the latitude is the southern
+ * boundary of the rectangle, the return value will be zero. If it is the northern boundary, the return
+ * value will be 1.0. Latitudes in between are mapped according to the Web Mercator projection.
+ */
+float czm_latitudeToWebMercatorFraction(float latitude, float southMercatorY, float oneOverMercatorHeight)
+{
+ float sinLatitude = sin(latitude);
+ float mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude));
+
+ return (mercatorY - southMercatorY) * oneOverMercatorHeight;
+}
+`;var Hv=`/**
+ * Converts a linear RGB color to an sRGB color.
+ *
+ * @param {vec3|vec4} linearIn The color in linear color space.
+ * @returns {vec3|vec4} The color in sRGB color space. The vector type matches the input.
+ */
+vec3 czm_linearToSrgb(vec3 linearIn)
+{
+ return pow(linearIn, vec3(1.0/2.2));
+}
+
+vec4 czm_linearToSrgb(vec4 linearIn)
+{
+ vec3 srgbOut = pow(linearIn.rgb, vec3(1.0/2.2));
+ return vec4(srgbOut, linearIn.a);
+}
+`;var Wv=`/**
+ * Computes distance from an point in 2D to a line in 2D.
+ *
+ * @name czm_lineDistance
+ * @glslFunction
+ *
+ * param {vec2} point1 A point along the line.
+ * param {vec2} point2 A point along the line.
+ * param {vec2} point A point that may or may not be on the line.
+ * returns {float} The distance from the point to the line.
+ */
+float czm_lineDistance(vec2 point1, vec2 point2, vec2 point) {
+ return abs((point2.y - point1.y) * point.x - (point2.x - point1.x) * point.y + point2.x * point1.y - point2.y * point1.x) / distance(point2, point1);
+}
+`;var jv=`/**
+ * Computes the luminance of a color.
+ *
+ * @name czm_luminance
+ * @glslFunction
+ *
+ * @param {vec3} rgb The color.
+ *
+ * @returns {float} The luminance.
+ *
+ * @example
+ * float light = czm_luminance(vec3(0.0)); // 0.0
+ * float dark = czm_luminance(vec3(1.0)); // ~1.0
+ */
+float czm_luminance(vec3 rgb)
+{
+ // Algorithm from Chapter 10 of Graphics Shaders.
+ const vec3 W = vec3(0.2125, 0.7154, 0.0721);
+ return dot(rgb, W);
+}
+`;var qv=`/**
+ * Computes the size of a pixel in meters at a distance from the eye.
+ * near = 0 and far = 1.
+ *
+ * This transform is useful when there is a need to manipulate window coordinates
+ * in a vertex shader as done by {@link BillboardCollection}.
+ *
+ * This function should not be confused with {@link czm_viewportOrthographic},
+ * which is an orthographic projection matrix that transforms from window
+ * coordinates to clip coordinates.
+ *
+ * @name czm_modelToWindowCoordinates
+ * @glslFunction
+ *
+ * @param {vec4} position The position in model coordinates to transform.
+ *
+ * @returns {vec4} The transformed position in window coordinates.
+ *
+ * @see czm_eyeToWindowCoordinates
+ * @see czm_modelViewProjection
+ * @see czm_viewportTransformation
+ * @see czm_viewportOrthographic
+ * @see BillboardCollection
+ *
+ * @example
+ * vec4 positionWC = czm_modelToWindowCoordinates(positionMC);
+ */
+vec4 czm_modelToWindowCoordinates(vec4 position)
+{
+ vec4 q = czm_modelViewProjection * position; // clip coordinates
+ q.xyz /= q.w; // normalized device coordinates
+ q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
+ return q;
+}
+`;var Xv=`/**
+ * DOC_TBA
+ *
+ * @name czm_multiplyWithColorBalance
+ * @glslFunction
+ */
+vec3 czm_multiplyWithColorBalance(vec3 left, vec3 right)
+{
+ // Algorithm from Chapter 10 of Graphics Shaders.
+ const vec3 W = vec3(0.2125, 0.7154, 0.0721);
+
+ vec3 target = left * right;
+ float leftLuminance = dot(left, W);
+ float rightLuminance = dot(right, W);
+ float targetLuminance = dot(target, W);
+
+ return ((leftLuminance + rightLuminance) / (2.0 * targetLuminance)) * target;
+}
+`;var Kv=`/**
+ * Computes a value that scales with distance. The scaling is clamped at the near and
+ * far distances, and does not extrapolate. This function works with the
+ * {@link NearFarScalar} JavaScript class.
+ *
+ * @name czm_nearFarScalar
+ * @glslFunction
+ *
+ * @param {vec4} nearFarScalar A vector with 4 components: Near distance (x), Near value (y), Far distance (z), Far value (w).
+ * @param {float} cameraDistSq The square of the current distance from the camera.
+ *
+ * @returns {float} The value at this distance.
+ */
+float czm_nearFarScalar(vec4 nearFarScalar, float cameraDistSq)
+{
+ float valueAtMin = nearFarScalar.y;
+ float valueAtMax = nearFarScalar.w;
+ float nearDistanceSq = nearFarScalar.x * nearFarScalar.x;
+ float farDistanceSq = nearFarScalar.z * nearFarScalar.z;
+
+ float t = (cameraDistSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);
+
+ t = pow(clamp(t, 0.0, 1.0), 0.2);
+
+ return mix(valueAtMin, valueAtMax, t);
+}
+`;var Jv=` /**
+ * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector.
+ * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
+ * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
+ *
+ * @name czm_octDecode
+ * @param {vec2} encoded The oct-encoded, unit-length vector
+ * @param {float} range The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
+ * @returns {vec3} The decoded and normalized vector
+ */
+ vec3 czm_octDecode(vec2 encoded, float range)
+ {
+ if (encoded.x == 0.0 && encoded.y == 0.0) {
+ return vec3(0.0, 0.0, 0.0);
+ }
+
+ encoded = encoded / range * 2.0 - 1.0;
+ vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));
+ if (v.z < 0.0)
+ {
+ v.xy = (1.0 - abs(v.yx)) * czm_signNotZero(v.xy);
+ }
+
+ return normalize(v);
+ }
+
+/**
+ * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector.
+ * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
+ * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
+ *
+ * @name czm_octDecode
+ * @param {vec2} encoded The oct-encoded, unit-length vector
+ * @returns {vec3} The decoded and normalized vector
+ */
+ vec3 czm_octDecode(vec2 encoded)
+ {
+ return czm_octDecode(encoded, 255.0);
+ }
+
+ /**
+ * Decodes a unit-length vector in 'oct' encoding packed into a floating-point number to a normalized 3-component Cartesian vector.
+ * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
+ * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
+ *
+ * @name czm_octDecode
+ * @param {float} encoded The oct-encoded, unit-length vector
+ * @returns {vec3} The decoded and normalized vector
+ */
+ vec3 czm_octDecode(float encoded)
+ {
+ float temp = encoded / 256.0;
+ float x = floor(temp);
+ float y = (temp - x) * 256.0;
+ return czm_octDecode(vec2(x, y));
+ }
+
+/**
+ * Decodes three unit-length vectors in 'oct' encoding packed into two floating-point numbers to normalized 3-component Cartesian vectors.
+ * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
+ * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
+ *
+ * @name czm_octDecode
+ * @param {vec2} encoded The packed oct-encoded, unit-length vectors.
+ * @param {vec3} vector1 One decoded and normalized vector.
+ * @param {vec3} vector2 One decoded and normalized vector.
+ * @param {vec3} vector3 One decoded and normalized vector.
+ */
+ void czm_octDecode(vec2 encoded, out vec3 vector1, out vec3 vector2, out vec3 vector3)
+ {
+ float temp = encoded.x / 65536.0;
+ float x = floor(temp);
+ float encodedFloat1 = (temp - x) * 65536.0;
+
+ temp = encoded.y / 65536.0;
+ float y = floor(temp);
+ float encodedFloat2 = (temp - y) * 65536.0;
+
+ vector1 = czm_octDecode(encodedFloat1);
+ vector2 = czm_octDecode(encodedFloat2);
+ vector3 = czm_octDecode(vec2(x, y));
+ }
+
+`;var Zv=`/**
+ * Packs a depth value into a vec3 that can be represented by unsigned bytes.
+ *
+ * @name czm_packDepth
+ * @glslFunction
+ *
+ * @param {float} depth The floating-point depth.
+ * @returns {vec3} The packed depth.
+ */
+vec4 czm_packDepth(float depth)
+{
+ // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA
+ // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
+ vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;
+ enc = fract(enc);
+ enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
+ return enc;
+}
+`;var Qv=`vec3 lambertianDiffuse(vec3 diffuseColor)
+{
+ return diffuseColor / czm_pi;
+}
+
+vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)
+{
+ return f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);
+}
+
+float smithVisibilityG1(float NdotV, float roughness)
+{
+ // this is the k value for direct lighting.
+ // for image based lighting it will be roughness^2 / 2
+ float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;
+ return NdotV / (NdotV * (1.0 - k) + k);
+}
+
+float smithVisibilityGGX(float roughness, float NdotL, float NdotV)
+{
+ return (
+ smithVisibilityG1(NdotL, roughness) *
+ smithVisibilityG1(NdotV, roughness)
+ );
+}
+
+float GGX(float roughness, float NdotH)
+{
+ float roughnessSquared = roughness * roughness;
+ float f = (NdotH * roughnessSquared - NdotH) * NdotH + 1.0;
+ return roughnessSquared / (czm_pi * f * f);
+}
+
+/**
+ * Compute the diffuse and specular contributions using physically based
+ * rendering. This function only handles direct lighting.
+ * time can be positive, negative, or zero.
+ *
+ * @name czm_pointAlongRay
+ * @glslFunction
+ *
+ * @param {czm_ray} ray The ray to compute the point along.
+ * @param {float} time The time along the ray.
+ *
+ * @returns {vec3} The point along the ray at the given time.
+ *
+ * @example
+ * czm_ray ray = czm_ray(vec3(0.0), vec3(1.0, 0.0, 0.0)); // origin, direction
+ * vec3 v = czm_pointAlongRay(ray, 2.0); // (2.0, 0.0, 0.0)
+ */
+vec3 czm_pointAlongRay(czm_ray ray, float time)
+{
+ return ray.origin + (time * ray.direction);
+}
+`;var oD=`/**
+ * DOC_TBA
+ *
+ * @name czm_rayEllipsoidIntersectionInterval
+ * @glslFunction
+ */
+czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii)
+{
+ // ray and ellipsoid center in eye coordinates. radii in model coordinates.
+ vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz;
+ vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz;
+
+ q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz;
+
+ float q2 = dot(q, q);
+ float qw = dot(q, w);
+
+ if (q2 > 1.0) // Outside ellipsoid.
+ {
+ if (qw >= 0.0) // Looking outward or tangent (0 intersections).
+ {
+ return czm_emptyRaySegment;
+ }
+ else // qw < 0.0.
+ {
+ float qw2 = qw * qw;
+ float difference = q2 - 1.0; // Positively valued.
+ float w2 = dot(w, w);
+ float product = w2 * difference;
+
+ if (qw2 < product) // Imaginary roots (0 intersections).
+ {
+ return czm_emptyRaySegment;
+ }
+ else if (qw2 > product) // Distinct roots (2 intersections).
+ {
+ float discriminant = qw * qw - product;
+ float temp = -qw + sqrt(discriminant); // Avoid cancellation.
+ float root0 = temp / w2;
+ float root1 = difference / temp;
+ if (root0 < root1)
+ {
+ czm_raySegment i = czm_raySegment(root0, root1);
+ return i;
+ }
+ else
+ {
+ czm_raySegment i = czm_raySegment(root1, root0);
+ return i;
+ }
+ }
+ else // qw2 == product. Repeated roots (2 intersections).
+ {
+ float root = sqrt(difference / w2);
+ czm_raySegment i = czm_raySegment(root, root);
+ return i;
+ }
+ }
+ }
+ else if (q2 < 1.0) // Inside ellipsoid (2 intersections).
+ {
+ float difference = q2 - 1.0; // Negatively valued.
+ float w2 = dot(w, w);
+ float product = w2 * difference; // Negatively valued.
+ float discriminant = qw * qw - product;
+ float temp = -qw + sqrt(discriminant); // Positively valued.
+ czm_raySegment i = czm_raySegment(0.0, temp / w2);
+ return i;
+ }
+ else // q2 == 1.0. On ellipsoid.
+ {
+ if (qw < 0.0) // Looking inward.
+ {
+ float w2 = dot(w, w);
+ czm_raySegment i = czm_raySegment(0.0, -qw / w2);
+ return i;
+ }
+ else // qw >= 0.0. Looking outward or tangent.
+ {
+ return czm_emptyRaySegment;
+ }
+ }
+}
+`;var rD=`/**
+ * Compute the intersection interval of a ray with a sphere.
+ *
+ * @name czm_raySphereIntersectionInterval
+ * @glslFunction
+ *
+ * @param {czm_ray} ray The ray.
+ * @param {vec3} center The center of the sphere.
+ * @param {float} radius The radius of the sphere.
+ * @return {czm_raySegment} The intersection interval of the ray with the sphere.
+ */
+czm_raySegment czm_raySphereIntersectionInterval(czm_ray ray, vec3 center, float radius)
+{
+ vec3 o = ray.origin;
+ vec3 d = ray.direction;
+
+ vec3 oc = o - center;
+
+ float a = dot(d, d);
+ float b = 2.0 * dot(d, oc);
+ float c = dot(oc, oc) - (radius * radius);
+
+ float det = (b * b) - (4.0 * a * c);
+
+ if (det < 0.0) {
+ return czm_emptyRaySegment;
+ }
+
+ float sqrtDet = sqrt(det);
+
+ float t0 = (-b - sqrtDet) / (2.0 * a);
+ float t1 = (-b + sqrtDet) / (2.0 * a);
+
+ czm_raySegment result = czm_raySegment(t0, t1);
+ return result;
+}
+`;var sD=`float czm_readDepth(sampler2D depthTexture, vec2 texCoords)
+{
+ return czm_reverseLogDepth(texture2D(depthTexture, texCoords).r);
+}
+`;var aD=`/**
+ * Reads a value previously transformed with {@link czm_writeNonPerspective}
+ * by dividing it by \`w\`, the value used in the perspective divide.
+ * This function is intended to be called in a fragment shader to access a
+ * \`varying\` that should not be subject to perspective interpolation.
+ * For example, screen-space texture coordinates. The value should have been
+ * previously written in the vertex shader with a call to
+ * {@link czm_writeNonPerspective}.
+ *
+ * @name czm_readNonPerspective
+ * @glslFunction
+ *
+ * @param {float|vec2|vec3|vec4} value The non-perspective value to be read.
+ * @param {float} oneOverW One over the perspective divide value, \`w\`. Usually this is simply \`gl_FragCoord.w\`.
+ * @returns {float|vec2|vec3|vec4} The usable value.
+ */
+float czm_readNonPerspective(float value, float oneOverW) {
+ return value * oneOverW;
+}
+
+vec2 czm_readNonPerspective(vec2 value, float oneOverW) {
+ return value * oneOverW;
+}
+
+vec3 czm_readNonPerspective(vec3 value, float oneOverW) {
+ return value * oneOverW;
+}
+
+vec4 czm_readNonPerspective(vec4 value, float oneOverW) {
+ return value * oneOverW;
+}
+`;var cD=`float czm_reverseLogDepth(float logZ)
+{
+#ifdef LOG_DEPTH
+ float near = czm_currentFrustum.x;
+ float far = czm_currentFrustum.y;
+ float log2Depth = logZ * czm_log2FarDepthFromNearPlusOne;
+ float depthFromNear = pow(2.0, log2Depth) - 1.0;
+ return far * (1.0 - near / (depthFromNear + near)) / (far - near);
+#endif
+ return logZ;
+}
+`;var lD=`/**
+ * Converts an RGB color to HSB (hue, saturation, brightness)
+ * HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}
+ *
+ * @name czm_RGBToHSB
+ * @glslFunction
+ *
+ * @param {vec3} rgb The color in RGB.
+ *
+ * @returns {vec3} The color in HSB.
+ *
+ * @example
+ * vec3 hsb = czm_RGBToHSB(rgb);
+ * hsb.z *= 0.1;
+ * rgb = czm_HSBToRGB(hsb);
+ */
+
+const vec4 K_RGB2HSB = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+
+vec3 czm_RGBToHSB(vec3 rgb)
+{
+ vec4 p = mix(vec4(rgb.bg, K_RGB2HSB.wz), vec4(rgb.gb, K_RGB2HSB.xy), step(rgb.b, rgb.g));
+ vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));
+
+ float d = q.x - min(q.w, q.y);
+ return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + czm_epsilon7)), d / (q.x + czm_epsilon7), q.x);
+}
+`;var uD=`/**
+ * Converts an RGB color to HSL (hue, saturation, lightness)
+ * HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html}
+ *
+ * @name czm_RGBToHSL
+ * @glslFunction
+ *
+ * @param {vec3} rgb The color in RGB.
+ *
+ * @returns {vec3} The color in HSL.
+ *
+ * @example
+ * vec3 hsl = czm_RGBToHSL(rgb);
+ * hsl.z *= 0.1;
+ * rgb = czm_HSLToRGB(hsl);
+ */
+
+vec3 RGBtoHCV(vec3 rgb)
+{
+ // Based on work by Sam Hocevar and Emil Persson
+ vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 2.0 / 3.0) : vec4(rgb.gb, 0.0, -1.0 / 3.0);
+ vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);
+ float c = q.x - min(q.w, q.y);
+ float h = abs((q.w - q.y) / (6.0 * c + czm_epsilon7) + q.z);
+ return vec3(h, c, q.x);
+}
+
+vec3 czm_RGBToHSL(vec3 rgb)
+{
+ vec3 hcv = RGBtoHCV(rgb);
+ float l = hcv.z - hcv.y * 0.5;
+ float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + czm_epsilon7);
+ return vec3(hcv.x, s, l);
+}
+`;var fD=`/**
+ * Converts an RGB color to CIE Yxy.
+ * sign except that returns 1.0 instead of 0.0 when the input value is 0.0.
+ *
+ * @name czm_signNotZero
+ * @glslFunction
+ *
+ * @param {} value The value for which to determine the sign.
+ * @returns {} 1.0 if the value is positive or zero, -1.0 if the value is negative.
+ */
+float czm_signNotZero(float value)
+{
+ return value >= 0.0 ? 1.0 : -1.0;
+}
+
+vec2 czm_signNotZero(vec2 value)
+{
+ return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));
+}
+
+vec3 czm_signNotZero(vec3 value)
+{
+ return vec3(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z));
+}
+
+vec4 czm_signNotZero(vec4 value)
+{
+ return vec4(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z), czm_signNotZero(value.w));
+}
+`;var yD=`/**
+ * Computes a color from the third order spherical harmonic coefficients and a normalized direction vector.
+ * vec3) that was encoded with {@link EncodedCartesian3},
+ * and then provided to the shader as separate high and low bits to
+ * be relative to the eye. As shown in the example, the position can then be transformed in eye
+ * or clip coordinates using {@link czm_modelViewRelativeToEye} or {@link czm_modelViewProjectionRelativeToEye},
+ * respectively.
+ * matrix can be
+ * a mat2, mat3, or mat4.
+ *
+ * @name czm_transpose
+ * @glslFunction
+ *
+ * @param {} matrix The matrix to transpose.
+ *
+ * @returns {} The transposed matrix.
+ *
+ * @example
+ * // GLSL declarations
+ * mat2 czm_transpose(mat2 matrix);
+ * mat3 czm_transpose(mat3 matrix);
+ * mat4 czm_transpose(mat4 matrix);
+ *
+ * // Transpose a 3x3 rotation matrix to find its inverse.
+ * mat3 eastNorthUpToEye = czm_eastNorthUpToEyeCoordinates(
+ * positionMC, normalEC);
+ * mat3 eyeToEastNorthUp = czm_transpose(eastNorthUpToEye);
+ */
+mat2 czm_transpose(mat2 matrix)
+{
+ return mat2(
+ matrix[0][0], matrix[1][0],
+ matrix[0][1], matrix[1][1]);
+}
+
+mat3 czm_transpose(mat3 matrix)
+{
+ return mat3(
+ matrix[0][0], matrix[1][0], matrix[2][0],
+ matrix[0][1], matrix[1][1], matrix[2][1],
+ matrix[0][2], matrix[1][2], matrix[2][2]);
+}
+
+mat4 czm_transpose(mat4 matrix)
+{
+ return mat4(
+ matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
+ matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
+ matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
+ matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);
+}
+`;var SD=`/**
+ * Unpacks a vec4 depth value to a float in [0, 1) range.
+ *
+ * @name czm_unpackDepth
+ * @glslFunction
+ *
+ * @param {vec4} packedDepth The packed depth.
+ *
+ * @returns {float} The floating-point depth in [0, 1) range.
+ */
+ float czm_unpackDepth(vec4 packedDepth)
+ {
+ // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA
+ // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
+ return dot(packedDepth, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));
+ }
+`;var wD=`/**
+ * Unpack an IEEE 754 single-precision float that is packed as a little-endian unsigned normalized vec4.
+ *
+ * @name czm_unpackFloat
+ * @glslFunction
+ *
+ * @param {vec4} packedFloat The packed float.
+ *
+ * @returns {float} The floating-point depth in arbitrary range.
+ */
+float czm_unpackFloat(vec4 packedFloat)
+{
+ // Convert to [0.0, 255.0] and round to integer
+ packedFloat = floor(packedFloat * 255.0 + 0.5);
+ float sign = 1.0 - step(128.0, packedFloat[3]) * 2.0;
+ float exponent = 2.0 * mod(packedFloat[3], 128.0) + step(128.0, packedFloat[2]) - 127.0;
+ if (exponent == -127.0)
+ {
+ return 0.0;
+ }
+ float mantissa = mod(packedFloat[2], 128.0) * 65536.0 + packedFloat[1] * 256.0 + packedFloat[0] + float(0x800000);
+ float result = sign * exp2(exponent - 23.0) * mantissa;
+ return result;
+}
+`;var vD=`/**
+ * Unpack unsigned integers of 1-4 bytes. in WebGL 1, there is no uint type,
+ * so the return value is an int.
+ * czm_viewportTransformation. The transformation from
+ * normalized device coordinates to clip coordinates is done using fragmentCoordinate.w,
+ * which is expected to be the scalar used in the perspective divide. The transformation
+ * from clip to eye coordinates is done using {@link czm_inverseProjection}.
+ *
+ * @name czm_windowToEyeCoordinates
+ * @glslFunction
+ *
+ * @param {vec4} fragmentCoordinate The position in window coordinates to transform.
+ *
+ * @returns {vec4} The transformed position in eye coordinates.
+ *
+ * @see czm_modelToWindowCoordinates
+ * @see czm_eyeToWindowCoordinates
+ * @see czm_inverseProjection
+ * @see czm_viewport
+ * @see czm_viewportTransformation
+ *
+ * @example
+ * vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord);
+ */
+vec4 czm_windowToEyeCoordinates(vec4 fragmentCoordinate)
+{
+ // Reconstruct NDC coordinates
+ float x = 2.0 * (fragmentCoordinate.x - czm_viewport.x) / czm_viewport.z - 1.0;
+ float y = 2.0 * (fragmentCoordinate.y - czm_viewport.y) / czm_viewport.w - 1.0;
+ float z = (fragmentCoordinate.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];
+ vec4 q = vec4(x, y, z, 1.0);
+
+ // Reverse the perspective division to obtain clip coordinates.
+ q /= fragmentCoordinate.w;
+
+ // Reverse the projection transformation to obtain eye coordinates.
+ if (!(czm_inverseProjection == mat4(0.0))) // IE and Edge sometimes do something weird with != between mat4s
+ {
+ q = czm_inverseProjection * q;
+ }
+ else
+ {
+ float top = czm_frustumPlanes.x;
+ float bottom = czm_frustumPlanes.y;
+ float left = czm_frustumPlanes.z;
+ float right = czm_frustumPlanes.w;
+
+ float near = czm_currentFrustum.x;
+ float far = czm_currentFrustum.y;
+
+ q.x = (q.x * (right - left) + left + right) * 0.5;
+ q.y = (q.y * (top - bottom) + bottom + top) * 0.5;
+ q.z = (q.z * (near - far) - near - far) * 0.5;
+ q.w = 1.0;
+ }
+
+ return q;
+}
+
+/**
+ * Transforms a position given as window x/y and a depth or a log depth from window to eye coordinates.
+ * This function produces more accurate results for window positions with log depth than
+ * conventionally unpacking the log depth using czm_reverseLogDepth and using the standard version
+ * of czm_windowToEyeCoordinates.
+ *
+ * @name czm_windowToEyeCoordinates
+ * @glslFunction
+ *
+ * @param {vec2} fragmentCoordinateXY The XY position in window coordinates to transform.
+ * @param {float} depthOrLogDepth A depth or log depth for the fragment.
+ *
+ * @see czm_modelToWindowCoordinates
+ * @see czm_eyeToWindowCoordinates
+ * @see czm_inverseProjection
+ * @see czm_viewport
+ * @see czm_viewportTransformation
+ *
+ * @returns {vec4} The transformed position in eye coordinates.
+ */
+vec4 czm_windowToEyeCoordinates(vec2 fragmentCoordinateXY, float depthOrLogDepth)
+{
+ // See reverseLogDepth.glsl. This is separate to re-use the pow.
+#ifdef LOG_DEPTH
+ float near = czm_currentFrustum.x;
+ float far = czm_currentFrustum.y;
+ float log2Depth = depthOrLogDepth * czm_log2FarDepthFromNearPlusOne;
+ float depthFromNear = pow(2.0, log2Depth) - 1.0;
+ float depthFromCamera = depthFromNear + near;
+ vec4 windowCoord = vec4(fragmentCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0);
+ vec4 eyeCoordinate = czm_windowToEyeCoordinates(windowCoord);
+ eyeCoordinate.w = 1.0 / depthFromCamera; // Better precision
+ return eyeCoordinate;
+#else
+ vec4 windowCoord = vec4(fragmentCoordinateXY, depthOrLogDepth, 1.0);
+ vec4 eyeCoordinate = czm_windowToEyeCoordinates(windowCoord);
+#endif
+ return eyeCoordinate;
+}
+`;var OD=`// emulated noperspective
+#if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)
+varying float v_WindowZ;
+#endif
+
+/**
+ * Emulates GL_DEPTH_CLAMP. Clamps a fragment to the near and far plane
+ * by writing the fragment's depth. See czm_depthClamp for more details.
+ * 0){let l=K.getSizeInBytes(e[o[0]].componentDatatype),f=a%l;f!==0&&(a+=l-f);let d=r*a,p=new ArrayBuffer(d),g={};for(t=0;t=I.SIXTY_FOUR_KILOBYTES&&t.elementIndexUint?p=st.createIndexBuffer({context:t,typedArray:new Uint32Array(g),usage:i,indexDatatype:Fe.UNSIGNED_INT}):p=st.createIndexBuffer({context:t,typedArray:new Uint16Array(g),usage:i,indexDatatype:Fe.UNSIGNED_SHORT})),new Sm({context:t,attributes:f,indexBuffer:p})};Object.defineProperties(Sm.prototype,{numberOfAttributes:{get:function(){return this._attributes.length}},numberOfVertices:{get:function(){return this._numberOfVertices}},indexBuffer:{get:function(){return this._indexBuffer}}});Sm.prototype.getAttribute=function(e){return this._attributes[e]};function sSe(e){let t=e._context,n=e._hasInstancedAttributes;if(!n&&!t._previousDrawInstanced)return;t._previousDrawInstanced=n;let i=t._vertexAttribDivisors,o=e._attributes,r=Nt.maximumVertexAttributes,s;if(n){let a=o.length;for(s=0;s0&&(t.glVertexAttribDivisor(s,0),i[s]=0)}function aSe(e,t){let n=e._attributes,i=n.length;for(let o=0;o>1^-(e&1)}mo.zigZagDeltaDecode=function(e,t,n){let i=e.length,o=0,r=0,s=0;for(let a=0;a>11,f=c>>5&o,d=c&i,p=3*a;t[p]=l*r,t[p+1]=f*s,t[p+2]=d*r}return t};var Un=mo;var BZ=new h,RZ=new h,MZ=new h;function CSe(e,t,n,i,o){u(o)||(o=new h);let r,s,a,c,l,f,d,p;if(u(t.z)){if(h.equalsEpsilon(e,t,I.EPSILON14))return h.clone(h.UNIT_X,o);if(h.equalsEpsilon(e,n,I.EPSILON14))return h.clone(h.UNIT_Y,o);if(h.equalsEpsilon(e,i,I.EPSILON14))return h.clone(h.UNIT_Z,o);r=h.subtract(n,t,BZ),s=h.subtract(i,t,RZ),a=h.subtract(e,t,MZ),c=h.dot(r,r),l=h.dot(r,s),f=h.dot(r,a),d=h.dot(s,s),p=h.dot(s,a)}else{if(H.equalsEpsilon(e,t,I.EPSILON14))return h.clone(h.UNIT_X,o);if(H.equalsEpsilon(e,n,I.EPSILON14))return h.clone(h.UNIT_Y,o);if(H.equalsEpsilon(e,i,I.EPSILON14))return h.clone(h.UNIT_Z,o);r=H.subtract(n,t,BZ),s=H.subtract(i,t,RZ),a=H.subtract(e,t,MZ),c=H.dot(r,r),l=H.dot(r,s),f=H.dot(r,a),d=H.dot(s,s),p=H.dot(s,a)}o.y=d*f-l*p,o.z=c*p-l*f;let g=c*d-l*l;if(g!==0)return o.y/=g,o.z/=g,o.x=1-o.y-o.z,o}var i0=CSe;var hH={};hH.calculateACMR=function(e){e=y(e,y.EMPTY_OBJECT);let t=e.indices,n=e.maximumIndex,i=y(e.cacheSize,24),o=t.length;if(!u(n)){n=0;let a=0,c=t[a];for(;a0||re.intersectPlane(A,nn.ORIGIN_ZX_PLANE)!==Kt.INTERSECTING?c.push(A):(l.push(A),f.push(A))}let d=c[0],p=f[0],g=l[0];for(i=1;i{i._completeLoad=()=>{if(this._ready)return;this._ready=!0,this.releaseGeometryInstances&&(this.geometryInstances=void 0);let a=this._error;u(a)?s(a):r(this)}}),this._primitive=void 0,this._maxHeight=void 0,this._minHeight=void 0,this._maxTerrainHeight=ni._defaultMaxTerrainHeight,this._minTerrainHeight=ni._defaultMinTerrainHeight,this._boundingSpheresKeys=[],this._boundingSpheres=[],this._useFragmentCulling=!1,this._zIndex=void 0;let o=this;this._classificationPrimitiveOptions={geometryInstances:void 0,appearance:void 0,vertexCacheOptimize:y(e.vertexCacheOptimize,!1),interleave:y(e.interleave,!1),releaseGeometryInstances:y(e.releaseGeometryInstances,!0),allowPicking:y(e.allowPicking,!0),asynchronous:y(e.asynchronous,!0),compressVertices:y(e.compressVertices,!0),_createBoundingVolumeFunction:void 0,_updateAndQueueCommandsFunction:void 0,_pickPrimitive:o,_extruded:!0,_uniformMap:cve}}Object.defineProperties($c.prototype,{vertexCacheOptimize:{get:function(){return this._classificationPrimitiveOptions.vertexCacheOptimize}},interleave:{get:function(){return this._classificationPrimitiveOptions.interleave}},releaseGeometryInstances:{get:function(){return this._classificationPrimitiveOptions.releaseGeometryInstances}},allowPicking:{get:function(){return this._classificationPrimitiveOptions.allowPicking}},asynchronous:{get:function(){return this._classificationPrimitiveOptions.asynchronous}},compressVertices:{get:function(){return this._classificationPrimitiveOptions.compressVertices}},ready:{get:function(){return this._ready}},readyPromise:{get:function(){return this._readyPromise}}});$c.isSupported=IC.isSupported;function vQ(e){return function(t,n){let i=n.maximumRadius,o=i/Math.cos(t*.5)-i;return e._maxHeight+o}}function DQ(e){return function(t,n){return e._minHeight}}var lve=new h,uve=new h,fve=new h,dve=new fe,hve=new ce;function a3(e,t){let n=e.mapProjection.ellipsoid;if(!u(t.attributes)||!u(t.attributes.position3DHigh))return u(t.rectangle)?t.rectangle:void 0;let i=t.attributes.position3DHigh.values,o=t.attributes.position3DLow.values,r=i.length,s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let d=0;d0||this._imageBasedLightingFactor.y>0}},shouldRegenerateShaders:{get:function(){return this._shouldRegenerateShaders}},useDefaultSphericalHarmonics:{get:function(){return this._useDefaultSphericalHarmonics}},useSphericalHarmonicCoefficients:{get:function(){return u(this._sphericalHarmonicCoefficients)||this._useDefaultSphericalHarmonics}},specularEnvironmentMapAtlas:{get:function(){return this._specularEnvironmentMapAtlas}},useDefaultSpecularMaps:{get:function(){return this._useDefaultSpecularMaps}},useSpecularEnvironmentMaps:{get:function(){return u(this._specularEnvironmentMapAtlas)&&this._specularEnvironmentMapAtlas.ready||this._useDefaultSpecularMaps}}});function cPe(e,t){if(!!qf.isSupported(t)){if(e._specularEnvironmentMapAtlas=e._specularEnvironmentMapAtlas&&e._specularEnvironmentMapAtlas.destroy(),u(e._specularEnvironmentMaps)){let n=new qf(e._specularEnvironmentMaps);e._specularEnvironmentMapAtlas=n,n.readyPromise.then(function(){e._specularEnvironmentMapLoaded=!0}).catch(function(i){console.error(`Error loading specularEnvironmentMaps: ${i}`)})}e._shouldRegenerateShaders=!0}}TP.prototype.update=function(e){if(e.frameNumber===this._previousFrameNumber)return;this._previousFrameNumber=e.frameNumber;let t=e.context;e.brdfLutGenerator.update(e),this._shouldRegenerateShaders=!1;let n=this._imageBasedLightingFactor,i=this._previousImageBasedLightingFactor;H.equals(n,i)||(this._shouldRegenerateShaders=n.x>0&&i.x===0||n.x===0&&i.x>0,this._shouldRegenerateShaders=this._shouldRegenerateShaders||n.y>0&&i.y===0||n.y===0&&i.y>0,this._previousImageBasedLightingFactor=H.clone(this._imageBasedLightingFactor,this._previousImageBasedLightingFactor)),this._luminanceAtZenith!==this._previousLuminanceAtZenith&&(this._shouldRegenerateShaders=this._shouldRegenerateShaders||u(this._luminanceAtZenith)!==u(this._previousLuminanceAtZenith),this._previousLuminanceAtZenith=this._luminanceAtZenith),this._previousSphericalHarmonicCoefficients!==this._sphericalHarmonicCoefficients&&(this._shouldRegenerateShaders=this._shouldRegenerateShaders||u(this._previousSphericalHarmonicCoefficients)!==u(this._sphericalHarmonicCoefficients),this._previousSphericalHarmonicCoefficients=this._sphericalHarmonicCoefficients),this._shouldRegenerateShaders=this._shouldRegenerateShaders||this._previousSpecularEnvironmentMapLoaded!==this._specularEnvironmentMapLoaded,this._previousSpecularEnvironmentMapLoaded=this._specularEnvironmentMapLoaded,this._specularEnvironmentMapAtlasDirty&&(cPe(this,t),this._specularEnvironmentMapAtlasDirty=!1),u(this._specularEnvironmentMapAtlas)&&this._specularEnvironmentMapAtlas.update(e);let o=!u(this._specularEnvironmentMapAtlas)&&u(e.specularEnvironmentMaps)&&!this._useDefaultSpecularMaps,r=!u(e.specularEnvironmentMaps)&&this._useDefaultSpecularMaps,s=!u(this._sphericalHarmonicCoefficients)&&u(e.sphericalHarmonicCoefficients)&&!this._useDefaultSphericalHarmonics,a=!u(e.sphericalHarmonicCoefficients)&&this._useDefaultSphericalHarmonics;this._shouldRegenerateShaders=this._shouldRegenerateShaders||o||r||s||a,this._useDefaultSpecularMaps=!u(this._specularEnvironmentMapAtlas)&&u(e.specularEnvironmentMaps),this._useDefaultSphericalHarmonics=!u(this._sphericalHarmonicCoefficients)&&u(e.sphericalHarmonicCoefficients)};TP.prototype.isDestroyed=function(){return!1};TP.prototype.destroy=function(){return this._specularEnvironmentMapAtlas=this._specularEnvironmentMapAtlas&&this._specularEnvironmentMapAtlas.destroy(),le(this)};var v0=TP;function hh(e){e=y(e,0),this._array=new Array(e),this._length=e}Object.defineProperties(hh.prototype,{length:{get:function(){return this._length},set:function(e){let t=this._array,n=this._length;if(e