YZProjectCloud/yanzhu-ui-vue3/public/Engine/Workers/OrientedBoundingBox-e7bf3b6...

2 lines
11 KiB
JavaScript
Raw Normal View History

2025-04-07 00:55:58 +08:00
define(["exports","./Transforms-99272364","./Matrix2-e3fb4559","./Cartesian3-7e9cc2ff","./Check-741c5f3c","./defaultValue-81eec7ed","./EllipsoidTangentPlane-f566b6b5","./Math-5f585871","./Matrix4-d34187af","./Plane-4f75b3df"],(function(a,t,e,n,r,i,s,o,c,C){"use strict";function u(a,t){this.center=n.Cartesian3.clone(i.defaultValue(a,n.Cartesian3.ZERO)),this.halfAxes=c.Matrix3.clone(i.defaultValue(t,c.Matrix3.ZERO))}u.packedLength=n.Cartesian3.packedLength+c.Matrix3.packedLength,u.pack=function(a,t,e){return e=i.defaultValue(e,0),n.Cartesian3.pack(a.center,t,e),c.Matrix3.pack(a.halfAxes,t,e+n.Cartesian3.packedLength),t},u.unpack=function(a,t,e){return t=i.defaultValue(t,0),i.defined(e)||(e=new u),n.Cartesian3.unpack(a,t,e.center),c.Matrix3.unpack(a,t+n.Cartesian3.packedLength,e.halfAxes),e};const l=new n.Cartesian3,d=new n.Cartesian3,h=new n.Cartesian3,x=new n.Cartesian3,f=new n.Cartesian3,m=new n.Cartesian3,M=new c.Matrix3,p={unitary:new c.Matrix3,diagonal:new c.Matrix3};u.fromPoints=function(a,t){if(i.defined(t)||(t=new u),!i.defined(a)||0===a.length)return t.halfAxes=c.Matrix3.ZERO,t.center=n.Cartesian3.ZERO,t;let e;const r=a.length,s=n.Cartesian3.clone(a[0],l);for(e=1;e<r;e++)n.Cartesian3.add(s,a[e],s);const o=1/r;n.Cartesian3.multiplyByScalar(s,o,s);let C,w=0,g=0,b=0,y=0,N=0,T=0;for(e=0;e<r;e++)C=n.Cartesian3.subtract(a[e],s,d),w+=C.x*C.x,g+=C.x*C.y,b+=C.x*C.z,y+=C.y*C.y,N+=C.y*C.z,T+=C.z*C.z;w*=o,g*=o,b*=o,y*=o,N*=o,T*=o;const O=M;O[0]=w,O[1]=g,O[2]=b,O[3]=g,O[4]=y,O[5]=N,O[6]=b,O[7]=N,O[8]=T;const A=c.Matrix3.computeEigenDecomposition(O,p),P=c.Matrix3.clone(A.unitary,t.halfAxes);let I=c.Matrix3.getColumn(P,0,x),R=c.Matrix3.getColumn(P,1,f),E=c.Matrix3.getColumn(P,2,m),S=-Number.MAX_VALUE,U=-Number.MAX_VALUE,L=-Number.MAX_VALUE,z=Number.MAX_VALUE,B=Number.MAX_VALUE,V=Number.MAX_VALUE;for(e=0;e<r;e++)C=a[e],S=Math.max(n.Cartesian3.dot(I,C),S),U=Math.max(n.Cartesian3.dot(R,C),U),L=Math.max(n.Cartesian3.dot(E,C),L),z=Math.min(n.Cartesian3.dot(I,C),z),B=Math.min(n.Cartesian3.dot(R,C),B),V=Math.min(n.Cartesian3.dot(E,C),V);I=n.Cartesian3.multiplyByScalar(I,.5*(z+S),I),R=n.Cartesian3.multiplyByScalar(R,.5*(B+U),R),E=n.Cartesian3.multiplyByScalar(E,.5*(V+L),E);const _=n.Cartesian3.add(I,R,t.center);n.Cartesian3.add(_,E,_);const k=h;return k.x=S-z,k.y=U-B,k.z=L-V,n.Cartesian3.multiplyByScalar(k,.5,k),c.Matrix3.multiplyByScale(t.halfAxes,k,t.halfAxes),t};const w=new n.Cartesian3,g=new n.Cartesian3;function b(a,t,e,r,s,o,C,l,d,h,x){i.defined(x)||(x=new u);const f=x.halfAxes;c.Matrix3.setColumn(f,0,t,f),c.Matrix3.setColumn(f,1,e,f),c.Matrix3.setColumn(f,2,r,f);let m=w;m.x=(s+o)/2,m.y=(C+l)/2,m.z=(d+h)/2;const M=g;M.x=(o-s)/2,M.y=(l-C)/2,M.z=(h-d)/2;const p=x.center;return m=c.Matrix3.multiplyByVector(f,m,m),n.Cartesian3.add(a,m,p),c.Matrix3.multiplyByScale(f,M,f),x}const y=new e.Cartographic,N=new n.Cartesian3,T=new e.Cartographic,O=new e.Cartographic,A=new e.Cartographic,P=new e.Cartographic,I=new e.Cartographic,R=new n.Cartesian3,E=new n.Cartesian3,S=new n.Cartesian3,U=new n.Cartesian3,L=new n.Cartesian3,z=new e.Cartesian2,B=new e.Cartesian2,V=new e.Cartesian2,_=new e.Cartesian2,k=new e.Cartesian2,W=new n.Cartesian3,X=new n.Cartesian3,q=new n.Cartesian3,D=new n.Cartesian3,j=new e.Cartesian2,Z=new n.Cartesian3,v=new n.Cartesian3,Y=new n.Cartesian3,G=new C.Plane(n.Cartesian3.UNIT_X,0);u.fromRectangle=function(a,t,r,c,u){let l,d,h,x,f,m,M;if(t=i.defaultValue(t,0),r=i.defaultValue(r,0),c=i.defaultValue(c,e.Ellipsoid.WGS84),a.width<=o.CesiumMath.PI){const n=e.Rectangle.center(a,y),i=c.cartographicToCartesian(n,N),o=new s.EllipsoidTangentPlane(i,c);M=o.plane;const p=n.longitude,w=a.south<0&&a.north>0?0:n.latitude,g=e.Cartographic.fromRadians(p,a.north,r,T),W=e.Cartographic.fromRadians(a.west,a.north,r,O),X=e.Cartographic.fromRadians(a.west,w,r,A),q=e.Cartographic.fromRadians(a.west,a.south,r,P),D=e.Cartographic.fromRadians(p,a.south,r,I),j=c.cartographicToCartesian(g,R);let Z=c.cartographicToCartesian(W,E);const v=c.cartographicToCartesian(X,S);let Y=c.cartographicToCartesian(q,U);const G=c.cartographicToCartesian(D,L),F=o.project