text: define(["exports","./when-54c2dc71","./Check-6c0211bc","./Cartesian2-57a76c50","./Transforms-9d269426","./ComponentDatatype-6d99a1ee","./GeometryAttribute-13f079b1","./GeometryAttributes-4fcfcf40","./GeometryPipeline-69e5d6e8","./IndexDatatype-53503fee","./WebMercatorProjection-7159ad73"],function(e,y,t,C,k,A,w,V,b,D,f){"use strict";function c(e,t,r){e=y.defaultValue(e,0),t=y.defaultValue(t,0),r=y.defaultValue(r,0),this.value=new Float32Array([e,t,r])}function v(e,t){var r=e.attributes,e=r.position,n=e.values.length/e.componentsPerAttribute;r.batchId=new w.GeometryAttribute({componentDatatype:A.ComponentDatatype.FLOAT,componentsPerAttribute:1,values:new Float32Array(n)});for(var i=r.batchId.values,o=0;o<n;++o)i[o]=t}function g(e){var t,r=e.instances,n=e.projection,i=e.elementIndexUintSupported,o=e.scene3DOnly,a=e.vertexCacheOptimize,s=e.compressVertices,e=e.modelMatrix,d=r.length;for(g=0;g<d;++g)if(y.defined(r[g].geometry)){r[g].geometry.primitiveType;break}if(!function(e,t,r){var n=!r,i=e.length;if(!n&&1<i)for(var o=e[0].modelMatrix,a=1;a<i;++a)if(!k.Matrix4.equals(o,e[a].modelMatrix)){n=!0;break}if(n)for(a=0;a<i;++a)y.defined(e[a].geometry)&&b.GeometryPipeline.transformToWorldCoordinates(e[a]);else k.Matrix4.multiplyTransformation(t,e[0].modelMatrix,t)}(r,e,o),!o)for(g=0;g<d;++g)y.defined(r[g].geometry)&&b.GeometryPipeline.splitLongitude(r[g]);if(!function(e){for(var t=e.length,r=0;r<t;++r){var n=e[r];y.defined(n.geometry)?v(n.geometry,r):y.defined(n.westHemisphereGeometry)&&y.defined(n.eastHemisphereGeometry)&&(v(n.westHemisphereGeometry,r),v(n.eastHemisphereGeometry,r))}}(r),a)for(g=0;g<d;++g){var p=r[g];y.defined(p.geometry)?(b.GeometryPipeline.reorderForPostVertexCache(p.geometry),b.GeometryPipeline.reorderForPreVertexCache(p.geometry)):y.defined(p.westHemisphereGeometry)&&y.defined(p.eastHemisphereGeometry)&&(b.GeometryPipeline.reorderForPostVertexCache(p.westHemisphereGeometry),b.GeometryPipeline.reorderForPreVertexCache(p.westHemisphereGeometry),b.GeometryPipeline.reorderForPostVertexCache(p.eastHemisphereGeometry),b.GeometryPipeline.reorderForPreVertexCache(p.eastHemisphereGeometry))}var u=b.GeometryPipeline.combineInstances(r);for(d=u.length,g=0;g<d;++g){var f,c,m,h=(t=u[g]).attributes;if(o)for(f in h)h.hasOwnProperty(f)&&h[f].componentDatatype===A.ComponentDatatype.DOUBLE&&b.GeometryPipeline.encodeAttribute(t,f,f+"3DHigh",f+"3DLow");else for(f in h){h.hasOwnProperty(f)&&h[f].componentDatatype===A.ComponentDatatype.DOUBLE&&(c=f+"3D",m=f+"2D",b.GeometryPipeline.projectTo2D(t,f,c,m,n),y.defined(t.boundingSphere)&&"position"===f&&(t.boundingSphereCV=k.BoundingSphere.fromVertices(t.attributes.position2D.values)),b.GeometryPipeline.encodeAttribute(t,c,c+"High",c+"Low"),b.GeometryPipeline.encodeAttribute(t,m,m+"High",m+"Low"))}s&&b.GeometryPipeline.compressVertices(t)}if(!i){for(var l=[],d=u.length,g=0;g<d;++g)t=u[g],l=l.concat(b.GeometryPipeline.fitToUnsignedShortIndices(t));u=l}return u}function x(e,t,r,n){var i,o,a,s=n.length-1;a=0<=s?(i=(s=n[s]).offset+s.count,r[o=s.index].indices.length):r[o=i=0].indices.length;for(var d=e.length,p=0;p<d;++p){var u=e[p][t];y.defined(u)&&(a<i+(u=u.indices.length)&&(i=0,a=r[++o].indices.length),n.push({index:o,offset:i,count:u}),i+=u)}}Object.defineProperties(c.prototype,{componentDatatype:{get:function(){return A.ComponentDatatype.FLOAT}},componentsPerAttribute:{get:function(){return 3}},normalize:{get:function(){return!1}}}),c.fromCartesian3=function(e){return new c(e.x,e.y,e.z)},c.toValue=function(e,t){return y.defined(t)||(t=new Float32Array([e.x,e.y,e.z])),t[0]=e.x,t[1]=e.y,t[2]=e.z,t};var m={};function i(e,t){for(var r=e.length,n=0;n<r;++n)!function(e,t){var r,n,i=e.attributes;for(r in i){i.hasOwnProperty(r)&&(n=i[r],y.defined(n)&&y.defined(n.values)&&t.push(n.values.buffer))}y.defined(e.indices)&&t.push(e.indices.buffer)}(e[n],t)}function o(e){var t=e.length,r=1+(k.BoundingSphere.packedLength+1)*t,n=new Float32Array(r),i=0;n[i++]=t;for(var o=0;o<t;++o){var a=e[o];y.defined(a)?(n[i++]=1,k.BoundingSphere.pack(e[o],n,i)):n[i++]=0,i+=k.BoundingSphere.packedLength}return n}function r(e){for(var t=new Array(e[0]),r=0,n=1;n<e.length;)1===e[n++]&&(t[r]=k.BoundingSphere.unpack(e,n)),++r,n+=k.BoundingSphere.packedLength;return t}m.combineGeometry=function(e){var t,r,n,i,o,a,s=e.instances,d=s.length,p=!1;0<d&&(0<(t=g(e)).length&&(r=b.GeometryPipeline.createAttributeLocations(t[0]),e.createPickOffsets&&(x(i=s,"geometry",o=t,a=[]),x(i,"westHemisphereGeometry",o,a),x(i,"eastHemisphereGeometry",o,a),a=a)),y.defined(s[0].attributes)&&y.defined(s[0].attributes.offset)&&(n=new Array(d),p=!0));for(var u=new Array(d),f=new Array(d),c=new Array(d),m=0;m<d;++m){var h=s[m],l=h.geometry;y.defined(l)&&(u[m]=l.boundingSphere,f[m]=l.boundingSphereCV,c[m]=[l.MaxPoint,l.MinPoint],p&&(n[m]=h.geometry.offsetAttribute));l=h.eastHemisphereGeometry,h=h.westHemisphereGeometry;y.defined(l)&&y.defined(h)&&(y.defined(l.boundingSphere)&&y.defined(h.boundingSphere)&&(u[m]=k.BoundingSphere.union(l.boundingSphere,h.boundingSphere)),y.defined(l.boundingSphereCV)&&y.defined(h.boundingSphereCV)&&(f[m]=k.BoundingSphere.union(l.boundingSphereCV,h.boundingSphereCV)))}return{geometries:t,modelMatrix:e.modelMatrix,attributeLocations:r,pickOffsets:a,offsetInstanceExtend:n,boundingSpheres:u,boundingSpheresCV:f,MaxMinArr:c}},m.packCreateGeometryResults=function(e,t){var r=new Float64Array(function(e){for(var t=1,r=e.length,n=0;n<r;n++){var i=e[n];if(++t,y.defined(i)){var o,a=i.attributes;for(o in t+=8+(y.defined(i.MaxPoint)?6:0)+2*k.BoundingSphere.packedLength+(y.defined(i.indices)?i.indices.length:0),a){a.hasOwnProperty(o)&&y.defined(a[o])&&(t+=5+a[o].values.length)}}}return t}(e)),n=[],i={},o=e.length,a=0;r[a++]=o;for(var s=0;s<o;s++){var d=e[s],p=y.defined(d);if(r[a++]=p?1:0,p){r[a++]=d.primitiveType,r[a++]=d.geometryType,y.defined(d.MaxPoint)?(r[a++]=1,r[a++]=d.MaxPoint.x,r[a++]=d.MaxPoint.y,r[a++]=d.MaxPoint.z,r[a++]=d.MinPoint.x,r[a++]=d.MinPoint.y,r[a++]=d.MinPoint.z):r[a++]=0,r[a++]=y.defaultValue(d.offsetAttribute,-1);p=y.defined(d.boundingSphere)?1:0;(r[a++]=p)&&k.BoundingSphere.pack(d.boundingSphere,r,a),a+=k.BoundingSphere.packedLength;p=y.defined(d.boundingSphereCV)?1:0;(r[a++]=p)&&k.BoundingSphere.pack(d.boundingSphereCV,r,a),a+=k.BoundingSphere.packedLength;var u,f=d.attributes,c=[];for(u in f)f.hasOwnProperty(u)&&y.defined(f[u])&&(c.push(u),y.defined(i[u])||(i[u]=n.length,n.push(u)));r[a++]=c.length;for(var m=0;m<c.length;m++){var h=c[m],l=f[h];r[a++]=i[h],r[a++]=l.componentDatatype,r[a++]=l.componentsPerAttribute,r[a++]=l.normalize?1:0,r[a++]=l.values.length,r.set(l.values,a),a+=l.values.length}p=y.defined(d.indices)?d.indices.length:0;0<(r[a++]=p)&&(r.set(d.indices,a),a+=p)}}return t.push(r.buffer),{stringTable:n,packedData:r}},m.unpackCreateGeometryResults=function(e){for(var t=e.stringTable,r=e.packedData,n=new Array(r[0]),i=0,o=1;o<r.length;){if(1===r[o++]){var a=r[o++],s=r[o++],d=r[o++],p=new C.Cartesian3,u=new C.Cartesian3;1===d&&(p.x=r[o++],p.y=r[o++],p.z=r[o++],u.x=r[o++],u.y=r[o++],u.z=r[o++]);var f,c,m=r[o++];-1===m&&(m=void 0),1===r[o++]&&(f=k.BoundingSphere.unpack(r,o)),o+=k.BoundingSphere.packedLength,1===r[o++]&&(c=k.BoundingSphere.unpack(r,o)),o+=k.BoundingSphere.packedLength;var h=new V.GeometryAttributes,l=r[o++];for(M=0;M<l;M++){for(var g=t[r[o++]],y=r[o++],b=r[o++],v=0!==r[o++],x=r[o++],P=A.ComponentDatatype.createTypedArray(y,x),G=0;G<x;G++)P[G]=r[o++];h[g]=new w.GeometryAttribute({componentDatatype:y,componentsPerAttribute:b,normalize:v,values:P})}if(0<(x=r[o++]))for(var d=P.length/b,S=D.IndexDatatype.createTypedArray(d,x),M=0;M<x;M++)S[M]=r[o++];n[i++]=new w.Geometry({primitiveType:a,geometryType:s,boundingSphere:f,boundingSphereCV:c,indices:S,attributes:h,offsetAttribute:m,MaxPoint:p,MinPoint:u})}else n[i++]=void 0}return n},m.packCombineGeometryParameters=function(e,t){for(var r=e.createGeometryResults,n=r.length,i=0;i<n;i++)t.push(r[i].packedData.buffer);return{createGeometryResults:e.createGeometryResults,packedInstances:function(e,t){var r=e.length,n=new Float64Array(1+19*r),i=0;n[i++]=r;for(var o=0;o<r;o++){var a=e[o];k.Matrix4.pack(a.modelMatrix,n,i),i+=k.Matrix4.packedLength,y.defined(a.attributes)&&y.defined(a.attributes.offset)&&(a=a.attributes.offset.value,n[i]=a[0],n[i+1]=a[1],n[i+2]=a[2]),i+=3}return t.push(n.buffer),n}(e.instances,t),ellipsoid:e.ellipsoid,isGeographic:e.projection instanceof k.GeographicProjection,elementIndexUintSupported:e.elementIndexUintSupported,scene3DOnly:e.scene3DOnly,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e.createPickOffsets}},m.unpackCombineGeometryParameters=function(e){for(var t=function(e){for(var t=e,r=new Array(t[0]),n=0,i=1;i<t.length;){var o,a=k.Matrix4.unpack(t,i);i+=k.Matrix4.packedLength,y.defined(t[i])&&(o={offset:new c(t[i],t[i+1],t[i+2])}),i+=3,r[n++]={modelMatrix:a,attributes:o}}return r}(e.packedInstances),r=e.createGeometryResults,n=r.length,i=0,o=0;o<n;o++)for(var a=m.unpackCreateGeometryResults(r[o]),s=a.length,d=0;d<s;d++){var p=a[d];t[i].geometry=p,++i}var u=C.Ellipsoid.clone(e.ellipsoid);return{instances:t,ellipsoid:u,projection:new(e.isGeographic?k.GeographicProjection:f.WebMercatorProjection)(u),elementIndexUintSupported:e.elementIndexUintSupported,scene3DOnly:e.scene3DOnly,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:k.Matrix4.clone(e.modelMatrix),createPickOffsets:e.createPickOffsets}},m.packCombineGeometryResults=function(e,t){y.defined(e.geometries)&&i(e.geometries,t);var r=o(e.boundingSpheres),n=o(e.boundingSpheresCV);return t.push(r.buffer,n.buffer),{geometries:e.geometries,attributeLocations:e.attributeLocations,modelMatrix:e.modelMatrix,pickOffsets:e.pickOffsets,offsetInstanceExtend:e.offsetInstanceExtend,boundingSpheres:r,boundingSpheresCV:n,MaxMinArr:e.MaxMinArr}},m.unpackCombineGeometryResults=function(e){return{geometries:e.geometries,attributeLocations:e.attributeLocations,modelMatrix:e.modelMatrix,pickOffsets:e.pickOffsets,offsetInstanceExtend:e.offsetInstanceExtend,boundingSpheres:r(e.boundingSpheres),boundingSpheresCV:r(e.boundingSpheresCV),MaxMinArr:e.MaxMinArr}},e.PrimitivePipeline=m});
  