bmh_cesium/public/lib/cesiumjs/CesiumUnminified/Workers/createRectangleGeometry.js

2 lines
16 KiB
JavaScript
Raw Normal View History

2025-03-09 23:23:50 +00:00
/* 2020-9-22 15:23:25 | 版权所有 军懋国兴 */
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./GeometryAttributes-90846c5f","./AttributeCompression-ea810287","./GeometryPipeline-1ea64cde","./EncodedCartesian3-29a09d7b","./IndexDatatype-79bb407c","./IntersectionTests-459f6f08","./Plane-46b5436f","./GeometryOffsetAttribute-9c676324","./VertexFormat-fe64931e","./GeometryInstance-6264cc0f","./EllipsoidRhumbLine-357c11e7","./PolygonPipeline-2ee85025","./RectangleGeometryLibrary-f62aa487"],function(mt,g,pt,gt,I,t,e,dt,yt,r,a,ft,n,ht,o,i,vt,bt,_t,s,At,H){"use strict";var wt=new gt.Cartesian3,xt=new gt.Cartesian3,Ct=new gt.Cartesian3,Rt=new gt.Cartesian3,_=new gt.Rectangle,z=new gt.Cartesian2,A=new I.BoundingSphere,w=new I.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:dt.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(a.attributes.normal=new yt.GeometryAttribute({componentDatatype:dt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(a.attributes.tangent=new yt.GeometryAttribute({componentDatatype:dt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(a.attributes.bitangent=new yt.GeometryAttribute({componentDatatype:dt.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.bitangents})),a}var Ft=new gt.Cartesian3,Gt=new gt.Cartesian3;function Pt(t,e){var a=t._vertexFormat,r=t._ellipsoid,n=e.height,o=e.width,i=e.northCap,s=e.southCap,l=0,u=n,c=n,m=0;i&&(--c,m+=l=1),s&&(--u,--c,m+=1),m+=o*c;for(var p=a.position?new Float64Array(3*m):void 0,g=a.st?new Float32Array(2*m):void 0,d=0,y=0,f=wt,h=z,v=Number.MAX_VALUE,b=Number.MAX_VALUE,_=-Number.MAX_VALUE,A=-Number.MAX_VALUE,w=l;w<u;++w)for(var x=0;x<o;++x)H.RectangleGeometryLibrary.computePosition(e,r,a.st,w,x,f,h),p[d++]=f.x,p[d++]=f.y,p[d++]=f.z,a.st&&(g[y++]=h.x,g[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(i&&(H.RectangleGeometryLibrary.computePosition(e,r,a.st,0,0,f,h),p[d++]=f.x,p[d++]=f.y,p[d++]=f.z,a.st&&(g[y++]=h.x,g[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),p[d++]=f.x,p[d++]=f.y,p[d]=f.z,a.st&&(g[y++]=h.x,g[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<g.length;C+=2)g[C]=(g[C]-v)/(_-v),g[C+1]=(g[C+1]-b)/(A-b);var R=function(t,e,a,r){var n=t.length,o=e.normal?new Float32Array(n):void 0,i=e.tangent?new Float32Array(n):void 0,s=e.bitangent?new Float32Array(n):void 0,l=0,u=Rt,c=Ct,m=xt;if(e.normal||e.tangent||e.bitangent)for(var p=0;p<n;p+=3){var g=gt.Cartesian3.fromArray(t,p,wt),d=l+1,y=l+2,m=a.geodeticSurfaceNormal(g,m);(e.tangent||e.bitangent)&&(gt.Cartesian3.cross(gt.Cartesian3.UNIT_Z,m,c),I.Matrix3.multiplyByVector(r,c,c),gt.Cartesian3.normalize(c,c),e.bitangent&&gt.Cartesian3.normalize(gt.Cartesian3.cross(m,c,u),u)),e.normal&&(o[l]=m.x,o[d]=m.y,o[y]=m.z),e.tangent&&(i[l]=c.x,i[d]=c.y,i[y]=c.z),e.bitangent&&(s[l]=u.x,s[d]=u.y,s[y]=u.z),l+=3}return Et(e,{positions:t,normals:o,tangents:i,bitangents:s})}(p,a,r,e.tangentRotationMatrix),E=6*(o-1)*(c-1);i&&(E+=3*(o-1)),s&&(E+=3*(o-1));for(var F=ht.IndexDatatype.createTypedArray(m,E),G=0,P=0,V=0;V<c-1;++V){for(var D=0;D<o-1;++D){var L=G+o,M=L+1,O=G+1;F[P++]=G,F[P++]=L,F[P++]=O,F[P++]=O,F[P++]=L,F[P++]=M,++G}++G}if(i||s){var T,N,k=m-1,S=m-1;if(i&&s&&(k=m-2),G=0,i)for(V=0;V<o-1;V++)N=(T=G)+1,F[P++]=k,F[P++]=T,F[P++]=N,++G;if(s)for(G=(c-1)*o,V=0;V<o-1;V++)N=(T=G)+1,F[P++]=T,F[P++]=S,F[P++]=N,++G}return R.indices=F,a.st&&(R.attributes.st=new yt.GeometryAttribute({componentDatatype:dt.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:g})),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 Dt(t,e,a,r)