createFrustumOutlineGeometry.js 2.9 KB

1
  1. define(["./when-b60132fc","./buildModuleUrl-57a32107","./Cartographic-3309dd0d","./Check-7b2a090c","./ComponentDatatype-c140a87d","./FrustumGeometry-d06b00ee","./GeometryAttribute-c42d25b7","./GeometryAttributes-252e9929","./Cartesian2-47311507","./Math-119be1a3","./Matrix4-cde86d0e","./Cartesian4-3ca25aab","./RuntimeError-4a5c8994","./WebGLConstants-4ae0db90","./Plane-ca0357f4","./VertexFormat-6446fca0","./FeatureDetection-c3b71206"],(function(e,t,r,a,n,i,u,o,c,s,p,m,d,h,f,g,_){"use strict";function k(t){var a,n,o=t.frustum,c=t.orientation,s=t.origin,p=e.defaultValue(t._drawNearPlane,!0);o instanceof i.PerspectiveFrustum?(a=0,n=i.PerspectiveFrustum.packedLength):o instanceof i.OrthographicFrustum&&(a=1,n=i.OrthographicFrustum.packedLength),this._frustumType=a,this._frustum=o.clone(),this._origin=r.Cartesian3.clone(s),this._orientation=u.Quaternion.clone(c),this._drawNearPlane=p,this._workerName="createFrustumOutlineGeometry",this.packedLength=2+n+r.Cartesian3.packedLength+u.Quaternion.packedLength}k.pack=function(t,a,n){n=e.defaultValue(n,0);var o=t._frustumType,c=t._frustum;return a[n++]=o,0===o?(i.PerspectiveFrustum.pack(c,a,n),n+=i.PerspectiveFrustum.packedLength):(i.OrthographicFrustum.pack(c,a,n),n+=i.OrthographicFrustum.packedLength),r.Cartesian3.pack(t._origin,a,n),n+=r.Cartesian3.packedLength,u.Quaternion.pack(t._orientation,a,n),a[n+=u.Quaternion.packedLength]=t._drawNearPlane?1:0,a};var l=new i.PerspectiveFrustum,y=new i.OrthographicFrustum,F=new u.Quaternion,v=new r.Cartesian3;return k.unpack=function(t,a,n){a=e.defaultValue(a,0);var o,c=t[a++];0===c?(o=i.PerspectiveFrustum.unpack(t,a,l),a+=i.PerspectiveFrustum.packedLength):(o=i.OrthographicFrustum.unpack(t,a,y),a+=i.OrthographicFrustum.packedLength);var s=r.Cartesian3.unpack(t,a,v);a+=r.Cartesian3.packedLength;var p=u.Quaternion.unpack(t,a,F),m=1===t[a+=u.Quaternion.packedLength];if(!e.defined(n))return new k({frustum:o,origin:s,orientation:p,_drawNearPlane:m});var d=c===n._frustumType?n._frustum:void 0;return n._frustum=o.clone(d),n._frustumType=c,n._origin=r.Cartesian3.clone(s,n._origin),n._orientation=u.Quaternion.clone(p,n._orientation),n._drawNearPlane=m,n},k.createGeometry=function(e){var r=e._frustumType,a=e._frustum,c=e._origin,s=e._orientation,p=e._drawNearPlane,m=new Float64Array(24);i.FrustumGeometry._computeNearFarPlanes(c,s,r,a,m);for(var d,h,f=new o.GeometryAttributes({position:new u.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:m})}),g=p?2:1,_=new Uint16Array(8*(g+1)),k=p?0:1;k<2;++k)h=4*k,_[d=p?8*k:0]=h,_[d+1]=h+1,_[d+2]=h+1,_[d+3]=h+2,_[d+4]=h+2,_[d+5]=h+3,_[d+6]=h+3,_[d+7]=h;for(k=0;k<2;++k)h=4*k,_[d=8*(g+k)]=h,_[d+1]=h+4,_[d+2]=h+1,_[d+3]=h+5,_[d+4]=h+2,_[d+5]=h+6,_[d+6]=h+3,_[d+7]=h+7;return new u.Geometry({attributes:f,indices:_,primitiveType:t.PrimitiveType.LINES,boundingSphere:t.BoundingSphere.fromVertices(m)})},function(t,r){return e.defined(r)&&(t=k.unpack(t,r)),k.createGeometry(t)}}));