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