@thatopen/components 2.4.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Components/index.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/namespace.d.ts +3697 -3697
- package/package.json +58 -58
package/dist/index.min.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,i,s)=>(((t,i,s)=>{i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s})(t,"symbol"!=typeof i?i+"":i,s),s);import*as i from"three";import{BufferAttribute as s,Vector3 as n,Plane as r,Line3 as o,Vector2 as a,Triangle as c,Sphere as l,Matrix4 as h,Box3 as u,BackSide as I,DoubleSide as d,FrontSide as E,Ray as f,Mesh as p,Object3D as C,MeshBasicMaterial as T,LineBasicMaterial as m,CylinderGeometry as R,BoxGeometry as g,BufferGeometry as A,Float32BufferAttribute as F,OctahedronGeometry as S,Line as O,TorusGeometry as N,SphereGeometry as y,Quaternion as L,Euler as _,PlaneGeometry as P,Raycaster as w}from"three";import*as M from"@thatopen/fragments";import{FragmentsGroup as v,Serializer as D}from"@thatopen/fragments";import*as b from"web-ifc";const U=1.25,x=65535,B=Math.pow(2,-24),V=Symbol("SKIP_GENERATION");function Y(e){return function(e){return e.index?e.index.count:e.attributes.position.count}(e)/3}function G(e,t){if(!e.index){const i=e.attributes.position.count,n=function(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}(i,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new s(n,1));for(let e=0;e<i;e++)n[e]=e}}function z(e){const t=Y(e),i=e.drawRange,s=i.start/3,n=(i.start+i.count)/3,r=Math.max(0,s),o=Math.min(t,n)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function k(e){if(!e.groups||!e.groups.length)return z(e);const t=[],i=new Set,s=e.drawRange,n=s.start/3,r=(s.start+s.count)/3;for(const t of e.groups){const e=t.start/3,s=(t.start+t.count)/3;i.add(Math.max(n,e)),i.add(Math.min(r,s))}const o=Array.from(i.values()).sort(((e,t)=>e-t));for(let e=0;e<o.length-1;e++){const i=o[e],s=o[e+1];t.push({offset:Math.floor(i),count:Math.floor(s-i)})}return t}function H(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function W(e){let t=-1,i=-1/0;for(let s=0;s<3;s++){const n=e[s+3]-e[s];n>i&&(i=n,t=s)}return t}function X(e,t){t.set(e)}function j(e,t,i){let s,n;for(let r=0;r<3;r++){const o=r+3;s=e[r],n=t[r],i[r]=s<n?s:n,s=e[o],n=t[o],i[o]=s>n?s:n}}function Z(e,t,i){for(let s=0;s<3;s++){const n=t[e+2*s],r=t[e+2*s+1],o=n-r,a=n+r;o<i[s]&&(i[s]=o),a>i[s+3]&&(i[s+3]=a)}}function $(e){const t=e[3]-e[0],i=e[4]-e[1],s=e[5]-e[2];return 2*(t*i+i*s+s*t)}function q(e,t,i,s,n=null){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,h=-1/0,u=1/0,I=1/0,d=1/0,E=-1/0,f=-1/0,p=-1/0;const C=null!==n;for(let s=6*t,n=6*(t+i);s<n;s+=6){const t=e[s+0],i=e[s+1],n=t-i,T=t+i;n<r&&(r=n),T>c&&(c=T),C&&t<u&&(u=t),C&&t>E&&(E=t);const m=e[s+2],R=e[s+3],g=m-R,A=m+R;g<o&&(o=g),A>l&&(l=A),C&&m<I&&(I=m),C&&m>f&&(f=m);const F=e[s+4],S=e[s+5],O=F-S,N=F+S;O<a&&(a=O),N>h&&(h=N),C&&F<d&&(d=F),C&&F>p&&(p=F)}s[0]=r,s[1]=o,s[2]=a,s[3]=c,s[4]=l,s[5]=h,C&&(n[0]=u,n[1]=I,n[2]=d,n[3]=E,n[4]=f,n[5]=p)}const Q=32,K=(e,t)=>e.candidate-t.candidate,J=new Array(Q).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),ee=new Float32Array(6);class te{constructor(){}}function ie(e,t,i,s,n,r){let o=s,a=s+n-1;const c=r.pos,l=2*r.axis;for(;;){for(;o<=a&&i[6*o+l]<c;)o++;for(;o<=a&&i[6*a+l]>=c;)a--;if(!(o<a))return o;for(let e=0;e<3;e++){let i=t[3*o+e];t[3*o+e]=t[3*a+e],t[3*a+e]=i}for(let e=0;e<6;e++){let t=i[6*o+e];i[6*o+e]=i[6*a+e],i[6*a+e]=t}o++,a--}}function se(e,t,i,s,n,r){let o=s,a=s+n-1;const c=r.pos,l=2*r.axis;for(;;){for(;o<=a&&i[6*o+l]<c;)o++;for(;o<=a&&i[6*a+l]>=c;)a--;if(!(o<a))return o;{let t=e[o];e[o]=e[a],e[a]=t;for(let e=0;e<6;e++){let t=i[6*o+e];i[6*o+e]=i[6*a+e],i[6*a+e]=t}o++,a--}}}function ne(e,t){const i=e.geometry,s=i.index?i.index.array:null,n=t.maxDepth,r=t.verbose,o=t.maxLeafTris,a=t.strategy,c=t.onProgress,l=Y(i),h=e._indirectBuffer;let u=!1;const I=new Float32Array(6),d=new Float32Array(6),E=function(e,t){var i;(i=t)[0]=i[1]=i[2]=1/0,i[3]=i[4]=i[5]=-1/0;const s=e.attributes.position,n=e.index?e.index.array:null,r=Y(e),o=new Float32Array(6*r),a=s.normalized,c=s.array,l=s.offset||0;let h=3;s.isInterleavedBufferAttribute&&(h=s.data.stride);const u=["getX","getY","getZ"];for(let e=0;e<r;e++){const i=3*e,r=6*e;let I=i+0,d=i+1,E=i+2;n&&(I=n[I],d=n[d],E=n[E]),a||(I=I*h+l,d=d*h+l,E=E*h+l);for(let e=0;e<3;e++){let i,n,l;a?(i=s[u[e]](I),n=s[u[e]](d),l=s[u[e]](E)):(i=c[I+e],n=c[d+e],l=c[E+e]);let h=i;n<h&&(h=n),l<h&&(h=l);let f=i;n>f&&(f=n),l>f&&(f=l);const p=(f-h)/2,C=2*e;o[r+C+0]=h+p,o[r+C+1]=p+(Math.abs(h)+p)*B,h<t[e]&&(t[e]=h),f>t[e+3]&&(t[e+3]=f)}}return o}(i,I),f=t.indirect?se:ie,p=[],C=t.indirect?z(i):k(i);if(1===C.length){const e=C[0],t=new te;t.boundingData=I,function(e,t,i,s){let n=1/0,r=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let s=6*t,h=6*(t+i);s<h;s+=6){const t=e[s+0];t<n&&(n=t),t>a&&(a=t);const i=e[s+2];i<r&&(r=i),i>c&&(c=i);const h=e[s+4];h<o&&(o=h),h>l&&(l=h)}s[0]=n,s[1]=r,s[2]=o,s[3]=a,s[4]=c,s[5]=l}(E,e.offset,e.count,d),m(t,e.offset,e.count,d),p.push(t)}else for(let e of C){const t=new te;t.boundingData=new Float32Array(6),q(E,e.offset,e.count,t.boundingData,d),m(t,e.offset,e.count,d),p.push(t)}return p;function T(e){c&&c(e/l)}function m(e,t,c,l=null,I=0){if(!u&&I>=n&&(u=!0,r&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),c<=o||I>=n)return T(t+c),e.offset=t,e.count=c,e;const p=function(e,t,i,s,n,r){let o=-1,a=0;if(0===r)o=W(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(1===r)o=W(e),-1!==o&&(a=function(e,t,i,s){let n=0;for(let r=t,o=t+i;r<o;r++)n+=e[6*r+2*s];return n/i}(i,s,n,o));else if(2===r){const r=$(e);let c=U*n;const l=6*s,h=6*(s+n);for(let e=0;e<3;e++){const s=t[e],u=(t[e+3]-s)/Q;if(n<8){const t=[...J];t.length=n;let s=0;for(let n=l;n<h;n+=6,s++){const r=t[s];r.candidate=i[n+2*e],r.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:c}=r;for(let e=0;e<3;e++)c[e]=1/0,c[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;Z(n,i,o)}t.sort(K);let u=n;for(let e=0;e<u;e++){const i=t[e];for(;e+1<u&&t[e+1].candidate===i.candidate;)t.splice(e+1,1),u--}for(let s=l;s<h;s+=6){const n=i[s+2*e];for(let e=0;e<u;e++){const r=t[e];n>=r.candidate?Z(s,i,r.rightCacheBounds):(Z(s,i,r.leftCacheBounds),r.count++)}}for(let i=0;i<u;i++){const s=t[i],l=s.count,h=n-s.count,u=s.leftCacheBounds,I=s.rightCacheBounds;let d=0;0!==l&&(d=$(u)/r);let E=0;0!==h&&(E=$(I)/r);const f=1+U*(d*l+E*h);f<c&&(o=e,c=f,a=s.candidate)}}else{for(let e=0;e<Q;e++){const t=J[e];t.count=0,t.candidate=s+u+e*u;const i=t.bounds;for(let e=0;e<3;e++)i[e]=1/0,i[e+3]=-1/0}for(let t=l;t<h;t+=6){let n=~~((i[t+2*e]-s)/u);n>=Q&&(n=31);const r=J[n];r.count++,Z(t,i,r.bounds)}const t=J[31];X(t.bounds,t.rightCacheBounds);for(let e=30;e>=0;e--){const t=J[e],i=J[e+1];j(t.bounds,i.rightCacheBounds,t.rightCacheBounds)}let I=0;for(let t=0;t<31;t++){const i=J[t],s=i.count,l=i.bounds,h=J[t+1].rightCacheBounds;0!==s&&(0===I?X(l,ee):j(l,ee,ee)),I+=s;let u=0,d=0;0!==I&&(u=$(ee)/r);const E=n-I;0!==E&&(d=$(h)/r);const f=1+U*(u*I+d*E);f<c&&(o=e,c=f,a=i.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}(e.boundingData,l,E,t,c,a);if(-1===p.axis)return T(t+c),e.offset=t,e.count=c,e;const C=f(h,s,E,t,c,p);if(C===t||C===t+c)T(t+c),e.offset=t,e.count=c;else{e.splitAxis=p.axis;const i=new te,s=t,n=C-t;e.left=i,i.boundingData=new Float32Array(6),q(E,s,n,i.boundingData,d),m(i,s,n,d,I+1);const r=new te,o=C,a=c-n;e.right=r,r.boundingData=new Float32Array(6),q(E,o,a,r.boundingData,d),m(r,o,a,d,I+1)}return e}}function re(e,t){const i=e.geometry;t.indirect&&(e._indirectBuffer=function(e,t){const i=(e.index?e.index.count:e.attributes.position.count)/3,s=i>65536,n=s?4:2,r=t?new SharedArrayBuffer(i*n):new ArrayBuffer(i*n),o=s?new Uint32Array(r):new Uint16Array(r);for(let e=0,t=o.length;e<t;e++)o[e]=e;return o}(i,t.useSharedArrayBuffer),function(e){if(0===e.groups.length)return!1;const t=Y(e),i=k(e).sort(((e,t)=>e.offset-t.offset)),s=i[i.length-1];s.count=Math.min(t-s.offset,s.count);let n=0;return i.forEach((({count:e})=>n+=e)),t!==n}(i)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),e._indirectBuffer||G(i,t);const s=ne(e,t);let n,r,o;const a=[],c=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let e=0;e<s.length;e++){const t=s[e];const i=new c(32*l(t));n=new Float32Array(i),r=new Uint32Array(i),o=new Uint16Array(i),h(0,t),a.push(i)}return void(e._roots=a);function l(e){return e.count?1:1+l(e.left)+l(e.right)}function h(e,t){const i=e/4,s=e/2,a=!!t.count,c=t.boundingData;for(let e=0;e<6;e++)n[i+e]=c[e];if(a){const n=t.offset,a=t.count;return r[i+6]=n,o[s+14]=a,o[s+15]=x,e+32}{const s=t.left,n=t.right,o=t.splitAxis;let a;if(a=h(e+32,s),a/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[i+6]=a/4,a=h(a,n),r[i+7]=o,a}}}class oe{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let n=0,r=e.length;n<r;n++){const r=e[n][t];i=r<i?r:i,s=r>s?r:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let n=0,r=t.length;n<r;n++){const r=t[n],o=e.dot(r);i=o<i?o:i,s=o>s?o:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}oe.prototype.setFromBox=function(){const e=new n;return function(t,i){const s=i.min,n=i.max;let r=1/0,o=-1/0;for(let i=0;i<=1;i++)for(let a=0;a<=1;a++)for(let c=0;c<=1;c++){e.x=s.x*i+n.x*(1-i),e.y=s.y*a+n.y*(1-a),e.z=s.z*c+n.z*(1-c);const l=t.dot(e);r=Math.min(l,r),o=Math.max(l,o)}this.min=r,this.max=o}}();const ae=function(){const e=new n,t=new n,i=new n;return function(s,n,r){const o=s.start,a=e,c=n.start,l=t;i.subVectors(o,c),e.subVectors(s.end,s.start),t.subVectors(n.end,n.start);const h=i.dot(l),u=l.dot(a),I=l.dot(l),d=i.dot(a),E=a.dot(a)*I-u*u;let f,p;f=0!==E?(h*u-d*I)/E:0,p=(h+f*u)/I,r.x=f,r.y=p}}(),ce=function(){const e=new a,t=new n,i=new n;return function(s,n,r,o){ae(s,n,e);let a=e.x,c=e.y;if(a>=0&&a<=1&&c>=0&&c<=1)return s.at(a,r),void n.at(c,o);if(a>=0&&a<=1)return c<0?n.at(0,o):n.at(1,o),void s.closestPointToPoint(o,!0,r);if(c>=0&&c<=1)return a<0?s.at(0,r):s.at(1,r),void n.closestPointToPoint(r,!0,o);{let e,l;e=a<0?s.start:s.end,l=c<0?n.start:n.end;const h=t,u=i;return s.closestPointToPoint(l,!0,t),n.closestPointToPoint(e,!0,i),h.distanceToSquared(l)<=u.distanceToSquared(e)?(r.copy(h),void o.copy(l)):(r.copy(e),void o.copy(u))}}}(),le=function(){const e=new n,t=new n,i=new r,s=new o;return function(n,r){const{radius:o,center:a}=n,{a:c,b:l,c:h}=r;s.start=c,s.end=l;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;s.start=c,s.end=h;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;s.start=l,s.end=h;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const u=r.getPlane(i);if(Math.abs(u.distanceToPoint(a))<=o){const e=u.projectPoint(a,t);if(r.containsPoint(e))return!0}return!1}}();function he(e){return Math.abs(e)<1e-15}class ue extends c{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new n)),this.satBounds=new Array(4).fill().map((()=>new oe)),this.points=[this.a,this.b,this.c],this.sphere=new l,this.plane=new r,this.needsUpdate=!0}intersectsSphere(e){return le(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,n=this.satAxes,r=this.satBounds,o=n[0],a=r[0];this.getNormal(o),a.setFromPoints(o,s);const c=n[1],l=r[1];c.subVectors(e,t),l.setFromPoints(c,s);const h=n[2],u=r[2];h.subVectors(t,i),u.setFromPoints(h,s);const I=n[3],d=r[3];I.subVectors(i,e),d.setFromPoints(I,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}ue.prototype.closestPointToSegment=function(){const e=new n,t=new n,i=new o;return function(s,n=null,r=null){const{start:o,end:a}=s,c=this.points;let l,h=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;i.start.copy(c[o]),i.end.copy(c[a]),ce(i,s,e,t),l=e.distanceToSquared(t),l<h&&(h=l,n&&n.copy(e),r&&r.copy(t))}return this.closestPointToPoint(o,e),l=o.distanceToSquared(e),l<h&&(h=l,n&&n.copy(e),r&&r.copy(o)),this.closestPointToPoint(a,e),l=a.distanceToSquared(e),l<h&&(h=l,n&&n.copy(e),r&&r.copy(a)),Math.sqrt(h)}}(),ue.prototype.intersectsTriangle=function(){const e=new ue,t=new Array(3),i=new Array(3),s=new oe,r=new oe,a=new n,c=new n,l=new n,h=new n,u=new n,I=new o,d=new o,E=new o,f=new n;function p(e,t,i){const s=e.points;let n=0,r=-1;for(let e=0;e<3;e++){const{start:o,end:a}=I;o.copy(s[e]),a.copy(s[(e+1)%3]),I.delta(c);const l=he(t.distanceToPoint(o));if(he(t.normal.dot(c))&&l){i.copy(I),n=2;break}const h=t.intersectLine(I,f);if(!h&&l&&f.copy(o),(h||l)&&!he(f.distanceTo(a))){if(n<=1){(1===n?i.start:i.end).copy(f),l&&(r=n)}else if(n>=2){(1===r?i.start:i.end).copy(f),n=2;break}if(n++,2===n&&-1===r)break}}return n}return function(n,o=null,c=!1){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);const I=this.plane,f=n.plane;if(Math.abs(I.normal.dot(f.normal))>1-1e-10){const e=this.satBounds,l=this.satAxes;i[0]=n.a,i[1]=n.b,i[2]=n.c;for(let t=0;t<4;t++){const n=e[t],r=l[t];if(s.setFromPoints(r,i),n.isSeparated(s))return!1}const h=n.satBounds,u=n.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let e=0;e<4;e++){const i=h[e],n=u[e];if(s.setFromPoints(n,t),i.isSeparated(s))return!1}for(let e=0;e<4;e++){const n=l[e];for(let e=0;e<4;e++){const o=u[e];if(a.crossVectors(n,o),s.setFromPoints(a,t),r.setFromPoints(a,i),s.isSeparated(r))return!1}}return o&&(c||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),o.start.set(0,0,0),o.end.set(0,0,0)),!0}{const e=p(this,f,d);if(1===e&&n.containsPoint(d.end))return o&&(o.start.copy(d.end),o.end.copy(d.end)),!0;if(2!==e)return!1;const t=p(n,I,E);if(1===t&&this.containsPoint(E.end))return o&&(o.start.copy(E.end),o.end.copy(E.end)),!0;if(2!==t)return!1;if(d.delta(l),E.delta(h),l.dot(h)<0){let e=E.start;E.start=E.end,E.end=e}const i=d.start.dot(l),s=d.end.dot(l),r=E.start.dot(l),a=E.end.dot(l);return(i===a||r===s||s<r!==i<a)&&(o&&(u.subVectors(d.start,E.start),u.dot(l)>0?o.start.copy(d.start):o.start.copy(E.start),u.subVectors(d.end,E.end),u.dot(l)<0?o.end.copy(d.end):o.end.copy(E.end)),!0)}}}(),ue.prototype.distanceToPoint=function(){const e=new n;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),ue.prototype.distanceToTriangle=function(){const e=new n,t=new n,i=["a","b","c"],s=new o,r=new o;return function(n,o=null,a=null){const c=o||a?s:null;if(this.intersectsTriangle(n,c))return(o||a)&&(o&&c.getCenter(o),a&&c.getCenter(a)),0;let l=1/0;for(let t=0;t<3;t++){let s;const r=i[t],c=n[r];this.closestPointToPoint(c,e),s=c.distanceToSquared(e),s<l&&(l=s,o&&o.copy(e),a&&a.copy(c));const h=this[r];n.closestPointToPoint(h,e),s=h.distanceToSquared(e),s<l&&(l=s,o&&o.copy(h),a&&a.copy(e))}for(let c=0;c<3;c++){const h=i[c],u=i[(c+1)%3];s.set(this[h],this[u]);for(let c=0;c<3;c++){const h=i[c],u=i[(c+1)%3];r.set(n[h],n[u]),ce(s,r,e,t);const I=e.distanceToSquared(t);I<l&&(l=I,o&&o.copy(e),a&&a.copy(t))}}return Math.sqrt(l)}}();class Ie{constructor(e,t,i){this.isOrientedBox=!0,this.min=new n,this.max=new n,this.matrix=new h,this.invMatrix=new h,this.points=new Array(8).fill().map((()=>new n)),this.satAxes=new Array(3).fill().map((()=>new n)),this.satBounds=new Array(3).fill().map((()=>new oe)),this.alignedSatBounds=new Array(3).fill().map((()=>new oe)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ie.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let n=0;n<=1;n++)for(let r=0;r<=1;r++)for(let o=0;o<=1;o++){const a=s[1*n|2*r|4*o];a.x=n?i.x:t.x,a.y=r?i.y:t.y,a.z=o?i.z:t.z,a.applyMatrix4(e)}const n=this.satBounds,r=this.satAxes,o=s[0];for(let e=0;e<3;e++){const t=r[e],i=n[e],a=s[1<<e];t.subVectors(o,a),i.setFromPoints(t,s)}const a=this.alignedSatBounds;a[0].setFromPointsField(s,"x"),a[1].setFromPointsField(s,"y"),a[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Ie.prototype.intersectsBox=function(){const e=new oe;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,n=this.satBounds,r=this.satAxes,o=this.alignedSatBounds;if(e.min=i.x,e.max=s.x,o[0].isSeparated(e))return!1;if(e.min=i.y,e.max=s.y,o[1].isSeparated(e))return!1;if(e.min=i.z,e.max=s.z,o[2].isSeparated(e))return!1;for(let i=0;i<3;i++){const s=r[i],o=n[i];if(e.setFromBox(s,t),o.isSeparated(e))return!1}return!0}}(),Ie.prototype.intersectsTriangle=function(){const e=new ue,t=new Array(3),i=new oe,s=new oe,r=new n;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);const o=this.satBounds,a=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let e=0;e<3;e++){const s=o[e],n=a[e];if(i.setFromPoints(n,t),s.isSeparated(i))return!1}const c=n.satBounds,l=n.satAxes,h=this.points;for(let e=0;e<3;e++){const t=c[e],s=l[e];if(i.setFromPoints(s,h),t.isSeparated(i))return!1}for(let e=0;e<3;e++){const n=a[e];for(let e=0;e<4;e++){const o=l[e];if(r.crossVectors(n,o),i.setFromPoints(r,t),s.setFromPoints(r,h),i.isSeparated(s))return!1}}return!0}}(),Ie.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}(),Ie.prototype.distanceToPoint=function(){const e=new n;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Ie.prototype.distanceToBox=function(){const e=["x","y","z"],t=new Array(12).fill().map((()=>new o)),i=new Array(12).fill().map((()=>new o)),s=new n,r=new n;return function(n,o=0,a=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(a||c)&&(n.getCenter(r),this.closestPointToPoint(r,s),n.closestPointToPoint(s,r),a&&a.copy(s),c&&c.copy(r)),0;const l=o*o,h=n.min,u=n.max,I=this.points;let d=1/0;for(let e=0;e<8;e++){const t=I[e];r.copy(t).clamp(h,u);const i=t.distanceToSquared(r);if(i<d&&(d=i,a&&a.copy(t),c&&c.copy(r),i<l))return Math.sqrt(i)}let E=0;for(let s=0;s<3;s++)for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){const o=(s+1)%3,a=(s+2)%3,c=1<<s|n<<o|r<<a,l=I[n<<o|r<<a],d=I[c];t[E].set(l,d);const f=e[s],p=e[o],C=e[a],T=i[E],m=T.start,R=T.end;m[f]=h[f],m[p]=n?h[p]:u[p],m[C]=r?h[C]:u[p],R[f]=u[f],R[p]=n?h[p]:u[p],R[C]=r?h[C]:u[p],E++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let i=0;i<=1;i++){r.x=e?u.x:h.x,r.y=t?u.y:h.y,r.z=i?u.z:h.z,this.closestPointToPoint(r,s);const n=r.distanceToSquared(s);if(n<d&&(d=n,a&&a.copy(s),c&&c.copy(r),n<l))return Math.sqrt(n)}for(let e=0;e<12;e++){const n=t[e];for(let e=0;e<12;e++){const t=i[e];ce(n,t,s,r);const o=s.distanceToSquared(r);if(o<d&&(d=o,a&&a.copy(s),c&&c.copy(r),o<l))return Math.sqrt(o)}}return Math.sqrt(d)}}();class de{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Ee extends de{constructor(){super((()=>new ue))}}const fe=new Ee;function pe(e,t){return 65535===t[e+15]}function Ce(e,t){return t[e+6]}function Te(e,t){return t[e+14]}function me(e){return e+8}function Re(e,t){return t[e+6]}function ge(e,t){return t[e+7]}const Ae=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==e.length&&this.setBuffer(e.pop())}}};let Fe,Se;const Oe=[],Ne=new de((()=>new u));function ye(e,t,i,s,n,r){Fe=Ne.getPrimitive(),Se=Ne.getPrimitive(),Oe.push(Fe,Se),Ae.setBuffer(e._roots[t]);const o=Le(0,e.geometry,i,s,n,r);Ae.clearBuffer(),Ne.releasePrimitive(Fe),Ne.releasePrimitive(Se),Oe.pop(),Oe.pop();const a=Oe.length;return a>0&&(Se=Oe[a-1],Fe=Oe[a-2]),o}function Le(e,t,i,s,n=null,r=0,o=0){const{float32Array:a,uint16Array:c,uint32Array:l}=Ae;let h=2*e;if(pe(h,c)){const t=Ce(e,l),i=Te(h,c);return H(e,a,Fe),s(t,i,!1,o,r+e,Fe)}{let h=function(e){const{uint16Array:t,uint32Array:i}=Ae;let s=2*e;for(;!pe(s,t);)s=2*(e=me(e));return Ce(e,i)},u=function(e){const{uint16Array:t,uint32Array:i}=Ae;let s=2*e;for(;!pe(s,t);)s=2*(e=Re(e,i));return Ce(e,i)+Te(s,t)};const I=me(e),d=Re(e,l);let E,f,p,C,T=I,m=d;if(n&&(p=Fe,C=Se,H(T,a,p),H(m,a,C),E=n(p),f=n(C),f<E)){T=d,m=I;const e=E;E=f,f=e,p=C}p||(p=Fe,H(T,a,p));const R=i(p,pe(2*T,c),E,o+1,r+T);let g;if(2===R){const e=h(T);g=s(e,u(T)-e,!0,o+1,r+T,p)}else g=R&&Le(T,t,i,s,n,r,o+1);if(g)return!0;C=Se,H(m,a,C);const A=i(C,pe(2*m,c),f,o+1,r+m);let F;if(2===A){const e=h(m);F=s(e,u(m)-e,!0,o+1,r+m,C)}else F=A&&Le(m,t,i,s,n,r,o+1);return!!F}}const _e=new n,Pe=new n;const we=new n,Me=new n,ve=new n,De=new a,be=new a,Ue=new a,xe=new n,Be=new n,Ve=new n,Ye=new n;function Ge(e,t,i,s,r,o,l,h,u){we.fromBufferAttribute(t,o),Me.fromBufferAttribute(t,l),ve.fromBufferAttribute(t,h);const E=function(e,t,i,s,n,r){let o;return o=r===I?e.intersectTriangle(s,i,t,!0,n):e.intersectTriangle(t,i,s,r!==d,n),null===o?null:{distance:e.origin.distanceTo(n),point:n.clone()}}(e,we,Me,ve,Ye,u);if(E){s&&(De.fromBufferAttribute(s,o),be.fromBufferAttribute(s,l),Ue.fromBufferAttribute(s,h),E.uv=c.getInterpolation(Ye,we,Me,ve,De,be,Ue,new a)),r&&(De.fromBufferAttribute(r,o),be.fromBufferAttribute(r,l),Ue.fromBufferAttribute(r,h),E.uv1=c.getInterpolation(Ye,we,Me,ve,De,be,Ue,new a)),i&&(xe.fromBufferAttribute(i,o),Be.fromBufferAttribute(i,l),Ve.fromBufferAttribute(i,h),E.normal=c.getInterpolation(Ye,we,Me,ve,xe,Be,Ve,new n),E.normal.dot(e.direction)>0&&E.normal.multiplyScalar(-1));const t={a:o,b:l,c:h,normal:new n,materialIndex:0};c.getNormal(we,Me,ve,t.normal),E.face=t,E.faceIndex=o}return E}function ze(e,t,i,s,n){const r=3*s;let o=r+0,a=r+1,c=r+2;const l=e.index;e.index&&(o=l.getX(o),a=l.getX(a),c=l.getX(c));const{position:h,normal:u,uv:I,uv1:d}=e.attributes,E=Ge(i,h,u,I,d,o,a,c,t);return E?(E.faceIndex=s,n&&n.push(E),E):null}function ke(e,t,i,s){const n=e.a,r=e.b,o=e.c;let a=t,c=t+1,l=t+2;i&&(a=i.getX(a),c=i.getX(c),l=i.getX(l)),n.x=s.getX(a),n.y=s.getY(a),n.z=s.getZ(a),r.x=s.getX(c),r.y=s.getY(c),r.z=s.getZ(c),o.x=s.getX(l),o.y=s.getY(l),o.z=s.getZ(l)}function He(e,t,i,s,n,r,o){const{geometry:a}=i,{index:c}=a,l=a.attributes.position;for(let i=e,a=t+e;i<a;i++){let e;if(e=i,ke(o,3*e,c,l),o.needsUpdate=!0,s(o,e,n,r))return!0}return!1}function We(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const i=e.geometry,s=i.index?i.index.array:null,n=i.attributes.position;let r,o,a,c,l=0;const h=e._roots;for(let e=0,t=h.length;e<t;e++)r=h[e],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),u(0,l),l+=r.byteLength;function u(e,i,r=!1){const l=2*e;if(a[l+15]===x){const t=o[e+6];let i=1/0,r=1/0,h=1/0,u=-1/0,I=-1/0,d=-1/0;for(let e=3*t,o=3*(t+a[l+14]);e<o;e++){let t=s[e];const o=n.getX(t),a=n.getY(t),c=n.getZ(t);o<i&&(i=o),o>u&&(u=o),a<r&&(r=a),a>I&&(I=a),c<h&&(h=c),c>d&&(d=c)}return(c[e+0]!==i||c[e+1]!==r||c[e+2]!==h||c[e+3]!==u||c[e+4]!==I||c[e+5]!==d)&&(c[e+0]=i,c[e+1]=r,c[e+2]=h,c[e+3]=u,c[e+4]=I,c[e+5]=d,!0)}{const s=e+8,n=o[e+6],a=s+i,l=n+i;let h=r,I=!1,d=!1;t?h||(I=t.has(a),d=t.has(l),h=!I&&!d):(I=!0,d=!0);const E=h||d;let f=!1;(h||I)&&(f=u(s,i,h));let p=!1;E&&(p=u(n,i,h));const C=f||p;if(C)for(let t=0;t<3;t++){const i=s+t,r=n+t,o=c[i],a=c[i+3],l=c[r],h=c[r+3];c[e+t]=o<l?o:l,c[e+t+3]=a>h?a:h}return C}}}const Xe=new u;function je(e,t,i,s){return H(e,t,Xe),i.intersectBox(Xe,s)}function Ze(e,t,i,s,n,r,o){const{geometry:a}=i,{index:c}=a,l=a.attributes.position;for(let a=e,h=t+e;a<h;a++){let e;if(e=i.resolveTriangleIndex(a),ke(o,3*e,c,l),o.needsUpdate=!0,s(o,e,n,r))return!0}return!1}const $e=new n;function qe(e,t,i,s,n){Ae.setBuffer(e._roots[t]),Qe(0,e,i,s,n),Ae.clearBuffer()}function Qe(e,t,i,s,n){const{float32Array:r,uint16Array:o,uint32Array:a}=Ae,c=2*e;if(pe(c,o)){!function(e,t,i,s,n,r){const{geometry:o,_indirectBuffer:a}=e;for(let e=s,a=s+n;e<a;e++)ze(o,t,i,e,r)}(t,i,s,Ce(e,a),Te(c,o),n)}else{const o=me(e);je(o,r,s,$e)&&Qe(o,t,i,s,n);const c=Re(e,a);je(c,r,s,$e)&&Qe(c,t,i,s,n)}}const Ke=new n,Je=["x","y","z"];function et(e,t,i,s){Ae.setBuffer(e._roots[t]);const n=tt(0,e,i,s);return Ae.clearBuffer(),n}function tt(e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:o}=Ae;let a=2*e;if(pe(a,r)){return function(e,t,i,s,n){const{geometry:r,_indirectBuffer:o}=e;let a=1/0,c=null;for(let e=s,o=s+n;e<o;e++){let s;s=ze(r,t,i,e),s&&s.distance<a&&(c=s,a=s.distance)}return c}(t,i,s,Ce(e,o),Te(a,r))}{const r=ge(e,o),a=Je[r],c=s.direction[a]>=0;let l,h;c?(l=me(e),h=Re(e,o)):(l=Re(e,o),h=me(e));const u=je(l,n,s,Ke)?tt(l,t,i,s):null;if(u){const e=u.point[a];if(c?e<=n[h+r]:e>=n[h+r+3])return u}const I=je(h,n,s,Ke)?tt(h,t,i,s):null;return u&&I?u.distance<=I.distance?u:I:u||I||null}}const it=new u,st=new ue,nt=new ue,rt=new h,ot=new Ie,at=new Ie;function ct(e,t,i,s){Ae.setBuffer(e._roots[t]);const n=lt(0,e,i,s);return Ae.clearBuffer(),n}function lt(e,t,i,s,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=Ae;let c=2*e;null===n&&(i.boundingBox||i.computeBoundingBox(),ot.set(i.boundingBox.min,i.boundingBox.max,s),n=ot);if(!pe(c,o)){const o=e+8,c=a[e+6];H(o,r,it);if(n.intersectsBox(it)&<(o,t,i,s,n))return!0;H(c,r,it);return!!(n.intersectsBox(it)&<(c,t,i,s,n))}{const n=t.geometry,l=n.index,h=n.attributes.position,u=i.index,I=i.attributes.position,d=Ce(e,a),E=Te(c,o);if(rt.copy(s).invert(),i.boundsTree){H(e,r,at),at.matrix.copy(rt),at.needsUpdate=!0;return i.boundsTree.shapecast({intersectsBounds:e=>at.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(s),e.b.applyMatrix4(s),e.c.applyMatrix4(s),e.needsUpdate=!0;for(let t=3*d,i=3*(E+d);t<i;t+=3)if(ke(nt,t,l,h),nt.needsUpdate=!0,e.intersectsTriangle(nt))return!0;return!1}})}for(let e=3*d,t=3*(E+d);e<t;e+=3){ke(st,e,l,h),st.a.applyMatrix4(rt),st.b.applyMatrix4(rt),st.c.applyMatrix4(rt),st.needsUpdate=!0;for(let e=0,t=u.count;e<t;e+=3)if(ke(nt,e,u,I),nt.needsUpdate=!0,st.intersectsTriangle(nt))return!0}}}const ht=new h,ut=new Ie,It=new Ie,dt=new n,Et=new n,ft=new n,pt=new n;function Ct(e,t,i,s={},n={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ut.set(t.boundingBox.min,t.boundingBox.max,i),ut.needsUpdate=!0;const a=e.geometry,c=a.attributes.position,l=a.index,h=t.attributes.position,u=t.index,I=fe.getPrimitive(),d=fe.getPrimitive();let E=dt,f=Et,p=null,C=null;n&&(p=ft,C=pt);let T=1/0,m=null,R=null;return ht.copy(i).invert(),It.matrix.copy(ht),e.shapecast({boundsTraverseOrder:e=>ut.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o&&(t&&(It.min.copy(e.min),It.max.copy(e.max),It.needsUpdate=!0),!0),intersectsRange:(e,s)=>{if(t.boundsTree){return t.boundsTree.shapecast({boundsTraverseOrder:e=>It.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o,intersectsRange:(t,n)=>{for(let o=t,a=t+n;o<a;o++){ke(d,3*o,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=e,i=e+s;t<i;t++){ke(I,3*t,l,c),I.needsUpdate=!0;const e=I.distanceToTriangle(d,E,p);if(e<T&&(f.copy(E),C&&C.copy(p),T=e,m=t,R=o),e<r)return!0}}}})}for(let n=0,o=Y(t);n<o;n++){ke(d,3*n,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=e,i=e+s;t<i;t++){ke(I,3*t,l,c),I.needsUpdate=!0;const e=I.distanceToTriangle(d,E,p);if(e<T&&(f.copy(E),C&&C.copy(p),T=e,m=t,R=n),e<r)return!0}}}}),fe.releasePrimitive(I),fe.releasePrimitive(d),T===1/0?null:(s.point?s.point.copy(f):s.point=f.clone(),s.distance=T,s.faceIndex=m,n&&(n.point?n.point.copy(C):n.point=C.clone(),n.point.applyMatrix4(ht),f.applyMatrix4(ht),n.distance=f.sub(n.point).length(),n.faceIndex=R),s)}function Tt(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const i=e.geometry,s=i.index?i.index.array:null,n=i.attributes.position;let r,o,a,c,l=0;const h=e._roots;for(let e=0,t=h.length;e<t;e++)r=h[e],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),u(0,l),l+=r.byteLength;function u(i,r,l=!1){const h=2*i;if(a[h+15]===x){const t=o[i+6];let r=1/0,l=1/0,u=1/0,I=-1/0,d=-1/0,E=-1/0;for(let i=t,o=t+a[h+14];i<o;i++){const t=3*e.resolveTriangleIndex(i);for(let e=0;e<3;e++){let i=t+e;i=s?s[i]:i;const o=n.getX(i),a=n.getY(i),c=n.getZ(i);o<r&&(r=o),o>I&&(I=o),a<l&&(l=a),a>d&&(d=a),c<u&&(u=c),c>E&&(E=c)}}return(c[i+0]!==r||c[i+1]!==l||c[i+2]!==u||c[i+3]!==I||c[i+4]!==d||c[i+5]!==E)&&(c[i+0]=r,c[i+1]=l,c[i+2]=u,c[i+3]=I,c[i+4]=d,c[i+5]=E,!0)}{const e=i+8,s=o[i+6],n=e+r,a=s+r;let h=l,I=!1,d=!1;t?h||(I=t.has(n),d=t.has(a),h=!I&&!d):(I=!0,d=!0);const E=h||d;let f=!1;(h||I)&&(f=u(e,r,h));let p=!1;E&&(p=u(s,r,h));const C=f||p;if(C)for(let t=0;t<3;t++){const n=e+t,r=s+t,o=c[n],a=c[n+3],l=c[r],h=c[r+3];c[i+t]=o<l?o:l,c[i+t+3]=a>h?a:h}return C}}}const mt=new n;function Rt(e,t,i,s,n){Ae.setBuffer(e._roots[t]),gt(0,e,i,s,n),Ae.clearBuffer()}function gt(e,t,i,s,n){const{float32Array:r,uint16Array:o,uint32Array:a}=Ae,c=2*e;if(pe(c,o)){!function(e,t,i,s,n,r){const{geometry:o,_indirectBuffer:a}=e;for(let e=s,c=s+n;e<c;e++)ze(o,t,i,a?a[e]:e,r)}(t,i,s,Ce(e,a),Te(c,o),n)}else{const o=me(e);je(o,r,s,mt)&>(o,t,i,s,n);const c=Re(e,a);je(c,r,s,mt)&>(c,t,i,s,n)}}const At=new n,Ft=["x","y","z"];function St(e,t,i,s){Ae.setBuffer(e._roots[t]);const n=Ot(0,e,i,s);return Ae.clearBuffer(),n}function Ot(e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:o}=Ae;let a=2*e;if(pe(a,r)){return function(e,t,i,s,n){const{geometry:r,_indirectBuffer:o}=e;let a=1/0,c=null;for(let e=s,l=s+n;e<l;e++){let s;s=ze(r,t,i,o?o[e]:e),s&&s.distance<a&&(c=s,a=s.distance)}return c}(t,i,s,Ce(e,o),Te(a,r))}{const r=ge(e,o),a=Ft[r],c=s.direction[a]>=0;let l,h;c?(l=me(e),h=Re(e,o)):(l=Re(e,o),h=me(e));const u=je(l,n,s,At)?Ot(l,t,i,s):null;if(u){const e=u.point[a];if(c?e<=n[h+r]:e>=n[h+r+3])return u}const I=je(h,n,s,At)?Ot(h,t,i,s):null;return u&&I?u.distance<=I.distance?u:I:u||I||null}}const Nt=new u,yt=new ue,Lt=new ue,_t=new h,Pt=new Ie,wt=new Ie;function Mt(e,t,i,s){Ae.setBuffer(e._roots[t]);const n=vt(0,e,i,s);return Ae.clearBuffer(),n}function vt(e,t,i,s,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=Ae;let c=2*e;null===n&&(i.boundingBox||i.computeBoundingBox(),Pt.set(i.boundingBox.min,i.boundingBox.max,s),n=Pt);if(!pe(c,o)){const o=e+8,c=a[e+6];H(o,r,Nt);if(n.intersectsBox(Nt)&&vt(o,t,i,s,n))return!0;H(c,r,Nt);return!!(n.intersectsBox(Nt)&&vt(c,t,i,s,n))}{const n=t.geometry,l=n.index,h=n.attributes.position,u=i.index,I=i.attributes.position,d=Ce(e,a),E=Te(c,o);if(_t.copy(s).invert(),i.boundsTree){H(e,r,wt),wt.matrix.copy(_t),wt.needsUpdate=!0;return i.boundsTree.shapecast({intersectsBounds:e=>wt.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(s),e.b.applyMatrix4(s),e.c.applyMatrix4(s),e.needsUpdate=!0;for(let i=d,s=E+d;i<s;i++)if(ke(Lt,3*t.resolveTriangleIndex(i),l,h),Lt.needsUpdate=!0,e.intersectsTriangle(Lt))return!0;return!1}})}for(let e=d,i=E+d;e<i;e++){const i=t.resolveTriangleIndex(e);ke(yt,3*i,l,h),yt.a.applyMatrix4(_t),yt.b.applyMatrix4(_t),yt.c.applyMatrix4(_t),yt.needsUpdate=!0;for(let e=0,t=u.count;e<t;e+=3)if(ke(Lt,e,u,I),Lt.needsUpdate=!0,yt.intersectsTriangle(Lt))return!0}}}const Dt=new h,bt=new Ie,Ut=new Ie,xt=new n,Bt=new n,Vt=new n,Yt=new n;function Gt(e,t,i,s={},n={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),bt.set(t.boundingBox.min,t.boundingBox.max,i),bt.needsUpdate=!0;const a=e.geometry,c=a.attributes.position,l=a.index,h=t.attributes.position,u=t.index,I=fe.getPrimitive(),d=fe.getPrimitive();let E=xt,f=Bt,p=null,C=null;n&&(p=Vt,C=Yt);let T=1/0,m=null,R=null;return Dt.copy(i).invert(),Ut.matrix.copy(Dt),e.shapecast({boundsTraverseOrder:e=>bt.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o&&(t&&(Ut.min.copy(e.min),Ut.max.copy(e.max),Ut.needsUpdate=!0),!0),intersectsRange:(s,n)=>{if(t.boundsTree){const a=t.boundsTree;return a.shapecast({boundsTraverseOrder:e=>Ut.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o,intersectsRange:(t,o)=>{for(let g=t,A=t+o;g<A;g++){const t=a.resolveTriangleIndex(g);ke(d,3*t,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=s,i=s+n;t<i;t++){const i=e.resolveTriangleIndex(t);ke(I,3*i,l,c),I.needsUpdate=!0;const s=I.distanceToTriangle(d,E,p);if(s<T&&(f.copy(E),C&&C.copy(p),T=s,m=t,R=g),s<r)return!0}}}})}for(let o=0,a=Y(t);o<a;o++){ke(d,3*o,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=s,i=s+n;t<i;t++){const i=e.resolveTriangleIndex(t);ke(I,3*i,l,c),I.needsUpdate=!0;const s=I.distanceToTriangle(d,E,p);if(s<T&&(f.copy(E),C&&C.copy(p),T=s,m=t,R=o),s<r)return!0}}}}),fe.releasePrimitive(I),fe.releasePrimitive(d),T===1/0?null:(s.point?s.point.copy(f):s.point=f.clone(),s.distance=T,s.faceIndex=m,n&&(n.point?n.point.copy(C):n.point=C.clone(),n.point.applyMatrix4(Dt),f.applyMatrix4(Dt),n.distance=f.sub(n.point).length(),n.faceIndex=R),s)}const zt=new Ae.constructor,kt=new Ae.constructor,Ht=new de((()=>new u)),Wt=new u,Xt=new u,jt=new u,Zt=new u;let $t=!1;function qt(e,t,i,s,n,r=0,o=0,a=0,c=0,l=null,h=!1){let u,I;h?(u=kt,I=zt):(u=zt,I=kt);const d=u.float32Array,E=u.uint32Array,f=u.uint16Array,p=I.float32Array,C=I.uint32Array,T=I.uint16Array,m=2*t,R=pe(2*e,f),g=pe(m,T);let A=!1;if(g&&R)A=h?n(Ce(t,C),Te(2*t,T),Ce(e,E),Te(2*e,f),c,o+t,a,r+e):n(Ce(e,E),Te(2*e,f),Ce(t,C),Te(2*t,T),a,r+e,c,o+t);else if(g){const l=Ht.getPrimitive();H(t,p,l),l.applyMatrix4(i);const u=me(e),I=Re(e,E);H(u,d,Wt),H(I,d,Xt);const f=l.intersectsBox(Wt),C=l.intersectsBox(Xt);A=f&&qt(t,u,s,i,n,o,r,c,a+1,l,!h)||C&&qt(t,I,s,i,n,o,r,c,a+1,l,!h),Ht.releasePrimitive(l)}else{const u=me(t),I=Re(t,C);H(u,p,jt),H(I,p,Zt);const f=l.intersectsBox(jt),T=l.intersectsBox(Zt);if(f&&T)A=qt(e,u,i,s,n,r,o,a,c+1,l,h)||qt(e,I,i,s,n,r,o,a,c+1,l,h);else if(f)if(R)A=qt(e,u,i,s,n,r,o,a,c+1,l,h);else{const t=Ht.getPrimitive();t.copy(jt).applyMatrix4(i);const l=me(e),I=Re(e,E);H(l,d,Wt),H(I,d,Xt);const f=t.intersectsBox(Wt),p=t.intersectsBox(Xt);A=f&&qt(u,l,s,i,n,o,r,c,a+1,t,!h)||p&&qt(u,I,s,i,n,o,r,c,a+1,t,!h),Ht.releasePrimitive(t)}else if(T)if(R)A=qt(e,I,i,s,n,r,o,a,c+1,l,h);else{const t=Ht.getPrimitive();t.copy(Zt).applyMatrix4(i);const l=me(e),u=Re(e,E);H(l,d,Wt),H(u,d,Xt);const f=t.intersectsBox(Wt),p=t.intersectsBox(Xt);A=f&&qt(I,l,s,i,n,o,r,c,a+1,t,!h)||p&&qt(I,u,s,i,n,o,r,c,a+1,t,!h),Ht.releasePrimitive(t)}}return A}const Qt=new Ie,Kt=new u;class Jt{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,n=e._indirectBuffer,r=i.getIndex();let o;return o=t.cloneBuffers?{roots:s.map((e=>e.slice())),index:r.array.slice(),indirectBuffer:n?n.slice():null}:{roots:s,index:r.array,indirectBuffer:n},o}static deserialize(e,t,i={}){i={setIndex:!0,indirect:Boolean(e.indirectBuffer),...i};const{index:n,roots:r,indirectBuffer:o}=e,a=new Jt(t,{...i,[V]:!0});if(a._roots=r,a._indirectBuffer=o||null,i.setIndex){const i=t.getIndex();if(null===i){const i=new s(e.index,1,!1);t.setIndex(i)}else i.array!==n&&(i.array.set(n),i.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[V]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[V]||(re(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new u)));const{_indirectBuffer:i}=this;this.resolveTriangleIndex=t.indirect?e=>i[e]:e=>e}refit(e=null){return(this.indirect?Tt:We)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),n=new Uint16Array(i);!function t(r,o=0){const a=2*r,c=n[a+15]===x;if(c){const t=s[r+6],l=n[a+14];e(o,c,new Float32Array(i,4*r,6),t,l)}else{const n=r+8,a=s[r+6],l=s[r+7];e(o,c,new Float32Array(i,4*r,6),l)||(t(n,o+1),t(a,o+1))}}(0)}raycast(e,t=E){const i=this._roots,s=this.geometry,n=[],r=t.isMaterial,o=Array.isArray(t),a=s.groups,c=r?t.side:t,l=this.indirect?Rt:qe;for(let s=0,r=i.length;s<r;s++){const i=o?t[a[s].materialIndex].side:c,r=n.length;if(l(this,s,i,e,n),o){const e=a[s].materialIndex;for(let t=r,i=n.length;t<i;t++)n[t].face.materialIndex=e}}return n}raycastFirst(e,t=E){const i=this._roots,s=this.geometry,n=t.isMaterial,r=Array.isArray(t);let o=null;const a=s.groups,c=n?t.side:t,l=this.indirect?St:et;for(let s=0,n=i.length;s<n;s++){const i=l(this,s,r?t[a[s].materialIndex].side:c,e);null!=i&&(null==o||i.distance<o.distance)&&(o=i,r&&(i.face.materialIndex=a[s].materialIndex))}return o}intersectsGeometry(e,t){let i=!1;const s=this._roots,n=this.indirect?Mt:ct;for(let r=0,o=s.length;r<o&&(i=n(this,r,e,t),!i);r++);return i}shapecast(e){const t=fe.getPrimitive(),i=this.indirect?Ze:He;let{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:r,intersectsTriangle:o}=e;if(r&&o){const e=r;r=(s,n,r,a,c)=>!!e(s,n,r,a,c)||i(s,n,this,o,r,a,t)}else r||(r=o?(e,s,n,r)=>i(e,s,this,o,n,r,t):(e,t,i)=>i);let a=!1,c=0;const l=this._roots;for(let e=0,t=l.length;e<t;e++){const t=l[e];if(a=ye(this,e,n,r,s,c),a)break;c+=t.byteLength}return fe.releasePrimitive(t),a}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const r=fe.getPrimitive(),o=this.geometry.index,a=this.geometry.attributes.position,c=this.indirect?e=>{const t=this.resolveTriangleIndex(e);ke(r,3*t,o,a)}:e=>{ke(r,3*e,o,a)},l=fe.getPrimitive(),u=e.geometry.index,I=e.geometry.attributes.position,d=e.indirect?t=>{const i=e.resolveTriangleIndex(t);ke(l,3*i,u,I)}:e=>{ke(l,3*e,u,I)};if(n){const e=(e,i,s,o,a,h,u,I)=>{for(let E=s,f=s+o;E<f;E++){d(E),l.a.applyMatrix4(t),l.b.applyMatrix4(t),l.c.applyMatrix4(t),l.needsUpdate=!0;for(let t=e,s=e+i;t<s;t++)if(c(t),r.needsUpdate=!0,n(r,l,t,E,a,h,u,I))return!0}return!1};if(s){const t=s;s=function(i,s,n,r,o,a,c,l){return!!t(i,s,n,r,o,a,c,l)||e(i,s,n,r,o,a,c,l)}}else s=e}return function(e,t,i,s){if($t)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");$t=!0;const n=e._roots,r=t._roots;let o,a=0,c=0;const l=(new h).copy(i).invert();for(let e=0,t=n.length;e<t;e++){zt.setBuffer(n[e]),c=0;const t=Ht.getPrimitive();H(0,zt.float32Array,t),t.applyMatrix4(l);for(let n=0,h=r.length;n<h&&(kt.setBuffer(r[e]),o=qt(0,0,i,l,s,a,c,0,0,t),kt.clearBuffer(),c+=r[n].length,!o);n++);if(Ht.releasePrimitive(t),zt.clearBuffer(),a+=n[e].length,o)break}return $t=!1,o}(this,e,t,s)}intersectsBox(e,t){return Qt.set(e.min,e.max,t),Qt.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Qt.intersectsBox(e),intersectsTriangle:e=>Qt.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},n=0,r=1/0){return(this.indirect?Gt:Ct)(this,e,t,i,s,n,r)}closestPointToPoint(e,t={},i=0,s=1/0){return function(e,t,i={},s=0,n=1/0){const r=s*s,o=n*n;let a=1/0,c=null;if(e.shapecast({boundsTraverseOrder:e=>(_e.copy(t).clamp(e.min,e.max),_e.distanceToSquared(t)),intersectsBounds:(e,t,i)=>i<a&&i<o,intersectsTriangle:(e,i)=>{e.closestPointToPoint(t,_e);const s=t.distanceToSquared(_e);return s<a&&(Pe.copy(_e),a=s,c=i),s<r}}),a===1/0)return null;const l=Math.sqrt(a);return i.point?i.point.copy(Pe):i.point=Pe.clone(),i.distance=l,i.faceIndex=c,i}(this,e,t,i,s)}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{H(0,new Float32Array(t),Kt),e.union(Kt)})),e}}function ei(e,t,i){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far?null:e)}const ti=new f,ii=new h,si=p.prototype.raycast;function ni(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;ii.copy(this.matrixWorld).invert(),ti.copy(e.ray).applyMatrix4(ii);const i=this.geometry.boundsTree;if(!0===e.firstHitOnly){const s=ei(i.raycastFirst(ti,this.material),this,e);s&&t.push(s)}else{const s=i.raycast(ti,this.material);for(let i=0,n=s.length;i<n;i++){const n=ei(s[i],this,e);n&&t.push(n)}}}else si.call(this,e,t)}function ri(e){return this.boundsTree=new Jt(this,e),this.boundsTree}function oi(){this.boundsTree=null}class ai{constructor(){t(this,"enabled",!0),t(this,"trigger",(e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)i(e)})),t(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter((t=>t!==e))}reset(){this.handlers.length=0}}class ci{constructor(){t(this,"enabled",!0),t(this,"trigger",(async e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)await i(e)})),t(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter((t=>t!==e))}reset(){this.handlers.length=0}}class li{constructor(e){t(this,"isDisposeable",(()=>"dispose"in this&&"onDisposed"in this)),t(this,"isResizeable",(()=>"resize"in this&&"getSize"in this)),t(this,"isUpdateable",(()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this)),t(this,"isHideable",(()=>"visible"in this)),t(this,"isConfigurable",(()=>"setup"in this&&"config"in this&&"onSetup"in this)),this.components=e}}class hi extends li{}class ui extends li{constructor(e){super(e),t(this,"worlds",new Map),t(this,"onWorldChanged",new ai),t(this,"currentWorld",null),this.onWorldChanged.add((({world:e,action:t})=>{"removed"===t&&this.worlds.delete(e.uuid)}))}}class Ii extends ui{constructor(){super(...arguments),t(this,"hasCameraControls",(()=>"controls"in this))}}class di extends ui{constructor(){super(...arguments),t(this,"onAfterUpdate",new ai),t(this,"onBeforeUpdate",new ai),t(this,"onDisposed",new ai),t(this,"onResize",new ai),t(this,"onClippingPlanesUpdated",new ai),t(this,"clippingPlanes",[])}updateClippingPlanes(){this.onClippingPlanesUpdated.trigger()}setPlane(e,t,i){t.isLocal=i;const s=this.clippingPlanes.indexOf(t);e&&-1===s?this.clippingPlanes.push(t):!e&&s>-1&&this.clippingPlanes.splice(s,1),this.three.clippingPlanes=this.clippingPlanes.filter((e=>!e.isLocal))}}const Ei=class e extends hi{constructor(i){super(i),t(this,"_disposedComponents",new Set),t(this,"enabled",!0),i.add(e.uuid,this)}get(){return this._disposedComponents}destroy(e,t=!0,i=!0){e.removeFromParent();const s=e;s.dispose&&s.dispose(),this.disposeGeometryAndMaterials(e,t),i&&s.children&&s.children.length&&this.disposeChildren(s),e.children.length=0}disposeGeometry(e){e.boundsTree&&e.disposeBoundsTree&&e.disposeBoundsTree(),e.dispose()}disposeGeometryAndMaterials(t,i){const s=t;s.geometry&&this.disposeGeometry(s.geometry),i&&s.material&&e.disposeMaterial(s),s.material=[],s.geometry=null}disposeChildren(e){for(const t of e.children)this.destroy(t)}static disposeMaterial(e){if(e.material)if(Array.isArray(e.material))for(const t of e.material)t.dispose();else e.material.dispose()}};t(Ei,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let fi=Ei;class pi extends ui{constructor(e){super(e),t(this,"onDisposed",new ai),t(this,"directionalLights",new Map),t(this,"ambientLights",new Map)}dispose(){const e=this.components.get(fi);for(const t of this.three.children){const i=t;i.geometry&&e.destroy(i)}this.deleteAllLights(),this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}deleteAllLights(){for(const[,e]of this.directionalLights)e.removeFromParent(),e.target.removeFromParent(),e.dispose();this.directionalLights.clear();for(const[,e]of this.ambientLights)e.removeFromParent(),e.dispose();this.ambientLights.clear()}}class Ci extends Set{constructor(e){super(e),t(this,"onItemAdded",new ai),t(this,"onItemDeleted",new ai),t(this,"onCleared",new ai),t(this,"guard",(()=>!0))}clear(){super.clear(),this.onCleared.trigger()}add(...e){for(const t of e){if(this.has(t))continue;this.guard(t)&&(super.add(t),this.onItemAdded||(this.onItemAdded=new ai),this.onItemAdded.trigger(t))}return this}delete(e){const t=super.delete(e);return t&&this.onItemDeleted.trigger(),t}dispose(){this.clear(),this.onItemAdded.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class Ti extends Map{constructor(e){super(e),t(this,"onItemSet",new ai),t(this,"onItemUpdated",new ai),t(this,"onItemDeleted",new ai),t(this,"onCleared",new ai),t(this,"guard",(()=>!0))}clear(){super.clear(),this.onCleared.trigger()}set(e,t){const i=this.has(e);if(!(this.guard??(()=>!0))(e,t))return this;const s=super.set(e,t);return i?(this.onItemUpdated||(this.onItemUpdated=new ai),this.onItemUpdated.trigger({key:e,value:t})):(this.onItemSet||(this.onItemSet=new ai),this.onItemSet.trigger({key:e,value:t})),s}delete(e){const t=super.delete(e);return t&&this.onItemDeleted.trigger(e),t}dispose(){this.clear(),this.onItemSet.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class mi extends hi{}class Ri{static isEntry(e){return new Set(["Boolean","Color","Text","Number","Select","Vector3","TextSet","None"]).has(e.type)}static copySchema(e,t={}){for(const i in e){const s=e[i];this.isEntry(s)?t[i]=this.copyEntry(s):(t[i]={},this.copySchema(s,t[i]))}return t}static copyEntry(e){if("Boolean"===e.type){const t=e;return{type:t.type,value:t.value}}if("Color"===e.type){const t=e;return{type:t.type,value:t.value.clone()}}if("Text"===e.type){const t=e;return{type:t.type,value:t.value}}if("Number"===e.type){const t=e;return{type:t.type,value:t.value,min:t.min,max:t.max,interpolable:t.interpolable}}if("Select"===e.type){const t=e;return{type:t.type,value:t.value,multiple:t.multiple,options:new Set(t.options)}}if("Vector3"===e.type){const t=e;return{type:t.type,value:t.value.clone()}}if("TextSet"===e.type){const t=e;return{type:t.type,value:new Set(t.value)}}if("None"===e.type){const t=e;return{type:t.type,value:t.value}}throw new Error("Invalid entry!")}}class gi{constructor(){t(this,"list",new Set)}add(e){for(const t of e)this.list.add(t)}remove(e){for(const t of e)this.list.delete(t)}set(e){for(const t of this.list)t.enabled=e}reset(){for(const e of this.list)e.reset()}}const Ai=new n,Fi=new o,Si=new r,Oi=new n,Ni=new c;class yi{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new wi,this.unassigned=new wi,this.vertices=[]}setFromPoints(e){if(e.length>=4){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.vertices.push(new Pi(e[t]));this.compute()}return this}setFromObject(e){const t=[];return e.updateMatrixWorld(!0),e.traverse((function(e){const i=e.geometry;if(void 0!==i){const s=i.attributes.position;if(void 0!==s)for(let i=0,r=s.count;i<r;i++){const r=new n;r.fromBufferAttribute(s,i).applyMatrix4(e.matrixWorld),t.push(r)}}})),this.setFromPoints(t)}containsPoint(e){const t=this.faces;for(let i=0,s=t.length;i<s;i++){if(t[i].distanceToPoint(e)>this.tolerance)return!1}return!0}intersectRay(e,t){const i=this.faces;let s=-1/0,n=1/0;for(let t=0,r=i.length;t<r;t++){const r=i[t],o=r.distanceToPoint(e.origin),a=r.normal.dot(e.direction);if(o>0&&a>=0)return null;const c=0!==a?-o/a:0;if(!(c<=0)&&(a>0?n=Math.min(c,n):s=Math.max(c,s),s>n))return null}return s!==-1/0?e.at(s,t):e.at(n,t),t}intersectsRay(e){return null!==this.intersectRay(e,Ai)}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(e,t){return e.face=t,null===t.outside?this.assigned.append(e):this.assigned.insertBefore(t.outside,e),t.outside=e,this}removeVertexFromFace(e,t){return e===t.outside&&(null!==e.next&&e.next.face===t?t.outside=e.next:t.outside=null),this.assigned.remove(e),this}removeAllVerticesFromFace(e){if(null!==e.outside){const t=e.outside;let i=e.outside;for(;null!==i.next&&i.next.face===e;)i=i.next;return this.assigned.removeSubList(t,i),t.prev=i.next=null,e.outside=null,t}}deleteFaceVertices(e,t){const i=this.removeAllVerticesFromFace(e);if(void 0!==i)if(void 0===t)this.unassigned.appendChain(i);else{let e=i;do{const i=e.next;t.distanceToPoint(e.point)>this.tolerance?this.addVertexToFace(e,t):this.unassigned.append(e),e=i}while(null!==e)}return this}resolveUnassignedPoints(e){if(!1===this.unassigned.isEmpty()){let t=this.unassigned.first();do{const i=t.next;let s=this.tolerance,n=null;for(let i=0;i<e.length;i++){const r=e[i];if(0===r.mark){const e=r.distanceToPoint(t.point);if(e>s&&(s=e,n=r),s>1e3*this.tolerance)break}}null!==n&&this.addVertexToFace(t,n),t=i}while(null!==t)}return this}computeExtremes(){const e=new n,t=new n,i=[],s=[];for(let e=0;e<3;e++)i[e]=s[e]=this.vertices[0];e.copy(this.vertices[0].point),t.copy(this.vertices[0].point);for(let n=0,r=this.vertices.length;n<r;n++){const r=this.vertices[n],o=r.point;for(let t=0;t<3;t++)o.getComponent(t)<e.getComponent(t)&&(e.setComponent(t,o.getComponent(t)),i[t]=r);for(let e=0;e<3;e++)o.getComponent(e)>t.getComponent(e)&&(t.setComponent(e,o.getComponent(e)),s[e]=r)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(e.x),Math.abs(t.x))+Math.max(Math.abs(e.y),Math.abs(t.y))+Math.max(Math.abs(e.z),Math.abs(t.z))),{min:i,max:s}}computeInitialHull(){const e=this.vertices,t=this.computeExtremes(),i=t.min,s=t.max;let n=0,r=0;for(let e=0;e<3;e++){const t=s[e].point.getComponent(e)-i[e].point.getComponent(e);t>n&&(n=t,r=e)}const o=i[r],a=s[r];let c,l;n=0,Fi.set(o.point,a.point);for(let t=0,i=this.vertices.length;t<i;t++){const i=e[t];if(i!==o&&i!==a){Fi.closestPointToPoint(i.point,!0,Oi);const e=Oi.distanceToSquared(i.point);e>n&&(n=e,c=i)}}n=-1,Si.setFromCoplanarPoints(o.point,a.point,c.point);for(let t=0,i=this.vertices.length;t<i;t++){const i=e[t];if(i!==o&&i!==a&&i!==c){const e=Math.abs(Si.distanceToPoint(i.point));e>n&&(n=e,l=i)}}const h=[];if(Si.distanceToPoint(l.point)<0){h.push(Li.create(o,a,c),Li.create(l,a,o),Li.create(l,c,a),Li.create(l,o,c));for(let e=0;e<3;e++){const t=(e+1)%3;h[e+1].getEdge(2).setTwin(h[0].getEdge(t)),h[e+1].getEdge(1).setTwin(h[t+1].getEdge(0))}}else{h.push(Li.create(o,c,a),Li.create(l,o,a),Li.create(l,a,c),Li.create(l,c,o));for(let e=0;e<3;e++){const t=(e+1)%3;h[e+1].getEdge(2).setTwin(h[0].getEdge((3-e)%3)),h[e+1].getEdge(0).setTwin(h[t+1].getEdge(1))}}for(let e=0;e<4;e++)this.faces.push(h[e]);for(let t=0,i=e.length;t<i;t++){const i=e[t];if(i!==o&&i!==a&&i!==c&&i!==l){n=this.tolerance;let e=null;for(let t=0;t<4;t++){const s=this.faces[t].distanceToPoint(i.point);s>n&&(n=s,e=this.faces[t])}null!==e&&this.addVertexToFace(i,e)}}return this}reindexFaces(){const e=[];for(let t=0;t<this.faces.length;t++){const i=this.faces[t];0===i.mark&&e.push(i)}return this.faces=e,this}nextVertexToAdd(){if(!1===this.assigned.isEmpty()){let e,t=0;const i=this.assigned.first().face;let s=i.outside;do{const n=i.distanceToPoint(s.point);n>t&&(t=n,e=s),s=s.next}while(null!==s&&s.face===i);return e}}computeHorizon(e,t,i,s){let n;this.deleteFaceVertices(i),i.mark=1,n=null===t?t=i.getEdge(0):t.next;do{const t=n.twin,i=t.face;0===i.mark&&(i.distanceToPoint(e)>this.tolerance?this.computeHorizon(e,t,i,s):s.push(n)),n=n.next}while(n!==t);return this}addAdjoiningFace(e,t){const i=Li.create(e,t.tail(),t.head());return this.faces.push(i),i.getEdge(-1).setTwin(t.twin),i.getEdge(0)}addNewFaces(e,t){this.newFaces=[];let i=null,s=null;for(let n=0;n<t.length;n++){const r=t[n],o=this.addAdjoiningFace(e,r);null===i?i=o:o.next.setTwin(s),this.newFaces.push(o.face),s=o}return i.next.setTwin(s),this}addVertexToHull(e){const t=[];return this.unassigned.clear(),this.removeVertexFromFace(e,e.face),this.computeHorizon(e.point,null,e.face,t),this.addNewFaces(e,t),this.resolveUnassignedPoints(this.newFaces),this}cleanup(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this}compute(){let e;for(this.computeInitialHull();void 0!==(e=this.nextVertexToAdd());)this.addVertexToHull(e);return this.reindexFaces(),this.cleanup(),this}}class Li{constructor(){this.normal=new n,this.midpoint=new n,this.area=0,this.constant=0,this.outside=null,this.mark=0,this.edge=null}static create(e,t,i){const s=new Li,n=new _i(e,s),r=new _i(t,s),o=new _i(i,s);return n.next=o.prev=r,r.next=n.prev=o,o.next=r.prev=n,s.edge=n,s.compute()}getEdge(e){let t=this.edge;for(;e>0;)t=t.next,e--;for(;e<0;)t=t.prev,e++;return t}compute(){const e=this.edge.tail(),t=this.edge.head(),i=this.edge.next.head();return Ni.set(e.point,t.point,i.point),Ni.getNormal(this.normal),Ni.getMidpoint(this.midpoint),this.area=Ni.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(e){return this.normal.dot(e)-this.constant}}class _i{constructor(e,t){this.vertex=e,this.prev=null,this.next=null,this.twin=null,this.face=t}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){const e=this.head(),t=this.tail();return null!==t?t.point.distanceTo(e.point):-1}lengthSquared(){const e=this.head(),t=this.tail();return null!==t?t.point.distanceToSquared(e.point):-1}setTwin(e){return this.twin=e,e.twin=this,this}}class Pi{constructor(e){this.point=e,this.prev=null,this.next=null,this.face=null}}class wi{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(e,t){return t.prev=e.prev,t.next=e,null===t.prev?this.head=t:t.prev.next=t,e.prev=t,this}insertAfter(e,t){return t.prev=e,t.next=e.next,null===t.next?this.tail=t:t.next.prev=t,e.next=t,this}append(e){return null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e,this}appendChain(e){for(null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail;null!==e.next;)e=e.next;return this.tail=e,this}remove(e){return null===e.prev?this.head=e.next:e.prev.next=e.next,null===e.next?this.tail=e.prev:e.next.prev=e.prev,this}removeSubList(e,t){return null===e.prev?this.head=t.next:e.prev.next=t.next,null===t.next?this.tail=e.prev:t.next.prev=e.prev,this}isEmpty(){return null===this.head}}const Mi=[2,2,1],vi=[1,0,0];function Di(e,t){return 3*e+t}function bi(e){const t=e.elements;let i=0;for(let e=0;e<3;e++){const s=t[Di(Mi[e],vi[e])];i+=2*s*s}return Math.sqrt(i)}function Ui(e,t){let i=0,s=1;const n=e.elements;for(let e=0;e<3;e++){const t=Math.abs(n[Di(Mi[e],vi[e])]);t>i&&(i=t,s=e)}let r=1,o=0;const a=vi[s],c=Mi[s];if(Math.abs(n[Di(c,a)])>Number.EPSILON){const e=(n[Di(c,c)]-n[Di(a,a)])/2/n[Di(c,a)];let t;t=e<0?-1/(-e+Math.sqrt(1+e*e)):1/(e+Math.sqrt(1+e*e)),r=1/Math.sqrt(1+t*t),o=t*r}return t.identity(),t.elements[Di(a,a)]=r,t.elements[Di(c,c)]=r,t.elements[Di(c,a)]=o,t.elements[Di(a,c)]=-o,t}function xi(e,t){let s=0,n=0;t.unitary.identity(),t.diagonal.copy(e);const r=t.unitary,o=t.diagonal,a=new i.Matrix3,c=new i.Matrix3,l=Number.EPSILON*function(e){const t=e.elements;let i=0;for(let e=0;e<9;e++)i+=t[e]*t[e];return Math.sqrt(i)}(o);for(;n<10&&bi(o)>l;)Ui(o,a),c.copy(a).transpose(),o.multiply(a),o.premultiply(c),r.multiply(a),++s>2&&(n++,s=0);return t}function Bi(e){const t=[];for(let s=0;s<e.length-2;s+=3){const n=e[s],r=e[s+1],o=e[s+2];t.push(new i.Vector3(n,r,o))}const s=new yi;s.setFromPoints(t);const n={unitary:new i.Matrix3,diagonal:new i.Matrix3},r=s.faces,o=[],a=[];for(let e=0,t=r.length;e<t;e++){const t=r[e];let i=t.edge;o.length=0;do{o.push(i),i=i.next}while(i!==t.edge);for(let e=1,t=o.length-2;e<=t;e++){const t=o[0].vertex,i=o[e+0].vertex,s=o[e+1].vertex;a.push(t.point.x,t.point.y,t.point.z),a.push(i.point.x,i.point.y,i.point.z),a.push(s.point.x,s.point.y,s.point.z)}}const c=new i.Vector3,l=new i.Vector3,h=new i.Vector3,u=new i.Vector3,I=new i.Vector3,d=new i.Vector3,E=new i.Vector3,f=new i.Vector3;let p=0,C=0,T=0,m=0,R=0,g=0,A=0;for(let e=0,t=a.length;e<t;e+=9){c.fromArray(a,e),l.fromArray(a,e+3),h.fromArray(a,e+6),E.set(0,0,0),E.add(c).add(l).add(h).divideScalar(3),u.subVectors(l,c),I.subVectors(h,c);const t=d.crossVectors(u,I).length()/2;f.add(d.copy(E).multiplyScalar(t)),p+=t,C+=(9*E.x*E.x+c.x*c.x+l.x*l.x+h.x*h.x)*(t/12),T+=(9*E.x*E.y+c.x*c.y+l.x*l.y+h.x*h.y)*(t/12),m+=(9*E.x*E.z+c.x*c.z+l.x*l.z+h.x*h.z)*(t/12),R+=(9*E.y*E.y+c.y*c.y+l.y*l.y+h.y*h.y)*(t/12),g+=(9*E.y*E.z+c.y*c.z+l.y*l.z+h.y*h.z)*(t/12),A+=(9*E.z*E.z+c.z*c.z+l.z*l.z+h.z*h.z)*(t/12)}f.divideScalar(p),C/=p,T/=p,m/=p,R/=p,g/=p,A/=p,C-=f.x*f.x,T-=f.x*f.y,m-=f.x*f.z,R-=f.y*f.y,g-=f.y*f.z,A-=f.z*f.z;const F=new i.Matrix3;F.elements[0]=C,F.elements[1]=T,F.elements[2]=m,F.elements[3]=T,F.elements[4]=R,F.elements[5]=g,F.elements[6]=m,F.elements[7]=g,F.elements[8]=A,xi(F,n);const S=n.unitary,O=new i.Vector3,N=new i.Vector3,y=new i.Vector3;S.extractBasis(O,N,y);let L=-1/0,_=-1/0,P=-1/0,w=1/0,M=1/0,v=1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e];L=Math.max(O.dot(i),L),_=Math.max(N.dot(i),_),P=Math.max(y.dot(i),P),w=Math.min(O.dot(i),w),M=Math.min(N.dot(i),M),v=Math.min(y.dot(i),v)}O.multiplyScalar(.5*(w+L)),N.multiplyScalar(.5*(M+_)),y.multiplyScalar(.5*(v+P));const D=new i.Vector3,b=new i.Vector3,U=new i.Matrix3;D.add(O).add(N).add(y),b.x=L-w,b.y=_-M,b.z=P-v,b.multiplyScalar(.5),U.copy(S);const{x:x,y:B,z:V}=b,Y=new i.Matrix4;Y.makeScale(2*x,2*B,2*V);const G=new i.Matrix4;G.makeTranslation(-x,-B,-V);const z=new i.Matrix4;z.makeTranslation(D.x,D.y,D.z);const k=new i.Matrix4;k.setFromMatrix3(U);const H=new i.Matrix4;return H.multiply(z),H.multiply(k),H.multiply(G),H.multiply(Y),{center:D,halfSizes:b,rotation:U,transformation:H}}function Vi(e,t,i){const s=[e[0]-t[0],e[1]-t[1],e[2]-t[2]];return i[0]*s[0]+i[1]*s[1]+i[2]*s[2]>0}class Yi{static isTransparent(e){return e.transparent&&e.opacity<1}}const Gi=class e{static create(){const t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return`${e._lut[255&t]+e._lut[t>>8&255]+e._lut[t>>16&255]+e._lut[t>>24&255]}-${e._lut[255&i]}${e._lut[i>>8&255]}-${e._lut[i>>16&15|64]}${e._lut[i>>24&255]}-${e._lut[63&s|128]}${e._lut[s>>8&255]}-${e._lut[s>>16&255]}${e._lut[s>>24&255]}${e._lut[255&n]}${e._lut[n>>8&255]}${e._lut[n>>16&255]}${e._lut[n>>24&255]}`.toLowerCase()}static validate(t){if(!e._pattern.test(t))throw new Error(`${t} is not a valid UUID v4.\n\n- If you're the tool creator, you can take one from https://www.uuidgenerator.net/.\n\n- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};t(Gi,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/),t(Gi,"_lut",["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"]);let zi=Gi;class ki extends hi{constructor(e,i){super(e),t(this,"onDisposed",new ai),t(this,"onVertexFound",new ai),t(this,"onVertexLost",new ai),t(this,"onEnabled",new ai),t(this,"components"),t(this,"workingPlane",null),t(this,"_pickedPoint",null),t(this,"_config"),t(this,"_enabled",!1),this.components=e,this.config={snapDistance:.25,showOnlyVertex:!1,...i},this.enabled=!1}set enabled(e){this._enabled=e,e||(this._pickedPoint=null),this.onEnabled.trigger(e)}get enabled(){return this._enabled}set config(e){this._config={...this._config,...e}}get config(){return this._config}dispose(){this.onVertexFound.reset(),this.onVertexLost.reset(),this.components=null,this.onDisposed.trigger(),this.onDisposed.reset()}get(e){if(!this.enabled)return this._pickedPoint;const t=this.components.get(En).get(e).castRay();if(!t)return null!==this._pickedPoint&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;const i=this.getClosestVertex(t);if(!i)return null!==this._pickedPoint&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;return!this.workingPlane||Math.abs(this.workingPlane.distanceToPoint(i))<.001?(null!==this._pickedPoint&&this._pickedPoint.equals(i)||(this._pickedPoint=i.clone(),this.onVertexFound.trigger(this._pickedPoint)),this._pickedPoint):(this._pickedPoint=null,this._pickedPoint)}getClosestVertex(e){let t=new i.Vector3,s=!1,n=Number.MAX_SAFE_INTEGER;const r=this.getVertices(e);if(null===r)return null;for(const i of r){if(!i)continue;const r=e.point.distanceTo(i);r>n||r>this._config.snapDistance||(s=!0,t=i,n=e.point.distanceTo(i))}return s?t:this.config.showOnlyVertex?null:e.point}getVertices(e){const t=e.object;if(!e.face||!t)return null;const s=t.geometry,n=new i.Matrix4,{instanceId:r}=e,o=void 0!==r,a=t instanceof i.InstancedMesh;return a&&o&&t.getMatrixAt(r,n),[this.getVertex(e.face.a,s),this.getVertex(e.face.b,s),this.getVertex(e.face.c,s)].map((e=>(e&&(a&&o&&e.applyMatrix4(n),e.applyMatrix4(t.matrixWorld)),e)))}getVertex(e,t){if(void 0===e)return null;const s=t.attributes.position;return new i.Vector3(s.getX(e),s.getY(e),s.getZ(e))}}const Hi=class e{constructor(){t(this,"onDisposed",new ai),t(this,"list",new Map),t(this,"enabled",!1),t(this,"_clock"),t(this,"onInit",new ai),t(this,"update",(()=>{if(!this.enabled)return;const e=this._clock.getDelta();for(const[t,i]of this.list)i.enabled&&i.isUpdateable()&&i.update(e);requestAnimationFrame(this.update)})),this._clock=new i.Clock,e.setupBVH()}add(e,t){if(this.list.has(e))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");zi.validate(e),this.list.set(e,t)}get(e){const t=e.uuid;if(!this.list.has(t)){const i=new e(this);return this.list.has(t)||this.add(t,i),i}return this.list.get(t)}init(){this.enabled=!0,this._clock.start(),this.update(),this.onInit.trigger()}dispose(){this.enabled=!1;for(const[e,t]of this.list)t.enabled=!1,t.isDisposeable()&&t.dispose();this._clock.stop(),this.onDisposed.trigger(),this.onDisposed.reset()}static setupBVH(){i.BufferGeometry.prototype.computeBoundsTree=ri,i.BufferGeometry.prototype.disposeBoundsTree=oi,i.Mesh.prototype.raycast=ni}};t(Hi,"release","2.4.0");let Wi=Hi;class Xi extends li{constructor(){super(...arguments),t(this,"meshes",new Set),t(this,"onAfterUpdate",new ai),t(this,"onBeforeUpdate",new ai),t(this,"onDisposed",new ai),t(this,"isDisposing",!1),t(this,"enabled",!0),t(this,"uuid",zi.create()),t(this,"name"),t(this,"_scene"),t(this,"_camera"),t(this,"_renderer",null)}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(e){this._scene=e,e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(e){this._camera=e,e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"})}get renderer(){return this._renderer}set renderer(e){this._renderer=e,e&&(e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"}))}update(e){this.enabled&&this._scene&&this._camera&&(this.scene.currentWorld=this,this.camera.currentWorld=this,this.renderer&&(this.renderer.currentWorld=this),this.onBeforeUpdate.trigger(),this.scene.isUpdateable()&&this.scene.update(e),this.camera.isUpdateable()&&this.camera.update(e),this.renderer&&this.renderer.update(e),this.onAfterUpdate.trigger())}dispose(e=!0){if(this.enabled=!1,this.isDisposing=!0,this.scene.onWorldChanged.trigger({world:this,action:"removed"}),this.camera.onWorldChanged.trigger({world:this,action:"removed"}),this.renderer&&this.renderer.onWorldChanged.trigger({world:this,action:"removed"}),e){const e=this.components.get(fi);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const t of this.meshes)e.destroy(t);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null;this.components.get(en).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class ji{constructor(e,i,s,n){t(this,"_component"),t(this,"name"),t(this,"uuid"),this._component=e,this.name=s,this.uuid=n??zi.create();i.get($i).list.set(this.uuid,this)}get controls(){return Ri.copySchema(this._config)}set(e){for(const t in e)if(t in this){this[t]=e[t].value}}export(e=this._config,t={}){for(const i in e){const s=e[i];if(Ri.isEntry(s))if("Color"===s.type){const{r:e,g:n,b:r}=s.value;t[i]={...s,value:{r:e,g:n,b:r}}}else if("Vector3"===s.type){const{x:e,y:n,z:r}=s.value;t[i]={...s,value:{x:e,y:n,z:r}}}else if("TextSet"===s.type){const e=Array.from(s.value);t[i]={...s,value:e}}else if("Select"===s.type){const e=Array.from(s.options);t[i]={...s,options:e}}else t[i]={...s};else t[i]={},this.export(s,t[i])}return t}import(e,t={},s=!0){for(const s in e){const n=e[s];if(Ri.isEntry(n))if("Color"===n.type){const{r:e,g:r,b:o}=n.value;t[s]={...n,value:new i.Color(e,r,o)}}else if("Vector3"===n.type){const{x:e,y:r,z:o}=n.value;t[s]={...n,value:new i.Vector3(e,r,o)}}else"TextSet"===n.type?t[s]={...n,value:new Set(n.value)}:"Select"===n.type?t[s]={...n,options:new Set(n.options)}:t[s]={...n};else t[s]={},this.import(n,t[s],!1)}s&&this.set(t)}}const Zi=class e extends hi{constructor(i){super(i),t(this,"list",new Ti),t(this,"enabled",!0),i.add(e.uuid,this)}};t(Zi,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let $i=Zi;class qi{constructor(e,i){t(this,"_list"),t(this,"_scene"),this._list=e,this._scene=i}get color(){return this._list.directionalLight.color.value}set color(e){this._list.directionalLight.color.value=e;for(const[,t]of this._scene.directionalLights)t.color.copy(e)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(e){this._list.directionalLight.intensity.value=e;for(const[,t]of this._scene.directionalLights)t.intensity=e}get position(){return this._list.directionalLight.position.value.clone()}set position(e){this._list.directionalLight.position.value=e;for(const[,t]of this._scene.directionalLights)t.position.copy(e)}}class Qi{constructor(e,i){t(this,"_list"),t(this,"_scene"),this._list=e,this._scene=i}get color(){return this._list.ambientLight.color.value}set color(e){this._list.ambientLight.color.value=e;for(const[,t]of this._scene.ambientLights)t.color.copy(e)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(e){this._list.ambientLight.intensity.value=e;for(const[,t]of this._scene.ambientLights)t.intensity=e}}class Ki extends ji{constructor(){super(...arguments),t(this,"_config",{backgroundColor:{value:new i.Color,type:"Color"},ambientLight:{color:{type:"Color",value:new i.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new i.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new i.Vector3}}}),t(this,"ambientLight",new Qi(this._config,this._component)),t(this,"directionalLight",new qi(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(e){this._config.backgroundColor.value=e,this._component.three.background=e}}class Ji extends pi{constructor(e){super(e),t(this,"onSetup",new ai),t(this,"isSetup",!1),t(this,"three"),t(this,"config",new Ki(this,this.components,"Scene")),t(this,"_defaultConfig",{backgroundColor:new i.Color(2107698),directionalLight:{color:new i.Color("white"),intensity:1.5,position:new i.Vector3(5,10,3)},ambientLight:{color:new i.Color("white"),intensity:1}}),this.three=new i.Scene,this.three.background=new i.Color(2107698)}setup(e){const t={...this._defaultConfig,...e};this.config.backgroundColor=t.backgroundColor;const s=t.ambientLight;this.config.ambientLight.color=s.color,this.config.ambientLight.intensity=s.intensity;const n=t.directionalLight;this.config.directionalLight.color=n.color,this.config.directionalLight.intensity=n.intensity,this.config.directionalLight.position=n.position,this.deleteAllLights();const{color:r,intensity:o}=this.config.directionalLight,a=new i.DirectionalLight(r,o);a.position.copy(n.position);const{color:c,intensity:l}=this.config.directionalLight,h=new i.AmbientLight(c,l);this.three.add(a,h),this.directionalLights.set(a.uuid,a),this.ambientLights.set(h.uuid,h),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose();this.components.get($i).list.delete(this.config.uuid)}}class es extends di{constructor(e,s,n){super(e),t(this,"enabled",!0),t(this,"container"),t(this,"three"),t(this,"_canvas"),t(this,"_parameters"),t(this,"_resizeObserver",null),t(this,"onContainerUpdated",new ai),t(this,"_resizing",!1),t(this,"resize",(e=>{if(this._resizing)return;this._resizing=!0,this.onContainerUpdated.trigger();const t=e?e.x:this.container.clientWidth,s=e?e.y:this.container.clientHeight;this.three.setSize(t,s),this.onResize.trigger(new i.Vector2(t,s)),this._resizing=!1})),t(this,"resizeEvent",(()=>{this.resize()})),t(this,"onContextLost",(e=>{e.preventDefault(),this.enabled=!1})),t(this,"onContextBack",(()=>{this.three.setRenderTarget(null),this.three.dispose(),this.three=new i.WebGLRenderer({canvas:this._canvas,antialias:!0,alpha:!0,...this._parameters}),this.enabled=!0})),this.container=s,this._parameters=n,this.three=new i.WebGLRenderer({antialias:!0,alpha:!0,...n}),this.three.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.setupRenderer(),this.setupEvents(!0),this.resize(),this._canvas=this.three.domElement;const r=this.three.getContext(),{canvas:o}=r;o.addEventListener("webglcontextlost",this.onContextLost,!1),o.addEventListener("webglcontextrestored",this.onContextBack,!1)}update(){if(!this.enabled||!this.currentWorld)return;this.onBeforeUpdate.trigger(this);const e=this.currentWorld.scene.three,t=this.currentWorld.camera.three;this.three.render(e,t),this.onAfterUpdate.trigger(this)}dispose(){this.enabled=!1,this.setupEvents(!1),this.three.domElement.remove(),this.three.forceContextLoss(),this.three.dispose(),this.onResize.reset(),this.onAfterUpdate.reset(),this.onBeforeUpdate.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}getSize(){return new i.Vector2(this.three.domElement.clientWidth,this.three.domElement.clientHeight)}setupEvents(e){const t=this.three.domElement.parentElement;if(!t)throw new Error("This renderer needs to have an HTML container!");this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),window.removeEventListener("resize",this.resizeEvent),e&&(this._resizeObserver=new ResizeObserver(this.resizeEvent),this._resizeObserver.observe(t),window.addEventListener("resize",this.resizeEvent))}setupRenderer(){this.three.localClippingEnabled=!0,this.container&&this.container.appendChild(this.three.domElement),this.onContainerUpdated.trigger()}}
|
|
1
|
+
var e=Object.defineProperty,t=(t,i,s)=>(((t,i,s)=>{i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s})(t,"symbol"!=typeof i?i+"":i,s),s);import*as i from"three";import{BufferAttribute as s,Vector3 as n,Plane as r,Line3 as o,Vector2 as a,Triangle as c,Sphere as l,Matrix4 as h,Box3 as u,BackSide as I,DoubleSide as d,FrontSide as E,Ray as f,Mesh as p,Object3D as C,MeshBasicMaterial as T,LineBasicMaterial as m,CylinderGeometry as R,BoxGeometry as g,BufferGeometry as A,Float32BufferAttribute as F,OctahedronGeometry as S,Line as O,TorusGeometry as N,SphereGeometry as y,Quaternion as L,Euler as _,PlaneGeometry as P,Raycaster as w}from"three";import*as M from"@thatopen/fragments";import{FragmentsGroup as v,Serializer as D}from"@thatopen/fragments";import*as b from"web-ifc";const U=1.25,x=65535,B=Math.pow(2,-24),V=Symbol("SKIP_GENERATION");function Y(e){return function(e){return e.index?e.index.count:e.attributes.position.count}(e)/3}function G(e,t){if(!e.index){const i=e.attributes.position.count,n=function(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}(i,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new s(n,1));for(let e=0;e<i;e++)n[e]=e}}function z(e){const t=Y(e),i=e.drawRange,s=i.start/3,n=(i.start+i.count)/3,r=Math.max(0,s),o=Math.min(t,n)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function k(e){if(!e.groups||!e.groups.length)return z(e);const t=[],i=new Set,s=e.drawRange,n=s.start/3,r=(s.start+s.count)/3;for(const t of e.groups){const e=t.start/3,s=(t.start+t.count)/3;i.add(Math.max(n,e)),i.add(Math.min(r,s))}const o=Array.from(i.values()).sort(((e,t)=>e-t));for(let e=0;e<o.length-1;e++){const i=o[e],s=o[e+1];t.push({offset:Math.floor(i),count:Math.floor(s-i)})}return t}function H(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function W(e){let t=-1,i=-1/0;for(let s=0;s<3;s++){const n=e[s+3]-e[s];n>i&&(i=n,t=s)}return t}function X(e,t){t.set(e)}function j(e,t,i){let s,n;for(let r=0;r<3;r++){const o=r+3;s=e[r],n=t[r],i[r]=s<n?s:n,s=e[o],n=t[o],i[o]=s>n?s:n}}function Z(e,t,i){for(let s=0;s<3;s++){const n=t[e+2*s],r=t[e+2*s+1],o=n-r,a=n+r;o<i[s]&&(i[s]=o),a>i[s+3]&&(i[s+3]=a)}}function $(e){const t=e[3]-e[0],i=e[4]-e[1],s=e[5]-e[2];return 2*(t*i+i*s+s*t)}function q(e,t,i,s,n=null){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,h=-1/0,u=1/0,I=1/0,d=1/0,E=-1/0,f=-1/0,p=-1/0;const C=null!==n;for(let s=6*t,n=6*(t+i);s<n;s+=6){const t=e[s+0],i=e[s+1],n=t-i,T=t+i;n<r&&(r=n),T>c&&(c=T),C&&t<u&&(u=t),C&&t>E&&(E=t);const m=e[s+2],R=e[s+3],g=m-R,A=m+R;g<o&&(o=g),A>l&&(l=A),C&&m<I&&(I=m),C&&m>f&&(f=m);const F=e[s+4],S=e[s+5],O=F-S,N=F+S;O<a&&(a=O),N>h&&(h=N),C&&F<d&&(d=F),C&&F>p&&(p=F)}s[0]=r,s[1]=o,s[2]=a,s[3]=c,s[4]=l,s[5]=h,C&&(n[0]=u,n[1]=I,n[2]=d,n[3]=E,n[4]=f,n[5]=p)}const Q=32,K=(e,t)=>e.candidate-t.candidate,J=new Array(Q).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),ee=new Float32Array(6);class te{constructor(){}}function ie(e,t,i,s,n,r){let o=s,a=s+n-1;const c=r.pos,l=2*r.axis;for(;;){for(;o<=a&&i[6*o+l]<c;)o++;for(;o<=a&&i[6*a+l]>=c;)a--;if(!(o<a))return o;for(let e=0;e<3;e++){let i=t[3*o+e];t[3*o+e]=t[3*a+e],t[3*a+e]=i}for(let e=0;e<6;e++){let t=i[6*o+e];i[6*o+e]=i[6*a+e],i[6*a+e]=t}o++,a--}}function se(e,t,i,s,n,r){let o=s,a=s+n-1;const c=r.pos,l=2*r.axis;for(;;){for(;o<=a&&i[6*o+l]<c;)o++;for(;o<=a&&i[6*a+l]>=c;)a--;if(!(o<a))return o;{let t=e[o];e[o]=e[a],e[a]=t;for(let e=0;e<6;e++){let t=i[6*o+e];i[6*o+e]=i[6*a+e],i[6*a+e]=t}o++,a--}}}function ne(e,t){const i=e.geometry,s=i.index?i.index.array:null,n=t.maxDepth,r=t.verbose,o=t.maxLeafTris,a=t.strategy,c=t.onProgress,l=Y(i),h=e._indirectBuffer;let u=!1;const I=new Float32Array(6),d=new Float32Array(6),E=function(e,t){var i;(i=t)[0]=i[1]=i[2]=1/0,i[3]=i[4]=i[5]=-1/0;const s=e.attributes.position,n=e.index?e.index.array:null,r=Y(e),o=new Float32Array(6*r),a=s.normalized,c=s.array,l=s.offset||0;let h=3;s.isInterleavedBufferAttribute&&(h=s.data.stride);const u=["getX","getY","getZ"];for(let e=0;e<r;e++){const i=3*e,r=6*e;let I=i+0,d=i+1,E=i+2;n&&(I=n[I],d=n[d],E=n[E]),a||(I=I*h+l,d=d*h+l,E=E*h+l);for(let e=0;e<3;e++){let i,n,l;a?(i=s[u[e]](I),n=s[u[e]](d),l=s[u[e]](E)):(i=c[I+e],n=c[d+e],l=c[E+e]);let h=i;n<h&&(h=n),l<h&&(h=l);let f=i;n>f&&(f=n),l>f&&(f=l);const p=(f-h)/2,C=2*e;o[r+C+0]=h+p,o[r+C+1]=p+(Math.abs(h)+p)*B,h<t[e]&&(t[e]=h),f>t[e+3]&&(t[e+3]=f)}}return o}(i,I),f=t.indirect?se:ie,p=[],C=t.indirect?z(i):k(i);if(1===C.length){const e=C[0],t=new te;t.boundingData=I,function(e,t,i,s){let n=1/0,r=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let s=6*t,h=6*(t+i);s<h;s+=6){const t=e[s+0];t<n&&(n=t),t>a&&(a=t);const i=e[s+2];i<r&&(r=i),i>c&&(c=i);const h=e[s+4];h<o&&(o=h),h>l&&(l=h)}s[0]=n,s[1]=r,s[2]=o,s[3]=a,s[4]=c,s[5]=l}(E,e.offset,e.count,d),m(t,e.offset,e.count,d),p.push(t)}else for(let e of C){const t=new te;t.boundingData=new Float32Array(6),q(E,e.offset,e.count,t.boundingData,d),m(t,e.offset,e.count,d),p.push(t)}return p;function T(e){c&&c(e/l)}function m(e,t,c,l=null,I=0){if(!u&&I>=n&&(u=!0,r&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),c<=o||I>=n)return T(t+c),e.offset=t,e.count=c,e;const p=function(e,t,i,s,n,r){let o=-1,a=0;if(0===r)o=W(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(1===r)o=W(e),-1!==o&&(a=function(e,t,i,s){let n=0;for(let r=t,o=t+i;r<o;r++)n+=e[6*r+2*s];return n/i}(i,s,n,o));else if(2===r){const r=$(e);let c=U*n;const l=6*s,h=6*(s+n);for(let e=0;e<3;e++){const s=t[e],u=(t[e+3]-s)/Q;if(n<8){const t=[...J];t.length=n;let s=0;for(let n=l;n<h;n+=6,s++){const r=t[s];r.candidate=i[n+2*e],r.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:c}=r;for(let e=0;e<3;e++)c[e]=1/0,c[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;Z(n,i,o)}t.sort(K);let u=n;for(let e=0;e<u;e++){const i=t[e];for(;e+1<u&&t[e+1].candidate===i.candidate;)t.splice(e+1,1),u--}for(let s=l;s<h;s+=6){const n=i[s+2*e];for(let e=0;e<u;e++){const r=t[e];n>=r.candidate?Z(s,i,r.rightCacheBounds):(Z(s,i,r.leftCacheBounds),r.count++)}}for(let i=0;i<u;i++){const s=t[i],l=s.count,h=n-s.count,u=s.leftCacheBounds,I=s.rightCacheBounds;let d=0;0!==l&&(d=$(u)/r);let E=0;0!==h&&(E=$(I)/r);const f=1+U*(d*l+E*h);f<c&&(o=e,c=f,a=s.candidate)}}else{for(let e=0;e<Q;e++){const t=J[e];t.count=0,t.candidate=s+u+e*u;const i=t.bounds;for(let e=0;e<3;e++)i[e]=1/0,i[e+3]=-1/0}for(let t=l;t<h;t+=6){let n=~~((i[t+2*e]-s)/u);n>=Q&&(n=31);const r=J[n];r.count++,Z(t,i,r.bounds)}const t=J[31];X(t.bounds,t.rightCacheBounds);for(let e=30;e>=0;e--){const t=J[e],i=J[e+1];j(t.bounds,i.rightCacheBounds,t.rightCacheBounds)}let I=0;for(let t=0;t<31;t++){const i=J[t],s=i.count,l=i.bounds,h=J[t+1].rightCacheBounds;0!==s&&(0===I?X(l,ee):j(l,ee,ee)),I+=s;let u=0,d=0;0!==I&&(u=$(ee)/r);const E=n-I;0!==E&&(d=$(h)/r);const f=1+U*(u*I+d*E);f<c&&(o=e,c=f,a=i.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}(e.boundingData,l,E,t,c,a);if(-1===p.axis)return T(t+c),e.offset=t,e.count=c,e;const C=f(h,s,E,t,c,p);if(C===t||C===t+c)T(t+c),e.offset=t,e.count=c;else{e.splitAxis=p.axis;const i=new te,s=t,n=C-t;e.left=i,i.boundingData=new Float32Array(6),q(E,s,n,i.boundingData,d),m(i,s,n,d,I+1);const r=new te,o=C,a=c-n;e.right=r,r.boundingData=new Float32Array(6),q(E,o,a,r.boundingData,d),m(r,o,a,d,I+1)}return e}}function re(e,t){const i=e.geometry;t.indirect&&(e._indirectBuffer=function(e,t){const i=(e.index?e.index.count:e.attributes.position.count)/3,s=i>65536,n=s?4:2,r=t?new SharedArrayBuffer(i*n):new ArrayBuffer(i*n),o=s?new Uint32Array(r):new Uint16Array(r);for(let e=0,t=o.length;e<t;e++)o[e]=e;return o}(i,t.useSharedArrayBuffer),function(e){if(0===e.groups.length)return!1;const t=Y(e),i=k(e).sort(((e,t)=>e.offset-t.offset)),s=i[i.length-1];s.count=Math.min(t-s.offset,s.count);let n=0;return i.forEach((({count:e})=>n+=e)),t!==n}(i)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),e._indirectBuffer||G(i,t);const s=ne(e,t);let n,r,o;const a=[],c=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let e=0;e<s.length;e++){const t=s[e];const i=new c(32*l(t));n=new Float32Array(i),r=new Uint32Array(i),o=new Uint16Array(i),h(0,t),a.push(i)}return void(e._roots=a);function l(e){return e.count?1:1+l(e.left)+l(e.right)}function h(e,t){const i=e/4,s=e/2,a=!!t.count,c=t.boundingData;for(let e=0;e<6;e++)n[i+e]=c[e];if(a){const n=t.offset,a=t.count;return r[i+6]=n,o[s+14]=a,o[s+15]=x,e+32}{const s=t.left,n=t.right,o=t.splitAxis;let a;if(a=h(e+32,s),a/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[i+6]=a/4,a=h(a,n),r[i+7]=o,a}}}class oe{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let n=0,r=e.length;n<r;n++){const r=e[n][t];i=r<i?r:i,s=r>s?r:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let n=0,r=t.length;n<r;n++){const r=t[n],o=e.dot(r);i=o<i?o:i,s=o>s?o:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}oe.prototype.setFromBox=function(){const e=new n;return function(t,i){const s=i.min,n=i.max;let r=1/0,o=-1/0;for(let i=0;i<=1;i++)for(let a=0;a<=1;a++)for(let c=0;c<=1;c++){e.x=s.x*i+n.x*(1-i),e.y=s.y*a+n.y*(1-a),e.z=s.z*c+n.z*(1-c);const l=t.dot(e);r=Math.min(l,r),o=Math.max(l,o)}this.min=r,this.max=o}}();const ae=function(){const e=new n,t=new n,i=new n;return function(s,n,r){const o=s.start,a=e,c=n.start,l=t;i.subVectors(o,c),e.subVectors(s.end,s.start),t.subVectors(n.end,n.start);const h=i.dot(l),u=l.dot(a),I=l.dot(l),d=i.dot(a),E=a.dot(a)*I-u*u;let f,p;f=0!==E?(h*u-d*I)/E:0,p=(h+f*u)/I,r.x=f,r.y=p}}(),ce=function(){const e=new a,t=new n,i=new n;return function(s,n,r,o){ae(s,n,e);let a=e.x,c=e.y;if(a>=0&&a<=1&&c>=0&&c<=1)return s.at(a,r),void n.at(c,o);if(a>=0&&a<=1)return c<0?n.at(0,o):n.at(1,o),void s.closestPointToPoint(o,!0,r);if(c>=0&&c<=1)return a<0?s.at(0,r):s.at(1,r),void n.closestPointToPoint(r,!0,o);{let e,l;e=a<0?s.start:s.end,l=c<0?n.start:n.end;const h=t,u=i;return s.closestPointToPoint(l,!0,t),n.closestPointToPoint(e,!0,i),h.distanceToSquared(l)<=u.distanceToSquared(e)?(r.copy(h),void o.copy(l)):(r.copy(e),void o.copy(u))}}}(),le=function(){const e=new n,t=new n,i=new r,s=new o;return function(n,r){const{radius:o,center:a}=n,{a:c,b:l,c:h}=r;s.start=c,s.end=l;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;s.start=c,s.end=h;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;s.start=l,s.end=h;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const u=r.getPlane(i);if(Math.abs(u.distanceToPoint(a))<=o){const e=u.projectPoint(a,t);if(r.containsPoint(e))return!0}return!1}}();function he(e){return Math.abs(e)<1e-15}class ue extends c{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new n)),this.satBounds=new Array(4).fill().map((()=>new oe)),this.points=[this.a,this.b,this.c],this.sphere=new l,this.plane=new r,this.needsUpdate=!0}intersectsSphere(e){return le(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,n=this.satAxes,r=this.satBounds,o=n[0],a=r[0];this.getNormal(o),a.setFromPoints(o,s);const c=n[1],l=r[1];c.subVectors(e,t),l.setFromPoints(c,s);const h=n[2],u=r[2];h.subVectors(t,i),u.setFromPoints(h,s);const I=n[3],d=r[3];I.subVectors(i,e),d.setFromPoints(I,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}ue.prototype.closestPointToSegment=function(){const e=new n,t=new n,i=new o;return function(s,n=null,r=null){const{start:o,end:a}=s,c=this.points;let l,h=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;i.start.copy(c[o]),i.end.copy(c[a]),ce(i,s,e,t),l=e.distanceToSquared(t),l<h&&(h=l,n&&n.copy(e),r&&r.copy(t))}return this.closestPointToPoint(o,e),l=o.distanceToSquared(e),l<h&&(h=l,n&&n.copy(e),r&&r.copy(o)),this.closestPointToPoint(a,e),l=a.distanceToSquared(e),l<h&&(h=l,n&&n.copy(e),r&&r.copy(a)),Math.sqrt(h)}}(),ue.prototype.intersectsTriangle=function(){const e=new ue,t=new Array(3),i=new Array(3),s=new oe,r=new oe,a=new n,c=new n,l=new n,h=new n,u=new n,I=new o,d=new o,E=new o,f=new n;function p(e,t,i){const s=e.points;let n=0,r=-1;for(let e=0;e<3;e++){const{start:o,end:a}=I;o.copy(s[e]),a.copy(s[(e+1)%3]),I.delta(c);const l=he(t.distanceToPoint(o));if(he(t.normal.dot(c))&&l){i.copy(I),n=2;break}const h=t.intersectLine(I,f);if(!h&&l&&f.copy(o),(h||l)&&!he(f.distanceTo(a))){if(n<=1){(1===n?i.start:i.end).copy(f),l&&(r=n)}else if(n>=2){(1===r?i.start:i.end).copy(f),n=2;break}if(n++,2===n&&-1===r)break}}return n}return function(n,o=null,c=!1){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);const I=this.plane,f=n.plane;if(Math.abs(I.normal.dot(f.normal))>1-1e-10){const e=this.satBounds,l=this.satAxes;i[0]=n.a,i[1]=n.b,i[2]=n.c;for(let t=0;t<4;t++){const n=e[t],r=l[t];if(s.setFromPoints(r,i),n.isSeparated(s))return!1}const h=n.satBounds,u=n.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let e=0;e<4;e++){const i=h[e],n=u[e];if(s.setFromPoints(n,t),i.isSeparated(s))return!1}for(let e=0;e<4;e++){const n=l[e];for(let e=0;e<4;e++){const o=u[e];if(a.crossVectors(n,o),s.setFromPoints(a,t),r.setFromPoints(a,i),s.isSeparated(r))return!1}}return o&&(c||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),o.start.set(0,0,0),o.end.set(0,0,0)),!0}{const e=p(this,f,d);if(1===e&&n.containsPoint(d.end))return o&&(o.start.copy(d.end),o.end.copy(d.end)),!0;if(2!==e)return!1;const t=p(n,I,E);if(1===t&&this.containsPoint(E.end))return o&&(o.start.copy(E.end),o.end.copy(E.end)),!0;if(2!==t)return!1;if(d.delta(l),E.delta(h),l.dot(h)<0){let e=E.start;E.start=E.end,E.end=e}const i=d.start.dot(l),s=d.end.dot(l),r=E.start.dot(l),a=E.end.dot(l);return(i===a||r===s||s<r!==i<a)&&(o&&(u.subVectors(d.start,E.start),u.dot(l)>0?o.start.copy(d.start):o.start.copy(E.start),u.subVectors(d.end,E.end),u.dot(l)<0?o.end.copy(d.end):o.end.copy(E.end)),!0)}}}(),ue.prototype.distanceToPoint=function(){const e=new n;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),ue.prototype.distanceToTriangle=function(){const e=new n,t=new n,i=["a","b","c"],s=new o,r=new o;return function(n,o=null,a=null){const c=o||a?s:null;if(this.intersectsTriangle(n,c))return(o||a)&&(o&&c.getCenter(o),a&&c.getCenter(a)),0;let l=1/0;for(let t=0;t<3;t++){let s;const r=i[t],c=n[r];this.closestPointToPoint(c,e),s=c.distanceToSquared(e),s<l&&(l=s,o&&o.copy(e),a&&a.copy(c));const h=this[r];n.closestPointToPoint(h,e),s=h.distanceToSquared(e),s<l&&(l=s,o&&o.copy(h),a&&a.copy(e))}for(let c=0;c<3;c++){const h=i[c],u=i[(c+1)%3];s.set(this[h],this[u]);for(let c=0;c<3;c++){const h=i[c],u=i[(c+1)%3];r.set(n[h],n[u]),ce(s,r,e,t);const I=e.distanceToSquared(t);I<l&&(l=I,o&&o.copy(e),a&&a.copy(t))}}return Math.sqrt(l)}}();class Ie{constructor(e,t,i){this.isOrientedBox=!0,this.min=new n,this.max=new n,this.matrix=new h,this.invMatrix=new h,this.points=new Array(8).fill().map((()=>new n)),this.satAxes=new Array(3).fill().map((()=>new n)),this.satBounds=new Array(3).fill().map((()=>new oe)),this.alignedSatBounds=new Array(3).fill().map((()=>new oe)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ie.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let n=0;n<=1;n++)for(let r=0;r<=1;r++)for(let o=0;o<=1;o++){const a=s[1*n|2*r|4*o];a.x=n?i.x:t.x,a.y=r?i.y:t.y,a.z=o?i.z:t.z,a.applyMatrix4(e)}const n=this.satBounds,r=this.satAxes,o=s[0];for(let e=0;e<3;e++){const t=r[e],i=n[e],a=s[1<<e];t.subVectors(o,a),i.setFromPoints(t,s)}const a=this.alignedSatBounds;a[0].setFromPointsField(s,"x"),a[1].setFromPointsField(s,"y"),a[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Ie.prototype.intersectsBox=function(){const e=new oe;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,n=this.satBounds,r=this.satAxes,o=this.alignedSatBounds;if(e.min=i.x,e.max=s.x,o[0].isSeparated(e))return!1;if(e.min=i.y,e.max=s.y,o[1].isSeparated(e))return!1;if(e.min=i.z,e.max=s.z,o[2].isSeparated(e))return!1;for(let i=0;i<3;i++){const s=r[i],o=n[i];if(e.setFromBox(s,t),o.isSeparated(e))return!1}return!0}}(),Ie.prototype.intersectsTriangle=function(){const e=new ue,t=new Array(3),i=new oe,s=new oe,r=new n;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);const o=this.satBounds,a=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let e=0;e<3;e++){const s=o[e],n=a[e];if(i.setFromPoints(n,t),s.isSeparated(i))return!1}const c=n.satBounds,l=n.satAxes,h=this.points;for(let e=0;e<3;e++){const t=c[e],s=l[e];if(i.setFromPoints(s,h),t.isSeparated(i))return!1}for(let e=0;e<3;e++){const n=a[e];for(let e=0;e<4;e++){const o=l[e];if(r.crossVectors(n,o),i.setFromPoints(r,t),s.setFromPoints(r,h),i.isSeparated(s))return!1}}return!0}}(),Ie.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}(),Ie.prototype.distanceToPoint=function(){const e=new n;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Ie.prototype.distanceToBox=function(){const e=["x","y","z"],t=new Array(12).fill().map((()=>new o)),i=new Array(12).fill().map((()=>new o)),s=new n,r=new n;return function(n,o=0,a=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(a||c)&&(n.getCenter(r),this.closestPointToPoint(r,s),n.closestPointToPoint(s,r),a&&a.copy(s),c&&c.copy(r)),0;const l=o*o,h=n.min,u=n.max,I=this.points;let d=1/0;for(let e=0;e<8;e++){const t=I[e];r.copy(t).clamp(h,u);const i=t.distanceToSquared(r);if(i<d&&(d=i,a&&a.copy(t),c&&c.copy(r),i<l))return Math.sqrt(i)}let E=0;for(let s=0;s<3;s++)for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){const o=(s+1)%3,a=(s+2)%3,c=1<<s|n<<o|r<<a,l=I[n<<o|r<<a],d=I[c];t[E].set(l,d);const f=e[s],p=e[o],C=e[a],T=i[E],m=T.start,R=T.end;m[f]=h[f],m[p]=n?h[p]:u[p],m[C]=r?h[C]:u[p],R[f]=u[f],R[p]=n?h[p]:u[p],R[C]=r?h[C]:u[p],E++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let i=0;i<=1;i++){r.x=e?u.x:h.x,r.y=t?u.y:h.y,r.z=i?u.z:h.z,this.closestPointToPoint(r,s);const n=r.distanceToSquared(s);if(n<d&&(d=n,a&&a.copy(s),c&&c.copy(r),n<l))return Math.sqrt(n)}for(let e=0;e<12;e++){const n=t[e];for(let e=0;e<12;e++){const t=i[e];ce(n,t,s,r);const o=s.distanceToSquared(r);if(o<d&&(d=o,a&&a.copy(s),c&&c.copy(r),o<l))return Math.sqrt(o)}}return Math.sqrt(d)}}();class de{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Ee extends de{constructor(){super((()=>new ue))}}const fe=new Ee;function pe(e,t){return 65535===t[e+15]}function Ce(e,t){return t[e+6]}function Te(e,t){return t[e+14]}function me(e){return e+8}function Re(e,t){return t[e+6]}function ge(e,t){return t[e+7]}const Ae=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==e.length&&this.setBuffer(e.pop())}}};let Fe,Se;const Oe=[],Ne=new de((()=>new u));function ye(e,t,i,s,n,r){Fe=Ne.getPrimitive(),Se=Ne.getPrimitive(),Oe.push(Fe,Se),Ae.setBuffer(e._roots[t]);const o=Le(0,e.geometry,i,s,n,r);Ae.clearBuffer(),Ne.releasePrimitive(Fe),Ne.releasePrimitive(Se),Oe.pop(),Oe.pop();const a=Oe.length;return a>0&&(Se=Oe[a-1],Fe=Oe[a-2]),o}function Le(e,t,i,s,n=null,r=0,o=0){const{float32Array:a,uint16Array:c,uint32Array:l}=Ae;let h=2*e;if(pe(h,c)){const t=Ce(e,l),i=Te(h,c);return H(e,a,Fe),s(t,i,!1,o,r+e,Fe)}{let h=function(e){const{uint16Array:t,uint32Array:i}=Ae;let s=2*e;for(;!pe(s,t);)s=2*(e=me(e));return Ce(e,i)},u=function(e){const{uint16Array:t,uint32Array:i}=Ae;let s=2*e;for(;!pe(s,t);)s=2*(e=Re(e,i));return Ce(e,i)+Te(s,t)};const I=me(e),d=Re(e,l);let E,f,p,C,T=I,m=d;if(n&&(p=Fe,C=Se,H(T,a,p),H(m,a,C),E=n(p),f=n(C),f<E)){T=d,m=I;const e=E;E=f,f=e,p=C}p||(p=Fe,H(T,a,p));const R=i(p,pe(2*T,c),E,o+1,r+T);let g;if(2===R){const e=h(T);g=s(e,u(T)-e,!0,o+1,r+T,p)}else g=R&&Le(T,t,i,s,n,r,o+1);if(g)return!0;C=Se,H(m,a,C);const A=i(C,pe(2*m,c),f,o+1,r+m);let F;if(2===A){const e=h(m);F=s(e,u(m)-e,!0,o+1,r+m,C)}else F=A&&Le(m,t,i,s,n,r,o+1);return!!F}}const _e=new n,Pe=new n;const we=new n,Me=new n,ve=new n,De=new a,be=new a,Ue=new a,xe=new n,Be=new n,Ve=new n,Ye=new n;function Ge(e,t,i,s,r,o,l,h,u){we.fromBufferAttribute(t,o),Me.fromBufferAttribute(t,l),ve.fromBufferAttribute(t,h);const E=function(e,t,i,s,n,r){let o;return o=r===I?e.intersectTriangle(s,i,t,!0,n):e.intersectTriangle(t,i,s,r!==d,n),null===o?null:{distance:e.origin.distanceTo(n),point:n.clone()}}(e,we,Me,ve,Ye,u);if(E){s&&(De.fromBufferAttribute(s,o),be.fromBufferAttribute(s,l),Ue.fromBufferAttribute(s,h),E.uv=c.getInterpolation(Ye,we,Me,ve,De,be,Ue,new a)),r&&(De.fromBufferAttribute(r,o),be.fromBufferAttribute(r,l),Ue.fromBufferAttribute(r,h),E.uv1=c.getInterpolation(Ye,we,Me,ve,De,be,Ue,new a)),i&&(xe.fromBufferAttribute(i,o),Be.fromBufferAttribute(i,l),Ve.fromBufferAttribute(i,h),E.normal=c.getInterpolation(Ye,we,Me,ve,xe,Be,Ve,new n),E.normal.dot(e.direction)>0&&E.normal.multiplyScalar(-1));const t={a:o,b:l,c:h,normal:new n,materialIndex:0};c.getNormal(we,Me,ve,t.normal),E.face=t,E.faceIndex=o}return E}function ze(e,t,i,s,n){const r=3*s;let o=r+0,a=r+1,c=r+2;const l=e.index;e.index&&(o=l.getX(o),a=l.getX(a),c=l.getX(c));const{position:h,normal:u,uv:I,uv1:d}=e.attributes,E=Ge(i,h,u,I,d,o,a,c,t);return E?(E.faceIndex=s,n&&n.push(E),E):null}function ke(e,t,i,s){const n=e.a,r=e.b,o=e.c;let a=t,c=t+1,l=t+2;i&&(a=i.getX(a),c=i.getX(c),l=i.getX(l)),n.x=s.getX(a),n.y=s.getY(a),n.z=s.getZ(a),r.x=s.getX(c),r.y=s.getY(c),r.z=s.getZ(c),o.x=s.getX(l),o.y=s.getY(l),o.z=s.getZ(l)}function He(e,t,i,s,n,r,o){const{geometry:a}=i,{index:c}=a,l=a.attributes.position;for(let i=e,a=t+e;i<a;i++){let e;if(e=i,ke(o,3*e,c,l),o.needsUpdate=!0,s(o,e,n,r))return!0}return!1}function We(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const i=e.geometry,s=i.index?i.index.array:null,n=i.attributes.position;let r,o,a,c,l=0;const h=e._roots;for(let e=0,t=h.length;e<t;e++)r=h[e],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),u(0,l),l+=r.byteLength;function u(e,i,r=!1){const l=2*e;if(a[l+15]===x){const t=o[e+6];let i=1/0,r=1/0,h=1/0,u=-1/0,I=-1/0,d=-1/0;for(let e=3*t,o=3*(t+a[l+14]);e<o;e++){let t=s[e];const o=n.getX(t),a=n.getY(t),c=n.getZ(t);o<i&&(i=o),o>u&&(u=o),a<r&&(r=a),a>I&&(I=a),c<h&&(h=c),c>d&&(d=c)}return(c[e+0]!==i||c[e+1]!==r||c[e+2]!==h||c[e+3]!==u||c[e+4]!==I||c[e+5]!==d)&&(c[e+0]=i,c[e+1]=r,c[e+2]=h,c[e+3]=u,c[e+4]=I,c[e+5]=d,!0)}{const s=e+8,n=o[e+6],a=s+i,l=n+i;let h=r,I=!1,d=!1;t?h||(I=t.has(a),d=t.has(l),h=!I&&!d):(I=!0,d=!0);const E=h||d;let f=!1;(h||I)&&(f=u(s,i,h));let p=!1;E&&(p=u(n,i,h));const C=f||p;if(C)for(let t=0;t<3;t++){const i=s+t,r=n+t,o=c[i],a=c[i+3],l=c[r],h=c[r+3];c[e+t]=o<l?o:l,c[e+t+3]=a>h?a:h}return C}}}const Xe=new u;function je(e,t,i,s){return H(e,t,Xe),i.intersectBox(Xe,s)}function Ze(e,t,i,s,n,r,o){const{geometry:a}=i,{index:c}=a,l=a.attributes.position;for(let a=e,h=t+e;a<h;a++){let e;if(e=i.resolveTriangleIndex(a),ke(o,3*e,c,l),o.needsUpdate=!0,s(o,e,n,r))return!0}return!1}const $e=new n;function qe(e,t,i,s,n){Ae.setBuffer(e._roots[t]),Qe(0,e,i,s,n),Ae.clearBuffer()}function Qe(e,t,i,s,n){const{float32Array:r,uint16Array:o,uint32Array:a}=Ae,c=2*e;if(pe(c,o)){!function(e,t,i,s,n,r){const{geometry:o,_indirectBuffer:a}=e;for(let e=s,a=s+n;e<a;e++)ze(o,t,i,e,r)}(t,i,s,Ce(e,a),Te(c,o),n)}else{const o=me(e);je(o,r,s,$e)&&Qe(o,t,i,s,n);const c=Re(e,a);je(c,r,s,$e)&&Qe(c,t,i,s,n)}}const Ke=new n,Je=["x","y","z"];function et(e,t,i,s){Ae.setBuffer(e._roots[t]);const n=tt(0,e,i,s);return Ae.clearBuffer(),n}function tt(e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:o}=Ae;let a=2*e;if(pe(a,r)){return function(e,t,i,s,n){const{geometry:r,_indirectBuffer:o}=e;let a=1/0,c=null;for(let e=s,o=s+n;e<o;e++){let s;s=ze(r,t,i,e),s&&s.distance<a&&(c=s,a=s.distance)}return c}(t,i,s,Ce(e,o),Te(a,r))}{const r=ge(e,o),a=Je[r],c=s.direction[a]>=0;let l,h;c?(l=me(e),h=Re(e,o)):(l=Re(e,o),h=me(e));const u=je(l,n,s,Ke)?tt(l,t,i,s):null;if(u){const e=u.point[a];if(c?e<=n[h+r]:e>=n[h+r+3])return u}const I=je(h,n,s,Ke)?tt(h,t,i,s):null;return u&&I?u.distance<=I.distance?u:I:u||I||null}}const it=new u,st=new ue,nt=new ue,rt=new h,ot=new Ie,at=new Ie;function ct(e,t,i,s){Ae.setBuffer(e._roots[t]);const n=lt(0,e,i,s);return Ae.clearBuffer(),n}function lt(e,t,i,s,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=Ae;let c=2*e;null===n&&(i.boundingBox||i.computeBoundingBox(),ot.set(i.boundingBox.min,i.boundingBox.max,s),n=ot);if(!pe(c,o)){const o=e+8,c=a[e+6];H(o,r,it);if(n.intersectsBox(it)&<(o,t,i,s,n))return!0;H(c,r,it);return!!(n.intersectsBox(it)&<(c,t,i,s,n))}{const n=t.geometry,l=n.index,h=n.attributes.position,u=i.index,I=i.attributes.position,d=Ce(e,a),E=Te(c,o);if(rt.copy(s).invert(),i.boundsTree){H(e,r,at),at.matrix.copy(rt),at.needsUpdate=!0;return i.boundsTree.shapecast({intersectsBounds:e=>at.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(s),e.b.applyMatrix4(s),e.c.applyMatrix4(s),e.needsUpdate=!0;for(let t=3*d,i=3*(E+d);t<i;t+=3)if(ke(nt,t,l,h),nt.needsUpdate=!0,e.intersectsTriangle(nt))return!0;return!1}})}for(let e=3*d,t=3*(E+d);e<t;e+=3){ke(st,e,l,h),st.a.applyMatrix4(rt),st.b.applyMatrix4(rt),st.c.applyMatrix4(rt),st.needsUpdate=!0;for(let e=0,t=u.count;e<t;e+=3)if(ke(nt,e,u,I),nt.needsUpdate=!0,st.intersectsTriangle(nt))return!0}}}const ht=new h,ut=new Ie,It=new Ie,dt=new n,Et=new n,ft=new n,pt=new n;function Ct(e,t,i,s={},n={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ut.set(t.boundingBox.min,t.boundingBox.max,i),ut.needsUpdate=!0;const a=e.geometry,c=a.attributes.position,l=a.index,h=t.attributes.position,u=t.index,I=fe.getPrimitive(),d=fe.getPrimitive();let E=dt,f=Et,p=null,C=null;n&&(p=ft,C=pt);let T=1/0,m=null,R=null;return ht.copy(i).invert(),It.matrix.copy(ht),e.shapecast({boundsTraverseOrder:e=>ut.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o&&(t&&(It.min.copy(e.min),It.max.copy(e.max),It.needsUpdate=!0),!0),intersectsRange:(e,s)=>{if(t.boundsTree){return t.boundsTree.shapecast({boundsTraverseOrder:e=>It.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o,intersectsRange:(t,n)=>{for(let o=t,a=t+n;o<a;o++){ke(d,3*o,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=e,i=e+s;t<i;t++){ke(I,3*t,l,c),I.needsUpdate=!0;const e=I.distanceToTriangle(d,E,p);if(e<T&&(f.copy(E),C&&C.copy(p),T=e,m=t,R=o),e<r)return!0}}}})}for(let n=0,o=Y(t);n<o;n++){ke(d,3*n,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=e,i=e+s;t<i;t++){ke(I,3*t,l,c),I.needsUpdate=!0;const e=I.distanceToTriangle(d,E,p);if(e<T&&(f.copy(E),C&&C.copy(p),T=e,m=t,R=n),e<r)return!0}}}}),fe.releasePrimitive(I),fe.releasePrimitive(d),T===1/0?null:(s.point?s.point.copy(f):s.point=f.clone(),s.distance=T,s.faceIndex=m,n&&(n.point?n.point.copy(C):n.point=C.clone(),n.point.applyMatrix4(ht),f.applyMatrix4(ht),n.distance=f.sub(n.point).length(),n.faceIndex=R),s)}function Tt(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const i=e.geometry,s=i.index?i.index.array:null,n=i.attributes.position;let r,o,a,c,l=0;const h=e._roots;for(let e=0,t=h.length;e<t;e++)r=h[e],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),u(0,l),l+=r.byteLength;function u(i,r,l=!1){const h=2*i;if(a[h+15]===x){const t=o[i+6];let r=1/0,l=1/0,u=1/0,I=-1/0,d=-1/0,E=-1/0;for(let i=t,o=t+a[h+14];i<o;i++){const t=3*e.resolveTriangleIndex(i);for(let e=0;e<3;e++){let i=t+e;i=s?s[i]:i;const o=n.getX(i),a=n.getY(i),c=n.getZ(i);o<r&&(r=o),o>I&&(I=o),a<l&&(l=a),a>d&&(d=a),c<u&&(u=c),c>E&&(E=c)}}return(c[i+0]!==r||c[i+1]!==l||c[i+2]!==u||c[i+3]!==I||c[i+4]!==d||c[i+5]!==E)&&(c[i+0]=r,c[i+1]=l,c[i+2]=u,c[i+3]=I,c[i+4]=d,c[i+5]=E,!0)}{const e=i+8,s=o[i+6],n=e+r,a=s+r;let h=l,I=!1,d=!1;t?h||(I=t.has(n),d=t.has(a),h=!I&&!d):(I=!0,d=!0);const E=h||d;let f=!1;(h||I)&&(f=u(e,r,h));let p=!1;E&&(p=u(s,r,h));const C=f||p;if(C)for(let t=0;t<3;t++){const n=e+t,r=s+t,o=c[n],a=c[n+3],l=c[r],h=c[r+3];c[i+t]=o<l?o:l,c[i+t+3]=a>h?a:h}return C}}}const mt=new n;function Rt(e,t,i,s,n){Ae.setBuffer(e._roots[t]),gt(0,e,i,s,n),Ae.clearBuffer()}function gt(e,t,i,s,n){const{float32Array:r,uint16Array:o,uint32Array:a}=Ae,c=2*e;if(pe(c,o)){!function(e,t,i,s,n,r){const{geometry:o,_indirectBuffer:a}=e;for(let e=s,c=s+n;e<c;e++)ze(o,t,i,a?a[e]:e,r)}(t,i,s,Ce(e,a),Te(c,o),n)}else{const o=me(e);je(o,r,s,mt)&>(o,t,i,s,n);const c=Re(e,a);je(c,r,s,mt)&>(c,t,i,s,n)}}const At=new n,Ft=["x","y","z"];function St(e,t,i,s){Ae.setBuffer(e._roots[t]);const n=Ot(0,e,i,s);return Ae.clearBuffer(),n}function Ot(e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:o}=Ae;let a=2*e;if(pe(a,r)){return function(e,t,i,s,n){const{geometry:r,_indirectBuffer:o}=e;let a=1/0,c=null;for(let e=s,l=s+n;e<l;e++){let s;s=ze(r,t,i,o?o[e]:e),s&&s.distance<a&&(c=s,a=s.distance)}return c}(t,i,s,Ce(e,o),Te(a,r))}{const r=ge(e,o),a=Ft[r],c=s.direction[a]>=0;let l,h;c?(l=me(e),h=Re(e,o)):(l=Re(e,o),h=me(e));const u=je(l,n,s,At)?Ot(l,t,i,s):null;if(u){const e=u.point[a];if(c?e<=n[h+r]:e>=n[h+r+3])return u}const I=je(h,n,s,At)?Ot(h,t,i,s):null;return u&&I?u.distance<=I.distance?u:I:u||I||null}}const Nt=new u,yt=new ue,Lt=new ue,_t=new h,Pt=new Ie,wt=new Ie;function Mt(e,t,i,s){Ae.setBuffer(e._roots[t]);const n=vt(0,e,i,s);return Ae.clearBuffer(),n}function vt(e,t,i,s,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=Ae;let c=2*e;null===n&&(i.boundingBox||i.computeBoundingBox(),Pt.set(i.boundingBox.min,i.boundingBox.max,s),n=Pt);if(!pe(c,o)){const o=e+8,c=a[e+6];H(o,r,Nt);if(n.intersectsBox(Nt)&&vt(o,t,i,s,n))return!0;H(c,r,Nt);return!!(n.intersectsBox(Nt)&&vt(c,t,i,s,n))}{const n=t.geometry,l=n.index,h=n.attributes.position,u=i.index,I=i.attributes.position,d=Ce(e,a),E=Te(c,o);if(_t.copy(s).invert(),i.boundsTree){H(e,r,wt),wt.matrix.copy(_t),wt.needsUpdate=!0;return i.boundsTree.shapecast({intersectsBounds:e=>wt.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(s),e.b.applyMatrix4(s),e.c.applyMatrix4(s),e.needsUpdate=!0;for(let i=d,s=E+d;i<s;i++)if(ke(Lt,3*t.resolveTriangleIndex(i),l,h),Lt.needsUpdate=!0,e.intersectsTriangle(Lt))return!0;return!1}})}for(let e=d,i=E+d;e<i;e++){const i=t.resolveTriangleIndex(e);ke(yt,3*i,l,h),yt.a.applyMatrix4(_t),yt.b.applyMatrix4(_t),yt.c.applyMatrix4(_t),yt.needsUpdate=!0;for(let e=0,t=u.count;e<t;e+=3)if(ke(Lt,e,u,I),Lt.needsUpdate=!0,yt.intersectsTriangle(Lt))return!0}}}const Dt=new h,bt=new Ie,Ut=new Ie,xt=new n,Bt=new n,Vt=new n,Yt=new n;function Gt(e,t,i,s={},n={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),bt.set(t.boundingBox.min,t.boundingBox.max,i),bt.needsUpdate=!0;const a=e.geometry,c=a.attributes.position,l=a.index,h=t.attributes.position,u=t.index,I=fe.getPrimitive(),d=fe.getPrimitive();let E=xt,f=Bt,p=null,C=null;n&&(p=Vt,C=Yt);let T=1/0,m=null,R=null;return Dt.copy(i).invert(),Ut.matrix.copy(Dt),e.shapecast({boundsTraverseOrder:e=>bt.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o&&(t&&(Ut.min.copy(e.min),Ut.max.copy(e.max),Ut.needsUpdate=!0),!0),intersectsRange:(s,n)=>{if(t.boundsTree){const a=t.boundsTree;return a.shapecast({boundsTraverseOrder:e=>Ut.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o,intersectsRange:(t,o)=>{for(let g=t,A=t+o;g<A;g++){const t=a.resolveTriangleIndex(g);ke(d,3*t,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=s,i=s+n;t<i;t++){const i=e.resolveTriangleIndex(t);ke(I,3*i,l,c),I.needsUpdate=!0;const s=I.distanceToTriangle(d,E,p);if(s<T&&(f.copy(E),C&&C.copy(p),T=s,m=t,R=g),s<r)return!0}}}})}for(let o=0,a=Y(t);o<a;o++){ke(d,3*o,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=s,i=s+n;t<i;t++){const i=e.resolveTriangleIndex(t);ke(I,3*i,l,c),I.needsUpdate=!0;const s=I.distanceToTriangle(d,E,p);if(s<T&&(f.copy(E),C&&C.copy(p),T=s,m=t,R=o),s<r)return!0}}}}),fe.releasePrimitive(I),fe.releasePrimitive(d),T===1/0?null:(s.point?s.point.copy(f):s.point=f.clone(),s.distance=T,s.faceIndex=m,n&&(n.point?n.point.copy(C):n.point=C.clone(),n.point.applyMatrix4(Dt),f.applyMatrix4(Dt),n.distance=f.sub(n.point).length(),n.faceIndex=R),s)}const zt=new Ae.constructor,kt=new Ae.constructor,Ht=new de((()=>new u)),Wt=new u,Xt=new u,jt=new u,Zt=new u;let $t=!1;function qt(e,t,i,s,n,r=0,o=0,a=0,c=0,l=null,h=!1){let u,I;h?(u=kt,I=zt):(u=zt,I=kt);const d=u.float32Array,E=u.uint32Array,f=u.uint16Array,p=I.float32Array,C=I.uint32Array,T=I.uint16Array,m=2*t,R=pe(2*e,f),g=pe(m,T);let A=!1;if(g&&R)A=h?n(Ce(t,C),Te(2*t,T),Ce(e,E),Te(2*e,f),c,o+t,a,r+e):n(Ce(e,E),Te(2*e,f),Ce(t,C),Te(2*t,T),a,r+e,c,o+t);else if(g){const l=Ht.getPrimitive();H(t,p,l),l.applyMatrix4(i);const u=me(e),I=Re(e,E);H(u,d,Wt),H(I,d,Xt);const f=l.intersectsBox(Wt),C=l.intersectsBox(Xt);A=f&&qt(t,u,s,i,n,o,r,c,a+1,l,!h)||C&&qt(t,I,s,i,n,o,r,c,a+1,l,!h),Ht.releasePrimitive(l)}else{const u=me(t),I=Re(t,C);H(u,p,jt),H(I,p,Zt);const f=l.intersectsBox(jt),T=l.intersectsBox(Zt);if(f&&T)A=qt(e,u,i,s,n,r,o,a,c+1,l,h)||qt(e,I,i,s,n,r,o,a,c+1,l,h);else if(f)if(R)A=qt(e,u,i,s,n,r,o,a,c+1,l,h);else{const t=Ht.getPrimitive();t.copy(jt).applyMatrix4(i);const l=me(e),I=Re(e,E);H(l,d,Wt),H(I,d,Xt);const f=t.intersectsBox(Wt),p=t.intersectsBox(Xt);A=f&&qt(u,l,s,i,n,o,r,c,a+1,t,!h)||p&&qt(u,I,s,i,n,o,r,c,a+1,t,!h),Ht.releasePrimitive(t)}else if(T)if(R)A=qt(e,I,i,s,n,r,o,a,c+1,l,h);else{const t=Ht.getPrimitive();t.copy(Zt).applyMatrix4(i);const l=me(e),u=Re(e,E);H(l,d,Wt),H(u,d,Xt);const f=t.intersectsBox(Wt),p=t.intersectsBox(Xt);A=f&&qt(I,l,s,i,n,o,r,c,a+1,t,!h)||p&&qt(I,u,s,i,n,o,r,c,a+1,t,!h),Ht.releasePrimitive(t)}}return A}const Qt=new Ie,Kt=new u;class Jt{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,n=e._indirectBuffer,r=i.getIndex();let o;return o=t.cloneBuffers?{roots:s.map((e=>e.slice())),index:r.array.slice(),indirectBuffer:n?n.slice():null}:{roots:s,index:r.array,indirectBuffer:n},o}static deserialize(e,t,i={}){i={setIndex:!0,indirect:Boolean(e.indirectBuffer),...i};const{index:n,roots:r,indirectBuffer:o}=e,a=new Jt(t,{...i,[V]:!0});if(a._roots=r,a._indirectBuffer=o||null,i.setIndex){const i=t.getIndex();if(null===i){const i=new s(e.index,1,!1);t.setIndex(i)}else i.array!==n&&(i.array.set(n),i.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[V]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[V]||(re(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new u)));const{_indirectBuffer:i}=this;this.resolveTriangleIndex=t.indirect?e=>i[e]:e=>e}refit(e=null){return(this.indirect?Tt:We)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),n=new Uint16Array(i);!function t(r,o=0){const a=2*r,c=n[a+15]===x;if(c){const t=s[r+6],l=n[a+14];e(o,c,new Float32Array(i,4*r,6),t,l)}else{const n=r+8,a=s[r+6],l=s[r+7];e(o,c,new Float32Array(i,4*r,6),l)||(t(n,o+1),t(a,o+1))}}(0)}raycast(e,t=E){const i=this._roots,s=this.geometry,n=[],r=t.isMaterial,o=Array.isArray(t),a=s.groups,c=r?t.side:t,l=this.indirect?Rt:qe;for(let s=0,r=i.length;s<r;s++){const i=o?t[a[s].materialIndex].side:c,r=n.length;if(l(this,s,i,e,n),o){const e=a[s].materialIndex;for(let t=r,i=n.length;t<i;t++)n[t].face.materialIndex=e}}return n}raycastFirst(e,t=E){const i=this._roots,s=this.geometry,n=t.isMaterial,r=Array.isArray(t);let o=null;const a=s.groups,c=n?t.side:t,l=this.indirect?St:et;for(let s=0,n=i.length;s<n;s++){const i=l(this,s,r?t[a[s].materialIndex].side:c,e);null!=i&&(null==o||i.distance<o.distance)&&(o=i,r&&(i.face.materialIndex=a[s].materialIndex))}return o}intersectsGeometry(e,t){let i=!1;const s=this._roots,n=this.indirect?Mt:ct;for(let r=0,o=s.length;r<o&&(i=n(this,r,e,t),!i);r++);return i}shapecast(e){const t=fe.getPrimitive(),i=this.indirect?Ze:He;let{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:r,intersectsTriangle:o}=e;if(r&&o){const e=r;r=(s,n,r,a,c)=>!!e(s,n,r,a,c)||i(s,n,this,o,r,a,t)}else r||(r=o?(e,s,n,r)=>i(e,s,this,o,n,r,t):(e,t,i)=>i);let a=!1,c=0;const l=this._roots;for(let e=0,t=l.length;e<t;e++){const t=l[e];if(a=ye(this,e,n,r,s,c),a)break;c+=t.byteLength}return fe.releasePrimitive(t),a}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const r=fe.getPrimitive(),o=this.geometry.index,a=this.geometry.attributes.position,c=this.indirect?e=>{const t=this.resolveTriangleIndex(e);ke(r,3*t,o,a)}:e=>{ke(r,3*e,o,a)},l=fe.getPrimitive(),u=e.geometry.index,I=e.geometry.attributes.position,d=e.indirect?t=>{const i=e.resolveTriangleIndex(t);ke(l,3*i,u,I)}:e=>{ke(l,3*e,u,I)};if(n){const e=(e,i,s,o,a,h,u,I)=>{for(let E=s,f=s+o;E<f;E++){d(E),l.a.applyMatrix4(t),l.b.applyMatrix4(t),l.c.applyMatrix4(t),l.needsUpdate=!0;for(let t=e,s=e+i;t<s;t++)if(c(t),r.needsUpdate=!0,n(r,l,t,E,a,h,u,I))return!0}return!1};if(s){const t=s;s=function(i,s,n,r,o,a,c,l){return!!t(i,s,n,r,o,a,c,l)||e(i,s,n,r,o,a,c,l)}}else s=e}return function(e,t,i,s){if($t)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");$t=!0;const n=e._roots,r=t._roots;let o,a=0,c=0;const l=(new h).copy(i).invert();for(let e=0,t=n.length;e<t;e++){zt.setBuffer(n[e]),c=0;const t=Ht.getPrimitive();H(0,zt.float32Array,t),t.applyMatrix4(l);for(let n=0,h=r.length;n<h&&(kt.setBuffer(r[e]),o=qt(0,0,i,l,s,a,c,0,0,t),kt.clearBuffer(),c+=r[n].length,!o);n++);if(Ht.releasePrimitive(t),zt.clearBuffer(),a+=n[e].length,o)break}return $t=!1,o}(this,e,t,s)}intersectsBox(e,t){return Qt.set(e.min,e.max,t),Qt.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Qt.intersectsBox(e),intersectsTriangle:e=>Qt.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},n=0,r=1/0){return(this.indirect?Gt:Ct)(this,e,t,i,s,n,r)}closestPointToPoint(e,t={},i=0,s=1/0){return function(e,t,i={},s=0,n=1/0){const r=s*s,o=n*n;let a=1/0,c=null;if(e.shapecast({boundsTraverseOrder:e=>(_e.copy(t).clamp(e.min,e.max),_e.distanceToSquared(t)),intersectsBounds:(e,t,i)=>i<a&&i<o,intersectsTriangle:(e,i)=>{e.closestPointToPoint(t,_e);const s=t.distanceToSquared(_e);return s<a&&(Pe.copy(_e),a=s,c=i),s<r}}),a===1/0)return null;const l=Math.sqrt(a);return i.point?i.point.copy(Pe):i.point=Pe.clone(),i.distance=l,i.faceIndex=c,i}(this,e,t,i,s)}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{H(0,new Float32Array(t),Kt),e.union(Kt)})),e}}function ei(e,t,i){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far?null:e)}const ti=new f,ii=new h,si=p.prototype.raycast;function ni(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;ii.copy(this.matrixWorld).invert(),ti.copy(e.ray).applyMatrix4(ii);const i=this.geometry.boundsTree;if(!0===e.firstHitOnly){const s=ei(i.raycastFirst(ti,this.material),this,e);s&&t.push(s)}else{const s=i.raycast(ti,this.material);for(let i=0,n=s.length;i<n;i++){const n=ei(s[i],this,e);n&&t.push(n)}}}else si.call(this,e,t)}function ri(e){return this.boundsTree=new Jt(this,e),this.boundsTree}function oi(){this.boundsTree=null}class ai{constructor(){t(this,"enabled",!0),t(this,"trigger",(e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)i(e)})),t(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter((t=>t!==e))}reset(){this.handlers.length=0}}class ci{constructor(){t(this,"enabled",!0),t(this,"trigger",(async e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)await i(e)})),t(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter((t=>t!==e))}reset(){this.handlers.length=0}}class li{constructor(e){t(this,"isDisposeable",(()=>"dispose"in this&&"onDisposed"in this)),t(this,"isResizeable",(()=>"resize"in this&&"getSize"in this)),t(this,"isUpdateable",(()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this)),t(this,"isHideable",(()=>"visible"in this)),t(this,"isConfigurable",(()=>"setup"in this&&"config"in this&&"onSetup"in this)),this.components=e}}class hi extends li{}class ui extends li{constructor(e){super(e),t(this,"worlds",new Map),t(this,"onWorldChanged",new ai),t(this,"currentWorld",null),this.onWorldChanged.add((({world:e,action:t})=>{"removed"===t&&this.worlds.delete(e.uuid)}))}}class Ii extends ui{constructor(){super(...arguments),t(this,"hasCameraControls",(()=>"controls"in this))}}class di extends ui{constructor(){super(...arguments),t(this,"onAfterUpdate",new ai),t(this,"onBeforeUpdate",new ai),t(this,"onDisposed",new ai),t(this,"onResize",new ai),t(this,"onClippingPlanesUpdated",new ai),t(this,"clippingPlanes",[])}updateClippingPlanes(){this.onClippingPlanesUpdated.trigger()}setPlane(e,t,i){t.isLocal=i;const s=this.clippingPlanes.indexOf(t);e&&-1===s?this.clippingPlanes.push(t):!e&&s>-1&&this.clippingPlanes.splice(s,1),this.three.clippingPlanes=this.clippingPlanes.filter((e=>!e.isLocal))}}const Ei=class e extends hi{constructor(i){super(i),t(this,"_disposedComponents",new Set),t(this,"enabled",!0),i.add(e.uuid,this)}get(){return this._disposedComponents}destroy(e,t=!0,i=!0){e.removeFromParent();const s=e;s.dispose&&s.dispose(),this.disposeGeometryAndMaterials(e,t),i&&s.children&&s.children.length&&this.disposeChildren(s),e.children.length=0}disposeGeometry(e){e.boundsTree&&e.disposeBoundsTree&&e.disposeBoundsTree(),e.dispose()}disposeGeometryAndMaterials(t,i){const s=t;s.geometry&&this.disposeGeometry(s.geometry),i&&s.material&&e.disposeMaterial(s),s.material=[],s.geometry=null}disposeChildren(e){for(const t of e.children)this.destroy(t)}static disposeMaterial(e){if(e.material)if(Array.isArray(e.material))for(const t of e.material)t.dispose();else e.material.dispose()}};t(Ei,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let fi=Ei;class pi extends ui{constructor(e){super(e),t(this,"onDisposed",new ai),t(this,"directionalLights",new Map),t(this,"ambientLights",new Map)}dispose(){const e=this.components.get(fi);for(const t of this.three.children){const i=t;i.geometry&&e.destroy(i)}this.deleteAllLights(),this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}deleteAllLights(){for(const[,e]of this.directionalLights)e.removeFromParent(),e.target.removeFromParent(),e.dispose();this.directionalLights.clear();for(const[,e]of this.ambientLights)e.removeFromParent(),e.dispose();this.ambientLights.clear()}}class Ci extends Set{constructor(e){super(e),t(this,"onItemAdded",new ai),t(this,"onItemDeleted",new ai),t(this,"onCleared",new ai),t(this,"guard",(()=>!0))}clear(){super.clear(),this.onCleared.trigger()}add(...e){for(const t of e){if(this.has(t))continue;this.guard(t)&&(super.add(t),this.onItemAdded||(this.onItemAdded=new ai),this.onItemAdded.trigger(t))}return this}delete(e){const t=super.delete(e);return t&&this.onItemDeleted.trigger(),t}dispose(){this.clear(),this.onItemAdded.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class Ti extends Map{constructor(e){super(e),t(this,"onItemSet",new ai),t(this,"onItemUpdated",new ai),t(this,"onItemDeleted",new ai),t(this,"onCleared",new ai),t(this,"guard",(()=>!0))}clear(){super.clear(),this.onCleared.trigger()}set(e,t){const i=this.has(e);if(!(this.guard??(()=>!0))(e,t))return this;const s=super.set(e,t);return i?(this.onItemUpdated||(this.onItemUpdated=new ai),this.onItemUpdated.trigger({key:e,value:t})):(this.onItemSet||(this.onItemSet=new ai),this.onItemSet.trigger({key:e,value:t})),s}delete(e){const t=super.delete(e);return t&&this.onItemDeleted.trigger(e),t}dispose(){this.clear(),this.onItemSet.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class mi extends hi{}class Ri{static isEntry(e){return new Set(["Boolean","Color","Text","Number","Select","Vector3","TextSet","None"]).has(e.type)}static copySchema(e,t={}){for(const i in e){const s=e[i];this.isEntry(s)?t[i]=this.copyEntry(s):(t[i]={},this.copySchema(s,t[i]))}return t}static copyEntry(e){if("Boolean"===e.type){const t=e;return{type:t.type,value:t.value}}if("Color"===e.type){const t=e;return{type:t.type,value:t.value.clone()}}if("Text"===e.type){const t=e;return{type:t.type,value:t.value}}if("Number"===e.type){const t=e;return{type:t.type,value:t.value,min:t.min,max:t.max,interpolable:t.interpolable}}if("Select"===e.type){const t=e;return{type:t.type,value:t.value,multiple:t.multiple,options:new Set(t.options)}}if("Vector3"===e.type){const t=e;return{type:t.type,value:t.value.clone()}}if("TextSet"===e.type){const t=e;return{type:t.type,value:new Set(t.value)}}if("None"===e.type){const t=e;return{type:t.type,value:t.value}}throw new Error("Invalid entry!")}}class gi{constructor(){t(this,"list",new Set)}add(e){for(const t of e)this.list.add(t)}remove(e){for(const t of e)this.list.delete(t)}set(e){for(const t of this.list)t.enabled=e}reset(){for(const e of this.list)e.reset()}}const Ai=new n,Fi=new o,Si=new r,Oi=new n,Ni=new c;class yi{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new wi,this.unassigned=new wi,this.vertices=[]}setFromPoints(e){if(e.length>=4){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.vertices.push(new Pi(e[t]));this.compute()}return this}setFromObject(e){const t=[];return e.updateMatrixWorld(!0),e.traverse((function(e){const i=e.geometry;if(void 0!==i){const s=i.attributes.position;if(void 0!==s)for(let i=0,r=s.count;i<r;i++){const r=new n;r.fromBufferAttribute(s,i).applyMatrix4(e.matrixWorld),t.push(r)}}})),this.setFromPoints(t)}containsPoint(e){const t=this.faces;for(let i=0,s=t.length;i<s;i++){if(t[i].distanceToPoint(e)>this.tolerance)return!1}return!0}intersectRay(e,t){const i=this.faces;let s=-1/0,n=1/0;for(let t=0,r=i.length;t<r;t++){const r=i[t],o=r.distanceToPoint(e.origin),a=r.normal.dot(e.direction);if(o>0&&a>=0)return null;const c=0!==a?-o/a:0;if(!(c<=0)&&(a>0?n=Math.min(c,n):s=Math.max(c,s),s>n))return null}return s!==-1/0?e.at(s,t):e.at(n,t),t}intersectsRay(e){return null!==this.intersectRay(e,Ai)}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(e,t){return e.face=t,null===t.outside?this.assigned.append(e):this.assigned.insertBefore(t.outside,e),t.outside=e,this}removeVertexFromFace(e,t){return e===t.outside&&(null!==e.next&&e.next.face===t?t.outside=e.next:t.outside=null),this.assigned.remove(e),this}removeAllVerticesFromFace(e){if(null!==e.outside){const t=e.outside;let i=e.outside;for(;null!==i.next&&i.next.face===e;)i=i.next;return this.assigned.removeSubList(t,i),t.prev=i.next=null,e.outside=null,t}}deleteFaceVertices(e,t){const i=this.removeAllVerticesFromFace(e);if(void 0!==i)if(void 0===t)this.unassigned.appendChain(i);else{let e=i;do{const i=e.next;t.distanceToPoint(e.point)>this.tolerance?this.addVertexToFace(e,t):this.unassigned.append(e),e=i}while(null!==e)}return this}resolveUnassignedPoints(e){if(!1===this.unassigned.isEmpty()){let t=this.unassigned.first();do{const i=t.next;let s=this.tolerance,n=null;for(let i=0;i<e.length;i++){const r=e[i];if(0===r.mark){const e=r.distanceToPoint(t.point);if(e>s&&(s=e,n=r),s>1e3*this.tolerance)break}}null!==n&&this.addVertexToFace(t,n),t=i}while(null!==t)}return this}computeExtremes(){const e=new n,t=new n,i=[],s=[];for(let e=0;e<3;e++)i[e]=s[e]=this.vertices[0];e.copy(this.vertices[0].point),t.copy(this.vertices[0].point);for(let n=0,r=this.vertices.length;n<r;n++){const r=this.vertices[n],o=r.point;for(let t=0;t<3;t++)o.getComponent(t)<e.getComponent(t)&&(e.setComponent(t,o.getComponent(t)),i[t]=r);for(let e=0;e<3;e++)o.getComponent(e)>t.getComponent(e)&&(t.setComponent(e,o.getComponent(e)),s[e]=r)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(e.x),Math.abs(t.x))+Math.max(Math.abs(e.y),Math.abs(t.y))+Math.max(Math.abs(e.z),Math.abs(t.z))),{min:i,max:s}}computeInitialHull(){const e=this.vertices,t=this.computeExtremes(),i=t.min,s=t.max;let n=0,r=0;for(let e=0;e<3;e++){const t=s[e].point.getComponent(e)-i[e].point.getComponent(e);t>n&&(n=t,r=e)}const o=i[r],a=s[r];let c,l;n=0,Fi.set(o.point,a.point);for(let t=0,i=this.vertices.length;t<i;t++){const i=e[t];if(i!==o&&i!==a){Fi.closestPointToPoint(i.point,!0,Oi);const e=Oi.distanceToSquared(i.point);e>n&&(n=e,c=i)}}n=-1,Si.setFromCoplanarPoints(o.point,a.point,c.point);for(let t=0,i=this.vertices.length;t<i;t++){const i=e[t];if(i!==o&&i!==a&&i!==c){const e=Math.abs(Si.distanceToPoint(i.point));e>n&&(n=e,l=i)}}const h=[];if(Si.distanceToPoint(l.point)<0){h.push(Li.create(o,a,c),Li.create(l,a,o),Li.create(l,c,a),Li.create(l,o,c));for(let e=0;e<3;e++){const t=(e+1)%3;h[e+1].getEdge(2).setTwin(h[0].getEdge(t)),h[e+1].getEdge(1).setTwin(h[t+1].getEdge(0))}}else{h.push(Li.create(o,c,a),Li.create(l,o,a),Li.create(l,a,c),Li.create(l,c,o));for(let e=0;e<3;e++){const t=(e+1)%3;h[e+1].getEdge(2).setTwin(h[0].getEdge((3-e)%3)),h[e+1].getEdge(0).setTwin(h[t+1].getEdge(1))}}for(let e=0;e<4;e++)this.faces.push(h[e]);for(let t=0,i=e.length;t<i;t++){const i=e[t];if(i!==o&&i!==a&&i!==c&&i!==l){n=this.tolerance;let e=null;for(let t=0;t<4;t++){const s=this.faces[t].distanceToPoint(i.point);s>n&&(n=s,e=this.faces[t])}null!==e&&this.addVertexToFace(i,e)}}return this}reindexFaces(){const e=[];for(let t=0;t<this.faces.length;t++){const i=this.faces[t];0===i.mark&&e.push(i)}return this.faces=e,this}nextVertexToAdd(){if(!1===this.assigned.isEmpty()){let e,t=0;const i=this.assigned.first().face;let s=i.outside;do{const n=i.distanceToPoint(s.point);n>t&&(t=n,e=s),s=s.next}while(null!==s&&s.face===i);return e}}computeHorizon(e,t,i,s){let n;this.deleteFaceVertices(i),i.mark=1,n=null===t?t=i.getEdge(0):t.next;do{const t=n.twin,i=t.face;0===i.mark&&(i.distanceToPoint(e)>this.tolerance?this.computeHorizon(e,t,i,s):s.push(n)),n=n.next}while(n!==t);return this}addAdjoiningFace(e,t){const i=Li.create(e,t.tail(),t.head());return this.faces.push(i),i.getEdge(-1).setTwin(t.twin),i.getEdge(0)}addNewFaces(e,t){this.newFaces=[];let i=null,s=null;for(let n=0;n<t.length;n++){const r=t[n],o=this.addAdjoiningFace(e,r);null===i?i=o:o.next.setTwin(s),this.newFaces.push(o.face),s=o}return i.next.setTwin(s),this}addVertexToHull(e){const t=[];return this.unassigned.clear(),this.removeVertexFromFace(e,e.face),this.computeHorizon(e.point,null,e.face,t),this.addNewFaces(e,t),this.resolveUnassignedPoints(this.newFaces),this}cleanup(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this}compute(){let e;for(this.computeInitialHull();void 0!==(e=this.nextVertexToAdd());)this.addVertexToHull(e);return this.reindexFaces(),this.cleanup(),this}}class Li{constructor(){this.normal=new n,this.midpoint=new n,this.area=0,this.constant=0,this.outside=null,this.mark=0,this.edge=null}static create(e,t,i){const s=new Li,n=new _i(e,s),r=new _i(t,s),o=new _i(i,s);return n.next=o.prev=r,r.next=n.prev=o,o.next=r.prev=n,s.edge=n,s.compute()}getEdge(e){let t=this.edge;for(;e>0;)t=t.next,e--;for(;e<0;)t=t.prev,e++;return t}compute(){const e=this.edge.tail(),t=this.edge.head(),i=this.edge.next.head();return Ni.set(e.point,t.point,i.point),Ni.getNormal(this.normal),Ni.getMidpoint(this.midpoint),this.area=Ni.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(e){return this.normal.dot(e)-this.constant}}class _i{constructor(e,t){this.vertex=e,this.prev=null,this.next=null,this.twin=null,this.face=t}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){const e=this.head(),t=this.tail();return null!==t?t.point.distanceTo(e.point):-1}lengthSquared(){const e=this.head(),t=this.tail();return null!==t?t.point.distanceToSquared(e.point):-1}setTwin(e){return this.twin=e,e.twin=this,this}}class Pi{constructor(e){this.point=e,this.prev=null,this.next=null,this.face=null}}class wi{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(e,t){return t.prev=e.prev,t.next=e,null===t.prev?this.head=t:t.prev.next=t,e.prev=t,this}insertAfter(e,t){return t.prev=e,t.next=e.next,null===t.next?this.tail=t:t.next.prev=t,e.next=t,this}append(e){return null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e,this}appendChain(e){for(null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail;null!==e.next;)e=e.next;return this.tail=e,this}remove(e){return null===e.prev?this.head=e.next:e.prev.next=e.next,null===e.next?this.tail=e.prev:e.next.prev=e.prev,this}removeSubList(e,t){return null===e.prev?this.head=t.next:e.prev.next=t.next,null===t.next?this.tail=e.prev:t.next.prev=e.prev,this}isEmpty(){return null===this.head}}const Mi=[2,2,1],vi=[1,0,0];function Di(e,t){return 3*e+t}function bi(e){const t=e.elements;let i=0;for(let e=0;e<3;e++){const s=t[Di(Mi[e],vi[e])];i+=2*s*s}return Math.sqrt(i)}function Ui(e,t){let i=0,s=1;const n=e.elements;for(let e=0;e<3;e++){const t=Math.abs(n[Di(Mi[e],vi[e])]);t>i&&(i=t,s=e)}let r=1,o=0;const a=vi[s],c=Mi[s];if(Math.abs(n[Di(c,a)])>Number.EPSILON){const e=(n[Di(c,c)]-n[Di(a,a)])/2/n[Di(c,a)];let t;t=e<0?-1/(-e+Math.sqrt(1+e*e)):1/(e+Math.sqrt(1+e*e)),r=1/Math.sqrt(1+t*t),o=t*r}return t.identity(),t.elements[Di(a,a)]=r,t.elements[Di(c,c)]=r,t.elements[Di(c,a)]=o,t.elements[Di(a,c)]=-o,t}function xi(e,t){let s=0,n=0;t.unitary.identity(),t.diagonal.copy(e);const r=t.unitary,o=t.diagonal,a=new i.Matrix3,c=new i.Matrix3,l=Number.EPSILON*function(e){const t=e.elements;let i=0;for(let e=0;e<9;e++)i+=t[e]*t[e];return Math.sqrt(i)}(o);for(;n<10&&bi(o)>l;)Ui(o,a),c.copy(a).transpose(),o.multiply(a),o.premultiply(c),r.multiply(a),++s>2&&(n++,s=0);return t}function Bi(e){const t=[];for(let s=0;s<e.length-2;s+=3){const n=e[s],r=e[s+1],o=e[s+2];t.push(new i.Vector3(n,r,o))}const s=new yi;s.setFromPoints(t);const n={unitary:new i.Matrix3,diagonal:new i.Matrix3},r=s.faces,o=[],a=[];for(let e=0,t=r.length;e<t;e++){const t=r[e];let i=t.edge;o.length=0;do{o.push(i),i=i.next}while(i!==t.edge);for(let e=1,t=o.length-2;e<=t;e++){const t=o[0].vertex,i=o[e+0].vertex,s=o[e+1].vertex;a.push(t.point.x,t.point.y,t.point.z),a.push(i.point.x,i.point.y,i.point.z),a.push(s.point.x,s.point.y,s.point.z)}}const c=new i.Vector3,l=new i.Vector3,h=new i.Vector3,u=new i.Vector3,I=new i.Vector3,d=new i.Vector3,E=new i.Vector3,f=new i.Vector3;let p=0,C=0,T=0,m=0,R=0,g=0,A=0;for(let e=0,t=a.length;e<t;e+=9){c.fromArray(a,e),l.fromArray(a,e+3),h.fromArray(a,e+6),E.set(0,0,0),E.add(c).add(l).add(h).divideScalar(3),u.subVectors(l,c),I.subVectors(h,c);const t=d.crossVectors(u,I).length()/2;f.add(d.copy(E).multiplyScalar(t)),p+=t,C+=(9*E.x*E.x+c.x*c.x+l.x*l.x+h.x*h.x)*(t/12),T+=(9*E.x*E.y+c.x*c.y+l.x*l.y+h.x*h.y)*(t/12),m+=(9*E.x*E.z+c.x*c.z+l.x*l.z+h.x*h.z)*(t/12),R+=(9*E.y*E.y+c.y*c.y+l.y*l.y+h.y*h.y)*(t/12),g+=(9*E.y*E.z+c.y*c.z+l.y*l.z+h.y*h.z)*(t/12),A+=(9*E.z*E.z+c.z*c.z+l.z*l.z+h.z*h.z)*(t/12)}f.divideScalar(p),C/=p,T/=p,m/=p,R/=p,g/=p,A/=p,C-=f.x*f.x,T-=f.x*f.y,m-=f.x*f.z,R-=f.y*f.y,g-=f.y*f.z,A-=f.z*f.z;const F=new i.Matrix3;F.elements[0]=C,F.elements[1]=T,F.elements[2]=m,F.elements[3]=T,F.elements[4]=R,F.elements[5]=g,F.elements[6]=m,F.elements[7]=g,F.elements[8]=A,xi(F,n);const S=n.unitary,O=new i.Vector3,N=new i.Vector3,y=new i.Vector3;S.extractBasis(O,N,y);let L=-1/0,_=-1/0,P=-1/0,w=1/0,M=1/0,v=1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e];L=Math.max(O.dot(i),L),_=Math.max(N.dot(i),_),P=Math.max(y.dot(i),P),w=Math.min(O.dot(i),w),M=Math.min(N.dot(i),M),v=Math.min(y.dot(i),v)}O.multiplyScalar(.5*(w+L)),N.multiplyScalar(.5*(M+_)),y.multiplyScalar(.5*(v+P));const D=new i.Vector3,b=new i.Vector3,U=new i.Matrix3;D.add(O).add(N).add(y),b.x=L-w,b.y=_-M,b.z=P-v,b.multiplyScalar(.5),U.copy(S);const{x:x,y:B,z:V}=b,Y=new i.Matrix4;Y.makeScale(2*x,2*B,2*V);const G=new i.Matrix4;G.makeTranslation(-x,-B,-V);const z=new i.Matrix4;z.makeTranslation(D.x,D.y,D.z);const k=new i.Matrix4;k.setFromMatrix3(U);const H=new i.Matrix4;return H.multiply(z),H.multiply(k),H.multiply(G),H.multiply(Y),{center:D,halfSizes:b,rotation:U,transformation:H}}function Vi(e,t,i){const s=[e[0]-t[0],e[1]-t[1],e[2]-t[2]];return i[0]*s[0]+i[1]*s[1]+i[2]*s[2]>0}class Yi{static isTransparent(e){return e.transparent&&e.opacity<1}}const Gi=class e{static create(){const t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return`${e._lut[255&t]+e._lut[t>>8&255]+e._lut[t>>16&255]+e._lut[t>>24&255]}-${e._lut[255&i]}${e._lut[i>>8&255]}-${e._lut[i>>16&15|64]}${e._lut[i>>24&255]}-${e._lut[63&s|128]}${e._lut[s>>8&255]}-${e._lut[s>>16&255]}${e._lut[s>>24&255]}${e._lut[255&n]}${e._lut[n>>8&255]}${e._lut[n>>16&255]}${e._lut[n>>24&255]}`.toLowerCase()}static validate(t){if(!e._pattern.test(t))throw new Error(`${t} is not a valid UUID v4.\n\n- If you're the tool creator, you can take one from https://www.uuidgenerator.net/.\n\n- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};t(Gi,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/),t(Gi,"_lut",["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"]);let zi=Gi;class ki extends hi{constructor(e,i){super(e),t(this,"onDisposed",new ai),t(this,"onVertexFound",new ai),t(this,"onVertexLost",new ai),t(this,"onEnabled",new ai),t(this,"components"),t(this,"workingPlane",null),t(this,"_pickedPoint",null),t(this,"_config"),t(this,"_enabled",!1),this.components=e,this.config={snapDistance:.25,showOnlyVertex:!1,...i},this.enabled=!1}set enabled(e){this._enabled=e,e||(this._pickedPoint=null),this.onEnabled.trigger(e)}get enabled(){return this._enabled}set config(e){this._config={...this._config,...e}}get config(){return this._config}dispose(){this.onVertexFound.reset(),this.onVertexLost.reset(),this.components=null,this.onDisposed.trigger(),this.onDisposed.reset()}get(e){if(!this.enabled)return this._pickedPoint;const t=this.components.get(En).get(e).castRay();if(!t)return null!==this._pickedPoint&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;const i=this.getClosestVertex(t);if(!i)return null!==this._pickedPoint&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;return!this.workingPlane||Math.abs(this.workingPlane.distanceToPoint(i))<.001?(null!==this._pickedPoint&&this._pickedPoint.equals(i)||(this._pickedPoint=i.clone(),this.onVertexFound.trigger(this._pickedPoint)),this._pickedPoint):(this._pickedPoint=null,this._pickedPoint)}getClosestVertex(e){let t=new i.Vector3,s=!1,n=Number.MAX_SAFE_INTEGER;const r=this.getVertices(e);if(null===r)return null;for(const i of r){if(!i)continue;const r=e.point.distanceTo(i);r>n||r>this._config.snapDistance||(s=!0,t=i,n=e.point.distanceTo(i))}return s?t:this.config.showOnlyVertex?null:e.point}getVertices(e){const t=e.object;if(!e.face||!t)return null;const s=t.geometry,n=new i.Matrix4,{instanceId:r}=e,o=void 0!==r,a=t instanceof i.InstancedMesh;return a&&o&&t.getMatrixAt(r,n),[this.getVertex(e.face.a,s),this.getVertex(e.face.b,s),this.getVertex(e.face.c,s)].map((e=>(e&&(a&&o&&e.applyMatrix4(n),e.applyMatrix4(t.matrixWorld)),e)))}getVertex(e,t){if(void 0===e)return null;const s=t.attributes.position;return new i.Vector3(s.getX(e),s.getY(e),s.getZ(e))}}const Hi=class e{constructor(){t(this,"onDisposed",new ai),t(this,"list",new Map),t(this,"enabled",!1),t(this,"_clock"),t(this,"onInit",new ai),t(this,"update",(()=>{if(!this.enabled)return;const e=this._clock.getDelta();for(const[t,i]of this.list)i.enabled&&i.isUpdateable()&&i.update(e);requestAnimationFrame(this.update)})),this._clock=new i.Clock,e.setupBVH()}add(e,t){if(this.list.has(e))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");zi.validate(e),this.list.set(e,t)}get(e){const t=e.uuid;if(!this.list.has(t)){const i=new e(this);return this.list.has(t)||this.add(t,i),i}return this.list.get(t)}init(){this.enabled=!0,this._clock.start(),this.update(),this.onInit.trigger()}dispose(){this.enabled=!1;for(const[e,t]of this.list)t.enabled=!1,t.isDisposeable()&&t.dispose();this._clock.stop(),this.onDisposed.trigger(),this.onDisposed.reset()}static setupBVH(){i.BufferGeometry.prototype.computeBoundsTree=ri,i.BufferGeometry.prototype.disposeBoundsTree=oi,i.Mesh.prototype.raycast=ni}};t(Hi,"release","2.4.2");let Wi=Hi;class Xi extends li{constructor(){super(...arguments),t(this,"meshes",new Set),t(this,"onAfterUpdate",new ai),t(this,"onBeforeUpdate",new ai),t(this,"onDisposed",new ai),t(this,"isDisposing",!1),t(this,"enabled",!0),t(this,"uuid",zi.create()),t(this,"name"),t(this,"_scene"),t(this,"_camera"),t(this,"_renderer",null)}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(e){this._scene=e,e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(e){this._camera=e,e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"})}get renderer(){return this._renderer}set renderer(e){this._renderer=e,e&&(e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"}))}update(e){this.enabled&&this._scene&&this._camera&&(this.scene.currentWorld=this,this.camera.currentWorld=this,this.renderer&&(this.renderer.currentWorld=this),this.onBeforeUpdate.trigger(),this.scene.isUpdateable()&&this.scene.update(e),this.camera.isUpdateable()&&this.camera.update(e),this.renderer&&this.renderer.update(e),this.onAfterUpdate.trigger())}dispose(e=!0){if(this.enabled=!1,this.isDisposing=!0,this.scene.onWorldChanged.trigger({world:this,action:"removed"}),this.camera.onWorldChanged.trigger({world:this,action:"removed"}),this.renderer&&this.renderer.onWorldChanged.trigger({world:this,action:"removed"}),e){const e=this.components.get(fi);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const t of this.meshes)e.destroy(t);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null;this.components.get(en).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class ji{constructor(e,i,s,n){t(this,"_component"),t(this,"name"),t(this,"uuid"),this._component=e,this.name=s,this.uuid=n??zi.create();i.get($i).list.set(this.uuid,this)}get controls(){return Ri.copySchema(this._config)}set(e){for(const t in e)if(t in this){this[t]=e[t].value}}export(e=this._config,t={}){for(const i in e){const s=e[i];if(Ri.isEntry(s))if("Color"===s.type){const{r:e,g:n,b:r}=s.value;t[i]={...s,value:{r:e,g:n,b:r}}}else if("Vector3"===s.type){const{x:e,y:n,z:r}=s.value;t[i]={...s,value:{x:e,y:n,z:r}}}else if("TextSet"===s.type){const e=Array.from(s.value);t[i]={...s,value:e}}else if("Select"===s.type){const e=Array.from(s.options);t[i]={...s,options:e}}else t[i]={...s};else t[i]={},this.export(s,t[i])}return t}import(e,t={},s=!0){for(const s in e){const n=e[s];if(Ri.isEntry(n))if("Color"===n.type){const{r:e,g:r,b:o}=n.value;t[s]={...n,value:new i.Color(e,r,o)}}else if("Vector3"===n.type){const{x:e,y:r,z:o}=n.value;t[s]={...n,value:new i.Vector3(e,r,o)}}else"TextSet"===n.type?t[s]={...n,value:new Set(n.value)}:"Select"===n.type?t[s]={...n,options:new Set(n.options)}:t[s]={...n};else t[s]={},this.import(n,t[s],!1)}s&&this.set(t)}}const Zi=class e extends hi{constructor(i){super(i),t(this,"list",new Ti),t(this,"enabled",!0),i.add(e.uuid,this)}};t(Zi,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let $i=Zi;class qi{constructor(e,i){t(this,"_list"),t(this,"_scene"),this._list=e,this._scene=i}get color(){return this._list.directionalLight.color.value}set color(e){this._list.directionalLight.color.value=e;for(const[,t]of this._scene.directionalLights)t.color.copy(e)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(e){this._list.directionalLight.intensity.value=e;for(const[,t]of this._scene.directionalLights)t.intensity=e}get position(){return this._list.directionalLight.position.value.clone()}set position(e){this._list.directionalLight.position.value=e;for(const[,t]of this._scene.directionalLights)t.position.copy(e)}}class Qi{constructor(e,i){t(this,"_list"),t(this,"_scene"),this._list=e,this._scene=i}get color(){return this._list.ambientLight.color.value}set color(e){this._list.ambientLight.color.value=e;for(const[,t]of this._scene.ambientLights)t.color.copy(e)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(e){this._list.ambientLight.intensity.value=e;for(const[,t]of this._scene.ambientLights)t.intensity=e}}class Ki extends ji{constructor(){super(...arguments),t(this,"_config",{backgroundColor:{value:new i.Color,type:"Color"},ambientLight:{color:{type:"Color",value:new i.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new i.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new i.Vector3}}}),t(this,"ambientLight",new Qi(this._config,this._component)),t(this,"directionalLight",new qi(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(e){this._config.backgroundColor.value=e,this._component.three.background=e}}class Ji extends pi{constructor(e){super(e),t(this,"onSetup",new ai),t(this,"isSetup",!1),t(this,"three"),t(this,"config",new Ki(this,this.components,"Scene")),t(this,"_defaultConfig",{backgroundColor:new i.Color(2107698),directionalLight:{color:new i.Color("white"),intensity:1.5,position:new i.Vector3(5,10,3)},ambientLight:{color:new i.Color("white"),intensity:1}}),this.three=new i.Scene,this.three.background=new i.Color(2107698)}setup(e){const t={...this._defaultConfig,...e};this.config.backgroundColor=t.backgroundColor;const s=t.ambientLight;this.config.ambientLight.color=s.color,this.config.ambientLight.intensity=s.intensity;const n=t.directionalLight;this.config.directionalLight.color=n.color,this.config.directionalLight.intensity=n.intensity,this.config.directionalLight.position=n.position,this.deleteAllLights();const{color:r,intensity:o}=this.config.directionalLight,a=new i.DirectionalLight(r,o);a.position.copy(n.position);const{color:c,intensity:l}=this.config.directionalLight,h=new i.AmbientLight(c,l);this.three.add(a,h),this.directionalLights.set(a.uuid,a),this.ambientLights.set(h.uuid,h),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose();this.components.get($i).list.delete(this.config.uuid)}}class es extends di{constructor(e,s,n){super(e),t(this,"enabled",!0),t(this,"container"),t(this,"three"),t(this,"_canvas"),t(this,"_parameters"),t(this,"_resizeObserver",null),t(this,"onContainerUpdated",new ai),t(this,"_resizing",!1),t(this,"resize",(e=>{if(this._resizing)return;this._resizing=!0,this.onContainerUpdated.trigger();const t=e?e.x:this.container.clientWidth,s=e?e.y:this.container.clientHeight;this.three.setSize(t,s),this.onResize.trigger(new i.Vector2(t,s)),this._resizing=!1})),t(this,"resizeEvent",(()=>{this.resize()})),t(this,"onContextLost",(e=>{e.preventDefault(),this.enabled=!1})),t(this,"onContextBack",(()=>{this.three.setRenderTarget(null),this.three.dispose(),this.three=new i.WebGLRenderer({canvas:this._canvas,antialias:!0,alpha:!0,...this._parameters}),this.enabled=!0})),this.container=s,this._parameters=n,this.three=new i.WebGLRenderer({antialias:!0,alpha:!0,...n}),this.three.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.setupRenderer(),this.setupEvents(!0),this.resize(),this._canvas=this.three.domElement;const r=this.three.getContext(),{canvas:o}=r;o.addEventListener("webglcontextlost",this.onContextLost,!1),o.addEventListener("webglcontextrestored",this.onContextBack,!1)}update(){if(!this.enabled||!this.currentWorld)return;this.onBeforeUpdate.trigger(this);const e=this.currentWorld.scene.three,t=this.currentWorld.camera.three;this.three.render(e,t),this.onAfterUpdate.trigger(this)}dispose(){this.enabled=!1,this.setupEvents(!1),this.three.domElement.remove(),this.three.forceContextLoss(),this.three.dispose(),this.onResize.reset(),this.onAfterUpdate.reset(),this.onBeforeUpdate.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}getSize(){return new i.Vector2(this.three.domElement.clientWidth,this.three.domElement.clientHeight)}setupEvents(e){const t=this.three.domElement.parentElement;if(!t)throw new Error("This renderer needs to have an HTML container!");this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),window.removeEventListener("resize",this.resizeEvent),e&&(this._resizeObserver=new ResizeObserver(this.resizeEvent),this._resizeObserver.observe(t),window.addEventListener("resize",this.resizeEvent))}setupRenderer(){this.three.localClippingEnabled=!0,this.container&&this.container.appendChild(this.three.domElement),this.onContainerUpdated.trigger()}}
|
|
2
2
|
/*!
|
|
3
3
|
* camera-controls
|
|
4
4
|
* https://github.com/yomotsu/camera-controls
|
package/dist/index.mjs
CHANGED
|
@@ -5459,7 +5459,7 @@ const _Components = class _Components {
|
|
|
5459
5459
|
/**
|
|
5460
5460
|
* The version of the @thatopen/components library.
|
|
5461
5461
|
*/
|
|
5462
|
-
__publicField(_Components, "release", "2.4.
|
|
5462
|
+
__publicField(_Components, "release", "2.4.2");
|
|
5463
5463
|
let Components = _Components;
|
|
5464
5464
|
class SimpleWorld extends Base {
|
|
5465
5465
|
constructor() {
|