learning_cesium/js/XbsjCesium/Workers/createRectangleGeometry.js

2 lines
15 KiB
JavaScript
Raw Permalink Normal View History

2024-03-19 18:06:25 +08:00
define(["./when-54335d57","./Cartesian2-697a9954","./GeometryOffsetAttribute-6e5d8e16","./Transforms-251ff661","./Check-f3fec9b0","./ComponentDatatype-417761a2","./GeometryAttribute-7ca1c9e4","./GeometryAttributes-caa08d6c","./GeometryInstance-1bb3fb4a","./GeometryPipeline-1dd54e44","./IndexDatatype-c134ea39","./Math-737a2579","./PolygonPipeline-1048742e","./RectangleGeometryLibrary-d5132530","./VertexFormat-acf45ede","./RuntimeError-88a32665","./WebGLConstants-4739ce15","./AttributeCompression-ab5c33b7","./EncodedCartesian3-0ae9fe5e","./IntersectionTests-3e34a0aa","./Plane-d4cb7bb3","./EllipsoidRhumbLine-e5c51fa7"],function(Q,W,J,S,t,j,Z,r,K,$,tt,et,at,I,rt,e,a,n,i,o,s,l){"use strict";var nt=new W.Cartesian3,it=new W.Cartesian3,ot=new W.Cartesian3,st=new W.Cartesian3,p=new W.Rectangle,k=new W.Cartesian2,d=new S.BoundingSphere,g=new S.BoundingSphere;function lt(t,e){var a=new Z.Geometry({attributes:new r.GeometryAttributes,primitiveType:Z.PrimitiveType.TRIANGLES});return a.attributes.position=new Z.GeometryAttribute({componentDatatype:j.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(a.attributes.normal=new Z.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(a.attributes.tangent=new Z.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(a.attributes.bitangent=new Z.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.bitangents})),a}var ut=new W.Cartesian3,ct=new W.Cartesian3;function mt(t,e){var a=t._vertexFormat,r=t._ellipsoid,n=e.height,i=e.width,o=e.northCap,s=e.southCap,l=0,u=n,c=n,t=0;o&&(--c,t+=l=1),s&&(--u,--c,t+=1),t+=i*c;for(var m=a.position?new Float64Array(3*t):void 0,p=a.st?new Float32Array(2*t):void 0,d=0,g=0,y=nt,f=k,h=Number.MAX_VALUE,b=Number.MAX_VALUE,v=-Number.MAX_VALUE,_=-Number.MAX_VALUE,A=l;A<u;++A)for(var x=0;x<i;++x)I.RectangleGeometryLibrary.computePosition(e,r,a.st,A,x,y,f),m[d++]=y.x,m[d++]=y.y,m[d++]=y.z,a.st&&(p[g++]=f.x,p[g++]=f.y,h=Math.min(h,f.x),b=Math.min(b,f.y),v=Math.max(v,f.x),_=Math.max(_,f.y));if(o&&(I.RectangleGeometryLibrary.computePosition(e,r,a.st,0,0,y,f),m[d++]=y.x,m[d++]=y.y,m[d++]=y.z,a.st&&(p[g++]=f.x,p[g++]=f.y,h=f.x,b=f.y,v=f.x,_=f.y)),s&&(I.RectangleGeometryLibrary.computePosition(e,r,a.st,n-1,0,y,f),m[d++]=y.x,m[d++]=y.y,m[d]=y.z,a.st&&(p[g++]=f.x,p[g]=f.y,h=Math.min(h,f.x),b=Math.min(b,f.y),v=Math.max(v,f.x),_=Math.max(_,f.y))),a.st&&(h<0||b<0||1<v||1<_))for(var w=0;w<p.length;w+=2)p[w]=(p[w]-h)/(v-h),p[w+1]=(p[w+1]-b)/(_-b);l=function(t,e,a,r){var n=t.length,i=e.normal?new Float32Array(n):void 0,o=e.tangent?new Float32Array(n):void 0,s=e.bitangent?new Float32Array(n):void 0,l=0,u=st,c=ot,m=it;if(e.normal||e.tangent||e.bitangent)for(var p=0;p<n;p+=3){var d=W.Cartesian3.fromArray(t,p,nt),g=l+1,y=l+2,m=a.geodeticSurfaceNormal(d,m);(e.tangent||e.bitangent)&&(W.Cartesian3.cross(W.Cartesian3.UNIT_Z,m,c),S.Matrix3.multiplyByVector(r,c,c),W.Cartesian3.normalize(c,c),e.bitangent&&W.Cartesian3.normalize(W.Cartesian3.cross(m,c,u),u)),e.normal&&(i[l]=m.x,i[g]=m.y,i[y]=m.z),e.tangent&&(o[l]=c.x,o[g]=c.y,o[y]=c.z),e.bitangent&&(s[l]=u.x,s[g]=u.y,s[y]=u.z),l+=3}return lt(e,{positions:t,normals:i,tangents:o,bitangents:s})}(m,a,r,e.tangentRotationMatrix),n=6*(i-1)*(c-1);o&&(n+=3*(i-1)),s&&(n+=3*(i-1));for(var C=tt.IndexDatatype.createTypedArray(t,n),R=0,E=0,F=0;F<c-1;++F){for(var G=0;G<i-1;++G){var P=R,V=P+i,L=V+1,D=P+1;C[E++]=P,C[E++]=V,C[E++]=D,C[E++]=D,C[E++]=V,C[E++]=L,++R}++R}if(o||s){var M,T,O=t-1,N=t-1;if(o&&s&&(O=t-2),R=0,o)for(F=0;F<i-1;F++)T=(M=R)+1,C[E++]=O,C[E++]=M,C[E++]=T,++R;if(s)for(R=(c-1)*i,F=0;F<i-1;F++)T=(M=R)+1,C[E++]=M,C[E++]=N,C[E++]=T,++R}return l.indices=C,a.st&&(l.attributes.st=new Z.GeometryAttribute({componentDatatype:j.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:p})),l}function pt(t,e,a,r,n){return t[e++]=r[a],t[e++]=r[a+1],t[e++]=r[a+2],t[e++]=n[a],t[e++]=n[a+1],t[e]=n[a+2],t}function dt(t,e,a,r){return t[e++]=r[a],t[e++]=r[a+1]