| 1 |
- import{a as R}from"./chunk-EAHMNWOP.js";import{a as y}from"./chunk-AOW426VA.js";import{a as B}from"./chunk-XKBSMKNP.js";import{a as U}from"./chunk-J4ID4JKR.js";import{a as L,d as m,n as H,o as D}from"./chunk-K2IDXOCV.js";import{b as w}from"./chunk-45OWWDV7.js";import{a as S}from"./chunk-JX5O4HI2.js";import{a as E}from"./chunk-CUQT2UK5.js";import{a as O}from"./chunk-4D2ERGZX.js";import{a as I}from"./chunk-EDZQSM3T.js";import{a as z}from"./chunk-PJGSCWXZ.js";import{a as v}from"./chunk-NUC3LT2W.js";function A(e,t,r){e=O(e,0),t=O(t,0),r=O(r,0),this.value=new Float32Array([e,t,r])}Object.defineProperties(A.prototype,{componentDatatype:{get:function(){return S.FLOAT}},componentsPerAttribute:{get:function(){return 3}},normalize:{get:function(){return!1}}});A.fromCartesian3=function(e){return I.defined("offset",e),new A(e.x,e.y,e.z)};A.toValue=function(e,t){return I.defined("offset",e),v(t)||(t=new Float32Array([e.x,e.y,e.z])),t[0]=e.x,t[1]=e.y,t[2]=e.z,t};var j=A;function Y(e,t,r){var o=!r,i=e.length,f;if(!o&&i>1){var n=e[0].modelMatrix;for(f=1;f<i;++f)if(!w.equals(n,e[f].modelMatrix)){o=!0;break}}if(o)for(f=0;f<i;++f)v(e[f].geometry)&&y.transformToWorldCoordinates(e[f]);else w.multiplyTransformation(t,e[0].modelMatrix,t)}function P(e,t){var r=e.attributes,o=r.position,i=o.values.length/o.componentsPerAttribute;r.batchId=new D({componentDatatype:S.FLOAT,componentsPerAttribute:1,values:new Float32Array(i)});for(var f=r.batchId.values,n=0;n<i;++n)f[n]=t}function Z(e){for(var t=e.length,r=0;r<t;++r){var o=e[r];v(o.geometry)?P(o.geometry,r):v(o.westHemisphereGeometry)&&v(o.eastHemisphereGeometry)&&(P(o.westHemisphereGeometry,r),P(o.eastHemisphereGeometry,r))}}function _(e){var t=e.instances,r=e.projection,o=e.elementIndexUintSupported,i=e.scene3DOnly,f=e.vertexCacheOptimize,n=e.compressVertices,l=e.modelMatrix,a,p,h,u=t.length;for(a=0;a<u;++a)if(v(t[a].geometry)){h=t[a].geometry.primitiveType;break}for(a=1;a<u;++a)if(v(t[a].geometry)&&t[a].geometry.primitiveType!==h)throw new z("All instance geometries must have the same primitiveType.");if(Y(t,l,i),!i)for(a=0;a<u;++a)v(t[a].geometry)&&y.splitLongitude(t[a]);if(Z(t),f)for(a=0;a<u;++a){var c=t[a];v(c.geometry)?(y.reorderForPostVertexCache(c.geometry),y.reorderForPreVertexCache(c.geometry)):v(c.westHemisphereGeometry)&&v(c.eastHemisphereGeometry)&&(y.reorderForPostVertexCache(c.westHemisphereGeometry),y.reorderForPreVertexCache(c.westHemisphereGeometry),y.reorderForPostVertexCache(c.eastHemisphereGeometry),y.reorderForPreVertexCache(c.eastHemisphereGeometry))}var d=y.combineInstances(t);for(u=d.length,a=0;a<u;++a){p=d[a];var g=p.attributes,s;if(i)for(s in g)g.hasOwnProperty(s)&&g[s].componentDatatype===S.DOUBLE&&y.encodeAttribute(p,s,s+"3DHigh",s+"3DLow");else for(s in g)if(g.hasOwnProperty(s)&&g[s].componentDatatype===S.DOUBLE){var x=s+"3D",b=s+"2D";y.projectTo2D(p,s,x,b,r),v(p.boundingSphere)&&s==="position"&&(p.boundingSphereCV=m.fromVertices(p.attributes.position2D.values)),y.encodeAttribute(p,x,x+"High",x+"Low"),y.encodeAttribute(p,b,b+"High",b+"Low")}n&&y.compressVertices(p)}if(!o){var C=[];for(u=d.length,a=0;a<u;++a)p=d[a],C=C.concat(y.fitToUnsignedShortIndices(p));d=C}return d}function T(e,t,r,o){var i,f,n,l=o.length-1;if(l>=0){var a=o[l];i=a.offset+a.count,n=a.index,f=r[n].indices.length}else i=0,n=0,f=r[n].indices.length;for(var p=e.length,h=0;h<p;++h){var u=e[h],c=u[t];if(!!v(c)){var d=c.indices.length;i+d>f&&(i=0,f=r[++n].indices.length),o.push({index:n,offset:i,count:d}),i+=d}}}function $(e,t){var r=[];return T(e,"geometry",t,r),T(e,"westHemisphereGeometry",t,r),T(e,"eastHemisphereGeometry",t,r),r}var k={};k.combineGeometry=function(e){var t,r,o=e.instances,i=o.length,f,n,l=!1;i>0&&(t=_(e),t.length>0&&(r=y.createAttributeLocations(t[0]),e.createPickOffsets&&(f=$(o,t))),v(o[0].attributes)&&v(o[0].attributes.offset)&&(n=new Array(i),l=!0));for(var a=new Array(i),p=new Array(i),h=0;h<i;++h){var u=o[h],c=u.geometry;v(c)&&(a[h]=c.boundingSphere,p[h]=c.boundingSphereCV,l&&(n[h]=u.geometry.offsetAttribute));var d=u.eastHemisphereGeometry,g=u.westHemisphereGeometry;v(d)&&v(g)&&(v(d.boundingSphere)&&v(g.boundingSphere)&&(a[h]=m.union(d.boundingSphere,g.boundingSphere)),v(d.boundingSphereCV)&&v(g.boundingSphereCV)&&(p[h]=m.union(d.boundingSphereCV,g.boundingSphereCV)))}return{geometries:t,modelMatrix:e.modelMatrix,attributeLocations:r,pickOffsets:f,offsetInstanceExtend:n,boundingSpheres:a,boundingSpheresCV:p}};function q(e,t){var r=e.attributes;for(var o in r)if(r.hasOwnProperty(o)){var i=r[o];v(i)&&v(i.values)&&t.push(i.values.buffer)}v(e.indices)&&t.push(e.indices.buffer)}function ee(e,t){for(var r=e.length,o=0;o<r;++o)q(e[o],t)}function re(e){for(var t=1,r=e.length,o=0;o<r;o++){var i=e[o];if(++t,!!v(i)){var f=i.attributes;t+=7+2*m.packedLength+(v(i.indices)?i.indices.length:0);for(var n in f)if(f.hasOwnProperty(n)&&v(f[n])){var l=f[n];t+=6+l.values.length}}}return t}k.packCreateGeometryResults=function(e,t){var r=new Float64Array(re(e)),o=[],i={},f=e.length,n=0;r[n++]=f;for(var l=0;l<f;l++){var a=e[l],p=v(a);if(r[n++]=p?1:0,!!p){r[n++]=a.primitiveType,r[n++]=a.geometryType,r[n++]=O(a.offsetAttribute,-1);var h=v(a.boundingSphere)?1:0;r[n++]=h,h&&m.pack(a.boundingSphere,r,n),n+=m.packedLength;var u=v(a.boundingSphereCV)?1:0;r[n++]=u,u&&m.pack(a.boundingSphereCV,r,n),n+=m.packedLength;var c=a.attributes,d=[];for(var g in c)c.hasOwnProperty(g)&&v(c[g])&&(d.push(g),v(i[g])||(i[g]=o.length,o.push(g)));r[n++]=d.length;for(var s=0;s<d.length;s++){var x=d[s],b=c[x];r[n++]=i[x],r[n++]=b.componentDatatype,r[n++]=b.componentsPerAttribute,r[n++]=b.normalize?1:0,r[n++]=b.isInstanceAttribute?1:0,r[n++]=b.values.length,r.set(b.values,n),n+=b.values.length}var C=v(a.indices)?a.indices.length:0;r[n++]=C,C>0&&(r.set(a.indices,n),n+=C)}}return t.push(r.buffer),{stringTable:o,packedData:r}};k.unpackCreateGeometryResults=function(e){for(var t=e.stringTable,r=e.packedData,o,i=new Array(r[0]),f=0,n=1;n<r.length;){var l=r[n++]===1;if(!l){i[f++]=void 0;continue}var a=r[n++],p=r[n++],h=r[n++];h===-1&&(h=void 0);var u,c,d=r[n++]===1;d&&(u=m.unpack(r,n)),n+=m.packedLength;var g=r[n++]===1;g&&(c=m.unpack(r,n)),n+=m.packedLength;var s,x,b,C=new U,K=r[n++];for(o=0;o<K;o++){var M=t[r[n++]],F=r[n++];b=r[n++];var N=r[n++]!==0,Q=r[n++]!==0;s=r[n++],x=S.createTypedArray(F,s);for(var G=0;G<s;G++)x[G]=r[n++];C[M]=new D({componentDatatype:F,componentsPerAttribute:b,normalize:N,values:x}),Q&&(C[M].isInstanceAttribute=!0)}var V;if(s=r[n++],s>0){var X=x.length/b;for(V=B.createTypedArray(X,s),o=0;o<s;o++)V[o]=r[n++]}i[f++]=new H({primitiveType:a,geometryType:p,boundingSphere:u,boundingSphereCV:c,indices:V,attributes:C,offsetAttribute:h})}return i};function te(e,t){var r=e.length,o=new Float64Array(1+r*19),i=0;o[i++]=r;for(var f=0;f<r;f++){var n=e[f];if(w.pack(n.modelMatrix,o,i),i+=w.packedLength,v(n.attributes)&&v(n.attributes.offset)){var l=n.attributes.offset.value;o[i]=l[0],o[i+1]=l[1],o[i+2]=l[2]}i+=3}return t.push(o.buffer),o}function ne(e){for(var t=e,r=new Array(t[0]),o=0,i=1;i<t.length;){var f=w.unpack(t,i),n;i+=w.packedLength,v(t[i])&&(n={offset:new j(t[i],t[i+1],t[i+2])}),i+=3,r[o++]={modelMatrix:f,attributes:n}}return r}k.packCombineGeometryParameters=function(e,t){for(var r=e.createGeometryResults,o=r.length,i=0;i<o;i++)t.push(r[i].packedData.buffer);return{createGeometryResults:e.createGeometryResults,packedInstances:te(e.instances,t),ellipsoid:e.ellipsoid,isGeographic:e.projection instanceof L,elementIndexUintSupported:e.elementIndexUintSupported,scene3DOnly:e.scene3DOnly,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e.createPickOffsets}};k.unpackCombineGeometryParameters=function(e){for(var t=ne(e.packedInstances),r=e.createGeometryResults,o=r.length,i=0,f=0;f<o;f++)for(var n=k.unpackCreateGeometryResults(r[f]),l=n.length,a=0;a<l;a++){var p=n[a],h=t[i];h.geometry=p,++i}var u=E.clone(e.ellipsoid),c=e.isGeographic?new L(u):new R(u);return{instances:t,ellipsoid:u,projection:c,elementIndexUintSupported:e.elementIndexUintSupported,scene3DOnly:e.scene3DOnly,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:w.clone(e.modelMatrix),createPickOffsets:e.createPickOffsets}};function W(e){var t=e.length,r=1+(m.packedLength+1)*t,o=new Float32Array(r),i=0;o[i++]=t;for(var f=0;f<t;++f){var n=e[f];v(n)?(o[i++]=1,m.pack(e[f],o,i)):o[i++]=0,i+=m.packedLength}return o}function J(e){for(var t=new Array(e[0]),r=0,o=1;o<e.length;)e[o++]===1&&(t[r]=m.unpack(e,o)),++r,o+=m.packedLength;return t}k.packCombineGeometryResults=function(e,t){v(e.geometries)&&ee(e.geometries,t);var r=W(e.boundingSpheres),o=W(e.boundingSpheresCV);return t.push(r.buffer,o.buffer),{geometries:e.geometries,attributeLocations:e.attributeLocations,modelMatrix:e.modelMatrix,pickOffsets:e.pickOffsets,offsetInstanceExtend:e.offsetInstanceExtend,boundingSpheres:r,boundingSpheresCV:o}};k.unpackCombineGeometryResults=function(e){return{geometries:e.geometries,attributeLocations:e.attributeLocations,modelMatrix:e.modelMatrix,pickOffsets:e.pickOffsets,offsetInstanceExtend:e.offsetInstanceExtend,boundingSpheres:J(e.boundingSpheres),boundingSpheresCV:J(e.boundingSpheresCV)}};var Se=k;export{Se as a};
|