bimland/dist/Cesium/Workers/OrientedBoundingBox-87d59c2...

2 lines
14 KiB
JavaScript
Raw Normal View History

2023-07-26 17:04:38 +08:00
define(["exports","./buildModuleUrl-4e1b81e7","./Cartesian2-47311507","./Cartographic-3309dd0d","./Cartesian4-3ca25aab","./Check-7b2a090c","./when-b60132fc","./EllipsoidTangentPlane-edb321d3","./Math-119be1a3","./PrimitiveType-a54dc62f","./Plane-7ae8294c","./PolygonPipeline-660e1625"],(function(a,t,e,n,r,i,s,o,C,d,u,c){"use strict";var l=[];function h(a,t){this.center=n.Cartesian3.clone(s.defaultValue(a,n.Cartesian3.ZERO)),this.halfAxes=d.Matrix3.clone(s.defaultValue(t,d.Matrix3.ZERO)),this.areaDirty=1}l[0]={num:0,des:"inside"},l[1]={num:4,data:[0,4,7,3],des:"left"},l[2]={num:4,data:[1,2,6,5],des:"right"},l[3]={num:0},l[4]={num:4,data:[0,1,5,4],des:"bottom"},l[5]={num:6,data:[0,1,5,4,7,3],des:"bottom, left"},l[6]={num:6,data:[0,1,2,6,5,4],des:"bottom, right"},l[7]={num:0},l[8]={num:4,data:[2,3,7,6],des:"top"},l[9]={num:6,data:[4,7,6,2,3,0],des:"top, left"},l[10]={num:6,data:[2,3,7,6,5,1],des:"top, right"},l[11]={num:0},l[12]={num:0},l[13]={num:0},l[14]={num:0},l[15]={num:0},l[16]={num:4,data:[0,3,2,1],des:"front"},l[17]={num:6,data:[0,4,7,3,2,1],des:"front, left"},l[18]={num:6,data:[0,3,2,6,5,1],des:"front, right"},l[19]={num:0},l[20]={num:6,data:[0,3,2,1,5,4],des:"front, bottom"},l[21]={num:6,data:[2,1,5,4,7,3],des:"front, bottom, left"},l[22]={num:6,data:[0,3,2,6,5,4],des:"front, bottom, right"},l[23]={num:0},l[24]={num:6,data:[0,3,7,6,2,1],des:"front, top"},l[25]={num:6,data:[0,4,7,6,2,1],des:"front, top, left"},l[26]={num:6,data:[0,3,7,6,5,1],des:"front, top, right"},l[27]={num:0},l[28]={num:0},l[29]={num:0},l[30]={num:0},l[31]={num:0},l[32]={num:4,data:[4,5,6,7],des:"back"},l[33]={num:6,data:[4,5,6,7,3,0],des:"back, left"},l[34]={num:6,data:[1,2,6,7,4,5],des:"back, right"},l[35]={num:0},l[36]={num:6,data:[0,1,5,6,7,4],des:"back, bottom"},l[37]={num:6,data:[0,1,5,6,7,3],des:"back, bottom, left"},l[38]={num:6,data:[0,1,2,6,7,4],des:"back, bottom, right"},l[39]={num:0},l[40]={num:6,data:[2,3,7,4,5,6],des:"back, top"},l[41]={num:6,data:[0,4,5,6,2,3],des:"back, top, left"},l[42]={num:6,data:[1,2,3,7,4,5],des:"back, top, right"},h.packedLength=n.Cartesian3.packedLength+d.Matrix3.packedLength,h.pack=function(a,t,e){return e=s.defaultValue(e,0),n.Cartesian3.pack(a.center,t,e),d.Matrix3.pack(a.halfAxes,t,e+n.Cartesian3.packedLength),t},h.unpack=function(a,t,e){return t=s.defaultValue(t,0),s.defined(e)||(e=new h),n.Cartesian3.unpack(a,t,e.center),d.Matrix3.unpack(a,t+n.Cartesian3.packedLength,e.halfAxes),e};var m=new n.Cartesian3,x=new n.Cartesian3,p=new n.Cartesian3,M=new n.Cartesian3,f=new n.Cartesian3,g=new n.Cartesian3,w=new d.Matrix3,b={unitary:new d.Matrix3,diagonal:new d.Matrix3},y=new n.Cartesian3,v=new n.Cartesian3,P=new n.Cartesian3;h.fromPoints=function(a,t){if(s.defined(t)||(t=new h),!s.defined(a)||0===a.length)return t.halfAxes=d.Matrix3.ZERO,t.center=n.Cartesian3.ZERO,t;var e,r=a.length,i=n.Cartesian3.clone(a[0],m);for(e=1;e<r;e++)n.Cartesian3.add(i,a[e],i);var o=1/r;n.Cartesian3.multiplyByScalar(i,o,i);var C,u=0,c=0,l=0,y=0,v=0,P=0;for(e=0;e<r;e++)u+=(C=n.Cartesian3.subtract(a[e],i,x)).x*C.x,c+=C.x*C.y,l+=C.x*C.z,y+=C.y*C.y,v+=C.y*C.z,P+=C.z*C.z;u*=o,c*=o,l*=o,y*=o,v*=o,P*=o;var O=w;O[0]=u,O[1]=c,O[2]=l,O[3]=c,O[4]=y,O[5]=v,O[6]=l,O[7]=v,O[8]=P;var z=d.Matrix3.computeEigenDecomposition(O,b),A=d.Matrix3.clone(z.unitary,t.halfAxes),N=d.Matrix3.getColumn(A,0,M),T=d.Matrix3.getColumn(A,1,f),R=d.Matrix3.getColumn(A,2,g),I=-Number.MAX_VALUE,E=-Number.MAX_VALUE,B=-Number.MAX_VALUE,L=Number.MAX_VALUE,k=Number.MAX_VALUE,U=Number.MAX_VALUE;for(e=0;e<r;e++)C=a[e],I=Math.max(n.Cartesian3.dot(N,C),I),E=Math.max(n.Cartesian3.dot(T,C),E),B=Math.max(n.Cartesian3.dot(R,C),B),L=Math.min(n.Cartesian3.dot(N,C),L),k=Math.min(n.Cartesian3.dot(T,C),k),U=Math.min(n.Cartesian3.dot(R,C),U);N=n.Cartesian3.multiplyByScalar(N,.5*(L+I),N),T=n.Cartesian3.multiplyByScalar(T,.5*(k+E),T),R=n.Cartesian3.multiplyByScalar(R,.5*(U+B),R);var V=n.Cartesian3.add(N,T,t.center);n.Cartesian3.add(V,R,V);var S=p;return S.x=I-L,S.y=E-k,S.z=B-U,n.Cartesian3.multiplyByScalar(S,.5,S),d.Matrix3.multiplyByScale(t.halfAxes,S,t.halfAxes),t};var O=new n.Cartesian3