2 lines
6.5 KiB
JavaScript
2 lines
6.5 KiB
JavaScript
/* 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","./IndexDatatype-79bb407c","./IntersectionTests-459f6f08","./Plane-46b5436f","./VertexFormat-fe64931e","./arrayRemoveDuplicates-d96adeb6","./EllipsoidRhumbLine-357c11e7","./EllipsoidGeodesic-007422da","./PolylinePipeline-be169602","./WallGeometryLibrary-ebaee328"],function(Y,d,Z,j,K,e,t,Q,X,$,ee,i,r,u,a,n,o,s,te){"use strict";var ie=new j.Cartesian3,re=new j.Cartesian3,ae=new j.Cartesian3,ne=new j.Cartesian3,oe=new j.Cartesian3,se=new j.Cartesian3,me=new j.Cartesian3;function f(e){var t=(e=Y.defaultValue(e,Y.defaultValue.EMPTY_OBJECT)).positions,i=e.maximumHeights,r=e.minimumHeights;if(!Y.defined(t))throw new d.DeveloperError("options.positions is required.");if(Y.defined(i)&&i.length!==t.length)throw new d.DeveloperError("options.positions and options.maximumHeights must have the same length.");if(Y.defined(r)&&r.length!==t.length)throw new d.DeveloperError("options.positions and options.minimumHeights must have the same length.");var a=Y.defaultValue(e.vertexFormat,u.VertexFormat.DEFAULT),n=Y.defaultValue(e.granularity,Z.CesiumMath.RADIANS_PER_DEGREE),o=Y.defaultValue(e.ellipsoid,j.Ellipsoid.WGS84);this._positions=t,this._minimumHeights=r,this._maximumHeights=i,this._vertexFormat=u.VertexFormat.clone(a),this._granularity=n,this._ellipsoid=j.Ellipsoid.clone(o),this._workerName="createWallGeometry";var s=1+t.length*j.Cartesian3.packedLength+2;Y.defined(r)&&(s+=r.length),Y.defined(i)&&(s+=i.length),this.packedLength=s+j.Ellipsoid.packedLength+u.VertexFormat.packedLength+1}f.pack=function(e,t,i){if(!Y.defined(e))throw new d.DeveloperError("value is required");if(!Y.defined(t))throw new d.DeveloperError("array is required");var r;i=Y.defaultValue(i,0);var a=e._positions,n=a.length;for(t[i++]=n,r=0;r<n;++r,i+=j.Cartesian3.packedLength)j.Cartesian3.pack(a[r],t,i);var o=e._minimumHeights,n=Y.defined(o)?o.length:0;if(t[i++]=n,Y.defined(o))for(r=0;r<n;++r)t[i++]=o[r];var s=e._maximumHeights;if(n=Y.defined(s)?s.length:0,t[i++]=n,Y.defined(s))for(r=0;r<n;++r)t[i++]=s[r];return j.Ellipsoid.pack(e._ellipsoid,t,i),i+=j.Ellipsoid.packedLength,u.VertexFormat.pack(e._vertexFormat,t,i),t[i+=u.VertexFormat.packedLength]=e._granularity,t};var c=j.Ellipsoid.clone(j.Ellipsoid.UNIT_SPHERE),h=new u.VertexFormat,g={positions:void 0,minimumHeights:void 0,maximumHeights:void 0,ellipsoid:c,vertexFormat:h,granularity:void 0};return f.unpack=function(e,t,i){if(!Y.defined(e))throw new d.DeveloperError("array is required");t=Y.defaultValue(t,0);for(var r,a,n=e[t++],o=new Array(n),s=0;s<n;++s,t+=j.Cartesian3.packedLength)o[s]=j.Cartesian3.unpack(e,t);if(0<(n=e[t++]))for(r=new Array(n),s=0;s<n;++s)r[s]=e[t++];if(0<(n=e[t++]))for(a=new Array(n),s=0;s<n;++s)a[s]=e[t++];var m=j.Ellipsoid.unpack(e,t,c);t+=j.Ellipsoid.packedLength;var l=u.VertexFormat.unpack(e,t,h),p=e[t+=u.VertexFormat.packedLength];return Y.defined(i)?(i._positions=o,i._minimumHeights=r,i._maximumHeights=a,i._ellipsoid=j.Ellipsoid.clone(m,i._ellipsoid),i._vertexFormat=u.VertexFormat.clone(l,i._vertexFormat),i._granularity=p,i):(g.positions=o,g.minimumHeights=r,g.maximumHeights=a,g.granularity=p,new f(g))},f.fromConstantHeights=function(e){var t=(e=Y.defaultValue(e,Y.defaultValue.EMPTY_OBJECT)).positions;if(!Y.defined(t))throw new d.DeveloperError("options.positions is required.");var i=e.minimumHeight,r=e.maximumHeight,a=Y.defined(i),n=Y.defined(r);if(a||n)for(var o=t.length,s=a?new Array(o):void 0,m=n?new Array(o):void 0,l=0;l<o;++l)a&&(s[l]=i),n&&(m[l]=r);return new f({positions:t,maximumHeights:m,minimumHeights:s,ellipsoid:e.ellipsoid,vertexFormat:e.vertexFormat})},f.createGeometry=function(e){var t=e._positions,i=e._minimumHeights,r=e._maximumHeights,a=e._vertexFormat,n=e._granularity,o=e._ellipsoid,s=te.WallGeometryLibrary.computePositions(o,t,r,i,n,!0);if(Y.defined(s)){for(var m=s.bottomPositions,l=s.topPositions,p=s.numCorners,d=l.length,u=2*d,f=a.position?new Float64Array(u):void 0,c=a.normal?new Float32Array(u):void 0,h=a.tangent?new Float32Array(u):void 0,g=a.bitangent?new Float32Array(u):void 0,y=a.st?new Float32Array(u/3*2):void 0,v=0,C=0,w=0,b=0,x=0,E=me,A=se,_=oe,F=!0,D=0,L=1/((d/=3)-p-1),H=0;H<d;++H){var k,V,G,P,T=3*H,z=j.Cartesian3.fromArray(l,T,ie),O=j.Cartesian3.fromArray(m,T,re);a.position&&(f[v++]=O.x,f[v++]=O.y,f[v++]=O.z,f[v++]=z.x,f[v++]=z.y,f[v++]=z.z),a.st&&(y[x++]=D,y[x++]=0,y[x++]=D,y[x++]=1),(a.normal||a.tangent||a.bitangent)&&(k=j.Cartesian3.clone(j.Cartesian3.ZERO,ne),V=j.Cartesian3.subtract(z,o.geodeticSurfaceNormal(z,re),re),H+1<d&&(k=j.Cartesian3.fromArray(l,3+T,ne)),F&&(G=j.Cartesian3.subtract(k,z,ae),P=j.Cartesian3.subtract(V,z,ie),E=j.Cartesian3.normalize(j.Cartesian3.cross(P,G,E),E),F=!1),j.Cartesian3.equalsEpsilon(z,k,Z.CesiumMath.EPSILON10)?F=!0:(D+=L,a.tangent&&(A=j.Cartesian3.normalize(j.Cartesian3.subtract(k,z,A),A)),a.bitangent&&(_=j.Cartesian3.normalize(j.Cartesian3.cross(E,A,_),_))),a.normal&&(c[C++]=E.x,c[C++]=E.y,c[C++]=E.z,c[C++]=E.x,c[C++]=E.y,c[C++]=E.z),a.tangent&&(h[b++]=A.x,h[b++]=A.y,h[b++]=A.z,h[b++]=A.x,h[b++]=A.y,h[b++]=A.z),a.bitangent&&(g[w++]=_.x,g[w++]=_.y,g[w++]=_.z,g[w++]=_.x,g[w++]=_.y,g[w++]=_.z))}var R=new $.GeometryAttributes;a.position&&(R.position=new X.GeometryAttribute({componentDatatype:Q.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:f})),a.normal&&(R.normal=new X.GeometryAttribute({componentDatatype:Q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:c})),a.tangent&&(R.tangent=new X.GeometryAttribute({componentDatatype:Q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:h})),a.bitangent&&(R.bitangent=new X.GeometryAttribute({componentDatatype:Q.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:g})),a.st&&(R.st=new X.GeometryAttribute({componentDatatype:Q.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:y}));var S=u/3;u-=6*(p+1);var I=ee.IndexDatatype.createTypedArray(S,u),q=0;for(H=0;H<S-2;H+=2){var N,M,W=H,B=H+2,U=j.Cartesian3.fromArray(f,3*W,ie),J=j.Cartesian3.fromArray(f,3*B,re);j.Cartesian3.equalsEpsilon(U,J,Z.CesiumMath.EPSILON10)||(N=H+1,M=H+3,I[q++]=N,I[q++]=W,I[q++]=M,I[q++]=M,I[q++]=W,I[q++]=B)}return new X.Geometry({attributes:R,indices:I,primitiveType:X.PrimitiveType.TRIANGLES,boundingSphere:new K.BoundingSphere.fromVertices(f)})}},function(e,t){return Y.defined(t)&&(e=f.unpack(e,t)),e._ellipsoid=j.Ellipsoid.clone(e._ellipsoid),f.createGeometry(e)}}); |