define(["exports","./AttributeCompression-1f045b73","./Matrix2-ccd5b911","./RuntimeError-346a3079","./when-4bbc8319","./ComponentDatatype-93750d1a","./Transforms-d5c6ad6e","./EncodedCartesian3-08b8d980","./GeometryAttribute-c30799b8","./IndexDatatype-b7d979a6","./IntersectionTests-4d6f5c54","./Plane-18bb00f8"],function(e,A,R,t,V,L,P,d,w,S,z,a){"use strict";var g=new R.Cartesian3,T=new R.Cartesian3,x=new R.Cartesian3;var s={calculateACMR:function(e){var t=(e=V.defaultValue(e,V.defaultValue.EMPTY_OBJECT)).indices,r=e.maximumIndex,a=V.defaultValue(e.cacheSize,24),n=t.length;if(!V.defined(r))for(var r=0,i=0,s=t[i];ia&&(o[t[d]]=p,++p);return(p-a+1)/(n/3)}};s.tipsify=function(e){var t=(e=V.defaultValue(e,V.defaultValue.EMPTY_OBJECT)).indices,r=e.maximumIndex,a=V.defaultValue(e.cacheSize,24);function n(e,t,r,a,n,i,s){for(var o,u=-1,p=-1,d=0;da&&(l.timeStamp=f,++f),++P}y=n(0,a,c,u,f,m,i)}return h};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,a={};for(t in e)e.hasOwnProperty(t)&&V.defined(e[t])&&V.defined(e[t].values)&&(r=e[t],a[t]=new w.GeometryAttribute({componentDatatype:r.componentDatatype,componentsPerAttribute:r.componentsPerAttribute,normalize:r.normalize,values:[]}));return a}r.toWireframe=function(e){var t=e.indices;if(V.defined(t)){switch(e.primitiveType){case w.PrimitiveType.TRIANGLES:e.indices=function(e){for(var t=e.length,r=S.IndexDatatype.createTypedArray(t,t/3*6),a=0,n=0;nn&&(n=r[i]);e.indices=s.tipsify({indices:r,maximumIndex:n,cacheSize:t})}return e},r.fitToUnsignedShortIndices=function(e){var t=[],r=w.Geometry.computeNumberOfVertices(e);if(V.defined(e.indices)&&r>=L.CesiumMath.SIXTY_FOUR_KILOBYTES){var a,n=[],i=[],s=0,o=v(e.attributes),u=e.indices,p=u.length;e.primitiveType===w.PrimitiveType.TRIANGLES?a=3:e.primitiveType===w.PrimitiveType.LINES?a=2:e.primitiveType===w.PrimitiveType.POINTS&&(a=1);for(var d=0;d=L.CesiumMath.SIXTY_FOUR_KILOBYTES&&(t.push(new w.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 w.Geometry({attributes:o,indices:i,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV}))}else t.push(e);return t};var y=new R.Cartesian3,f=new R.Cartographic;r.projectTo2D=function(e,t,r,a,n){for(var i=e.attributes[t],s=(n=V.defined(n)?n:new P.GeographicProjection).ellipsoid,o=i.values,u=new Float64Array(o.length),p=0,d=0;dL.CesiumMath.EPSILON6?1:0},ie=new R.Cartesian3,se=new R.Cartesian3,oe=new R.Cartesian3,ue=new R.Cartesian3;function pe(e,t,r,a,n,i,s,o,u,p,d,l,y,f,v,c){if(V.defined(i)||V.defined(s)||V.defined(o)||V.defined(u)||V.defined(p)||0!==f){var m,C=function(e,t,r,a,n){var i,s,o,u,p,d,l;if(V.defined(n)||(n=new R.Cartesian3),V.defined(t.z)){if(R.Cartesian3.equalsEpsilon(e,t,L.CesiumMath.EPSILON14))return R.Cartesian3.clone(R.Cartesian3.UNIT_X,n);if(R.Cartesian3.equalsEpsilon(e,r,L.CesiumMath.EPSILON14))return R.Cartesian3.clone(R.Cartesian3.UNIT_Y,n);if(R.Cartesian3.equalsEpsilon(e,a,L.CesiumMath.EPSILON14))return R.Cartesian3.clone(R.Cartesian3.UNIT_Z,n);i=R.Cartesian3.subtract(r,t,g),s=R.Cartesian3.subtract(a,t,T),o=R.Cartesian3.subtract(e,t,x),u=R.Cartesian3.dot(i,i),y=R.Cartesian3.dot(i,s),p=R.Cartesian3.dot(i,o),d=R.Cartesian3.dot(s,s),l=R.Cartesian3.dot(s,o)}else{if(R.Cartesian2.equalsEpsilon(e,t,L.CesiumMath.EPSILON14))return R.Cartesian3.clone(R.Cartesian3.UNIT_X,n);if(R.Cartesian2.equalsEpsilon(e,r,L.CesiumMath.EPSILON14))return R.Cartesian3.clone(R.Cartesian3.UNIT_Y,n);if(R.Cartesian2.equalsEpsilon(e,a,L.CesiumMath.EPSILON14))return R.Cartesian3.clone(R.Cartesian3.UNIT_Z,n);i=R.Cartesian2.subtract(r,t,g),s=R.Cartesian2.subtract(a,t,T),o=R.Cartesian2.subtract(e,t,x),u=R.Cartesian2.dot(i,i),y=R.Cartesian2.dot(i,s),p=R.Cartesian2.dot(i,o),d=R.Cartesian2.dot(s,s),l=R.Cartesian2.dot(s,o)}n.y=d*p-y*l,n.z=u*l-y*p;var y=u*d-y*y;return 0!==n.y&&(n.y/=y),0!==n.z&&(n.z/=y),n.x=1-n.y-n.z,n}(a,R.Cartesian3.fromArray(n,3*e,ie),R.Cartesian3.fromArray(n,3*t,se),R.Cartesian3.fromArray(n,3*r,oe),ue);if(V.defined(i)&&re(e,t,r,C,i,l.normal.values,c,!0),V.defined(p)&&(n=R.Cartesian3.fromArray(p,3*e,ie),i=R.Cartesian3.fromArray(p,3*t,se),p=R.Cartesian3.fromArray(p,3*r,oe),R.Cartesian3.multiplyByScalar(n,C.x,n),R.Cartesian3.multiplyByScalar(i,C.y,i),R.Cartesian3.multiplyByScalar(p,C.z,p),R.Cartesian3.equals(n,R.Cartesian3.ZERO)&&R.Cartesian3.equals(i,R.Cartesian3.ZERO)&&R.Cartesian3.equals(p,R.Cartesian3.ZERO)?((m=ie).x=0,m.y=0,m.z=0):(m=R.Cartesian3.add(n,i,n),R.Cartesian3.add(m,p,m),R.Cartesian3.normalize(m,m)),R.Cartesian3.pack(m,l.extrudeDirection.values,3*c)),V.defined(d)&&ne(e,t,r,C,d,l.applyOffset.values,c),V.defined(s)&&re(e,t,r,C,s,l.tangent.values,c,!0),V.defined(o)&&re(e,t,r,C,o,l.bitangent.values,c,!0),V.defined(u)&&ae(e,t,r,C,u,l.st.values,c),0