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

2 lines
16 KiB
JavaScript
Raw Normal View History

2024-01-31 09:03:02 +08:00
define(["./defaultValue-0a909f67","./Matrix3-b6f074fa","./Matrix2-163b5a1d","./Transforms-713aa3a8","./ComponentDatatype-77274976","./GeometryAttribute-0b8b7b82","./GeometryAttributes-f06a2792","./GeometryInstance-9b27c40d","./GeometryOffsetAttribute-04332ce7","./GeometryPipeline-b6eb7525","./IndexDatatype-2149f06c","./Math-e97915da","./PolygonPipeline-1b86ab0c","./RectangleGeometryLibrary-97b463a4","./VertexFormat-ab2e00e6","./RuntimeError-06c93819","./combine-ca22a614","./WebGLConstants-a8cc3e8c","./AttributeCompression-e18a879a","./EncodedCartesian3-de837603","./IntersectionTests-87baf287","./Plane-1c5a21a3","./EllipsoidRhumbLine-7f84cca0"],(function(t,e,n,a,o,r,i,s,l,u,c,m,p,d,g,y,f,h,b,_,A,x,w){"use strict";const C=new e.Cartesian3,v=new e.Cartesian3,R=new e.Cartesian3,E=new e.Cartesian3,G=new n.Rectangle,F=new n.Cartesian2,P=new a.BoundingSphere,V=new a.BoundingSphere;function L(t,e){const n=new r.Geometry({attributes:new i.GeometryAttributes,primitiveType:r.PrimitiveType.TRIANGLES});return n.attributes.position=new r.GeometryAttribute({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(n.attributes.normal=new r.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(n.attributes.tangent=new r.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(n.attributes.bitangent=new r.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.bitangents})),n}const D=new e.Cartesian3,M=new e.Cartesian3;function T(t,n){const a=t._vertexFormat,i=t._ellipsoid,s=n.height,l=n.width,u=n.northCap,m=n.southCap;let p=0,g=s,y=s,f=0;u&&(p=1,y-=1,f+=1),m&&(g-=1,y-=1,f+=1),f+=l*y;const h=a.position?new Float64Array(3*f):void 0,b=a.st?new Float32Array(2*f):void 0;let _=0,A=0;const x=C,w=F;let G=Number.MAX_VALUE,P=Number.MAX_VALUE,V=-Number.MAX_VALUE,D=-Number.MAX_VALUE;for(let t=p;t<g;++t)for(let e=0;e<l;++e)d.RectangleGeometryLibrary.computePosition(n,i,a.st,t,e,x,w),h[_++]=x.x,h[_++]=x.y,h[_++]=x.z,a.st&&(b[A++]=w.x,b[A++]=w.y,G=Math.min(G,w.x),P=Math.min(P,w.y),V=Math.max(V,w.x),D=Math.max(D,w.y));if(u&&(d.RectangleGeometryLibrary.computePosition(n,i,a.st,0,0,x,w),h[_++]=x.x,h[_++]=x.y,h[_++]=x.z,a.st&&(b[A++]=w.x,b[A++]=w.y,G=w.x,P=w.y,V=w.x,D=w.y)),m&&(d.RectangleGeometryLibrary.computePosition(n,i,a.st,s-1,0,x,w),h[_++]=x.x,h[_++]=x.y,h[_]=x.z,a.st&&(b[A++]=w.x,b[A]=w.y,G=Math.min(G,w.x),P=Math.min(P,w.y),V=Math.max(V,w.x),D=Math.max(D,w.y))),a.st&&(G<0||P<0||V>1||D>1))for(let t=0;t<b.length;t+=2)b[t]=(b[t]-G)/(V-G),b[t+1]=(b[t+1]-P)/(D-P);const M=function(t,n,a,o){const r=t.length,i=n.normal?new Float32Array(r):void 0,s=n.tangent?new Float32Array(r):void 0,l=n.bitangent?new Float32Array(r):void 0;let u=0;const c=E,m=R;let p=v;if(n.normal||n.tangent||n.bitangent)for(let d=0;d<r;d+=3){const r=e.Cartesian3.fromArray(t,d,C),g=u+1,y=u+2;p=a.geodeticSurfaceNormal(r,p),(n.tangent||n.bitangent)&&(e.Cartesian3.cross(e.Cartesian3.UNIT_Z,p,m),e.Matrix3.multiplyByVector(o,m,m),e.Cartesian3.normalize(m,m),n.bitangent&&e.Cartesian3.normalize(e.Cartesian3.cross(p,m,c),c)),n.normal&&(i[u]=p.x,i[g]=p.y,i[y]=p.z),n.tangent&&(s[u]=m.x,s[g]=m.y,s[y]=m.z),n.bitangent&&(l[u]=c.x,l[g]=c.y,l[y]=c.z),u+=3}return L(n,{positions:t,normals:i,tangents:s,bitangents:l})}(h,a,i,n.tangentRotationMatrix);let T=6*(l-1)*(y-1);u&&(T+=3*(l-1)),m&&(T+=3*(l-1));const O=c.IndexDatatype.createTypedArray(f,T);let N,S=0,I=0;for(N=0;N<y-1;++N){for(let t=0;t<l-1;++t){const t=S,e=t+l,n=e+1,a=t+1;O[I++]=t,O[I++]=e,O[I++]=a,O[I++]=a,O[I++]=e,O[I++]=n,++S}++S}if(u||m){let t=f-1;const e=f-1;let n,a;if(u&&m&&(t=f-2),S=0,u)for(N=0;N<l-1;N++)n=S,a=n+1,O[I++]=t,O[I++]=n,O[I++]=a,++S;if(m)for(S=(y-1)*l,N=0;N<l-1;N++)n=S,a=n+1,O[I++]=n,O[I++]=e,O[I++]=a,++S}return M.indices=O,a.st&&(M.attributes.st=new r.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:b})),M}function O(t,e,n,a,o){return t[e++]=a[n],t[e++]=a[n+1],t[e++]=a[n+