define(["exports","./Matrix2-ccd5b911","./ComponentDatatype-93750d1a","./RuntimeError-346a3079","./when-4bbc8319"],function(e,r,C,t,u){"use strict";var a={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4",getMathType:function(e){switch(e){case a.SCALAR:return Number;case a.VEC2:return r.Cartesian2;case a.VEC3:return r.Cartesian3;case a.VEC4:return r.Cartesian4;case a.MAT2:return r.Matrix2;case a.MAT3:return r.Matrix3;case a.MAT4:return r.Matrix4}},getNumberOfComponents:function(e){switch(e){case a.SCALAR:return 1;case a.VEC2:return 2;case a.VEC3:return 3;case a.VEC4:case a.MAT2:return 4;case a.MAT3:return 9;case a.MAT4:return 16}},getGlslType:function(e){switch(e){case a.SCALAR:return"float";case a.VEC2:return"vec2";case a.VEC3:return"vec3";case a.VEC4:return"vec4";case a.MAT2:return"mat2";case a.MAT3:return"mat3";case a.MAT4:return"mat4"}}},M=Object.freeze(a),s={octEncodeInRange:function(e,t,a){var n;return a.x=e.x/(Math.abs(e.x)+Math.abs(e.y)+Math.abs(e.z)),a.y=e.y/(Math.abs(e.x)+Math.abs(e.y)+Math.abs(e.z)),e.z<0&&(n=a.x,e=a.y,a.x=(1-Math.abs(e))*C.CesiumMath.signNotZero(n),a.y=(1-Math.abs(n))*C.CesiumMath.signNotZero(e)),a.x=C.CesiumMath.toSNorm(a.x,t),a.y=C.CesiumMath.toSNorm(a.y,t),a},octEncode:function(e,t){return s.octEncodeInRange(e,255,t)}},n=new r.Cartesian2,o=new Uint8Array(1);function c(e){return o[0]=e,o[0]}s.octEncodeToCartesian4=function(e,t){return s.octEncodeInRange(e,65535,n),t.x=c(n.x*(1/256)),t.y=c(n.x),t.z=c(n.y*(1/256)),t.w=c(n.y),t},s.octDecodeInRange=function(e,t,a,n){return n.x=C.CesiumMath.fromSNorm(e,a),n.y=C.CesiumMath.fromSNorm(t,a),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0&&(a=n.x,n.x=(1-Math.abs(n.y))*C.CesiumMath.signNotZero(a),n.y=(1-Math.abs(a))*C.CesiumMath.signNotZero(n.y)),r.Cartesian3.normalize(n,n)},s.octDecode=function(e,t,a){return s.octDecodeInRange(e,t,255,a)},s.octDecodeFromCartesian4=function(e,t){var a=e.x,n=e.y,r=e.z,e=e.w;return s.octDecodeInRange(256*a+n,256*r+e,65535,t)},s.octPackFloat=function(e){return 256*e.x+e.y};var i=new r.Cartesian2;function f(e){return e>>1^-(1&e)}s.octEncodeFloat=function(e){return s.octEncode(e,i),s.octPackFloat(i)},s.octDecodeFloat=function(e,t){var a=e/256,e=Math.floor(a);return s.octDecode(e,256*(a-e),t)},s.octPack=function(e,t,a,n){e=s.octEncodeFloat(e),t=s.octEncodeFloat(t),a=s.octEncode(a,i);return n.x=65536*a.x+e,n.y=65536*a.y+t,n},s.octUnpack=function(e,t,a,n){var r=e.x/65536,o=Math.floor(r),c=65536*(r-o),r=e.y/65536,e=Math.floor(r),r=65536*(r-e);s.octDecodeFloat(c,t),s.octDecodeFloat(r,a),s.octDecode(o,e,n)},s.compressTextureCoordinates=function(e){return 4096*(4095*e.x|0)+(4095*e.y|0)},s.decompressTextureCoordinates=function(e,t){var a=Math.floor(e/4096);return t.x=a/4095,t.y=(e-4096*a)/4095,t},s.zigZagDeltaDecode=function(e,t,a){for(var n=e.length,r=0,o=0,c=0,s=0;s<n;++s)r+=f(e[s]),o+=f(t[s]),e[s]=r,t[s]=o,u.defined(a)&&(c+=f(a[s]),a[s]=c)},s.dequantize=function(e,t,a,n){var r,o=M.getNumberOfComponents(a);switch(t){case C.ComponentDatatype.BYTE:r=127;break;case C.ComponentDatatype.UNSIGNED_BYTE:r=255;break;case C.ComponentDatatype.SHORT:r=32767;break;case C.ComponentDatatype.UNSIGNED_SHORT:r=65535;break;case C.ComponentDatatype.INT:r=2147483647;break;case C.ComponentDatatype.UNSIGNED_INT:r=4294967295}for(var c=new Float32Array(n*o),s=0;s<n;s++)for(var u=0;u<o;u++){var i=s*o+u;c[i]=Math.max(e[i]/r,-1)}return c},e.AttributeCompression=s});
