define(["exports","./AttributeCompression-f9ee669b","./Cartesian2-1b9b0d8a","./Cartographic-1bbcab04","./Check-3aa71481","./when-515d5295","./Math-5e38123d","./buildModuleUrl-dba4ec07","./Cartesian4-034d54d5","./ComponentDatatype-d430c7f7","./EncodedCartesian3-d74c1b81","./Intersect-53434a77","./GeometryAttribute-9bc31a7f","./IndexDatatype-eefd5922","./IntersectionTests-5fa33dbd","./PrimitiveType-b38a4004","./Plane-92c15089"],(function(e,t,r,a,n,i,o,s,u,p,l,v,c,f,y,m,d){"use strict";var h=new a.a,b=new a.a,w=new a.a;function g(e,t,s,u,p){var l,v,c,f,y,m,d,g;if(n.n.defined("point",e),n.n.defined("p0",t),n.n.defined("p1",s),n.n.defined("p2",u),i.t(p)||(p=new a.a),i.t(t.z)){if(a.a.equalsEpsilon(e,t,o.n.EPSILON14))return a.a.clone(a.a.UNIT_X,p);if(a.a.equalsEpsilon(e,s,o.n.EPSILON14))return a.a.clone(a.a.UNIT_Y,p);if(a.a.equalsEpsilon(e,u,o.n.EPSILON14))return a.a.clone(a.a.UNIT_Z,p);l=a.a.subtract(s,t,h),v=a.a.subtract(u,t,b),c=a.a.subtract(e,t,w),f=a.a.dot(l,l),y=a.a.dot(l,v),m=a.a.dot(l,c),d=a.a.dot(v,v),g=a.a.dot(v,c)}else{if(r.r.equalsEpsilon(e,t,o.n.EPSILON14))return a.a.clone(a.a.UNIT_X,p);if(r.r.equalsEpsilon(e,s,o.n.EPSILON14))return a.a.clone(a.a.UNIT_Y,p);if(r.r.equalsEpsilon(e,u,o.n.EPSILON14))return a.a.clone(a.a.UNIT_Z,p);l=r.r.subtract(s,t,h),v=r.r.subtract(u,t,b),c=r.r.subtract(e,t,w),f=r.r.dot(l,l),y=r.r.dot(l,v),m=r.r.dot(l,c),d=r.r.dot(v,v),g=r.r.dot(v,c)}p.y=d*m-y*g,p.z=f*g-y*m;var T=f*d-y*y;return 0!==p.y&&(p.y/=T),0!==p.z&&(p.z/=T),p.x=1-p.y-p.z,p}var T={calculateACMR:function(e){var t=(e=i.e(e,i.e.EMPTY_OBJECT)).indices,r=e.maximumIndex,a=i.e(e.cacheSize,24);if(!i.t(t))throw new n.t("indices is required.");var o=t.length;if(o<3||o%3!=0)throw new n.t("indices length must be a multiple of three.");if(r<=0)throw new n.t("maximumIndex must be greater than zero.");if(a<3)throw new n.t("cacheSize must be greater than two.");if(!i.t(r)){r=0;for(var s=0,u=t[s];sr&&(r=u),u=t[++s]}for(var p=[],l=0;la&&(p[t[c]]=v,++v);return(v-a+1)/(o/3)}};T.tipsify=function(e){var t,r=(e=i.e(e,i.e.EMPTY_OBJECT)).indices,a=e.maximumIndex,o=i.e(e.cacheSize,24);function s(e,r,a,n,i,o,s){for(var u,p=-1,l=-1,v=0;vl||-1===l)&&(l=u,p=c)),++v}return-1===p?function(e,r,a,n){for(;r.length>=1;){var i=r[r.length-1];if(r.splice(r.length-1,1),e[i].numLiveTriangles>0)return i}for(;t0)return++t-1;++t}return-1}(n,o,0,s):p}if(!i.t(r))throw new n.t("indices is required.");var u=r.length;if(u<3||u%3!=0)throw new n.t("indices length must be a multiple of three.");if(a<=0)throw new n.t("maximumIndex must be greater than zero.");if(o<3)throw new n.t("cacheSize must be greater than two.");var p=0,l=0,v=r[l],c=u;if(i.t(a))p=a+1;else{for(;lp&&(p=v),v=r[++l];if(-1===p)return 0;++p}var f,y=[];for(f=0;fo&&(b.timeStamp=h,++h),++l}d=s(0,o,x,y,h,A,p)}return S};var x={};function A(e,t,r,a,n){e[t++]=r,e[t++]=a,e[t++]=a,e[t++]=n,e[t++]=n,e[t]=r}function I(e){var t={};for(var r in e)if(e.hasOwnProperty(r)&&i.t(e[r])&&i.t(e[r].values)){var a=e[r];t[r]=new c.r({componentDatatype:a.componentDatatype,componentsPerAttribute:a.componentsPerAttribute,normalize:a.normalize,values:[]})}return t}function S(e,t,r){for(var a in t)if(t.hasOwnProperty(a)&&i.t(t[a])&&i.t(t[a].values))for(var n=t[a],o=0;o=3){var r=6*(t-2),a=f.IndexDatatype.createTypedArray(t,r);A(a,0,e[0],e[1],e[2]);for(var n=6,i=3;i0){for(var t=e.length-1,r=6*(t-1),a=f.IndexDatatype.createTypedArray(t,r),n=e[0],i=0,o=1;oo&&(o=r[s]);e.indices=T.tipsify({indices:r,maximumIndex:o,cacheSize:t})}return e},x.fitToUnsignedShortIndices=function(e){if(!i.t(e))throw new n.t("geometry is required.");if(i.t(e.indices)&&e.primitiveType!==m._0x38df4a.TRIANGLES&&e.primitiveType!==m._0x38df4a.LINES&&e.primitiveType!==m._0x38df4a.POINTS)throw new n.t("geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS.");var t=[],r=c.T.computeNumberOfVertices(e);if(i.t(e.indices)&&r>=o.n.SIXTY_FOUR_KILOBYTES){var a,s=[],u=[],p=0,l=I(e.attributes),v=e.indices,f=v.length;e.primitiveType===m._0x38df4a.TRIANGLES?a=3:e.primitiveType===m._0x38df4a.LINES?a=2:e.primitiveType===m._0x38df4a.POINTS&&(a=1);for(var y=0;y=o.n.SIXTY_FOUR_KILOBYTES&&(t.push(new c.T({attributes:l,indices:u,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV})),s=[],u=[],p=0,l=I(e.attributes))}0!==u.length&&t.push(new c.T({attributes:l,indices:u,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV}))}else t.push(e);return t};var P=new a.a,N=new a.i;x.projectTo2D=function(e,t,r,o,s){if(!i.t(e))throw new n.t("geometry is required.");if(!i.t(t))throw new n.t("attributeName is required.");if(!i.t(r))throw new n.t("attributeName3D is required.");if(!i.t(o))throw new n.t("attributeName2D is required.");if(!i.t(e.attributes[t]))throw new n.t("geometry must have attribute matching the attributeName argument: "+t+".");if(e.attributes[t].componentDatatype!==p.ComponentDatatype.DOUBLE)throw new n.t("The attribute componentDatatype must be ComponentDatatype.DOUBLE.");for(var u=e.attributes[t],l=(s=i.t(s)?s:new v.s).ellipsoid,f=u.values,y=new Float64Array(f.length),m=0,d=0;dz&&(z=_)}return new c.T({attributes:x,indices:T,primitiveType:h,boundingSphere:i.t(D)?new s.c(D,z):void 0})}x.combineInstances=function(e){if(!i.t(e)||e.length<1)throw new n.t("instances is required and must have length greater than zero.");for(var t=[],r=[],a=e.length,o=0;o0&&u.push(C(t,"geometry")),r.length>0&&(u.push(C(r,"westHemisphereGeometry")),u.push(C(r,"eastHemisphereGeometry"))),u};var R=new a.a,G=new a.a,F=new a.a,k=new a.a;x.computeNormal=function(e){if(!i.t(e))throw new n.t("geometry is required.");if(!i.t(e.attributes.position)||!i.t(e.attributes.position.values))throw new n.t("geometry.attributes.position.values is required.");if(!i.t(e.indices))throw new n.t("geometry.indices is required.");if(e.indices.length<2||e.indices.length%3!=0)throw new n.t("geometry.indices length must be greater than 0 and be a multiple of 3.");if(e.primitiveType!==m._0x38df4a.TRIANGLES)throw new n.t("geometry.primitiveType must be PrimitiveType.TRIANGLES.");var t,r=e.indices,s=e.attributes,u=s.position.values,l=s.position.values.length/3,v=r.length,f=new Array(l),y=new Array(v/3),d=new Array(v);for(t=0;t0){for(h=0;h3&&(r[3]=0,r[4]=2,r[5]=3);for(var a=6,i=3;i=0||t.x>=0||r.x>=0)){!function(e,t,r){if(0!==e.y&&0!==t.y&&0!==r.y)return j(e,e.y<0),j(t,t.y<0),void j(r,r.y<0);var a=Math.abs(e.y),n=Math.abs(t.y),i=Math.abs(r.y),s=(a>n?a>i?o.n.sign(e.y):o.n.sign(r.y):n>i?o.n.sign(t.y):o.n.sign(r.y))<0;j(e,s),j(t,s),j(r,s)}(e,t,r);var a=e.y<0,n=t.y<0,i=r.y<0,s=0;s+=a?1:0,s+=n?1:0;var u=re.indices;1===(s+=i?1:0)?(u[1]=3,u[2]=4,u[5]=6,u[7]=6,u[8]=5,a?(K(e,t,Q,ee),K(e,r,$,te),u[0]=0,u[3]=1,u[4]=2,u[6]=1):n?(K(t,r,Q,ee),K(t,e,$,te),u[0]=1,u[3]=2,u[4]=0,u[6]=2):i&&(K(r,e,Q,ee),K(r,t,$,te),u[0]=2,u[3]=0,u[4]=1,u[6]=0)):2===s&&(u[2]=4,u[4]=4,u[5]=3,u[7]=5,u[8]=6,a?n?i||(K(r,e,Q,ee),K(r,t,$,te),u[0]=0,u[1]=1,u[3]=0,u[6]=2):(K(t,r,Q,ee),K(t,e,$,te),u[0]=2,u[1]=0,u[3]=2,u[6]=1):(K(e,t,Q,ee),K(e,r,$,te),u[0]=1,u[1]=2,u[3]=1,u[6]=0));var p=re.positions;return p[0]=e,p[1]=t,p[2]=r,p.length=3,(1===s||2===s)&&(p[3]=Q,p[4]=$,p[5]=ee,p[6]=te,p.length=7),re}}function ne(e,t){var r=e.attributes;if(0!==r.position.values.length){for(var a in r)if(r.hasOwnProperty(a)&&i.t(r[a])&&i.t(r[a].values)){var n=r[a];n.values=p.ComponentDatatype.createTypedArray(n.componentDatatype,n.values)}var o=c.T.computeNumberOfVertices(e);return e.indices=f.IndexDatatype.createTypedArray(o,e.indices),t&&(e.boundingSphere=s.c.fromVertices(r.position.values)),e}}function ie(e){var t=e.attributes,r={};for(var a in t)if(t.hasOwnProperty(a)&&i.t(t[a])&&i.t(t[a].values)){var n=t[a];r[a]=new c.r({componentDatatype:n.componentDatatype,componentsPerAttribute:n.componentsPerAttribute,normalize:n.normalize,values:[]})}return new c.T({attributes:r,indices:[],primitiveType:e.primitiveType})}function oe(e,t,r){var a=i.t(e.geometry.boundingSphere);t=ne(t,a),r=ne(r,a),i.t(r)&&!i.t(t)?e.geometry=r:!i.t(r)&&i.t(t)?e.geometry=t:(e.westHemisphereGeometry=t,e.eastHemisphereGeometry=r,e.geometry=void 0)}function se(e,t){var r=new e,a=new e,n=new e;return function(i,o,s,u,p,l,v,c){var f=e.fromArray(p,i*t,r),y=e.fromArray(p,o*t,a),m=e.fromArray(p,s*t,n);e.multiplyByScalar(f,u.x,f),e.multiplyByScalar(y,u.y,y),e.multiplyByScalar(m,u.z,m);var d=e.add(f,y,f);e.add(d,m,d),c&&e.normalize(d,d),e.pack(d,l,v*t)}}var ue=se(u.a,4),pe=se(a.a,3),le=se(r.r,2),ve=new a.a,ce=new a.a,fe=new a.a,ye=new a.a;function me(e,t,r,n,s,u,p,l,v,c,f,y,m,d,h,b){if(i.t(u)||i.t(p)||i.t(l)||i.t(v)||i.t(c)||0!==d){var w=g(n,a.a.fromArray(s,3*e,ve),a.a.fromArray(s,3*t,ce),a.a.fromArray(s,3*r,fe),ye);if(i.t(u)&&pe(e,t,r,w,u,y.normal.values,b,!0),i.t(c)){var T,x=a.a.fromArray(c,3*e,ve),A=a.a.fromArray(c,3*t,ce),I=a.a.fromArray(c,3*r,fe);a.a.multiplyByScalar(x,w.x,x),a.a.multiplyByScalar(A,w.y,A),a.a.multiplyByScalar(I,w.z,I),a.a.equals(x,a.a.ZERO)&&a.a.equals(A,a.a.ZERO)&&a.a.equals(I,a.a.ZERO)?((T=ve).x=0,T.y=0,T.z=0):(T=a.a.add(x,A,x),a.a.add(T,I,T),a.a.normalize(T,T)),a.a.pack(T,y.extrudeDirection.values,3*b)}if(i.t(f)&&function(e,t,r,a,n,i,s){var u=n[e]*a.x,p=n[t]*a.y,l=n[r]*a.z;i[s]=u+p+l>o.n.EPSILON6?1:0}(e,t,r,w,f,y.applyOffset.values,b),i.t(p)&&pe(e,t,r,w,p,y.tangent.values,b,!0),i.t(l)&&pe(e,t,r,w,l,y.bitangent.values,b,!0),i.t(v)&&le(e,t,r,w,v,y.st.values,b),d>0)for(var S=0;S3)for(var z=D.positions,_=D.indices,q=_.length,C=0;C0)){var p=a.a.unpack(n,s,Ee);(u.y<0&&p.y>0||u.y>0&&p.y<0)&&(s-3>0?(n[s]=r[s-3],n[s+1]=r[s-2],n[s+2]=r[s-1]):a.a.pack(u,n,s));var l=a.a.unpack(i,s,Oe);(u.y<0&&l.y>0||u.y>0&&l.y<0)&&(s+30||s.c.intersectPlane(p,d.n.ORIGIN_ZX_PLANE)!==v.S.INTERSECTING))return e;if(t.geometryType!==c.Sr.NONE)switch(t.geometryType){case c.Sr.POLYLINES:!function(e){var t,n,s,p=e.geometry,l=p.attributes,v=l.position.values,c=l.prevPosition.values,f=l.nextPosition.values,m=l.expandAndWidth.values,d=i.t(l.st)?l.st.values:void 0,h=i.t(l.color)?l.color.values:void 0,b=i.t(l.dist)?l.dist.values:void 0,w=ie(p),g=ie(p),T=!1,x=v.length/3;for(t=0;t