createPolylineVolumeGeometry.js 7.0 KB

1
  1. define(["./defaultValue-81eec7ed","./Matrix2-e3fb4559","./arrayRemoveDuplicates-85770175","./BoundingRectangle-b88064b7","./Transforms-98ffa11d","./Cartesian3-7e9cc2ff","./ComponentDatatype-aaeec80f","./PolylineVolumeGeometryLibrary-22aaee12","./Check-741c5f3c","./GeometryAttribute-b025f9a8","./GeometryAttributes-32b29525","./GeometryPipeline-4b426993","./IndexDatatype-f1e3f799","./Math-5f585871","./Matrix4-d34187af","./PolygonPipeline-6f83d8b1","./VertexFormat-d50a69ba","./_commonjsHelpers-3aae1032-26891ab7","./combine-3c023bda","./RuntimeError-26acdd3b","./WebGLConstants-508b9636","./EllipsoidTangentPlane-fa1337e1","./AxisAlignedBoundingBox-37250ed6","./IntersectionTests-73b87d72","./Plane-4f75b3df","./PolylinePipeline-de59c85a","./EllipsoidGeodesic-6de45192","./EllipsoidRhumbLine-9c6b32ea","./AttributeCompression-e2e3f0dd","./EncodedCartesian3-aac44514"],(function(e,t,n,o,i,r,a,l,s,d,c,p,m,u,g,y,h,f,x,b,P,_,E,L,T,F,G,k,v,C){"use strict";const w={};function V(t,n){e.defined(w[t])||(w[t]=!0)}function A(t,n,o,l,s,u,h){const f=new c.GeometryAttributes;l.position&&(f.position=new d.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:t}));const x=n.length,b=t.length/3;let P=(b-2*x)/(2*x);const _=y.PolygonPipeline.triangulate(n),E=(P-1)*x*6+2*_.length,L=m.IndexDatatype.createTypedArray(b,E);let T,F,G,k,v,C;const w=2*x;let A=0;for(T=0;T<P-1;T++){for(F=0;F<x-1;F++)G=2*F+T*x*2,C=G+w,k=G+1,v=k+w,L[A++]=k,L[A++]=G,L[A++]=v,L[A++]=v,L[A++]=G,L[A++]=C;G=2*x-2+T*x*2,k=G+1,v=k+w,C=G+w,L[A++]=k,L[A++]=G,L[A++]=v,L[A++]=v,L[A++]=G,L[A++]=C}if(l.st||l.tangent||l.bitangent){const e=new Float32Array(2*b),t=1/(P-1),i=1/o.height,r=o.height/2;let l,s,c=0;for(T=0;T<P;T++){for(l=T*t,s=i*(n[0].y+r),e[c++]=l,e[c++]=s,F=1;F<x;F++)s=i*(n[F].y+r),e[c++]=l,e[c++]=s,e[c++]=l,e[c++]=s;s=i*(n[0].y+r),e[c++]=l,e[c++]=s}for(F=0;F<x;F++)l=0,s=i*(n[F].y+r),e[c++]=l,e[c++]=s;for(F=0;F<x;F++)l=(P-1)*t,s=i*(n[F].y+r),e[c++]=l,e[c++]=s;f.st=new d.GeometryAttribute({componentDatatype:a.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:new Float32Array(e)})}const M=b-2*x;for(T=0;T<_.length;T+=3){const e=_[T]+M,t=_[T+1]+M,n=_[T+2]+M;L[A++]=e,L[A++]=t,L[A++]=n,L[A++]=n+x,L[A++]=t+x,L[A++]=e+x}const R=function(t,n,o){const i=[],a=new g.Matrix4;e.defined(n)&&!n.equals(new g.Matrix4)&&g.Matrix4.inverse(n,a);for(let e=0;e<t.length/3;e++){const n=new r.Cartesian3(t[3*e],t[3*e+1],t[3*e+2]);1!==o&&g.Matrix4.multiplyByPoint(a,n,n),i.push(n.x,n.y,n.z)}const l=new r.Cartesian3(-1/0,-1/0,-1/0),s=new r.Cartesian3(1/0,1/0,1/0);for(let e=0;e<i.length/3;e++){const t=new r.Cartesian3(i[3*e],i[3*e+1],i[3*e+2]);l.x=Math.max(l.x,t.x),l.y=Math.max(l.y,t.y),l.z=Math.max(l.z,t.z),s.x=Math.min(s.x,t.x),s.y=Math.min(s.y,t.y),s.z=Math.min(s.z,t.z)}return[l,s]}(t,s,h);let D=new d.Geometry({attributes:f,indices:L,boundingSphere:i.BoundingSphere.fromVertices(t),MaxPoint:R[0],MinPoint:R[1],primitiveType:d.PrimitiveType.TRIANGLES});if(l.normal&&(D=p.GeometryPipeline.computeNormal(D,1===h?s:void 0)),l.tangent||l.bitangent){try{D=p.GeometryPipeline.computeTangentAndBitangent(D)}catch(e){V("polyline-volume-tangent-bitangent")}l.tangent||(D.attributes.tangent=void 0),l.bitangent||(D.attributes.bitangent=void 0),l.st||(D.attributes.st=void 0)}return D}function M(n){const o=(n=e.defaultValue(n,e.defaultValue.EMPTY_OBJECT)).polylinePositions,i=n.shapePositions;let a;this._positions=o,this._shape=i,this._ellipsoid=t.Ellipsoid.clone(e.defaultValue(n.ellipsoid,t.Ellipsoid.WGS84)),this._cornerType=e.defaultValue(n.cornerType,l.CornerType.ROUNDED),this._vertexFormat=h.VertexFormat.clone(e.defaultValue(n.vertexFormat,h.VertexFormat.DEFAULT)),this._granularity=e.defaultValue(n.granularity,u.CesiumMath.RADIANS_PER_DEGREE),e.defined(n.id)&&(a=n.id._polylineVolume.RootTransform,this._rootTransform=a),n.rootTransform&&(this._rootTransform=n.rootTransform),e.defined(n.isFromGLP)&&(this._isFromGLP=n.isFromGLP),this._workerName="createPolylineVolumeGeometry";let s=1+o.length*r.Cartesian3.packedLength;s+=1+i.length*t.Cartesian2.packedLength,e.defined(a)&&(s+=1+a.length),e.defined(n.rootTransform)&&(s+=1+n.rootTransform.length),e.defined(n.isFromGLP)&&(s+=1),this.packedLength=s+t.Ellipsoid.packedLength+h.VertexFormat.packedLength+2}V.geometryOutlines="Entity geometry outlines are unsupported on terrain. Outlines will be disabled. To enable outlines, disable geometry terrain clamping by explicitly setting height to 0.",V.geometryZIndex="Entity geometry with zIndex are unsupported when height or extrudedHeight are defined. zIndex will be ignored",V.geometryHeightReference="Entity corridor, ellipse, polygon or rectangle with heightReference must also have a defined height. heightReference will be ignored",V.geometryExtrudedHeightReference="Entity corridor, ellipse, polygon or rectangle with extrudedHeightReference must also have a defined extrudedHeight. extrudedHeightReference will be ignored",M.pack=function(n,o,i){let a;i=e.defaultValue(i,0);const l=n._positions;let s=l.length;for(o[i++]=s,a=0;a<s;++a,i+=r.Cartesian3.packedLength)r.Cartesian3.pack(l[a],o,i);const d=n._shape;for(s=d.length,o[i++]=s,a=0;a<s;++a,i+=t.Cartesian2.packedLength)t.Cartesian2.pack(d[a],o,i);t.Ellipsoid.pack(n._ellipsoid,o,i),i+=t.Ellipsoid.packedLength,h.VertexFormat.pack(n._vertexFormat,o,i),i+=h.VertexFormat.packedLength,o[i++]=n._cornerType,o[i++]=n._granularity;const c=n._rootTransform;return e.defined(c)&&(g.Matrix4.pack(c,o,i++),i+=15),e.defined(n._isFromGLP)&&(o[i++]=n._isFromGLP),o};const R=t.Ellipsoid.clone(t.Ellipsoid.UNIT_SPHERE),D=new h.VertexFormat,B={polylinePositions:void 0,shapePositions:void 0,ellipsoid:R,vertexFormat:D,cornerType:void 0,granularity:void 0};M.unpack=function(n,o,i){let a;o=e.defaultValue(o,0);let l=n[o++];const s=new Array(l);for(a=0;a<l;++a,o+=r.Cartesian3.packedLength)s[a]=r.Cartesian3.unpack(n,o);l=n[o++];const d=new Array(l);for(a=0;a<l;++a,o+=t.Cartesian2.packedLength)d[a]=t.Cartesian2.unpack(n,o);const c=t.Ellipsoid.unpack(n,o,R);o+=t.Ellipsoid.packedLength;const p=h.VertexFormat.unpack(n,o,D);o+=h.VertexFormat.packedLength;const m=n[o++],u=n[o++];var y,f=new g.Matrix4;return n.length>o&&(g.Matrix4.unpack(n,o++,f),o+=15),y=n.length>o?n[o++]:0,e.defined(i)?(i._positions=s,i._shape=d,i._ellipsoid=t.Ellipsoid.clone(c,i._ellipsoid),i._vertexFormat=h.VertexFormat.clone(p,i._vertexFormat),i._cornerType=m,i._granularity=u,i._rootTransform=f,i._isFromGLP=y,i):(B.polylinePositions=s,B.shapePositions=d,B.cornerType=m,B.granularity=u,B.rootTransform=f,B.isFromGLP=y,new M(B))};const I=new o.BoundingRectangle;return M.createGeometry=function(e){const t=e._positions,i=n.arrayRemoveDuplicates(t,r.Cartesian3.equalsEpsilon);let a=e._shape;if(a=l.PolylineVolumeGeometryLibrary.removeDuplicatesFromShape(a),i.length<2||a.length<3)return;y.PolygonPipeline.computeWindingOrder2D(a)===y.WindingOrder.CLOCKWISE&&a.reverse();const s=o.BoundingRectangle.fromPoints(a,I);return A(l.PolylineVolumeGeometryLibrary.computePositions(i,a,s,e,!0),a,s,e._vertexFormat,e._rootTransform,0,e._isFromGLP)},function(n,o){return e.defined(o)&&(n=M.unpack(n,o)),n._ellipsoid=t.Ellipsoid.clone(n._ellipsoid),M.createGeometry(n)}}));