import{L as N,a as gt,G as ue,b as pe,d as de,M as he,P as ye,T as Ct,V as _,S as me,e as oe,B as $,f as bt,F as Ot,O as xe,g as we,h as at,i as Ae,D as ge}from"./model.vue.8f6f7b03.js";var be=Object.defineProperty,Pe=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,qt=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,Nt=(n,t,e)=>t in n?be(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Bt=(n,t)=>{for(var e in t||(t={}))Be.call(t,e)&&Nt(n,e,t[e]);if(qt)for(var e of qt(t))Me.call(t,e)&&Nt(n,e,t[e]);return n},Se=(n,t)=>Pe(n,Te(t));const re=0,ve=1,Ie=2,Ht=2,Mt=1.25,jt=1,wt=6*4+4+4,Vt=65535,_e=Math.pow(2,-24);class ft{constructor(){}}function U(n,t,e){return e.min.x=t[n],e.min.y=t[n+1],e.min.z=t[n+2],e.max.x=t[n+3],e.max.y=t[n+4],e.max.z=t[n+5],e}function kt(n){let t=-1,e=-1/0;for(let i=0;i<3;i++){const s=n[i+3]-n[i];s>e&&(e=s,t=i)}return t}function Xt(n,t){t.set(n)}function Wt(n,t,e){let i,s;for(let r=0;r<3;r++){const o=r+3;i=n[r],s=t[r],e[r]=is?i:s}}function ut(n,t,e){for(let i=0;i<3;i++){const s=t[n+2*i],r=t[n+2*i+1],o=s-r,l=s+r;oe[i+3]&&(e[i+3]=l)}}function et(n){const t=n[3]-n[0],e=n[4]-n[1],i=n[5]-n[2];return 2*(t*e+e*i+i*t)}function Ce(n,t){if(!n.index){const e=n.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;let s;e>65535?s=new Uint32Array(new i(4*e)):s=new Uint16Array(new i(2*e)),n.setIndex(new bt(s,1));for(let r=0;rs-r);for(let s=0;sc&&(c=M),y&&xg&&(g=x);const B=n[m+2],T=n[m+3],S=B-T,v=B+T;Sf&&(f=v),y&&Bw&&(w=B);const I=n[m+4],C=n[m+5],F=I-C,V=I+C;Fa&&(a=V),y&&IA&&(A=I)}i[0]=r,i[1]=o,i[2]=l,i[3]=c,i[4]=f,i[5]=a,y&&(s[0]=u,s[1]=p,s[2]=d,s[3]=g,s[4]=w,s[5]=A)}function ze(n,t,e,i){let s=1/0,r=1/0,o=1/0,l=-1/0,c=-1/0,f=-1/0;for(let a=t*6,u=(t+e)*6;al&&(l=p);const d=n[a+2];dc&&(c=d);const g=n[a+4];gf&&(f=g)}i[0]=s,i[1]=r,i[2]=o,i[3]=l,i[4]=c,i[5]=f}function Fe(n,t,e,i,s){let r=e,o=e+i-1;const l=s.pos,c=s.axis*2;for(;;){for(;r<=o&&t[r*6+c]=l;)o--;if(rn.candidate-t.candidate,k=new Array(q).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),pt=new Float32Array(6);function Le(n,t,e,i,s,r){let o=-1,l=0;if(r===re)o=kt(t),o!==-1&&(l=(t[o]+t[o+3])/2);else if(r===ve)o=kt(n),o!==-1&&(l=Ue(e,i,s,o));else if(r===Ie){const c=et(n);let f=Mt*s;const a=i*6,u=(i+s)*6;for(let p=0;p<3;p++){const d=t[p],A=(t[p+3]-d)/q;if(s=M.candidate?ut(x,e,M.rightCacheBounds):(ut(x,e,M.leftCacheBounds),M.count++)}}for(let x=0;x=q&&(P=q-1);const M=k[P];M.count++,ut(h,e,M.bounds)}const y=k[q-1];Xt(y.bounds,y.rightCacheBounds);for(let h=q-2;h>=0;h--){const x=k[h],b=k[h+1];Wt(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let m=0;for(let h=0;hx&&(x=y),m>x&&(x=m);const b=(x-h)/2,P=w*2;o[u+P+0]=h+b,o[u+P+1]=b+(Math.abs(h)+b)*_e,ht[w+3]&&(t[w+3]=x)}}return o}function Re(n,t){function e(y){p&&p(y/d)}function i(y,m,h,x=null,b=0){if(!g&&b>=c&&(g=!0,f&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(n))),h<=a||b>=c)return e(m),y.offset=m,y.count=h,y;const P=Le(y.boundingData,x,o,m,h,u);if(P.axis===-1)return e(m),y.offset=m,y.count=h,y;const M=Fe(l,o,m,h,P);if(M===m||M===m+h)e(m),y.offset=m,y.count=h;else{y.splitAxis=P.axis;const B=new ft,T=m,S=M-m;y.left=B,B.boundingData=new Float32Array(6),St(o,T,S,B.boundingData,r),i(B,T,S,r,b+1);const v=new ft,I=M,C=h-S;y.right=v,v.boundingData=new Float32Array(6),St(o,I,C,v.boundingData,r),i(v,I,C,r,b+1)}return y}Ce(n,t);const s=new Float32Array(6),r=new Float32Array(6),o=De(n,s),l=n.index.array,c=t.maxDepth,f=t.verbose,a=t.maxLeafTris,u=t.strategy,p=t.onProgress,d=n.index.count/3;let g=!1;const w=[],A=Ve(n);if(A.length===1){const y=A[0],m=new ft;m.boundingData=s,ze(o,y.offset,y.count,r),i(m,y.offset,y.count,r),w.push(m)}else for(let y of A){const m=new ft;m.boundingData=new Float32Array(6),St(o,y.offset,y.count,m.boundingData,r),i(m,y.offset,y.count,r),w.push(m)}return w}function Oe(n,t){const e=Re(n,t);let i,s,r;const o=[],l=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let a=0;aMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[p+6]=h/4,h=f(h,y),s[p+7]=m,h}}}class H{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,s=-1/0;for(let r=0,o=t.length;rs?c:s}this.min=i,this.max=s}setFromPoints(t,e){let i=1/0,s=-1/0;for(let r=0,o=e.length;rs?c:s}this.min=i,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}}H.prototype.setFromBox=function(){const n=new _;return function(e,i){const s=i.min,r=i.max;let o=1/0,l=-1/0;for(let c=0;c<=1;c++)for(let f=0;f<=1;f++)for(let a=0;a<=1;a++){n.x=s.x*c+r.x*(1-c),n.y=s.y*f+r.y*(1-f),n.z=s.z*a+r.z*(1-a);const u=e.dot(n);o=Math.min(u,o),l=Math.max(u,l)}this.min=o,this.max=l}}();const qe=function(){const n=new _,t=new _,e=new _;return function(s,r,o){const l=s.start,c=n,f=r.start,a=t;e.subVectors(l,f),n.subVectors(s.end,r.start),t.subVectors(r.end,r.start);const u=e.dot(a),p=a.dot(c),d=a.dot(a),g=e.dot(c),A=c.dot(c)*d-p*p;let y,m;A!==0?y=(u*p-g*d)/A:y=0,m=(u+y*p)/d,o.x=y,o.y=m}}(),Lt=function(){const n=new at,t=new _,e=new _;return function(s,r,o,l){qe(s,r,n);let c=n.x,f=n.y;if(c>=0&&c<=1&&f>=0&&f<=1){s.at(c,o),r.at(f,l);return}else if(c>=0&&c<=1){f<0?r.at(0,l):r.at(1,l),s.closestPointToPoint(l,!0,o);return}else if(f>=0&&f<=1){c<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,l);return}else{let a;c<0?a=s.start:a=s.end;let u;f<0?u=r.start:u=r.end;const p=t,d=e;if(s.closestPointToPoint(u,!0,t),r.closestPointToPoint(a,!0,e),p.distanceToSquared(u)<=d.distanceToSquared(a)){o.copy(p),l.copy(u);return}else{o.copy(a),l.copy(d);return}}}}(),Ne=function(){const n=new _,t=new _,e=new oe,i=new N;return function(r,o){const{radius:l,center:c}=r,{a:f,b:a,c:u}=o;if(i.start=f,i.end=a,i.closestPointToPoint(c,!0,n).distanceTo(c)<=l||(i.start=f,i.end=u,i.closestPointToPoint(c,!0,n).distanceTo(c)<=l)||(i.start=a,i.end=u,i.closestPointToPoint(c,!0,n).distanceTo(c)<=l))return!0;const w=o.getPlane(e);if(Math.abs(w.distanceToPoint(c))<=l){const y=w.projectPoint(c,t);if(o.containsPoint(y))return!0}return!1}}();class j extends Ct{constructor(...t){super(...t),this.isSeparatingAxisTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _),this.satBounds=new Array(4).fill().map(()=>new H),this.points=[this.a,this.b,this.c],this.sphere=new me,this.plane=new oe,this.needsUpdate=!1}intersectsSphere(t){return Ne(t,this)}update(){const t=this.a,e=this.b,i=this.c,s=this.points,r=this.satAxes,o=this.satBounds,l=r[0],c=o[0];this.getNormal(l),c.setFromPoints(l,s);const f=r[1],a=o[1];f.subVectors(t,e),a.setFromPoints(f,s);const u=r[2],p=o[2];u.subVectors(e,i),p.setFromPoints(u,s);const d=r[3],g=o[3];d.subVectors(i,t),g.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(l,t),this.needsUpdate=!1}}j.prototype.closestPointToSegment=function(){const n=new _,t=new _,e=new N;return function(s,r=null,o=null){const{start:l,end:c}=s,f=this.points;let a,u=1/0;for(let p=0;p<3;p++){const d=(p+1)%3;e.start.copy(f[p]),e.end.copy(f[d]),Lt(e,s,n,t),a=n.distanceToSquared(t),a1-1e-10)console.warn("SeparatingAxisTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0);else{const b=this.points;let P=!1;for(let T=0;T<3;T++){const S=b[T],v=b[(T+1)%3];if(f.start.copy(S),f.end.copy(v),x.intersectLine(f,P?a.start:a.end)){if(P)break;P=!0}}const M=d.points;let B=!1;for(let T=0;T<3;T++){const S=M[T],v=M[(T+1)%3];if(f.start.copy(S),f.end.copy(v),h.intersectLine(f,B?u.start:u.end)){if(B)break;B=!0}}if(a.delta(o),u.delta(l),o.dot(l)<0){let T=u.start;u.start=u.end,u.end=T}c.subVectors(a.start,u.start),c.dot(o)>0?g.start.copy(a.start):g.start.copy(u.start),c.subVectors(a.end,u.end),c.dot(o)<0?g.end.copy(a.end):g.end.copy(u.end)}}return!0}}();j.prototype.distanceToPoint=function(){const n=new _;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}}();j.prototype.distanceToTriangle=function(){const n=new _,t=new _,e=["a","b","c"],i=new N,s=new N;return function(o,l=null,c=null){const f=l||c?i:null;if(this.intersectsTriangle(o,f))return(l||c)&&(l&&f.getCenter(l),c&&f.getCenter(c)),0;let a=1/0;for(let u=0;u<3;u++){let p;const d=e[u],g=o[d];this.closestPointToPoint(g,n),p=g.distanceToSquared(n),pnew _),this.satAxes=new Array(3).fill().map(()=>new _),this.satBounds=new Array(3).fill().map(()=>new H),this.alignedSatBounds=new Array(3).fill().map(()=>new H),this.needsUpdate=!1}set(t,e,i){super.set(t,e),this.matrix=i,this.needsUpdate=!0}copy(t){super.copy(t),this.matrix.copy(t.matrix),this.needsUpdate=!0}}O.prototype.update=function(){return function(){const t=this.matrix,e=this.min,i=this.max,s=this.points;for(let f=0;f<=1;f++)for(let a=0;a<=1;a++)for(let u=0;u<=1;u++){const p=1*f|2*a|4*u,d=s[p];d.x=f?i.x:e.x,d.y=a?i.y:e.y,d.z=u?i.z:e.z,d.applyMatrix4(t)}const r=this.satBounds,o=this.satAxes,l=s[0];for(let f=0;f<3;f++){const a=o[f],u=r[f],p=1<new N),e=new Array(12).fill().map(()=>new N),i=new _,s=new _;return function(o,l=0,c=null,f=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(c||f)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),c&&c.copy(i),f&&f.copy(s)),0;const a=l*l,u=o.min,p=o.max,d=this.points;let g=1/0;for(let A=0;A<8;A++){const y=d[A];s.copy(y).clamp(u,p);const m=y.distanceToSquared(s);if(me.far)?null:n}function R(n,t,e,i){const s=n.a,r=n.b,o=n.c;let l=t,c=t+1,f=t+2;e&&(l=e.getX(t),c=e.getX(t+1),f=e.getX(t+2)),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),r.x=i.getX(c),r.y=i.getY(c),r.z=i.getZ(c),o.x=i.getX(f),o.y=i.getY(f),o.z=i.getZ(f)}function Kt(n,t,e,i,s,r,o){const l=e.index,c=e.attributes.position;for(let f=n,a=t+n;f=0;let d,g;p?(d=rt(n),g=ct(n,l)):(d=ct(n,l),g=rt(n));const A=Tt(d,r,i,Pt)?Ft(d,t,e,i):null;if(A){const h=A.point[a];if(p?h<=r[g+f]:h>=r[g+f+3])return A}const m=Tt(g,r,i,Pt)?Ft(g,t,e,i):null;return A&&m?A.distance<=m.distance?A:m:A||m||null}}const $e=function(){let n,t;const e=[],i=new le(()=>new $);return function(...o){n=i.getPrimitive(),t=i.getPrimitive(),e.push(n,t);const l=s(...o);i.releasePrimitive(n),i.releasePrimitive(t),e.pop(),e.pop();const c=e.length;return c>0&&(t=e[c-1],n=e[c-2]),l};function s(r,o,l,c,f=null,a=0,u=0){function p(h){let x=h*2,b=W,P=G;for(;!X(x,b);)h=rt(h),x=h*2;return Q(h,P)}function d(h){let x=h*2,b=W,P=G;for(;!X(x,b);)h=ct(h,P),x=h*2;return Q(h,P)+ot(x,b)}let g=r*2,w=tt,A=W,y=G;if(X(g,A)){const h=Q(r,y),x=ot(g,A);return U(r,w,n),c(h,x,!1,u,a+r,n)}else{const h=rt(r),x=ct(r,y);let b=h,P=x,M,B,T,S;if(f&&(T=n,S=t,U(b,w,T),U(P,w,S),M=f(T),B=f(S),Bs.intersectsBox(B),intersectsTriangle:B=>{B.a.applyMatrix4(f),B.b.applyMatrix4(f),B.c.applyMatrix4(f),B.needsUpdate=!0;for(let T=b*3,S=(P+b)*3;Tnew j);class z{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),z.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e=Bt({cloneBuffers:!0},e);const i=t.geometry,s=t._roots,r=i.getIndex();let o;return e.cloneBuffers?o={roots:s.map(l=>l.slice()),index:r.array.slice()}:o={roots:s,index:r.array},o}static deserialize(t,e,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),z.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i=Bt({setIndex:!0},i);const{index:s,roots:r}=t,o=new z(e,Se(Bt({},i),{[vt]:!0}));if(o._roots=r,i.setIndex){const l=e.getIndex();if(l===null){const c=new bt(t.index,1,!1);e.setIndex(c)}else l.array!==s&&(l.array.set(s),l.needsUpdate=!0)}return o}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:re,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[vt]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[vt]||(this._roots=Oe(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new $))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=this.geometry,i=e.index.array,s=e.attributes.position,r=s.array,o=s.offset||0;let l=3;s.isInterleavedBufferAttribute&&(l=s.data.stride);let c,f,a,u,p=0;const d=this._roots;for(let w=0,A=d.length;wT&&(T=V),ES&&(S=E),Lv&&(v=L)}return u[w+0]!==P||u[w+1]!==M||u[w+2]!==B||u[w+3]!==T||u[w+4]!==S||u[w+5]!==v?(u[w+0]=P,u[w+1]=M,u[w+2]=B,u[w+3]=T,u[w+4]=S,u[w+5]=v,!0):!1}else{const x=w+8,b=f[w+6],P=x+A,M=b+A;let B=y,T=!1,S=!1;t?B||(T=t.has(P),S=t.has(M),B=!T&&!S):(T=!0,S=!0);const v=B||T,I=B||S;let C=!1;v&&(C=g(x,A,B));let F=!1;I&&(F=g(b,A,B));const V=C||F;if(V)for(let E=0;E<3;E++){const L=x+E,lt=b+E,Z=u[L],Ut=u[L+3],Dt=u[lt],Rt=u[lt+3];u[w+E]=ZRt?Ut:Rt}return V}}}traverse(t,e=0){const i=this._roots[e],s=new Uint32Array(i),r=new Uint16Array(i);o(0);function o(l,c=0){const f=l*2,a=r[f+15]===Vt;if(a){const u=s[l+6],p=r[f+14];t(c,a,new Float32Array(i,l*4,6),u,p)}else{const u=l+wt/4,p=s[l+6],d=s[l+7];t(c,a,new Float32Array(i,l*4,6),d)||(o(u,c+1),o(p,c+1))}}}raycast(t,e=Ot){const i=this._roots,s=this.geometry,r=[],o=e.isMaterial,l=Array.isArray(e),c=s.groups,f=o?e.side:e;for(let a=0,u=i.length;a{const y=g*3;return p(d,y,y+1,y+2,w,A)}}t={boundsTraverseOrder:i,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}const r=D.getPrimitive();let{boundsTraverseOrder:o,intersectsBounds:l,intersectsRange:c,intersectsTriangle:f}=t;if(c&&f){const p=c;c=(d,g,w,A,y)=>p(d,g,w,A,y)?!0:Kt(d,g,s,f,w,A,r)}else c||(f?c=(p,d,g,w)=>Kt(p,d,s,f,g,w,r):c=(p,d,g)=>g);let a=!1,u=0;for(const p of this._roots){if(it(p),a=$e(0,s,l,c,o,u),mt(),a)break;u+=p.byteLength}return D.releasePrimitive(r),a}bvhcast(t,e,i){let{intersectsRanges:s,intersectsTriangles:r}=i;const o=this.geometry.index,l=this.geometry.attributes.position,c=t.geometry.index,f=t.geometry.attributes.position;K.copy(e).invert();const a=D.getPrimitive(),u=D.getPrimitive();if(r){let d=function(g,w,A,y,m,h,x,b){for(let P=A,M=A+y;P_t.intersectsBox(d),intersectsRange:(d,g,w,A,y,m)=>(It.copy(m),It.applyMatrix4(K),t.shapecast({intersectsBounds:h=>It.intersectsBox(h),intersectsRange:(h,x,b,P,M)=>s(d,g,h,x,A,y,P,M)}))});return D.releasePrimitive(a),D.releasePrimitive(u),p}intersectsBox(t,e){return Y.set(t.min,t.max,e),Y.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Y.intersectsBox(i),intersectsTriangle:i=>Y.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},s={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Y.set(t.boundingBox.min,t.boundingBox.max,e),Y.needsUpdate=!0;const l=this.geometry,c=l.attributes.position,f=l.index,a=t.attributes.position,u=t.index,p=D.getPrimitive(),d=D.getPrimitive();let g=xt,w=Ze,A=null,y=null;s&&(A=Ke,y=Je);let m=1/0,h=null,x=null;return K.copy(e).invert(),nt.matrix.copy(K),this.shapecast({boundsTraverseOrder:b=>Y.distanceToBox(b,Math.min(m,o)),intersectsBounds:(b,P,M)=>M{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:M=>nt.distanceToBox(M,Math.min(m,o)),intersectsBounds:(M,B,T)=>T{for(let T=M*3,S=(M+B)*3;T(st.copy(t).clamp(a.min,a.max),st.distanceToSquared(t)),intersectsBounds:(a,u,p)=>p{a.closestPointToPoint(t,st);const p=t.distanceToSquared(st);return p{U(0,new Float32Array(i),Jt),t.union(Jt)}),t}}const Qt=z.prototype.raycast;z.prototype.raycast=function(...n){if(n[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');const[t,e,i,s]=n;return Qt.call(this,i,t.material).forEach(o=>{o=ae(o,t,e),o&&s.push(o)}),s}else return Qt.apply(this,n)};const te=z.prototype.raycastFirst;z.prototype.raycastFirst=function(...n){if(n[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');const[t,e,i]=n;return ae(te.call(this,i,t.material),t,e)}else return te.apply(this,n)};const ee=z.prototype.closestPointToPoint;z.prototype.closestPointToPoint=function(...n){if(n[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),n.unshift();const t=n[1],e={};return n[1]=e,ee.apply(this,n),t&&t.copy(e.point),e.distance}else return ee.apply(this,n)};const ne=z.prototype.closestPointToGeometry;z.prototype.closestPointToGeometry=function(...n){const t=n[2],e=n[3];if(t&&t.isVector3||e&&e.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');const i={},s={},r=n[1];return n[2]=i,n[3]=s,ne.apply(this,n),t&&t.copy(i.point),e&&e.copy(s.point).applyMatrix4(r),i.distance}else return ne.apply(this,n)};const se=z.prototype.refit;z.prototype.refit=function(...n){const t=n[0],e=n[1];if(e&&(e instanceof Set||Array.isArray(e))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');const i=new Set;e.forEach(s=>i.add(s)),t&&t.forEach(s=>i.add(s)),se.call(this,i)}else se.apply(this,n)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(n=>{const t=z.prototype[n];z.prototype[n]=function(...e){return(e[0]===null||e[0].isMesh)&&(e.shift(),console.warn(`MeshBVH: The function signature for "${n}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,e)}});const ie=new $;class Qe extends xe{get isMesh(){return!this.displayEdges}get isLineSegments(){return this.displayEdges}get isLine(){return this.displayEdges}constructor(t,e,i=10,s=0){super(),this.material=e,this.geometry=new we,this.name="MeshBVHRootVisualizer",this.depth=i,this.displayParents=!1,this.mesh=t,this.displayEdges=!0,this._group=s}raycast(){}update(){const t=this.geometry,e=this.mesh.geometry.boundsTree,i=this._group;if(t.dispose(),this.visible=!1,e){const s=this.depth-1,r=this.displayParents;let o=0;e.traverse((p,d)=>{if(p===s||d)return o++,!0;r&&o++},i);let l=0;const c=new Float32Array(8*3*o);e.traverse((p,d,g)=>{const w=p===s||d;if(w||r){U(0,g,ie);const{min:A,max:y}=ie;for(let m=-1;m<=1;m+=2){const h=m<0?A.x:y.x;for(let x=-1;x<=1;x+=2){const b=x<0?A.y:y.y;for(let P=-1;P<=1;P+=2){const M=P<0?A.z:y.z;c[l+0]=h,c[l+1]=b,c[l+2]=M,l+=3}}}return w}},i);let f,a;this.displayEdges?a=new Uint8Array([0,4,1,5,2,6,3,7,0,2,1,3,4,6,5,7,0,1,2,3,4,5,6,7]):a=new Uint8Array([0,1,2,2,1,3,4,6,5,6,7,5,1,4,5,0,4,1,2,3,6,3,7,6,0,2,4,2,6,4,1,5,3,3,5,7]),c.length>65535?f=new Uint32Array(a.length*o):f=new Uint16Array(a.length*o);const u=a.length;for(let p=0;pe;)this._roots.pop();for(let i=0;i=this._roots.length){const r=new Qe(this.mesh,this.edgeMaterial,this.depth,i);this.add(r),this._roots.push(r)}const s=this._roots[i];s.depth=this.depth,s.mesh=this.mesh,s.displayParents=this.displayParents,s.displayEdges=this.displayEdges,s.material=this.displayEdges?this.edgeMaterial:this.meshMaterial,s.update()}}updateMatrixWorld(...t){this.position.copy(this.mesh.position),this.rotation.copy(this.mesh.rotation),this.scale.copy(this.mesh.scale),super.updateMatrixWorld(...t)}copy(t){this.depth=t.depth,this.mesh=t.mesh}clone(){return new fe(this.mesh,this.depth)}dispose(){this.edgeMaterial.dispose(),this.meshMaterial.dispose();const t=this.children;for(let e=0,i=t.length;e{n.outerObject3d.updateMatrixWorld(!0);const t=[];n.outerObject3d.traverse(i=>{if(!i.geometry||i===n.object3d&&!(n instanceof ye))return;const s=i.geometry.clone();s.applyMatrix4(i.matrixWorld),t.push(s),s.dispose()});const e=[];for(const i of t){const s=i.boundsTree=new z(i);e.push(s),tn.set(s,n)}return[e,t]};export{fe as M,tn as b,nn as c};