/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.96.6 * * Copyright 2011-2022 Cesium Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details. */ define(["exports","./Transforms-66eda18c","./ComponentDatatype-438cad2a","./defaultValue-028a8a27","./RuntimeError-a977b8e0","./Matrix2-4706dd70","./GeometryAttribute-2cdece80","./GeometryAttributes-98e858da","./GeometryPipeline-d062bcb6","./IndexDatatype-dfa09980","./WebMercatorProjection-9bd06b6c"],(function(e,t,n,r,o,i,s,c,a,d,p){"use strict";function u(e,t,n){e=r.defaultValue(e,0),t=r.defaultValue(t,0),n=r.defaultValue(n,0),this.value=new Float32Array([e,t,n])}function f(e,t,n){let o=!n;const s=e.length;let c;if(!o&&s>1){const t=e[0].modelMatrix;for(c=1;c<s;++c)if(!i.Matrix4.equals(t,e[c].modelMatrix)){o=!0;break}}if(o)for(c=0;c<s;++c)r.defined(e[c].geometry)&&a.GeometryPipeline.transformToWorldCoordinates(e[c]);else i.Matrix4.multiplyTransformation(t,e[0].modelMatrix,t)}function l(e,t){const r=e.attributes,o=r.position,i=o.values.length/o.componentsPerAttribute;r.batchId=new s.GeometryAttribute({componentDatatype:n.ComponentDatatype.FLOAT,componentsPerAttribute:1,values:new Float32Array(i)});const c=r.batchId.values;for(let n=0;n<i;++n)c[n]=t}function m(e){const t=e.length;for(let n=0;n<t;++n){const t=e[n];r.defined(t.geometry)?l(t.geometry,n):r.defined(t.westHemisphereGeometry)&&r.defined(t.eastHemisphereGeometry)&&(l(t.westHemisphereGeometry,n),l(t.eastHemisphereGeometry,n))}}function h(e){const i=e.instances,s=e.projection,c=e.elementIndexUintSupported,d=e.scene3DOnly,p=e.vertexCacheOptimize,u=e.compressVertices,l=e.modelMatrix;let h,g,y,b=i.length;for(h=0;h<b;++h)if(r.defined(i[h].geometry)){y=i[h].geometry.primitiveType;break}for(h=1;h<b;++h)if(r.defined(i[h].geometry)&&i[h].geometry.primitiveType!==y)throw new o.DeveloperError("All instance geometries must have the same primitiveType.");if(f(i,l,d),!d)for(h=0;h<b;++h)r.defined(i[h].geometry)&&a.GeometryPipeline.splitLongitude(i[h]);if(m(i),p)for(h=0;h<b;++h){const e=i[h];r.defined(e.geometry)?(a.GeometryPipeline.reorderForPostVertexCache(e.geometry),a.GeometryPipeline.reorderForPreVertexCache(e.geometry)):r.defined(e.westHemisphereGeometry)&&r.defined(e.eastHemisphereGeometry)&&(a.GeometryPipeline.reorderForPostVertexCache(e.westHemisphereGeometry),a.GeometryPipeline.reorderForPreVertexCache(e.westHemisphereGeometry),a.GeometryPipeline.reorderForPostVertexCache(e.eastHemisphereGeometry),a.GeometryPipeline.reorderForPreVertexCache(e.eastHemisphereGeometry))}let x=a.GeometryPipeline.combineInstances(i);for(b=x.length,h=0;h<b;++h){g=x[h];const e=g.attributes;if(d)for(const t in e)e.hasOwnProperty(t)&&e[t].componentDatatype===n.ComponentDatatype.DOUBLE&&a.GeometryPipeline.encodeAttribute(g,t,`${t}3DHigh`,`${t}3DLow`);else for(const o in e)if(e.hasOwnProperty(o)&&e[o].componentDatatype===n.ComponentDatatype.DOUBLE){const e=`${o}3D`,n=`${o}2D`;a.GeometryPipeline.projectTo2D(g,o,e,n,s),r.defined(g.boundingSphere)&&"position"===o&&(g.boundingSphereCV=t.BoundingSphere.fromVertices(g.attributes.position2D.values)),a.GeometryPipeline.encodeAttribute(g,e,`${e}High`,`${e}Low`),a.GeometryPipeline.encodeAttribute(g,n,`${n}High`,`${n}Low`)}u&&a.GeometryPipeline.compressVertices(g)}if(!c){let e=[];for(b=x.length,h=0;h<b;++h)g=x[h],e=e.concat(a.GeometryPipeline.fitToUnsignedShortIndices(g));x=e}return x}function g(e,t,n,o){let i,s,c;const a=o.length-1;if(a>=0){const e=o[a];i=e.offset+e.count,c=e.index,s=n[c].indices.length}else i=0,c=0,s=n[c].indices.length;const d=e.length;for(let p=0;p<d;++p){const a=e[p][t];if(!r.defined(a))continue;const d=a.indices.length;i+d>s&&(i=0,s=n[++c].indices.length),o.push({index:c,offset:i,count:d}),i+=d}}function y(e,t){const n=[];return g(e,"geometry",t,n),g(e,"westHemisphereGeometry",t,n),g(e,"eastHemisphereGeometry",t,n),n}Object.defineProperties(u.prototype,{componentDatatype:{get:function(){return n.ComponentDatatype.FLOAT}},componentsPerAttribute:{get:function(){return 3}},normalize:{get:function(){return!1}}}),u.fromCartesian3=function(e){return o.Check.defined("offset",e),new u(e.x,e.y,e.z)},u.toValue=function(e,t){return o.Check.defined("offset",e),r.defined(t)||(t=new Float32Array([e.x,e.y,e.z])),t[0]=e.x,t[1]=e.y,t[2]=e.z,t};const b={};function x(e,t){const n=e.attributes;for(const o in n)if(n.hasOwnProperty(o)){const e=n[o];r.defined(e)&&r.defined(e.values)&&t.push(e.values.buffer)}r.defined(e.indices)&&t.push(e.indices.buffer)}function G(e,t){const n=e.length;for(let r=0;r<n;++r)x(e[r],t)}function S(e){let n=1;const o=e.length;for(let i=0;i<o;i++){const o=e[i];if(++n,!r.defined(o))continue;const s=o.attributes;n+=7+2*t.BoundingSphere.packedLength+(r.defined(o.indices)?o.indices.length:0);for(const e in s)if(s.hasOwnProperty(e)&&r.defined(s[e])){const t=s[e];n+=5+t.values.length}}return n}function P(e,t){const n=e.length,o=new Float64Array(1+19*n);let s=0;o[s++]=n;for(let c=0;c<n;c++){const t=e[c];if(i.Matrix4.pack(t.modelMatrix,o,s),s+=i.Matrix4.packedLength,r.defined(t.attributes)&&r.defined(t.attributes.offset)){const e=t.attributes.offset.value;o[s]=e[0],o[s+1]=e[1],o[s+2]=e[2]}s+=3}return t.push(o.buffer),o}function k(e){const t=e,n=new Array(t[0]);let o=0,s=1;for(;s<t.length;){const e=i.Matrix4.unpack(t,s);let c;s+=i.Matrix4.packedLength,r.defined(t[s])&&(c={offset:new u(t[s],t[s+1],t[s+2])}),s+=3,n[o++]={modelMatrix:e,attributes:c}}return n}function C(e){const n=e.length,o=1+(t.BoundingSphere.packedLength+1)*n,i=new Float32Array(o);let s=0;i[s++]=n;for(let c=0;c<n;++c){const n=e[c];r.defined(n)?(i[s++]=1,t.BoundingSphere.pack(e[c],i,s)):i[s++]=0,s+=t.BoundingSphere.packedLength}return i}function w(e){const n=new Array(e[0]);let r=0,o=1;for(;o<e.length;)1===e[o++]&&(n[r]=t.BoundingSphere.unpack(e,o)),++r,o+=t.BoundingSphere.packedLength;return n}b.combineGeometry=function(e){let n,o;const i=e.instances,s=i.length;let c,d,p=!1;s>0&&(n=h(e),n.length>0&&(o=a.GeometryPipeline.createAttributeLocations(n[0]),e.createPickOffsets&&(c=y(i,n))),r.defined(i[0].attributes)&&r.defined(i[0].attributes.offset)&&(d=new Array(s),p=!0));const u=new Array(s),f=new Array(s);for(let a=0;a<s;++a){const e=i[a],n=e.geometry;r.defined(n)&&(u[a]=n.boundingSphere,f[a]=n.boundingSphereCV,p&&(d[a]=e.geometry.offsetAttribute));const o=e.eastHemisphereGeometry,s=e.westHemisphereGeometry;r.defined(o)&&r.defined(s)&&(r.defined(o.boundingSphere)&&r.defined(s.boundingSphere)&&(u[a]=t.BoundingSphere.union(o.boundingSphere,s.boundingSphere)),r.defined(o.boundingSphereCV)&&r.defined(s.boundingSphereCV)&&(f[a]=t.BoundingSphere.union(o.boundingSphereCV,s.boundingSphereCV)))}return{geometries:n,modelMatrix:e.modelMatrix,attributeLocations:o,pickOffsets:c,offsetInstanceExtend:d,boundingSpheres:u,boundingSpheresCV:f}},b.packCreateGeometryResults=function(e,n){const o=new Float64Array(S(e)),i=[],s={},c=e.length;let a=0;o[a++]=c;for(let d=0;d<c;d++){const n=e[d],c=r.defined(n);if(o[a++]=c?1:0,!c)continue;o[a++]=n.primitiveType,o[a++]=n.geometryType,o[a++]=r.defaultValue(n.offsetAttribute,-1);const p=r.defined(n.boundingSphere)?1:0;o[a++]=p,p&&t.BoundingSphere.pack(n.boundingSphere,o,a),a+=t.BoundingSphere.packedLength;const u=r.defined(n.boundingSphereCV)?1:0;o[a++]=u,u&&t.BoundingSphere.pack(n.boundingSphereCV,o,a),a+=t.BoundingSphere.packedLength;const f=n.attributes,l=[];for(const e in f)f.hasOwnProperty(e)&&r.defined(f[e])&&(l.push(e),r.defined(s[e])||(s[e]=i.length,i.push(e)));o[a++]=l.length;for(let e=0;e<l.length;e++){const t=l[e],n=f[t];o[a++]=s[t],o[a++]=n.componentDatatype,o[a++]=n.componentsPerAttribute,o[a++]=n.normalize?1:0,o[a++]=n.values.length,o.set(n.values,a),a+=n.values.length}const m=r.defined(n.indices)?n.indices.length:0;o[a++]=m,m>0&&(o.set(n.indices,a),a+=m)}return n.push(o.buffer),{stringTable:i,packedData:o}},b.unpackCreateGeometryResults=function(e){const r=e.stringTable,o=e.packedData;let i;const a=new Array(o[0]);let p=0,u=1;for(;u<o.length;){if(1!==o[u++]){a[p++]=void 0;continue}const e=o[u++],f=o[u++];let l,m,h,g,y,b=o[u++];-1===b&&(b=void 0),1===o[u++]&&(l=t.BoundingSphere.unpack(o,u)),u+=t.BoundingSphere.packedLength,1===o[u++]&&(m=t.BoundingSphere.unpack(o,u)),u+=t.BoundingSphere.packedLength;const x=new c.GeometryAttributes,G=o[u++];for(i=0;i<G;i++){const e=r[o[u++]],t=o[u++];y=o[u++];const i=0!==o[u++];h=o[u++],g=n.ComponentDatatype.createTypedArray(t,h);for(let n=0;n<h;n++)g[n]=o[u++];x[e]=new s.GeometryAttribute({componentDatatype:t,componentsPerAttribute:y,normalize:i,values:g})}let S;if(h=o[u++],h>0){const e=g.length/y;for(S=d.IndexDatatype.createTypedArray(e,h),i=0;i<h;i++)S[i]=o[u++]}a[p++]=new s.Geometry({primitiveType:e,geometryType:f,boundingSphere:l,boundingSphereCV:m,indices:S,attributes:x,offsetAttribute:b})}return a},b.packCombineGeometryParameters=function(e,n){const r=e.createGeometryResults,o=r.length;for(let t=0;t<o;t++)n.push(r[t].packedData.buffer);return{createGeometryResults:e.createGeometryResults,packedInstances:P(e.instances,n),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}},b.unpackCombineGeometryParameters=function(e){const n=k(e.packedInstances),r=e.createGeometryResults,o=r.length;let s=0;for(let t=0;t<o;t++){const e=b.unpackCreateGeometryResults(r[t]),o=e.length;for(let t=0;t<o;t++){const r=e[t],o=n[s];o.geometry=r,++s}}const c=i.Ellipsoid.clone(e.ellipsoid),a=e.isGeographic?new t.GeographicProjection(c):new p.WebMercatorProjection(c);return{instances:n,ellipsoid:c,projection:a,elementIndexUintSupported:e.elementIndexUintSupported,scene3DOnly:e.scene3DOnly,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:i.Matrix4.clone(e.modelMatrix),createPickOffsets:e.createPickOffsets}},b.packCombineGeometryResults=function(e,t){r.defined(e.geometries)&&G(e.geometries,t);const n=C(e.boundingSpheres),o=C(e.boundingSpheresCV);return t.push(n.buffer,o.buffer),{geometries:e.geometries,attributeLocations:e.attributeLocations,modelMatrix:e.modelMatrix,pickOffsets:e.pickOffsets,offsetInstanceExtend:e.offsetInstanceExtend,boundingSpheres:n,boundingSpheresCV:o}},b.unpackCombineGeometryResults=function(e){return{geometries:e.geometries,attributeLocations:e.attributeLocations,modelMatrix:e.modelMatrix,pickOffsets:e.pickOffsets,offsetInstanceExtend:e.offsetInstanceExtend,boundingSpheres:w(e.boundingSpheres),boundingSpheresCV:w(e.boundingSpheresCV)}},e.PrimitivePipeline=b}));