2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
|
define(["exports","./GeometryOffsetAttribute-ed56ff58","./Transforms-99272364","./Matrix2-e3fb4559","./Cartesian3-7e9cc2ff","./Check-741c5f3c","./ComponentDatatype-aaeec80f","./defaultValue-81eec7ed","./EllipseGeometryLibrary-2e1ed447","./GeometryAttribute-088ad91d","./GeometryAttributes-32b29525","./GeometryInstance-ce434bcb","./GeometryPipeline-1165e4c4","./IndexDatatype-f1e3f799","./Math-5f585871","./Matrix4-d34187af","./VertexFormat-d50a69ba"],(function(t,e,i,r,n,o,a,s,l,u,m,c,p,y,d,f,A){"use strict";const x=new n.Cartesian3,h=new n.Cartesian3,g=new n.Cartesian3,_=new n.Cartesian3,b=new r.Cartesian2,C=new f.Matrix3,w=new f.Matrix3,M=new i.Quaternion,E=new n.Cartesian3,I=new n.Cartesian3,T=new n.Cartesian3,G=new r.Cartographic,N=new n.Cartesian3,P=new r.Cartesian2,F=new r.Cartesian2;function v(t,o,c){const p=o.vertexFormat,y=o.center,d=o.semiMajorAxis,A=o.semiMinorAxis,_=o.ellipsoid,v=o.stRotation,V=c?t.length/3*2:t.length/3,D=o.shadowVolume,O=p.st?new Float32Array(2*V):void 0,S=p.normal?new Float32Array(3*V):void 0,L=p.tangent?new Float32Array(3*V):void 0,R=p.bitangent?new Float32Array(3*V):void 0,j=D?new Float32Array(3*V):void 0;let k=0,z=E,B=I,Y=T;const H=new i.GeographicProjection(_),U=H.project(_.cartesianToCartographic(y,G),N),Q=_.scaleToGeodeticSurface(y,x);_.geodeticSurfaceNormal(Q,Q);let W=C,J=w;if(0!==v){let t=i.Quaternion.fromAxisAngle(Q,v,M);W=f.Matrix3.fromQuaternion(t,W),t=i.Quaternion.fromAxisAngle(Q,-v,M),J=f.Matrix3.fromQuaternion(t,J)}else W=f.Matrix3.clone(f.Matrix3.IDENTITY,W),J=f.Matrix3.clone(f.Matrix3.IDENTITY,J);const q=r.Cartesian2.fromElements(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,P),Z=r.Cartesian2.fromElements(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,F);let K=t.length;const X=c?K:0,$=X/3*2;for(let e=0;e<K;e+=3){const i=e+1,r=e+2,o=n.Cartesian3.fromArray(t,e,x);if(p.st){const t=f.Matrix3.multiplyByVector(W,o,h),e=H.project(_.cartesianToCartographic(t,G),g);n.Cartesian3.subtract(e,U,e),b.x=(e.x+d)/(2*d),b.y=(e.y+A)/(2*A),q.x=Math.min(b.x,q.x),q.y=Math.min(b.y,q.y),Z.x=Math.max(b.x,Z.x),Z.y=Math.max(b.y,Z.y),c&&(O[k+$]=b.x,O[k+1+$]=b.y),O[k++]=b.x,O[k++]=b.y}(p.normal||p.tangent||p.bitangent||D)&&(z=_.geodeticSurfaceNormal(o,z),D&&(j[e+X]=-z.x,j[i+X]=-z.y,j[r+X]=-z.z),(p.normal||p.tangent||p.bitangent)&&((p.tangent||p.bitangent)&&(B=n.Cartesian3.normalize(n.Cartesian3.cross(n.Cartesian3.UNIT_Z,z,B),B),f.Matrix3.multiplyByVector(J,B,B)),p.normal&&(S[e]=z.x,S[i]=z.y,S[r]=z.z,c&&(S[e+X]=-z.x,S[i+X]=-z.y,S[r+X]=-z.z)),p.tangent&&(L[e]=B.x,L[i]=B.y,L[r]=B.z,c&&(L[e+X]=-B.x,L[i+X]=-B.y,L[r+X]=-B.z)),p.bitangent&&(Y=n.Cartesian3.normalize(n.Cartesian3.cross(z,B,Y),Y),R[e]=Y.x,R[i]=Y.y,R[r]=Y.z,c&&(R[e+X]=Y.x,R[i+X]=Y.y,R[r+X]=Y.z))))}if(p.st){K=O.length;for(let t=0;t<K;t+=2)O[t]=(O[t]-q.x)/(Z.x-q.x),O[t+1]=(O[t+1]-q.y)/(Z.y-q.y)}const tt=new m.GeometryAttributes;if(p.position){const e=l.EllipseGeometryLibrary.raisePositionsToHeight(t,o,c);tt.position=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e})}if(p.st&&(tt.st=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:O})),p.normal&&(tt.normal=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:S})),p.tangent&&(tt.tangent=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),p.bitangent&&(tt.bitangent=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:R})),D&&(tt.extrudeDirection=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:j})),c&&s.defined(o.offsetAttribute)){let t=new Uint8Array(V);if(o.offsetAttribute===e.GeometryOffsetAttribute.TOP)t=e.arrayFill(t,1,0,V/2);else{const i=o.offsetAttribute===e.GeometryOffsetAttribute.NONE?0:1;t=e.arrayFill(t,i)}tt.applyOffset=new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:t})}return tt}function V(t){const e=new Array(t*(t+1)*12-6
|