GeometryAttribute-44fb48f1.js 6.6 KB

1
  1. define(["exports","./when-54c2dc71","./Check-6c0211bc","./Cartesian2-bddc1162","./Transforms-ec27f304","./WebGLConstants-76bb35d1"],function(t,a,e,O,M,n){"use strict";var r=Object.freeze({NONE:0,TRIANGLES:1,LINES:2,POLYLINES:3});function v(t,e,n,r){this[0]=a.defaultValue(t,0),this[1]=a.defaultValue(n,0),this[2]=a.defaultValue(e,0),this[3]=a.defaultValue(r,0)}v.packedLength=4,v.pack=function(t,e,n){return n=a.defaultValue(n,0),e[n++]=t[0],e[n++]=t[1],e[n++]=t[2],e[n++]=t[3],e},v.unpack=function(t,e,n){return e=a.defaultValue(e,0),a.defined(n)||(n=new v),n[0]=t[e++],n[1]=t[e++],n[2]=t[e++],n[3]=t[e++],n},v.clone=function(t,e){if(a.defined(t))return a.defined(e)?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):new v(t[0],t[2],t[1],t[3])},v.fromArray=function(t,e,n){return e=a.defaultValue(e,0),a.defined(n)||(n=new v),n[0]=t[e],n[1]=t[e+1],n[2]=t[e+2],n[3]=t[e+3],n},v.fromColumnMajorArray=function(t,e){return v.clone(t,e)},v.fromRowMajorArray=function(t,e){return a.defined(e)?(e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3],e):new v(t[0],t[1],t[2],t[3])},v.fromScale=function(t,e){return a.defined(e)?(e[0]=t.x,e[1]=0,e[2]=0,e[3]=t.y,e):new v(t.x,0,0,t.y)},v.fromUniformScale=function(t,e){return a.defined(e)?(e[0]=t,e[1]=0,e[2]=0,e[3]=t,e):new v(t,0,0,t)},v.fromRotation=function(t,e){var n=Math.cos(t),r=Math.sin(t);return a.defined(e)?(e[0]=n,e[1]=r,e[2]=-r,e[3]=n,e):new v(n,-r,r,n)},v.toArray=function(t,e){return a.defined(e)?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):[t[0],t[1],t[2],t[3]]},v.getElementIndex=function(t,e){return 2*t+e},v.getColumn=function(t,e,n){var r=2*e,a=t[r],i=t[1+r];return n.x=a,n.y=i,n},v.setColumn=function(t,e,n,r){var a=2*e;return(r=v.clone(t,r))[a]=n.x,r[1+a]=n.y,r},v.getRow=function(t,e,n){var r=t[e],a=t[e+2];return n.x=r,n.y=a,n},v.setRow=function(t,e,n,r){return(r=v.clone(t,r))[e]=n.x,r[e+2]=n.y,r};var i=new O.Cartesian2;v.getScale=function(t,e){return e.x=O.Cartesian2.magnitude(O.Cartesian2.fromElements(t[0],t[1],i)),e.y=O.Cartesian2.magnitude(O.Cartesian2.fromElements(t[2],t[3],i)),e};var u=new O.Cartesian2;v.getMaximumScale=function(t){return v.getScale(t,u),O.Cartesian2.maximumComponent(u)},v.multiply=function(t,e,n){var r=t[0]*e[0]+t[2]*e[1],a=t[0]*e[2]+t[2]*e[3],i=t[1]*e[0]+t[3]*e[1],u=t[1]*e[2]+t[3]*e[3];return n[0]=r,n[1]=i,n[2]=a,n[3]=u,n},v.add=function(t,e,n){return n[0]=t[0]+e[0],n[1]=t[1]+e[1],n[2]=t[2]+e[2],n[3]=t[3]+e[3],n},v.subtract=function(t,e,n){return n[0]=t[0]-e[0],n[1]=t[1]-e[1],n[2]=t[2]-e[2],n[3]=t[3]-e[3],n},v.multiplyByVector=function(t,e,n){var r=t[0]*e.x+t[2]*e.y,a=t[1]*e.x+t[3]*e.y;return n.x=r,n.y=a,n},v.multiplyByScalar=function(t,e,n){return n[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n[3]=t[3]*e,n},v.multiplyByScale=function(t,e,n){return n[0]=t[0]*e.x,n[1]=t[1]*e.x,n[2]=t[2]*e.y,n[3]=t[3]*e.y,n},v.negate=function(t,e){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},v.transpose=function(t,e){var n=t[0],r=t[2],a=t[1],i=t[3];return e[0]=n,e[1]=r,e[2]=a,e[3]=i,e},v.abs=function(t,e){return e[0]=Math.abs(t[0]),e[1]=Math.abs(t[1]),e[2]=Math.abs(t[2]),e[3]=Math.abs(t[3]),e},v.equals=function(t,e){return t===e||a.defined(t)&&a.defined(e)&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},v.equalsArray=function(t,e,n){return t[0]===e[n]&&t[1]===e[n+1]&&t[2]===e[n+2]&&t[3]===e[n+3]},v.equalsEpsilon=function(t,e,n){return n=a.defaultValue(n,0),t===e||a.defined(t)&&a.defined(e)&&Math.abs(t[0]-e[0])<=n&&Math.abs(t[1]-e[1])<=n&&Math.abs(t[2]-e[2])<=n&&Math.abs(t[3]-e[3])<=n},v.IDENTITY=Object.freeze(new v(1,0,0,1)),v.ZERO=Object.freeze(new v(0,0,0,0)),v.COLUMN0ROW0=0,v.COLUMN0ROW1=1,v.COLUMN1ROW0=2,v.COLUMN1ROW1=3,Object.defineProperties(v.prototype,{length:{get:function(){return v.packedLength}}}),v.prototype.clone=function(t){return v.clone(this,t)},v.prototype.equals=function(t){return v.equals(this,t)},v.prototype.equalsEpsilon=function(t,e){return v.equalsEpsilon(this,t,e)},v.prototype.toString=function(){return"("+this[0]+", "+this[2]+")\n("+this[1]+", "+this[3]+")"};var o={POINTS:n.WebGLConstants.POINTS,LINES:n.WebGLConstants.LINES,LINE_LOOP:n.WebGLConstants.LINE_LOOP,LINE_STRIP:n.WebGLConstants.LINE_STRIP,TRIANGLES:n.WebGLConstants.TRIANGLES,TRIANGLE_STRIP:n.WebGLConstants.TRIANGLE_STRIP,TRIANGLE_FAN:n.WebGLConstants.TRIANGLE_FAN,validate:function(t){return t===o.POINTS||t===o.LINES||t===o.LINE_LOOP||t===o.LINE_STRIP||t===o.TRIANGLES||t===o.TRIANGLE_STRIP||t===o.TRIANGLE_FAN}},s=Object.freeze(o);function f(t){t=a.defaultValue(t,a.defaultValue.EMPTY_OBJECT),this.attributes=t.attributes,this.indices=t.indices,this.primitiveType=a.defaultValue(t.primitiveType,s.TRIANGLES),this.boundingSphere=t.boundingSphere,this.geometryType=a.defaultValue(t.geometryType,r.NONE),this.boundingSphereCV=t.boundingSphereCV,this.offsetAttribute=t.offsetAttribute}f.computeNumberOfVertices=function(t){var e,n=-1;for(var r in t.attributes){t.attributes.hasOwnProperty(r)&&a.defined(t.attributes[r])&&a.defined(t.attributes[r].values)&&(n=(e=t.attributes[r]).values.length/e.componentsPerAttribute)}return n};var R=new O.Cartographic,V=new O.Cartesian3,P=new M.Matrix4,G=[new O.Cartographic,new O.Cartographic,new O.Cartographic],_=[new O.Cartesian2,new O.Cartesian2,new O.Cartesian2],W=[new O.Cartesian2,new O.Cartesian2,new O.Cartesian2],B=new O.Cartesian3,F=new M.Quaternion,k=new M.Matrix4,Y=new v;f._textureCoordinateRotationPoints=function(t,e,n,r){var a=O.Rectangle.center(r,R),i=O.Cartographic.toCartesian(a,n,V),u=M.Transforms.eastNorthUpToFixedFrame(i,n,P),o=M.Matrix4.inverse(u,P),s=_,f=G;f[0].longitude=r.west,f[0].latitude=r.south,f[1].longitude=r.west,f[1].latitude=r.north,f[2].longitude=r.east,f[2].latitude=r.south;for(var c=B,l=0;l<3;l++)O.Cartographic.toCartesian(f[l],n,c),c=M.Matrix4.multiplyByPointAsVector(o,c,c),s[l].x=c.x,s[l].y=c.y;var d=M.Quaternion.fromAxisAngle(O.Cartesian3.UNIT_Z,-e,F),y=M.Matrix3.fromQuaternion(d,k),m=t.length,p=Number.POSITIVE_INFINITY,h=Number.POSITIVE_INFINITY,N=Number.NEGATIVE_INFINITY,I=Number.NEGATIVE_INFINITY;for(l=0;l<m;l++)c=M.Matrix4.multiplyByPointAsVector(o,t[l],c),c=M.Matrix3.multiplyByVector(y,c,c),p=Math.min(p,c.x),h=Math.min(h,c.y),N=Math.max(N,c.x),I=Math.max(I,c.y);var C=v.fromRotation(e,Y),b=W;b[0].x=p,b[0].y=h,b[1].x=p,b[1].y=I,b[2].x=N,b[2].y=h;var T=s[0],E=s[2].x-T.x,x=s[1].y-T.y;for(l=0;l<3;l++){var L=b[l];v.multiplyByVector(C,L,L),L.x=(L.x-T.x)/E,L.y=(L.y-T.y)/x}var w=b[0],g=b[1],S=b[2],A=new Array(6);return O.Cartesian2.pack(w,A),O.Cartesian2.pack(g,A,2),O.Cartesian2.pack(S,A,4),A},t.Geometry=f,t.GeometryAttribute=function(t){t=a.defaultValue(t,a.defaultValue.EMPTY_OBJECT),this.componentDatatype=t.componentDatatype,this.componentsPerAttribute=t.componentsPerAttribute,this.normalize=a.defaultValue(t.normalize,!1),this.values=t.values},t.GeometryType=r,t.Matrix2=v,t.PrimitiveType=s});