Newer
Older
smartwell_front_dz / smartwell / mars3d-cesium / Workers / AttributeCompression-18035d40.js
wangxitong on 11 Sep 2023 6 KB first commit
/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.96.6
 *
 * Copyright 2011-2022 Cesium Contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Columbus View (Pat. Pend.)
 *
 * Portions licensed separately.
 * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
 */
define(["exports","./Matrix2-4706dd70","./ComponentDatatype-438cad2a","./RuntimeError-a977b8e0","./defaultValue-028a8a27"],(function(e,t,n,r,o){"use strict";const 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 t.Cartesian2;case a.VEC3:return t.Cartesian3;case a.VEC4:return t.Cartesian4;case a.MAT2:return t.Matrix2;case a.MAT3:return t.Matrix3;case a.MAT4:return t.Matrix4;default:throw new r.DeveloperError("attributeType is not a valid value.")}},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;default:throw new r.DeveloperError("attributeType is not a valid value.")}},getAttributeLocationCount:function(e){switch(e){case a.SCALAR:case a.VEC2:case a.VEC3:case a.VEC4:return 1;case a.MAT2:return 2;case a.MAT3:return 3;case a.MAT4:return 4;default:throw new r.DeveloperError("attributeType is not a valid value.")}},getGlslType:function(e){switch(r.Check.typeOf.string("attributeType",e),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";default:throw new r.DeveloperError("attributeType is not a valid value.")}}};var c=Object.freeze(a);const s=1/256,u=256,i={octEncodeInRange:function(e,o,a){r.Check.defined("vector",e),r.Check.defined("result",a);const c=t.Cartesian3.magnitudeSquared(e);if(Math.abs(c-1)>n.CesiumMath.EPSILON6)throw new r.DeveloperError("vector must be normalized.");if(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){const e=a.x,t=a.y;a.x=(1-Math.abs(t))*n.CesiumMath.signNotZero(e),a.y=(1-Math.abs(e))*n.CesiumMath.signNotZero(t)}return a.x=n.CesiumMath.toSNorm(a.x,o),a.y=n.CesiumMath.toSNorm(a.y,o),a},octEncode:function(e,t){return i.octEncodeInRange(e,255,t)}},d=new t.Cartesian2,f=new Uint8Array(1);function h(e){return f[0]=e,f[0]}i.octEncodeToCartesian4=function(e,t){return i.octEncodeInRange(e,65535,d),t.x=h(d.x*s),t.y=h(d.x),t.z=h(d.y*s),t.w=h(d.y),t},i.octDecodeInRange=function(e,o,a,c){if(r.Check.defined("result",c),e<0||e>a||o<0||o>a)throw new r.DeveloperError(`x and y must be unsigned normalized integers between 0 and ${a}`);if(c.x=n.CesiumMath.fromSNorm(e,a),c.y=n.CesiumMath.fromSNorm(o,a),c.z=1-(Math.abs(c.x)+Math.abs(c.y)),c.z<0){const e=c.x;c.x=(1-Math.abs(c.y))*n.CesiumMath.signNotZero(e),c.y=(1-Math.abs(e))*n.CesiumMath.signNotZero(c.y)}return t.Cartesian3.normalize(c,c)},i.octDecode=function(e,t,n){return i.octDecodeInRange(e,t,255,n)},i.octDecodeFromCartesian4=function(e,t){r.Check.typeOf.object("encoded",e),r.Check.typeOf.object("result",t);const n=e.x,o=e.y,a=e.z,c=e.w;if(n<0||n>255||o<0||o>255||a<0||a>255||c<0||c>255)throw new r.DeveloperError("x, y, z, and w must be unsigned normalized integers between 0 and 255");const s=n*u+o,d=a*u+c;return i.octDecodeInRange(s,d,65535,t)},i.octPackFloat=function(e){return r.Check.defined("encoded",e),256*e.x+e.y};const C=new t.Cartesian2;function l(e){return e>>1^-(1&e)}i.octEncodeFloat=function(e){return i.octEncode(e,C),i.octPackFloat(C)},i.octDecodeFloat=function(e,t){r.Check.defined("value",e);const n=e/256,o=Math.floor(n),a=256*(n-o);return i.octDecode(o,a,t)},i.octPack=function(e,t,n,o){r.Check.defined("v1",e),r.Check.defined("v2",t),r.Check.defined("v3",n),r.Check.defined("result",o);const a=i.octEncodeFloat(e),c=i.octEncodeFloat(t),s=i.octEncode(n,C);return o.x=65536*s.x+a,o.y=65536*s.y+c,o},i.octUnpack=function(e,t,n,o){r.Check.defined("packed",e),r.Check.defined("v1",t),r.Check.defined("v2",n),r.Check.defined("v3",o);let a=e.x/65536;const c=Math.floor(a),s=65536*(a-c);a=e.y/65536;const u=Math.floor(a),d=65536*(a-u);i.octDecodeFloat(s,t),i.octDecodeFloat(d,n),i.octDecode(c,u,o)},i.compressTextureCoordinates=function(e){r.Check.defined("textureCoordinates",e);const t=4095*e.x|0,n=4095*e.y|0;return 4096*t+n},i.decompressTextureCoordinates=function(e,t){r.Check.defined("compressed",e),r.Check.defined("result",t);const n=e/4096,o=Math.floor(n);return t.x=o/4095,t.y=(e-4096*o)/4095,t},i.zigZagDeltaDecode=function(e,t,n){r.Check.defined("uBuffer",e),r.Check.defined("vBuffer",t),r.Check.typeOf.number.equals("uBuffer.length","vBuffer.length",e.length,t.length),o.defined(n)&&r.Check.typeOf.number.equals("uBuffer.length","heightBuffer.length",e.length,n.length);const a=e.length;let c=0,s=0,u=0;for(let r=0;r<a;++r)c+=l(e[r]),s+=l(t[r]),e[r]=c,t[r]=s,o.defined(n)&&(u+=l(n[r]),n[r]=u)},i.dequantize=function(e,t,o,a){r.Check.defined("typedArray",e),r.Check.defined("componentDatatype",t),r.Check.defined("type",o),r.Check.defined("count",a);const s=c.getNumberOfComponents(o);let u;switch(t){case n.ComponentDatatype.BYTE:u=127;break;case n.ComponentDatatype.UNSIGNED_BYTE:u=255;break;case n.ComponentDatatype.SHORT:u=32767;break;case n.ComponentDatatype.UNSIGNED_SHORT:u=65535;break;case n.ComponentDatatype.INT:u=2147483647;break;case n.ComponentDatatype.UNSIGNED_INT:u=4294967295;break;default:throw new r.DeveloperError(`Cannot dequantize component datatype: ${t}`)}const i=new Float32Array(a*s);for(let n=0;n<a;n++)for(let t=0;t<s;t++){const r=n*s+t;i[r]=Math.max(e[r]/u,-1)}return i},i.decodeRGB565=function(e,t){r.Check.defined("typedArray",e);const n=3*e.length;o.defined(t)&&r.Check.typeOf.number.equals("result.length","typedArray.length * 3",t.length,n);const a=e.length;o.defined(t)||(t=new Float32Array(3*a));const c=31,s=63,u=1/31,i=1/63;for(let r=0;r<a;r++){const n=e[r],o=n>>11,a=n>>5&s,d=n&c,f=3*r;t[f]=o*u,t[f+1]=a*i,t[f+2]=d*u}return t},e.AttributeCompression=i}));