2 lines
30 KiB
JavaScript
2 lines
30 KiB
JavaScript
|
define(["exports","./AttributeCompression-8f752c03","./Cartesian2-bd414876","./Cartesian3-e0307675","./Check-741c5f3c","./defaultValue-81eec7ed","./Math-e73894ab","./BoundingSphere-9a3b5656","./Matrix4-4c545f70","./ComponentDatatype-aaeec80f","./EncodedCartesian3-aafcc30f","./GeographicProjection-c931c7fb","./GeometryAttribute-2b42a913","./IndexDatatype-3f3c99e8","./IntersectionTests-80510c7b","./Plane-bc8b6777"],(function(e,t,n,i,r,a,s,o,u,c,l,p,d,f,y,m){"use strict";const C=new i.Cartesian3,h=new i.Cartesian3,v=new i.Cartesian3;const b={calculateACMR:function(e){const t=(e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT)).indices;let n=e.maximumIndex;const i=a.defaultValue(e.cacheSize,24),r=t.length;if(!a.defined(n)){n=0;let e=0,i=t[e];for(;e<r;)i>n&&(n=i),++e,i=t[e]}const s=[];for(let e=0;e<n+1;e++)s[e]=0;let o=i+1;for(let e=0;e<r;++e)o-s[t[e]]>i&&(s[t[e]]=o,++o);return(o-i+1)/(r/3)}};b.tipsify=function(e){const t=(e=a.defaultValue(e,a.defaultValue.EMPTY_OBJECT)).indices,n=e.maximumIndex,i=a.defaultValue(e.cacheSize,24);let r;function s(e,t,n,i,a,s,o){let u,c=-1,l=-1,p=0;for(;p<n.length;){const e=n[p];i[e].numLiveTriangles&&(u=0,a-i[e].timeStamp+2*i[e].numLiveTriangles<=t&&(u=a-i[e].timeStamp),(u>l||-1===l)&&(l=u,c=e)),++p}return-1===c?function(e,t,n,i){for(;t.length>=1;){const n=t[t.length-1];if(t.splice(t.length-1,1),e[n].numLiveTriangles>0)return n}for(;r<i;){if(e[r].numLiveTriangles>0)return++r,r-1;++r}return-1}(i,s,0,o):c}const o=t.length;let u=0,c=0,l=t[c];const p=o;if(a.defined(n))u=n+1;else{for(;c<p;)l>u&&(u=l),++c,l=t[c];if(-1===u)return 0;++u}const d=[];let f;for(f=0;f<u;f++)d[f]={numLiveTriangles:0,timeStamp:0,vertexTriangles:[]};c=0;let y=0;for(;c<p;)d[t[c]].vertexTriangles.push(y),++d[t[c]].numLiveTriangles,d[t[c+1]].vertexTriangles.push(y),++d[t[c+1]].numLiveTriangles,d[t[c+2]].vertexTriangles.push(y),++d[t[c+2]].numLiveTriangles,++y,c+=3;let m=0,C=i+1;r=1;let h=[];const v=[];let b,g,A=0;const T=[],x=o/3,P=[];for(f=0;f<x;f++)P[f]=!1;let w,S;for(;-1!==m;){h=[],g=d[m],S=g.vertexTriangles.length;for(let e=0;e<S;++e)if(y=g.vertexTriangles[e],!P[y]){P[y]=!0,c=y+y+y;for(let e=0;e<3;++e)w=t[c],h.push(w),v.push(w),T[A]=w,++A,b=d[w],--b.numLiveTriangles,C-b.timeStamp>i&&(b.timeStamp=C,++C),++c}m=s(0,i,h,d,C,v,u)}return T};const g={};function A(e,t,n,i,r){e[t++]=n,e[t++]=i,e[t++]=i,e[t++]=r,e[t++]=r,e[t]=n}function T(e){const t={};for(const n in e)if(e.hasOwnProperty(n)&&a.defined(e[n])&&a.defined(e[n].values)){const i=e[n];t[n]=new d.GeometryAttribute({componentDatatype:i.componentDatatype,componentsPerAttribute:i.componentsPerAttribute,normalize:i.normalize,values:[]})}return t}function x(e,t,n){for(const i in t)if(t.hasOwnProperty(i)&&a.defined(t[i])&&a.defined(t[i].values)){const r=t[i];for(let t=0;t<r.componentsPerAttribute;++t)e[i].values.push(r.values[n*r.componentsPerAttribute+t])}}g.toWireframe=function(e){const t=e.indices;if(a.defined(t)){switch(e.primitiveType){case d.PrimitiveType.TRIANGLES:e.indices=function(e){const t=e.length,n=t/3*6,i=f.IndexDatatype.createTypedArray(t,n);let r=0;for(let n=0;n<t;n+=3,r+=6)A(i,r,e[n],e[n+1],e[n+2]);return i}(t);break;case d.PrimitiveType.TRIANGLE_STRIP:e.indices=function(e){const t=e.length;if(t>=3){const n=6*(t-2),i=f.IndexDatatype.createTypedArray(t,n);A(i,0,e[0],e[1],e[2]);let r=6;for(let n=3;n<t;++n,r+=6)A(i,r,e[n-1],e[n],e[n-2]);return i}return new Uint16Array}(t);break;case d.PrimitiveType.TRIANGLE_FAN:e.indices=function(e){if(e.length>0){const t=e.length-1,n=6*(t-1),i=f.IndexDatatype.createTypedArray(t,n),r=e[0];let a=0;for(let n=1;n<t;++n,a+=6)A(i,a,r,e[n],e[n+1]);return i}return new Uint16Array}(t)}e.primitiveType=d.PrimitiveType.LINES}return e},g.createLineSegmentsForVectors=function(e,t,n){t=a.defaultValue(t,"normal"),n=a.defaultValue(n,1e4);const i=e.attributes.position.values,r=e.attributes[t].values,s=i.length,u=new Float64Array(2*s);let l,p=0;for(let e=0;e<s;e+=3)u[p++]=i[e],u[p++]=i[e+1],u[p++]=i[e+2],u[p++]=i[e]+r[e]*n,u[p++]=i[e+1]+r[e+1]*n,u[p++]=i[e+2]+r[e+2]*n;const f=e.boundingSphere;return a.defined(f)&&(l=new o.BoundingSphere(f.center,f.radius
|