1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-23 08:28:36 -05:00
sdrangel/plugins/feature/map/Cesium/Workers/createFrustumOutlineGeometry.js

2 lines
2.8 KiB
JavaScript
Raw Normal View History

2022-02-04 15:41:22 -05:00
define(["./when-229515d6","./Transforms-ab7258fe","./Matrix2-46444433","./RuntimeError-608565a6","./ComponentDatatype-692a36d3","./FrustumGeometry-00f0dfed","./GeometryAttribute-d3bef603","./GeometryAttributes-b253752a","./combine-35b6d9cb","./WebGLConstants-f63312fc","./Plane-1f2a7880","./VertexFormat-7272aabd"],(function(e,t,r,n,a,i,u,o,s,c,p,m){"use strict";function d(n){const a=n.frustum,u=n.orientation,o=n.origin,s=e.defaultValue(n._drawNearPlane,!0);let c,p;a instanceof i.PerspectiveFrustum?(c=0,p=i.PerspectiveFrustum.packedLength):a instanceof i.OrthographicFrustum&&(c=1,p=i.OrthographicFrustum.packedLength),this._frustumType=c,this._frustum=a.clone(),this._origin=r.Cartesian3.clone(o),this._orientation=t.Quaternion.clone(u),this._drawNearPlane=s,this._workerName="createFrustumOutlineGeometry",this.packedLength=2+p+r.Cartesian3.packedLength+t.Quaternion.packedLength}d.pack=function(n,a,u){u=e.defaultValue(u,0);const o=n._frustumType,s=n._frustum;return a[u++]=o,0===o?(i.PerspectiveFrustum.pack(s,a,u),u+=i.PerspectiveFrustum.packedLength):(i.OrthographicFrustum.pack(s,a,u),u+=i.OrthographicFrustum.packedLength),r.Cartesian3.pack(n._origin,a,u),u+=r.Cartesian3.packedLength,t.Quaternion.pack(n._orientation,a,u),a[u+=t.Quaternion.packedLength]=n._drawNearPlane?1:0,a};const f=new i.PerspectiveFrustum,h=new i.OrthographicFrustum,g=new t.Quaternion,_=new r.Cartesian3;return d.unpack=function(n,a,u){a=e.defaultValue(a,0);const o=n[a++];let s;0===o?(s=i.PerspectiveFrustum.unpack(n,a,f),a+=i.PerspectiveFrustum.packedLength):(s=i.OrthographicFrustum.unpack(n,a,h),a+=i.OrthographicFrustum.packedLength);const c=r.Cartesian3.unpack(n,a,_);a+=r.Cartesian3.packedLength;const p=t.Quaternion.unpack(n,a,g),m=1===n[a+=t.Quaternion.packedLength];if(!e.defined(u))return new d({frustum:s,origin:c,orientation:p,_drawNearPlane:m});const l=o===u._frustumType?u._frustum:void 0;return u._frustum=s.clone(l),u._frustumType=o,u._origin=r.Cartesian3.clone(c,u._origin),u._orientation=t.Quaternion.clone(p,u._orientation),u._drawNearPlane=m,u},d.createGeometry=function(e){const r=e._frustumType,n=e._frustum,s=e._origin,c=e._orientation,p=e._drawNearPlane,m=new Float64Array(24);i.FrustumGeometry._computeNearFarPlanes(s,c,r,n,m);const d=new o.GeometryAttributes({position:new u.GeometryAttribute({componentDatatype:a.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:m})});let f,h;const g=p?2:1,_=new Uint16Array(8*(g+1));let l=p?0:1;for(;l<2;++l)f=p?8*l:0,h=4*l,_[f]=h,_[f+1]=h+1,_[f+2]=h+1,_[f+3]=h+2,_[f+4]=h+2,_[f+5]=h+3,_[f+6]=h+3,_[f+7]=h;for(l=0;l<2;++l)f=8*(g+l),h=4*l,_[f]=h,_[f+1]=h+4,_[f+2]=h+1,_[f+3]=h+5,_[f+4]=h+2,_[f+5]=h+6,_[f+6]=h+3,_[f+7]=h+7;return new u.Geometry({attributes:d,indices:_,primitiveType:u.PrimitiveType.LINES,boundingSphere:t.BoundingSphere.fromVertices(m)})},function(t,r){return e.defined(r)&&(t=d.unpack(t,r)),d.createGeometry(t)}}));