createWallGeometry.js 6.0 KB

1
  1. define(["./defaultValue-81eec7ed","./Matrix2-e3fb4559","./Transforms-98ffa11d","./Cartesian3-7e9cc2ff","./ComponentDatatype-aaeec80f","./Check-741c5f3c","./GeometryAttribute-b025f9a8","./GeometryAttributes-32b29525","./IndexDatatype-f1e3f799","./Math-5f585871","./VertexFormat-d50a69ba","./WallGeometryLibrary-dfadd129","./Matrix4-d34187af","./RuntimeError-26acdd3b","./_commonjsHelpers-3aae1032-26891ab7","./combine-3c023bda","./WebGLConstants-508b9636","./arrayRemoveDuplicates-85770175","./PolylinePipeline-de59c85a","./EllipsoidGeodesic-6de45192","./EllipsoidRhumbLine-9c6b32ea","./IntersectionTests-73b87d72","./Plane-4f75b3df"],(function(e,t,n,i,a,o,r,s,l,m,u,c,d,p,f,y,g,h,C,b,x,A,_){"use strict";const E=new i.Cartesian3,w=new i.Cartesian3,F=new i.Cartesian3,v=new i.Cartesian3,L=new i.Cartesian3,k=new i.Cartesian3,H=new i.Cartesian3;function V(n){const a=(n=e.defaultValue(n,e.defaultValue.EMPTY_OBJECT)).positions,o=n.maximumHeights,r=n.minimumHeights,s=e.defaultValue(n.vertexFormat,u.VertexFormat.DEFAULT),l=e.defaultValue(n.granularity,m.CesiumMath.RADIANS_PER_DEGREE),c=e.defaultValue(n.ellipsoid,t.Ellipsoid.WGS84);this._positions=a,this._minimumHeights=r,this._maximumHeights=o,this._vertexFormat=u.VertexFormat.clone(s),this._granularity=l,this._ellipsoid=t.Ellipsoid.clone(c),this._workerName="createWallGeometry";let d=1+a.length*i.Cartesian3.packedLength+2;e.defined(r)&&(d+=r.length),e.defined(o)&&(d+=o.length),this.packedLength=d+t.Ellipsoid.packedLength+u.VertexFormat.packedLength+1}V.pack=function(n,a,o){let r;o=e.defaultValue(o,0);const s=n._positions;let l=s.length;for(a[o++]=l,r=0;r<l;++r,o+=i.Cartesian3.packedLength)i.Cartesian3.pack(s[r],a,o);const m=n._minimumHeights;if(l=e.defined(m)?m.length:0,a[o++]=l,e.defined(m))for(r=0;r<l;++r)a[o++]=m[r];const c=n._maximumHeights;if(l=e.defined(c)?c.length:0,a[o++]=l,e.defined(c))for(r=0;r<l;++r)a[o++]=c[r];return t.Ellipsoid.pack(n._ellipsoid,a,o),o+=t.Ellipsoid.packedLength,u.VertexFormat.pack(n._vertexFormat,a,o),a[o+=u.VertexFormat.packedLength]=n._granularity,a};const G=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),D=new u.VertexFormat,P={positions:void 0,minimumHeights:void 0,maximumHeights:void 0,ellipsoid:G,vertexFormat:D,granularity:void 0};return V.unpack=function(n,a,o){let r;a=e.defaultValue(a,0);let s=n[a++];const l=new Array(s);for(r=0;r<s;++r,a+=i.Cartesian3.packedLength)l[r]=i.Cartesian3.unpack(n,a);let m,c;if(s=n[a++],s>0)for(m=new Array(s),r=0;r<s;++r)m[r]=n[a++];if(s=n[a++],s>0)for(c=new Array(s),r=0;r<s;++r)c[r]=n[a++];const d=t.Ellipsoid.unpack(n,a,G);a+=t.Ellipsoid.packedLength;const p=u.VertexFormat.unpack(n,a,D),f=n[a+=u.VertexFormat.packedLength];return e.defined(o)?(o._positions=l,o._minimumHeights=m,o._maximumHeights=c,o._ellipsoid=t.Ellipsoid.clone(d,o._ellipsoid),o._vertexFormat=u.VertexFormat.clone(p,o._vertexFormat),o._granularity=f,o):(P.positions=l,P.minimumHeights=m,P.maximumHeights=c,P.granularity=f,new V(P))},V.fromConstantHeights=function(t){const n=(t=e.defaultValue(t,e.defaultValue.EMPTY_OBJECT)).positions;let i,a;const o=t.minimumHeight,r=t.maximumHeight,s=e.defined(o),l=e.defined(r);if(s||l){const e=n.length;i=s?new Array(e):void 0,a=l?new Array(e):void 0;for(let t=0;t<e;++t)s&&(i[t]=o),l&&(a[t]=r)}return new V({positions:n,maximumHeights:a,minimumHeights:i,ellipsoid:t.ellipsoid,vertexFormat:t.vertexFormat})},V.createGeometry=function(t){const o=t._positions,u=t._minimumHeights,d=t._maximumHeights,p=t._vertexFormat,f=t._granularity,y=t._ellipsoid,g=c.WallGeometryLibrary.computePositions(y,o,d,u,f,!0);if(!e.defined(g))return;const h=g.bottomPositions,C=g.topPositions,b=g.numCorners;let x=C.length,A=2*x;const _=p.position?new Float64Array(A):void 0,V=p.normal?new Float32Array(A):void 0,G=p.tangent?new Float32Array(A):void 0,D=p.bitangent?new Float32Array(A):void 0,P=p.st?new Float32Array(A/3*2):void 0;let T,z=0,O=0,R=0,S=0,I=0,M=H,N=k,W=L,B=!0;x/=3;let U=0;const q=1/(x-b-1);for(T=0;T<x;++T){const e=3*T,t=i.Cartesian3.fromArray(C,e,E),n=i.Cartesian3.fromArray(h,e,w);if(p.position&&(_[z++]=n.x,_[z++]=n.y,_[z++]=n.z,_[z++]=t.x,_[z++]=t.y,_[z++]=t.z),p.st&&(P[I++]=U,P[I++]=0,P[I++]=U,P[I++]=1),p.normal||p.tangent||p.bitangent){let n=i.Cartesian3.clone(i.Cartesian3.ZERO,v);const a=i.Cartesian3.subtract(t,y.geodeticSurfaceNormal(t,w),w);if(T+1<x&&(n=i.Cartesian3.fromArray(C,e+3,v)),B){const e=i.Cartesian3.subtract(n,t,F),o=i.Cartesian3.subtract(a,t,E);M=i.Cartesian3.normalize(i.Cartesian3.cross(o,e,M),M),B=!1}i.Cartesian3.equalsEpsilon(t,n,m.CesiumMath.EPSILON10)?B=!0:(U+=q,p.tangent&&(N=i.Cartesian3.normalize(i.Cartesian3.subtract(n,t,N),N)),p.bitangent&&(W=i.Cartesian3.normalize(i.Cartesian3.cross(M,N,W),W))),p.normal&&(V[O++]=M.x,V[O++]=M.y,V[O++]=M.z,V[O++]=M.x,V[O++]=M.y,V[O++]=M.z),p.tangent&&(G[S++]=N.x,G[S++]=N.y,G[S++]=N.z,G[S++]=N.x,G[S++]=N.y,G[S++]=N.z),p.bitangent&&(D[R++]=W.x,D[R++]=W.y,D[R++]=W.z,D[R++]=W.x,D[R++]=W.y,D[R++]=W.z)}}const J=new s.GeometryAttributes;p.position&&(J.position=new r.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:_})),p.normal&&(J.normal=new r.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:V})),p.tangent&&(J.tangent=new r.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:G})),p.bitangent&&(J.bitangent=new r.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:D})),p.st&&(J.st=new r.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:P}));const Y=A/3;A-=6*(b+1);const j=l.IndexDatatype.createTypedArray(Y,A);let Z=0;for(T=0;T<Y-2;T+=2){const e=T,t=T+2,n=i.Cartesian3.fromArray(_,3*e,E),a=i.Cartesian3.fromArray(_,3*t,w);if(i.Cartesian3.equalsEpsilon(n,a,m.CesiumMath.EPSILON10))continue;const o=T+1,r=T+3;j[Z++]=o,j[Z++]=e,j[Z++]=r,j[Z++]=r,j[Z++]=e,j[Z++]=t}return new r.Geometry({attributes:J,indices:j,primitiveType:r.PrimitiveType.TRIANGLES,boundingSphere:new n.BoundingSphere.fromVertices(_)})},function(n,i){return e.defined(i)&&(n=V.unpack(n,i)),n._ellipsoid=t.Ellipsoid.clone(n._ellipsoid),V.createGeometry(n)}}));