1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-16 18:06:35 -04:00
sdrangel/plugins/feature/map/Cesium/Workers/createRectangleGeometry.js

2 lines
16 KiB
JavaScript
Raw Normal View History

2022-02-04 15:41:22 -05:00
define(["./when-229515d6","./Matrix2-46444433","./GeometryOffsetAttribute-4f901209","./Transforms-ab7258fe","./RuntimeError-608565a6","./ComponentDatatype-692a36d3","./GeometryAttribute-d3bef603","./GeometryAttributes-b253752a","./GeometryInstance-f781740f","./GeometryPipeline-dfaf2218","./IndexDatatype-7c683b18","./PolygonPipeline-259e0bdf","./RectangleGeometryLibrary-f383a8ff","./VertexFormat-7272aabd","./combine-35b6d9cb","./WebGLConstants-f63312fc","./AttributeCompression-95366034","./EncodedCartesian3-d9d33966","./IntersectionTests-4cf437d5","./Plane-1f2a7880","./EllipsoidRhumbLine-9cd85d72"],(function(t,e,n,a,o,r,i,s,l,u,c,m,d,p,g,y,f,h,b,_,A){"use strict";const x=new e.Cartesian3,w=new e.Cartesian3,C=new e.Cartesian3,v=new e.Cartesian3,R=new e.Rectangle,E=new e.Cartesian2,F=new a.BoundingSphere,G=new a.BoundingSphere;function P(t,e){const n=new i.Geometry({attributes:new s.GeometryAttributes,primitiveType:i.PrimitiveType.TRIANGLES});return n.attributes.position=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(n.attributes.normal=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(n.attributes.tangent=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(n.attributes.bitangent=new i.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.bitangents})),n}const V=new e.Cartesian3,L=new e.Cartesian3;function D(t,n){const a=t._vertexFormat,o=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 R=x,F=E;let G=Number.MAX_VALUE,V=Number.MAX_VALUE,L=-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,o,a.st,t,e,R,F),h[_++]=R.x,h[_++]=R.y,h[_++]=R.z,a.st&&(b[A++]=F.x,b[A++]=F.y,G=Math.min(G,F.x),V=Math.min(V,F.y),L=Math.max(L,F.x),D=Math.max(D,F.y));if(u&&(d.RectangleGeometryLibrary.computePosition(n,o,a.st,0,0,R,F),h[_++]=R.x,h[_++]=R.y,h[_++]=R.z,a.st&&(b[A++]=F.x,b[A++]=F.y,G=F.x,V=F.y,L=F.x,D=F.y)),m&&(d.RectangleGeometryLibrary.computePosition(n,o,a.st,s-1,0,R,F),h[_++]=R.x,h[_++]=R.y,h[_]=R.z,a.st&&(b[A++]=F.x,b[A]=F.y,G=Math.min(G,F.x),V=Math.min(V,F.y),L=Math.max(L,F.x),D=Math.max(D,F.y))),a.st&&(G<0||V<0||L>1||D>1))for(let t=0;t<b.length;t+=2)b[t]=(b[t]-G)/(L-G),b[t+1]=(b[t+1]-V)/(D-V);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=v,m=C;let d=w;if(n.normal||n.tangent||n.bitangent)for(let p=0;p<r;p+=3){const r=e.Cartesian3.fromArray(t,p,x),g=u+1,y=u+2;d=a.geodeticSurfaceNormal(r,d),(n.tangent||n.bitangent)&&(e.Cartesian3.cross(e.Cartesian3.UNIT_Z,d,m),e.Matrix3.multiplyByVector(o,m,m),e.Cartesian3.normalize(m,m),n.bitangent&&e.Cartesian3.normalize(e.Cartesian3.cross(d,m,c),c)),n.normal&&(i[u]=d.x,i[g]=d.y,i[y]=d.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 P(n,{positions:t,normals:i,tangents:s,bitangents:l})}(h,a,o,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 i.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:b})),M}function M(t,e,n,a,o){return t[e++]=a[n],t[e++]=a[n+1],t[e++]=a[n+2],t[e++]=o[n],t[e++]=o[n+1],t[e]=o[n+2],t}function