@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 5.04 kB
JavaScript
import{c as e,d as t}from"../../../chunks/mat3.js";import{c as a}from"../../../chunks/mat3f64.js";import{a as n,c as r}from"../../../chunks/quat.js";import{a as s,b as i}from"../../../chunks/quatf32.js";import{a as f}from"../../../chunks/quatf64.js";import{c as o,b as c,q as h,w as u,s as l,t as z,a as S,u as m,x as b,y as M,l as p,g as q,z as j,A as k,B as g}from"../../../chunks/vec3.js";import{a as x,b as y}from"../../../chunks/vec3f32.js";import{b as v,a as w,c as d}from"../../../chunks/vec3f64.js";import{t as A}from"../../../chunks/vec4.js";import{c as B}from"../../../chunks/vec4f64.js";import{create as G}from"../../../geometry/support/aaBoundingBox.js";import{signedDistance as I,normal as V}from"../../../geometry/support/plane.js";import{ViewingMode as C}from"../../ViewingMode.js";import{computeOBB as D}from"./dito.js";const E=f(),F=d(),H=d(),J=B(),K=a();class L{constructor(e){const t=56,a=0,n=24,r=36,i=e*t;this.buffer=new ArrayBuffer(i),this.obbs=new Array(e);for(let f=0;f<e;f++)this.obbs[f]={center:v(this.buffer,t*f+a),halfSize:x(this.buffer,t*f+n),quaternion:s(this.buffer,t*f+r)}}}function N(e=[0,0,0],t=[-1,-1,-1],a=f()){return{center:w(e),halfSize:y(t),quaternion:i(a)}}function O(e){return N(e.center,e.halfSize,e.quaternion)}function P(e,t){o(t.center,e.center),o(t.halfSize,e.halfSize),n(t.quaternion,e.quaternion)}function Q(e,t){return t=t||N(),D(e,t),t}function R(e,t){const a=I(t,e.center),n=ee(e,V(t));return a>n?1:a<-n?-1:0}function T(t,a){a||(a=G());const n=e(K,t.quaternion),r=t.halfSize[0]*Math.abs(n[0])+t.halfSize[1]*Math.abs(n[3])+t.halfSize[2]*Math.abs(n[6]),s=t.halfSize[0]*Math.abs(n[1])+t.halfSize[1]*Math.abs(n[4])+t.halfSize[2]*Math.abs(n[7]),i=t.halfSize[0]*Math.abs(n[2])+t.halfSize[1]*Math.abs(n[5])+t.halfSize[2]*Math.abs(n[8]);return a[0]=t.center[0]-r,a[1]=t.center[1]-s,a[2]=t.center[2]-i,a[3]=t.center[0]+r,a[4]=t.center[1]+s,a[5]=t.center[2]+i,a}function U(e,t){return I(t,e.center)-ee(e,V(t))}function W(e,t){return I(t,e.center)+ee(e,V(t))}function X(e,t){return R(e,t[0])<=0&&R(e,t[1])<=0&&R(e,t[2])<=0&&R(e,t[3])<=0&&R(e,t[4])<=0&&R(e,t[5])<=0}function Y(e,t,a,n=0){r(E,e.quaternion),c(F,t,e.center);const s=h(F,F,E),i=h(H,a,E);let f=-1/0,o=1/0;for(let r=0;r<3;r++)if(Math.abs(i[r])>1e-6){const t=(n+e.halfSize[r]-s[r])/i[r],a=(-n-e.halfSize[r]-s[r])/i[r];f=Math.max(f,Math.min(t,a)),o=Math.min(o,Math.max(t,a))}else if(s[r]>e.halfSize[r]+n||s[r]<-e.halfSize[r]-n)return!1;return f<=o}function Z(a,n,s,i,f){r(E,a.quaternion),u(F,n,a.center),h(F,F,E);const o=F[0]<-a.halfSize[0]?-1:F[0]>a.halfSize[0]?1:0,c=F[1]<-a.halfSize[1]?-1:F[1]>a.halfSize[1]?1:0,m=F[2]<-a.halfSize[2]?-1:F[2]>a.halfSize[2]?1:0,b=Math.abs(o)+Math.abs(c)+Math.abs(m);if(0===b)return 1/0;const M=1===b?4:6,p=6*(o+3*c+9*m+13);e(K,a.quaternion),t(K,K,a.halfSize);for(let e=0;e<M;e++){const t=_[p+e];l(F,((1&t)<<1)-1,(2&t)-1,((4&t)>>1)-1),z(F,F,K),S(J,a.center,F),J[3]=1,A(J,J,s);const n=1/Math.max(1e-6,J[3]);$[2*e]=J[0]*n,$[2*e+1]=J[1]*n}const q=2*M-2;let j=$[0]*($[3]-$[q+1])+$[q]*($[1]-$[q-1]);for(let e=2;e<q;e+=2)j+=$[e]*($[e+3]-$[e-1]);return Math.abs(j)*i*f*.125}const $=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],_=(()=>{const e=new Int8Array(162);let t=0;const a=a=>{for(let n=0;n<a.length;n++)e[t+n]=a[n];t+=6};return a([6,2,3,1,5,4]),a([0,2,3,1,5,4]),a([0,2,3,7,5,4]),a([0,1,3,2,6,4]),a([0,1,3,2,0,0]),a([0,1,5,7,3,2]),a([0,1,3,7,6,4]),a([0,1,3,7,6,2]),a([0,1,5,7,6,2]),a([0,1,5,4,6,2]),a([0,1,5,4,0,0]),a([0,1,3,7,5,4]),a([0,2,6,4,0,0]),a([0,0,0,0,0,0]),a([1,3,7,5,0,0]),a([2,3,7,6,4,0]),a([2,3,7,6,0,0]),a([2,3,1,5,7,6]),a([0,1,5,7,6,2]),a([0,1,5,7,6,4]),a([0,1,3,7,6,4]),a([4,5,7,6,2,0]),a([4,5,7,6,0,0]),a([4,5,1,3,7,6]),a([0,2,3,7,5,4]),a([6,2,3,7,5,4]),a([6,2,3,1,5,4]),e})();function ee(e,t){r(E,e.quaternion),h(F,t,E);const a=e.halfSize;return Math.abs(F[0]*a[0])+Math.abs(F[1]*a[1])+Math.abs(F[2]*a[2])}function te(e,t){for(let a=0;a<8;++a){const n=t[a];n[0]=1&a?-e.halfSize[0]:e.halfSize[0],n[1]=2&a?-e.halfSize[1]:e.halfSize[1],n[2]=4&a?-e.halfSize[2]:e.halfSize[2],h(n,n,e.quaternion),S(n,n,e.center)}}function ae(e){return m(e.halfSize)}function ne(e,t,a,s,i){if(n(i.quaternion,e.quaternion),s===C.Global){r(fe,e.quaternion),h(re,e.center,fe),b(se,re),M(ie,se,e.halfSize),u(ie,se,ie);const n=p(ie);S(ie,se,e.halfSize);const s=p(ie);if(n<a)o(i.center,e.center),l(re,a,a,a),S(i.halfSize,e.halfSize,re);else{const r=s>0?1+t/s:1,f=n>0?1+a/n:1,o=(f+r)/2,c=(f-r)/2;q(i.halfSize,se,c),j(i.halfSize,i.halfSize,e.halfSize,o),q(i.center,se,o),j(i.center,i.center,e.halfSize,c),k(re,re),g(i.center,i.center,re),h(i.center,i.center,i.quaternion)}}else{const n=l(re,0,0,1);j(i.center,e.center,n,(a+t)/2),r(fe,e.quaternion),h(n,n,fe),b(n,n),j(i.halfSize,e.halfSize,n,(a-t)/2)}return i}const re=d(),se=d(),ie=d(),fe=f();export{L as ObbArray,O as clone,Q as compute,ne as computeOffsetObb,te as corners,N as create,Y as intersectLine,R as intersectPlane,X as isVisible,W as maximumDistancePlane,U as minimumDistancePlane,Z as projectedArea,ee as projectedRadius,ae as radius,P as set,T as toAaBoundingBox};