define(["exports","./when-54c2dc71","./Check-6c0211bc","./Math-fc8cecf5","./Cartesian2-bddc1162","./Transforms-ec27f304","./ComponentDatatype-6d99a1ee","./GeometryAttribute-44fb48f1","./AttributeCompression-9fc99391","./EncodedCartesian3-e9c71cf0","./IndexDatatype-53503fee","./IntersectionTests-2626c9e9","./Plane-231f1723"],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),n=t.length;if(!_.defined(r))for(var i=r=0,s=t[i];ia&&(o[t[d]]=p,++p);return(p-a+1)/(n/3)}};s.tipsify=function(e){var t=(e=_.defaultValue(e,_.defaultValue.EMPTY_OBJECT)).indices,r=e.maximumIndex,a=_.defaultValue(e.cacheSize,24);function n(e,t,r,a,n,i,s){for(var o,u=-1,p=-1,d=0;da&&(f.timeStamp=h,++h),++o}C=n(0,a,g,d,h,A,s)}return x};var r={};function o(e,t,r,a,n){e[t++]=r,e[t++]=a,e[t++]=a,e[t++]=n,e[t++]=n,e[t]=r}function v(e){var t,r={};for(var a in e){e.hasOwnProperty(a)&&_.defined(e[a])&&_.defined(e[a].values)&&(t=e[a],r[a]=new G.GeometryAttribute({componentDatatype:t.componentDatatype,componentsPerAttribute:t.componentsPerAttribute,normalize:t.normalize,values:[]}))}return r}r.toWireframe=function(e){var t=e.indices;if(_.defined(t)){switch(e.primitiveType){case G.PrimitiveType.TRIANGLES:e.indices=function(e){for(var t=e.length,r=t/3*6,a=w.IndexDatatype.createTypedArray(t,r),n=0,i=0;in&&(n=r[i]);e.indices=s.tipsify({indices:r,maximumIndex:n,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,n=[],i=[],s=0,o=v(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:i,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV})),n=[],i=[],s=0,o=v(e.attributes))}0!==i.length&&t.push(new G.Geometry({attributes:o,indices:i,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV}))}else t.push(e);return t};var c=new U.Cartesian3,m=new U.Cartographic;r.projectTo2D=function(e,t,r,a,n){for(var i=e.attributes[t],s=(n=_.defined(n)?n:new Y.GeographicProjection).ellipsoid,o=i.values,u=new Float64Array(o.length),p=0,d=0;dq.CesiumMath.EPSILON6?1:0},se=new U.Cartesian3,oe=new U.Cartesian3,ue=new U.Cartesian3,pe=new U.Cartesian3;function de(e,t,r,a,n,i,s,o,u,p,d,l,y,f,v,c){if(_.defined(i)||_.defined(s)||_.defined(o)||_.defined(u)||_.defined(p)||0!==f){var m,C,h,b,g=function(e,t,r,a,n){var i,s,o,u,p,d,l,y;if(_.defined(n)||(n=new U.Cartesian3),_.defined(t.z)){if(U.Cartesian3.equalsEpsilon(e,t,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_X,n);if(U.Cartesian3.equalsEpsilon(e,r,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_Y,n);if(U.Cartesian3.equalsEpsilon(e,a,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_Z,n);i=U.Cartesian3.subtract(r,t,x),s=U.Cartesian3.subtract(a,t,S),o=U.Cartesian3.subtract(e,t,I),u=U.Cartesian3.dot(i,i),p=U.Cartesian3.dot(i,s),d=U.Cartesian3.dot(i,o),l=U.Cartesian3.dot(s,s),y=U.Cartesian3.dot(s,o)}else{if(U.Cartesian2.equalsEpsilon(e,t,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_X,n);if(U.Cartesian2.equalsEpsilon(e,r,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_Y,n);if(U.Cartesian2.equalsEpsilon(e,a,q.CesiumMath.EPSILON14))return U.Cartesian3.clone(U.Cartesian3.UNIT_Z,n);i=U.Cartesian2.subtract(r,t,x),s=U.Cartesian2.subtract(a,t,S),o=U.Cartesian2.subtract(e,t,I),u=U.Cartesian2.dot(i,i),p=U.Cartesian2.dot(i,s),d=U.Cartesian2.dot(i,o),l=U.Cartesian2.dot(s,s),y=U.Cartesian2.dot(s,o)}n.y=l*d-p*y,n.z=u*y-p*d;var f=u*l-p*p;return 0!==n.y&&(n.y/=f),0!==n.z&&(n.z/=f),n.x=1-n.y-n.z,n}(a,U.Cartesian3.fromArray(n,3*e,se),U.Cartesian3.fromArray(n,3*t,oe),U.Cartesian3.fromArray(n,3*r,ue),pe);if(_.defined(i)&&ae(e,t,r,g,i,l.normal.values,c,!0),_.defined(p)&&(m=U.Cartesian3.fromArray(p,3*e,se),C=U.Cartesian3.fromArray(p,3*t,oe),h=U.Cartesian3.fromArray(p,3*r,ue),U.Cartesian3.multiplyByScalar(m,g.x,m),U.Cartesian3.multiplyByScalar(C,g.y,C),U.Cartesian3.multiplyByScalar(h,g.z,h),U.Cartesian3.equals(m,U.Cartesian3.ZERO)&&U.Cartesian3.equals(C,U.Cartesian3.ZERO)&&U.Cartesian3.equals(h,U.Cartesian3.ZERO)?((b=se).x=0,b.y=0,b.z=0):(b=U.Cartesian3.add(m,C,m),U.Cartesian3.add(b,h,b),U.Cartesian3.normalize(b,b)),U.Cartesian3.pack(b,l.extrudeDirection.values,3*c)),_.defined(d)&&ie(e,t,r,g,d,l.applyOffset.values,c),_.defined(s)&&ae(e,t,r,g,s,l.tangent.values,c,!0),_.defined(o)&&ae(e,t,r,g,o,l.bitangent.values,c,!0),_.defined(u)&&ne(e,t,r,g,u,l.st.values,c),0