createBoxOutlineGeometry.js 3.9 KB

1234567891011121314151617181920212223242526
  1. /**
  2. * @license
  3. * Cesium - https://github.com/CesiumGS/cesium
  4. * Version 1.110.1
  5. *
  6. * Copyright 2011-2022 Cesium Contributors
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. * Columbus View (Pat. Pend.)
  21. *
  22. * Portions licensed separately.
  23. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
  24. */
  25. import{a as d}from"./chunk-HL2OONDA.js";import{a as l}from"./chunk-XYZU5ZKW.js";import{b as O,c as h,d as p}from"./chunk-ADEEKX5Q.js";import{d as A}from"./chunk-O5E7EBKP.js";import"./chunk-LEJDAZA7.js";import"./chunk-GMFQULD7.js";import{a}from"./chunk-IS523WNE.js";import{a as m}from"./chunk-4ZQSV4FU.js";import"./chunk-CLQ5X6HS.js";import"./chunk-6Y3U6IMI.js";import"./chunk-7DENS74L.js";import{a as u}from"./chunk-FOJGNIAW.js";import{a as b,b as r}from"./chunk-UGI536VH.js";import{e as c}from"./chunk-BQUQ5TPM.js";var g=new m;function f(e){e=u(e,u.EMPTY_OBJECT);let t=e.minimum,n=e.maximum;if(r.typeOf.object("min",t),r.typeOf.object("max",n),c(e.offsetAttribute)&&e.offsetAttribute===d.TOP)throw new b("GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.");this._min=m.clone(t),this._max=m.clone(n),this._offsetAttribute=e.offsetAttribute,this._workerName="createBoxOutlineGeometry"}f.fromDimensions=function(e){e=u(e,u.EMPTY_OBJECT);let t=e.dimensions;r.typeOf.object("dimensions",t),r.typeOf.number.greaterThanOrEquals("dimensions.x",t.x,0),r.typeOf.number.greaterThanOrEquals("dimensions.y",t.y,0),r.typeOf.number.greaterThanOrEquals("dimensions.z",t.z,0);let n=m.multiplyByScalar(t,.5,new m);return new f({minimum:m.negate(n,new m),maximum:n,offsetAttribute:e.offsetAttribute})};f.fromAxisAlignedBoundingBox=function(e){return r.typeOf.object("boundindBox",e),new f({minimum:e.minimum,maximum:e.maximum})};f.packedLength=2*m.packedLength+1;f.pack=function(e,t,n){return r.typeOf.object("value",e),r.defined("array",t),n=u(n,0),m.pack(e._min,t,n),m.pack(e._max,t,n+m.packedLength),t[n+m.packedLength*2]=u(e._offsetAttribute,-1),t};var w=new m,x=new m,_={minimum:w,maximum:x,offsetAttribute:void 0};f.unpack=function(e,t,n){r.defined("array",e),t=u(t,0);let s=m.unpack(e,t,w),o=m.unpack(e,t+m.packedLength,x),i=e[t+m.packedLength*2];return c(n)?(n._min=m.clone(s,n._min),n._max=m.clone(o,n._max),n._offsetAttribute=i===-1?void 0:i,n):(_.offsetAttribute=i===-1?void 0:i,new f(_))};f.createGeometry=function(e){let t=e._min,n=e._max;if(m.equals(t,n))return;let s=new l,o=new Uint16Array(12*2),i=new Float64Array(8*3);i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=n.x,i[4]=t.y,i[5]=t.z,i[6]=n.x,i[7]=n.y,i[8]=t.z,i[9]=t.x,i[10]=n.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=n.z,i[15]=n.x,i[16]=t.y,i[17]=n.z,i[18]=n.x,i[19]=n.y,i[20]=n.z,i[21]=t.x,i[22]=n.y,i[23]=n.z,s.position=new p({componentDatatype:a.DOUBLE,componentsPerAttribute:3,values:i}),o[0]=4,o[1]=5,o[2]=5,o[3]=6,o[4]=6,o[5]=7,o[6]=7,o[7]=4,o[8]=0,o[9]=1,o[10]=1,o[11]=2,o[12]=2,o[13]=3,o[14]=3,o[15]=0,o[16]=0,o[17]=4,o[18]=1,o[19]=5,o[20]=2,o[21]=6,o[22]=3,o[23]=7;let k=m.subtract(n,t,g),E=m.magnitude(k)*.5;if(c(e._offsetAttribute)){let T=i.length,B=e._offsetAttribute===d.NONE?0:1,z=new Uint8Array(T/3).fill(B);s.applyOffset=new p({componentDatatype:a.UNSIGNED_BYTE,componentsPerAttribute:1,values:z})}return new h({attributes:s,indices:o,primitiveType:O.LINES,boundingSphere:new A(m.ZERO,E),offsetAttribute:e._offsetAttribute})};var y=f;function L(e,t){return c(t)&&(e=y.unpack(e,t)),y.createGeometry(e)}var R=L;export{R as default};