createFrustumOutlineGeometry.js 2.8 KB

1
  1. define(["./when-208fe5b0","./Transforms-d5dbea8d","./Cartesian2-b4b7b0b3","./Check-5e798bbf","./ComponentDatatype-ce69354e","./FrustumGeometry-01786c68","./GeometryAttribute-3314089a","./GeometryAttributes-b0b294d8","./Math-8386669c","./RuntimeError-7f634f5d","./WebGLConstants-76bb35d1","./Plane-06d5a63d","./VertexFormat-7e57a3bd"],function(o,m,s,e,d,h,f,g,t,r,n,a,u){"use strict";var c=0,i=1;function p(e){var t,r,n=e.frustum,a=e.orientation,u=e.origin,e=o.defaultValue(e._drawNearPlane,!0);n instanceof h.PerspectiveFrustum?(t=c,r=h.PerspectiveFrustum.packedLength):n instanceof h.OrthographicFrustum&&(t=i,r=h.OrthographicFrustum.packedLength),this._frustumType=t,this._frustum=n.clone(),this._origin=s.Cartesian3.clone(u),this._orientation=m.Quaternion.clone(a),this._drawNearPlane=e,this._workerName="createFrustumOutlineGeometry",this.packedLength=2+r+s.Cartesian3.packedLength+m.Quaternion.packedLength}p.pack=function(e,t,r){r=o.defaultValue(r,0);var n=e._frustumType,a=e._frustum;return(t[r++]=n)===c?(h.PerspectiveFrustum.pack(a,t,r),r+=h.PerspectiveFrustum.packedLength):(h.OrthographicFrustum.pack(a,t,r),r+=h.OrthographicFrustum.packedLength),s.Cartesian3.pack(e._origin,t,r),r+=s.Cartesian3.packedLength,m.Quaternion.pack(e._orientation,t,r),t[r+=m.Quaternion.packedLength]=e._drawNearPlane?1:0,t};var _=new h.PerspectiveFrustum,k=new h.OrthographicFrustum,l=new m.Quaternion,y=new s.Cartesian3;return p.unpack=function(e,t,r){t=o.defaultValue(t,0);var n,a=e[t++];a===c?(n=h.PerspectiveFrustum.unpack(e,t,_),t+=h.PerspectiveFrustum.packedLength):(n=h.OrthographicFrustum.unpack(e,t,k),t+=h.OrthographicFrustum.packedLength);var u=s.Cartesian3.unpack(e,t,y);t+=s.Cartesian3.packedLength;var i=m.Quaternion.unpack(e,t,l),e=1===e[t+=m.Quaternion.packedLength];if(!o.defined(r))return new p({frustum:n,origin:u,orientation:i,_drawNearPlane:e});t=a===r._frustumType?r._frustum:void 0;return r._frustum=n.clone(t),r._frustumType=a,r._origin=s.Cartesian3.clone(u,r._origin),r._orientation=m.Quaternion.clone(i,r._orientation),r._drawNearPlane=e,r},p.createGeometry=function(e){var t=e._frustumType,r=e._frustum,n=e._origin,a=e._orientation,u=e._drawNearPlane,e=new Float64Array(24);h.FrustumGeometry._computeNearFarPlanes(n,a,t,r,e);for(var i,o,r=new g.GeometryAttributes({position:new f.GeometryAttribute({componentDatatype:d.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:e})}),s=u?2:1,c=new Uint16Array(8*(1+s)),p=u?0:1;p<2;++p)c[i=u?8*p:0]=o=4*p,c[i+1]=o+1,c[i+2]=o+1,c[i+3]=o+2,c[i+4]=o+2,c[i+5]=o+3,c[i+6]=o+3,c[i+7]=o;for(p=0;p<2;++p)c[i=8*(s+p)]=o=4*p,c[i+1]=o+4,c[i+2]=o+1,c[i+3]=o+5,c[i+4]=o+2,c[i+5]=o+6,c[i+6]=o+3,c[i+7]=o+7;return new f.Geometry({attributes:r,indices:c,primitiveType:f.PrimitiveType.LINES,boundingSphere:m.BoundingSphere.fromVertices(e)})},function(e,t){return o.defined(t)&&(e=p.unpack(e,t)),p.createGeometry(e)}});