createBoxOutlineGeometry.js 2.9 KB

1
  1. define(["./GeometryOffsetAttribute-8c5e10db","./Transforms-969e35b7","./Matrix2-7fbd2afb","./RuntimeError-8952249c","./ComponentDatatype-be80d12c","./defaultValue-81eec7ed","./GeometryAttribute-6e58c1bc","./GeometryAttributes-32b29525","./_commonjsHelpers-3aae1032-26891ab7","./combine-3c023bda","./WebGLConstants-508b9636"],(function(e,t,n,a,i,r,o,u,s,m,f){"use strict";const c=new n.Cartesian3;function b(e){const t=(e=r.defaultValue(e,r.defaultValue.EMPTY_OBJECT)).minimum,a=e.maximum;this._min=n.Cartesian3.clone(t),this._max=n.Cartesian3.clone(a),this._offsetAttribute=e.offsetAttribute,this._workerName="createBoxOutlineGeometry"}b.fromDimensions=function(e){const t=(e=r.defaultValue(e,r.defaultValue.EMPTY_OBJECT)).dimensions,a=n.Cartesian3.multiplyByScalar(t,.5,new n.Cartesian3);return new b({minimum:n.Cartesian3.negate(a,new n.Cartesian3),maximum:a,offsetAttribute:e.offsetAttribute})},b.fromAxisAlignedBoundingBox=function(e){return new b({minimum:e.minimum,maximum:e.maximum})},b.packedLength=2*n.Cartesian3.packedLength+1,b.pack=function(e,t,a){return a=r.defaultValue(a,0),n.Cartesian3.pack(e._min,t,a),n.Cartesian3.pack(e._max,t,a+n.Cartesian3.packedLength),t[a+2*n.Cartesian3.packedLength]=r.defaultValue(e._offsetAttribute,-1),t};const d=new n.Cartesian3,p=new n.Cartesian3,l={minimum:d,maximum:p,offsetAttribute:void 0};return b.unpack=function(e,t,a){t=r.defaultValue(t,0);const i=n.Cartesian3.unpack(e,t,d),o=n.Cartesian3.unpack(e,t+n.Cartesian3.packedLength,p),u=e[t+2*n.Cartesian3.packedLength];return r.defined(a)?(a._min=n.Cartesian3.clone(i,a._min),a._max=n.Cartesian3.clone(o,a._max),a._offsetAttribute=-1===u?void 0:u,a):(l.offsetAttribute=-1===u?void 0:u,new b(l))},b.createGeometry=function(a){const s=a._min,m=a._max;if(n.Cartesian3.equals(s,m))return;const f=new u.GeometryAttributes,b=new Uint16Array(24),d=new Float64Array(24);d[0]=s.x,d[1]=s.y,d[2]=s.z,d[3]=m.x,d[4]=s.y,d[5]=s.z,d[6]=m.x,d[7]=m.y,d[8]=s.z,d[9]=s.x,d[10]=m.y,d[11]=s.z,d[12]=s.x,d[13]=s.y,d[14]=m.z,d[15]=m.x,d[16]=s.y,d[17]=m.z,d[18]=m.x,d[19]=m.y,d[20]=m.z,d[21]=s.x,d[22]=m.y,d[23]=m.z,f.position=new o.GeometryAttribute({componentDatatype:i.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:d}),b[0]=4,b[1]=5,b[2]=5,b[3]=6,b[4]=6,b[5]=7,b[6]=7,b[7]=4,b[8]=0,b[9]=1,b[10]=1,b[11]=2,b[12]=2,b[13]=3,b[14]=3,b[15]=0,b[16]=0,b[17]=4,b[18]=1,b[19]=5,b[20]=2,b[21]=6,b[22]=3,b[23]=7;const p=n.Cartesian3.subtract(m,s,c),l=.5*n.Cartesian3.magnitude(p);if(r.defined(a._offsetAttribute)){const t=d.length,n=new Uint8Array(t/3),r=a._offsetAttribute===e.GeometryOffsetAttribute.NONE?0:1;e.arrayFill(n,r),f.applyOffset=new o.GeometryAttribute({componentDatatype:i.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}return new o.Geometry({attributes:f,indices:b,primitiveType:o.PrimitiveType.LINES,boundingSphere:new t.BoundingSphere(n.Cartesian3.ZERO,l),offsetAttribute:a._offsetAttribute})},function(e,t){return r.defined(t)&&(e=b.unpack(e,t)),b.createGeometry(e)}}));