integrated_traffic_vue/public/lib/Cesium/Workers/decodeI3S.js

2 lines
10 KiB
JavaScript
Raw Normal View History

2024-01-31 09:03:02 +08:00
define(["./createTaskProcessorWorker","./defaultValue-0a909f67","./WebMercatorProjection-8e29b101","./Matrix3-b6f074fa","./Math-e97915da"],(function(e,t,n,r,o){"use strict";let a;function i(e,t,n,r){return r[e+t*n]}function s(e,t,n){const r=n.nativeExtent;let o=(e-r.west)/(r.east-r.west)*(n.width-1),a=(t-r.south)/(r.north-r.south)*(n.height-1);const s=Math.floor(o);let u=Math.floor(a);o-=s,a-=u;const c=s<n.width?s+1:s;let f=u<n.height?u+1:u;u=n.height-1-u,f=n.height-1-f;let l=function(e,t,n,r,o,a){return(n*(1-e)+r*e)*(1-t)+(o*(1-e)+a*e)*t}(o,a,i(s,u,n.width,n.buffer),i(c,u,n.width,n.buffer),i(s,f,n.width,n.buffer),i(c,f,n.width,n.buffer));return l=l*n.scale+n.offset,l}function u(e,t,o){for(let a=0;a<o.length;a++){const i=o[a].nativeExtent;let u=new r.Cartesian3;if("WebMercator"===o[a].projectionType){const i=o[a].projection._ellipsoid._radii;u=new n.WebMercatorProjection(new r.Ellipsoid(i.x,i.y,i.z)).project(new r.Cartographic(e,t,0))}else u.x=e,u.y=t;if(u.x>i.west&&u.x<i.east&&u.y>i.south&&u.y<i.north)return s(u.x,u.y,o[a])}return 0}function c(e,n,r,o){const i=new Uint8Array(e,0,5);return i[0]==="D".charCodeAt()&&i[1]==="R".charCodeAt()&&i[2]==="A".charCodeAt()&&i[3]==="C".charCodeAt()&&i[4]==="O".charCodeAt()?function(e){const n=a,r=new n.DecoderBuffer,o=new Uint8Array(e);r.Init(o,o.length);const i=new n.Decoder,s=i.GetEncodedGeometryType(r),u=new n.MetadataQuerier;let c,l;s===n.TRIANGULAR_MESH&&(c=new n.Mesh,l=i.DecodeBufferToMesh(r,c));const d={vertexCount:[0],featureCount:0};if(t.defined(l)&&l.ok()&&0!==c.ptr){const e=c.num_faces(),r=c.num_attributes(),o=c.num_points();d.indices=new Uint32Array(3*e);const a=d.indices;d.vertexCount[0]=o,d.scale_x=1,d.scale_y=1;const s=new n.DracoInt32Array(3);for(let t=0;t<e;++t)i.GetFaceFromMesh(c,t,s),a[3*t]=s.GetValue(0),a[3*t+1]=s.GetValue(1),a[3*t+2]=s.GetValue(2);n.destroy(s);for(let e=0;e<r;++e){const r=i.GetAttribute(c,e),a=f(n,i,c,r,o),s=r.attribute_type();let l="unknown";s===n.POSITION?l="positions":s===n.NORMAL?l="normals":s===n.COLOR?l="colors":s===n.TEX_COORD&&(l="uv0s");const y=i.GetAttributeMetadata(c,e);if(0!==y.ptr){const e=u.NumEntries(y);for(let t=0;t<e;++t){const e=u.GetEntryName(y,t);"i3s-scale_x"===e?d.scale_x=u.GetDoubleEntry(y,"i3s-scale_x"):"i3s-scale_y"===e?d.scale_y=u.GetDoubleEntry(y,"i3s-scale_y"):"i3s-attribute-type"===e&&(l=u.GetStringEntry(y,"i3s-attribute-type"))}}t.defined(d[l])&&console.log("Attribute already exists",l),d[l]=a,"feature-index"===l&&d.featureCount++}n.destroy(c)}return n.destroy(u),n.destroy(i),d}(e):function(e,n,r,o){const a={vertexCount:0},i=new DataView(e);try{let s=0;if(a.vertexCount=i.getUint32(s,1),s+=4,a.featureCount=i.getUint32(s,1),s+=4,t.defined(r))for(let n=0;n<r.attributes.length;n++)t.defined(l[r.attributes[n]])?s=l[r.attributes[n]](a,e,s):console.error("Unknown decoder for",r.attributes[n]);else{let r=n.ordering,i=n.featureAttributeOrder;t.defined(o)&&t.defined(o.geometryData)&&t.defined(o.geometryData[0])&&t.defined(o.geometryData[0].params)&&(r=Object.keys(o.geometryData[0].params.vertexAttributes),i=Object.keys(o.geometryData[0].params.featureAttributes));for(let n=0;n<r.length;n++){const o=l[r[n]];t.defined(o)||console.log(r[n]),s=o(a,e,s)}for(let n=0;n<i.length;n++){const r=l[i[n]];t.defined(r)||console.log(i[n]),s=r(a,e,s)}}}catch(e){console.error(e)}return a.scale_x=1,a.scale_y=1,a}(e,n,r,o)}function f(e,n,r,o,a){const i=o.num_components()*a;let s;const u=[function(){},function(){s=new e.DracoInt8Array(i);n.GetAttributeInt8ForAllPoints(r,o,s)||console.error("Bad stream");const t=new Int8Array(i);for(let e=0;e<i;++e)t[e]=s.GetValue(e);return t},function(){s=new e.DracoInt8Array(i);n.GetAttributeUInt8ForAllPoints(r,o,s)||console.error("Bad stream");const t=new Uint8Array(i);for(let e=0;e<i;++e)t[e]=s.GetValue(e);return t},function(){s=new e.DracoInt16Array(i);n.GetAttributeInt16ForAllPoints(r,o,s)||console.error("Bad stream");const t=new Int16Array(i);for(let e=0;e<i;++e)t[e]=s.GetValue(e);return t},function(){s=new e.DracoInt16Array(i);n.GetAttributeUInt16ForAllPoints(r,o,s)||console.error("Bad stream");const t=ne