2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
|
define(["./defaultValue-81eec7ed","./Matrix2-e3fb4559","./GeometryOffsetAttribute-ed56ff58","./Transforms-98ffa11d","./Cartesian3-7e9cc2ff","./Check-741c5f3c","./ComponentDatatype-aaeec80f","./GeometryAttribute-b025f9a8","./GeometryAttributes-32b29525","./GeometryInstance-ce434bcb","./GeometryPipeline-4b426993","./IndexDatatype-f1e3f799","./Math-5f585871","./Matrix4-d34187af","./PolygonPipeline-6f83d8b1","./RectangleGeometryLibrary-193b0cdb","./VertexFormat-d50a69ba","./_commonjsHelpers-3aae1032-26891ab7","./combine-3c023bda","./RuntimeError-26acdd3b","./WebGLConstants-508b9636","./AttributeCompression-e2e3f0dd","./EncodedCartesian3-aac44514","./IntersectionTests-73b87d72","./Plane-4f75b3df","./EllipsoidRhumbLine-9c6b32ea"],(function(t,e,n,a,o,r,i,s,l,u,c,m,d,p,g,y,f,h,b,_,A,x,w,C,v,R){"use strict";const E=new o.Cartesian3,F=new o.Cartesian3,G=new o.Cartesian3,P=new o.Cartesian3,V=new e.Rectangle,L=new e.Cartesian2,D=new a.BoundingSphere,M=new a.BoundingSphere;function T(t,e){const n=new s.Geometry({attributes:new l.GeometryAttributes,primitiveType:s.PrimitiveType.TRIANGLES});return n.attributes.position=new s.GeometryAttribute({componentDatatype:i.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(n.attributes.normal=new s.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(n.attributes.tangent=new s.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(n.attributes.bitangent=new s.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:e.bitangents})),n}const O=new o.Cartesian3,N=new o.Cartesian3;function S(t,e){const n=t._vertexFormat,a=t._ellipsoid,r=e.height,l=e.width,u=e.northCap,c=e.southCap;let d=0,g=r,f=r,h=0;u&&(d=1,f-=1,h+=1),c&&(g-=1,f-=1,h+=1),h+=l*f;const b=n.position?new Float64Array(3*h):void 0,_=n.st?new Float32Array(2*h):void 0;let A=0,x=0;const w=E,C=L;let v=Number.MAX_VALUE,R=Number.MAX_VALUE,V=-Number.MAX_VALUE,D=-Number.MAX_VALUE;for(let t=d;t<g;++t)for(let o=0;o<l;++o)y.RectangleGeometryLibrary.computePosition(e,a,n.st,t,o,w,C),b[A++]=w.x,b[A++]=w.y,b[A++]=w.z,n.st&&(_[x++]=C.x,_[x++]=C.y,v=Math.min(v,C.x),R=Math.min(R,C.y),V=Math.max(V,C.x),D=Math.max(D,C.y));if(u&&(y.RectangleGeometryLibrary.computePosition(e,a,n.st,0,0,w,C),b[A++]=w.x,b[A++]=w.y,b[A++]=w.z,n.st&&(_[x++]=C.x,_[x++]=C.y,v=C.x,R=C.y,V=C.x,D=C.y)),c&&(y.RectangleGeometryLibrary.computePosition(e,a,n.st,r-1,0,w,C),b[A++]=w.x,b[A++]=w.y,b[A]=w.z,n.st&&(_[x++]=C.x,_[x]=C.y,v=Math.min(v,C.x),R=Math.min(R,C.y),V=Math.max(V,C.x),D=Math.max(D,C.y))),n.st&&(v<0||R<0||V>1||D>1))for(let t=0;t<_.length;t+=2)_[t]=(_[t]-v)/(V-v),_[t+1]=(_[t+1]-R)/(D-R);const M=function(t,e,n,a){const r=t.length,i=e.normal?new Float32Array(r):void 0,s=e.tangent?new Float32Array(r):void 0,l=e.bitangent?new Float32Array(r):void 0;let u=0;const c=P,m=G;let d=F;if(e.normal||e.tangent||e.bitangent)for(let g=0;g<r;g+=3){const r=o.Cartesian3.fromArray(t,g,E),y=u+1,f=u+2;d=n.geodeticSurfaceNormal(r,d),(e.tangent||e.bitangent)&&(o.Cartesian3.cross(o.Cartesian3.UNIT_Z,d,m),p.Matrix3.multiplyByVector(a,m,m),o.Cartesian3.normalize(m,m),e.bitangent&&o.Cartesian3.normalize(o.Cartesian3.cross(d,m,c),c)),e.normal&&(i[u]=d.x,i[y]=d.y,i[f]=d.z),e.tangent&&(s[u]=m.x,s[y]=m.y,s[f]=m.z),e.bitangent&&(l[u]=c.x,l[y]=c.y,l[f]=c.z),u+=3}return T(e,{positions:t,normals:i,tangents:s,bitangents:l})}(b,n,a,e.tangentRotationMatrix);let O=6*(l-1)*(f-1);u&&(O+=3*(l-1)),c&&(O+=3*(l-1));const N=m.IndexDatatype.createTypedArray(h,O);let S,I=0,k=0;for(S=0;S<f-1;++S){for(let t=0;t<l-1;++t){const t=I,e=t+l,n=e+1,a=t+1;N[k++]=t,N[k++]=e,N[k++]=a,N[k++]=a,N[k++]=e,N[k++]=n,++I}++I}if(u||c){let t=h-1;const e=h-1;let n,a;if(u&&c&&(t=h-2),I=0,u)for(S=0;S<l-1;S++)n=I,a=n+1,N[k++]=t,N[k++]=n,N[k++]=a,++I;if(c)for(I=(f-1)*l,S=0;S<l-1;S++)n=I,a=n+1,N[k++]=n,N[k++]=e,N[k++]=a,++I}return M.indices=N,n.st&&(M.attributes.st=new s.GeometryAttribute({componentDatatype:i.ComponentDatatype.FLOAT,componentsPerAttr
|