define(["exports","./AttributeCompression-80665726","./Matrix2-47e98d76","./RuntimeError-8952249c","./defaultValue-81eec7ed","./ComponentDatatype-a15c9a19","./Transforms-08771371","./EncodedCartesian3-d9f5c4a4","./GeometryAttribute-64b853f6","./IndexDatatype-f1dcdf35","./IntersectionTests-bc78300e","./Plane-3f01019d"],(function(e,t,n,i,r,a,s,o,u,c,l,p){"use strict";const d=new n.Cartesian3,f=new n.Cartesian3,y=new n.Cartesian3;const m={calculateACMR:function(e){const t=(e=r.defaultValue(e,r.defaultValue.EMPTY_OBJECT)).indices;let n=e.maximumIndex;const i=r.defaultValue(e.cacheSize,24),a=t.length;if(!r.defined(n)){n=0;let e=0,i=t[e];for(;en&&(n=i),++e,i=t[e]}const s=[];for(let e=0;ei&&(s[t[e]]=o,++o);return(o-i+1)/(a/3)}};m.tipsify=function(e){const t=(e=r.defaultValue(e,r.defaultValue.EMPTY_OBJECT)).indices,n=e.maximumIndex,i=r.defaultValue(e.cacheSize,24);let a;function s(e,t,n,i,r,s,o){let u,c=-1,l=-1,p=0;for(;pl||-1===l)&&(l=u,c=e)),++p}return-1===c?function(e,t,n,i){for(;t.length>=1;){const n=t[t.length-1];if(t.splice(t.length-1,1),e[n].numLiveTriangles>0)return n}for(;a0)return++a,a-1;++a}return-1}(i,s,0,o):c}const o=t.length;let u=0,c=0,l=t[c];const p=o;if(r.defined(n))u=n+1;else{for(;cu&&(u=l),++c,l=t[c];if(-1===u)return 0;++u}const d=[];let f;for(f=0;fi&&(b.timeStamp=C,++C),++c}m=s(0,i,h,d,C,v,u)}return T};const C={};function h(e,t,n,i,r){e[t++]=n,e[t++]=i,e[t++]=i,e[t++]=r,e[t++]=r,e[t]=n}function v(e){const t={};for(const n in e)if(e.hasOwnProperty(n)&&r.defined(e[n])&&r.defined(e[n].values)){const i=e[n];t[n]=new u.GeometryAttribute({componentDatatype:i.componentDatatype,componentsPerAttribute:i.componentsPerAttribute,normalize:i.normalize,values:[]})}return t}function b(e,t,n){for(const i in t)if(t.hasOwnProperty(i)&&r.defined(t[i])&&r.defined(t[i].values)){const r=t[i];for(let t=0;t=3){const n=6*(t-2),i=c.IndexDatatype.createTypedArray(t,n);h(i,0,e[0],e[1],e[2]);let r=6;for(let n=3;n0){const t=e.length-1,n=6*(t-1),i=c.IndexDatatype.createTypedArray(t,n),r=e[0];let a=0;for(let n=1;nr&&(r=n[e]);e.indices=m.tipsify({indices:n,maximumIndex:r,cacheSize:t})}return e},C.fitToUnsignedShortIndices=function(e){const t=[],n=u.Geometry.computeNumberOfVertices(e);if(r.defined(e.indices)&&n>=a.CesiumMath.SIXTY_FOUR_KILOBYTES){let n=[],i=[],s=0,o=v(e.attributes);const c=e.indices,l=c.length;let p;e.primitiveType===u.PrimitiveType.TRIANGLES?p=3:e.primitiveType===u.PrimitiveType.LINES?p=2:e.primitiveType===u.PrimitiveType.POINTS&&(p=1);for(let d=0;d=a.CesiumMath.SIXTY_FOUR_KILOBYTES&&(t.push(new u.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 u.Geometry({attributes:o,indices:i,primitiveType:e.primitiveType,boundingSphere:e.boundingSphere,boundingSphereCV:e.boundingSphereCV}))}else t.push(e);return t};const g=new n.Cartesian3,A=new n.Cartographic;C.projectTo2D=function(e,t,i,o,c){const l=e.attributes[t],p=(c=r.defined(c)?c:new s.GeographicProjection).ellipsoid,d=l.values,f=new Float64Array(d.length);let y=0;for(let e=0;eT&&(T=i)}return new u.Geometry({attributes:m,indices:b,primitiveType:y,boundingSphere:r.defined(A)?new s.BoundingSphere(A,T):void 0})}C.combineInstances=function(e){const t=[],n=[],i=e.length;for(let a=0;a0&&a.push(E(t,"geometry")),n.length>0&&(a.push(E(n,"westHemisphereGeometry")),a.push(E(n,"eastHemisphereGeometry"))),a};const N=new n.Cartesian3,L=new n.Cartesian3,z=new n.Cartesian3,D=new n.Cartesian3;C.computeNormal=function(e){const t=e.indices,i=e.attributes,r=i.position.values,s=i.position.values.length/3,o=t.length,c=new Array(s),l=new Array(o/3),p=new Array(o);let d;for(d=0;d0){for(f=0;f3&&(n[3]=0,n[4]=2,n[5]=3);let i=6;for(let e=3;e=0||t.x>=0||n.x>=0)return;!function(e,t,n){if(0!==e.y&&0!==t.y&&0!==n.y)return U(e,e.y<0),U(t,t.y<0),void U(n,n.y<0);const i=Math.abs(e.y),r=Math.abs(t.y),s=Math.abs(n.y);let o;o=i>r?i>s?a.CesiumMath.sign(e.y):a.CesiumMath.sign(n.y):r>s?a.CesiumMath.sign(t.y):a.CesiumMath.sign(n.y);const u=o<0;U(e,u),U(t,u),U(n,u)}(e,t,n);const i=e.y<0,r=t.y<0,s=n.y<0;let o=0;o+=i?1:0,o+=r?1:0,o+=s?1:0;const u=J.indices;1===o?(u[1]=3,u[2]=4,u[5]=6,u[7]=6,u[8]=5,i?(Z(e,t,H,X),Z(e,n,W,j),u[0]=0,u[3]=1,u[4]=2,u[6]=1):r?(Z(t,n,H,X),Z(t,e,W,j),u[0]=1,u[3]=2,u[4]=0,u[6]=2):s&&(Z(n,e,H,X),Z(n,t,W,j),u[0]=2,u[3]=0,u[4]=1,u[6]=0)):2===o&&(u[2]=4,u[4]=4,u[5]=3,u[7]=5,u[8]=6,i?r?s||(Z(n,e,H,X),Z(n,t,W,j),u[0]=0,u[1]=1,u[3]=0,u[6]=2):(Z(t,n,H,X),Z(t,e,W,j),u[0]=2,u[1]=0,u[3]=2,u[6]=1):(Z(e,t,H,X),Z(e,n,W,j),u[0]=1,u[1]=2,u[3]=1,u[6]=0));const c=J.positions;return c[0]=e,c[1]=t,c[2]=n,c.length=3,1!==o&&2!==o||(c[3]=H,c[4]=W,c[5]=X,c[6]=j,c.length=7),J}function Q(e,t){const n=e.attributes;if(0===n.position.values.length)return;for(const e in n)if(n.hasOwnProperty(e)&&r.defined(n[e])&&r.defined(n[e].values)){const t=n[e];t.values=a.ComponentDatatype.createTypedArray(t.componentDatatype,t.values)}const i=u.Geometry.computeNumberOfVertices(e);return e.indices=c.IndexDatatype.createTypedArray(i,e.indices),t&&(e.boundingSphere=s.BoundingSphere.fromVertices(n.position.values)),e}function $(e){const t=e.attributes,n={};for(const e in t)if(t.hasOwnProperty(e)&&r.defined(t[e])&&r.defined(t[e].values)){const i=t[e];n[e]=new u.GeometryAttribute({componentDatatype:i.componentDatatype,componentsPerAttribute:i.componentsPerAttribute,normalize:i.normalize,values:[]})}return new u.Geometry({attributes:n,indices:[],primitiveType:e.primitiveType})}function ee(e,t,n){const i=r.defined(e.geometry.boundingSphere);t=Q(t,i),n=Q(n,i),r.defined(n)&&!r.defined(t)?e.geometry=n:!r.defined(n)&&r.defined(t)?e.geometry=t:(e.westHemisphereGeometry=t,e.eastHemisphereGeometry=n,e.geometry=void 0)}function te(e,t){const n=new e,i=new e,r=new e;return function(a,s,o,u,c,l,p,d){const f=e.fromArray(c,a*t,n),y=e.fromArray(c,s*t,i),m=e.fromArray(c,o*t,r);e.multiplyByScalar(f,u.x,f),e.multiplyByScalar(y,u.y,y),e.multiplyByScalar(m,u.z,m);const C=e.add(f,y,f);e.add(C,m,C),d&&e.normalize(C,C),e.pack(C,l,p*t)}}const ne=te(n.Cartesian4,4),ie=te(n.Cartesian3,3),re=te(n.Cartesian2,2),ae=new n.Cartesian3,se=new n.Cartesian3,oe=new n.Cartesian3,ue=new n.Cartesian3;function ce(e,t,i,s,o,u,c,l,p,m,C,h,v,b,g,A){if(!(r.defined(u)||r.defined(c)||r.defined(l)||r.defined(p)||r.defined(m)||0!==b))return;const T=function(e,t,i,s,o){let u,c,l,p,m,C,h,v;if(r.defined(o)||(o=new n.Cartesian3),r.defined(t.z)){if(n.Cartesian3.equalsEpsilon(e,t,a.CesiumMath.EPSILON14))return n.Cartesian3.clone(n.Cartesian3.UNIT_X,o);if(n.Cartesian3.equalsEpsilon(e,i,a.CesiumMath.EPSILON14))return n.Cartesian3.clone(n.Cartesian3.UNIT_Y,o);if(n.Cartesian3.equalsEpsilon(e,s,a.CesiumMath.EPSILON14))return n.Cartesian3.clone(n.Cartesian3.UNIT_Z,o);u=n.Cartesian3.subtract(i,t,d),c=n.Cartesian3.subtract(s,t,f),l=n.Cartesian3.subtract(e,t,y),p=n.Cartesian3.dot(u,u),m=n.Cartesian3.dot(u,c),C=n.Cartesian3.dot(u,l),h=n.Cartesian3.dot(c,c),v=n.Cartesian3.dot(c,l)}else{if(n.Cartesian2.equalsEpsilon(e,t,a.CesiumMath.EPSILON14))return n.Cartesian3.clone(n.Cartesian3.UNIT_X,o);if(n.Cartesian2.equalsEpsilon(e,i,a.CesiumMath.EPSILON14))return n.Cartesian3.clone(n.Cartesian3.UNIT_Y,o);if(n.Cartesian2.equalsEpsilon(e,s,a.CesiumMath.EPSILON14))return n.Cartesian3.clone(n.Cartesian3.UNIT_Z,o);u=n.Cartesian2.subtract(i,t,d),c=n.Cartesian2.subtract(s,t,f),l=n.Cartesian2.subtract(e,t,y),p=n.Cartesian2.dot(u,u),m=n.Cartesian2.dot(u,c),C=n.Cartesian2.dot(u,l),h=n.Cartesian2.dot(c,c),v=n.Cartesian2.dot(c,l)}o.y=h*C-m*v,o.z=p*v-m*C;const b=p*h-m*m;if(0!==b)return o.y/=b,o.z/=b,o.x=1-o.y-o.z,o}(s,n.Cartesian3.fromArray(o,3*e,ae),n.Cartesian3.fromArray(o,3*t,se),n.Cartesian3.fromArray(o,3*i,oe),ue);if(r.defined(T)){if(r.defined(u)&&ie(e,t,i,T,u,h.normal.values,A,!0),r.defined(m)){const r=n.Cartesian3.fromArray(m,3*e,ae),a=n.Cartesian3.fromArray(m,3*t,se),s=n.Cartesian3.fromArray(m,3*i,oe);let o;n.Cartesian3.multiplyByScalar(r,T.x,r),n.Cartesian3.multiplyByScalar(a,T.y,a),n.Cartesian3.multiplyByScalar(s,T.z,s),n.Cartesian3.equals(r,n.Cartesian3.ZERO)&&n.Cartesian3.equals(a,n.Cartesian3.ZERO)&&n.Cartesian3.equals(s,n.Cartesian3.ZERO)?(o=ae,o.x=0,o.y=0,o.z=0):(o=n.Cartesian3.add(r,a,r),n.Cartesian3.add(o,s,o),n.Cartesian3.normalize(o,o)),n.Cartesian3.pack(o,h.extrudeDirection.values,3*A)}if(r.defined(C)&&function(e,t,n,i,r,s,o){const u=r[e]*i.x,c=r[t]*i.y,l=r[n]*i.z;s[o]=u+c+l>a.CesiumMath.EPSILON6?1:0}(e,t,i,T,C,h.applyOffset.values,A),r.defined(c)&&ie(e,t,i,T,c,h.tangent.values,A,!0),r.defined(l)&&ie(e,t,i,T,l,h.bitangent.values,A,!0),r.defined(p)&&re(e,t,i,T,p,h.st.values,A),b>0)for(let n=0;n3){const n=O.positions,r=O.indices,w=r.length;for(let S=0;S0)continue;const o=n.Cartesian3.unpack(r,e,Te);(t.y<0&&o.y>0||t.y>0&&o.y<0)&&(e-3>0?(r[e]=i[e-3],r[e+1]=i[e-2],r[e+2]=i[e-1]):n.Cartesian3.pack(t,r,e));const u=n.Cartesian3.unpack(a,e,xe);(t.y<0&&u.y>0||t.y>0&&u.y<0)&&(e+30||s.BoundingSphere.intersectPlane(i,p.Plane.ORIGIN_ZX_PLANE)!==s.Intersect.INTERSECTING)return e}if(t.geometryType!==u.GeometryType.NONE)switch(t.geometryType){case u.GeometryType.POLYLINES:!function(e){const t=e.geometry,i=t.attributes,s=i.position.values,o=i.prevPosition.values,u=i.nextPosition.values,c=i.expandAndWidth.values,p=r.defined(i.st)?i.st.values:void 0,d=r.defined(i.color)?i.color.values:void 0,f=$(t),y=$(t);let m,C,h,v=!1;const b=s.length/3;for(m=0;m