2 lines
9.6 KiB
JavaScript
2 lines
9.6 KiB
JavaScript
define(["exports","./buildModuleUrl-8cce5713","./FeatureDetection-ab6f364c","./when-b60132fc","./Check-7b2a090c","./GeometryAttribute-923c2729","./GeometryAttributes-252e9929","./GeometryPipeline-54076c24","./IndexDatatype-3565e02d","./WebMercatorProjection-6d3eefcc"],(function(e,t,r,n,i,o,a,s,d,p){"use strict";function u(e,t,r){e=n.defaultValue(e,0),t=n.defaultValue(t,0),r=n.defaultValue(r,0),this.value=new Float32Array([e,t,r])}function c(e,t){var n=e.attributes,i=n.position,a=i.values.length/i.componentsPerAttribute;n.batchId=new o.GeometryAttribute({componentDatatype:r.ComponentDatatype.FLOAT,componentsPerAttribute:1,values:new Float32Array(a)});for(var s=n.batchId.values,d=0;d<a;++d)s[d]=t}function f(e){var i,o,a=e.instances,d=e.projection,p=e.elementIndexUintSupported,u=e.scene3DOnly,f=e.vertexCacheOptimize,m=e.compressVertices,l=e.modelMatrix,h=a.length;for(i=0;i<h;++i)if(n.defined(a[i].geometry)){a[i].geometry.primitiveType;break}if(function(e,r,i){var o,a=!i,d=e.length;if(!a&&d>1){var p=e[0].modelMatrix;for(o=1;o<d;++o)if(!t.Matrix4.equals(p,e[o].modelMatrix)){a=!0;break}}if(a)for(o=0;o<d;++o)n.defined(e[o].geometry)&&s.GeometryPipeline.transformToWorldCoordinates(e[o]);else t.Matrix4.multiplyTransformation(r,e[0].modelMatrix,r)}(a,l,u),!u)for(i=0;i<h;++i)n.defined(a[i].geometry)&&s.GeometryPipeline.splitLongitude(a[i]);if(function(e){for(var t=e.length,r=0;r<t;++r){var i=e[r];n.defined(i.geometry)?c(i.geometry,r):n.defined(i.westHemisphereGeometry)&&n.defined(i.eastHemisphereGeometry)&&(c(i.westHemisphereGeometry,r),c(i.eastHemisphereGeometry,r))}}(a),f)for(i=0;i<h;++i){var g=a[i];n.defined(g.geometry)?(s.GeometryPipeline.reorderForPostVertexCache(g.geometry),s.GeometryPipeline.reorderForPreVertexCache(g.geometry)):n.defined(g.westHemisphereGeometry)&&n.defined(g.eastHemisphereGeometry)&&(s.GeometryPipeline.reorderForPostVertexCache(g.westHemisphereGeometry),s.GeometryPipeline.reorderForPreVertexCache(g.westHemisphereGeometry),s.GeometryPipeline.reorderForPostVertexCache(g.eastHemisphereGeometry),s.GeometryPipeline.reorderForPreVertexCache(g.eastHemisphereGeometry))}var y=s.GeometryPipeline.combineInstances(a);for(h=y.length,i=0;i<h;++i){var b,v=(o=y[i]).attributes;if(u)for(b in v)v.hasOwnProperty(b)&&v[b].componentDatatype===r.ComponentDatatype.DOUBLE&&s.GeometryPipeline.encodeAttribute(o,b,b+"3DHigh",b+"3DLow");else for(b in v)if(v.hasOwnProperty(b)&&v[b].componentDatatype===r.ComponentDatatype.DOUBLE){var G=b+"3D",x=b+"2D";s.GeometryPipeline.projectTo2D(o,b,G,x,d),n.defined(o.boundingSphere)&&"position"===b&&(o.boundingSphereCV=t.BoundingSphere.fromVertices(o.attributes.position2D.values)),s.GeometryPipeline.encodeAttribute(o,G,G+"High",G+"Low"),s.GeometryPipeline.encodeAttribute(o,x,x+"High",x+"Low")}m&&s.GeometryPipeline.compressVertices(o)}if(!p){var S=[];for(h=y.length,i=0;i<h;++i)o=y[i],S=S.concat(s.GeometryPipeline.fitToUnsignedShortIndices(o));y=S}return y}function m(e,t,r,i){var o,a,s,d=i.length-1;if(d>=0){var p=i[d];o=p.offset+p.count,a=r[s=p.index].indices.length}else o=0,a=r[s=0].indices.length;for(var u=e.length,c=0;c<u;++c){var f=e[c][t];if(n.defined(f)){var m=f.indices.length;o+m>a&&(o=0,a=r[++s].indices.length),i.push({index:s,offset:o,count:m}),o+=m}}}Object.defineProperties(u.prototype,{componentDatatype:{get:function(){return r.ComponentDatatype.FLOAT}},componentsPerAttribute:{get:function(){return 3}},normalize:{get:function(){return!1}}}),u.fromCartesian3=function(e){return new u(e.x,e.y,e.z)},u.toValue=function(e,t){return n.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 l={};function h(e,t){var r=e.attributes;for(var i in r)if(r.hasOwnProperty(i)){var o=r[i];n.defined(o)&&n.defined(o.values)&&t.push(o.values.buffer)}n.defined(e.indices)&&t.push(e.indices.buffer)}function g(e,r){var i=e.length,o=new Float64Array(1+19*i),a=0;o[a++]=i;for(var s=0;s<i;s++){var d=e[s];if(t.Matrix4.pack(d.modelMatrix,o,a),a+=t.Matrix4.packedLength,n.defined(d.attributes)&&n.defined(d.attributes.offset)){var p=d.attributes.offset.value;o[a]=p[0],o[a+1]=p[1],o[a+2]=p[2]}a+=3}return r.push(o.buffer),o}function y(e){var r=e.length,i=1+(t.BoundingSphere.packedLength+1)*r,o=new Float32Array(i),a=0;o[a++]=r;for(var s=0;s<r;++s){var d=e[s];n.defined(d)?(o[a++]=1,t.BoundingSphere.pack(e[s],o,a)):o[a++]=0,a+=t.BoundingSphere.packedLength}return o}function b(e){for(var r=new Array(e[0]),n=0,i=1;i<e.length;)1===e[i++]&&(r[n]=t.BoundingSphere.unpack(e,i)),++n,i+=t.BoundingSphere.packedLength;return r}l.combineGeometry=function(e){var r,i,o,a,d=e.instances,p=d.length,u=!1;p>0&&((r=f(e)).length>0&&(i=s.GeometryPipeline.createAttributeLocations(r[0]),e.createPickOffsets&&(o=function(e,t){var r=[];return m(e,"geometry",t,r),m(e,"westHemisphereGeometry",t,r),m(e,"eastHemisphereGeometry",t,r),r}(d,r))),n.defined(d[0].attributes)&&n.defined(d[0].attributes.offset)&&(a=new Array(p),u=!0));for(var c=new Array(p),l=new Array(p),h=0;h<p;++h){var g=d[h],y=g.geometry;n.defined(y)&&(c[h]=y.boundingSphere,l[h]=y.boundingSphereCV,u&&(a[h]=g.geometry.offsetAttribute));var b=g.eastHemisphereGeometry,v=g.westHemisphereGeometry;n.defined(b)&&n.defined(v)&&(n.defined(b.boundingSphere)&&n.defined(v.boundingSphere)&&(c[h]=t.BoundingSphere.union(b.boundingSphere,v.boundingSphere)),n.defined(b.boundingSphereCV)&&n.defined(v.boundingSphereCV)&&(l[h]=t.BoundingSphere.union(b.boundingSphereCV,v.boundingSphereCV)))}return{geometries:r,modelMatrix:e.modelMatrix,attributeLocations:i,pickOffsets:o,offsetInstanceExtend:a,boundingSpheres:c,boundingSpheresCV:l}},l.packCreateGeometryResults=function(e,r){var i=new Float64Array(function(e){for(var r=1,i=e.length,o=0;o<i;o++){var a=e[o];if(++r,n.defined(a)){var s=a.attributes;for(var d in r+=7+2*t.BoundingSphere.packedLength+(n.defined(a.indices)?a.indices.length:0),s)s.hasOwnProperty(d)&&n.defined(s[d])&&(r+=5+s[d].values.length)}}return r}(e)),o=[],a={},s=e.length,d=0;i[d++]=s;for(var p=0;p<s;p++){var u=e[p],c=n.defined(u);if(i[d++]=c?1:0,c){i[d++]=u.primitiveType,i[d++]=u.geometryType,i[d++]=n.defaultValue(u.offsetAttribute,-1);var f=n.defined(u.boundingSphere)?1:0;i[d++]=f,f&&t.BoundingSphere.pack(u.boundingSphere,i,d),d+=t.BoundingSphere.packedLength;var m=n.defined(u.boundingSphereCV)?1:0;i[d++]=m,m&&t.BoundingSphere.pack(u.boundingSphereCV,i,d),d+=t.BoundingSphere.packedLength;var l=u.attributes,h=[];for(var g in l)l.hasOwnProperty(g)&&n.defined(l[g])&&(h.push(g),n.defined(a[g])||(a[g]=o.length,o.push(g)));i[d++]=h.length;for(var y=0;y<h.length;y++){var b=h[y],v=l[b];i[d++]=a[b],i[d++]=v.componentDatatype,i[d++]=v.componentsPerAttribute,i[d++]=v.normalize?1:0,i[d++]=v.values.length,i.set(v.values,d),d+=v.values.length}var G=n.defined(u.indices)?u.indices.length:0;i[d++]=G,G>0&&(i.set(u.indices,d),d+=G)}}return r.push(i.buffer),{stringTable:o,packedData:i}},l.unpackCreateGeometryResults=function(e){for(var n,i=e.stringTable,s=e.packedData,p=new Array(s[0]),u=0,c=1;c<s.length;){if(1===s[c++]){var f,m,l,h,g,y=s[c++],b=s[c++],v=s[c++];-1===v&&(v=void 0),1===s[c++]&&(f=t.BoundingSphere.unpack(s,c)),c+=t.BoundingSphere.packedLength,1===s[c++]&&(m=t.BoundingSphere.unpack(s,c)),c+=t.BoundingSphere.packedLength;var G,x=new a.GeometryAttributes,S=s[c++];for(n=0;n<S;n++){var P=i[s[c++]],k=s[c++];g=s[c++];var C=0!==s[c++];l=s[c++],h=r.ComponentDatatype.createTypedArray(k,l);for(var w=0;w<l;w++)h[w]=s[c++];x[P]=new o.GeometryAttribute({componentDatatype:k,componentsPerAttribute:g,normalize:C,values:h})}if((l=s[c++])>0){var A=h.length/g;for(G=d.IndexDatatype.createTypedArray(A,l),n=0;n<l;n++)G[n]=s[c++]}p[u++]=new o.Geometry({primitiveType:y,geometryType:b,boundingSphere:f,boundingSphereCV:m,indices:G,attributes:x,offsetAttribute:v})}else p[u++]=void 0}return p},l.packCombineGeometryParameters=function(e,r){for(var n=e.createGeometryResults,i=n.length,o=0;o<i;o++)r.push(n[o].packedData.buffer);return{createGeometryResults:e.createGeometryResults,packedInstances:g(e.instances,r),ellipsoid:e.ellipsoid,isGeographic:e.projection instanceof t.GeographicProjection,elementIndexUintSupported:e.elementIndexUintSupported,scene3DOnly:e.scene3DOnly,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e.createPickOffsets}},l.unpackCombineGeometryParameters=function(e){for(var r=function(e){for(var r=e,i=new Array(r[0]),o=0,a=1;a<r.length;){var s,d=t.Matrix4.unpack(r,a);a+=t.Matrix4.packedLength,n.defined(r[a])&&(s={offset:new u(r[a],r[a+1],r[a+2])}),a+=3,i[o++]={modelMatrix:d,attributes:s}}return i}(e.packedInstances),i=e.createGeometryResults,o=i.length,a=0,s=0;s<o;s++)for(var d=l.unpackCreateGeometryResults(i[s]),c=d.length,f=0;f<c;f++){var m=d[f];r[a].geometry=m,++a}var h=t.Ellipsoid.clone(e.ellipsoid);return{instances:r,ellipsoid:h,projection:e.isGeographic?new t.GeographicProjection(h):new p.WebMercatorProjection(h),elementIndexUintSupported:e.elementIndexUintSupported,scene3DOnly:e.scene3DOnly,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:t.Matrix4.clone(e.modelMatrix),createPickOffsets:e.createPickOffsets}},l.packCombineGeometryResults=function(e,t){n.defined(e.geometries)&&function(e,t){for(var r=e.length,n=0;n<r;++n)h(e[n],t)}(e.geometries,t);var r=y(e.boundingSpheres),i=y(e.boundingSpheresCV);return t.push(r.buffer,i.buffer),{geometries:e.geometries,attributeLocations:e.attributeLocations,modelMatrix:e.modelMatrix,pickOffsets:e.pickOffsets,offsetInstanceExtend:e.offsetInstanceExtend,boundingSpheres:r,boundingSpheresCV:i}},l.unpackCombineGeometryResults=function(e){return{geometries:e.geometries,attributeLocations:e.attributeLocations,modelMatrix:e.modelMatrix,pickOffsets:e.pickOffsets,offsetInstanceExtend:e.offsetInstanceExtend,boundingSpheres:b(e.boundingSpheres),boundingSpheresCV:b(e.boundingSpheresCV)}},e.PrimitivePipeline=l}));
|