define(["exports","./when-cbf8cd21","./Check-35e1a91d","./Math-6a1814d8","./Cartesian2-c451a606","./Transforms-e4be2a30","./ComponentDatatype-7ee14e67","./GeometryAttribute-6f280ece","./AttributeCompression-bb3dc748","./EncodedCartesian3-4930ae29","./IndexDatatype-354a5ea3","./IntersectionTests-8371bf29","./Plane-929e0674"],function(e,_,t,q,U,Y,M,G,P,l,w,Z,a){"use strict";var x=new U.Cartesian3,S=new U.Cartesian3,I=new U.Cartesian3;var s={calculateACMR:function(e){var t=(e=_.defaultValue(e,_.defaultValue.EMPTY_OBJECT)).indices,r=e.maximumIndex,a=_.defaultValue(e.cacheSize,24),i=t.length;if(!_.defined(r))for(var n=r=0,s=t[n];na&&(o[t[d]]=p,++p);return(p-a+1)/(i/3)}};s.tipsify=function(e){var v,t=(e=_.defaultValue(e,_.defaultValue.EMPTY_OBJECT)).indices,r=e.maximumIndex,a=_.defaultValue(e.cacheSize,24);function i(e,t,r,a,i,n,s){for(var o,u=-1,p=-1,d=0;da&&(m.timeStamp=c,++c),++o}f=i(0,a,g,l,c,A,s)}return x};var r={};function o(e,t,r,a,i){e[t++]=r,e[t++]=a,e[t++]=a,e[t++]=i,e[t++]=i,e[t]=r}function f(e){var t={};for(var r in e)if(e.hasOwnProperty(r)&&_.defined(e[r])&&_.defined(e[r].values)){var a=e[r];t[r]=new G.GeometryAttribute({componentDatatype:a.componentDatatype,componentsPerAttribute:a.componentsPerAttribute,normalize:a.normalize,values:[]})}return t}function c(e,t,r){for(var a in t)if(t.hasOwnProperty(a)&&_.defined(t[a])&&_.defined(t[a].values))for(var i=t[a],n=0;ni&&(i=r[n]);e.indices=s.tipsify({indices:r,maximumIndex:i,cacheSize:t})}return e},r.fitToUnsignedShortIndices=function(e){var t=[],r=G.Geometry.computeNumberOfVertices(e);if(_.defined(e.indices)&&r>=q.CesiumMath.SIXTY_FOUR_KILOBYTES){var a,i=[],n=[],s=0,o=f(e.attributes),u=e.indices,p=u.length;e.primitiveType===G.PrimitiveType.TRIANGLES?a=3:e.primitiveType===G.PrimitiveType.LINES?a=2:e.primitiveType===G.PrimitiveType.POINTS&&(a=1);for(var d=0;d=q.CesiumMath.SIXTY_FOUR_KILOBYTES&&(t.push(new G.Geometry({attributes:o,indices:n,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV})),i=[],n=[],s=0,o=f(e.attributes))}0!==n.length&&t.push(new G.Geometry({attributes:o,indices:n,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV}))}else t.push(e);return t};var m=new U.Cartesian3,C=new U.Cartographic;r.projectTo2D=function(e,t,r,a,i){for(var n=e.attributes[t],s=(i=_.defined(i)?i:new Y.GeographicProjection).ellipsoid,o=n.values,u=new Float64Array(o.length),p=0,d=0;dq.CesiumMath.EPSILON6?1:0},oe=new U.Cartesian3,ue=new U.Cartesian3,pe=new U.Cartesian3,de=new U.Cartesian3;function le(e,t,r,a,i,n,s,o,u,p,d,l,v,y,f,c){if(_.defined(n)||_.defined(s)||_.defined(o)||_.defined(u)||_.defined(p)||0!==y){var m=function(e,t,r,a,i){var n,s,o,u,p,d,l,v;if(_.defined(i)||(i=new U.Cartesian3),_.defined(t.z)){if(U.Cartesian3.equalsEpsilon(e,t,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_X,i);if(U.Cartesian3.equalsEpsilon(e,r,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_Y,i);if(U.Cartesian3.equalsEpsilon(e,a,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_Z,i);n=U.Cartesian3.subtract(r,t,x),s=U.Cartesian3.subtract(a,t,S),o=U.Cartesian3.subtract(e,t,I),u=U.Cartesian3.dot(n,n),p=U.Cartesian3.dot(n,s),d=U.Cartesian3.dot(n,o),l=U.Cartesian3.dot(s,s),v=U.Cartesian3.dot(s,o)}else{if(U.Cartesian2.equalsEpsilon(e,t,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_X,i);if(U.Cartesian2.equalsEpsilon(e,r,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_Y,i);if(U.Cartesian2.equalsEpsilon(e,a,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_Z,i);n=U.Cartesian2.subtract(r,t,x),s=U.Cartesian2.subtract(a,t,S),o=U.Cartesian2.subtract(e,t,I),u=U.Cartesian2.dot(n,n),p=U.Cartesian2.dot(n,s),d=U.Cartesian2.dot(n,o),l=U.Cartesian2.dot(s,s),v=U.Cartesian2.dot(s,o)}i.y=l*d-p*v,i.z=u*v-p*d;var y=u*l-p*p;return 0!==i.y&&(i.y/=y),0!==i.z&&(i.z/=y),i.x=1-i.y-i.z,i}(a,U.Cartesian3.fromArray(i,3*e,oe),U.Cartesian3.fromArray(i,3*t,ue),U.Cartesian3.fromArray(i,3*r,pe),de);if(_.defined(n)&&ie(e,t,r,m,n,l.normal.values,c,!0),_.defined(p)){var C,h=U.Cartesian3.fromArray(p,3*e,oe),b=U.Cartesian3.fromArray(p,3*t,ue),g=U.Cartesian3.fromArray(p,3*r,pe);U.Cartesian3.multiplyByScalar(h,m.x,h),U.Cartesian3.multiplyByScalar(b,m.y,b),U.Cartesian3.multiplyByScalar(g,m.z,g),U.Cartesian3.equals(h,U.Cartesian3.ZERO)&&U.Cartesian3.equals(b,U.Cartesian3.ZERO)&&U.Cartesian3.equals(g,U.Cartesian3.ZERO)?((C=oe).x=0,C.y=0,C.z=0):(C=U.Cartesian3.add(h,b,h),U.Cartesian3.add(C,g,C),U.Cartesian3.normalize(C,C)),U.Cartesian3.pack(C,l.extrudeDirection.values,3*c)}if(_.defined(d)&&se(e,t,r,m,d,l.applyOffset.values,c),_.defined(s)&&ie(e,t,r,m,s,l.tangent.values,c,!0),_.defined(o)&&ie(e,t,r,m,o,l.bitangent.values,c,!0),_.defined(u)&&ne(e,t,r,m,u,l.st.values,c),0