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