learning_cesium/Build168/Cesium/Workers/createRectangleGeometry.js

2 lines
15 KiB
JavaScript
Raw Normal View History

2024-03-19 18:06:25 +08:00
define(["./when-c2e8ef35","./Check-c4f3a3fc","./Math-d30358ed","./Cartesian2-e875d9d2","./Transforms-44592b02","./RuntimeError-6122571f","./WebGLConstants-4ae0db90","./ComponentDatatype-5d3f6452","./GeometryAttribute-4098b8de","./GeometryAttributes-57608efc","./AttributeCompression-6cb5b251","./GeometryPipeline-99c06fbd","./EncodedCartesian3-e19aab62","./IndexDatatype-e3260434","./IntersectionTests-ef7d18d8","./Plane-2d882f9f","./GeometryOffsetAttribute-e6e9672c","./VertexFormat-ad523db1","./GeometryInstance-b43ca1c5","./EllipsoidRhumbLine-5134246a","./PolygonPipeline-84f0d07f","./RectangleGeometryLibrary-bb0e14b8"],function(mt,t,dt,pt,k,e,a,gt,yt,r,n,ft,i,ht,o,s,vt,bt,_t,l,At,H){"use strict";var xt=new pt.Cartesian3,wt=new pt.Cartesian3,Ct=new pt.Cartesian3,Rt=new pt.Cartesian3,_=new pt.Rectangle,z=new pt.Cartesian2,A=new k.BoundingSphere,x=new k.BoundingSphere;function Et(t,e){var a=new yt.Geometry({attributes:new r.GeometryAttributes,primitiveType:yt.PrimitiveType.TRIANGLES});return a.attributes.position=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(a.attributes.normal=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(a.attributes.tangent=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(a.attributes.bitangent=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.bitangents})),a}var Ft=new pt.Cartesian3,Gt=new pt.Cartesian3;function Pt(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,m=0;o&&(--c,m+=l=1),s&&(--u,--c,m+=1),m+=i*c;for(var d=a.position?new Float64Array(3*m):void 0,p=a.st?new Float32Array(2*m):void 0,g=0,y=0,f=xt,h=z,v=Number.MAX_VALUE,b=Number.MAX_VALUE,_=-Number.MAX_VALUE,A=-Number.MAX_VALUE,x=l;x<u;++x)for(var w=0;w<i;++w)H.RectangleGeometryLibrary.computePosition(e,r,a.st,x,w,f,h),d[g++]=f.x,d[g++]=f.y,d[g++]=f.z,a.st&&(p[y++]=h.x,p[y++]=h.y,v=Math.min(v,h.x),b=Math.min(b,h.y),_=Math.max(_,h.x),A=Math.max(A,h.y));if(o&&(H.RectangleGeometryLibrary.computePosition(e,r,a.st,0,0,f,h),d[g++]=f.x,d[g++]=f.y,d[g++]=f.z,a.st&&(p[y++]=h.x,p[y++]=h.y,v=h.x,b=h.y,_=h.x,A=h.y)),s&&(H.RectangleGeometryLibrary.computePosition(e,r,a.st,n-1,0,f,h),d[g++]=f.x,d[g++]=f.y,d[g]=f.z,a.st&&(p[y++]=h.x,p[y]=h.y,v=Math.min(v,h.x),b=Math.min(b,h.y),_=Math.max(_,h.x),A=Math.max(A,h.y))),a.st&&(v<0||b<0||1<_||1<A))for(var C=0;C<p.length;C+=2)p[C]=(p[C]-v)/(_-v),p[C+1]=(p[C+1]-b)/(A-b);var R=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=Rt,c=Ct,m=wt;if(e.normal||e.tangent||e.bitangent)for(var d=0;d<n;d+=3){var p=pt.Cartesian3.fromArray(t,d,xt),g=l+1,y=l+2;m=a.geodeticSurfaceNormal(p,m),(e.tangent||e.bitangent)&&(pt.Cartesian3.cross(pt.Cartesian3.UNIT_Z,m,c),k.Matrix3.multiplyByVector(r,c,c),pt.Cartesian3.normalize(c,c),e.bitangent&&pt.Cartesian3.normalize(pt.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 Et(e,{positions:t,normals:i,tangents:o,bitangents:s})}(d,a,r,e.tangentRotationMatrix),E=6*(i-1)*(c-1);o&&(E+=3*(i-1)),s&&(E+=3*(i-1));var F,G=ht.IndexDatatype.createTypedArray(m,E),P=0,V=0;for(F=0;F<c-1;++F){for(var L=0;L<i-1;++L){var D=P+i,M=D+1,T=P+1;G[V++]=P,G[V++]=D,G[V++]=T,G[V++]=T,G[V++]=D,G[V++]=M,++P}++P}if(o||s){var O,N,S=m-1,I=m-1;if(o&&s&&(S=m-2),P=0,o)for(F=0;F<i-1;F++)N=(O=P)+1,G[V++]=S,G[V++]=O,G[V++]=N,++P;if(s)for(P=(c-1)*i,F=0;F<i-1;F++)N=(O=P)+1,G[V++]=O,G[V++]=I,G[V++]=N,++P}return R.indices=G,a.st&&(R.attributes.st=new yt.GeometryAttribute({componentDatatype:gt.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:p})),R}function Vt(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 Lt(t,e,a,