define(["exports","./AttributeCompression-49f7b62a","./Cartesian2-6033fa5d","./Cartographic-67e73ef9","./Check-52a7d806","./when-92c6cf3c","./Math-92c3b5f7","./buildModuleUrl-3d15f25c","./Cartesian4-ad128b5d","./ComponentDatatype-81047f82","./EncodedCartesian3-b86c8d65","./Intersect-b97e930a","./GeometryAttribute-ef657318","./IndexDatatype-4c0e98b8","./IntersectionTests-a42760d9","./PrimitiveType-cdfe443e","./Plane-f8d22530"],(function(e,t,r,i,n,a,o,s,u,p,l,v,y,c,m,f,h){"use strict";var d=new i.t,b=new i.t,w=new i.t;function g(e,t,s,u,p){var l,v,y,c,m,f,h,g;if(n.o.defined("point",e),n.o.defined("p0",t),n.o.defined("p1",s),n.o.defined("p2",u),a.e(p)||(p=new i.t),a.e(t.z)){if(i.t.equalsEpsilon(e,t,o.e.EPSILON14))return i.t.clone(i.t.UNIT_X,p);if(i.t.equalsEpsilon(e,s,o.e.EPSILON14))return i.t.clone(i.t.UNIT_Y,p);if(i.t.equalsEpsilon(e,u,o.e.EPSILON14))return i.t.clone(i.t.UNIT_Z,p);l=i.t.subtract(s,t,d),v=i.t.subtract(u,t,b),y=i.t.subtract(e,t,w),c=i.t.dot(l,l),m=i.t.dot(l,v),f=i.t.dot(l,y),h=i.t.dot(v,v),g=i.t.dot(v,y)}else{if(r.o.equalsEpsilon(e,t,o.e.EPSILON14))return i.t.clone(i.t.UNIT_X,p);if(r.o.equalsEpsilon(e,s,o.e.EPSILON14))return i.t.clone(i.t.UNIT_Y,p);if(r.o.equalsEpsilon(e,u,o.e.EPSILON14))return i.t.clone(i.t.UNIT_Z,p);l=r.o.subtract(s,t,d),v=r.o.subtract(u,t,b),y=r.o.subtract(e,t,w),c=r.o.dot(l,l),m=r.o.dot(l,v),f=r.o.dot(l,y),h=r.o.dot(v,v),g=r.o.dot(v,y)}p.y=h*f-m*g,p.z=c*g-m*f;var x=c*h-m*m;return 0!==p.y&&(p.y/=x),0!==p.z&&(p.z/=x),p.x=1-p.y-p.z,p}var x={calculateACMR:function(e){var t=(e=a.u(e,a.u.EMPTY_OBJECT)).indices,r=e.maximumIndex,i=a.u(e.cacheSize,24);if(!a.e(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(i<3)throw new n.t("cacheSize must be greater than two.");if(!a.e(r)){r=0;for(var s=0,u=t[s];sr&&(r=u),u=t[++s]}for(var p=[],l=0;li&&(p[t[y]]=v,++v);return(v-i+1)/(o/3)}};x.tipsify=function(e){var t,r=(e=a.u(e,a.u.EMPTY_OBJECT)).indices,i=e.maximumIndex,o=a.u(e.cacheSize,24);function s(e,r,i,n,a,o,s){for(var u,p=-1,l=-1,v=0;vl||-1===l)&&(l=u,p=y)),++v}return-1===p?function(e,r,i,n){for(;r.length>=1;){var a=r[r.length-1];if(r.splice(r.length-1,1),e[a].numLiveTriangles>0)return a}for(;t0)return++t-1;++t}return-1}(n,o,0,s):p}if(!a.e(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(i<=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],y=u;if(a.e(i))p=i+1;else{for(;lp&&(p=v),v=r[++l];if(-1===p)return 0;++p}var c,m=[];for(c=0;co&&(b.timeStamp=d,++d),++l}h=s(0,o,T,m,d,A,p)}return S};var T={};function A(e,t,r,i,n){e[t++]=r,e[t++]=i,e[t++]=i,e[t++]=n,e[t++]=n,e[t]=r}function I(e){var t={};for(var r in e)if(e.hasOwnProperty(r)&&a.e(e[r])&&a.e(e[r].values)){var i=e[r];t[r]=new y.o({componentDatatype:i.componentDatatype,componentsPerAttribute:i.componentsPerAttribute,normalize:i.normalize,values:[]})}return t}function S(e,t,r){for(var i in t)if(t.hasOwnProperty(i)&&a.e(t[i])&&a.e(t[i].values))for(var n=t[i],o=0;o=3){var r=6*(t-2),i=c.IndexDatatype.createTypedArray(t,r);A(i,0,e[0],e[1],e[2]);for(var n=6,a=3;a0){for(var t=e.length-1,r=6*(t-1),i=c.IndexDatatype.createTypedArray(t,r),n=e[0],a=0,o=1;oo&&(o=r[s]);e.indices=x.tipsify({indices:r,maximumIndex:o,cacheSize:t})}return e},T.fitToUnsignedShortIndices=function(e){if(!a.e(e))throw new n.t("geometry is required.");if(a.e(e.indices)&&e.primitiveType!==f._0x29ba75.TRIANGLES&&e.primitiveType!==f._0x29ba75.LINES&&e.primitiveType!==f._0x29ba75.POINTS)throw new n.t("geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS.");var t=[],r=y.I.computeNumberOfVertices(e);if(a.e(e.indices)&&r>=o.e.SIXTY_FOUR_KILOBYTES){var i,s=[],u=[],p=0,l=I(e.attributes),v=e.indices,c=v.length;e.primitiveType===f._0x29ba75.TRIANGLES?i=3:e.primitiveType===f._0x29ba75.LINES?i=2:e.primitiveType===f._0x29ba75.POINTS&&(i=1);for(var m=0;m=o.e.SIXTY_FOUR_KILOBYTES&&(t.push(new y.I({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 y.I({attributes:l,indices:u,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV}))}else t.push(e);return t};var P=new i.t,N=new i.t$1;T.projectTo2D=function(e,t,r,o,s){if(!a.e(e))throw new n.t("geometry is required.");if(!a.e(t))throw new n.t("attributeName is required.");if(!a.e(r))throw new n.t("attributeName3D is required.");if(!a.e(o))throw new n.t("attributeName2D is required.");if(!a.e(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=a.e(s)?s:new v.n).ellipsoid,c=u.values,m=new Float64Array(c.length),f=0,h=0;hz&&(z=_)}return new y.I({attributes:T,indices:x,primitiveType:d,boundingSphere:a.e(D)?new s.i(D,z):void 0})}T.combineInstances=function(e){if(!a.e(e)||e.length<1)throw new n.t("instances is required and must have length greater than zero.");for(var t=[],r=[],i=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 i.t,G=new i.t,F=new i.t,k=new i.t;T.computeNormal=function(e){if(!a.e(e))throw new n.t("geometry is required.");if(!a.e(e.attributes.position)||!a.e(e.attributes.position.values))throw new n.t("geometry.attributes.position.values is required.");if(!a.e(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!==f._0x29ba75.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,c=new Array(l),m=new Array(v/3),h=new Array(v);for(t=0;t0){for(d=0;d3&&(r[3]=0,r[4]=2,r[5]=3);for(var i=6,a=3;a=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 i=Math.abs(e.y),n=Math.abs(t.y),a=Math.abs(r.y),s=(i>n?i>a?o.e.sign(e.y):o.e.sign(r.y):n>a?o.e.sign(t.y):o.e.sign(r.y))<0;j(e,s),j(t,s),j(r,s)}(e,t,r);var i=e.y<0,n=t.y<0,a=r.y<0,s=0;s+=i?1:0,s+=n?1:0;var u=re.indices;1===(s+=a?1:0)?(u[1]=3,u[2]=4,u[5]=6,u[7]=6,u[8]=5,i?(K(e,t,$,ee),K(e,r,Q,te),u[0]=0,u[3]=1,u[4]=2,u[6]=1):n?(K(t,r,$,ee),K(t,e,Q,te),u[0]=1,u[3]=2,u[4]=0,u[6]=2):a&&(K(r,e,$,ee),K(r,t,Q,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,i?n?a||(K(r,e,$,ee),K(r,t,Q,te),u[0]=0,u[1]=1,u[3]=0,u[6]=2):(K(t,r,$,ee),K(t,e,Q,te),u[0]=2,u[1]=0,u[3]=2,u[6]=1):(K(e,t,$,ee),K(e,r,Q,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]=$,p[4]=Q,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 i in r)if(r.hasOwnProperty(i)&&a.e(r[i])&&a.e(r[i].values)){var n=r[i];n.values=p.ComponentDatatype.createTypedArray(n.componentDatatype,n.values)}var o=y.I.computeNumberOfVertices(e);return e.indices=c.IndexDatatype.createTypedArray(o,e.indices),t&&(e.boundingSphere=s.i.fromVertices(r.position.values)),e}}function ae(e){var t=e.attributes,r={};for(var i in t)if(t.hasOwnProperty(i)&&a.e(t[i])&&a.e(t[i].values)){var n=t[i];r[i]=new y.o({componentDatatype:n.componentDatatype,componentsPerAttribute:n.componentsPerAttribute,normalize:n.normalize,values:[]})}return new y.I({attributes:r,indices:[],primitiveType:e.primitiveType})}function oe(e,t,r){var i=a.e(e.geometry.boundingSphere);t=ne(t,i),r=ne(r,i),a.e(r)&&!a.e(t)?e.geometry=r:!a.e(r)&&a.e(t)?e.geometry=t:(e.westHemisphereGeometry=t,e.eastHemisphereGeometry=r,e.geometry=void 0)}function se(e,t){var r=new e,i=new e,n=new e;return function(a,o,s,u,p,l,v,y){var c=e.fromArray(p,a*t,r),m=e.fromArray(p,o*t,i),f=e.fromArray(p,s*t,n);e.multiplyByScalar(c,u.x,c),e.multiplyByScalar(m,u.y,m),e.multiplyByScalar(f,u.z,f);var h=e.add(c,m,c);e.add(h,f,h),y&&e.normalize(h,h),e.pack(h,l,v*t)}}var ue=se(u.e,4),pe=se(i.t,3),le=se(r.o,2),ve=new i.t,ye=new i.t,ce=new i.t,me=new i.t;function fe(e,t,r,n,s,u,p,l,v,y,c,m,f,h,d,b){if(a.e(u)||a.e(p)||a.e(l)||a.e(v)||a.e(y)||0!==h){var w=g(n,i.t.fromArray(s,3*e,ve),i.t.fromArray(s,3*t,ye),i.t.fromArray(s,3*r,ce),me);if(a.e(u)&&pe(e,t,r,w,u,m.normal.values,b,!0),a.e(y)){var x,T=i.t.fromArray(y,3*e,ve),A=i.t.fromArray(y,3*t,ye),I=i.t.fromArray(y,3*r,ce);i.t.multiplyByScalar(T,w.x,T),i.t.multiplyByScalar(A,w.y,A),i.t.multiplyByScalar(I,w.z,I),i.t.equals(T,i.t.ZERO)&&i.t.equals(A,i.t.ZERO)&&i.t.equals(I,i.t.ZERO)?((x=ve).x=0,x.y=0,x.z=0):(x=i.t.add(T,A,T),i.t.add(x,I,x),i.t.normalize(x,x)),i.t.pack(x,m.extrudeDirection.values,3*b)}if(a.e(c)&&function(e,t,r,i,n,a,s){var u=n[e]*i.x,p=n[t]*i.y,l=n[r]*i.z;a[s]=u+p+l>o.e.EPSILON6?1:0}(e,t,r,w,c,m.applyOffset.values,b),a.e(p)&&pe(e,t,r,w,p,m.tangent.values,b,!0),a.e(l)&&pe(e,t,r,w,l,m.bitangent.values,b,!0),a.e(v)&&le(e,t,r,w,v,m.st.values,b),h>0)for(var S=0;S3)for(var z=D.positions,_=D.indices,q=_.length,C=0;C0)){var p=i.t.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]):i.t.pack(u,n,s));var l=i.t.unpack(a,s,Oe);(u.y<0&&l.y>0||u.y>0&&l.y<0)&&(s+30||s.i.intersectPlane(p,h.o.ORIGIN_ZX_PLANE)!==v.S.INTERSECTING))return e;if(t.geometryType!==y.Me.NONE)switch(t.geometryType){case y.Me.POLYLINES:!function(e){var t,n,s,p=e.geometry,l=p.attributes,v=l.position.values,y=l.prevPosition.values,c=l.nextPosition.values,f=l.expandAndWidth.values,h=a.e(l.st)?l.st.values:void 0,d=a.e(l.color)?l.color.values:void 0,b=a.e(l.dist)?l.dist.values:void 0,w=ae(p),g=ae(p),x=!1,T=v.length/3;for(t=0;t