/* 2020-9-22 15:23:26 | 版权所有 军懋国兴  */
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-607c9a0c","./IndexDatatype-79bb407c","./createTaskProcessorWorker"],function(f,e,t,b,r,A,m,n){"use strict";var w;function l(e,t,r){var n,o=e.num_points(),a=r.num_components(),i=new w.AttributeQuantizationTransform;if(i.InitFromAttribute(r)){for(var u=new Array(a),s=0;s<a;++s)u[s]=i.min_value(s);n={quantizationBits:i.quantization_bits(),minValues:u,range:i.range(),octEncoded:!1}}w.destroy(i),(i=new w.AttributeOctahedronTransform).InitFromAttribute(r)&&(n={quantizationBits:i.quantization_bits(),octEncoded:!0}),w.destroy(i);var c=o*a,d=f.defined(n)?function(e,t,r,n,o){var a,i;n.quantizationBits<=8?(i=new w.DracoUInt8Array,a=new Uint8Array(o),t.GetAttributeUInt8ForAllPoints(e,r,i)):(i=new w.DracoUInt16Array,a=new Uint16Array(o),t.GetAttributeUInt16ForAllPoints(e,r,i));for(var u=0;u<o;++u)a[u]=i.GetValue(u);return w.destroy(i),a}(e,t,r,n,c):function(e,t,r,n){var o,a;switch(r.data_type()){case 1:case 11:a=new w.DracoInt8Array,o=new Int8Array(n),t.GetAttributeInt8ForAllPoints(e,r,a);break;case 2:a=new w.DracoUInt8Array,o=new Uint8Array(n),t.GetAttributeUInt8ForAllPoints(e,r,a);break;case 3:a=new w.DracoInt16Array,o=new Int16Array(n),t.GetAttributeInt16ForAllPoints(e,r,a);break;case 4:a=new w.DracoUInt16Array,o=new Uint16Array(n),t.GetAttributeUInt16ForAllPoints(e,r,a);break;case 5:case 7:a=new w.DracoInt32Array,o=new Int32Array(n),t.GetAttributeInt32ForAllPoints(e,r,a);break;case 6:case 8:a=new w.DracoUInt32Array,o=new Uint32Array(n),t.GetAttributeUInt32ForAllPoints(e,r,a);break;case 9:case 10:a=new w.DracoFloat32Array,o=new Float32Array(n),t.GetAttributeFloatForAllPoints(e,r,a)}for(var i=0;i<n;++i)o[i]=a.GetValue(i);return w.destroy(a),o}(e,t,r,c),y=A.ComponentDatatype.fromTypedArray(d);return{array:d,data:{componentsPerAttribute:a,componentDatatype:y,byteOffset:r.byte_offset(),byteStride:A.ComponentDatatype.getSizeInBytes(y)*a,normalized:r.normalized(),quantization:n}}}function o(e){var t=new w.Decoder,r=["POSITION","NORMAL","COLOR","TEX_COORD"];if(e.dequantizeInShader)for(var n=0;n<r.length;++n)t.SkipAttributeTransform(w[r[n]]);var o=e.bufferView,a=new w.DecoderBuffer;if(a.Init(e.array,o.byteLength),t.GetEncodedGeometryType(a)!==w.TRIANGULAR_MESH)throw new b.RuntimeError("Unsupported draco mesh geometry type.");var i=new w.Mesh,u=t.DecodeBufferToMesh(a,i);if(!u.ok()||0===i.ptr)throw new b.RuntimeError("Error decoding draco mesh geometry: "+u.error_msg());w.destroy(a);var s,c,d,y={},f=e.compressedAttributes;for(s in f){f.hasOwnProperty(s)&&(c=f[s],d=t.GetAttributeByUniqueId(i,c),y[s]=l(i,t,d))}var A={indexArray:function(e,t){for(var r=e.num_points(),n=e.num_faces(),o=new w.DracoInt32Array,a=3*n,i=m.IndexDatatype.createTypedArray(r,a),u=0,s=0;s<n;++s)t.GetFaceFromMesh(e,s,o),i[u+0]=o.GetValue(0),i[u+1]=o.GetValue(1),i[u+2]=o.GetValue(2),u+=3;return w.destroy(o),{typedArray:i,numberOfIndices:a}}(i,t),attributeData:y};return w.destroy(i),w.destroy(t),A}function a(e){return(f.defined(e.primitive)?o:function(e){var t=new w.Decoder;e.dequantizeInShader&&(t.SkipAttributeTransform(w.POSITION),t.SkipAttributeTransform(w.NORMAL));var r=new w.DecoderBuffer;if(r.Init(e.buffer,e.buffer.length),t.GetEncodedGeometryType(r)!==w.POINT_CLOUD)throw new b.RuntimeError("Draco geometry type must be POINT_CLOUD.");var n=new w.PointCloud,o=t.DecodeBufferToPointCloud(r,n);if(!o.ok()||0===n.ptr)throw new b.RuntimeError("Error decoding draco point cloud: "+o.error_msg());w.destroy(r);var a,i,u,s={},c=e.properties;for(a in c){c.hasOwnProperty(a)&&(i=c[a],u=t.GetAttributeByUniqueId(n,i),s[a]=l(n,t,u))}return w.destroy(n),w.destroy(t),s})(e)}function i(e){w=e,self.onmessage=n(a),self.postMessage(!0)}return function(e){var t=e.data.webAssemblyConfig;if(f.defined(t))return require([t.modulePath],function(e){f.defined(t.wasmBinaryFile)?(f.defined(e)||(e=self.DracoDecoderModule),e(t).then(function(e){i(e)})):i(e())})}});