qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/decodeDraco.js

2 lines
4.1 KiB
JavaScript
Raw Normal View History

2023-12-17 15:30:40 +08:00
define(["./ComponentDatatype-aaeec80f","./defaultValue-81eec7ed","./IndexDatatype-3f3c99e8","./RuntimeError-26acdd3b","./createTaskProcessorWorker","./Check-741c5f3c","./WebGLConstants-508b9636","./Math-e73894ab","./when-422ea0ae"],(function(e,t,r,n,o,a,i,s,c){"use strict";let u;function d(e,t){const n=e.num_points(),o=e.num_faces(),a=new u.DracoInt32Array,i=3*o,s=r.IndexDatatype.createTypedArray(n,i);let c=0;for(let r=0;r<o;++r)t.GetFaceFromMesh(e,r,a),s[c+0]=a.GetValue(0),s[c+1]=a.GetValue(1),s[c+2]=a.GetValue(2),c+=3;return u.destroy(a),{typedArray:s,numberOfIndices:i}}function f(r,n,o){const a=r.num_points(),i=o.num_components();let s,c=new u.AttributeQuantizationTransform;if(c.InitFromAttribute(o)){const e=new Array(i);for(let t=0;t<i;++t)e[t]=c.min_value(t);s={quantizationBits:c.quantization_bits(),minValues:e,range:c.range(),octEncoded:!1}}u.destroy(c),c=new u.AttributeOctahedronTransform,c.InitFromAttribute(o)&&(s={quantizationBits:c.quantization_bits(),octEncoded:!0}),u.destroy(c);const d=a*i;let f;f=t.defined(s)?function(e,t,r,n,o){let a,i;n.quantizationBits<=8?(i=new u.DracoUInt8Array,a=new Uint8Array(o),t.GetAttributeUInt8ForAllPoints(e,r,i)):(i=new u.DracoUInt16Array,a=new Uint16Array(o),t.GetAttributeUInt16ForAllPoints(e,r,i));for(let e=0;e<o;++e)a[e]=i.GetValue(e);return u.destroy(i),a}(r,n,o,s,d):function(e,t,r,n){let o,a;switch(r.data_type()){case 1:case 11:a=new u.DracoInt8Array,o=new Int8Array(n),t.GetAttributeInt8ForAllPoints(e,r,a);break;case 2:a=new u.DracoUInt8Array,o=new Uint8Array(n),t.GetAttributeUInt8ForAllPoints(e,r,a);break;case 3:a=new u.DracoInt16Array,o=new Int16Array(n),t.GetAttributeInt16ForAllPoints(e,r,a);break;case 4:a=new u.DracoUInt16Array,o=new Uint16Array(n),t.GetAttributeUInt16ForAllPoints(e,r,a);break;case 5:case 7:a=new u.DracoInt32Array,o=new Int32Array(n),t.GetAttributeInt32ForAllPoints(e,r,a);break;case 6:case 8:a=new u.DracoUInt32Array,o=new Uint32Array(n),t.GetAttributeUInt32ForAllPoints(e,r,a);break;case 9:case 10:a=new u.DracoFloat32Array,o=new Float32Array(n),t.GetAttributeFloatForAllPoints(e,r,a)}for(let e=0;e<n;++e)o[e]=a.GetValue(e);return u.destroy(a),o}(r,n,o,d);const y=e.ComponentDatatype.fromTypedArray(f);return{array:f,data:{componentsPerAttribute:i,componentDatatype:y,byteOffset:o.byte_offset(),byteStride:e.ComponentDatatype.getSizeInBytes(y)*i,normalized:o.normalized(),quantization:s}}}function y(e){return t.defined(e.bufferView)?function(e){const t=new u.Decoder,r=["POSITION","NORMAL","COLOR","TEX_COORD"];if(e.dequantizeInShader)for(let e=0;e<r.length;++e)t.SkipAttributeTransform(u[r[e]]);const o=e.bufferView,a=new u.DecoderBuffer;if(a.Init(e.array,o.byteLength),t.GetEncodedGeometryType(a)!==u.TRIANGULAR_MESH)throw new n.RuntimeError("Unsupported draco mesh geometry type.");const i=new u.Mesh,s=t.DecodeBufferToMesh(a,i);if(!s.ok()||0===i.ptr)throw new n.RuntimeError(`Error decoding draco mesh geometry: ${s.error_msg()}`);u.destroy(a);const c={},y=e.compressedAttributes;for(const e in y)if(y.hasOwnProperty(e)){const r=y[e],n=t.GetAttributeByUniqueId(i,r);c[e]=f(i,t,n)}const A={indexArray:d(i,t),attributeData:c};return u.destroy(i),u.destroy(t),A}(e):function(e){const t=new u.Decoder;e.dequantizeInShader&&(t.SkipAttributeTransform(u.POSITION),t.SkipAttributeTransform(u.NORMAL));const r=new u.DecoderBuffer;if(r.Init(e.buffer,e.buffer.length),t.GetEncodedGeometryType(r)!==u.POINT_CLOUD)throw new n.RuntimeError("Draco geometry type must be POINT_CLOUD.");const o=new u.PointCloud,a=t.DecodeBufferToPointCloud(r,o);if(!a.ok()||0===o.ptr)throw new n.RuntimeError(`Error decoding draco point cloud: ${a.error_msg()}`);u.destroy(r);const i={},s=e.properties;for(const e in s)if(s.hasOwnProperty(e)){let r;if("POSITION"===e||"NORMAL"===e){const n=t.GetAttributeId(o,u[e]);r=t.GetAttribute(o,n)}else{const n=s[e];r=t.GetAttributeByUniqueId(o,n)}i[e]=f(o,t,r)}return u.destroy(o),u.destroy(t),i}(e)}function A(e){u=e,self.onmessage=o(y),self.postMessage(!0)}return function(e){const r=e.data.webAssemblyConfig;if(t.defined(r))return require([r.modulePath],(function(e){t.defined(r.w