@thatopen/components 2.1.22 → 2.1.23
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/ifc/IfcRelationsIndexer/src/relToAttributesMap.d.ts +1 -1
- package/dist/ifc/IfcRelationsIndexer/src/types.d.ts +10 -2
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +166 -137
- package/dist/namespace.d.ts +2603 -2595
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";var qn=Object.defineProperty;var Kn=(l,s,t)=>s in l?qn(l,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[s]=t;var u=(l,s,t)=>(Kn(l,typeof s!="symbol"?s+"":s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("three"),pn=require("@thatopen/fragments"),$n=require("web-ifc");function Oi(l){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(s,t,e.get?e:{enumerable:!0,get:()=>l[t]})}}return s.default=l,Object.freeze(s)}const g=Oi(C),Dt=Oi(pn),x=Oi($n),Cn=0,Jn=1,to=2,Di=2,vs=1.25,xi=1,rs=6*4+4+4,Ns=65535,eo=Math.pow(2,-24),Bs=Symbol("SKIP_GENERATION");function so(l){return l.index?l.index.count:l.attributes.position.count}function he(l){return so(l)/3}function io(l,s=ArrayBuffer){return l>65535?new Uint32Array(new s(4*l)):new Uint16Array(new s(2*l))}function no(l,s){if(!l.index){const t=l.attributes.position.count,e=s.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=io(t,e);l.setIndex(new C.BufferAttribute(i,1));for(let o=0;o<t;o++)i[o]=o}}function Tn(l){const s=he(l),t=l.drawRange,e=t.start/3,i=(t.start+t.count)/3,o=Math.max(0,e),n=Math.min(s,i)-o;return[{offset:Math.floor(o),count:Math.floor(n)}]}function mn(l){if(!l.groups||!l.groups.length)return Tn(l);const s=[],t=new Set,e=l.drawRange,i=e.start/3,o=(e.start+e.count)/3;for(const r of l.groups){const a=r.start/3,c=(r.start+r.count)/3;t.add(Math.max(i,a)),t.add(Math.min(o,c))}const n=Array.from(t.values()).sort((r,a)=>r-a);for(let r=0;r<n.length-1;r++){const a=n[r],c=n[r+1];s.push({offset:Math.floor(a),count:Math.floor(c-a)})}return s}function oo(l){if(l.groups.length===0)return!1;const s=he(l),t=mn(l).sort((o,n)=>o.offset-n.offset),e=t[t.length-1];e.count=Math.min(s-e.offset,e.count);let i=0;return t.forEach(({count:o})=>i+=o),s!==i}function q(l,s,t){return t.min.x=s[l],t.min.y=s[l+1],t.min.z=s[l+2],t.max.x=s[l+3],t.max.y=s[l+4],t.max.z=s[l+5],t}function ro(l){l[0]=l[1]=l[2]=1/0,l[3]=l[4]=l[5]=-1/0}function Ui(l){let s=-1,t=-1/0;for(let e=0;e<3;e++){const i=l[e+3]-l[e];i>t&&(t=i,s=e)}return s}function bi(l,s){s.set(l)}function vi(l,s,t){let e,i;for(let o=0;o<3;o++){const n=o+3;e=l[o],i=s[o],t[o]=e<i?e:i,e=l[n],i=s[n],t[n]=e>i?e:i}}function ve(l,s,t){for(let e=0;e<3;e++){const i=s[l+2*e],o=s[l+2*e+1],n=i-o,r=i+o;n<t[e]&&(t[e]=n),r>t[e+3]&&(t[e+3]=r)}}function ue(l){const s=l[3]-l[0],t=l[4]-l[1],e=l[5]-l[2];return 2*(s*t+t*e+e*s)}function Vs(l,s,t,e,i=null){let o=1/0,n=1/0,r=1/0,a=-1/0,c=-1/0,h=-1/0,E=1/0,d=1/0,I=1/0,f=-1/0,T=-1/0,F=-1/0;const m=i!==null;for(let A=s*6,O=(s+t)*6;A<O;A+=6){const p=l[A+0],R=l[A+1],S=p-R,_=p+R;S<o&&(o=S),_>a&&(a=_),m&&p<E&&(E=p),m&&p>f&&(f=p);const y=l[A+2],N=l[A+3],P=y-N,D=y+N;P<n&&(n=P),D>c&&(c=D),m&&y<d&&(d=y),m&&y>T&&(T=y);const w=l[A+4],U=l[A+5],b=w-U,v=w+U;b<r&&(r=b),v>h&&(h=v),m&&w<I&&(I=w),m&&w>F&&(F=w)}e[0]=o,e[1]=n,e[2]=r,e[3]=a,e[4]=c,e[5]=h,m&&(i[0]=E,i[1]=d,i[2]=I,i[3]=f,i[4]=T,i[5]=F)}function ao(l,s,t,e){let i=1/0,o=1/0,n=1/0,r=-1/0,a=-1/0,c=-1/0;for(let h=s*6,E=(s+t)*6;h<E;h+=6){const d=l[h+0];d<i&&(i=d),d>r&&(r=d);const I=l[h+2];I<o&&(o=I),I>a&&(a=I);const f=l[h+4];f<n&&(n=f),f>c&&(c=f)}e[0]=i,e[1]=o,e[2]=n,e[3]=r,e[4]=a,e[5]=c}function co(l,s){ro(s);const t=l.attributes.position,e=l.index?l.index.array:null,i=he(l),o=new Float32Array(i*6),n=t.normalized,r=t.array,a=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const h=["getX","getY","getZ"];for(let E=0;E<i;E++){const d=E*3,I=E*6;let f=d+0,T=d+1,F=d+2;e&&(f=e[f],T=e[T],F=e[F]),n||(f=f*c+a,T=T*c+a,F=F*c+a);for(let m=0;m<3;m++){let A,O,p;n?(A=t[h[m]](f),O=t[h[m]](T),p=t[h[m]](F)):(A=r[f+m],O=r[T+m],p=r[F+m]);let R=A;O<R&&(R=O),p<R&&(R=p);let S=A;O>S&&(S=O),p>S&&(S=p);const _=(S-R)/2,y=m*2;o[I+y+0]=R+_,o[I+y+1]=_+(Math.abs(R)+_)*eo,R<s[m]&&(s[m]=R),S>s[m+3]&&(s[m+3]=S)}}return o}const Ot=32,lo=(l,s)=>l.candidate-s.candidate,yt=new Array(Ot).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Be=new Float32Array(6);function ho(l,s,t,e,i,o){let n=-1,r=0;if(o===Cn)n=Ui(s),n!==-1&&(r=(s[n]+s[n+3])/2);else if(o===Jn)n=Ui(l),n!==-1&&(r=Eo(t,e,i,n));else if(o===to){const a=ue(l);let c=vs*i;const h=e*6,E=(e+i)*6;for(let d=0;d<3;d++){const I=s[d],F=(s[d+3]-I)/Ot;if(i<Ot/4){const m=[...yt];m.length=i;let A=0;for(let p=h;p<E;p+=6,A++){const R=m[A];R.candidate=t[p+2*d],R.count=0;const{bounds:S,leftCacheBounds:_,rightCacheBounds:y}=R;for(let N=0;N<3;N++)y[N]=1/0,y[N+3]=-1/0,_[N]=1/0,_[N+3]=-1/0,S[N]=1/0,S[N+3]=-1/0;ve(p,t,S)}m.sort(lo);let O=i;for(let p=0;p<O;p++){const R=m[p];for(;p+1<O&&m[p+1].candidate===R.candidate;)m.splice(p+1,1),O--}for(let p=h;p<E;p+=6){const R=t[p+2*d];for(let S=0;S<O;S++){const _=m[S];R>=_.candidate?ve(p,t,_.rightCacheBounds):(ve(p,t,_.leftCacheBounds),_.count++)}}for(let p=0;p<O;p++){const R=m[p],S=R.count,_=i-R.count,y=R.leftCacheBounds,N=R.rightCacheBounds;let P=0;S!==0&&(P=ue(y)/a);let D=0;_!==0&&(D=ue(N)/a);const w=xi+vs*(P*S+D*_);w<c&&(n=d,c=w,r=R.candidate)}}else{for(let O=0;O<Ot;O++){const p=yt[O];p.count=0,p.candidate=I+F+O*F;const R=p.bounds;for(let S=0;S<3;S++)R[S]=1/0,R[S+3]=-1/0}for(let O=h;O<E;O+=6){let S=~~((t[O+2*d]-I)/F);S>=Ot&&(S=Ot-1);const _=yt[S];_.count++,ve(O,t,_.bounds)}const m=yt[Ot-1];bi(m.bounds,m.rightCacheBounds);for(let O=Ot-2;O>=0;O--){const p=yt[O],R=yt[O+1];vi(p.bounds,R.rightCacheBounds,p.rightCacheBounds)}let A=0;for(let O=0;O<Ot-1;O++){const p=yt[O],R=p.count,S=p.bounds,y=yt[O+1].rightCacheBounds;R!==0&&(A===0?bi(S,Be):vi(S,Be,Be)),A+=R;let N=0,P=0;A!==0&&(N=ue(Be)/a);const D=i-A;D!==0&&(P=ue(y)/a);const w=xi+vs*(N*A+P*D);w<c&&(n=d,c=w,r=p.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${o} used.`);return{axis:n,pos:r}}function Eo(l,s,t,e){let i=0;for(let o=s,n=s+t;o<n;o++)i+=l[o*6+e*2];return i/t}class Ve{constructor(){}}function uo(l,s,t,e,i,o){let n=e,r=e+i-1;const a=o.pos,c=o.axis*2;for(;;){for(;n<=r&&t[n*6+c]<a;)n++;for(;n<=r&&t[r*6+c]>=a;)r--;if(n<r){for(let h=0;h<3;h++){let E=s[n*3+h];s[n*3+h]=s[r*3+h],s[r*3+h]=E}for(let h=0;h<6;h++){let E=t[n*6+h];t[n*6+h]=t[r*6+h],t[r*6+h]=E}n++,r--}else return n}}function Io(l,s,t,e,i,o){let n=e,r=e+i-1;const a=o.pos,c=o.axis*2;for(;;){for(;n<=r&&t[n*6+c]<a;)n++;for(;n<=r&&t[r*6+c]>=a;)r--;if(n<r){let h=l[n];l[n]=l[r],l[r]=h;for(let E=0;E<6;E++){let d=t[n*6+E];t[n*6+E]=t[r*6+E],t[r*6+E]=d}n++,r--}else return n}}function fo(l,s){const t=(l.index?l.index.count:l.attributes.position.count)/3,e=t>2**16,i=e?4:2,o=s?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),n=e?new Uint32Array(o):new Uint16Array(o);for(let r=0,a=n.length;r<a;r++)n[r]=r;return n}function po(l,s){const t=l.geometry,e=t.index?t.index.array:null,i=s.maxDepth,o=s.verbose,n=s.maxLeafTris,r=s.strategy,a=s.onProgress,c=he(t),h=l._indirectBuffer;let E=!1;const d=new Float32Array(6),I=new Float32Array(6),f=co(t,d),T=s.indirect?Io:uo,F=[],m=s.indirect?Tn(t):mn(t);if(m.length===1){const p=m[0],R=new Ve;R.boundingData=d,ao(f,p.offset,p.count,I),O(R,p.offset,p.count,I),F.push(R)}else for(let p of m){const R=new Ve;R.boundingData=new Float32Array(6),Vs(f,p.offset,p.count,R.boundingData,I),O(R,p.offset,p.count,I),F.push(R)}return F;function A(p){a&&a(p/c)}function O(p,R,S,_=null,y=0){if(!E&&y>=i&&(E=!0,o&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),S<=n||y>=i)return A(R+S),p.offset=R,p.count=S,p;const N=ho(p.boundingData,_,f,R,S,r);if(N.axis===-1)return A(R+S),p.offset=R,p.count=S,p;const P=T(h,e,f,R,S,N);if(P===R||P===R+S)A(R+S),p.offset=R,p.count=S;else{p.splitAxis=N.axis;const D=new Ve,w=R,U=P-R;p.left=D,D.boundingData=new Float32Array(6),Vs(f,w,U,D.boundingData,I),O(D,w,U,I,y+1);const b=new Ve,v=P,z=S-U;p.right=b,b.boundingData=new Float32Array(6),Vs(f,v,z,b.boundingData,I),O(b,v,z,I,y+1)}return p}}function Co(l,s){const t=l.geometry;s.indirect&&(l._indirectBuffer=fo(t,s.useSharedArrayBuffer),oo(t)&&!s.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.')),l._indirectBuffer||no(t,s);const e=po(l,s);let i,o,n;const r=[],a=s.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let E=0;E<e.length;E++){const d=e[E];let I=c(d);const f=new a(rs*I);i=new Float32Array(f),o=new Uint32Array(f),n=new Uint16Array(f),h(0,d),r.push(f)}l._roots=r;return;function c(E){return E.count?1:1+c(E.left)+c(E.right)}function h(E,d){const I=E/4,f=E/2,T=!!d.count,F=d.boundingData;for(let m=0;m<6;m++)i[I+m]=F[m];if(T){const m=d.offset,A=d.count;return o[I+6]=m,n[f+14]=A,n[f+15]=Ns,E+rs}else{const m=d.left,A=d.right,O=d.splitAxis;let p;if(p=h(E+rs,m),p/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return o[I+6]=p/4,p=h(p,A),o[I+7]=O,p}}}class St{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(s,t){let e=1/0,i=-1/0;for(let o=0,n=s.length;o<n;o++){const a=s[o][t];e=a<e?a:e,i=a>i?a:i}this.min=e,this.max=i}setFromPoints(s,t){let e=1/0,i=-1/0;for(let o=0,n=t.length;o<n;o++){const r=t[o],a=s.dot(r);e=a<e?a:e,i=a>i?a:i}this.min=e,this.max=i}isSeparated(s){return this.min>s.max||s.min>this.max}}St.prototype.setFromBox=function(){const l=new C.Vector3;return function(t,e){const i=e.min,o=e.max;let n=1/0,r=-1/0;for(let a=0;a<=1;a++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){l.x=i.x*a+o.x*(1-a),l.y=i.y*c+o.y*(1-c),l.z=i.z*h+o.z*(1-h);const E=t.dot(l);n=Math.min(E,n),r=Math.max(E,r)}this.min=n,this.max=r}}();const To=function(){const l=new C.Vector3,s=new C.Vector3,t=new C.Vector3;return function(i,o,n){const r=i.start,a=l,c=o.start,h=s;t.subVectors(r,c),l.subVectors(i.end,i.start),s.subVectors(o.end,o.start);const E=t.dot(h),d=h.dot(a),I=h.dot(h),f=t.dot(a),F=a.dot(a)*I-d*d;let m,A;F!==0?m=(E*d-f*I)/F:m=0,A=(E+m*d)/I,n.x=m,n.y=A}}(),Si=function(){const l=new C.Vector2,s=new C.Vector3,t=new C.Vector3;return function(i,o,n,r){To(i,o,l);let a=l.x,c=l.y;if(a>=0&&a<=1&&c>=0&&c<=1){i.at(a,n),o.at(c,r);return}else if(a>=0&&a<=1){c<0?o.at(0,r):o.at(1,r),i.closestPointToPoint(r,!0,n);return}else if(c>=0&&c<=1){a<0?i.at(0,n):i.at(1,n),o.closestPointToPoint(n,!0,r);return}else{let h;a<0?h=i.start:h=i.end;let E;c<0?E=o.start:E=o.end;const d=s,I=t;if(i.closestPointToPoint(E,!0,s),o.closestPointToPoint(h,!0,t),d.distanceToSquared(E)<=I.distanceToSquared(h)){n.copy(d),r.copy(E);return}else{n.copy(h),r.copy(I);return}}}}(),mo=function(){const l=new C.Vector3,s=new C.Vector3,t=new C.Plane,e=new C.Line3;return function(o,n){const{radius:r,center:a}=o,{a:c,b:h,c:E}=n;if(e.start=c,e.end=h,e.closestPointToPoint(a,!0,l).distanceTo(a)<=r||(e.start=c,e.end=E,e.closestPointToPoint(a,!0,l).distanceTo(a)<=r)||(e.start=h,e.end=E,e.closestPointToPoint(a,!0,l).distanceTo(a)<=r))return!0;const T=n.getPlane(t);if(Math.abs(T.distanceToPoint(a))<=r){const m=T.projectPoint(a,s);if(n.containsPoint(m))return!0}return!1}}(),Ro=1e-15;function Ys(l){return Math.abs(l)<Ro}class mt extends C.Triangle{constructor(...s){super(...s),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new C.Vector3),this.satBounds=new Array(4).fill().map(()=>new St),this.points=[this.a,this.b,this.c],this.sphere=new C.Sphere,this.plane=new C.Plane,this.needsUpdate=!0}intersectsSphere(s){return mo(s,this)}update(){const s=this.a,t=this.b,e=this.c,i=this.points,o=this.satAxes,n=this.satBounds,r=o[0],a=n[0];this.getNormal(r),a.setFromPoints(r,i);const c=o[1],h=n[1];c.subVectors(s,t),h.setFromPoints(c,i);const E=o[2],d=n[2];E.subVectors(t,e),d.setFromPoints(E,i);const I=o[3],f=n[3];I.subVectors(e,s),f.setFromPoints(I,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(r,s),this.needsUpdate=!1}}mt.prototype.closestPointToSegment=function(){const l=new C.Vector3,s=new C.Vector3,t=new C.Line3;return function(i,o=null,n=null){const{start:r,end:a}=i,c=this.points;let h,E=1/0;for(let d=0;d<3;d++){const I=(d+1)%3;t.start.copy(c[d]),t.end.copy(c[I]),Si(t,i,l,s),h=l.distanceToSquared(s),h<E&&(E=h,o&&o.copy(l),n&&n.copy(s))}return this.closestPointToPoint(r,l),h=r.distanceToSquared(l),h<E&&(E=h,o&&o.copy(l),n&&n.copy(r)),this.closestPointToPoint(a,l),h=a.distanceToSquared(l),h<E&&(E=h,o&&o.copy(l),n&&n.copy(a)),Math.sqrt(E)}}();mt.prototype.intersectsTriangle=function(){const l=new mt,s=new Array(3),t=new Array(3),e=new St,i=new St,o=new C.Vector3,n=new C.Vector3,r=new C.Vector3,a=new C.Vector3,c=new C.Vector3,h=new C.Line3,E=new C.Line3,d=new C.Line3,I=new C.Vector3;function f(T,F,m){const A=T.points;let O=0,p=-1;for(let R=0;R<3;R++){const{start:S,end:_}=h;S.copy(A[R]),_.copy(A[(R+1)%3]),h.delta(n);const y=Ys(F.distanceToPoint(S));if(Ys(F.normal.dot(n))&&y){m.copy(h),O=2;break}const N=F.intersectLine(h,I);if(!N&&y&&I.copy(S),(N||y)&&!Ys(I.distanceTo(_))){if(O<=1)(O===1?m.start:m.end).copy(I),y&&(p=O);else if(O>=2){(p===1?m.start:m.end).copy(I),O=2;break}if(O++,O===2&&p===-1)break}}return O}return function(F,m=null,A=!1){this.needsUpdate&&this.update(),F.isExtendedTriangle?F.needsUpdate&&F.update():(l.copy(F),l.update(),F=l);const O=this.plane,p=F.plane;if(Math.abs(O.normal.dot(p.normal))>1-1e-10){const R=this.satBounds,S=this.satAxes;t[0]=F.a,t[1]=F.b,t[2]=F.c;for(let N=0;N<4;N++){const P=R[N],D=S[N];if(e.setFromPoints(D,t),P.isSeparated(e))return!1}const _=F.satBounds,y=F.satAxes;s[0]=this.a,s[1]=this.b,s[2]=this.c;for(let N=0;N<4;N++){const P=_[N],D=y[N];if(e.setFromPoints(D,s),P.isSeparated(e))return!1}for(let N=0;N<4;N++){const P=S[N];for(let D=0;D<4;D++){const w=y[D];if(o.crossVectors(P,w),e.setFromPoints(o,s),i.setFromPoints(o,t),e.isSeparated(i))return!1}}return m&&(A||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{const R=f(this,p,E);if(R===1&&F.containsPoint(E.end))return m&&(m.start.copy(E.end),m.end.copy(E.end)),!0;if(R!==2)return!1;const S=f(F,O,d);if(S===1&&this.containsPoint(d.end))return m&&(m.start.copy(d.end),m.end.copy(d.end)),!0;if(S!==2)return!1;if(E.delta(r),d.delta(a),r.dot(a)<0){let U=d.start;d.start=d.end,d.end=U}const _=E.start.dot(r),y=E.end.dot(r),N=d.start.dot(r),P=d.end.dot(r),D=y<N,w=_<P;return _!==P&&N!==y&&D===w?!1:(m&&(c.subVectors(E.start,d.start),c.dot(r)>0?m.start.copy(E.start):m.start.copy(d.start),c.subVectors(E.end,d.end),c.dot(r)<0?m.end.copy(E.end):m.end.copy(d.end)),!0)}}}();mt.prototype.distanceToPoint=function(){const l=new C.Vector3;return function(t){return this.closestPointToPoint(t,l),t.distanceTo(l)}}();mt.prototype.distanceToTriangle=function(){const l=new C.Vector3,s=new C.Vector3,t=["a","b","c"],e=new C.Line3,i=new C.Line3;return function(n,r=null,a=null){const c=r||a?e:null;if(this.intersectsTriangle(n,c))return(r||a)&&(r&&c.getCenter(r),a&&c.getCenter(a)),0;let h=1/0;for(let E=0;E<3;E++){let d;const I=t[E],f=n[I];this.closestPointToPoint(f,l),d=f.distanceToSquared(l),d<h&&(h=d,r&&r.copy(l),a&&a.copy(f));const T=this[I];n.closestPointToPoint(T,l),d=T.distanceToSquared(l),d<h&&(h=d,r&&r.copy(T),a&&a.copy(l))}for(let E=0;E<3;E++){const d=t[E],I=t[(E+1)%3];e.set(this[d],this[I]);for(let f=0;f<3;f++){const T=t[f],F=t[(f+1)%3];i.set(n[T],n[F]),Si(e,i,l,s);const m=l.distanceToSquared(s);m<h&&(h=m,r&&r.copy(l),a&&a.copy(s))}}return Math.sqrt(h)}}();class rt{constructor(s,t,e){this.isOrientedBox=!0,this.min=new C.Vector3,this.max=new C.Vector3,this.matrix=new C.Matrix4,this.invMatrix=new C.Matrix4,this.points=new Array(8).fill().map(()=>new C.Vector3),this.satAxes=new Array(3).fill().map(()=>new C.Vector3),this.satBounds=new Array(3).fill().map(()=>new St),this.alignedSatBounds=new Array(3).fill().map(()=>new St),this.needsUpdate=!1,s&&this.min.copy(s),t&&this.max.copy(t),e&&this.matrix.copy(e)}set(s,t,e){this.min.copy(s),this.max.copy(t),this.matrix.copy(e),this.needsUpdate=!0}copy(s){this.min.copy(s.min),this.max.copy(s.max),this.matrix.copy(s.matrix),this.needsUpdate=!0}}rt.prototype.update=function(){return function(){const s=this.matrix,t=this.min,e=this.max,i=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let E=0;E<=1;E++){const d=1*c|2*h|4*E,I=i[d];I.x=c?e.x:t.x,I.y=h?e.y:t.y,I.z=E?e.z:t.z,I.applyMatrix4(s)}const o=this.satBounds,n=this.satAxes,r=i[0];for(let c=0;c<3;c++){const h=n[c],E=o[c],d=1<<c,I=i[d];h.subVectors(r,I),E.setFromPoints(h,i)}const a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();rt.prototype.intersectsBox=function(){const l=new St;return function(t){this.needsUpdate&&this.update();const e=t.min,i=t.max,o=this.satBounds,n=this.satAxes,r=this.alignedSatBounds;if(l.min=e.x,l.max=i.x,r[0].isSeparated(l)||(l.min=e.y,l.max=i.y,r[1].isSeparated(l))||(l.min=e.z,l.max=i.z,r[2].isSeparated(l)))return!1;for(let a=0;a<3;a++){const c=n[a],h=o[a];if(l.setFromBox(c,t),h.isSeparated(l))return!1}return!0}}();rt.prototype.intersectsTriangle=function(){const l=new mt,s=new Array(3),t=new St,e=new St,i=new C.Vector3;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(l.copy(n),l.update(),n=l);const r=this.satBounds,a=this.satAxes;s[0]=n.a,s[1]=n.b,s[2]=n.c;for(let d=0;d<3;d++){const I=r[d],f=a[d];if(t.setFromPoints(f,s),I.isSeparated(t))return!1}const c=n.satBounds,h=n.satAxes,E=this.points;for(let d=0;d<3;d++){const I=c[d],f=h[d];if(t.setFromPoints(f,E),I.isSeparated(t))return!1}for(let d=0;d<3;d++){const I=a[d];for(let f=0;f<4;f++){const T=h[f];if(i.crossVectors(I,T),t.setFromPoints(i,s),e.setFromPoints(i,E),t.isSeparated(e))return!1}}return!0}}();rt.prototype.closestPointToPoint=function(){return function(s,t){return this.needsUpdate&&this.update(),t.copy(s).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();rt.prototype.distanceToPoint=function(){const l=new C.Vector3;return function(t){return this.closestPointToPoint(t,l),t.distanceTo(l)}}();rt.prototype.distanceToBox=function(){const l=["x","y","z"],s=new Array(12).fill().map(()=>new C.Line3),t=new Array(12).fill().map(()=>new C.Line3),e=new C.Vector3,i=new C.Vector3;return function(n,r=0,a=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(a||c)&&(n.getCenter(i),this.closestPointToPoint(i,e),n.closestPointToPoint(e,i),a&&a.copy(e),c&&c.copy(i)),0;const h=r*r,E=n.min,d=n.max,I=this.points;let f=1/0;for(let F=0;F<8;F++){const m=I[F];i.copy(m).clamp(E,d);const A=m.distanceToSquared(i);if(A<f&&(f=A,a&&a.copy(m),c&&c.copy(i),A<h))return Math.sqrt(A)}let T=0;for(let F=0;F<3;F++)for(let m=0;m<=1;m++)for(let A=0;A<=1;A++){const O=(F+1)%3,p=(F+2)%3,R=m<<O|A<<p,S=1<<F|m<<O|A<<p,_=I[R],y=I[S];s[T].set(_,y);const P=l[F],D=l[O],w=l[p],U=t[T],b=U.start,v=U.end;b[P]=E[P],b[D]=m?E[D]:d[D],b[w]=A?E[w]:d[D],v[P]=d[P],v[D]=m?E[D]:d[D],v[w]=A?E[w]:d[D],T++}for(let F=0;F<=1;F++)for(let m=0;m<=1;m++)for(let A=0;A<=1;A++){i.x=F?d.x:E.x,i.y=m?d.y:E.y,i.z=A?d.z:E.z,this.closestPointToPoint(i,e);const O=i.distanceToSquared(e);if(O<f&&(f=O,a&&a.copy(e),c&&c.copy(i),O<h))return Math.sqrt(O)}for(let F=0;F<12;F++){const m=s[F];for(let A=0;A<12;A++){const O=t[A];Si(m,O,e,i);const p=e.distanceToSquared(i);if(p<f&&(f=p,a&&a.copy(e),c&&c.copy(i),p<h))return Math.sqrt(p)}}return Math.sqrt(f)}}();class _i{constructor(s){this._getNewPrimitive=s,this._primitives=[]}getPrimitive(){const s=this._primitives;return s.length===0?this._getNewPrimitive():s.pop()}releasePrimitive(s){this._primitives.push(s)}}class Fo extends _i{constructor(){super(()=>new mt)}}const dt=new Fo;function ct(l,s){return s[l+15]===65535}function lt(l,s){return s[l+6]}function Et(l,s){return s[l+14]}function ut(l){return l+8}function It(l,s){return s[l+6]}function Rn(l,s){return s[l+7]}class Ao{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const s=[];let t=null;this.setBuffer=e=>{t&&s.push(t),t=e,this.float32Array=new Float32Array(e),this.uint16Array=new Uint16Array(e),this.uint32Array=new Uint32Array(e)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,s.length!==0&&this.setBuffer(s.pop())}}}const X=new Ao;let Mt,re;const Xt=[],Ye=new _i(()=>new C.Box3);function go(l,s,t,e,i,o){Mt=Ye.getPrimitive(),re=Ye.getPrimitive(),Xt.push(Mt,re),X.setBuffer(l._roots[s]);const n=ni(0,l.geometry,t,e,i,o);X.clearBuffer(),Ye.releasePrimitive(Mt),Ye.releasePrimitive(re),Xt.pop(),Xt.pop();const r=Xt.length;return r>0&&(re=Xt[r-1],Mt=Xt[r-2]),n}function ni(l,s,t,e,i=null,o=0,n=0){const{float32Array:r,uint16Array:a,uint32Array:c}=X;let h=l*2;if(ct(h,a)){const d=lt(l,c),I=Et(h,a);return q(l,r,Mt),e(d,I,!1,n,o+l,Mt)}else{let P=function(w){const{uint16Array:U,uint32Array:b}=X;let v=w*2;for(;!ct(v,U);)w=ut(w),v=w*2;return lt(w,b)},D=function(w){const{uint16Array:U,uint32Array:b}=X;let v=w*2;for(;!ct(v,U);)w=It(w,b),v=w*2;return lt(w,b)+Et(v,U)};const d=ut(l),I=It(l,c);let f=d,T=I,F,m,A,O;if(i&&(A=Mt,O=re,q(f,r,A),q(T,r,O),F=i(A),m=i(O),m<F)){f=I,T=d;const w=F;F=m,m=w,A=O}A||(A=Mt,q(f,r,A));const p=ct(f*2,a),R=t(A,p,F,n+1,o+f);let S;if(R===Di){const w=P(f),b=D(f)-w;S=e(w,b,!0,n+1,o+f,A)}else S=R&&ni(f,s,t,e,i,o,n+1);if(S)return!0;O=re,q(T,r,O);const _=ct(T*2,a),y=t(O,_,m,n+1,o+T);let N;if(y===Di){const w=P(T),b=D(T)-w;N=e(w,b,!0,n+1,o+T,O)}else N=y&&ni(T,s,t,e,i,o,n+1);return!!N}}const Ie=new C.Vector3,Gs=new C.Vector3;function Oo(l,s,t={},e=0,i=1/0){const o=e*e,n=i*i;let r=1/0,a=null;if(l.shapecast({boundsTraverseOrder:h=>(Ie.copy(s).clamp(h.min,h.max),Ie.distanceToSquared(s)),intersectsBounds:(h,E,d)=>d<r&&d<n,intersectsTriangle:(h,E)=>{h.closestPointToPoint(s,Ie);const d=s.distanceToSquared(Ie);return d<r&&(Gs.copy(Ie),r=d,a=E),d<o}}),r===1/0)return null;const c=Math.sqrt(r);return t.point?t.point.copy(Gs):t.point=Gs.clone(),t.distance=c,t.faceIndex=a,t}const Zt=new C.Vector3,Qt=new C.Vector3,jt=new C.Vector3,Ge=new C.Vector2,ze=new C.Vector2,He=new C.Vector2,Bi=new C.Vector3,Vi=new C.Vector3,Yi=new C.Vector3,We=new C.Vector3;function So(l,s,t,e,i,o){let n;return o===C.BackSide?n=l.intersectTriangle(e,t,s,!0,i):n=l.intersectTriangle(s,t,e,o!==C.DoubleSide,i),n===null?null:{distance:l.origin.distanceTo(i),point:i.clone()}}function _o(l,s,t,e,i,o,n,r,a){Zt.fromBufferAttribute(s,o),Qt.fromBufferAttribute(s,n),jt.fromBufferAttribute(s,r);const c=So(l,Zt,Qt,jt,We,a);if(c){e&&(Ge.fromBufferAttribute(e,o),ze.fromBufferAttribute(e,n),He.fromBufferAttribute(e,r),c.uv=C.Triangle.getInterpolation(We,Zt,Qt,jt,Ge,ze,He,new C.Vector2)),i&&(Ge.fromBufferAttribute(i,o),ze.fromBufferAttribute(i,n),He.fromBufferAttribute(i,r),c.uv1=C.Triangle.getInterpolation(We,Zt,Qt,jt,Ge,ze,He,new C.Vector2)),t&&(Bi.fromBufferAttribute(t,o),Vi.fromBufferAttribute(t,n),Yi.fromBufferAttribute(t,r),c.normal=C.Triangle.getInterpolation(We,Zt,Qt,jt,Bi,Vi,Yi,new C.Vector3),c.normal.dot(l.direction)>0&&c.normal.multiplyScalar(-1));const h={a:o,b:n,c:r,normal:new C.Vector3,materialIndex:0};C.Triangle.getNormal(Zt,Qt,jt,h.normal),c.face=h,c.faceIndex=o}return c}function Ls(l,s,t,e,i){const o=e*3;let n=o+0,r=o+1,a=o+2;const c=l.index;l.index&&(n=c.getX(n),r=c.getX(r),a=c.getX(a));const{position:h,normal:E,uv:d,uv1:I}=l.attributes,f=_o(t,h,E,d,I,n,r,a,s);return f?(f.faceIndex=e,i&&i.push(f),f):null}function tt(l,s,t,e){const i=l.a,o=l.b,n=l.c;let r=s,a=s+1,c=s+2;t&&(r=t.getX(r),a=t.getX(a),c=t.getX(c)),i.x=e.getX(r),i.y=e.getY(r),i.z=e.getZ(r),o.x=e.getX(a),o.y=e.getY(a),o.z=e.getZ(a),n.x=e.getX(c),n.y=e.getY(c),n.z=e.getZ(c)}function yo(l,s,t,e,i,o){const{geometry:n,_indirectBuffer:r}=l;for(let a=e,c=e+i;a<c;a++)Ls(n,s,t,a,o)}function No(l,s,t,e,i){const{geometry:o,_indirectBuffer:n}=l;let r=1/0,a=null;for(let c=e,h=e+i;c<h;c++){let E;E=Ls(o,s,t,c),E&&E.distance<r&&(a=E,r=E.distance)}return a}function Lo(l,s,t,e,i,o,n){const{geometry:r}=t,{index:a}=r,c=r.attributes.position;for(let h=l,E=s+l;h<E;h++){let d;if(d=h,tt(n,d*3,a,c),n.needsUpdate=!0,e(n,d,i,o))return!0}return!1}function Po(l,s=null){s&&Array.isArray(s)&&(s=new Set(s));const t=l.geometry,e=t.index?t.index.array:null,i=t.attributes.position;let o,n,r,a,c=0;const h=l._roots;for(let d=0,I=h.length;d<I;d++)o=h[d],n=new Uint32Array(o),r=new Uint16Array(o),a=new Float32Array(o),E(0,c),c+=o.byteLength;function E(d,I,f=!1){const T=d*2;if(r[T+15]===Ns){const m=n[d+6],A=r[T+14];let O=1/0,p=1/0,R=1/0,S=-1/0,_=-1/0,y=-1/0;for(let N=3*m,P=3*(m+A);N<P;N++){let D=e[N];const w=i.getX(D),U=i.getY(D),b=i.getZ(D);w<O&&(O=w),w>S&&(S=w),U<p&&(p=U),U>_&&(_=U),b<R&&(R=b),b>y&&(y=b)}return a[d+0]!==O||a[d+1]!==p||a[d+2]!==R||a[d+3]!==S||a[d+4]!==_||a[d+5]!==y?(a[d+0]=O,a[d+1]=p,a[d+2]=R,a[d+3]=S,a[d+4]=_,a[d+5]=y,!0):!1}else{const m=d+8,A=n[d+6],O=m+I,p=A+I;let R=f,S=!1,_=!1;s?R||(S=s.has(O),_=s.has(p),R=!S&&!_):(S=!0,_=!0);const y=R||S,N=R||_;let P=!1;y&&(P=E(m,I,R));let D=!1;N&&(D=E(A,I,R));const w=P||D;if(w)for(let U=0;U<3;U++){const b=m+U,v=A+U,z=a[b],j=a[b+3],et=a[v],Z=a[v+3];a[d+U]=z<et?z:et,a[d+U+3]=j>Z?j:Z}return w}}}const Gi=new C.Box3;function Ut(l,s,t,e){return q(l,s,Gi),t.intersectBox(Gi,e)}function wo(l,s,t,e,i,o){const{geometry:n,_indirectBuffer:r}=l;for(let a=e,c=e+i;a<c;a++){let h=r?r[a]:a;Ls(n,s,t,h,o)}}function Mo(l,s,t,e,i){const{geometry:o,_indirectBuffer:n}=l;let r=1/0,a=null;for(let c=e,h=e+i;c<h;c++){let E;E=Ls(o,s,t,n?n[c]:c),E&&E.distance<r&&(a=E,r=E.distance)}return a}function Do(l,s,t,e,i,o,n){const{geometry:r}=t,{index:a}=r,c=r.attributes.position;for(let h=l,E=s+l;h<E;h++){let d;if(d=t.resolveTriangleIndex(h),tt(n,d*3,a,c),n.needsUpdate=!0,e(n,d,i,o))return!0}return!1}const zi=new C.Vector3;function xo(l,s,t,e,i){X.setBuffer(l._roots[s]),oi(0,l,t,e,i),X.clearBuffer()}function oi(l,s,t,e,i){const{float32Array:o,uint16Array:n,uint32Array:r}=X,a=l*2;if(ct(a,n)){const h=lt(l,r),E=Et(a,n);yo(s,t,e,h,E,i)}else{const h=ut(l);Ut(h,o,e,zi)&&oi(h,s,t,e,i);const E=It(l,r);Ut(E,o,e,zi)&&oi(E,s,t,e,i)}}const Hi=new C.Vector3,Uo=["x","y","z"];function bo(l,s,t,e){X.setBuffer(l._roots[s]);const i=ri(0,l,t,e);return X.clearBuffer(),i}function ri(l,s,t,e){const{float32Array:i,uint16Array:o,uint32Array:n}=X;let r=l*2;if(ct(r,o)){const c=lt(l,n),h=Et(r,o);return No(s,t,e,c,h)}else{const c=Rn(l,n),h=Uo[c],d=e.direction[h]>=0;let I,f;d?(I=ut(l),f=It(l,n)):(I=It(l,n),f=ut(l));const F=Ut(I,i,e,Hi)?ri(I,s,t,e):null;if(F){const O=F.point[h];if(d?O<=i[f+c]:O>=i[f+c+3])return F}const A=Ut(f,i,e,Hi)?ri(f,s,t,e):null;return F&&A?F.distance<=A.distance?F:A:F||A||null}}const ke=new C.Box3,qt=new mt,Kt=new mt,fe=new C.Matrix4,Wi=new rt,Xe=new rt;function vo(l,s,t,e){X.setBuffer(l._roots[s]);const i=ai(0,l,t,e);return X.clearBuffer(),i}function ai(l,s,t,e,i=null){const{float32Array:o,uint16Array:n,uint32Array:r}=X;let a=l*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Wi.set(t.boundingBox.min,t.boundingBox.max,e),i=Wi),ct(a,n)){const h=s.geometry,E=h.index,d=h.attributes.position,I=t.index,f=t.attributes.position,T=lt(l,r),F=Et(a,n);if(fe.copy(e).invert(),t.boundsTree)return q(l,o,Xe),Xe.matrix.copy(fe),Xe.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:A=>Xe.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(e),A.b.applyMatrix4(e),A.c.applyMatrix4(e),A.needsUpdate=!0;for(let O=T*3,p=(F+T)*3;O<p;O+=3)if(tt(Kt,O,E,d),Kt.needsUpdate=!0,A.intersectsTriangle(Kt))return!0;return!1}});for(let m=T*3,A=(F+T)*3;m<A;m+=3){tt(qt,m,E,d),qt.a.applyMatrix4(fe),qt.b.applyMatrix4(fe),qt.c.applyMatrix4(fe),qt.needsUpdate=!0;for(let O=0,p=I.count;O<p;O+=3)if(tt(Kt,O,I,f),Kt.needsUpdate=!0,qt.intersectsTriangle(Kt))return!0}}else{const h=l+8,E=r[l+6];return q(h,o,ke),!!(i.intersectsBox(ke)&&ai(h,s,t,e,i)||(q(E,o,ke),i.intersectsBox(ke)&&ai(E,s,t,e,i)))}}const Ze=new C.Matrix4,zs=new rt,pe=new rt,Bo=new C.Vector3,Vo=new C.Vector3,Yo=new C.Vector3,Go=new C.Vector3;function zo(l,s,t,e={},i={},o=0,n=1/0){s.boundingBox||s.computeBoundingBox(),zs.set(s.boundingBox.min,s.boundingBox.max,t),zs.needsUpdate=!0;const r=l.geometry,a=r.attributes.position,c=r.index,h=s.attributes.position,E=s.index,d=dt.getPrimitive(),I=dt.getPrimitive();let f=Bo,T=Vo,F=null,m=null;i&&(F=Yo,m=Go);let A=1/0,O=null,p=null;return Ze.copy(t).invert(),pe.matrix.copy(Ze),l.shapecast({boundsTraverseOrder:R=>zs.distanceToBox(R),intersectsBounds:(R,S,_)=>_<A&&_<n?(S&&(pe.min.copy(R.min),pe.max.copy(R.max),pe.needsUpdate=!0),!0):!1,intersectsRange:(R,S)=>{if(s.boundsTree)return s.boundsTree.shapecast({boundsTraverseOrder:y=>pe.distanceToBox(y),intersectsBounds:(y,N,P)=>P<A&&P<n,intersectsRange:(y,N)=>{for(let P=y,D=y+N;P<D;P++){tt(I,3*P,E,h),I.a.applyMatrix4(t),I.b.applyMatrix4(t),I.c.applyMatrix4(t),I.needsUpdate=!0;for(let w=R,U=R+S;w<U;w++){tt(d,3*w,c,a),d.needsUpdate=!0;const b=d.distanceToTriangle(I,f,F);if(b<A&&(T.copy(f),m&&m.copy(F),A=b,O=w,p=P),b<o)return!0}}}});{const _=he(s);for(let y=0,N=_;y<N;y++){tt(I,3*y,E,h),I.a.applyMatrix4(t),I.b.applyMatrix4(t),I.c.applyMatrix4(t),I.needsUpdate=!0;for(let P=R,D=R+S;P<D;P++){tt(d,3*P,c,a),d.needsUpdate=!0;const w=d.distanceToTriangle(I,f,F);if(w<A&&(T.copy(f),m&&m.copy(F),A=w,O=P,p=y),w<o)return!0}}}}}),dt.releasePrimitive(d),dt.releasePrimitive(I),A===1/0?null:(e.point?e.point.copy(T):e.point=T.clone(),e.distance=A,e.faceIndex=O,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Ze),T.applyMatrix4(Ze),i.distance=T.sub(i.point).length(),i.faceIndex=p),e)}function Ho(l,s=null){s&&Array.isArray(s)&&(s=new Set(s));const t=l.geometry,e=t.index?t.index.array:null,i=t.attributes.position;let o,n,r,a,c=0;const h=l._roots;for(let d=0,I=h.length;d<I;d++)o=h[d],n=new Uint32Array(o),r=new Uint16Array(o),a=new Float32Array(o),E(0,c),c+=o.byteLength;function E(d,I,f=!1){const T=d*2;if(r[T+15]===Ns){const m=n[d+6],A=r[T+14];let O=1/0,p=1/0,R=1/0,S=-1/0,_=-1/0,y=-1/0;for(let N=m,P=m+A;N<P;N++){const D=3*l.resolveTriangleIndex(N);for(let w=0;w<3;w++){let U=D+w;U=e?e[U]:U;const b=i.getX(U),v=i.getY(U),z=i.getZ(U);b<O&&(O=b),b>S&&(S=b),v<p&&(p=v),v>_&&(_=v),z<R&&(R=z),z>y&&(y=z)}}return a[d+0]!==O||a[d+1]!==p||a[d+2]!==R||a[d+3]!==S||a[d+4]!==_||a[d+5]!==y?(a[d+0]=O,a[d+1]=p,a[d+2]=R,a[d+3]=S,a[d+4]=_,a[d+5]=y,!0):!1}else{const m=d+8,A=n[d+6],O=m+I,p=A+I;let R=f,S=!1,_=!1;s?R||(S=s.has(O),_=s.has(p),R=!S&&!_):(S=!0,_=!0);const y=R||S,N=R||_;let P=!1;y&&(P=E(m,I,R));let D=!1;N&&(D=E(A,I,R));const w=P||D;if(w)for(let U=0;U<3;U++){const b=m+U,v=A+U,z=a[b],j=a[b+3],et=a[v],Z=a[v+3];a[d+U]=z<et?z:et,a[d+U+3]=j>Z?j:Z}return w}}}const ki=new C.Vector3;function Wo(l,s,t,e,i){X.setBuffer(l._roots[s]),ci(0,l,t,e,i),X.clearBuffer()}function ci(l,s,t,e,i){const{float32Array:o,uint16Array:n,uint32Array:r}=X,a=l*2;if(ct(a,n)){const h=lt(l,r),E=Et(a,n);wo(s,t,e,h,E,i)}else{const h=ut(l);Ut(h,o,e,ki)&&ci(h,s,t,e,i);const E=It(l,r);Ut(E,o,e,ki)&&ci(E,s,t,e,i)}}const Xi=new C.Vector3,ko=["x","y","z"];function Xo(l,s,t,e){X.setBuffer(l._roots[s]);const i=li(0,l,t,e);return X.clearBuffer(),i}function li(l,s,t,e){const{float32Array:i,uint16Array:o,uint32Array:n}=X;let r=l*2;if(ct(r,o)){const c=lt(l,n),h=Et(r,o);return Mo(s,t,e,c,h)}else{const c=Rn(l,n),h=ko[c],d=e.direction[h]>=0;let I,f;d?(I=ut(l),f=It(l,n)):(I=It(l,n),f=ut(l));const F=Ut(I,i,e,Xi)?li(I,s,t,e):null;if(F){const O=F.point[h];if(d?O<=i[f+c]:O>=i[f+c+3])return F}const A=Ut(f,i,e,Xi)?li(f,s,t,e):null;return F&&A?F.distance<=A.distance?F:A:F||A||null}}const Qe=new C.Box3,$t=new mt,Jt=new mt,Ce=new C.Matrix4,Zi=new rt,je=new rt;function Zo(l,s,t,e){X.setBuffer(l._roots[s]);const i=hi(0,l,t,e);return X.clearBuffer(),i}function hi(l,s,t,e,i=null){const{float32Array:o,uint16Array:n,uint32Array:r}=X;let a=l*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Zi.set(t.boundingBox.min,t.boundingBox.max,e),i=Zi),ct(a,n)){const h=s.geometry,E=h.index,d=h.attributes.position,I=t.index,f=t.attributes.position,T=lt(l,r),F=Et(a,n);if(Ce.copy(e).invert(),t.boundsTree)return q(l,o,je),je.matrix.copy(Ce),je.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:A=>je.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(e),A.b.applyMatrix4(e),A.c.applyMatrix4(e),A.needsUpdate=!0;for(let O=T,p=F+T;O<p;O++)if(tt(Jt,3*s.resolveTriangleIndex(O),E,d),Jt.needsUpdate=!0,A.intersectsTriangle(Jt))return!0;return!1}});for(let m=T,A=F+T;m<A;m++){const O=s.resolveTriangleIndex(m);tt($t,3*O,E,d),$t.a.applyMatrix4(Ce),$t.b.applyMatrix4(Ce),$t.c.applyMatrix4(Ce),$t.needsUpdate=!0;for(let p=0,R=I.count;p<R;p+=3)if(tt(Jt,p,I,f),Jt.needsUpdate=!0,$t.intersectsTriangle(Jt))return!0}}else{const h=l+8,E=r[l+6];return q(h,o,Qe),!!(i.intersectsBox(Qe)&&hi(h,s,t,e,i)||(q(E,o,Qe),i.intersectsBox(Qe)&&hi(E,s,t,e,i)))}}const qe=new C.Matrix4,Hs=new rt,Te=new rt,Qo=new C.Vector3,jo=new C.Vector3,qo=new C.Vector3,Ko=new C.Vector3;function $o(l,s,t,e={},i={},o=0,n=1/0){s.boundingBox||s.computeBoundingBox(),Hs.set(s.boundingBox.min,s.boundingBox.max,t),Hs.needsUpdate=!0;const r=l.geometry,a=r.attributes.position,c=r.index,h=s.attributes.position,E=s.index,d=dt.getPrimitive(),I=dt.getPrimitive();let f=Qo,T=jo,F=null,m=null;i&&(F=qo,m=Ko);let A=1/0,O=null,p=null;return qe.copy(t).invert(),Te.matrix.copy(qe),l.shapecast({boundsTraverseOrder:R=>Hs.distanceToBox(R),intersectsBounds:(R,S,_)=>_<A&&_<n?(S&&(Te.min.copy(R.min),Te.max.copy(R.max),Te.needsUpdate=!0),!0):!1,intersectsRange:(R,S)=>{if(s.boundsTree){const _=s.boundsTree;return _.shapecast({boundsTraverseOrder:y=>Te.distanceToBox(y),intersectsBounds:(y,N,P)=>P<A&&P<n,intersectsRange:(y,N)=>{for(let P=y,D=y+N;P<D;P++){const w=_.resolveTriangleIndex(P);tt(I,3*w,E,h),I.a.applyMatrix4(t),I.b.applyMatrix4(t),I.c.applyMatrix4(t),I.needsUpdate=!0;for(let U=R,b=R+S;U<b;U++){const v=l.resolveTriangleIndex(U);tt(d,3*v,c,a),d.needsUpdate=!0;const z=d.distanceToTriangle(I,f,F);if(z<A&&(T.copy(f),m&&m.copy(F),A=z,O=U,p=P),z<o)return!0}}}})}else{const _=he(s);for(let y=0,N=_;y<N;y++){tt(I,3*y,E,h),I.a.applyMatrix4(t),I.b.applyMatrix4(t),I.c.applyMatrix4(t),I.needsUpdate=!0;for(let P=R,D=R+S;P<D;P++){const w=l.resolveTriangleIndex(P);tt(d,3*w,c,a),d.needsUpdate=!0;const U=d.distanceToTriangle(I,f,F);if(U<A&&(T.copy(f),m&&m.copy(F),A=U,O=P,p=y),U<o)return!0}}}}}),dt.releasePrimitive(d),dt.releasePrimitive(I),A===1/0?null:(e.point?e.point.copy(T):e.point=T.clone(),e.distance=A,e.faceIndex=O,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(qe),T.applyMatrix4(qe),i.distance=T.sub(i.point).length(),i.faceIndex=p),e)}function Jo(){return typeof SharedArrayBuffer<"u"}const Ne=new X.constructor,ls=new X.constructor,Pt=new _i(()=>new C.Box3),te=new C.Box3,ee=new C.Box3,Ws=new C.Box3,ks=new C.Box3;let Xs=!1;function tr(l,s,t,e){if(Xs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Xs=!0;const i=l._roots,o=s._roots;let n,r=0,a=0;const c=new C.Matrix4().copy(t).invert();for(let h=0,E=i.length;h<E;h++){Ne.setBuffer(i[h]),a=0;const d=Pt.getPrimitive();q(0,Ne.float32Array,d),d.applyMatrix4(c);for(let I=0,f=o.length;I<f&&(ls.setBuffer(o[h]),n=ft(0,0,t,c,e,r,a,0,0,d),ls.clearBuffer(),a+=o[I].length,!n);I++);if(Pt.releasePrimitive(d),Ne.clearBuffer(),r+=i[h].length,n)break}return Xs=!1,n}function ft(l,s,t,e,i,o=0,n=0,r=0,a=0,c=null,h=!1){let E,d;h?(E=ls,d=Ne):(E=Ne,d=ls);const I=E.float32Array,f=E.uint32Array,T=E.uint16Array,F=d.float32Array,m=d.uint32Array,A=d.uint16Array,O=l*2,p=s*2,R=ct(O,T),S=ct(p,A);let _=!1;if(S&&R)h?_=i(lt(s,m),Et(s*2,A),lt(l,f),Et(l*2,T),a,n+s,r,o+l):_=i(lt(l,f),Et(l*2,T),lt(s,m),Et(s*2,A),r,o+l,a,n+s);else if(S){const y=Pt.getPrimitive();q(s,F,y),y.applyMatrix4(t);const N=ut(l),P=It(l,f);q(N,I,te),q(P,I,ee);const D=y.intersectsBox(te),w=y.intersectsBox(ee);_=D&&ft(s,N,e,t,i,n,o,a,r+1,y,!h)||w&&ft(s,P,e,t,i,n,o,a,r+1,y,!h),Pt.releasePrimitive(y)}else{const y=ut(s),N=It(s,m);q(y,F,Ws),q(N,F,ks);const P=c.intersectsBox(Ws),D=c.intersectsBox(ks);if(P&&D)_=ft(l,y,t,e,i,o,n,r,a+1,c,h)||ft(l,N,t,e,i,o,n,r,a+1,c,h);else if(P)if(R)_=ft(l,y,t,e,i,o,n,r,a+1,c,h);else{const w=Pt.getPrimitive();w.copy(Ws).applyMatrix4(t);const U=ut(l),b=It(l,f);q(U,I,te),q(b,I,ee);const v=w.intersectsBox(te),z=w.intersectsBox(ee);_=v&&ft(y,U,e,t,i,n,o,a,r+1,w,!h)||z&&ft(y,b,e,t,i,n,o,a,r+1,w,!h),Pt.releasePrimitive(w)}else if(D)if(R)_=ft(l,N,t,e,i,o,n,r,a+1,c,h);else{const w=Pt.getPrimitive();w.copy(ks).applyMatrix4(t);const U=ut(l),b=It(l,f);q(U,I,te),q(b,I,ee);const v=w.intersectsBox(te),z=w.intersectsBox(ee);_=v&&ft(N,U,e,t,i,n,o,a,r+1,w,!h)||z&&ft(N,b,e,t,i,n,o,a,r+1,w,!h),Pt.releasePrimitive(w)}}return _}const Ke=new rt,Qi=new C.Box3;class yi{static serialize(s,t={}){t={cloneBuffers:!0,...t};const e=s.geometry,i=s._roots,o=s._indirectBuffer,n=e.getIndex();let r;return t.cloneBuffers?r={roots:i.map(a=>a.slice()),index:n.array.slice(),indirectBuffer:o?o.slice():null}:r={roots:i,index:n.array,indirectBuffer:o},r}static deserialize(s,t,e={}){e={setIndex:!0,indirect:!!s.indirectBuffer,...e};const{index:i,roots:o,indirectBuffer:n}=s,r=new yi(t,{...e,[Bs]:!0});if(r._roots=o,r._indirectBuffer=n||null,e.setIndex){const a=t.getIndex();if(a===null){const c=new C.BufferAttribute(s.index,1,!1);t.setIndex(c)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return r}get indirect(){return!!this._indirectBuffer}constructor(s,t={}){if(s.isBufferGeometry){if(s.index&&s.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:Cn,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[Bs]:!1},t),t.useSharedArrayBuffer&&!Jo())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=s,this._roots=null,this._indirectBuffer=null,t[Bs]||(Co(this,t),!s.boundingBox&&t.setBoundingBox&&(s.boundingBox=this.getBoundingBox(new C.Box3)));const{_indirectBuffer:e}=this;this.resolveTriangleIndex=t.indirect?i=>e[i]:i=>i}refit(s=null){return(this.indirect?Ho:Po)(this,s)}traverse(s,t=0){const e=this._roots[t],i=new Uint32Array(e),o=new Uint16Array(e);n(0);function n(r,a=0){const c=r*2,h=o[c+15]===Ns;if(h){const E=i[r+6],d=o[c+14];s(a,h,new Float32Array(e,r*4,6),E,d)}else{const E=r+rs/4,d=i[r+6],I=i[r+7];s(a,h,new Float32Array(e,r*4,6),I)||(n(E,a+1),n(d,a+1))}}}raycast(s,t=C.FrontSide){const e=this._roots,i=this.geometry,o=[],n=t.isMaterial,r=Array.isArray(t),a=i.groups,c=n?t.side:t,h=this.indirect?Wo:xo;for(let E=0,d=e.length;E<d;E++){const I=r?t[a[E].materialIndex].side:c,f=o.length;if(h(this,E,I,s,o),r){const T=a[E].materialIndex;for(let F=f,m=o.length;F<m;F++)o[F].face.materialIndex=T}}return o}raycastFirst(s,t=C.FrontSide){const e=this._roots,i=this.geometry,o=t.isMaterial,n=Array.isArray(t);let r=null;const a=i.groups,c=o?t.side:t,h=this.indirect?Xo:bo;for(let E=0,d=e.length;E<d;E++){const I=n?t[a[E].materialIndex].side:c,f=h(this,E,I,s);f!=null&&(r==null||f.distance<r.distance)&&(r=f,n&&(f.face.materialIndex=a[E].materialIndex))}return r}intersectsGeometry(s,t){let e=!1;const i=this._roots,o=this.indirect?Zo:vo;for(let n=0,r=i.length;n<r&&(e=o(this,n,s,t),!e);n++);return e}shapecast(s){const t=dt.getPrimitive(),e=this.indirect?Do:Lo;let{boundsTraverseOrder:i,intersectsBounds:o,intersectsRange:n,intersectsTriangle:r}=s;if(n&&r){const E=n;n=(d,I,f,T,F)=>E(d,I,f,T,F)?!0:e(d,I,this,r,f,T,t)}else n||(r?n=(E,d,I,f)=>e(E,d,this,r,I,f,t):n=(E,d,I)=>I);let a=!1,c=0;const h=this._roots;for(let E=0,d=h.length;E<d;E++){const I=h[E];if(a=go(this,E,o,n,i,c),a)break;c+=I.byteLength}return dt.releasePrimitive(t),a}bvhcast(s,t,e){let{intersectsRanges:i,intersectsTriangles:o}=e;const n=dt.getPrimitive(),r=this.geometry.index,a=this.geometry.attributes.position,c=this.indirect?f=>{const T=this.resolveTriangleIndex(f);tt(n,T*3,r,a)}:f=>{tt(n,f*3,r,a)},h=dt.getPrimitive(),E=s.geometry.index,d=s.geometry.attributes.position,I=s.indirect?f=>{const T=s.resolveTriangleIndex(f);tt(h,T*3,E,d)}:f=>{tt(h,f*3,E,d)};if(o){const f=(T,F,m,A,O,p,R,S)=>{for(let _=m,y=m+A;_<y;_++){I(_),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let N=T,P=T+F;N<P;N++)if(c(N),n.needsUpdate=!0,o(n,h,N,_,O,p,R,S))return!0}return!1};if(i){const T=i;i=function(F,m,A,O,p,R,S,_){return T(F,m,A,O,p,R,S,_)?!0:f(F,m,A,O,p,R,S,_)}}else i=f}return tr(this,s,t,i)}intersectsBox(s,t){return Ke.set(s.min,s.max,t),Ke.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Ke.intersectsBox(e),intersectsTriangle:e=>Ke.intersectsTriangle(e)})}intersectsSphere(s){return this.shapecast({intersectsBounds:t=>s.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(s)})}closestPointToGeometry(s,t,e={},i={},o=0,n=1/0){return(this.indirect?$o:zo)(this,s,t,e,i,o,n)}closestPointToPoint(s,t={},e=0,i=1/0){return Oo(this,s,t,e,i)}getBoundingBox(s){return s.makeEmpty(),this._roots.forEach(e=>{q(0,new Float32Array(e),Qi),s.union(Qi)}),s}}function ji(l,s,t){return l===null||(l.point.applyMatrix4(s.matrixWorld),l.distance=l.point.distanceTo(t.ray.origin),l.object=s,l.distance<t.near||l.distance>t.far)?null:l}const Zs=new C.Ray,qi=new C.Matrix4,er=C.Mesh.prototype.raycast;function sr(l,s){if(this.geometry.boundsTree){if(this.material===void 0)return;qi.copy(this.matrixWorld).invert(),Zs.copy(l.ray).applyMatrix4(qi);const t=this.geometry.boundsTree;if(l.firstHitOnly===!0){const e=ji(t.raycastFirst(Zs,this.material),this,l);e&&s.push(e)}else{const e=t.raycast(Zs,this.material);for(let i=0,o=e.length;i<o;i++){const n=ji(e[i],this,l);n&&s.push(n)}}}else er.call(this,l,s)}function ir(l){return this.boundsTree=new yi(this,l),this.boundsTree}function nr(){this.boundsTree=null}class M{constructor(){u(this,"trigger",s=>{const t=this.handlers.slice(0);for(const e of t)e(s)});u(this,"handlers",[])}add(s){this.handlers.push(s)}remove(s){this.handlers=this.handlers.filter(t=>t!==s)}reset(){this.handlers.length=0}}class Le{constructor(){u(this,"trigger",async s=>{const t=this.handlers.slice(0);for(const e of t)await e(s)});u(this,"handlers",[])}add(s){this.handlers.push(s)}remove(s){this.handlers=this.handlers.filter(t=>t!==s)}reset(){this.handlers.length=0}}class Ps{constructor(s){u(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this);u(this,"isResizeable",()=>"resize"in this&&"getSize"in this);u(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this);u(this,"isHideable",()=>"visible"in this);u(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this);this.components=s}}class $ extends Ps{}class ws extends Ps{constructor(t){super(t);u(this,"worlds",new Map);u(this,"onWorldChanged",new M);u(this,"currentWorld",null);this.onWorldChanged.add(({world:e,action:i})=>{i==="removed"&&this.worlds.delete(e.uuid)})}}class Fn extends ws{constructor(){super(...arguments);u(this,"hasCameraControls",()=>"controls"in this)}}class An extends ws{constructor(){super(...arguments);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onDisposed",new M);u(this,"onResize",new M);u(this,"onClippingPlanesUpdated",new M);u(this,"clippingPlanes",[])}updateClippingPlanes(){this.onClippingPlanesUpdated.trigger()}setPlane(t,e,i){e.isLocal=i;const o=this.clippingPlanes.indexOf(e);t&&o===-1?this.clippingPlanes.push(e):!t&&o>-1&&this.clippingPlanes.splice(o,1),this.three.clippingPlanes=this.clippingPlanes.filter(n=>!n.isLocal)}}const Pe=class Pe extends ${constructor(t){super(t);u(this,"_disposedComponents",new Set);u(this,"enabled",!0);t.add(Pe.uuid,this)}get(){return this._disposedComponents}destroy(t,e=!0,i=!0){t.removeFromParent();const o=t;o.dispose&&o.dispose(),this.disposeGeometryAndMaterials(t,e),i&&o.children&&o.children.length&&this.disposeChildren(o),t.children.length=0}disposeGeometry(t){t.boundsTree&&t.disposeBoundsTree&&t.disposeBoundsTree(),t.dispose()}disposeGeometryAndMaterials(t,e){const i=t;i.geometry&&this.disposeGeometry(i.geometry),e&&i.material&&Pe.disposeMaterial(i),i.material=[],i.geometry=null}disposeChildren(t){for(const e of t.children)this.destroy(e)}static disposeMaterial(t){if(t.material)if(Array.isArray(t.material))for(const e of t.material)e.dispose();else t.material.dispose()}};u(Pe,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let _t=Pe;class gn extends ws{constructor(t){super(t);u(this,"onDisposed",new M);u(this,"directionalLights",new Map);u(this,"ambientLights",new Map)}dispose(){const t=this.components.get(_t);for(const e of this.three.children){const i=e;i.geometry&&t.destroy(i)}for(const[,e]of this.directionalLights)e.removeFromParent(),e.target.removeFromParent(),e.dispose();for(const[,e]of this.ambientLights)e.removeFromParent(),e.dispose();this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}}class or extends Set{constructor(t){super(t);u(this,"onItemAdded",new M);u(this,"onItemDeleted",new M);u(this,"onCleared",new M)}clear(){super.clear(),this.onCleared.trigger()}add(t){if(this.has(t))return this;const i=super.add(t);return this.onItemAdded||(this.onItemAdded=new M),this.onItemAdded.trigger(t),i}delete(t){const e=super.delete(t);return e&&this.onItemDeleted.trigger(),e}dispose(){this.clear(),this.onItemAdded.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class di extends Map{constructor(t){super(t);u(this,"onItemSet",new M);u(this,"onItemUpdated",new M);u(this,"onItemDeleted",new M);u(this,"onCleared",new M)}clear(){super.clear(),this.onCleared.trigger()}set(t,e){const i=this.has(t),o=super.set(t,e);return i?(this.onItemUpdated||(this.onItemUpdated=new M),this.onItemUpdated.trigger({key:t,value:e})):(this.onItemSet||(this.onItemSet=new M),this.onItemSet.trigger({key:t,value:e})),o}delete(t){const e=super.delete(t);return e&&this.onItemDeleted.trigger(),e}dispose(){this.clear(),this.onItemSet.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}const as=0,rr=1,ar=new C.Vector3,Ki=new C.Line3,Qs=new C.Plane,$i=new C.Vector3,$e=new C.Triangle;class cr{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new Ji,this.unassigned=new Ji,this.vertices=[]}setFromPoints(s){if(s.length>=4){this.makeEmpty();for(let t=0,e=s.length;t<e;t++)this.vertices.push(new lr(s[t]));this.compute()}return this}setFromObject(s){const t=[];return s.updateMatrixWorld(!0),s.traverse(function(e){const i=e.geometry;if(i!==void 0){const o=i.attributes.position;if(o!==void 0)for(let n=0,r=o.count;n<r;n++){const a=new C.Vector3;a.fromBufferAttribute(o,n).applyMatrix4(e.matrixWorld),t.push(a)}}}),this.setFromPoints(t)}containsPoint(s){const t=this.faces;for(let e=0,i=t.length;e<i;e++)if(t[e].distanceToPoint(s)>this.tolerance)return!1;return!0}intersectRay(s,t){const e=this.faces;let i=-1/0,o=1/0;for(let n=0,r=e.length;n<r;n++){const a=e[n],c=a.distanceToPoint(s.origin),h=a.normal.dot(s.direction);if(c>0&&h>=0)return null;const E=h!==0?-c/h:0;if(!(E<=0)&&(h>0?o=Math.min(E,o):i=Math.max(E,i),i>o))return null}return i!==-1/0?s.at(i,t):s.at(o,t),t}intersectsRay(s){return this.intersectRay(s,ar)!==null}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(s,t){return s.face=t,t.outside===null?this.assigned.append(s):this.assigned.insertBefore(t.outside,s),t.outside=s,this}removeVertexFromFace(s,t){return s===t.outside&&(s.next!==null&&s.next.face===t?t.outside=s.next:t.outside=null),this.assigned.remove(s),this}removeAllVerticesFromFace(s){if(s.outside!==null){const t=s.outside;let e=s.outside;for(;e.next!==null&&e.next.face===s;)e=e.next;return this.assigned.removeSubList(t,e),t.prev=e.next=null,s.outside=null,t}}deleteFaceVertices(s,t){const e=this.removeAllVerticesFromFace(s);if(e!==void 0)if(t===void 0)this.unassigned.appendChain(e);else{let i=e;do{const o=i.next;t.distanceToPoint(i.point)>this.tolerance?this.addVertexToFace(i,t):this.unassigned.append(i),i=o}while(i!==null)}return this}resolveUnassignedPoints(s){if(this.unassigned.isEmpty()===!1){let t=this.unassigned.first();do{const e=t.next;let i=this.tolerance,o=null;for(let n=0;n<s.length;n++){const r=s[n];if(r.mark===as){const a=r.distanceToPoint(t.point);if(a>i&&(i=a,o=r),i>1e3*this.tolerance)break}}o!==null&&this.addVertexToFace(t,o),t=e}while(t!==null)}return this}computeExtremes(){const s=new C.Vector3,t=new C.Vector3,e=[],i=[];for(let o=0;o<3;o++)e[o]=i[o]=this.vertices[0];s.copy(this.vertices[0].point),t.copy(this.vertices[0].point);for(let o=0,n=this.vertices.length;o<n;o++){const r=this.vertices[o],a=r.point;for(let c=0;c<3;c++)a.getComponent(c)<s.getComponent(c)&&(s.setComponent(c,a.getComponent(c)),e[c]=r);for(let c=0;c<3;c++)a.getComponent(c)>t.getComponent(c)&&(t.setComponent(c,a.getComponent(c)),i[c]=r)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(s.x),Math.abs(t.x))+Math.max(Math.abs(s.y),Math.abs(t.y))+Math.max(Math.abs(s.z),Math.abs(t.z))),{min:e,max:i}}computeInitialHull(){const s=this.vertices,t=this.computeExtremes(),e=t.min,i=t.max;let o=0,n=0;for(let d=0;d<3;d++){const I=i[d].point.getComponent(d)-e[d].point.getComponent(d);I>o&&(o=I,n=d)}const r=e[n],a=i[n];let c,h;o=0,Ki.set(r.point,a.point);for(let d=0,I=this.vertices.length;d<I;d++){const f=s[d];if(f!==r&&f!==a){Ki.closestPointToPoint(f.point,!0,$i);const T=$i.distanceToSquared(f.point);T>o&&(o=T,c=f)}}o=-1,Qs.setFromCoplanarPoints(r.point,a.point,c.point);for(let d=0,I=this.vertices.length;d<I;d++){const f=s[d];if(f!==r&&f!==a&&f!==c){const T=Math.abs(Qs.distanceToPoint(f.point));T>o&&(o=T,h=f)}}const E=[];if(Qs.distanceToPoint(h.point)<0){E.push(Ct.create(r,a,c),Ct.create(h,a,r),Ct.create(h,c,a),Ct.create(h,r,c));for(let d=0;d<3;d++){const I=(d+1)%3;E[d+1].getEdge(2).setTwin(E[0].getEdge(I)),E[d+1].getEdge(1).setTwin(E[I+1].getEdge(0))}}else{E.push(Ct.create(r,c,a),Ct.create(h,r,a),Ct.create(h,a,c),Ct.create(h,c,r));for(let d=0;d<3;d++){const I=(d+1)%3;E[d+1].getEdge(2).setTwin(E[0].getEdge((3-d)%3)),E[d+1].getEdge(0).setTwin(E[I+1].getEdge(1))}}for(let d=0;d<4;d++)this.faces.push(E[d]);for(let d=0,I=s.length;d<I;d++){const f=s[d];if(f!==r&&f!==a&&f!==c&&f!==h){o=this.tolerance;let T=null;for(let F=0;F<4;F++){const m=this.faces[F].distanceToPoint(f.point);m>o&&(o=m,T=this.faces[F])}T!==null&&this.addVertexToFace(f,T)}}return this}reindexFaces(){const s=[];for(let t=0;t<this.faces.length;t++){const e=this.faces[t];e.mark===as&&s.push(e)}return this.faces=s,this}nextVertexToAdd(){if(this.assigned.isEmpty()===!1){let s,t=0;const e=this.assigned.first().face;let i=e.outside;do{const o=e.distanceToPoint(i.point);o>t&&(t=o,s=i),i=i.next}while(i!==null&&i.face===e);return s}}computeHorizon(s,t,e,i){this.deleteFaceVertices(e),e.mark=rr;let o;t===null?o=t=e.getEdge(0):o=t.next;do{const n=o.twin,r=n.face;r.mark===as&&(r.distanceToPoint(s)>this.tolerance?this.computeHorizon(s,n,r,i):i.push(o)),o=o.next}while(o!==t);return this}addAdjoiningFace(s,t){const e=Ct.create(s,t.tail(),t.head());return this.faces.push(e),e.getEdge(-1).setTwin(t.twin),e.getEdge(0)}addNewFaces(s,t){this.newFaces=[];let e=null,i=null;for(let o=0;o<t.length;o++){const n=t[o],r=this.addAdjoiningFace(s,n);e===null?e=r:r.next.setTwin(i),this.newFaces.push(r.face),i=r}return e.next.setTwin(i),this}addVertexToHull(s){const t=[];return this.unassigned.clear(),this.removeVertexFromFace(s,s.face),this.computeHorizon(s.point,null,s.face,t),this.addNewFaces(s,t),this.resolveUnassignedPoints(this.newFaces),this}cleanup(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this}compute(){let s;for(this.computeInitialHull();(s=this.nextVertexToAdd())!==void 0;)this.addVertexToHull(s);return this.reindexFaces(),this.cleanup(),this}}class Ct{constructor(){this.normal=new C.Vector3,this.midpoint=new C.Vector3,this.area=0,this.constant=0,this.outside=null,this.mark=as,this.edge=null}static create(s,t,e){const i=new Ct,o=new js(s,i),n=new js(t,i),r=new js(e,i);return o.next=r.prev=n,n.next=o.prev=r,r.next=n.prev=o,i.edge=o,i.compute()}getEdge(s){let t=this.edge;for(;s>0;)t=t.next,s--;for(;s<0;)t=t.prev,s++;return t}compute(){const s=this.edge.tail(),t=this.edge.head(),e=this.edge.next.head();return $e.set(s.point,t.point,e.point),$e.getNormal(this.normal),$e.getMidpoint(this.midpoint),this.area=$e.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(s){return this.normal.dot(s)-this.constant}}class js{constructor(s,t){this.vertex=s,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 s=this.head(),t=this.tail();return t!==null?t.point.distanceTo(s.point):-1}lengthSquared(){const s=this.head(),t=this.tail();return t!==null?t.point.distanceToSquared(s.point):-1}setTwin(s){return this.twin=s,s.twin=this,this}}class lr{constructor(s){this.point=s,this.prev=null,this.next=null,this.face=null}}class Ji{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(s,t){return t.prev=s.prev,t.next=s,t.prev===null?this.head=t:t.prev.next=t,s.prev=t,this}insertAfter(s,t){return t.prev=s,t.next=s.next,t.next===null?this.tail=t:t.next.prev=t,s.next=t,this}append(s){return this.head===null?this.head=s:this.tail.next=s,s.prev=this.tail,s.next=null,this.tail=s,this}appendChain(s){for(this.head===null?this.head=s:this.tail.next=s,s.prev=this.tail;s.next!==null;)s=s.next;return this.tail=s,this}remove(s){return s.prev===null?this.head=s.next:s.prev.next=s.next,s.next===null?this.tail=s.prev:s.next.prev=s.prev,this}removeSubList(s,t){return s.prev===null?this.head=t.next:s.prev.next=t.next,t.next===null?this.tail=s.prev:t.next.prev=s.prev,this}isEmpty(){return this.head===null}}const Ei=[2,2,1],ui=[1,0,0];function gt(l,s){return l*3+s}function hr(l){const s=l.elements;let t=0;for(let e=0;e<9;e++)t+=s[e]*s[e];return Math.sqrt(t)}function dr(l){const s=l.elements;let t=0;for(let e=0;e<3;e++){const i=s[gt(Ei[e],ui[e])];t+=2*i*i}return Math.sqrt(t)}function Er(l,s){let t=0,e=1;const i=l.elements;for(let c=0;c<3;c++){const h=Math.abs(i[gt(Ei[c],ui[c])]);h>t&&(t=h,e=c)}let o=1,n=0;const r=ui[e],a=Ei[e];if(Math.abs(i[gt(a,r)])>Number.EPSILON){const c=i[gt(a,a)],h=i[gt(r,r)],E=i[gt(a,r)],d=(c-h)/2/E;let I;d<0?I=-1/(-d+Math.sqrt(1+d*d)):I=1/(d+Math.sqrt(1+d*d)),o=1/Math.sqrt(1+I*I),n=I*o}return s.identity(),s.elements[gt(r,r)]=o,s.elements[gt(a,a)]=o,s.elements[gt(a,r)]=n,s.elements[gt(r,a)]=-n,s}function ur(l,s){let t=0,e=0;const i=10;s.unitary.identity(),s.diagonal.copy(l);const o=s.unitary,n=s.diagonal,r=new g.Matrix3,a=new g.Matrix3,c=Number.EPSILON*hr(n);for(;e<i&&dr(n)>c;)Er(n,r),a.copy(r).transpose(),n.multiply(r),n.premultiply(a),o.multiply(r),++t>2&&(e++,t=0);return s}function On(l){const s=[];for(let st=0;st<l.length-2;st+=3){const Vt=l[st],J=l[st+1],kt=l[st+2];s.push(new g.Vector3(Vt,J,kt))}const t=new cr;t.setFromPoints(s);const e={unitary:new g.Matrix3,diagonal:new g.Matrix3},i=t.faces,o=[],n=[];for(let st=0,Vt=i.length;st<Vt;st++){const J=i[st];let kt=J.edge;o.length=0;do o.push(kt),kt=kt.next;while(kt!==J.edge);const Qn=o.length-2;for(let be=1,jn=Qn;be<=jn;be++){const xs=o[0].vertex,Us=o[be+0].vertex,bs=o[be+1].vertex;n.push(xs.point.x,xs.point.y,xs.point.z),n.push(Us.point.x,Us.point.y,Us.point.z),n.push(bs.point.x,bs.point.y,bs.point.z)}}const r=new g.Vector3,a=new g.Vector3,c=new g.Vector3,h=new g.Vector3,E=new g.Vector3,d=new g.Vector3,I=new g.Vector3,f=new g.Vector3;let T=0,F=0,m=0,A=0,O=0,p=0,R=0;for(let st=0,Vt=n.length;st<Vt;st+=9){r.fromArray(n,st),a.fromArray(n,st+3),c.fromArray(n,st+6),I.set(0,0,0),I.add(r).add(a).add(c).divideScalar(3),h.subVectors(a,r),E.subVectors(c,r);const J=d.crossVectors(h,E).length()/2;f.add(d.copy(I).multiplyScalar(J)),T+=J,F+=(9*I.x*I.x+r.x*r.x+a.x*a.x+c.x*c.x)*(J/12),m+=(9*I.x*I.y+r.x*r.y+a.x*a.y+c.x*c.y)*(J/12),A+=(9*I.x*I.z+r.x*r.z+a.x*a.z+c.x*c.z)*(J/12),O+=(9*I.y*I.y+r.y*r.y+a.y*a.y+c.y*c.y)*(J/12),p+=(9*I.y*I.z+r.y*r.z+a.y*a.z+c.y*c.z)*(J/12),R+=(9*I.z*I.z+r.z*r.z+a.z*a.z+c.z*c.z)*(J/12)}f.divideScalar(T),F/=T,m/=T,A/=T,O/=T,p/=T,R/=T,F-=f.x*f.x,m-=f.x*f.y,A-=f.x*f.z,O-=f.y*f.y,p-=f.y*f.z,R-=f.z*f.z;const S=new g.Matrix3;S.elements[0]=F,S.elements[1]=m,S.elements[2]=A,S.elements[3]=m,S.elements[4]=O,S.elements[5]=p,S.elements[6]=A,S.elements[7]=p,S.elements[8]=R,ur(S,e);const _=e.unitary,y=new g.Vector3,N=new g.Vector3,P=new g.Vector3;_.extractBasis(y,N,P);let D=-1/0,w=-1/0,U=-1/0,b=1/0,v=1/0,z=1/0;for(let st=0,Vt=s.length;st<Vt;st++){const J=s[st];D=Math.max(y.dot(J),D),w=Math.max(N.dot(J),w),U=Math.max(P.dot(J),U),b=Math.min(y.dot(J),b),v=Math.min(N.dot(J),v),z=Math.min(P.dot(J),z)}y.multiplyScalar(.5*(b+D)),N.multiplyScalar(.5*(v+w)),P.multiplyScalar(.5*(z+U));const j=new g.Vector3,et=new g.Vector3,Z=new g.Matrix3;j.add(y).add(N).add(P),et.x=D-b,et.y=w-v,et.z=U-z,et.multiplyScalar(.5),Z.copy(_);const{x:bt,y:vt,z:Bt}=et,Ue=new g.Matrix4;Ue.makeScale(bt*2,vt*2,Bt*2);const de=new g.Matrix4;de.makeTranslation(-bt,-vt,-Bt);const wi=new g.Matrix4;wi.makeTranslation(j.x,j.y,j.z);const Mi=new g.Matrix4;Mi.setFromMatrix3(Z);const Ee=new g.Matrix4;return Ee.multiply(wi),Ee.multiply(Mi),Ee.multiply(de),Ee.multiply(Ue),{center:j,halfSizes:et,rotation:Z,transformation:Ee}}function Sn(l,s,t){const e=[l[0]-s[0],l[1]-s[1],l[2]-s[2]];return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]>0}class Ii{static isTransparent(s){return s.transparent&&s.opacity<1}}const K=class K{static create(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return`${K._lut[s&255]+K._lut[s>>8&255]+K._lut[s>>16&255]+K._lut[s>>24&255]}-${K._lut[t&255]}${K._lut[t>>8&255]}-${K._lut[t>>16&15|64]}${K._lut[t>>24&255]}-${K._lut[e&63|128]}${K._lut[e>>8&255]}-${K._lut[e>>16&255]}${K._lut[e>>24&255]}${K._lut[i&255]}${K._lut[i>>8&255]}${K._lut[i>>16&255]}${K._lut[i>>24&255]}`.toLowerCase()}static validate(s){if(!K._pattern.test(s))throw new Error(`${s} is not a valid UUID v4.
|
|
1
|
+
"use strict";var qn=Object.defineProperty;var Kn=(l,s,t)=>s in l?qn(l,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[s]=t;var u=(l,s,t)=>(Kn(l,typeof s!="symbol"?s+"":s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("three"),pn=require("@thatopen/fragments"),$n=require("web-ifc");function Oi(l){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(s,t,e.get?e:{enumerable:!0,get:()=>l[t]})}}return s.default=l,Object.freeze(s)}const g=Oi(C),Dt=Oi(pn),D=Oi($n),Cn=0,Jn=1,to=2,Di=2,vs=1.25,xi=1,rs=6*4+4+4,Ns=65535,eo=Math.pow(2,-24),Bs=Symbol("SKIP_GENERATION");function so(l){return l.index?l.index.count:l.attributes.position.count}function he(l){return so(l)/3}function io(l,s=ArrayBuffer){return l>65535?new Uint32Array(new s(4*l)):new Uint16Array(new s(2*l))}function no(l,s){if(!l.index){const t=l.attributes.position.count,e=s.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=io(t,e);l.setIndex(new C.BufferAttribute(i,1));for(let o=0;o<t;o++)i[o]=o}}function Tn(l){const s=he(l),t=l.drawRange,e=t.start/3,i=(t.start+t.count)/3,o=Math.max(0,e),n=Math.min(s,i)-o;return[{offset:Math.floor(o),count:Math.floor(n)}]}function mn(l){if(!l.groups||!l.groups.length)return Tn(l);const s=[],t=new Set,e=l.drawRange,i=e.start/3,o=(e.start+e.count)/3;for(const r of l.groups){const a=r.start/3,c=(r.start+r.count)/3;t.add(Math.max(i,a)),t.add(Math.min(o,c))}const n=Array.from(t.values()).sort((r,a)=>r-a);for(let r=0;r<n.length-1;r++){const a=n[r],c=n[r+1];s.push({offset:Math.floor(a),count:Math.floor(c-a)})}return s}function oo(l){if(l.groups.length===0)return!1;const s=he(l),t=mn(l).sort((o,n)=>o.offset-n.offset),e=t[t.length-1];e.count=Math.min(s-e.offset,e.count);let i=0;return t.forEach(({count:o})=>i+=o),s!==i}function q(l,s,t){return t.min.x=s[l],t.min.y=s[l+1],t.min.z=s[l+2],t.max.x=s[l+3],t.max.y=s[l+4],t.max.z=s[l+5],t}function ro(l){l[0]=l[1]=l[2]=1/0,l[3]=l[4]=l[5]=-1/0}function Ui(l){let s=-1,t=-1/0;for(let e=0;e<3;e++){const i=l[e+3]-l[e];i>t&&(t=i,s=e)}return s}function bi(l,s){s.set(l)}function vi(l,s,t){let e,i;for(let o=0;o<3;o++){const n=o+3;e=l[o],i=s[o],t[o]=e<i?e:i,e=l[n],i=s[n],t[n]=e>i?e:i}}function ve(l,s,t){for(let e=0;e<3;e++){const i=s[l+2*e],o=s[l+2*e+1],n=i-o,r=i+o;n<t[e]&&(t[e]=n),r>t[e+3]&&(t[e+3]=r)}}function ue(l){const s=l[3]-l[0],t=l[4]-l[1],e=l[5]-l[2];return 2*(s*t+t*e+e*s)}function Vs(l,s,t,e,i=null){let o=1/0,n=1/0,r=1/0,a=-1/0,c=-1/0,h=-1/0,E=1/0,d=1/0,I=1/0,f=-1/0,T=-1/0,F=-1/0;const m=i!==null;for(let A=s*6,O=(s+t)*6;A<O;A+=6){const p=l[A+0],R=l[A+1],S=p-R,_=p+R;S<o&&(o=S),_>a&&(a=_),m&&p<E&&(E=p),m&&p>f&&(f=p);const y=l[A+2],N=l[A+3],P=y-N,x=y+N;P<n&&(n=P),x>c&&(c=x),m&&y<d&&(d=y),m&&y>T&&(T=y);const w=l[A+4],U=l[A+5],b=w-U,v=w+U;b<r&&(r=b),v>h&&(h=v),m&&w<I&&(I=w),m&&w>F&&(F=w)}e[0]=o,e[1]=n,e[2]=r,e[3]=a,e[4]=c,e[5]=h,m&&(i[0]=E,i[1]=d,i[2]=I,i[3]=f,i[4]=T,i[5]=F)}function ao(l,s,t,e){let i=1/0,o=1/0,n=1/0,r=-1/0,a=-1/0,c=-1/0;for(let h=s*6,E=(s+t)*6;h<E;h+=6){const d=l[h+0];d<i&&(i=d),d>r&&(r=d);const I=l[h+2];I<o&&(o=I),I>a&&(a=I);const f=l[h+4];f<n&&(n=f),f>c&&(c=f)}e[0]=i,e[1]=o,e[2]=n,e[3]=r,e[4]=a,e[5]=c}function co(l,s){ro(s);const t=l.attributes.position,e=l.index?l.index.array:null,i=he(l),o=new Float32Array(i*6),n=t.normalized,r=t.array,a=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const h=["getX","getY","getZ"];for(let E=0;E<i;E++){const d=E*3,I=E*6;let f=d+0,T=d+1,F=d+2;e&&(f=e[f],T=e[T],F=e[F]),n||(f=f*c+a,T=T*c+a,F=F*c+a);for(let m=0;m<3;m++){let A,O,p;n?(A=t[h[m]](f),O=t[h[m]](T),p=t[h[m]](F)):(A=r[f+m],O=r[T+m],p=r[F+m]);let R=A;O<R&&(R=O),p<R&&(R=p);let S=A;O>S&&(S=O),p>S&&(S=p);const _=(S-R)/2,y=m*2;o[I+y+0]=R+_,o[I+y+1]=_+(Math.abs(R)+_)*eo,R<s[m]&&(s[m]=R),S>s[m+3]&&(s[m+3]=S)}}return o}const Ot=32,lo=(l,s)=>l.candidate-s.candidate,yt=new Array(Ot).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Be=new Float32Array(6);function ho(l,s,t,e,i,o){let n=-1,r=0;if(o===Cn)n=Ui(s),n!==-1&&(r=(s[n]+s[n+3])/2);else if(o===Jn)n=Ui(l),n!==-1&&(r=Eo(t,e,i,n));else if(o===to){const a=ue(l);let c=vs*i;const h=e*6,E=(e+i)*6;for(let d=0;d<3;d++){const I=s[d],F=(s[d+3]-I)/Ot;if(i<Ot/4){const m=[...yt];m.length=i;let A=0;for(let p=h;p<E;p+=6,A++){const R=m[A];R.candidate=t[p+2*d],R.count=0;const{bounds:S,leftCacheBounds:_,rightCacheBounds:y}=R;for(let N=0;N<3;N++)y[N]=1/0,y[N+3]=-1/0,_[N]=1/0,_[N+3]=-1/0,S[N]=1/0,S[N+3]=-1/0;ve(p,t,S)}m.sort(lo);let O=i;for(let p=0;p<O;p++){const R=m[p];for(;p+1<O&&m[p+1].candidate===R.candidate;)m.splice(p+1,1),O--}for(let p=h;p<E;p+=6){const R=t[p+2*d];for(let S=0;S<O;S++){const _=m[S];R>=_.candidate?ve(p,t,_.rightCacheBounds):(ve(p,t,_.leftCacheBounds),_.count++)}}for(let p=0;p<O;p++){const R=m[p],S=R.count,_=i-R.count,y=R.leftCacheBounds,N=R.rightCacheBounds;let P=0;S!==0&&(P=ue(y)/a);let x=0;_!==0&&(x=ue(N)/a);const w=xi+vs*(P*S+x*_);w<c&&(n=d,c=w,r=R.candidate)}}else{for(let O=0;O<Ot;O++){const p=yt[O];p.count=0,p.candidate=I+F+O*F;const R=p.bounds;for(let S=0;S<3;S++)R[S]=1/0,R[S+3]=-1/0}for(let O=h;O<E;O+=6){let S=~~((t[O+2*d]-I)/F);S>=Ot&&(S=Ot-1);const _=yt[S];_.count++,ve(O,t,_.bounds)}const m=yt[Ot-1];bi(m.bounds,m.rightCacheBounds);for(let O=Ot-2;O>=0;O--){const p=yt[O],R=yt[O+1];vi(p.bounds,R.rightCacheBounds,p.rightCacheBounds)}let A=0;for(let O=0;O<Ot-1;O++){const p=yt[O],R=p.count,S=p.bounds,y=yt[O+1].rightCacheBounds;R!==0&&(A===0?bi(S,Be):vi(S,Be,Be)),A+=R;let N=0,P=0;A!==0&&(N=ue(Be)/a);const x=i-A;x!==0&&(P=ue(y)/a);const w=xi+vs*(N*A+P*x);w<c&&(n=d,c=w,r=p.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${o} used.`);return{axis:n,pos:r}}function Eo(l,s,t,e){let i=0;for(let o=s,n=s+t;o<n;o++)i+=l[o*6+e*2];return i/t}class Ve{constructor(){}}function uo(l,s,t,e,i,o){let n=e,r=e+i-1;const a=o.pos,c=o.axis*2;for(;;){for(;n<=r&&t[n*6+c]<a;)n++;for(;n<=r&&t[r*6+c]>=a;)r--;if(n<r){for(let h=0;h<3;h++){let E=s[n*3+h];s[n*3+h]=s[r*3+h],s[r*3+h]=E}for(let h=0;h<6;h++){let E=t[n*6+h];t[n*6+h]=t[r*6+h],t[r*6+h]=E}n++,r--}else return n}}function Io(l,s,t,e,i,o){let n=e,r=e+i-1;const a=o.pos,c=o.axis*2;for(;;){for(;n<=r&&t[n*6+c]<a;)n++;for(;n<=r&&t[r*6+c]>=a;)r--;if(n<r){let h=l[n];l[n]=l[r],l[r]=h;for(let E=0;E<6;E++){let d=t[n*6+E];t[n*6+E]=t[r*6+E],t[r*6+E]=d}n++,r--}else return n}}function fo(l,s){const t=(l.index?l.index.count:l.attributes.position.count)/3,e=t>2**16,i=e?4:2,o=s?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),n=e?new Uint32Array(o):new Uint16Array(o);for(let r=0,a=n.length;r<a;r++)n[r]=r;return n}function po(l,s){const t=l.geometry,e=t.index?t.index.array:null,i=s.maxDepth,o=s.verbose,n=s.maxLeafTris,r=s.strategy,a=s.onProgress,c=he(t),h=l._indirectBuffer;let E=!1;const d=new Float32Array(6),I=new Float32Array(6),f=co(t,d),T=s.indirect?Io:uo,F=[],m=s.indirect?Tn(t):mn(t);if(m.length===1){const p=m[0],R=new Ve;R.boundingData=d,ao(f,p.offset,p.count,I),O(R,p.offset,p.count,I),F.push(R)}else for(let p of m){const R=new Ve;R.boundingData=new Float32Array(6),Vs(f,p.offset,p.count,R.boundingData,I),O(R,p.offset,p.count,I),F.push(R)}return F;function A(p){a&&a(p/c)}function O(p,R,S,_=null,y=0){if(!E&&y>=i&&(E=!0,o&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),S<=n||y>=i)return A(R+S),p.offset=R,p.count=S,p;const N=ho(p.boundingData,_,f,R,S,r);if(N.axis===-1)return A(R+S),p.offset=R,p.count=S,p;const P=T(h,e,f,R,S,N);if(P===R||P===R+S)A(R+S),p.offset=R,p.count=S;else{p.splitAxis=N.axis;const x=new Ve,w=R,U=P-R;p.left=x,x.boundingData=new Float32Array(6),Vs(f,w,U,x.boundingData,I),O(x,w,U,I,y+1);const b=new Ve,v=P,z=S-U;p.right=b,b.boundingData=new Float32Array(6),Vs(f,v,z,b.boundingData,I),O(b,v,z,I,y+1)}return p}}function Co(l,s){const t=l.geometry;s.indirect&&(l._indirectBuffer=fo(t,s.useSharedArrayBuffer),oo(t)&&!s.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.')),l._indirectBuffer||no(t,s);const e=po(l,s);let i,o,n;const r=[],a=s.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let E=0;E<e.length;E++){const d=e[E];let I=c(d);const f=new a(rs*I);i=new Float32Array(f),o=new Uint32Array(f),n=new Uint16Array(f),h(0,d),r.push(f)}l._roots=r;return;function c(E){return E.count?1:1+c(E.left)+c(E.right)}function h(E,d){const I=E/4,f=E/2,T=!!d.count,F=d.boundingData;for(let m=0;m<6;m++)i[I+m]=F[m];if(T){const m=d.offset,A=d.count;return o[I+6]=m,n[f+14]=A,n[f+15]=Ns,E+rs}else{const m=d.left,A=d.right,O=d.splitAxis;let p;if(p=h(E+rs,m),p/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return o[I+6]=p/4,p=h(p,A),o[I+7]=O,p}}}class St{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(s,t){let e=1/0,i=-1/0;for(let o=0,n=s.length;o<n;o++){const a=s[o][t];e=a<e?a:e,i=a>i?a:i}this.min=e,this.max=i}setFromPoints(s,t){let e=1/0,i=-1/0;for(let o=0,n=t.length;o<n;o++){const r=t[o],a=s.dot(r);e=a<e?a:e,i=a>i?a:i}this.min=e,this.max=i}isSeparated(s){return this.min>s.max||s.min>this.max}}St.prototype.setFromBox=function(){const l=new C.Vector3;return function(t,e){const i=e.min,o=e.max;let n=1/0,r=-1/0;for(let a=0;a<=1;a++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){l.x=i.x*a+o.x*(1-a),l.y=i.y*c+o.y*(1-c),l.z=i.z*h+o.z*(1-h);const E=t.dot(l);n=Math.min(E,n),r=Math.max(E,r)}this.min=n,this.max=r}}();const To=function(){const l=new C.Vector3,s=new C.Vector3,t=new C.Vector3;return function(i,o,n){const r=i.start,a=l,c=o.start,h=s;t.subVectors(r,c),l.subVectors(i.end,i.start),s.subVectors(o.end,o.start);const E=t.dot(h),d=h.dot(a),I=h.dot(h),f=t.dot(a),F=a.dot(a)*I-d*d;let m,A;F!==0?m=(E*d-f*I)/F:m=0,A=(E+m*d)/I,n.x=m,n.y=A}}(),Si=function(){const l=new C.Vector2,s=new C.Vector3,t=new C.Vector3;return function(i,o,n,r){To(i,o,l);let a=l.x,c=l.y;if(a>=0&&a<=1&&c>=0&&c<=1){i.at(a,n),o.at(c,r);return}else if(a>=0&&a<=1){c<0?o.at(0,r):o.at(1,r),i.closestPointToPoint(r,!0,n);return}else if(c>=0&&c<=1){a<0?i.at(0,n):i.at(1,n),o.closestPointToPoint(n,!0,r);return}else{let h;a<0?h=i.start:h=i.end;let E;c<0?E=o.start:E=o.end;const d=s,I=t;if(i.closestPointToPoint(E,!0,s),o.closestPointToPoint(h,!0,t),d.distanceToSquared(E)<=I.distanceToSquared(h)){n.copy(d),r.copy(E);return}else{n.copy(h),r.copy(I);return}}}}(),mo=function(){const l=new C.Vector3,s=new C.Vector3,t=new C.Plane,e=new C.Line3;return function(o,n){const{radius:r,center:a}=o,{a:c,b:h,c:E}=n;if(e.start=c,e.end=h,e.closestPointToPoint(a,!0,l).distanceTo(a)<=r||(e.start=c,e.end=E,e.closestPointToPoint(a,!0,l).distanceTo(a)<=r)||(e.start=h,e.end=E,e.closestPointToPoint(a,!0,l).distanceTo(a)<=r))return!0;const T=n.getPlane(t);if(Math.abs(T.distanceToPoint(a))<=r){const m=T.projectPoint(a,s);if(n.containsPoint(m))return!0}return!1}}(),Ro=1e-15;function Ys(l){return Math.abs(l)<Ro}class mt extends C.Triangle{constructor(...s){super(...s),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new C.Vector3),this.satBounds=new Array(4).fill().map(()=>new St),this.points=[this.a,this.b,this.c],this.sphere=new C.Sphere,this.plane=new C.Plane,this.needsUpdate=!0}intersectsSphere(s){return mo(s,this)}update(){const s=this.a,t=this.b,e=this.c,i=this.points,o=this.satAxes,n=this.satBounds,r=o[0],a=n[0];this.getNormal(r),a.setFromPoints(r,i);const c=o[1],h=n[1];c.subVectors(s,t),h.setFromPoints(c,i);const E=o[2],d=n[2];E.subVectors(t,e),d.setFromPoints(E,i);const I=o[3],f=n[3];I.subVectors(e,s),f.setFromPoints(I,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(r,s),this.needsUpdate=!1}}mt.prototype.closestPointToSegment=function(){const l=new C.Vector3,s=new C.Vector3,t=new C.Line3;return function(i,o=null,n=null){const{start:r,end:a}=i,c=this.points;let h,E=1/0;for(let d=0;d<3;d++){const I=(d+1)%3;t.start.copy(c[d]),t.end.copy(c[I]),Si(t,i,l,s),h=l.distanceToSquared(s),h<E&&(E=h,o&&o.copy(l),n&&n.copy(s))}return this.closestPointToPoint(r,l),h=r.distanceToSquared(l),h<E&&(E=h,o&&o.copy(l),n&&n.copy(r)),this.closestPointToPoint(a,l),h=a.distanceToSquared(l),h<E&&(E=h,o&&o.copy(l),n&&n.copy(a)),Math.sqrt(E)}}();mt.prototype.intersectsTriangle=function(){const l=new mt,s=new Array(3),t=new Array(3),e=new St,i=new St,o=new C.Vector3,n=new C.Vector3,r=new C.Vector3,a=new C.Vector3,c=new C.Vector3,h=new C.Line3,E=new C.Line3,d=new C.Line3,I=new C.Vector3;function f(T,F,m){const A=T.points;let O=0,p=-1;for(let R=0;R<3;R++){const{start:S,end:_}=h;S.copy(A[R]),_.copy(A[(R+1)%3]),h.delta(n);const y=Ys(F.distanceToPoint(S));if(Ys(F.normal.dot(n))&&y){m.copy(h),O=2;break}const N=F.intersectLine(h,I);if(!N&&y&&I.copy(S),(N||y)&&!Ys(I.distanceTo(_))){if(O<=1)(O===1?m.start:m.end).copy(I),y&&(p=O);else if(O>=2){(p===1?m.start:m.end).copy(I),O=2;break}if(O++,O===2&&p===-1)break}}return O}return function(F,m=null,A=!1){this.needsUpdate&&this.update(),F.isExtendedTriangle?F.needsUpdate&&F.update():(l.copy(F),l.update(),F=l);const O=this.plane,p=F.plane;if(Math.abs(O.normal.dot(p.normal))>1-1e-10){const R=this.satBounds,S=this.satAxes;t[0]=F.a,t[1]=F.b,t[2]=F.c;for(let N=0;N<4;N++){const P=R[N],x=S[N];if(e.setFromPoints(x,t),P.isSeparated(e))return!1}const _=F.satBounds,y=F.satAxes;s[0]=this.a,s[1]=this.b,s[2]=this.c;for(let N=0;N<4;N++){const P=_[N],x=y[N];if(e.setFromPoints(x,s),P.isSeparated(e))return!1}for(let N=0;N<4;N++){const P=S[N];for(let x=0;x<4;x++){const w=y[x];if(o.crossVectors(P,w),e.setFromPoints(o,s),i.setFromPoints(o,t),e.isSeparated(i))return!1}}return m&&(A||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{const R=f(this,p,E);if(R===1&&F.containsPoint(E.end))return m&&(m.start.copy(E.end),m.end.copy(E.end)),!0;if(R!==2)return!1;const S=f(F,O,d);if(S===1&&this.containsPoint(d.end))return m&&(m.start.copy(d.end),m.end.copy(d.end)),!0;if(S!==2)return!1;if(E.delta(r),d.delta(a),r.dot(a)<0){let U=d.start;d.start=d.end,d.end=U}const _=E.start.dot(r),y=E.end.dot(r),N=d.start.dot(r),P=d.end.dot(r),x=y<N,w=_<P;return _!==P&&N!==y&&x===w?!1:(m&&(c.subVectors(E.start,d.start),c.dot(r)>0?m.start.copy(E.start):m.start.copy(d.start),c.subVectors(E.end,d.end),c.dot(r)<0?m.end.copy(E.end):m.end.copy(d.end)),!0)}}}();mt.prototype.distanceToPoint=function(){const l=new C.Vector3;return function(t){return this.closestPointToPoint(t,l),t.distanceTo(l)}}();mt.prototype.distanceToTriangle=function(){const l=new C.Vector3,s=new C.Vector3,t=["a","b","c"],e=new C.Line3,i=new C.Line3;return function(n,r=null,a=null){const c=r||a?e:null;if(this.intersectsTriangle(n,c))return(r||a)&&(r&&c.getCenter(r),a&&c.getCenter(a)),0;let h=1/0;for(let E=0;E<3;E++){let d;const I=t[E],f=n[I];this.closestPointToPoint(f,l),d=f.distanceToSquared(l),d<h&&(h=d,r&&r.copy(l),a&&a.copy(f));const T=this[I];n.closestPointToPoint(T,l),d=T.distanceToSquared(l),d<h&&(h=d,r&&r.copy(T),a&&a.copy(l))}for(let E=0;E<3;E++){const d=t[E],I=t[(E+1)%3];e.set(this[d],this[I]);for(let f=0;f<3;f++){const T=t[f],F=t[(f+1)%3];i.set(n[T],n[F]),Si(e,i,l,s);const m=l.distanceToSquared(s);m<h&&(h=m,r&&r.copy(l),a&&a.copy(s))}}return Math.sqrt(h)}}();class rt{constructor(s,t,e){this.isOrientedBox=!0,this.min=new C.Vector3,this.max=new C.Vector3,this.matrix=new C.Matrix4,this.invMatrix=new C.Matrix4,this.points=new Array(8).fill().map(()=>new C.Vector3),this.satAxes=new Array(3).fill().map(()=>new C.Vector3),this.satBounds=new Array(3).fill().map(()=>new St),this.alignedSatBounds=new Array(3).fill().map(()=>new St),this.needsUpdate=!1,s&&this.min.copy(s),t&&this.max.copy(t),e&&this.matrix.copy(e)}set(s,t,e){this.min.copy(s),this.max.copy(t),this.matrix.copy(e),this.needsUpdate=!0}copy(s){this.min.copy(s.min),this.max.copy(s.max),this.matrix.copy(s.matrix),this.needsUpdate=!0}}rt.prototype.update=function(){return function(){const s=this.matrix,t=this.min,e=this.max,i=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let E=0;E<=1;E++){const d=1*c|2*h|4*E,I=i[d];I.x=c?e.x:t.x,I.y=h?e.y:t.y,I.z=E?e.z:t.z,I.applyMatrix4(s)}const o=this.satBounds,n=this.satAxes,r=i[0];for(let c=0;c<3;c++){const h=n[c],E=o[c],d=1<<c,I=i[d];h.subVectors(r,I),E.setFromPoints(h,i)}const a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();rt.prototype.intersectsBox=function(){const l=new St;return function(t){this.needsUpdate&&this.update();const e=t.min,i=t.max,o=this.satBounds,n=this.satAxes,r=this.alignedSatBounds;if(l.min=e.x,l.max=i.x,r[0].isSeparated(l)||(l.min=e.y,l.max=i.y,r[1].isSeparated(l))||(l.min=e.z,l.max=i.z,r[2].isSeparated(l)))return!1;for(let a=0;a<3;a++){const c=n[a],h=o[a];if(l.setFromBox(c,t),h.isSeparated(l))return!1}return!0}}();rt.prototype.intersectsTriangle=function(){const l=new mt,s=new Array(3),t=new St,e=new St,i=new C.Vector3;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(l.copy(n),l.update(),n=l);const r=this.satBounds,a=this.satAxes;s[0]=n.a,s[1]=n.b,s[2]=n.c;for(let d=0;d<3;d++){const I=r[d],f=a[d];if(t.setFromPoints(f,s),I.isSeparated(t))return!1}const c=n.satBounds,h=n.satAxes,E=this.points;for(let d=0;d<3;d++){const I=c[d],f=h[d];if(t.setFromPoints(f,E),I.isSeparated(t))return!1}for(let d=0;d<3;d++){const I=a[d];for(let f=0;f<4;f++){const T=h[f];if(i.crossVectors(I,T),t.setFromPoints(i,s),e.setFromPoints(i,E),t.isSeparated(e))return!1}}return!0}}();rt.prototype.closestPointToPoint=function(){return function(s,t){return this.needsUpdate&&this.update(),t.copy(s).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();rt.prototype.distanceToPoint=function(){const l=new C.Vector3;return function(t){return this.closestPointToPoint(t,l),t.distanceTo(l)}}();rt.prototype.distanceToBox=function(){const l=["x","y","z"],s=new Array(12).fill().map(()=>new C.Line3),t=new Array(12).fill().map(()=>new C.Line3),e=new C.Vector3,i=new C.Vector3;return function(n,r=0,a=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(a||c)&&(n.getCenter(i),this.closestPointToPoint(i,e),n.closestPointToPoint(e,i),a&&a.copy(e),c&&c.copy(i)),0;const h=r*r,E=n.min,d=n.max,I=this.points;let f=1/0;for(let F=0;F<8;F++){const m=I[F];i.copy(m).clamp(E,d);const A=m.distanceToSquared(i);if(A<f&&(f=A,a&&a.copy(m),c&&c.copy(i),A<h))return Math.sqrt(A)}let T=0;for(let F=0;F<3;F++)for(let m=0;m<=1;m++)for(let A=0;A<=1;A++){const O=(F+1)%3,p=(F+2)%3,R=m<<O|A<<p,S=1<<F|m<<O|A<<p,_=I[R],y=I[S];s[T].set(_,y);const P=l[F],x=l[O],w=l[p],U=t[T],b=U.start,v=U.end;b[P]=E[P],b[x]=m?E[x]:d[x],b[w]=A?E[w]:d[x],v[P]=d[P],v[x]=m?E[x]:d[x],v[w]=A?E[w]:d[x],T++}for(let F=0;F<=1;F++)for(let m=0;m<=1;m++)for(let A=0;A<=1;A++){i.x=F?d.x:E.x,i.y=m?d.y:E.y,i.z=A?d.z:E.z,this.closestPointToPoint(i,e);const O=i.distanceToSquared(e);if(O<f&&(f=O,a&&a.copy(e),c&&c.copy(i),O<h))return Math.sqrt(O)}for(let F=0;F<12;F++){const m=s[F];for(let A=0;A<12;A++){const O=t[A];Si(m,O,e,i);const p=e.distanceToSquared(i);if(p<f&&(f=p,a&&a.copy(e),c&&c.copy(i),p<h))return Math.sqrt(p)}}return Math.sqrt(f)}}();class _i{constructor(s){this._getNewPrimitive=s,this._primitives=[]}getPrimitive(){const s=this._primitives;return s.length===0?this._getNewPrimitive():s.pop()}releasePrimitive(s){this._primitives.push(s)}}class Fo extends _i{constructor(){super(()=>new mt)}}const dt=new Fo;function ct(l,s){return s[l+15]===65535}function lt(l,s){return s[l+6]}function Et(l,s){return s[l+14]}function ut(l){return l+8}function It(l,s){return s[l+6]}function Rn(l,s){return s[l+7]}class Ao{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const s=[];let t=null;this.setBuffer=e=>{t&&s.push(t),t=e,this.float32Array=new Float32Array(e),this.uint16Array=new Uint16Array(e),this.uint32Array=new Uint32Array(e)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,s.length!==0&&this.setBuffer(s.pop())}}}const X=new Ao;let Mt,re;const Xt=[],Ye=new _i(()=>new C.Box3);function go(l,s,t,e,i,o){Mt=Ye.getPrimitive(),re=Ye.getPrimitive(),Xt.push(Mt,re),X.setBuffer(l._roots[s]);const n=ni(0,l.geometry,t,e,i,o);X.clearBuffer(),Ye.releasePrimitive(Mt),Ye.releasePrimitive(re),Xt.pop(),Xt.pop();const r=Xt.length;return r>0&&(re=Xt[r-1],Mt=Xt[r-2]),n}function ni(l,s,t,e,i=null,o=0,n=0){const{float32Array:r,uint16Array:a,uint32Array:c}=X;let h=l*2;if(ct(h,a)){const d=lt(l,c),I=Et(h,a);return q(l,r,Mt),e(d,I,!1,n,o+l,Mt)}else{let P=function(w){const{uint16Array:U,uint32Array:b}=X;let v=w*2;for(;!ct(v,U);)w=ut(w),v=w*2;return lt(w,b)},x=function(w){const{uint16Array:U,uint32Array:b}=X;let v=w*2;for(;!ct(v,U);)w=It(w,b),v=w*2;return lt(w,b)+Et(v,U)};const d=ut(l),I=It(l,c);let f=d,T=I,F,m,A,O;if(i&&(A=Mt,O=re,q(f,r,A),q(T,r,O),F=i(A),m=i(O),m<F)){f=I,T=d;const w=F;F=m,m=w,A=O}A||(A=Mt,q(f,r,A));const p=ct(f*2,a),R=t(A,p,F,n+1,o+f);let S;if(R===Di){const w=P(f),b=x(f)-w;S=e(w,b,!0,n+1,o+f,A)}else S=R&&ni(f,s,t,e,i,o,n+1);if(S)return!0;O=re,q(T,r,O);const _=ct(T*2,a),y=t(O,_,m,n+1,o+T);let N;if(y===Di){const w=P(T),b=x(T)-w;N=e(w,b,!0,n+1,o+T,O)}else N=y&&ni(T,s,t,e,i,o,n+1);return!!N}}const Ie=new C.Vector3,Gs=new C.Vector3;function Oo(l,s,t={},e=0,i=1/0){const o=e*e,n=i*i;let r=1/0,a=null;if(l.shapecast({boundsTraverseOrder:h=>(Ie.copy(s).clamp(h.min,h.max),Ie.distanceToSquared(s)),intersectsBounds:(h,E,d)=>d<r&&d<n,intersectsTriangle:(h,E)=>{h.closestPointToPoint(s,Ie);const d=s.distanceToSquared(Ie);return d<r&&(Gs.copy(Ie),r=d,a=E),d<o}}),r===1/0)return null;const c=Math.sqrt(r);return t.point?t.point.copy(Gs):t.point=Gs.clone(),t.distance=c,t.faceIndex=a,t}const Zt=new C.Vector3,Qt=new C.Vector3,jt=new C.Vector3,Ge=new C.Vector2,ze=new C.Vector2,He=new C.Vector2,Bi=new C.Vector3,Vi=new C.Vector3,Yi=new C.Vector3,We=new C.Vector3;function So(l,s,t,e,i,o){let n;return o===C.BackSide?n=l.intersectTriangle(e,t,s,!0,i):n=l.intersectTriangle(s,t,e,o!==C.DoubleSide,i),n===null?null:{distance:l.origin.distanceTo(i),point:i.clone()}}function _o(l,s,t,e,i,o,n,r,a){Zt.fromBufferAttribute(s,o),Qt.fromBufferAttribute(s,n),jt.fromBufferAttribute(s,r);const c=So(l,Zt,Qt,jt,We,a);if(c){e&&(Ge.fromBufferAttribute(e,o),ze.fromBufferAttribute(e,n),He.fromBufferAttribute(e,r),c.uv=C.Triangle.getInterpolation(We,Zt,Qt,jt,Ge,ze,He,new C.Vector2)),i&&(Ge.fromBufferAttribute(i,o),ze.fromBufferAttribute(i,n),He.fromBufferAttribute(i,r),c.uv1=C.Triangle.getInterpolation(We,Zt,Qt,jt,Ge,ze,He,new C.Vector2)),t&&(Bi.fromBufferAttribute(t,o),Vi.fromBufferAttribute(t,n),Yi.fromBufferAttribute(t,r),c.normal=C.Triangle.getInterpolation(We,Zt,Qt,jt,Bi,Vi,Yi,new C.Vector3),c.normal.dot(l.direction)>0&&c.normal.multiplyScalar(-1));const h={a:o,b:n,c:r,normal:new C.Vector3,materialIndex:0};C.Triangle.getNormal(Zt,Qt,jt,h.normal),c.face=h,c.faceIndex=o}return c}function Ls(l,s,t,e,i){const o=e*3;let n=o+0,r=o+1,a=o+2;const c=l.index;l.index&&(n=c.getX(n),r=c.getX(r),a=c.getX(a));const{position:h,normal:E,uv:d,uv1:I}=l.attributes,f=_o(t,h,E,d,I,n,r,a,s);return f?(f.faceIndex=e,i&&i.push(f),f):null}function tt(l,s,t,e){const i=l.a,o=l.b,n=l.c;let r=s,a=s+1,c=s+2;t&&(r=t.getX(r),a=t.getX(a),c=t.getX(c)),i.x=e.getX(r),i.y=e.getY(r),i.z=e.getZ(r),o.x=e.getX(a),o.y=e.getY(a),o.z=e.getZ(a),n.x=e.getX(c),n.y=e.getY(c),n.z=e.getZ(c)}function yo(l,s,t,e,i,o){const{geometry:n,_indirectBuffer:r}=l;for(let a=e,c=e+i;a<c;a++)Ls(n,s,t,a,o)}function No(l,s,t,e,i){const{geometry:o,_indirectBuffer:n}=l;let r=1/0,a=null;for(let c=e,h=e+i;c<h;c++){let E;E=Ls(o,s,t,c),E&&E.distance<r&&(a=E,r=E.distance)}return a}function Lo(l,s,t,e,i,o,n){const{geometry:r}=t,{index:a}=r,c=r.attributes.position;for(let h=l,E=s+l;h<E;h++){let d;if(d=h,tt(n,d*3,a,c),n.needsUpdate=!0,e(n,d,i,o))return!0}return!1}function Po(l,s=null){s&&Array.isArray(s)&&(s=new Set(s));const t=l.geometry,e=t.index?t.index.array:null,i=t.attributes.position;let o,n,r,a,c=0;const h=l._roots;for(let d=0,I=h.length;d<I;d++)o=h[d],n=new Uint32Array(o),r=new Uint16Array(o),a=new Float32Array(o),E(0,c),c+=o.byteLength;function E(d,I,f=!1){const T=d*2;if(r[T+15]===Ns){const m=n[d+6],A=r[T+14];let O=1/0,p=1/0,R=1/0,S=-1/0,_=-1/0,y=-1/0;for(let N=3*m,P=3*(m+A);N<P;N++){let x=e[N];const w=i.getX(x),U=i.getY(x),b=i.getZ(x);w<O&&(O=w),w>S&&(S=w),U<p&&(p=U),U>_&&(_=U),b<R&&(R=b),b>y&&(y=b)}return a[d+0]!==O||a[d+1]!==p||a[d+2]!==R||a[d+3]!==S||a[d+4]!==_||a[d+5]!==y?(a[d+0]=O,a[d+1]=p,a[d+2]=R,a[d+3]=S,a[d+4]=_,a[d+5]=y,!0):!1}else{const m=d+8,A=n[d+6],O=m+I,p=A+I;let R=f,S=!1,_=!1;s?R||(S=s.has(O),_=s.has(p),R=!S&&!_):(S=!0,_=!0);const y=R||S,N=R||_;let P=!1;y&&(P=E(m,I,R));let x=!1;N&&(x=E(A,I,R));const w=P||x;if(w)for(let U=0;U<3;U++){const b=m+U,v=A+U,z=a[b],j=a[b+3],et=a[v],Z=a[v+3];a[d+U]=z<et?z:et,a[d+U+3]=j>Z?j:Z}return w}}}const Gi=new C.Box3;function Ut(l,s,t,e){return q(l,s,Gi),t.intersectBox(Gi,e)}function wo(l,s,t,e,i,o){const{geometry:n,_indirectBuffer:r}=l;for(let a=e,c=e+i;a<c;a++){let h=r?r[a]:a;Ls(n,s,t,h,o)}}function Mo(l,s,t,e,i){const{geometry:o,_indirectBuffer:n}=l;let r=1/0,a=null;for(let c=e,h=e+i;c<h;c++){let E;E=Ls(o,s,t,n?n[c]:c),E&&E.distance<r&&(a=E,r=E.distance)}return a}function Do(l,s,t,e,i,o,n){const{geometry:r}=t,{index:a}=r,c=r.attributes.position;for(let h=l,E=s+l;h<E;h++){let d;if(d=t.resolveTriangleIndex(h),tt(n,d*3,a,c),n.needsUpdate=!0,e(n,d,i,o))return!0}return!1}const zi=new C.Vector3;function xo(l,s,t,e,i){X.setBuffer(l._roots[s]),oi(0,l,t,e,i),X.clearBuffer()}function oi(l,s,t,e,i){const{float32Array:o,uint16Array:n,uint32Array:r}=X,a=l*2;if(ct(a,n)){const h=lt(l,r),E=Et(a,n);yo(s,t,e,h,E,i)}else{const h=ut(l);Ut(h,o,e,zi)&&oi(h,s,t,e,i);const E=It(l,r);Ut(E,o,e,zi)&&oi(E,s,t,e,i)}}const Hi=new C.Vector3,Uo=["x","y","z"];function bo(l,s,t,e){X.setBuffer(l._roots[s]);const i=ri(0,l,t,e);return X.clearBuffer(),i}function ri(l,s,t,e){const{float32Array:i,uint16Array:o,uint32Array:n}=X;let r=l*2;if(ct(r,o)){const c=lt(l,n),h=Et(r,o);return No(s,t,e,c,h)}else{const c=Rn(l,n),h=Uo[c],d=e.direction[h]>=0;let I,f;d?(I=ut(l),f=It(l,n)):(I=It(l,n),f=ut(l));const F=Ut(I,i,e,Hi)?ri(I,s,t,e):null;if(F){const O=F.point[h];if(d?O<=i[f+c]:O>=i[f+c+3])return F}const A=Ut(f,i,e,Hi)?ri(f,s,t,e):null;return F&&A?F.distance<=A.distance?F:A:F||A||null}}const ke=new C.Box3,qt=new mt,Kt=new mt,fe=new C.Matrix4,Wi=new rt,Xe=new rt;function vo(l,s,t,e){X.setBuffer(l._roots[s]);const i=ai(0,l,t,e);return X.clearBuffer(),i}function ai(l,s,t,e,i=null){const{float32Array:o,uint16Array:n,uint32Array:r}=X;let a=l*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Wi.set(t.boundingBox.min,t.boundingBox.max,e),i=Wi),ct(a,n)){const h=s.geometry,E=h.index,d=h.attributes.position,I=t.index,f=t.attributes.position,T=lt(l,r),F=Et(a,n);if(fe.copy(e).invert(),t.boundsTree)return q(l,o,Xe),Xe.matrix.copy(fe),Xe.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:A=>Xe.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(e),A.b.applyMatrix4(e),A.c.applyMatrix4(e),A.needsUpdate=!0;for(let O=T*3,p=(F+T)*3;O<p;O+=3)if(tt(Kt,O,E,d),Kt.needsUpdate=!0,A.intersectsTriangle(Kt))return!0;return!1}});for(let m=T*3,A=(F+T)*3;m<A;m+=3){tt(qt,m,E,d),qt.a.applyMatrix4(fe),qt.b.applyMatrix4(fe),qt.c.applyMatrix4(fe),qt.needsUpdate=!0;for(let O=0,p=I.count;O<p;O+=3)if(tt(Kt,O,I,f),Kt.needsUpdate=!0,qt.intersectsTriangle(Kt))return!0}}else{const h=l+8,E=r[l+6];return q(h,o,ke),!!(i.intersectsBox(ke)&&ai(h,s,t,e,i)||(q(E,o,ke),i.intersectsBox(ke)&&ai(E,s,t,e,i)))}}const Ze=new C.Matrix4,zs=new rt,pe=new rt,Bo=new C.Vector3,Vo=new C.Vector3,Yo=new C.Vector3,Go=new C.Vector3;function zo(l,s,t,e={},i={},o=0,n=1/0){s.boundingBox||s.computeBoundingBox(),zs.set(s.boundingBox.min,s.boundingBox.max,t),zs.needsUpdate=!0;const r=l.geometry,a=r.attributes.position,c=r.index,h=s.attributes.position,E=s.index,d=dt.getPrimitive(),I=dt.getPrimitive();let f=Bo,T=Vo,F=null,m=null;i&&(F=Yo,m=Go);let A=1/0,O=null,p=null;return Ze.copy(t).invert(),pe.matrix.copy(Ze),l.shapecast({boundsTraverseOrder:R=>zs.distanceToBox(R),intersectsBounds:(R,S,_)=>_<A&&_<n?(S&&(pe.min.copy(R.min),pe.max.copy(R.max),pe.needsUpdate=!0),!0):!1,intersectsRange:(R,S)=>{if(s.boundsTree)return s.boundsTree.shapecast({boundsTraverseOrder:y=>pe.distanceToBox(y),intersectsBounds:(y,N,P)=>P<A&&P<n,intersectsRange:(y,N)=>{for(let P=y,x=y+N;P<x;P++){tt(I,3*P,E,h),I.a.applyMatrix4(t),I.b.applyMatrix4(t),I.c.applyMatrix4(t),I.needsUpdate=!0;for(let w=R,U=R+S;w<U;w++){tt(d,3*w,c,a),d.needsUpdate=!0;const b=d.distanceToTriangle(I,f,F);if(b<A&&(T.copy(f),m&&m.copy(F),A=b,O=w,p=P),b<o)return!0}}}});{const _=he(s);for(let y=0,N=_;y<N;y++){tt(I,3*y,E,h),I.a.applyMatrix4(t),I.b.applyMatrix4(t),I.c.applyMatrix4(t),I.needsUpdate=!0;for(let P=R,x=R+S;P<x;P++){tt(d,3*P,c,a),d.needsUpdate=!0;const w=d.distanceToTriangle(I,f,F);if(w<A&&(T.copy(f),m&&m.copy(F),A=w,O=P,p=y),w<o)return!0}}}}}),dt.releasePrimitive(d),dt.releasePrimitive(I),A===1/0?null:(e.point?e.point.copy(T):e.point=T.clone(),e.distance=A,e.faceIndex=O,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Ze),T.applyMatrix4(Ze),i.distance=T.sub(i.point).length(),i.faceIndex=p),e)}function Ho(l,s=null){s&&Array.isArray(s)&&(s=new Set(s));const t=l.geometry,e=t.index?t.index.array:null,i=t.attributes.position;let o,n,r,a,c=0;const h=l._roots;for(let d=0,I=h.length;d<I;d++)o=h[d],n=new Uint32Array(o),r=new Uint16Array(o),a=new Float32Array(o),E(0,c),c+=o.byteLength;function E(d,I,f=!1){const T=d*2;if(r[T+15]===Ns){const m=n[d+6],A=r[T+14];let O=1/0,p=1/0,R=1/0,S=-1/0,_=-1/0,y=-1/0;for(let N=m,P=m+A;N<P;N++){const x=3*l.resolveTriangleIndex(N);for(let w=0;w<3;w++){let U=x+w;U=e?e[U]:U;const b=i.getX(U),v=i.getY(U),z=i.getZ(U);b<O&&(O=b),b>S&&(S=b),v<p&&(p=v),v>_&&(_=v),z<R&&(R=z),z>y&&(y=z)}}return a[d+0]!==O||a[d+1]!==p||a[d+2]!==R||a[d+3]!==S||a[d+4]!==_||a[d+5]!==y?(a[d+0]=O,a[d+1]=p,a[d+2]=R,a[d+3]=S,a[d+4]=_,a[d+5]=y,!0):!1}else{const m=d+8,A=n[d+6],O=m+I,p=A+I;let R=f,S=!1,_=!1;s?R||(S=s.has(O),_=s.has(p),R=!S&&!_):(S=!0,_=!0);const y=R||S,N=R||_;let P=!1;y&&(P=E(m,I,R));let x=!1;N&&(x=E(A,I,R));const w=P||x;if(w)for(let U=0;U<3;U++){const b=m+U,v=A+U,z=a[b],j=a[b+3],et=a[v],Z=a[v+3];a[d+U]=z<et?z:et,a[d+U+3]=j>Z?j:Z}return w}}}const ki=new C.Vector3;function Wo(l,s,t,e,i){X.setBuffer(l._roots[s]),ci(0,l,t,e,i),X.clearBuffer()}function ci(l,s,t,e,i){const{float32Array:o,uint16Array:n,uint32Array:r}=X,a=l*2;if(ct(a,n)){const h=lt(l,r),E=Et(a,n);wo(s,t,e,h,E,i)}else{const h=ut(l);Ut(h,o,e,ki)&&ci(h,s,t,e,i);const E=It(l,r);Ut(E,o,e,ki)&&ci(E,s,t,e,i)}}const Xi=new C.Vector3,ko=["x","y","z"];function Xo(l,s,t,e){X.setBuffer(l._roots[s]);const i=li(0,l,t,e);return X.clearBuffer(),i}function li(l,s,t,e){const{float32Array:i,uint16Array:o,uint32Array:n}=X;let r=l*2;if(ct(r,o)){const c=lt(l,n),h=Et(r,o);return Mo(s,t,e,c,h)}else{const c=Rn(l,n),h=ko[c],d=e.direction[h]>=0;let I,f;d?(I=ut(l),f=It(l,n)):(I=It(l,n),f=ut(l));const F=Ut(I,i,e,Xi)?li(I,s,t,e):null;if(F){const O=F.point[h];if(d?O<=i[f+c]:O>=i[f+c+3])return F}const A=Ut(f,i,e,Xi)?li(f,s,t,e):null;return F&&A?F.distance<=A.distance?F:A:F||A||null}}const Qe=new C.Box3,$t=new mt,Jt=new mt,Ce=new C.Matrix4,Zi=new rt,je=new rt;function Zo(l,s,t,e){X.setBuffer(l._roots[s]);const i=hi(0,l,t,e);return X.clearBuffer(),i}function hi(l,s,t,e,i=null){const{float32Array:o,uint16Array:n,uint32Array:r}=X;let a=l*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Zi.set(t.boundingBox.min,t.boundingBox.max,e),i=Zi),ct(a,n)){const h=s.geometry,E=h.index,d=h.attributes.position,I=t.index,f=t.attributes.position,T=lt(l,r),F=Et(a,n);if(Ce.copy(e).invert(),t.boundsTree)return q(l,o,je),je.matrix.copy(Ce),je.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:A=>je.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(e),A.b.applyMatrix4(e),A.c.applyMatrix4(e),A.needsUpdate=!0;for(let O=T,p=F+T;O<p;O++)if(tt(Jt,3*s.resolveTriangleIndex(O),E,d),Jt.needsUpdate=!0,A.intersectsTriangle(Jt))return!0;return!1}});for(let m=T,A=F+T;m<A;m++){const O=s.resolveTriangleIndex(m);tt($t,3*O,E,d),$t.a.applyMatrix4(Ce),$t.b.applyMatrix4(Ce),$t.c.applyMatrix4(Ce),$t.needsUpdate=!0;for(let p=0,R=I.count;p<R;p+=3)if(tt(Jt,p,I,f),Jt.needsUpdate=!0,$t.intersectsTriangle(Jt))return!0}}else{const h=l+8,E=r[l+6];return q(h,o,Qe),!!(i.intersectsBox(Qe)&&hi(h,s,t,e,i)||(q(E,o,Qe),i.intersectsBox(Qe)&&hi(E,s,t,e,i)))}}const qe=new C.Matrix4,Hs=new rt,Te=new rt,Qo=new C.Vector3,jo=new C.Vector3,qo=new C.Vector3,Ko=new C.Vector3;function $o(l,s,t,e={},i={},o=0,n=1/0){s.boundingBox||s.computeBoundingBox(),Hs.set(s.boundingBox.min,s.boundingBox.max,t),Hs.needsUpdate=!0;const r=l.geometry,a=r.attributes.position,c=r.index,h=s.attributes.position,E=s.index,d=dt.getPrimitive(),I=dt.getPrimitive();let f=Qo,T=jo,F=null,m=null;i&&(F=qo,m=Ko);let A=1/0,O=null,p=null;return qe.copy(t).invert(),Te.matrix.copy(qe),l.shapecast({boundsTraverseOrder:R=>Hs.distanceToBox(R),intersectsBounds:(R,S,_)=>_<A&&_<n?(S&&(Te.min.copy(R.min),Te.max.copy(R.max),Te.needsUpdate=!0),!0):!1,intersectsRange:(R,S)=>{if(s.boundsTree){const _=s.boundsTree;return _.shapecast({boundsTraverseOrder:y=>Te.distanceToBox(y),intersectsBounds:(y,N,P)=>P<A&&P<n,intersectsRange:(y,N)=>{for(let P=y,x=y+N;P<x;P++){const w=_.resolveTriangleIndex(P);tt(I,3*w,E,h),I.a.applyMatrix4(t),I.b.applyMatrix4(t),I.c.applyMatrix4(t),I.needsUpdate=!0;for(let U=R,b=R+S;U<b;U++){const v=l.resolveTriangleIndex(U);tt(d,3*v,c,a),d.needsUpdate=!0;const z=d.distanceToTriangle(I,f,F);if(z<A&&(T.copy(f),m&&m.copy(F),A=z,O=U,p=P),z<o)return!0}}}})}else{const _=he(s);for(let y=0,N=_;y<N;y++){tt(I,3*y,E,h),I.a.applyMatrix4(t),I.b.applyMatrix4(t),I.c.applyMatrix4(t),I.needsUpdate=!0;for(let P=R,x=R+S;P<x;P++){const w=l.resolveTriangleIndex(P);tt(d,3*w,c,a),d.needsUpdate=!0;const U=d.distanceToTriangle(I,f,F);if(U<A&&(T.copy(f),m&&m.copy(F),A=U,O=P,p=y),U<o)return!0}}}}}),dt.releasePrimitive(d),dt.releasePrimitive(I),A===1/0?null:(e.point?e.point.copy(T):e.point=T.clone(),e.distance=A,e.faceIndex=O,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(qe),T.applyMatrix4(qe),i.distance=T.sub(i.point).length(),i.faceIndex=p),e)}function Jo(){return typeof SharedArrayBuffer<"u"}const Ne=new X.constructor,ls=new X.constructor,Pt=new _i(()=>new C.Box3),te=new C.Box3,ee=new C.Box3,Ws=new C.Box3,ks=new C.Box3;let Xs=!1;function tr(l,s,t,e){if(Xs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Xs=!0;const i=l._roots,o=s._roots;let n,r=0,a=0;const c=new C.Matrix4().copy(t).invert();for(let h=0,E=i.length;h<E;h++){Ne.setBuffer(i[h]),a=0;const d=Pt.getPrimitive();q(0,Ne.float32Array,d),d.applyMatrix4(c);for(let I=0,f=o.length;I<f&&(ls.setBuffer(o[h]),n=ft(0,0,t,c,e,r,a,0,0,d),ls.clearBuffer(),a+=o[I].length,!n);I++);if(Pt.releasePrimitive(d),Ne.clearBuffer(),r+=i[h].length,n)break}return Xs=!1,n}function ft(l,s,t,e,i,o=0,n=0,r=0,a=0,c=null,h=!1){let E,d;h?(E=ls,d=Ne):(E=Ne,d=ls);const I=E.float32Array,f=E.uint32Array,T=E.uint16Array,F=d.float32Array,m=d.uint32Array,A=d.uint16Array,O=l*2,p=s*2,R=ct(O,T),S=ct(p,A);let _=!1;if(S&&R)h?_=i(lt(s,m),Et(s*2,A),lt(l,f),Et(l*2,T),a,n+s,r,o+l):_=i(lt(l,f),Et(l*2,T),lt(s,m),Et(s*2,A),r,o+l,a,n+s);else if(S){const y=Pt.getPrimitive();q(s,F,y),y.applyMatrix4(t);const N=ut(l),P=It(l,f);q(N,I,te),q(P,I,ee);const x=y.intersectsBox(te),w=y.intersectsBox(ee);_=x&&ft(s,N,e,t,i,n,o,a,r+1,y,!h)||w&&ft(s,P,e,t,i,n,o,a,r+1,y,!h),Pt.releasePrimitive(y)}else{const y=ut(s),N=It(s,m);q(y,F,Ws),q(N,F,ks);const P=c.intersectsBox(Ws),x=c.intersectsBox(ks);if(P&&x)_=ft(l,y,t,e,i,o,n,r,a+1,c,h)||ft(l,N,t,e,i,o,n,r,a+1,c,h);else if(P)if(R)_=ft(l,y,t,e,i,o,n,r,a+1,c,h);else{const w=Pt.getPrimitive();w.copy(Ws).applyMatrix4(t);const U=ut(l),b=It(l,f);q(U,I,te),q(b,I,ee);const v=w.intersectsBox(te),z=w.intersectsBox(ee);_=v&&ft(y,U,e,t,i,n,o,a,r+1,w,!h)||z&&ft(y,b,e,t,i,n,o,a,r+1,w,!h),Pt.releasePrimitive(w)}else if(x)if(R)_=ft(l,N,t,e,i,o,n,r,a+1,c,h);else{const w=Pt.getPrimitive();w.copy(ks).applyMatrix4(t);const U=ut(l),b=It(l,f);q(U,I,te),q(b,I,ee);const v=w.intersectsBox(te),z=w.intersectsBox(ee);_=v&&ft(N,U,e,t,i,n,o,a,r+1,w,!h)||z&&ft(N,b,e,t,i,n,o,a,r+1,w,!h),Pt.releasePrimitive(w)}}return _}const Ke=new rt,Qi=new C.Box3;class yi{static serialize(s,t={}){t={cloneBuffers:!0,...t};const e=s.geometry,i=s._roots,o=s._indirectBuffer,n=e.getIndex();let r;return t.cloneBuffers?r={roots:i.map(a=>a.slice()),index:n.array.slice(),indirectBuffer:o?o.slice():null}:r={roots:i,index:n.array,indirectBuffer:o},r}static deserialize(s,t,e={}){e={setIndex:!0,indirect:!!s.indirectBuffer,...e};const{index:i,roots:o,indirectBuffer:n}=s,r=new yi(t,{...e,[Bs]:!0});if(r._roots=o,r._indirectBuffer=n||null,e.setIndex){const a=t.getIndex();if(a===null){const c=new C.BufferAttribute(s.index,1,!1);t.setIndex(c)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return r}get indirect(){return!!this._indirectBuffer}constructor(s,t={}){if(s.isBufferGeometry){if(s.index&&s.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:Cn,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[Bs]:!1},t),t.useSharedArrayBuffer&&!Jo())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=s,this._roots=null,this._indirectBuffer=null,t[Bs]||(Co(this,t),!s.boundingBox&&t.setBoundingBox&&(s.boundingBox=this.getBoundingBox(new C.Box3)));const{_indirectBuffer:e}=this;this.resolveTriangleIndex=t.indirect?i=>e[i]:i=>i}refit(s=null){return(this.indirect?Ho:Po)(this,s)}traverse(s,t=0){const e=this._roots[t],i=new Uint32Array(e),o=new Uint16Array(e);n(0);function n(r,a=0){const c=r*2,h=o[c+15]===Ns;if(h){const E=i[r+6],d=o[c+14];s(a,h,new Float32Array(e,r*4,6),E,d)}else{const E=r+rs/4,d=i[r+6],I=i[r+7];s(a,h,new Float32Array(e,r*4,6),I)||(n(E,a+1),n(d,a+1))}}}raycast(s,t=C.FrontSide){const e=this._roots,i=this.geometry,o=[],n=t.isMaterial,r=Array.isArray(t),a=i.groups,c=n?t.side:t,h=this.indirect?Wo:xo;for(let E=0,d=e.length;E<d;E++){const I=r?t[a[E].materialIndex].side:c,f=o.length;if(h(this,E,I,s,o),r){const T=a[E].materialIndex;for(let F=f,m=o.length;F<m;F++)o[F].face.materialIndex=T}}return o}raycastFirst(s,t=C.FrontSide){const e=this._roots,i=this.geometry,o=t.isMaterial,n=Array.isArray(t);let r=null;const a=i.groups,c=o?t.side:t,h=this.indirect?Xo:bo;for(let E=0,d=e.length;E<d;E++){const I=n?t[a[E].materialIndex].side:c,f=h(this,E,I,s);f!=null&&(r==null||f.distance<r.distance)&&(r=f,n&&(f.face.materialIndex=a[E].materialIndex))}return r}intersectsGeometry(s,t){let e=!1;const i=this._roots,o=this.indirect?Zo:vo;for(let n=0,r=i.length;n<r&&(e=o(this,n,s,t),!e);n++);return e}shapecast(s){const t=dt.getPrimitive(),e=this.indirect?Do:Lo;let{boundsTraverseOrder:i,intersectsBounds:o,intersectsRange:n,intersectsTriangle:r}=s;if(n&&r){const E=n;n=(d,I,f,T,F)=>E(d,I,f,T,F)?!0:e(d,I,this,r,f,T,t)}else n||(r?n=(E,d,I,f)=>e(E,d,this,r,I,f,t):n=(E,d,I)=>I);let a=!1,c=0;const h=this._roots;for(let E=0,d=h.length;E<d;E++){const I=h[E];if(a=go(this,E,o,n,i,c),a)break;c+=I.byteLength}return dt.releasePrimitive(t),a}bvhcast(s,t,e){let{intersectsRanges:i,intersectsTriangles:o}=e;const n=dt.getPrimitive(),r=this.geometry.index,a=this.geometry.attributes.position,c=this.indirect?f=>{const T=this.resolveTriangleIndex(f);tt(n,T*3,r,a)}:f=>{tt(n,f*3,r,a)},h=dt.getPrimitive(),E=s.geometry.index,d=s.geometry.attributes.position,I=s.indirect?f=>{const T=s.resolveTriangleIndex(f);tt(h,T*3,E,d)}:f=>{tt(h,f*3,E,d)};if(o){const f=(T,F,m,A,O,p,R,S)=>{for(let _=m,y=m+A;_<y;_++){I(_),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let N=T,P=T+F;N<P;N++)if(c(N),n.needsUpdate=!0,o(n,h,N,_,O,p,R,S))return!0}return!1};if(i){const T=i;i=function(F,m,A,O,p,R,S,_){return T(F,m,A,O,p,R,S,_)?!0:f(F,m,A,O,p,R,S,_)}}else i=f}return tr(this,s,t,i)}intersectsBox(s,t){return Ke.set(s.min,s.max,t),Ke.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Ke.intersectsBox(e),intersectsTriangle:e=>Ke.intersectsTriangle(e)})}intersectsSphere(s){return this.shapecast({intersectsBounds:t=>s.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(s)})}closestPointToGeometry(s,t,e={},i={},o=0,n=1/0){return(this.indirect?$o:zo)(this,s,t,e,i,o,n)}closestPointToPoint(s,t={},e=0,i=1/0){return Oo(this,s,t,e,i)}getBoundingBox(s){return s.makeEmpty(),this._roots.forEach(e=>{q(0,new Float32Array(e),Qi),s.union(Qi)}),s}}function ji(l,s,t){return l===null||(l.point.applyMatrix4(s.matrixWorld),l.distance=l.point.distanceTo(t.ray.origin),l.object=s,l.distance<t.near||l.distance>t.far)?null:l}const Zs=new C.Ray,qi=new C.Matrix4,er=C.Mesh.prototype.raycast;function sr(l,s){if(this.geometry.boundsTree){if(this.material===void 0)return;qi.copy(this.matrixWorld).invert(),Zs.copy(l.ray).applyMatrix4(qi);const t=this.geometry.boundsTree;if(l.firstHitOnly===!0){const e=ji(t.raycastFirst(Zs,this.material),this,l);e&&s.push(e)}else{const e=t.raycast(Zs,this.material);for(let i=0,o=e.length;i<o;i++){const n=ji(e[i],this,l);n&&s.push(n)}}}else er.call(this,l,s)}function ir(l){return this.boundsTree=new yi(this,l),this.boundsTree}function nr(){this.boundsTree=null}class M{constructor(){u(this,"trigger",s=>{const t=this.handlers.slice(0);for(const e of t)e(s)});u(this,"handlers",[])}add(s){this.handlers.push(s)}remove(s){this.handlers=this.handlers.filter(t=>t!==s)}reset(){this.handlers.length=0}}class Le{constructor(){u(this,"trigger",async s=>{const t=this.handlers.slice(0);for(const e of t)await e(s)});u(this,"handlers",[])}add(s){this.handlers.push(s)}remove(s){this.handlers=this.handlers.filter(t=>t!==s)}reset(){this.handlers.length=0}}class Ps{constructor(s){u(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this);u(this,"isResizeable",()=>"resize"in this&&"getSize"in this);u(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this);u(this,"isHideable",()=>"visible"in this);u(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this);this.components=s}}class $ extends Ps{}class ws extends Ps{constructor(t){super(t);u(this,"worlds",new Map);u(this,"onWorldChanged",new M);u(this,"currentWorld",null);this.onWorldChanged.add(({world:e,action:i})=>{i==="removed"&&this.worlds.delete(e.uuid)})}}class Fn extends ws{constructor(){super(...arguments);u(this,"hasCameraControls",()=>"controls"in this)}}class An extends ws{constructor(){super(...arguments);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onDisposed",new M);u(this,"onResize",new M);u(this,"onClippingPlanesUpdated",new M);u(this,"clippingPlanes",[])}updateClippingPlanes(){this.onClippingPlanesUpdated.trigger()}setPlane(t,e,i){e.isLocal=i;const o=this.clippingPlanes.indexOf(e);t&&o===-1?this.clippingPlanes.push(e):!t&&o>-1&&this.clippingPlanes.splice(o,1),this.three.clippingPlanes=this.clippingPlanes.filter(n=>!n.isLocal)}}const Pe=class Pe extends ${constructor(t){super(t);u(this,"_disposedComponents",new Set);u(this,"enabled",!0);t.add(Pe.uuid,this)}get(){return this._disposedComponents}destroy(t,e=!0,i=!0){t.removeFromParent();const o=t;o.dispose&&o.dispose(),this.disposeGeometryAndMaterials(t,e),i&&o.children&&o.children.length&&this.disposeChildren(o),t.children.length=0}disposeGeometry(t){t.boundsTree&&t.disposeBoundsTree&&t.disposeBoundsTree(),t.dispose()}disposeGeometryAndMaterials(t,e){const i=t;i.geometry&&this.disposeGeometry(i.geometry),e&&i.material&&Pe.disposeMaterial(i),i.material=[],i.geometry=null}disposeChildren(t){for(const e of t.children)this.destroy(e)}static disposeMaterial(t){if(t.material)if(Array.isArray(t.material))for(const e of t.material)e.dispose();else t.material.dispose()}};u(Pe,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let _t=Pe;class gn extends ws{constructor(t){super(t);u(this,"onDisposed",new M);u(this,"directionalLights",new Map);u(this,"ambientLights",new Map)}dispose(){const t=this.components.get(_t);for(const e of this.three.children){const i=e;i.geometry&&t.destroy(i)}for(const[,e]of this.directionalLights)e.removeFromParent(),e.target.removeFromParent(),e.dispose();for(const[,e]of this.ambientLights)e.removeFromParent(),e.dispose();this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}}class or extends Set{constructor(t){super(t);u(this,"onItemAdded",new M);u(this,"onItemDeleted",new M);u(this,"onCleared",new M)}clear(){super.clear(),this.onCleared.trigger()}add(t){if(this.has(t))return this;const i=super.add(t);return this.onItemAdded||(this.onItemAdded=new M),this.onItemAdded.trigger(t),i}delete(t){const e=super.delete(t);return e&&this.onItemDeleted.trigger(),e}dispose(){this.clear(),this.onItemAdded.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class di extends Map{constructor(t){super(t);u(this,"onItemSet",new M);u(this,"onItemUpdated",new M);u(this,"onItemDeleted",new M);u(this,"onCleared",new M)}clear(){super.clear(),this.onCleared.trigger()}set(t,e){const i=this.has(t),o=super.set(t,e);return i?(this.onItemUpdated||(this.onItemUpdated=new M),this.onItemUpdated.trigger({key:t,value:e})):(this.onItemSet||(this.onItemSet=new M),this.onItemSet.trigger({key:t,value:e})),o}delete(t){const e=super.delete(t);return e&&this.onItemDeleted.trigger(),e}dispose(){this.clear(),this.onItemSet.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}const as=0,rr=1,ar=new C.Vector3,Ki=new C.Line3,Qs=new C.Plane,$i=new C.Vector3,$e=new C.Triangle;class cr{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new Ji,this.unassigned=new Ji,this.vertices=[]}setFromPoints(s){if(s.length>=4){this.makeEmpty();for(let t=0,e=s.length;t<e;t++)this.vertices.push(new lr(s[t]));this.compute()}return this}setFromObject(s){const t=[];return s.updateMatrixWorld(!0),s.traverse(function(e){const i=e.geometry;if(i!==void 0){const o=i.attributes.position;if(o!==void 0)for(let n=0,r=o.count;n<r;n++){const a=new C.Vector3;a.fromBufferAttribute(o,n).applyMatrix4(e.matrixWorld),t.push(a)}}}),this.setFromPoints(t)}containsPoint(s){const t=this.faces;for(let e=0,i=t.length;e<i;e++)if(t[e].distanceToPoint(s)>this.tolerance)return!1;return!0}intersectRay(s,t){const e=this.faces;let i=-1/0,o=1/0;for(let n=0,r=e.length;n<r;n++){const a=e[n],c=a.distanceToPoint(s.origin),h=a.normal.dot(s.direction);if(c>0&&h>=0)return null;const E=h!==0?-c/h:0;if(!(E<=0)&&(h>0?o=Math.min(E,o):i=Math.max(E,i),i>o))return null}return i!==-1/0?s.at(i,t):s.at(o,t),t}intersectsRay(s){return this.intersectRay(s,ar)!==null}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(s,t){return s.face=t,t.outside===null?this.assigned.append(s):this.assigned.insertBefore(t.outside,s),t.outside=s,this}removeVertexFromFace(s,t){return s===t.outside&&(s.next!==null&&s.next.face===t?t.outside=s.next:t.outside=null),this.assigned.remove(s),this}removeAllVerticesFromFace(s){if(s.outside!==null){const t=s.outside;let e=s.outside;for(;e.next!==null&&e.next.face===s;)e=e.next;return this.assigned.removeSubList(t,e),t.prev=e.next=null,s.outside=null,t}}deleteFaceVertices(s,t){const e=this.removeAllVerticesFromFace(s);if(e!==void 0)if(t===void 0)this.unassigned.appendChain(e);else{let i=e;do{const o=i.next;t.distanceToPoint(i.point)>this.tolerance?this.addVertexToFace(i,t):this.unassigned.append(i),i=o}while(i!==null)}return this}resolveUnassignedPoints(s){if(this.unassigned.isEmpty()===!1){let t=this.unassigned.first();do{const e=t.next;let i=this.tolerance,o=null;for(let n=0;n<s.length;n++){const r=s[n];if(r.mark===as){const a=r.distanceToPoint(t.point);if(a>i&&(i=a,o=r),i>1e3*this.tolerance)break}}o!==null&&this.addVertexToFace(t,o),t=e}while(t!==null)}return this}computeExtremes(){const s=new C.Vector3,t=new C.Vector3,e=[],i=[];for(let o=0;o<3;o++)e[o]=i[o]=this.vertices[0];s.copy(this.vertices[0].point),t.copy(this.vertices[0].point);for(let o=0,n=this.vertices.length;o<n;o++){const r=this.vertices[o],a=r.point;for(let c=0;c<3;c++)a.getComponent(c)<s.getComponent(c)&&(s.setComponent(c,a.getComponent(c)),e[c]=r);for(let c=0;c<3;c++)a.getComponent(c)>t.getComponent(c)&&(t.setComponent(c,a.getComponent(c)),i[c]=r)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(s.x),Math.abs(t.x))+Math.max(Math.abs(s.y),Math.abs(t.y))+Math.max(Math.abs(s.z),Math.abs(t.z))),{min:e,max:i}}computeInitialHull(){const s=this.vertices,t=this.computeExtremes(),e=t.min,i=t.max;let o=0,n=0;for(let d=0;d<3;d++){const I=i[d].point.getComponent(d)-e[d].point.getComponent(d);I>o&&(o=I,n=d)}const r=e[n],a=i[n];let c,h;o=0,Ki.set(r.point,a.point);for(let d=0,I=this.vertices.length;d<I;d++){const f=s[d];if(f!==r&&f!==a){Ki.closestPointToPoint(f.point,!0,$i);const T=$i.distanceToSquared(f.point);T>o&&(o=T,c=f)}}o=-1,Qs.setFromCoplanarPoints(r.point,a.point,c.point);for(let d=0,I=this.vertices.length;d<I;d++){const f=s[d];if(f!==r&&f!==a&&f!==c){const T=Math.abs(Qs.distanceToPoint(f.point));T>o&&(o=T,h=f)}}const E=[];if(Qs.distanceToPoint(h.point)<0){E.push(Ct.create(r,a,c),Ct.create(h,a,r),Ct.create(h,c,a),Ct.create(h,r,c));for(let d=0;d<3;d++){const I=(d+1)%3;E[d+1].getEdge(2).setTwin(E[0].getEdge(I)),E[d+1].getEdge(1).setTwin(E[I+1].getEdge(0))}}else{E.push(Ct.create(r,c,a),Ct.create(h,r,a),Ct.create(h,a,c),Ct.create(h,c,r));for(let d=0;d<3;d++){const I=(d+1)%3;E[d+1].getEdge(2).setTwin(E[0].getEdge((3-d)%3)),E[d+1].getEdge(0).setTwin(E[I+1].getEdge(1))}}for(let d=0;d<4;d++)this.faces.push(E[d]);for(let d=0,I=s.length;d<I;d++){const f=s[d];if(f!==r&&f!==a&&f!==c&&f!==h){o=this.tolerance;let T=null;for(let F=0;F<4;F++){const m=this.faces[F].distanceToPoint(f.point);m>o&&(o=m,T=this.faces[F])}T!==null&&this.addVertexToFace(f,T)}}return this}reindexFaces(){const s=[];for(let t=0;t<this.faces.length;t++){const e=this.faces[t];e.mark===as&&s.push(e)}return this.faces=s,this}nextVertexToAdd(){if(this.assigned.isEmpty()===!1){let s,t=0;const e=this.assigned.first().face;let i=e.outside;do{const o=e.distanceToPoint(i.point);o>t&&(t=o,s=i),i=i.next}while(i!==null&&i.face===e);return s}}computeHorizon(s,t,e,i){this.deleteFaceVertices(e),e.mark=rr;let o;t===null?o=t=e.getEdge(0):o=t.next;do{const n=o.twin,r=n.face;r.mark===as&&(r.distanceToPoint(s)>this.tolerance?this.computeHorizon(s,n,r,i):i.push(o)),o=o.next}while(o!==t);return this}addAdjoiningFace(s,t){const e=Ct.create(s,t.tail(),t.head());return this.faces.push(e),e.getEdge(-1).setTwin(t.twin),e.getEdge(0)}addNewFaces(s,t){this.newFaces=[];let e=null,i=null;for(let o=0;o<t.length;o++){const n=t[o],r=this.addAdjoiningFace(s,n);e===null?e=r:r.next.setTwin(i),this.newFaces.push(r.face),i=r}return e.next.setTwin(i),this}addVertexToHull(s){const t=[];return this.unassigned.clear(),this.removeVertexFromFace(s,s.face),this.computeHorizon(s.point,null,s.face,t),this.addNewFaces(s,t),this.resolveUnassignedPoints(this.newFaces),this}cleanup(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this}compute(){let s;for(this.computeInitialHull();(s=this.nextVertexToAdd())!==void 0;)this.addVertexToHull(s);return this.reindexFaces(),this.cleanup(),this}}class Ct{constructor(){this.normal=new C.Vector3,this.midpoint=new C.Vector3,this.area=0,this.constant=0,this.outside=null,this.mark=as,this.edge=null}static create(s,t,e){const i=new Ct,o=new js(s,i),n=new js(t,i),r=new js(e,i);return o.next=r.prev=n,n.next=o.prev=r,r.next=n.prev=o,i.edge=o,i.compute()}getEdge(s){let t=this.edge;for(;s>0;)t=t.next,s--;for(;s<0;)t=t.prev,s++;return t}compute(){const s=this.edge.tail(),t=this.edge.head(),e=this.edge.next.head();return $e.set(s.point,t.point,e.point),$e.getNormal(this.normal),$e.getMidpoint(this.midpoint),this.area=$e.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(s){return this.normal.dot(s)-this.constant}}class js{constructor(s,t){this.vertex=s,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 s=this.head(),t=this.tail();return t!==null?t.point.distanceTo(s.point):-1}lengthSquared(){const s=this.head(),t=this.tail();return t!==null?t.point.distanceToSquared(s.point):-1}setTwin(s){return this.twin=s,s.twin=this,this}}class lr{constructor(s){this.point=s,this.prev=null,this.next=null,this.face=null}}class Ji{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(s,t){return t.prev=s.prev,t.next=s,t.prev===null?this.head=t:t.prev.next=t,s.prev=t,this}insertAfter(s,t){return t.prev=s,t.next=s.next,t.next===null?this.tail=t:t.next.prev=t,s.next=t,this}append(s){return this.head===null?this.head=s:this.tail.next=s,s.prev=this.tail,s.next=null,this.tail=s,this}appendChain(s){for(this.head===null?this.head=s:this.tail.next=s,s.prev=this.tail;s.next!==null;)s=s.next;return this.tail=s,this}remove(s){return s.prev===null?this.head=s.next:s.prev.next=s.next,s.next===null?this.tail=s.prev:s.next.prev=s.prev,this}removeSubList(s,t){return s.prev===null?this.head=t.next:s.prev.next=t.next,t.next===null?this.tail=s.prev:t.next.prev=s.prev,this}isEmpty(){return this.head===null}}const Ei=[2,2,1],ui=[1,0,0];function gt(l,s){return l*3+s}function hr(l){const s=l.elements;let t=0;for(let e=0;e<9;e++)t+=s[e]*s[e];return Math.sqrt(t)}function dr(l){const s=l.elements;let t=0;for(let e=0;e<3;e++){const i=s[gt(Ei[e],ui[e])];t+=2*i*i}return Math.sqrt(t)}function Er(l,s){let t=0,e=1;const i=l.elements;for(let c=0;c<3;c++){const h=Math.abs(i[gt(Ei[c],ui[c])]);h>t&&(t=h,e=c)}let o=1,n=0;const r=ui[e],a=Ei[e];if(Math.abs(i[gt(a,r)])>Number.EPSILON){const c=i[gt(a,a)],h=i[gt(r,r)],E=i[gt(a,r)],d=(c-h)/2/E;let I;d<0?I=-1/(-d+Math.sqrt(1+d*d)):I=1/(d+Math.sqrt(1+d*d)),o=1/Math.sqrt(1+I*I),n=I*o}return s.identity(),s.elements[gt(r,r)]=o,s.elements[gt(a,a)]=o,s.elements[gt(a,r)]=n,s.elements[gt(r,a)]=-n,s}function ur(l,s){let t=0,e=0;const i=10;s.unitary.identity(),s.diagonal.copy(l);const o=s.unitary,n=s.diagonal,r=new g.Matrix3,a=new g.Matrix3,c=Number.EPSILON*hr(n);for(;e<i&&dr(n)>c;)Er(n,r),a.copy(r).transpose(),n.multiply(r),n.premultiply(a),o.multiply(r),++t>2&&(e++,t=0);return s}function On(l){const s=[];for(let st=0;st<l.length-2;st+=3){const Vt=l[st],J=l[st+1],kt=l[st+2];s.push(new g.Vector3(Vt,J,kt))}const t=new cr;t.setFromPoints(s);const e={unitary:new g.Matrix3,diagonal:new g.Matrix3},i=t.faces,o=[],n=[];for(let st=0,Vt=i.length;st<Vt;st++){const J=i[st];let kt=J.edge;o.length=0;do o.push(kt),kt=kt.next;while(kt!==J.edge);const Qn=o.length-2;for(let be=1,jn=Qn;be<=jn;be++){const xs=o[0].vertex,Us=o[be+0].vertex,bs=o[be+1].vertex;n.push(xs.point.x,xs.point.y,xs.point.z),n.push(Us.point.x,Us.point.y,Us.point.z),n.push(bs.point.x,bs.point.y,bs.point.z)}}const r=new g.Vector3,a=new g.Vector3,c=new g.Vector3,h=new g.Vector3,E=new g.Vector3,d=new g.Vector3,I=new g.Vector3,f=new g.Vector3;let T=0,F=0,m=0,A=0,O=0,p=0,R=0;for(let st=0,Vt=n.length;st<Vt;st+=9){r.fromArray(n,st),a.fromArray(n,st+3),c.fromArray(n,st+6),I.set(0,0,0),I.add(r).add(a).add(c).divideScalar(3),h.subVectors(a,r),E.subVectors(c,r);const J=d.crossVectors(h,E).length()/2;f.add(d.copy(I).multiplyScalar(J)),T+=J,F+=(9*I.x*I.x+r.x*r.x+a.x*a.x+c.x*c.x)*(J/12),m+=(9*I.x*I.y+r.x*r.y+a.x*a.y+c.x*c.y)*(J/12),A+=(9*I.x*I.z+r.x*r.z+a.x*a.z+c.x*c.z)*(J/12),O+=(9*I.y*I.y+r.y*r.y+a.y*a.y+c.y*c.y)*(J/12),p+=(9*I.y*I.z+r.y*r.z+a.y*a.z+c.y*c.z)*(J/12),R+=(9*I.z*I.z+r.z*r.z+a.z*a.z+c.z*c.z)*(J/12)}f.divideScalar(T),F/=T,m/=T,A/=T,O/=T,p/=T,R/=T,F-=f.x*f.x,m-=f.x*f.y,A-=f.x*f.z,O-=f.y*f.y,p-=f.y*f.z,R-=f.z*f.z;const S=new g.Matrix3;S.elements[0]=F,S.elements[1]=m,S.elements[2]=A,S.elements[3]=m,S.elements[4]=O,S.elements[5]=p,S.elements[6]=A,S.elements[7]=p,S.elements[8]=R,ur(S,e);const _=e.unitary,y=new g.Vector3,N=new g.Vector3,P=new g.Vector3;_.extractBasis(y,N,P);let x=-1/0,w=-1/0,U=-1/0,b=1/0,v=1/0,z=1/0;for(let st=0,Vt=s.length;st<Vt;st++){const J=s[st];x=Math.max(y.dot(J),x),w=Math.max(N.dot(J),w),U=Math.max(P.dot(J),U),b=Math.min(y.dot(J),b),v=Math.min(N.dot(J),v),z=Math.min(P.dot(J),z)}y.multiplyScalar(.5*(b+x)),N.multiplyScalar(.5*(v+w)),P.multiplyScalar(.5*(z+U));const j=new g.Vector3,et=new g.Vector3,Z=new g.Matrix3;j.add(y).add(N).add(P),et.x=x-b,et.y=w-v,et.z=U-z,et.multiplyScalar(.5),Z.copy(_);const{x:bt,y:vt,z:Bt}=et,Ue=new g.Matrix4;Ue.makeScale(bt*2,vt*2,Bt*2);const de=new g.Matrix4;de.makeTranslation(-bt,-vt,-Bt);const wi=new g.Matrix4;wi.makeTranslation(j.x,j.y,j.z);const Mi=new g.Matrix4;Mi.setFromMatrix3(Z);const Ee=new g.Matrix4;return Ee.multiply(wi),Ee.multiply(Mi),Ee.multiply(de),Ee.multiply(Ue),{center:j,halfSizes:et,rotation:Z,transformation:Ee}}function Sn(l,s,t){const e=[l[0]-s[0],l[1]-s[1],l[2]-s[2]];return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]>0}class Ii{static isTransparent(s){return s.transparent&&s.opacity<1}}const K=class K{static create(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return`${K._lut[s&255]+K._lut[s>>8&255]+K._lut[s>>16&255]+K._lut[s>>24&255]}-${K._lut[t&255]}${K._lut[t>>8&255]}-${K._lut[t>>16&15|64]}${K._lut[t>>24&255]}-${K._lut[e&63|128]}${K._lut[e>>8&255]}-${K._lut[e>>16&255]}${K._lut[e>>24&255]}${K._lut[i&255]}${K._lut[i>>8&255]}${K._lut[i>>16&255]}${K._lut[i>>24&255]}`.toLowerCase()}static validate(s){if(!K._pattern.test(s))throw new Error(`${s} is not a valid UUID v4.
|
|
2
2
|
|
|
3
3
|
- If you're the tool creator, you can take one from https://www.uuidgenerator.net/.
|
|
4
4
|
|
|
5
|
-
- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};u(K,"_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}$/),u(K,"_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 ae=K;class Ir extends ${constructor(t,e){super(t);u(this,"onDisposed",new M);u(this,"onVertexFound",new M);u(this,"onVertexLost",new M);u(this,"onEnabled",new M);u(this,"components");u(this,"workingPlane",null);u(this,"_pickedPoint",null);u(this,"_config");u(this,"_enabled",!1);this.components=t,this.config={snapDistance:.25,showOnlyVertex:!1,...e},this.enabled=!1}set enabled(t){this._enabled=t,t||(this._pickedPoint=null),this.onEnabled.trigger(t)}get enabled(){return this._enabled}set config(t){this._config={...this._config,...t}}get config(){return this._config}dispose(){this.onVertexFound.reset(),this.onVertexLost.reset(),this.components=null,this.onDisposed.trigger(),this.onDisposed.reset()}get(t){if(!this.enabled)return this._pickedPoint;const o=this.components.get(le).get(t).castRay();if(!o)return this._pickedPoint!==null&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;const n=this.getClosestVertex(o);return n?(this.workingPlane?Math.abs(this.workingPlane.distanceToPoint(n))<.001:!0)?((this._pickedPoint===null||!this._pickedPoint.equals(n))&&(this._pickedPoint=n.clone(),this.onVertexFound.trigger(this._pickedPoint)),this._pickedPoint):(this._pickedPoint=null,this._pickedPoint):(this._pickedPoint!==null&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint)}getClosestVertex(t){let e=new g.Vector3,i=!1,o=Number.MAX_SAFE_INTEGER;const n=this.getVertices(t);if(n===null)return null;for(const r of n){if(!r)continue;const a=t.point.distanceTo(r);a>o||a>this._config.snapDistance||(i=!0,e=r,o=t.point.distanceTo(r))}return i?e:this.config.showOnlyVertex?null:t.point}getVertices(t){const e=t.object;if(!t.face||!e)return null;const i=e.geometry,o=new g.Matrix4,{instanceId:n}=t,r=n!==void 0,a=e instanceof g.InstancedMesh;return a&&r&&e.getMatrixAt(n,o),[this.getVertex(t.face.a,i),this.getVertex(t.face.b,i),this.getVertex(t.face.c,i)].map(c=>(c&&(a&&r&&c.applyMatrix4(o),c.applyMatrix4(e.matrixWorld)),c))}getVertex(t,e){if(t===void 0)return null;const i=e.attributes.position;return new g.Vector3(i.getX(t),i.getY(t),i.getZ(t))}}const ps=class ps{constructor(){u(this,"onDisposed",new M);u(this,"list",new Map);u(this,"enabled",!1);u(this,"_clock");u(this,"update",()=>{if(!this.enabled)return;const s=this._clock.getDelta();for(const[t,e]of this.list)e.enabled&&e.isUpdateable()&&e.update(s);requestAnimationFrame(this.update)});this._clock=new g.Clock,ps.setupBVH()}add(s,t){if(this.list.has(s))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");ae.validate(s),this.list.set(s,t)}get(s){const t=s.uuid;if(!this.list.has(t)){const e=new s(this);return this.list.has(t)||this.add(t,e),e}return this.list.get(t)}init(){this.enabled=!0,this._clock.start(),this.update()}dispose(){this.enabled=!1;for(const[s,t]of this.list)t.enabled=!1,t.isDisposeable()&&t.dispose();this._clock.stop(),this.onDisposed.trigger(),this.onDisposed.reset()}static setupBVH(){g.BufferGeometry.prototype.computeBoundsTree=ir,g.BufferGeometry.prototype.disposeBoundsTree=nr,g.Mesh.prototype.raycast=sr}};u(ps,"release","2.1.
|
|
5
|
+
- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};u(K,"_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}$/),u(K,"_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 ae=K;class Ir extends ${constructor(t,e){super(t);u(this,"onDisposed",new M);u(this,"onVertexFound",new M);u(this,"onVertexLost",new M);u(this,"onEnabled",new M);u(this,"components");u(this,"workingPlane",null);u(this,"_pickedPoint",null);u(this,"_config");u(this,"_enabled",!1);this.components=t,this.config={snapDistance:.25,showOnlyVertex:!1,...e},this.enabled=!1}set enabled(t){this._enabled=t,t||(this._pickedPoint=null),this.onEnabled.trigger(t)}get enabled(){return this._enabled}set config(t){this._config={...this._config,...t}}get config(){return this._config}dispose(){this.onVertexFound.reset(),this.onVertexLost.reset(),this.components=null,this.onDisposed.trigger(),this.onDisposed.reset()}get(t){if(!this.enabled)return this._pickedPoint;const o=this.components.get(le).get(t).castRay();if(!o)return this._pickedPoint!==null&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;const n=this.getClosestVertex(o);return n?(this.workingPlane?Math.abs(this.workingPlane.distanceToPoint(n))<.001:!0)?((this._pickedPoint===null||!this._pickedPoint.equals(n))&&(this._pickedPoint=n.clone(),this.onVertexFound.trigger(this._pickedPoint)),this._pickedPoint):(this._pickedPoint=null,this._pickedPoint):(this._pickedPoint!==null&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint)}getClosestVertex(t){let e=new g.Vector3,i=!1,o=Number.MAX_SAFE_INTEGER;const n=this.getVertices(t);if(n===null)return null;for(const r of n){if(!r)continue;const a=t.point.distanceTo(r);a>o||a>this._config.snapDistance||(i=!0,e=r,o=t.point.distanceTo(r))}return i?e:this.config.showOnlyVertex?null:t.point}getVertices(t){const e=t.object;if(!t.face||!e)return null;const i=e.geometry,o=new g.Matrix4,{instanceId:n}=t,r=n!==void 0,a=e instanceof g.InstancedMesh;return a&&r&&e.getMatrixAt(n,o),[this.getVertex(t.face.a,i),this.getVertex(t.face.b,i),this.getVertex(t.face.c,i)].map(c=>(c&&(a&&r&&c.applyMatrix4(o),c.applyMatrix4(e.matrixWorld)),c))}getVertex(t,e){if(t===void 0)return null;const i=e.attributes.position;return new g.Vector3(i.getX(t),i.getY(t),i.getZ(t))}}const ps=class ps{constructor(){u(this,"onDisposed",new M);u(this,"list",new Map);u(this,"enabled",!1);u(this,"_clock");u(this,"update",()=>{if(!this.enabled)return;const s=this._clock.getDelta();for(const[t,e]of this.list)e.enabled&&e.isUpdateable()&&e.update(s);requestAnimationFrame(this.update)});this._clock=new g.Clock,ps.setupBVH()}add(s,t){if(this.list.has(s))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");ae.validate(s),this.list.set(s,t)}get(s){const t=s.uuid;if(!this.list.has(t)){const e=new s(this);return this.list.has(t)||this.add(t,e),e}return this.list.get(t)}init(){this.enabled=!0,this._clock.start(),this.update()}dispose(){this.enabled=!1;for(const[s,t]of this.list)t.enabled=!1,t.isDisposeable()&&t.dispose();this._clock.stop(),this.onDisposed.trigger(),this.onDisposed.reset()}static setupBVH(){g.BufferGeometry.prototype.computeBoundsTree=ir,g.BufferGeometry.prototype.disposeBoundsTree=nr,g.Mesh.prototype.raycast=sr}};u(ps,"release","2.1.23");let hs=ps;class _n extends Ps{constructor(){super(...arguments);u(this,"meshes",new Set);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onDisposed",new M);u(this,"isDisposing",!1);u(this,"enabled",!0);u(this,"uuid",ae.create());u(this,"name");u(this,"_scene");u(this,"_camera");u(this,"_renderer",null)}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(t){this._scene=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(t){this._camera=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get renderer(){return this._renderer}set renderer(t){this._renderer=t,t&&(t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"}))}update(t){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(t),this.camera.isUpdateable()&&this.camera.update(t),this.renderer&&this.renderer.update(t),this.onAfterUpdate.trigger()))}dispose(t=!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"}),t){const e=this.components.get(_t);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const i of this.meshes)e.destroy(i);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null,this.onDisposed.trigger()}}class yn extends gn{constructor(t){super(t);u(this,"isSetup",!1);u(this,"three");u(this,"onSetup",new M);u(this,"config",{directionalLight:{color:new g.Color("white"),intensity:1.5,position:new g.Vector3(5,10,3)},ambientLight:{color:new g.Color("white"),intensity:1}});this.three=new g.Scene,this.three.background=new g.Color(2107698)}setup(t){this.config={...this.config,...t};const e=new g.DirectionalLight(this.config.directionalLight.color,this.config.directionalLight.intensity);e.position.copy(this.config.directionalLight.position);const i=new g.AmbientLight(this.config.ambientLight.color,this.config.ambientLight.intensity);this.three.add(e,i),this.directionalLights.set(e.uuid,e),this.ambientLights.set(i.uuid,i),this.isSetup=!0,this.onSetup.trigger(this)}}class fr extends An{constructor(t,e,i){super(t);u(this,"enabled",!0);u(this,"container");u(this,"three");u(this,"_canvas");u(this,"_parameters");u(this,"_resizeObserver",null);u(this,"onContainerUpdated",new M);u(this,"_resizing",!1);u(this,"resize",t=>{if(this._resizing)return;this._resizing=!0,this.onContainerUpdated.trigger();const e=t?t.x:this.container.clientWidth,i=t?t.y:this.container.clientHeight;this.three.setSize(e,i),this.onResize.trigger(new g.Vector2(e,i)),this._resizing=!1});u(this,"resizeEvent",()=>{this.resize()});u(this,"onContextLost",t=>{t.preventDefault(),this.enabled=!1});u(this,"onContextBack",()=>{this.three.setRenderTarget(null),this.three.dispose(),this.three=new g.WebGLRenderer({canvas:this._canvas,antialias:!0,alpha:!0,...this._parameters}),this.enabled=!0});this.container=e,this._parameters=i,this.three=new g.WebGLRenderer({antialias:!0,alpha:!0,...i}),this.three.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.setupRenderer(),this.setupEvents(!0),this.resize(),this._canvas=this.three.domElement;const o=this.three.getContext(),{canvas:n}=o;n.addEventListener("webglcontextlost",this.onContextLost,!1),n.addEventListener("webglcontextrestored",this.onContextBack,!1)}update(){if(!this.enabled||!this.currentWorld)return;this.onBeforeUpdate.trigger(this);const t=this.currentWorld.scene.three,e=this.currentWorld.camera.three;this.three.render(t,e),this.onAfterUpdate.trigger(this)}dispose(){this.enabled=!1,this.setupEvents(!1),this.three.domElement.remove(),this.three.dispose(),this.onResize.reset(),this.onAfterUpdate.reset(),this.onBeforeUpdate.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}getSize(){return new g.Vector2(this.three.domElement.clientWidth,this.three.domElement.clientHeight)}setupEvents(t){const e=this.three.domElement.parentElement;if(!e)throw new Error("This renderer needs to have an HTML container!");this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),window.removeEventListener("resize",this.resizeEvent),t&&(this._resizeObserver=new ResizeObserver(this.resizeEvent),this._resizeObserver.observe(e),window.addEventListener("resize",this.resizeEvent))}setupRenderer(){this.three.localClippingEnabled=!0,this.container&&this.container.appendChild(this.three.domElement),this.onContainerUpdated.trigger()}}/*!
|
|
6
6
|
* camera-controls
|
|
7
7
|
* https://github.com/yomotsu/camera-controls
|
|
8
8
|
* (c) 2017 @yomotsu
|
|
9
9
|
* Released under the MIT License.
|
|
10
|
-
*/const V={LEFT:1,RIGHT:2,MIDDLE:4},L=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),se={NONE:0,IN:1,OUT:-1};function Yt(l){return l.isPerspectiveCamera}function Lt(l){return l.isOrthographicCamera}const ie=Math.PI*2,tn=Math.PI/2,Nn=1e-5,me=Math.PI/180;function pt(l,s,t){return Math.max(s,Math.min(t,l))}function k(l,s=Nn){return Math.abs(l)<s}function H(l,s,t=Nn){return k(l-s,t)}function en(l,s){return Math.round(l/s)*s}function Re(l){return isFinite(l)?l:l<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Fe(l){return Math.abs(l)<Number.MAX_VALUE?l:l*(1/0)}function Je(l,s,t,e,i=1/0,o){e=Math.max(1e-4,e);const n=2/e,r=n*o,a=1/(1+r+.48*r*r+.235*r*r*r);let c=l-s;const h=s,E=i*e;c=pt(c,-E,E),s=l-c;const d=(t.value+n*c)*o;t.value=(t.value-n*d)*a;let I=s+(c+d)*a;return h-l>0==I>h&&(I=h,t.value=(I-h)/o),I}function sn(l,s,t,e,i=1/0,o,n){e=Math.max(1e-4,e);const r=2/e,a=r*o,c=1/(1+a+.48*a*a+.235*a*a*a);let h=s.x,E=s.y,d=s.z,I=l.x-h,f=l.y-E,T=l.z-d;const F=h,m=E,A=d,O=i*e,p=O*O,R=I*I+f*f+T*T;if(R>p){const v=Math.sqrt(R);I=I/v*O,f=f/v*O,T=T/v*O}h=l.x-I,E=l.y-f,d=l.z-T;const S=(t.x+r*I)*o,_=(t.y+r*f)*o,y=(t.z+r*T)*o;t.x=(t.x-r*S)*c,t.y=(t.y-r*_)*c,t.z=(t.z-r*y)*c,n.x=h+(I+S)*c,n.y=E+(f+_)*c,n.z=d+(T+y)*c;const N=F-l.x,P=m-l.y,D=A-l.z,w=n.x-F,U=n.y-m,b=n.z-A;return N*w+P*U+D*b>0&&(n.x=F,n.y=m,n.z=A,t.x=(n.x-F)/o,t.y=(n.y-m)/o,t.z=(n.z-A)/o),n}function qs(l,s){s.set(0,0),l.forEach(t=>{s.x+=t.clientX,s.y+=t.clientY}),s.x/=l.length,s.y/=l.length}function Ks(l,s){return Lt(l)?(console.warn(`${s} is not supported in OrthographicCamera`),!0):!1}class pr{constructor(){this._listeners={}}addEventListener(s,t){const e=this._listeners;e[s]===void 0&&(e[s]=[]),e[s].indexOf(t)===-1&&e[s].push(t)}hasEventListener(s,t){const e=this._listeners;return e[s]!==void 0&&e[s].indexOf(t)!==-1}removeEventListener(s,t){const i=this._listeners[s];if(i!==void 0){const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}removeAllEventListeners(s){if(!s){this._listeners={};return}Array.isArray(this._listeners[s])&&(this._listeners[s].length=0)}dispatchEvent(s){const e=this._listeners[s.type];if(e!==void 0){s.target=this;const i=e.slice(0);for(let o=0,n=i.length;o<n;o++)i[o].call(this,s)}}}const Cr="2.7.3",ts=1/8,Ln=typeof window<"u",Tr=Ln&&/Mac/.test(navigator.platform),mr=!(Ln&&"PointerEvent"in window);let B,nn,es,$s,at,Y,G,ne,Ae,Rt,Ft,Gt,on,rn,ht,ge,oe,an,Js,cn,ti,ei,ss;class nt extends pr{static install(s){B=s.THREE,nn=Object.freeze(new B.Vector3(0,0,0)),es=Object.freeze(new B.Vector3(0,1,0)),$s=Object.freeze(new B.Vector3(0,0,1)),at=new B.Vector2,Y=new B.Vector3,G=new B.Vector3,ne=new B.Vector3,Ae=new B.Vector3,Rt=new B.Vector3,Ft=new B.Vector3,Gt=new B.Vector3,on=new B.Vector3,rn=new B.Vector3,ht=new B.Spherical,ge=new B.Spherical,oe=new B.Box3,an=new B.Box3,Js=new B.Sphere,cn=new B.Quaternion,ti=new B.Quaternion,ei=new B.Matrix4,ss=new B.Raycaster}static get ACTION(){return L}constructor(s,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=L.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=se.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new B.Vector3,this._focalOffsetVelocity=new B.Vector3,this._zoomVelocity={value:0},this._truckInternal=(p,R,S)=>{let _,y;if(Yt(this._camera)){const N=Y.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*me,D=N.length()*Math.tan(P*.5);_=this.truckSpeed*p*D/this._elementRect.height,y=this.truckSpeed*R*D/this._elementRect.height}else if(Lt(this._camera)){const N=this._camera;_=p*(N.right-N.left)/N.zoom/this._elementRect.width,y=R*(N.top-N.bottom)/N.zoom/this._elementRect.height}else return;this.verticalDragToForward?(S?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(_,0,!0),this.forward(-y,!0)):S?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y+y,this._focalOffsetEnd.z,!0):this.truck(_,y,!0)},this._rotateInternal=(p,R)=>{const S=ie*this.azimuthRotateSpeed*p/this._elementRect.height,_=ie*this.polarRotateSpeed*R/this._elementRect.height;this.rotate(S,_,!0)},this._dollyInternal=(p,R,S)=>{const _=Math.pow(.95,-p*this.dollySpeed),y=this._sphericalEnd.radius,N=this._sphericalEnd.radius*_,P=pt(N,this.minDistance,this.maxDistance),D=P-N;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(N,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(D,!0),this._dollyToNoClamp(P,!0)):this._dollyToNoClamp(P,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?N:P)-y,this._dollyControlCoord.set(R,S)),this._lastDollyDirection=Math.sign(-p)},this._zoomInternal=(p,R,S)=>{const _=Math.pow(.95,p*this.dollySpeed),y=this._zoom,N=this._zoom*_;this.zoomTo(N,!0),this.dollyToCursor&&(this._changedZoom+=N-y,this._dollyControlCoord.set(R,S))},typeof B>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=s,this._yAxisUpSpace=new B.Quaternion().setFromUnitVectors(this._camera.up,es),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=L.NONE,this._target=new B.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new B.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new B.Spherical().setFromVector3(Y.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new B.Vector3,new B.Vector3,new B.Vector3,new B.Vector3],this._updateNearPlaneCorners(),this._boundary=new B.Box3(new B.Vector3(-1/0,-1/0,-1/0),new B.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new B.Vector2,this.mouseButtons={left:L.ROTATE,middle:L.DOLLY,right:L.TRUCK,wheel:Yt(this._camera)?L.DOLLY:Lt(this._camera)?L.ZOOM:L.NONE},this.touches={one:L.TOUCH_ROTATE,two:Yt(this._camera)?L.TOUCH_DOLLY_TRUCK:Lt(this._camera)?L.TOUCH_ZOOM_TRUCK:L.NONE,three:L.TOUCH_TRUCK};const e=new B.Vector2,i=new B.Vector2,o=new B.Vector2,n=p=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const _=this._domElement.getBoundingClientRect(),y=p.clientX/_.width,N=p.clientY/_.height;if(y<this._interactiveArea.left||y>this._interactiveArea.right||N<this._interactiveArea.top||N>this._interactiveArea.bottom)return}const R=p.pointerType!=="mouse"?null:(p.buttons&V.LEFT)===V.LEFT?V.LEFT:(p.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(p.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(R!==null){const _=this._findPointerByMouseButton(R);_&&this._disposePointer(_)}if((p.buttons&V.LEFT)===V.LEFT&&this._lockedPointer)return;const S={pointerId:p.pointerId,clientX:p.clientX,clientY:p.clientY,deltaX:0,deltaY:0,mouseButton:R};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),this._isDragging=!0,T(p)},r=p=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const _=this._domElement.getBoundingClientRect(),y=p.clientX/_.width,N=p.clientY/_.height;if(y<this._interactiveArea.left||y>this._interactiveArea.right||N<this._interactiveArea.top||N>this._interactiveArea.bottom)return}const R=(p.buttons&V.LEFT)===V.LEFT?V.LEFT:(p.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(p.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(R!==null){const _=this._findPointerByMouseButton(R);_&&this._disposePointer(_)}const S={pointerId:1,clientX:p.clientX,clientY:p.clientY,deltaX:0,deltaY:0,mouseButton:(p.buttons&V.LEFT)===V.LEFT?V.LEFT:(p.buttons&V.MIDDLE)===V.LEFT?V.MIDDLE:(p.buttons&V.RIGHT)===V.LEFT?V.RIGHT:null};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("mousemove",c),this._domElement.ownerDocument.removeEventListener("mouseup",E),this._domElement.ownerDocument.addEventListener("mousemove",c),this._domElement.ownerDocument.addEventListener("mouseup",E),this._isDragging=!0,T(p)},a=p=>{p.cancelable&&p.preventDefault();const R=p.pointerId,S=this._lockedPointer||this._findPointerById(R);if(S){if(S.clientX=p.clientX,S.clientY=p.clientY,S.deltaX=p.movementX,S.deltaY=p.movementY,this._state=0,p.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(p.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(p.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(p.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);F()}},c=p=>{const R=this._lockedPointer||this._findPointerById(1);R&&(R.clientX=p.clientX,R.clientY=p.clientY,R.deltaX=p.movementX,R.deltaY=p.movementY,this._state=0,(this._lockedPointer||(p.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),(p.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(p.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right),F())},h=p=>{const R=this._findPointerById(p.pointerId);if(!(R&&R===this._lockedPointer)){if(R&&this._disposePointer(R),p.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=L.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=L.NONE;m()}},E=()=>{const p=this._findPointerById(1);p&&p===this._lockedPointer||(p&&this._disposePointer(p),this._state=L.NONE,m())};let d=-1;const I=p=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===L.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const N=this._domElement.getBoundingClientRect(),P=p.clientX/N.width,D=p.clientY/N.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}if(p.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===L.ROTATE||this.mouseButtons.wheel===L.TRUCK){const N=performance.now();d-N<1e3&&this._getClientRect(this._elementRect),d=N}const R=Tr?-1:-3,S=p.deltaMode===1?p.deltaY/R:p.deltaY/(R*10),_=this.dollyToCursor?(p.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,y=this.dollyToCursor?(p.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case L.ROTATE:{this._rotateInternal(p.deltaX,p.deltaY),this._isUserControllingRotate=!0;break}case L.TRUCK:{this._truckInternal(p.deltaX,p.deltaY,!1),this._isUserControllingTruck=!0;break}case L.OFFSET:{this._truckInternal(p.deltaX,p.deltaY,!0),this._isUserControllingOffset=!0;break}case L.DOLLY:{this._dollyInternal(-S,_,y),this._isUserControllingDolly=!0;break}case L.ZOOM:{this._zoomInternal(-S,_,y),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=p=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===nt.ACTION.NONE){const R=p instanceof PointerEvent?p.pointerId:(p instanceof MouseEvent,0),S=this._findPointerById(R);S&&this._disposePointer(S),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mousemove",c),this._domElement.ownerDocument.removeEventListener("mouseup",E);return}p.preventDefault()}},T=p=>{if(!this._enabled)return;if(qs(this._activePointers,at),this._getClientRect(this._elementRect),e.copy(at),i.copy(at),this._activePointers.length>=2){const S=at.x-this._activePointers[1].clientX,_=at.y-this._activePointers[1].clientY,y=Math.sqrt(S*S+_*_);o.set(0,y);const N=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,P=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(N,P)}if(this._state=0,!p)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in p&&p.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(p.buttons&V.LEFT)===V.LEFT&&(this._state=this._state|this.mouseButtons.left),(p.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(p.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&L.ROTATE)===L.ROTATE||(this._state&L.TOUCH_ROTATE)===L.TOUCH_ROTATE||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE||(this._state&L.TOUCH_ZOOM_ROTATE)===L.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&L.TRUCK)===L.TRUCK||(this._state&L.TOUCH_TRUCK)===L.TOUCH_TRUCK||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_ZOOM_TRUCK)===L.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&L.DOLLY)===L.DOLLY||(this._state&L.TOUCH_DOLLY)===L.TOUCH_DOLLY||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&L.ZOOM)===L.ZOOM||(this._state&L.TOUCH_ZOOM)===L.TOUCH_ZOOM||(this._state&L.TOUCH_ZOOM_TRUCK)===L.TOUCH_ZOOM_TRUCK||(this._state&L.TOUCH_ZOOM_OFFSET)===L.TOUCH_ZOOM_OFFSET||(this._state&L.TOUCH_ZOOM_ROTATE)===L.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&L.OFFSET)===L.OFFSET||(this._state&L.TOUCH_OFFSET)===L.TOUCH_OFFSET||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET||(this._state&L.TOUCH_ZOOM_OFFSET)===L.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},F=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,qs(this._activePointers,at);const R=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,S=R?-R.deltaX:i.x-at.x,_=R?-R.deltaY:i.y-at.y;if(i.copy(at),((this._state&L.ROTATE)===L.ROTATE||(this._state&L.TOUCH_ROTATE)===L.TOUCH_ROTATE||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE||(this._state&L.TOUCH_ZOOM_ROTATE)===L.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(S,_),this._isUserControllingRotate=!0),(this._state&L.DOLLY)===L.DOLLY||(this._state&L.ZOOM)===L.ZOOM){const y=this.dollyToCursor?(e.x-this._elementRect.x)/this._elementRect.width*2-1:0,N=this.dollyToCursor?(e.y-this._elementRect.y)/this._elementRect.height*-2+1:0,P=this.dollyDragInverted?-1:1;(this._state&L.DOLLY)===L.DOLLY?(this._dollyInternal(P*_*ts,y,N),this._isUserControllingDolly=!0):(this._zoomInternal(P*_*ts,y,N),this._isUserControllingZoom=!0)}if((this._state&L.TOUCH_DOLLY)===L.TOUCH_DOLLY||(this._state&L.TOUCH_ZOOM)===L.TOUCH_ZOOM||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_ZOOM_TRUCK)===L.TOUCH_ZOOM_TRUCK||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET||(this._state&L.TOUCH_ZOOM_OFFSET)===L.TOUCH_ZOOM_OFFSET||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE||(this._state&L.TOUCH_ZOOM_ROTATE)===L.TOUCH_ZOOM_ROTATE){const y=at.x-this._activePointers[1].clientX,N=at.y-this._activePointers[1].clientY,P=Math.sqrt(y*y+N*N),D=o.y-P;o.set(0,P);const w=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,U=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&L.TOUCH_DOLLY)===L.TOUCH_DOLLY||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET?(this._dollyInternal(D*ts,w,U),this._isUserControllingDolly=!0):(this._zoomInternal(D*ts,w,U),this._isUserControllingZoom=!0)}((this._state&L.TRUCK)===L.TRUCK||(this._state&L.TOUCH_TRUCK)===L.TOUCH_TRUCK||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_ZOOM_TRUCK)===L.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(S,_,!1),this._isUserControllingTruck=!0),((this._state&L.OFFSET)===L.OFFSET||(this._state&L.TOUCH_OFFSET)===L.TOUCH_OFFSET||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET||(this._state&L.TOUCH_ZOOM_OFFSET)===L.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(S,_,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},m=()=>{qs(this._activePointers,at),i.copy(at),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",c),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",E),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",A),this._domElement.ownerDocument.addEventListener("pointerlockerror",O),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),T())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",A),this._domElement.ownerDocument.removeEventListener("pointerlockerror",O))};const A=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},O=()=>{this.unlockPointer()};this._addAllEventListeners=p=>{this._domElement=p,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",n),mr&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",I,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",n),this._domElement.removeEventListener("mousedown",r),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",I,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",c),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",E),this._domElement.ownerDocument.removeEventListener("pointerlockchange",A),this._domElement.ownerDocument.removeEventListener("pointerlockerror",O))},this.cancel=()=>{this._state!==L.NONE&&(this._state=L.NONE,this._activePointers.length=0,m())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(s){this._camera=s,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(s){this._enabled=s,this._domElement&&(s?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(s){this._spherical.radius===s&&this._sphericalEnd.radius===s||(this._spherical.radius=s,this._sphericalEnd.radius=s,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(s){this._spherical.theta===s&&this._sphericalEnd.theta===s||(this._spherical.theta=s,this._sphericalEnd.theta=s,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(s){this._spherical.phi===s&&this._sphericalEnd.phi===s||(this._spherical.phi=s,this._sphericalEnd.phi=s,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(s){this._boundaryEnclosesCamera=s,this._needsUpdate=!0}set interactiveArea(s){this._interactiveArea.width=pt(s.width,0,1),this._interactiveArea.height=pt(s.height,0,1),this._interactiveArea.x=pt(s.x,0,1-this._interactiveArea.width),this._interactiveArea.y=pt(s.y,0,1-this._interactiveArea.height)}addEventListener(s,t){super.addEventListener(s,t)}removeEventListener(s,t){super.removeEventListener(s,t)}rotate(s,t,e=!1){return this.rotateTo(this._sphericalEnd.theta+s,this._sphericalEnd.phi+t,e)}rotateAzimuthTo(s,t=!1){return this.rotateTo(s,this._sphericalEnd.phi,t)}rotatePolarTo(s,t=!1){return this.rotateTo(this._sphericalEnd.theta,s,t)}rotateTo(s,t,e=!1){this._isUserControllingRotate=!1;const i=pt(s,this.minAzimuthAngle,this.maxAzimuthAngle),o=pt(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=o,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,e||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const n=!e||H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(n)}dolly(s,t=!1){return this.dollyTo(this._sphericalEnd.radius-s,t)}dollyTo(s,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=se.NONE,this._changedDolly=0,this._dollyToNoClamp(pt(s,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(s,t=!1){const e=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const n=this._collisionTest(),r=H(n,this._spherical.radius);if(!(e>s)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(s,n)}else this._sphericalEnd.radius=s;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const o=!t||H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(o)}dollyInFixed(s,t=!1){this._targetEnd.add(this._getCameraDirection(Ae).multiplyScalar(s)),t||this._target.copy(this._targetEnd);const e=!t||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(e)}zoom(s,t=!1){return this.zoomTo(this._zoomEnd+s,t)}zoomTo(s,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=pt(s,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const e=!t||H(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(e)}pan(s,t,e=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(s,t,e)}truck(s,t,e=!1){this._camera.updateMatrix(),Rt.setFromMatrixColumn(this._camera.matrix,0),Ft.setFromMatrixColumn(this._camera.matrix,1),Rt.multiplyScalar(s),Ft.multiplyScalar(-t);const i=Y.copy(Rt).add(Ft),o=G.copy(this._targetEnd).add(i);return this.moveTo(o.x,o.y,o.z,e)}forward(s,t=!1){Y.setFromMatrixColumn(this._camera.matrix,0),Y.crossVectors(this._camera.up,Y),Y.multiplyScalar(s);const e=G.copy(this._targetEnd).add(Y);return this.moveTo(e.x,e.y,e.z,t)}elevate(s,t=!1){return Y.copy(this._camera.up).multiplyScalar(s),this.moveTo(this._targetEnd.x+Y.x,this._targetEnd.y+Y.y,this._targetEnd.z+Y.z,t)}moveTo(s,t,e,i=!1){this._isUserControllingTruck=!1;const o=Y.set(s,t,e).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,o,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const n=!i||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}lookInDirectionOf(s,t,e,i=!1){const r=Y.set(s,t,e).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,i)}fitToBox(s,t,{cover:e=!1,paddingLeft:i=0,paddingRight:o=0,paddingBottom:n=0,paddingTop:r=0}={}){const a=[],c=s.isBox3?oe.copy(s):oe.setFromObject(s);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=en(this._sphericalEnd.theta,tn),E=en(this._sphericalEnd.phi,tn);a.push(this.rotateTo(h,E,t));const d=Y.setFromSpherical(this._sphericalEnd).normalize(),I=cn.setFromUnitVectors(d,$s),f=H(Math.abs(d.y),1);f&&I.multiply(ti.setFromAxisAngle(es,h)),I.multiply(this._yAxisUpSpaceInverse);const T=an.makeEmpty();G.copy(c.min).applyQuaternion(I),T.expandByPoint(G),G.copy(c.min).setX(c.max.x).applyQuaternion(I),T.expandByPoint(G),G.copy(c.min).setY(c.max.y).applyQuaternion(I),T.expandByPoint(G),G.copy(c.max).setZ(c.min.z).applyQuaternion(I),T.expandByPoint(G),G.copy(c.min).setZ(c.max.z).applyQuaternion(I),T.expandByPoint(G),G.copy(c.max).setY(c.min.y).applyQuaternion(I),T.expandByPoint(G),G.copy(c.max).setX(c.min.x).applyQuaternion(I),T.expandByPoint(G),G.copy(c.max).applyQuaternion(I),T.expandByPoint(G),T.min.x-=i,T.min.y-=n,T.max.x+=o,T.max.y+=r,I.setFromUnitVectors($s,d),f&&I.premultiply(ti.invert()),I.premultiply(this._yAxisUpSpace);const F=T.getSize(Y),m=T.getCenter(G).applyQuaternion(I);if(Yt(this._camera)){const A=this.getDistanceToFitBox(F.x,F.y,F.z,e);a.push(this.moveTo(m.x,m.y,m.z,t)),a.push(this.dollyTo(A,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(Lt(this._camera)){const A=this._camera,O=A.right-A.left,p=A.top-A.bottom,R=e?Math.max(O/F.x,p/F.y):Math.min(O/F.x,p/F.y);a.push(this.moveTo(m.x,m.y,m.z,t)),a.push(this.zoomTo(R,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(s,t){const e=[],o=s instanceof B.Sphere?Js.copy(s):nt.createBoundingSphere(s,Js);if(e.push(this.moveTo(o.center.x,o.center.y,o.center.z,t)),Yt(this._camera)){const n=this.getDistanceToFitSphere(o.radius);e.push(this.dollyTo(n,t))}else if(Lt(this._camera)){const n=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*o.radius,c=Math.min(n/a,r/a);e.push(this.zoomTo(c,t))}return e.push(this.setFocalOffset(0,0,0,t)),Promise.all(e)}setLookAt(s,t,e,i,o,n,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=se.NONE,this._changedDolly=0;const a=G.set(i,o,n),c=Y.set(s,t,e);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(c.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!r||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold)&&H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(s,t,e,i,o,n,r,a,c,h,E,d,I,f=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=se.NONE,this._changedDolly=0;const T=Y.set(i,o,n),F=G.set(s,t,e);ht.setFromVector3(F.sub(T).applyQuaternion(this._yAxisUpSpace));const m=ne.set(h,E,d),A=G.set(r,a,c);ge.setFromVector3(A.sub(m).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(T.lerp(m,I));const O=ge.theta-ht.theta,p=ge.phi-ht.phi,R=ge.radius-ht.radius;this._sphericalEnd.set(ht.radius+R*I,ht.phi+p*I,ht.theta+O*I),this.normalizeRotations(),this._needsUpdate=!0,f||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const S=!f||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold)&&H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(S)}setPosition(s,t,e,i=!1){return this.setLookAt(s,t,e,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(s,t,e,i=!1){const o=this.getPosition(Y),n=this.setLookAt(o.x,o.y,o.z,s,t,e,i);return this._sphericalEnd.phi=pt(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),n}setFocalOffset(s,t,e,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(s,t,e),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const o=!i||H(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&H(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&H(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}setOrbitPoint(s,t,e){this._camera.updateMatrixWorld(),Rt.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Ft.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Gt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=Y.set(s,t,e),o=i.distanceTo(this._camera.position),n=i.sub(this._camera.position);Rt.multiplyScalar(n.x),Ft.multiplyScalar(n.y),Gt.multiplyScalar(n.z),Y.copy(Rt).add(Ft).add(Gt),Y.z=Y.z+o,this.dollyTo(o,!1),this.setFocalOffset(-Y.x,Y.y,-Y.z,!1),this.moveTo(s,t,e,!1)}setBoundary(s){if(!s){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(s),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(s,t,e,i){if(s===null){this._viewport=null;return}this._viewport=this._viewport||new B.Vector4,typeof s=="number"?this._viewport.set(s,t,e,i):this._viewport.copy(s)}getDistanceToFitBox(s,t,e,i=!1){if(Ks(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=s/t,n=this._camera.getEffectiveFOV()*me,r=this._camera.aspect;return((i?o>r:o<r)?t:s/r)*.5/Math.tan(n*.5)+e*.5}getDistanceToFitSphere(s){if(Ks(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*me,e=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,i=1<this._camera.aspect?t:e;return s/Math.sin(i*.5)}getTarget(s,t=!0){return(s&&s.isVector3?s:new B.Vector3).copy(t?this._targetEnd:this._target)}getPosition(s,t=!0){return(s&&s.isVector3?s:new B.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(s,t=!0){return(s&&s instanceof B.Spherical?s:new B.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(s,t=!0){return(s&&s.isVector3?s:new B.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%ie,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=ie),this._spherical.theta+=ie*Math.round((this._sphericalEnd.theta-this._spherical.theta)/ie)}reset(s=!1){if(!H(this._camera.up.x,this._cameraUp0.x)||!H(this._camera.up.y,this._cameraUp0.y)||!H(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const e=this.getPosition(Y);this.updateCameraUp(),this.setPosition(e.x,e.y,e.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,s),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,s),this.zoomTo(this._zoom0,s)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,es),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const s=Y.subVectors(this._target,this._camera.position).normalize(),t=G.crossVectors(s,this._camera.up);this._camera.up.crossVectors(t,s).normalize(),this._camera.updateMatrixWorld();const e=this.getPosition(Y);this.updateCameraUp(),this.setPosition(e.x,e.y,e.z)}update(s){const t=this._sphericalEnd.theta-this._spherical.theta,e=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,o=on.subVectors(this._targetEnd,this._target),n=rn.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(k(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const E=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Je(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,E,1/0,s),this._needsUpdate=!0}if(k(e))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const E=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Je(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,E,1/0,s),this._needsUpdate=!0}if(k(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const E=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Je(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,E,this.maxSpeed,s),this._needsUpdate=!0}if(k(o.x)&&k(o.y)&&k(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const E=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;sn(this._target,this._targetEnd,this._targetVelocity,E,this.maxSpeed,s,this._target),this._needsUpdate=!0}if(k(n.x)&&k(n.y)&&k(n.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const E=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;sn(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,E,this.maxSpeed,s,this._focalOffset),this._needsUpdate=!0}if(k(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const E=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Je(this._zoom,this._zoomEnd,this._zoomVelocity,E,1/0,s)}if(this.dollyToCursor){if(Yt(this._camera)&&this._changedDolly!==0){const E=this._spherical.radius-this._lastDistance,d=this._camera,I=this._getCameraDirection(Ae),f=Y.copy(I).cross(d.up).normalize();f.lengthSq()===0&&(f.x=1);const T=G.crossVectors(f,I),F=this._sphericalEnd.radius*Math.tan(d.getEffectiveFOV()*me*.5),A=(this._sphericalEnd.radius-E-this._sphericalEnd.radius)/this._sphericalEnd.radius,O=ne.copy(this._targetEnd).add(f.multiplyScalar(this._dollyControlCoord.x*F*d.aspect)).add(T.multiplyScalar(this._dollyControlCoord.y*F)),p=Y.copy(this._targetEnd).lerp(O,A),R=this._lastDollyDirection===se.IN&&this._spherical.radius<=this.minDistance,S=this._lastDollyDirection===se.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(R||S)){this._sphericalEnd.radius-=E,this._spherical.radius-=E;const y=G.copy(I).multiplyScalar(-E);p.add(y)}this._boundary.clampPoint(p,p);const _=G.subVectors(p,this._targetEnd);this._targetEnd.copy(p),this._target.add(_),this._changedDolly-=E,k(this._changedDolly)&&(this._changedDolly=0)}else if(Lt(this._camera)&&this._changedZoom!==0){const E=this._zoom-this._lastZoom,d=this._camera,I=Y.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(d.near+d.far)/(d.near-d.far)).unproject(d),f=G.set(0,0,-1).applyQuaternion(d.quaternion),T=ne.copy(I).add(f.multiplyScalar(-I.dot(d.up))),m=-(this._zoom-E-this._zoom)/this._zoom,A=this._getCameraDirection(Ae),O=this._targetEnd.dot(A),p=Y.copy(this._targetEnd).lerp(T,m),R=p.dot(A),S=A.multiplyScalar(R-O);p.sub(S),this._boundary.clampPoint(p,p);const _=G.subVectors(p,this._targetEnd);this._targetEnd.copy(p),this._target.add(_),this._changedZoom-=E,k(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!k(this._focalOffset.x)||!k(this._focalOffset.y)||!k(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Rt.setFromMatrixColumn(this._camera.matrix,0),Ft.setFromMatrixColumn(this._camera.matrix,1),Gt.setFromMatrixColumn(this._camera.matrix,2),Rt.multiplyScalar(this._focalOffset.x),Ft.multiplyScalar(-this._focalOffset.y),Gt.multiplyScalar(this._focalOffset.z),Y.copy(Rt).add(Ft).add(Gt),this._camera.position.add(Y)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Y.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const h=this._needsUpdate;return h&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):h?(this.dispatchEvent({type:"update"}),k(t,this.restThreshold)&&k(e,this.restThreshold)&&k(i,this.restThreshold)&&k(o.x,this.restThreshold)&&k(o.y,this.restThreshold)&&k(o.z,this.restThreshold)&&k(n.x,this.restThreshold)&&k(n.y,this.restThreshold)&&k(n.z,this.restThreshold)&&k(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!h&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=h,this._needsUpdate=!1,h}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Re(this.maxDistance),minZoom:this.minZoom,maxZoom:Re(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Re(this.maxPolarAngle),minAzimuthAngle:Re(this.minAzimuthAngle),maxAzimuthAngle:Re(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:Y.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(s,t=!1){const e=JSON.parse(s);this.enabled=e.enabled,this.minDistance=e.minDistance,this.maxDistance=Fe(e.maxDistance),this.minZoom=e.minZoom,this.maxZoom=Fe(e.maxZoom),this.minPolarAngle=e.minPolarAngle,this.maxPolarAngle=Fe(e.maxPolarAngle),this.minAzimuthAngle=Fe(e.minAzimuthAngle),this.maxAzimuthAngle=Fe(e.maxAzimuthAngle),this.smoothTime=e.smoothTime,this.draggingSmoothTime=e.draggingSmoothTime,this.dollySpeed=e.dollySpeed,this.truckSpeed=e.truckSpeed,this.dollyToCursor=e.dollyToCursor,this.verticalDragToForward=e.verticalDragToForward,this._target0.fromArray(e.target0),this._position0.fromArray(e.position0),this._zoom0=e.zoom0,this._focalOffset0.fromArray(e.focalOffset0),this.moveTo(e.target[0],e.target[1],e.target[2],t),ht.setFromVector3(Y.fromArray(e.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ht.theta,ht.phi,t),this.dollyTo(ht.radius,t),this.zoomTo(e.zoom,t),this.setFocalOffset(e.focalOffset[0],e.focalOffset[1],e.focalOffset[2],t),this._needsUpdate=!0}connect(s){if(this._domElement){console.warn("camera-controls is already connected.");return}s.setAttribute("data-camera-controls-version",Cr),this._addAllEventListeners(s),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(s){return s.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(s){return this._getTargetDirection(s).negate()}_findPointerById(s){return this._activePointers.find(t=>t.pointerId===s)}_findPointerByMouseButton(s){return this._activePointers.find(t=>t.mouseButton===s)}_disposePointer(s){this._activePointers.splice(this._activePointers.indexOf(s),1)}_encloseToBoundary(s,t,e){const i=t.lengthSq();if(i===0)return s;const o=G.copy(t).add(s),r=this._boundary.clampPoint(o,ne).sub(o),a=r.lengthSq();if(a===0)return s.add(t);if(a===i)return s;if(e===0)return s.add(t).add(r);{const c=1+e*a/t.dot(r);return s.add(G.copy(t).multiplyScalar(c)).add(r.multiplyScalar(1-e))}}_updateNearPlaneCorners(){if(Yt(this._camera)){const s=this._camera,t=s.near,e=s.getEffectiveFOV()*me,i=Math.tan(e*.5)*t,o=i*s.aspect;this._nearPlaneCorners[0].set(-o,-i,0),this._nearPlaneCorners[1].set(o,-i,0),this._nearPlaneCorners[2].set(o,i,0),this._nearPlaneCorners[3].set(-o,i,0)}else if(Lt(this._camera)){const s=this._camera,t=1/s.zoom,e=s.left*t,i=s.right*t,o=s.top*t,n=s.bottom*t;this._nearPlaneCorners[0].set(e,o,0),this._nearPlaneCorners[1].set(i,o,0),this._nearPlaneCorners[2].set(i,n,0),this._nearPlaneCorners[3].set(e,n,0)}}_collisionTest(){let s=1/0;if(!(this.colliderMeshes.length>=1)||Ks(this._camera,"_collisionTest"))return s;const e=this._getTargetDirection(Ae);ei.lookAt(nn,e,this._camera.up);for(let i=0;i<4;i++){const o=G.copy(this._nearPlaneCorners[i]);o.applyMatrix4(ei);const n=ne.addVectors(this._target,o);ss.set(n,e),ss.far=this._spherical.radius+1;const r=ss.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<s&&(s=r[0].distance)}return s}_getClientRect(s){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return s.x=t.left,s.y=t.top,this._viewport?(s.x+=this._viewport.x,s.y+=t.height-this._viewport.w-this._viewport.y,s.width=this._viewport.z,s.height=this._viewport.w):(s.width=t.width,s.height=t.height),s}_createOnRestPromise(s){return s?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const e=()=>{this.removeEventListener("rest",e),t()};this.addEventListener("rest",e)}))}_addAllEventListeners(s){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(s){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(s){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(s,t=new B.Sphere){const e=t,i=e.center;oe.makeEmpty(),s.traverseVisible(n=>{n.isMesh&&oe.expandByObject(n)}),oe.getCenter(i);let o=0;return s.traverseVisible(n=>{if(!n.isMesh)return;const r=n,a=r.geometry.clone();a.applyMatrix4(r.matrixWorld);const h=a.attributes.position;for(let E=0,d=h.count;E<d;E++)Y.fromBufferAttribute(h,E),o=Math.max(o,i.distanceToSquared(Y))}),e.radius=Math.sqrt(o),e}}class ce extends Fn{constructor(t){super(t);u(this,"onBeforeUpdate",new M);u(this,"onAfterUpdate",new M);u(this,"onAspectUpdated",new M);u(this,"onDisposed",new M);u(this,"three");u(this,"_allControls",new Map);u(this,"updateAspect",()=>{var t;if(!(!this.currentWorld||!this.currentWorld.renderer)){if(this.three instanceof g.OrthographicCamera){this.onAspectUpdated.trigger();return}if((t=this.currentWorld.renderer)!=null&&t.isResizeable()){const e=this.currentWorld.renderer.getSize();this.three.aspect=e.width/e.height,this.three.updateProjectionMatrix(),this.onAspectUpdated.trigger()}}});this.three=this.setupCamera(),this.setupEvents(!0),this.onWorldChanged.add(({action:e,world:i})=>{if(e==="added"){const o=this.newCameraControls();this._allControls.set(i.uuid,o)}if(e==="removed"){const o=this._allControls.get(i.uuid);o&&(o.dispose(),this._allControls.delete(i.uuid))}})}get controls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");const t=this._allControls.get(this.currentWorld.uuid);if(!t)throw new Error("Controls not found!");return t}get enabled(){return this.currentWorld===null?!1:this.controls.enabled}set enabled(t){this.currentWorld!==null&&(this.controls.enabled=t)}dispose(){this.setupEvents(!1),this.onAspectUpdated.reset(),this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.three.removeFromParent(),this.onDisposed.trigger(),this.onDisposed.reset();for(const[t,e]of this._allControls)e.dispose()}update(t){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(t),this.onAfterUpdate.trigger(this))}setupCamera(){const t=window.innerWidth/window.innerHeight,e=new g.PerspectiveCamera(60,t,1,1e3);return e.position.set(50,50,50),e.lookAt(new g.Vector3(0,0,0)),e}newCameraControls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");nt.install({THREE:ce.getSubsetOfThree()});const{domElement:t}=this.currentWorld.renderer.three,e=new nt(this.three,t);return e.smoothTime=.2,e.dollyToCursor=!0,e.infinityDolly=!0,e.minDistance=6,e}setupEvents(t){t?window.addEventListener("resize",this.updateAspect):window.removeEventListener("resize",this.updateAspect)}static getSubsetOfThree(){return{MOUSE:g.MOUSE,Vector2:g.Vector2,Vector3:g.Vector3,Vector4:g.Vector4,Quaternion:g.Quaternion,Matrix4:g.Matrix4,Spherical:g.Spherical,Box3:g.Box3,Sphere:g.Sphere,Raycaster:g.Raycaster,MathUtils:g.MathUtils}}}const Cs=class Cs extends ${constructor(t){super(t);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onDisposed",new M);u(this,"onWorldCreated",new M);u(this,"onWorldDeleted",new M);u(this,"list",new Map);u(this,"enabled",!0);t.add(Cs.uuid,this)}create(){const t=new _n(this.components),e=t.uuid;if(this.list.has(e))throw new Error("There is already a world with this name!");return this.list.set(e,t),this.onWorldCreated.trigger(t),t}delete(t){if(!this.list.has(t.uuid))throw new Error("The provided world is not found in the list!");const e=t.uuid;this.list.delete(t.uuid),t.dispose(),this.onWorldDeleted.trigger(e)}dispose(){this.enabled=!1;for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}update(t){if(this.enabled)for(const[e,i]of this.list)i.update(t)}};u(Cs,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let ds=Cs;function Rr(l,s,t,e){return new Promise((i,o)=>{function n(){const r=l.clientWaitSync(s,t,0);if(r===l.WAIT_FAILED){o();return}if(r===l.TIMEOUT_EXPIRED){setTimeout(n,e);return}i()}n()})}async function Fr(l,s,t,e,i,o,n){const r=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);l.flush(),await Rr(l,r,0,10),l.deleteSync(r),l.bindBuffer(s,t),l.getBufferSubData(s,e,i,o,n),l.bindBuffer(s,null)}async function Ni(l,s,t,e,i,o,n,r){const a=l.createBuffer();return l.bindBuffer(l.PIXEL_PACK_BUFFER,a),l.bufferData(l.PIXEL_PACK_BUFFER,r.byteLength,l.STREAM_READ),l.readPixels(s,t,e,i,o,n,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),await Fr(l,l.PIXEL_PACK_BUFFER,a,0,r),l.deleteBuffer(a),r}class Pn{constructor(s,t,e){u(this,"onDisposed",new M);u(this,"onViewUpdated",new Le);u(this,"enabled",!0);u(this,"needsUpdate",!1);u(this,"renderDebugFrame",!1);u(this,"components");u(this,"world");u(this,"renderer");u(this,"autoUpdate",!0);u(this,"updateInterval",1e3);u(this,"worker");u(this,"scene",new g.Scene);u(this,"_width",512);u(this,"_height",512);u(this,"_availableColor",1);u(this,"renderTarget");u(this,"bufferSize");u(this,"_buffer");u(this,"_isWorkerBusy",!1);u(this,"updateVisibility",async s=>{if(!this.enabled||!this.needsUpdate&&!s||this._isWorkerBusy)return;this._isWorkerBusy=!0;const t=this.world.camera.three;t.updateMatrix(),this.renderer.setSize(this._width,this._height),this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.scene,t);const e=this.renderer.getContext();await Ni(e,0,0,this._width,this._height,e.RGBA,e.UNSIGNED_BYTE,this._buffer),this.renderer.setRenderTarget(null),this.renderDebugFrame&&this.renderer.render(this.scene,t),this.worker.postMessage({buffer:this._buffer}),this.needsUpdate=!1});if(!t.renderer)throw new Error("The given world must have a renderer!");this.components=s,this.applySettings(e),this.world=t,this.renderer=new g.WebGLRenderer,this.renderTarget=new g.WebGLRenderTarget(this._width,this._height),this.bufferSize=this._width*this._height*4,this._buffer=new Uint8Array(this.bufferSize),this.renderer.clippingPlanes=t.renderer.clippingPlanes;const i=`
|
|
10
|
+
*/const V={LEFT:1,RIGHT:2,MIDDLE:4},L=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),se={NONE:0,IN:1,OUT:-1};function Yt(l){return l.isPerspectiveCamera}function Lt(l){return l.isOrthographicCamera}const ie=Math.PI*2,tn=Math.PI/2,Nn=1e-5,me=Math.PI/180;function pt(l,s,t){return Math.max(s,Math.min(t,l))}function k(l,s=Nn){return Math.abs(l)<s}function H(l,s,t=Nn){return k(l-s,t)}function en(l,s){return Math.round(l/s)*s}function Re(l){return isFinite(l)?l:l<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Fe(l){return Math.abs(l)<Number.MAX_VALUE?l:l*(1/0)}function Je(l,s,t,e,i=1/0,o){e=Math.max(1e-4,e);const n=2/e,r=n*o,a=1/(1+r+.48*r*r+.235*r*r*r);let c=l-s;const h=s,E=i*e;c=pt(c,-E,E),s=l-c;const d=(t.value+n*c)*o;t.value=(t.value-n*d)*a;let I=s+(c+d)*a;return h-l>0==I>h&&(I=h,t.value=(I-h)/o),I}function sn(l,s,t,e,i=1/0,o,n){e=Math.max(1e-4,e);const r=2/e,a=r*o,c=1/(1+a+.48*a*a+.235*a*a*a);let h=s.x,E=s.y,d=s.z,I=l.x-h,f=l.y-E,T=l.z-d;const F=h,m=E,A=d,O=i*e,p=O*O,R=I*I+f*f+T*T;if(R>p){const v=Math.sqrt(R);I=I/v*O,f=f/v*O,T=T/v*O}h=l.x-I,E=l.y-f,d=l.z-T;const S=(t.x+r*I)*o,_=(t.y+r*f)*o,y=(t.z+r*T)*o;t.x=(t.x-r*S)*c,t.y=(t.y-r*_)*c,t.z=(t.z-r*y)*c,n.x=h+(I+S)*c,n.y=E+(f+_)*c,n.z=d+(T+y)*c;const N=F-l.x,P=m-l.y,x=A-l.z,w=n.x-F,U=n.y-m,b=n.z-A;return N*w+P*U+x*b>0&&(n.x=F,n.y=m,n.z=A,t.x=(n.x-F)/o,t.y=(n.y-m)/o,t.z=(n.z-A)/o),n}function qs(l,s){s.set(0,0),l.forEach(t=>{s.x+=t.clientX,s.y+=t.clientY}),s.x/=l.length,s.y/=l.length}function Ks(l,s){return Lt(l)?(console.warn(`${s} is not supported in OrthographicCamera`),!0):!1}class pr{constructor(){this._listeners={}}addEventListener(s,t){const e=this._listeners;e[s]===void 0&&(e[s]=[]),e[s].indexOf(t)===-1&&e[s].push(t)}hasEventListener(s,t){const e=this._listeners;return e[s]!==void 0&&e[s].indexOf(t)!==-1}removeEventListener(s,t){const i=this._listeners[s];if(i!==void 0){const o=i.indexOf(t);o!==-1&&i.splice(o,1)}}removeAllEventListeners(s){if(!s){this._listeners={};return}Array.isArray(this._listeners[s])&&(this._listeners[s].length=0)}dispatchEvent(s){const e=this._listeners[s.type];if(e!==void 0){s.target=this;const i=e.slice(0);for(let o=0,n=i.length;o<n;o++)i[o].call(this,s)}}}const Cr="2.7.3",ts=1/8,Ln=typeof window<"u",Tr=Ln&&/Mac/.test(navigator.platform),mr=!(Ln&&"PointerEvent"in window);let B,nn,es,$s,at,Y,G,ne,Ae,Rt,Ft,Gt,on,rn,ht,ge,oe,an,Js,cn,ti,ei,ss;class nt extends pr{static install(s){B=s.THREE,nn=Object.freeze(new B.Vector3(0,0,0)),es=Object.freeze(new B.Vector3(0,1,0)),$s=Object.freeze(new B.Vector3(0,0,1)),at=new B.Vector2,Y=new B.Vector3,G=new B.Vector3,ne=new B.Vector3,Ae=new B.Vector3,Rt=new B.Vector3,Ft=new B.Vector3,Gt=new B.Vector3,on=new B.Vector3,rn=new B.Vector3,ht=new B.Spherical,ge=new B.Spherical,oe=new B.Box3,an=new B.Box3,Js=new B.Sphere,cn=new B.Quaternion,ti=new B.Quaternion,ei=new B.Matrix4,ss=new B.Raycaster}static get ACTION(){return L}constructor(s,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=L.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=se.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new B.Vector3,this._focalOffsetVelocity=new B.Vector3,this._zoomVelocity={value:0},this._truckInternal=(p,R,S)=>{let _,y;if(Yt(this._camera)){const N=Y.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*me,x=N.length()*Math.tan(P*.5);_=this.truckSpeed*p*x/this._elementRect.height,y=this.truckSpeed*R*x/this._elementRect.height}else if(Lt(this._camera)){const N=this._camera;_=p*(N.right-N.left)/N.zoom/this._elementRect.width,y=R*(N.top-N.bottom)/N.zoom/this._elementRect.height}else return;this.verticalDragToForward?(S?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(_,0,!0),this.forward(-y,!0)):S?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y+y,this._focalOffsetEnd.z,!0):this.truck(_,y,!0)},this._rotateInternal=(p,R)=>{const S=ie*this.azimuthRotateSpeed*p/this._elementRect.height,_=ie*this.polarRotateSpeed*R/this._elementRect.height;this.rotate(S,_,!0)},this._dollyInternal=(p,R,S)=>{const _=Math.pow(.95,-p*this.dollySpeed),y=this._sphericalEnd.radius,N=this._sphericalEnd.radius*_,P=pt(N,this.minDistance,this.maxDistance),x=P-N;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(N,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(x,!0),this._dollyToNoClamp(P,!0)):this._dollyToNoClamp(P,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?N:P)-y,this._dollyControlCoord.set(R,S)),this._lastDollyDirection=Math.sign(-p)},this._zoomInternal=(p,R,S)=>{const _=Math.pow(.95,p*this.dollySpeed),y=this._zoom,N=this._zoom*_;this.zoomTo(N,!0),this.dollyToCursor&&(this._changedZoom+=N-y,this._dollyControlCoord.set(R,S))},typeof B>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=s,this._yAxisUpSpace=new B.Quaternion().setFromUnitVectors(this._camera.up,es),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=L.NONE,this._target=new B.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new B.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new B.Spherical().setFromVector3(Y.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new B.Vector3,new B.Vector3,new B.Vector3,new B.Vector3],this._updateNearPlaneCorners(),this._boundary=new B.Box3(new B.Vector3(-1/0,-1/0,-1/0),new B.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new B.Vector2,this.mouseButtons={left:L.ROTATE,middle:L.DOLLY,right:L.TRUCK,wheel:Yt(this._camera)?L.DOLLY:Lt(this._camera)?L.ZOOM:L.NONE},this.touches={one:L.TOUCH_ROTATE,two:Yt(this._camera)?L.TOUCH_DOLLY_TRUCK:Lt(this._camera)?L.TOUCH_ZOOM_TRUCK:L.NONE,three:L.TOUCH_TRUCK};const e=new B.Vector2,i=new B.Vector2,o=new B.Vector2,n=p=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const _=this._domElement.getBoundingClientRect(),y=p.clientX/_.width,N=p.clientY/_.height;if(y<this._interactiveArea.left||y>this._interactiveArea.right||N<this._interactiveArea.top||N>this._interactiveArea.bottom)return}const R=p.pointerType!=="mouse"?null:(p.buttons&V.LEFT)===V.LEFT?V.LEFT:(p.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(p.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(R!==null){const _=this._findPointerByMouseButton(R);_&&this._disposePointer(_)}if((p.buttons&V.LEFT)===V.LEFT&&this._lockedPointer)return;const S={pointerId:p.pointerId,clientX:p.clientX,clientY:p.clientY,deltaX:0,deltaY:0,mouseButton:R};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),this._isDragging=!0,T(p)},r=p=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const _=this._domElement.getBoundingClientRect(),y=p.clientX/_.width,N=p.clientY/_.height;if(y<this._interactiveArea.left||y>this._interactiveArea.right||N<this._interactiveArea.top||N>this._interactiveArea.bottom)return}const R=(p.buttons&V.LEFT)===V.LEFT?V.LEFT:(p.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(p.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(R!==null){const _=this._findPointerByMouseButton(R);_&&this._disposePointer(_)}const S={pointerId:1,clientX:p.clientX,clientY:p.clientY,deltaX:0,deltaY:0,mouseButton:(p.buttons&V.LEFT)===V.LEFT?V.LEFT:(p.buttons&V.MIDDLE)===V.LEFT?V.MIDDLE:(p.buttons&V.RIGHT)===V.LEFT?V.RIGHT:null};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("mousemove",c),this._domElement.ownerDocument.removeEventListener("mouseup",E),this._domElement.ownerDocument.addEventListener("mousemove",c),this._domElement.ownerDocument.addEventListener("mouseup",E),this._isDragging=!0,T(p)},a=p=>{p.cancelable&&p.preventDefault();const R=p.pointerId,S=this._lockedPointer||this._findPointerById(R);if(S){if(S.clientX=p.clientX,S.clientY=p.clientY,S.deltaX=p.movementX,S.deltaY=p.movementY,this._state=0,p.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(p.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(p.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(p.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);F()}},c=p=>{const R=this._lockedPointer||this._findPointerById(1);R&&(R.clientX=p.clientX,R.clientY=p.clientY,R.deltaX=p.movementX,R.deltaY=p.movementY,this._state=0,(this._lockedPointer||(p.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),(p.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(p.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right),F())},h=p=>{const R=this._findPointerById(p.pointerId);if(!(R&&R===this._lockedPointer)){if(R&&this._disposePointer(R),p.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=L.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=L.NONE;m()}},E=()=>{const p=this._findPointerById(1);p&&p===this._lockedPointer||(p&&this._disposePointer(p),this._state=L.NONE,m())};let d=-1;const I=p=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===L.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const N=this._domElement.getBoundingClientRect(),P=p.clientX/N.width,x=p.clientY/N.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||x<this._interactiveArea.top||x>this._interactiveArea.bottom)return}if(p.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===L.ROTATE||this.mouseButtons.wheel===L.TRUCK){const N=performance.now();d-N<1e3&&this._getClientRect(this._elementRect),d=N}const R=Tr?-1:-3,S=p.deltaMode===1?p.deltaY/R:p.deltaY/(R*10),_=this.dollyToCursor?(p.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,y=this.dollyToCursor?(p.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case L.ROTATE:{this._rotateInternal(p.deltaX,p.deltaY),this._isUserControllingRotate=!0;break}case L.TRUCK:{this._truckInternal(p.deltaX,p.deltaY,!1),this._isUserControllingTruck=!0;break}case L.OFFSET:{this._truckInternal(p.deltaX,p.deltaY,!0),this._isUserControllingOffset=!0;break}case L.DOLLY:{this._dollyInternal(-S,_,y),this._isUserControllingDolly=!0;break}case L.ZOOM:{this._zoomInternal(-S,_,y),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=p=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===nt.ACTION.NONE){const R=p instanceof PointerEvent?p.pointerId:(p instanceof MouseEvent,0),S=this._findPointerById(R);S&&this._disposePointer(S),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mousemove",c),this._domElement.ownerDocument.removeEventListener("mouseup",E);return}p.preventDefault()}},T=p=>{if(!this._enabled)return;if(qs(this._activePointers,at),this._getClientRect(this._elementRect),e.copy(at),i.copy(at),this._activePointers.length>=2){const S=at.x-this._activePointers[1].clientX,_=at.y-this._activePointers[1].clientY,y=Math.sqrt(S*S+_*_);o.set(0,y);const N=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,P=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(N,P)}if(this._state=0,!p)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in p&&p.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(p.buttons&V.LEFT)===V.LEFT&&(this._state=this._state|this.mouseButtons.left),(p.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(p.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&L.ROTATE)===L.ROTATE||(this._state&L.TOUCH_ROTATE)===L.TOUCH_ROTATE||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE||(this._state&L.TOUCH_ZOOM_ROTATE)===L.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&L.TRUCK)===L.TRUCK||(this._state&L.TOUCH_TRUCK)===L.TOUCH_TRUCK||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_ZOOM_TRUCK)===L.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&L.DOLLY)===L.DOLLY||(this._state&L.TOUCH_DOLLY)===L.TOUCH_DOLLY||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&L.ZOOM)===L.ZOOM||(this._state&L.TOUCH_ZOOM)===L.TOUCH_ZOOM||(this._state&L.TOUCH_ZOOM_TRUCK)===L.TOUCH_ZOOM_TRUCK||(this._state&L.TOUCH_ZOOM_OFFSET)===L.TOUCH_ZOOM_OFFSET||(this._state&L.TOUCH_ZOOM_ROTATE)===L.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&L.OFFSET)===L.OFFSET||(this._state&L.TOUCH_OFFSET)===L.TOUCH_OFFSET||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET||(this._state&L.TOUCH_ZOOM_OFFSET)===L.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},F=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,qs(this._activePointers,at);const R=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,S=R?-R.deltaX:i.x-at.x,_=R?-R.deltaY:i.y-at.y;if(i.copy(at),((this._state&L.ROTATE)===L.ROTATE||(this._state&L.TOUCH_ROTATE)===L.TOUCH_ROTATE||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE||(this._state&L.TOUCH_ZOOM_ROTATE)===L.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(S,_),this._isUserControllingRotate=!0),(this._state&L.DOLLY)===L.DOLLY||(this._state&L.ZOOM)===L.ZOOM){const y=this.dollyToCursor?(e.x-this._elementRect.x)/this._elementRect.width*2-1:0,N=this.dollyToCursor?(e.y-this._elementRect.y)/this._elementRect.height*-2+1:0,P=this.dollyDragInverted?-1:1;(this._state&L.DOLLY)===L.DOLLY?(this._dollyInternal(P*_*ts,y,N),this._isUserControllingDolly=!0):(this._zoomInternal(P*_*ts,y,N),this._isUserControllingZoom=!0)}if((this._state&L.TOUCH_DOLLY)===L.TOUCH_DOLLY||(this._state&L.TOUCH_ZOOM)===L.TOUCH_ZOOM||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_ZOOM_TRUCK)===L.TOUCH_ZOOM_TRUCK||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET||(this._state&L.TOUCH_ZOOM_OFFSET)===L.TOUCH_ZOOM_OFFSET||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE||(this._state&L.TOUCH_ZOOM_ROTATE)===L.TOUCH_ZOOM_ROTATE){const y=at.x-this._activePointers[1].clientX,N=at.y-this._activePointers[1].clientY,P=Math.sqrt(y*y+N*N),x=o.y-P;o.set(0,P);const w=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,U=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&L.TOUCH_DOLLY)===L.TOUCH_DOLLY||(this._state&L.TOUCH_DOLLY_ROTATE)===L.TOUCH_DOLLY_ROTATE||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET?(this._dollyInternal(x*ts,w,U),this._isUserControllingDolly=!0):(this._zoomInternal(x*ts,w,U),this._isUserControllingZoom=!0)}((this._state&L.TRUCK)===L.TRUCK||(this._state&L.TOUCH_TRUCK)===L.TOUCH_TRUCK||(this._state&L.TOUCH_DOLLY_TRUCK)===L.TOUCH_DOLLY_TRUCK||(this._state&L.TOUCH_ZOOM_TRUCK)===L.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(S,_,!1),this._isUserControllingTruck=!0),((this._state&L.OFFSET)===L.OFFSET||(this._state&L.TOUCH_OFFSET)===L.TOUCH_OFFSET||(this._state&L.TOUCH_DOLLY_OFFSET)===L.TOUCH_DOLLY_OFFSET||(this._state&L.TOUCH_ZOOM_OFFSET)===L.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(S,_,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},m=()=>{qs(this._activePointers,at),i.copy(at),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",c),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",E),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",A),this._domElement.ownerDocument.addEventListener("pointerlockerror",O),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),T())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",A),this._domElement.ownerDocument.removeEventListener("pointerlockerror",O))};const A=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},O=()=>{this.unlockPointer()};this._addAllEventListeners=p=>{this._domElement=p,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",n),mr&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",I,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",n),this._domElement.removeEventListener("mousedown",r),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",I,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",c),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",E),this._domElement.ownerDocument.removeEventListener("pointerlockchange",A),this._domElement.ownerDocument.removeEventListener("pointerlockerror",O))},this.cancel=()=>{this._state!==L.NONE&&(this._state=L.NONE,this._activePointers.length=0,m())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(s){this._camera=s,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(s){this._enabled=s,this._domElement&&(s?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(s){this._spherical.radius===s&&this._sphericalEnd.radius===s||(this._spherical.radius=s,this._sphericalEnd.radius=s,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(s){this._spherical.theta===s&&this._sphericalEnd.theta===s||(this._spherical.theta=s,this._sphericalEnd.theta=s,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(s){this._spherical.phi===s&&this._sphericalEnd.phi===s||(this._spherical.phi=s,this._sphericalEnd.phi=s,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(s){this._boundaryEnclosesCamera=s,this._needsUpdate=!0}set interactiveArea(s){this._interactiveArea.width=pt(s.width,0,1),this._interactiveArea.height=pt(s.height,0,1),this._interactiveArea.x=pt(s.x,0,1-this._interactiveArea.width),this._interactiveArea.y=pt(s.y,0,1-this._interactiveArea.height)}addEventListener(s,t){super.addEventListener(s,t)}removeEventListener(s,t){super.removeEventListener(s,t)}rotate(s,t,e=!1){return this.rotateTo(this._sphericalEnd.theta+s,this._sphericalEnd.phi+t,e)}rotateAzimuthTo(s,t=!1){return this.rotateTo(s,this._sphericalEnd.phi,t)}rotatePolarTo(s,t=!1){return this.rotateTo(this._sphericalEnd.theta,s,t)}rotateTo(s,t,e=!1){this._isUserControllingRotate=!1;const i=pt(s,this.minAzimuthAngle,this.maxAzimuthAngle),o=pt(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=o,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,e||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const n=!e||H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(n)}dolly(s,t=!1){return this.dollyTo(this._sphericalEnd.radius-s,t)}dollyTo(s,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=se.NONE,this._changedDolly=0,this._dollyToNoClamp(pt(s,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(s,t=!1){const e=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const n=this._collisionTest(),r=H(n,this._spherical.radius);if(!(e>s)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(s,n)}else this._sphericalEnd.radius=s;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const o=!t||H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(o)}dollyInFixed(s,t=!1){this._targetEnd.add(this._getCameraDirection(Ae).multiplyScalar(s)),t||this._target.copy(this._targetEnd);const e=!t||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(e)}zoom(s,t=!1){return this.zoomTo(this._zoomEnd+s,t)}zoomTo(s,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=pt(s,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const e=!t||H(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(e)}pan(s,t,e=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(s,t,e)}truck(s,t,e=!1){this._camera.updateMatrix(),Rt.setFromMatrixColumn(this._camera.matrix,0),Ft.setFromMatrixColumn(this._camera.matrix,1),Rt.multiplyScalar(s),Ft.multiplyScalar(-t);const i=Y.copy(Rt).add(Ft),o=G.copy(this._targetEnd).add(i);return this.moveTo(o.x,o.y,o.z,e)}forward(s,t=!1){Y.setFromMatrixColumn(this._camera.matrix,0),Y.crossVectors(this._camera.up,Y),Y.multiplyScalar(s);const e=G.copy(this._targetEnd).add(Y);return this.moveTo(e.x,e.y,e.z,t)}elevate(s,t=!1){return Y.copy(this._camera.up).multiplyScalar(s),this.moveTo(this._targetEnd.x+Y.x,this._targetEnd.y+Y.y,this._targetEnd.z+Y.z,t)}moveTo(s,t,e,i=!1){this._isUserControllingTruck=!1;const o=Y.set(s,t,e).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,o,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const n=!i||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}lookInDirectionOf(s,t,e,i=!1){const r=Y.set(s,t,e).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,i)}fitToBox(s,t,{cover:e=!1,paddingLeft:i=0,paddingRight:o=0,paddingBottom:n=0,paddingTop:r=0}={}){const a=[],c=s.isBox3?oe.copy(s):oe.setFromObject(s);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=en(this._sphericalEnd.theta,tn),E=en(this._sphericalEnd.phi,tn);a.push(this.rotateTo(h,E,t));const d=Y.setFromSpherical(this._sphericalEnd).normalize(),I=cn.setFromUnitVectors(d,$s),f=H(Math.abs(d.y),1);f&&I.multiply(ti.setFromAxisAngle(es,h)),I.multiply(this._yAxisUpSpaceInverse);const T=an.makeEmpty();G.copy(c.min).applyQuaternion(I),T.expandByPoint(G),G.copy(c.min).setX(c.max.x).applyQuaternion(I),T.expandByPoint(G),G.copy(c.min).setY(c.max.y).applyQuaternion(I),T.expandByPoint(G),G.copy(c.max).setZ(c.min.z).applyQuaternion(I),T.expandByPoint(G),G.copy(c.min).setZ(c.max.z).applyQuaternion(I),T.expandByPoint(G),G.copy(c.max).setY(c.min.y).applyQuaternion(I),T.expandByPoint(G),G.copy(c.max).setX(c.min.x).applyQuaternion(I),T.expandByPoint(G),G.copy(c.max).applyQuaternion(I),T.expandByPoint(G),T.min.x-=i,T.min.y-=n,T.max.x+=o,T.max.y+=r,I.setFromUnitVectors($s,d),f&&I.premultiply(ti.invert()),I.premultiply(this._yAxisUpSpace);const F=T.getSize(Y),m=T.getCenter(G).applyQuaternion(I);if(Yt(this._camera)){const A=this.getDistanceToFitBox(F.x,F.y,F.z,e);a.push(this.moveTo(m.x,m.y,m.z,t)),a.push(this.dollyTo(A,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(Lt(this._camera)){const A=this._camera,O=A.right-A.left,p=A.top-A.bottom,R=e?Math.max(O/F.x,p/F.y):Math.min(O/F.x,p/F.y);a.push(this.moveTo(m.x,m.y,m.z,t)),a.push(this.zoomTo(R,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(s,t){const e=[],o=s instanceof B.Sphere?Js.copy(s):nt.createBoundingSphere(s,Js);if(e.push(this.moveTo(o.center.x,o.center.y,o.center.z,t)),Yt(this._camera)){const n=this.getDistanceToFitSphere(o.radius);e.push(this.dollyTo(n,t))}else if(Lt(this._camera)){const n=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*o.radius,c=Math.min(n/a,r/a);e.push(this.zoomTo(c,t))}return e.push(this.setFocalOffset(0,0,0,t)),Promise.all(e)}setLookAt(s,t,e,i,o,n,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=se.NONE,this._changedDolly=0;const a=G.set(i,o,n),c=Y.set(s,t,e);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(c.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!r||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold)&&H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(s,t,e,i,o,n,r,a,c,h,E,d,I,f=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=se.NONE,this._changedDolly=0;const T=Y.set(i,o,n),F=G.set(s,t,e);ht.setFromVector3(F.sub(T).applyQuaternion(this._yAxisUpSpace));const m=ne.set(h,E,d),A=G.set(r,a,c);ge.setFromVector3(A.sub(m).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(T.lerp(m,I));const O=ge.theta-ht.theta,p=ge.phi-ht.phi,R=ge.radius-ht.radius;this._sphericalEnd.set(ht.radius+R*I,ht.phi+p*I,ht.theta+O*I),this.normalizeRotations(),this._needsUpdate=!0,f||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const S=!f||H(this._target.x,this._targetEnd.x,this.restThreshold)&&H(this._target.y,this._targetEnd.y,this.restThreshold)&&H(this._target.z,this._targetEnd.z,this.restThreshold)&&H(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&H(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&H(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(S)}setPosition(s,t,e,i=!1){return this.setLookAt(s,t,e,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(s,t,e,i=!1){const o=this.getPosition(Y),n=this.setLookAt(o.x,o.y,o.z,s,t,e,i);return this._sphericalEnd.phi=pt(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),n}setFocalOffset(s,t,e,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(s,t,e),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const o=!i||H(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&H(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&H(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}setOrbitPoint(s,t,e){this._camera.updateMatrixWorld(),Rt.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Ft.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Gt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=Y.set(s,t,e),o=i.distanceTo(this._camera.position),n=i.sub(this._camera.position);Rt.multiplyScalar(n.x),Ft.multiplyScalar(n.y),Gt.multiplyScalar(n.z),Y.copy(Rt).add(Ft).add(Gt),Y.z=Y.z+o,this.dollyTo(o,!1),this.setFocalOffset(-Y.x,Y.y,-Y.z,!1),this.moveTo(s,t,e,!1)}setBoundary(s){if(!s){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(s),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(s,t,e,i){if(s===null){this._viewport=null;return}this._viewport=this._viewport||new B.Vector4,typeof s=="number"?this._viewport.set(s,t,e,i):this._viewport.copy(s)}getDistanceToFitBox(s,t,e,i=!1){if(Ks(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=s/t,n=this._camera.getEffectiveFOV()*me,r=this._camera.aspect;return((i?o>r:o<r)?t:s/r)*.5/Math.tan(n*.5)+e*.5}getDistanceToFitSphere(s){if(Ks(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*me,e=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,i=1<this._camera.aspect?t:e;return s/Math.sin(i*.5)}getTarget(s,t=!0){return(s&&s.isVector3?s:new B.Vector3).copy(t?this._targetEnd:this._target)}getPosition(s,t=!0){return(s&&s.isVector3?s:new B.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(s,t=!0){return(s&&s instanceof B.Spherical?s:new B.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(s,t=!0){return(s&&s.isVector3?s:new B.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%ie,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=ie),this._spherical.theta+=ie*Math.round((this._sphericalEnd.theta-this._spherical.theta)/ie)}reset(s=!1){if(!H(this._camera.up.x,this._cameraUp0.x)||!H(this._camera.up.y,this._cameraUp0.y)||!H(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const e=this.getPosition(Y);this.updateCameraUp(),this.setPosition(e.x,e.y,e.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,s),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,s),this.zoomTo(this._zoom0,s)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,es),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const s=Y.subVectors(this._target,this._camera.position).normalize(),t=G.crossVectors(s,this._camera.up);this._camera.up.crossVectors(t,s).normalize(),this._camera.updateMatrixWorld();const e=this.getPosition(Y);this.updateCameraUp(),this.setPosition(e.x,e.y,e.z)}update(s){const t=this._sphericalEnd.theta-this._spherical.theta,e=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,o=on.subVectors(this._targetEnd,this._target),n=rn.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(k(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const E=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Je(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,E,1/0,s),this._needsUpdate=!0}if(k(e))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const E=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Je(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,E,1/0,s),this._needsUpdate=!0}if(k(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const E=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Je(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,E,this.maxSpeed,s),this._needsUpdate=!0}if(k(o.x)&&k(o.y)&&k(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const E=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;sn(this._target,this._targetEnd,this._targetVelocity,E,this.maxSpeed,s,this._target),this._needsUpdate=!0}if(k(n.x)&&k(n.y)&&k(n.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const E=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;sn(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,E,this.maxSpeed,s,this._focalOffset),this._needsUpdate=!0}if(k(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const E=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Je(this._zoom,this._zoomEnd,this._zoomVelocity,E,1/0,s)}if(this.dollyToCursor){if(Yt(this._camera)&&this._changedDolly!==0){const E=this._spherical.radius-this._lastDistance,d=this._camera,I=this._getCameraDirection(Ae),f=Y.copy(I).cross(d.up).normalize();f.lengthSq()===0&&(f.x=1);const T=G.crossVectors(f,I),F=this._sphericalEnd.radius*Math.tan(d.getEffectiveFOV()*me*.5),A=(this._sphericalEnd.radius-E-this._sphericalEnd.radius)/this._sphericalEnd.radius,O=ne.copy(this._targetEnd).add(f.multiplyScalar(this._dollyControlCoord.x*F*d.aspect)).add(T.multiplyScalar(this._dollyControlCoord.y*F)),p=Y.copy(this._targetEnd).lerp(O,A),R=this._lastDollyDirection===se.IN&&this._spherical.radius<=this.minDistance,S=this._lastDollyDirection===se.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(R||S)){this._sphericalEnd.radius-=E,this._spherical.radius-=E;const y=G.copy(I).multiplyScalar(-E);p.add(y)}this._boundary.clampPoint(p,p);const _=G.subVectors(p,this._targetEnd);this._targetEnd.copy(p),this._target.add(_),this._changedDolly-=E,k(this._changedDolly)&&(this._changedDolly=0)}else if(Lt(this._camera)&&this._changedZoom!==0){const E=this._zoom-this._lastZoom,d=this._camera,I=Y.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(d.near+d.far)/(d.near-d.far)).unproject(d),f=G.set(0,0,-1).applyQuaternion(d.quaternion),T=ne.copy(I).add(f.multiplyScalar(-I.dot(d.up))),m=-(this._zoom-E-this._zoom)/this._zoom,A=this._getCameraDirection(Ae),O=this._targetEnd.dot(A),p=Y.copy(this._targetEnd).lerp(T,m),R=p.dot(A),S=A.multiplyScalar(R-O);p.sub(S),this._boundary.clampPoint(p,p);const _=G.subVectors(p,this._targetEnd);this._targetEnd.copy(p),this._target.add(_),this._changedZoom-=E,k(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!k(this._focalOffset.x)||!k(this._focalOffset.y)||!k(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Rt.setFromMatrixColumn(this._camera.matrix,0),Ft.setFromMatrixColumn(this._camera.matrix,1),Gt.setFromMatrixColumn(this._camera.matrix,2),Rt.multiplyScalar(this._focalOffset.x),Ft.multiplyScalar(-this._focalOffset.y),Gt.multiplyScalar(this._focalOffset.z),Y.copy(Rt).add(Ft).add(Gt),this._camera.position.add(Y)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Y.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const h=this._needsUpdate;return h&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):h?(this.dispatchEvent({type:"update"}),k(t,this.restThreshold)&&k(e,this.restThreshold)&&k(i,this.restThreshold)&&k(o.x,this.restThreshold)&&k(o.y,this.restThreshold)&&k(o.z,this.restThreshold)&&k(n.x,this.restThreshold)&&k(n.y,this.restThreshold)&&k(n.z,this.restThreshold)&&k(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!h&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=h,this._needsUpdate=!1,h}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Re(this.maxDistance),minZoom:this.minZoom,maxZoom:Re(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Re(this.maxPolarAngle),minAzimuthAngle:Re(this.minAzimuthAngle),maxAzimuthAngle:Re(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:Y.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(s,t=!1){const e=JSON.parse(s);this.enabled=e.enabled,this.minDistance=e.minDistance,this.maxDistance=Fe(e.maxDistance),this.minZoom=e.minZoom,this.maxZoom=Fe(e.maxZoom),this.minPolarAngle=e.minPolarAngle,this.maxPolarAngle=Fe(e.maxPolarAngle),this.minAzimuthAngle=Fe(e.minAzimuthAngle),this.maxAzimuthAngle=Fe(e.maxAzimuthAngle),this.smoothTime=e.smoothTime,this.draggingSmoothTime=e.draggingSmoothTime,this.dollySpeed=e.dollySpeed,this.truckSpeed=e.truckSpeed,this.dollyToCursor=e.dollyToCursor,this.verticalDragToForward=e.verticalDragToForward,this._target0.fromArray(e.target0),this._position0.fromArray(e.position0),this._zoom0=e.zoom0,this._focalOffset0.fromArray(e.focalOffset0),this.moveTo(e.target[0],e.target[1],e.target[2],t),ht.setFromVector3(Y.fromArray(e.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ht.theta,ht.phi,t),this.dollyTo(ht.radius,t),this.zoomTo(e.zoom,t),this.setFocalOffset(e.focalOffset[0],e.focalOffset[1],e.focalOffset[2],t),this._needsUpdate=!0}connect(s){if(this._domElement){console.warn("camera-controls is already connected.");return}s.setAttribute("data-camera-controls-version",Cr),this._addAllEventListeners(s),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(s){return s.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(s){return this._getTargetDirection(s).negate()}_findPointerById(s){return this._activePointers.find(t=>t.pointerId===s)}_findPointerByMouseButton(s){return this._activePointers.find(t=>t.mouseButton===s)}_disposePointer(s){this._activePointers.splice(this._activePointers.indexOf(s),1)}_encloseToBoundary(s,t,e){const i=t.lengthSq();if(i===0)return s;const o=G.copy(t).add(s),r=this._boundary.clampPoint(o,ne).sub(o),a=r.lengthSq();if(a===0)return s.add(t);if(a===i)return s;if(e===0)return s.add(t).add(r);{const c=1+e*a/t.dot(r);return s.add(G.copy(t).multiplyScalar(c)).add(r.multiplyScalar(1-e))}}_updateNearPlaneCorners(){if(Yt(this._camera)){const s=this._camera,t=s.near,e=s.getEffectiveFOV()*me,i=Math.tan(e*.5)*t,o=i*s.aspect;this._nearPlaneCorners[0].set(-o,-i,0),this._nearPlaneCorners[1].set(o,-i,0),this._nearPlaneCorners[2].set(o,i,0),this._nearPlaneCorners[3].set(-o,i,0)}else if(Lt(this._camera)){const s=this._camera,t=1/s.zoom,e=s.left*t,i=s.right*t,o=s.top*t,n=s.bottom*t;this._nearPlaneCorners[0].set(e,o,0),this._nearPlaneCorners[1].set(i,o,0),this._nearPlaneCorners[2].set(i,n,0),this._nearPlaneCorners[3].set(e,n,0)}}_collisionTest(){let s=1/0;if(!(this.colliderMeshes.length>=1)||Ks(this._camera,"_collisionTest"))return s;const e=this._getTargetDirection(Ae);ei.lookAt(nn,e,this._camera.up);for(let i=0;i<4;i++){const o=G.copy(this._nearPlaneCorners[i]);o.applyMatrix4(ei);const n=ne.addVectors(this._target,o);ss.set(n,e),ss.far=this._spherical.radius+1;const r=ss.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<s&&(s=r[0].distance)}return s}_getClientRect(s){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return s.x=t.left,s.y=t.top,this._viewport?(s.x+=this._viewport.x,s.y+=t.height-this._viewport.w-this._viewport.y,s.width=this._viewport.z,s.height=this._viewport.w):(s.width=t.width,s.height=t.height),s}_createOnRestPromise(s){return s?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const e=()=>{this.removeEventListener("rest",e),t()};this.addEventListener("rest",e)}))}_addAllEventListeners(s){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(s){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(s){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(s,t=new B.Sphere){const e=t,i=e.center;oe.makeEmpty(),s.traverseVisible(n=>{n.isMesh&&oe.expandByObject(n)}),oe.getCenter(i);let o=0;return s.traverseVisible(n=>{if(!n.isMesh)return;const r=n,a=r.geometry.clone();a.applyMatrix4(r.matrixWorld);const h=a.attributes.position;for(let E=0,d=h.count;E<d;E++)Y.fromBufferAttribute(h,E),o=Math.max(o,i.distanceToSquared(Y))}),e.radius=Math.sqrt(o),e}}class ce extends Fn{constructor(t){super(t);u(this,"onBeforeUpdate",new M);u(this,"onAfterUpdate",new M);u(this,"onAspectUpdated",new M);u(this,"onDisposed",new M);u(this,"three");u(this,"_allControls",new Map);u(this,"updateAspect",()=>{var t;if(!(!this.currentWorld||!this.currentWorld.renderer)){if(this.three instanceof g.OrthographicCamera){this.onAspectUpdated.trigger();return}if((t=this.currentWorld.renderer)!=null&&t.isResizeable()){const e=this.currentWorld.renderer.getSize();this.three.aspect=e.width/e.height,this.three.updateProjectionMatrix(),this.onAspectUpdated.trigger()}}});this.three=this.setupCamera(),this.setupEvents(!0),this.onWorldChanged.add(({action:e,world:i})=>{if(e==="added"){const o=this.newCameraControls();this._allControls.set(i.uuid,o)}if(e==="removed"){const o=this._allControls.get(i.uuid);o&&(o.dispose(),this._allControls.delete(i.uuid))}})}get controls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");const t=this._allControls.get(this.currentWorld.uuid);if(!t)throw new Error("Controls not found!");return t}get enabled(){return this.currentWorld===null?!1:this.controls.enabled}set enabled(t){this.currentWorld!==null&&(this.controls.enabled=t)}dispose(){this.setupEvents(!1),this.onAspectUpdated.reset(),this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.three.removeFromParent(),this.onDisposed.trigger(),this.onDisposed.reset();for(const[t,e]of this._allControls)e.dispose()}update(t){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(t),this.onAfterUpdate.trigger(this))}setupCamera(){const t=window.innerWidth/window.innerHeight,e=new g.PerspectiveCamera(60,t,1,1e3);return e.position.set(50,50,50),e.lookAt(new g.Vector3(0,0,0)),e}newCameraControls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");nt.install({THREE:ce.getSubsetOfThree()});const{domElement:t}=this.currentWorld.renderer.three,e=new nt(this.three,t);return e.smoothTime=.2,e.dollyToCursor=!0,e.infinityDolly=!0,e.minDistance=6,e}setupEvents(t){t?window.addEventListener("resize",this.updateAspect):window.removeEventListener("resize",this.updateAspect)}static getSubsetOfThree(){return{MOUSE:g.MOUSE,Vector2:g.Vector2,Vector3:g.Vector3,Vector4:g.Vector4,Quaternion:g.Quaternion,Matrix4:g.Matrix4,Spherical:g.Spherical,Box3:g.Box3,Sphere:g.Sphere,Raycaster:g.Raycaster,MathUtils:g.MathUtils}}}const Cs=class Cs extends ${constructor(t){super(t);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onDisposed",new M);u(this,"onWorldCreated",new M);u(this,"onWorldDeleted",new M);u(this,"list",new Map);u(this,"enabled",!0);t.add(Cs.uuid,this)}create(){const t=new _n(this.components),e=t.uuid;if(this.list.has(e))throw new Error("There is already a world with this name!");return this.list.set(e,t),this.onWorldCreated.trigger(t),t}delete(t){if(!this.list.has(t.uuid))throw new Error("The provided world is not found in the list!");const e=t.uuid;this.list.delete(t.uuid),t.dispose(),this.onWorldDeleted.trigger(e)}dispose(){this.enabled=!1;for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}update(t){if(this.enabled)for(const[e,i]of this.list)i.update(t)}};u(Cs,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let ds=Cs;function Rr(l,s,t,e){return new Promise((i,o)=>{function n(){const r=l.clientWaitSync(s,t,0);if(r===l.WAIT_FAILED){o();return}if(r===l.TIMEOUT_EXPIRED){setTimeout(n,e);return}i()}n()})}async function Fr(l,s,t,e,i,o,n){const r=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);l.flush(),await Rr(l,r,0,10),l.deleteSync(r),l.bindBuffer(s,t),l.getBufferSubData(s,e,i,o,n),l.bindBuffer(s,null)}async function Ni(l,s,t,e,i,o,n,r){const a=l.createBuffer();return l.bindBuffer(l.PIXEL_PACK_BUFFER,a),l.bufferData(l.PIXEL_PACK_BUFFER,r.byteLength,l.STREAM_READ),l.readPixels(s,t,e,i,o,n,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),await Fr(l,l.PIXEL_PACK_BUFFER,a,0,r),l.deleteBuffer(a),r}class Pn{constructor(s,t,e){u(this,"onDisposed",new M);u(this,"onViewUpdated",new Le);u(this,"enabled",!0);u(this,"needsUpdate",!1);u(this,"renderDebugFrame",!1);u(this,"components");u(this,"world");u(this,"renderer");u(this,"autoUpdate",!0);u(this,"updateInterval",1e3);u(this,"worker");u(this,"scene",new g.Scene);u(this,"_width",512);u(this,"_height",512);u(this,"_availableColor",1);u(this,"renderTarget");u(this,"bufferSize");u(this,"_buffer");u(this,"_isWorkerBusy",!1);u(this,"updateVisibility",async s=>{if(!this.enabled||!this.needsUpdate&&!s||this._isWorkerBusy)return;this._isWorkerBusy=!0;const t=this.world.camera.three;t.updateMatrix(),this.renderer.setSize(this._width,this._height),this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.scene,t);const e=this.renderer.getContext();await Ni(e,0,0,this._width,this._height,e.RGBA,e.UNSIGNED_BYTE,this._buffer),this.renderer.setRenderTarget(null),this.renderDebugFrame&&this.renderer.render(this.scene,t),this.worker.postMessage({buffer:this._buffer}),this.needsUpdate=!1});if(!t.renderer)throw new Error("The given world must have a renderer!");this.components=s,this.applySettings(e),this.world=t,this.renderer=new g.WebGLRenderer,this.renderTarget=new g.WebGLRenderTarget(this._width,this._height),this.bufferSize=this._width*this._height*4,this._buffer=new Uint8Array(this.bufferSize),this.renderer.clippingPlanes=t.renderer.clippingPlanes;const i=`
|
|
11
11
|
addEventListener("message", (event) => {
|
|
12
12
|
const { buffer } = event.data;
|
|
13
13
|
const colors = new Map();
|
|
@@ -125,4 +125,4 @@ void main() {
|
|
|
125
125
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
`,extensions:{derivatives:!0}});this.three=new g.Mesh(a,c),this.three.frustumCulled=!1,t.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(s){s?this.world.scene.three.add(this.three):this.three.removeFromParent()}get material(){return this.three.material}get fade(){return this._fade===3}set fade(s){this._fade=s?3:0,this.material.uniforms.uFade.value=this._fade}dispose(){this.setupEvents(!1),this.components.get(_t).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(s){if(this.world.isDisposing||!(this.world.camera instanceof ce))return;const t=this.world.camera.controls;s?t.addEventListener("update",this.updateZoom):t.removeEventListener("update",this.updateZoom)}}const ms=class ms extends ${constructor(t){super(t);u(this,"list",new Map);u(this,"config",{color:new g.Color(12303291),size1:1,size2:10,distance:500});u(this,"onDisposed",new M);u(this,"enabled",!0);t.add(ms.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");const e=new xn(this.components,t,this.config);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}};u(ms,"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");let fi=ms;const zt=new C.Raycaster,it=new C.Vector3,Nt=new C.Vector3,Q=new C.Quaternion,ln={X:new C.Vector3(1,0,0),Y:new C.Vector3(0,1,0),Z:new C.Vector3(0,0,1)},si={type:"change"},hn={type:"mouseDown"},dn={type:"mouseUp",mode:null},En={type:"objectChange"};class Or extends C.Object3D{constructor(s,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const e=new Pr;this._gizmo=e,this.add(e);const i=new wr;this._plane=i,this.add(i);const o=this;function n(A,O){let p=O;Object.defineProperty(o,A,{get:function(){return p!==void 0?p:O},set:function(R){p!==R&&(p=R,i[A]=R,e[A]=R,o.dispatchEvent({type:A+"-changed",value:R}),o.dispatchEvent(si))}}),o[A]=O,i[A]=O,e[A]=O}n("camera",s),n("object",void 0),n("enabled",!0),n("axis",null),n("mode","translate"),n("translationSnap",null),n("rotationSnap",null),n("scaleSnap",null),n("space","world"),n("size",1),n("dragging",!1),n("showX",!0),n("showY",!0),n("showZ",!0);const r=new C.Vector3,a=new C.Vector3,c=new C.Quaternion,h=new C.Quaternion,E=new C.Vector3,d=new C.Quaternion,I=new C.Vector3,f=new C.Vector3,T=new C.Vector3,F=0,m=new C.Vector3;n("worldPosition",r),n("worldPositionStart",a),n("worldQuaternion",c),n("worldQuaternionStart",h),n("cameraPosition",E),n("cameraQuaternion",d),n("pointStart",I),n("pointEnd",f),n("rotationAxis",T),n("rotationAngle",F),n("eye",m),this._offset=new C.Vector3,this._startNorm=new C.Vector3,this._endNorm=new C.Vector3,this._cameraScale=new C.Vector3,this._parentPosition=new C.Vector3,this._parentQuaternion=new C.Quaternion,this._parentQuaternionInv=new C.Quaternion,this._parentScale=new C.Vector3,this._worldScaleStart=new C.Vector3,this._worldQuaternionInv=new C.Quaternion,this._worldScale=new C.Vector3,this._positionStart=new C.Vector3,this._quaternionStart=new C.Quaternion,this._scaleStart=new C.Vector3,this._getPointer=Sr.bind(this),this._onPointerDown=yr.bind(this),this._onPointerHover=_r.bind(this),this._onPointerMove=Nr.bind(this),this._onPointerUp=Lr.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(s){if(this.object===void 0||this.dragging===!0)return;zt.setFromCamera(s,this.camera);const t=ii(this._gizmo.picker[this.mode],zt);t?this.axis=t.object.name:this.axis=null}pointerDown(s){if(!(this.object===void 0||this.dragging===!0||s.button!==0)&&this.axis!==null){zt.setFromCamera(s,this.camera);const t=ii(this._plane,zt,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,hn.mode=this.mode,this.dispatchEvent(hn)}}pointerMove(s){const t=this.axis,e=this.mode,i=this.object;let o=this.space;if(e==="scale"?o="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(o="world"),i===void 0||t===null||this.dragging===!1||s.button!==-1)return;zt.setFromCamera(s,this.camera);const n=ii(this._plane,zt,!0);if(n){if(this.pointEnd.copy(n.point).sub(this.worldPositionStart),e==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),o==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),o==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(o==="local"&&(i.position.applyQuaternion(Q.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),o==="world"&&(i.parent&&i.position.add(it.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(it.setFromMatrixPosition(i.parent.matrixWorld))));else if(e==="scale"){if(t.search("XYZ")!==-1){let r=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(r*=-1),Nt.set(r,r,r)}else it.copy(this.pointStart),Nt.copy(this.pointEnd),it.applyQuaternion(this._worldQuaternionInv),Nt.applyQuaternion(this._worldQuaternionInv),Nt.divide(it),t.search("X")===-1&&(Nt.x=1),t.search("Y")===-1&&(Nt.y=1),t.search("Z")===-1&&(Nt.z=1);i.scale.copy(this._scaleStart).multiply(Nt),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(e==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const r=20/this.worldPosition.distanceTo(it.setFromMatrixPosition(this.camera.matrixWorld));let a=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(it.copy(this.rotationAxis).cross(this.eye))*r):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(ln[t]),it.copy(ln[t]),o==="local"&&it.applyQuaternion(this.worldQuaternion),it.cross(this.eye),it.length()===0?a=!0:this.rotationAngle=this._offset.dot(it.normalize())*r),(t==="E"||a)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),o==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Q.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Q.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(si),this.dispatchEvent(En)}}pointerUp(s){s.button===0&&(this.dragging&&this.axis!==null&&(dn.mode=this.mode,this.dispatchEvent(dn)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(s){s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose()})}attach(s){return this.object=s,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(si),this.dispatchEvent(En),this.pointStart.copy(this.pointEnd))}getRaycaster(){return zt}getMode(){return this.mode}setMode(s){this.mode=s}setTranslationSnap(s){this.translationSnap=s}setRotationSnap(s){this.rotationSnap=s}setScaleSnap(s){this.scaleSnap=s}setSize(s){this.size=s}setSpace(s){this.space=s}}function Sr(l){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:l.button};{const s=this.domElement.getBoundingClientRect();return{x:(l.clientX-s.left)/s.width*2-1,y:-(l.clientY-s.top)/s.height*2+1,button:l.button}}}function _r(l){if(this.enabled)switch(l.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(l));break}}function yr(l){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(l)),this.pointerDown(this._getPointer(l)))}function Nr(l){this.enabled&&this.pointerMove(this._getPointer(l))}function Lr(l){this.enabled&&(this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(l)))}function ii(l,s,t){const e=s.intersectObject(l,!0);for(let i=0;i<e.length;i++)if(e[i].object.visible||t)return e[i];return!1}const is=new C.Euler,W=new C.Vector3(0,1,0),un=new C.Vector3(0,0,0),In=new C.Matrix4,ns=new C.Quaternion,cs=new C.Quaternion,At=new C.Vector3,fn=new C.Matrix4,_e=new C.Vector3(1,0,0),Ht=new C.Vector3(0,1,0),ye=new C.Vector3(0,0,1),os=new C.Vector3,Oe=new C.Vector3,Se=new C.Vector3;class Pr extends C.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const s=new C.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new C.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=s.clone();e.opacity=.15;const i=t.clone();i.opacity=.5;const o=s.clone();o.color.setHex(16711680);const n=s.clone();n.color.setHex(65280);const r=s.clone();r.color.setHex(255);const a=s.clone();a.color.setHex(16711680),a.opacity=.5;const c=s.clone();c.color.setHex(65280),c.opacity=.5;const h=s.clone();h.color.setHex(255),h.opacity=.5;const E=s.clone();E.opacity=.25;const d=s.clone();d.color.setHex(16776960),d.opacity=.25,s.clone().color.setHex(16776960);const f=s.clone();f.color.setHex(7895160);const T=new C.CylinderGeometry(0,.04,.1,12);T.translate(0,.05,0);const F=new C.BoxGeometry(.08,.08,.08);F.translate(0,.04,0);const m=new C.BufferGeometry;m.setAttribute("position",new C.Float32BufferAttribute([0,0,0,1,0,0],3));const A=new C.CylinderGeometry(.0075,.0075,.5,3);A.translate(0,.25,0);function O(v,z){const j=new C.TorusGeometry(v,.0075,3,64,z*Math.PI*2);return j.rotateY(Math.PI/2),j.rotateX(Math.PI/2),j}function p(){const v=new C.BufferGeometry;return v.setAttribute("position",new C.Float32BufferAttribute([0,0,0,1,1,1],3)),v}const R={X:[[new C.Mesh(T,o),[.5,0,0],[0,0,-Math.PI/2]],[new C.Mesh(T,o),[-.5,0,0],[0,0,Math.PI/2]],[new C.Mesh(A,o),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new C.Mesh(T,n),[0,.5,0]],[new C.Mesh(T,n),[0,-.5,0],[Math.PI,0,0]],[new C.Mesh(A,n)]],Z:[[new C.Mesh(T,r),[0,0,.5],[Math.PI/2,0,0]],[new C.Mesh(T,r),[0,0,-.5],[-Math.PI/2,0,0]],[new C.Mesh(A,r),null,[Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.OctahedronGeometry(.1,0),E.clone()),[0,0,0]]],XY:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),a.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[.3,0,0],[0,0,-Math.PI/2]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,.3,0]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,-.3,0],[0,0,Math.PI]]],Z:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,0,.3],[Math.PI/2,0,0]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.OctahedronGeometry(.2,0),e)]],XY:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[.15,.15,0]]],YZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[.15,0,.15],[-Math.PI/2,0,0]]]},_={START:[[new C.Mesh(new C.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new C.Mesh(new C.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new C.Line(p(),i),null,null,null,"helper"]],X:[[new C.Line(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new C.Line(m,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new C.Line(m,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},y={XYZE:[[new C.Mesh(O(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new C.Mesh(O(.5,.5),o)]],Y:[[new C.Mesh(O(.5,.5),n),null,[0,0,-Math.PI/2]]],Z:[[new C.Mesh(O(.5,.5),r),null,[0,Math.PI/2,0]]],E:[[new C.Mesh(O(.75,1),d),null,[0,Math.PI/2,0]]]},N={AXIS:[[new C.Line(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},P={XYZE:[[new C.Mesh(new C.SphereGeometry(.25,10,8),e)]],X:[[new C.Mesh(new C.TorusGeometry(.5,.1,4,24),e),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new C.Mesh(new C.TorusGeometry(.5,.1,4,24),e),[0,0,0],[Math.PI/2,0,0]]],Z:[[new C.Mesh(new C.TorusGeometry(.5,.1,4,24),e),[0,0,0],[0,0,-Math.PI/2]]],E:[[new C.Mesh(new C.TorusGeometry(.75,.1,2,24),e)]]},D={X:[[new C.Mesh(F,o),[.5,0,0],[0,0,-Math.PI/2]],[new C.Mesh(A,o),[0,0,0],[0,0,-Math.PI/2]],[new C.Mesh(F,o),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new C.Mesh(F,n),[0,.5,0]],[new C.Mesh(A,n)],[new C.Mesh(F,n),[0,-.5,0],[0,0,Math.PI]]],Z:[[new C.Mesh(F,r),[0,0,.5],[Math.PI/2,0,0]],[new C.Mesh(A,r),[0,0,0],[Math.PI/2,0,0]],[new C.Mesh(F,r),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.BoxGeometry(.1,.1,.1),E.clone())]]},w={X:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[.3,0,0],[0,0,-Math.PI/2]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,.3,0]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,-.3,0],[0,0,Math.PI]]],Z:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,0,.3],[Math.PI/2,0,0]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[.15,.15,0]]],YZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.2),e),[0,0,0]]]},U={X:[[new C.Line(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new C.Line(m,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new C.Line(m,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function b(v){const z=new C.Object3D;for(const j in v)for(let et=v[j].length;et--;){const Z=v[j][et][0].clone(),bt=v[j][et][1],vt=v[j][et][2],Bt=v[j][et][3],Ue=v[j][et][4];Z.name=j,Z.tag=Ue,bt&&Z.position.set(bt[0],bt[1],bt[2]),vt&&Z.rotation.set(vt[0],vt[1],vt[2]),Bt&&Z.scale.set(Bt[0],Bt[1],Bt[2]),Z.updateMatrix();const de=Z.geometry.clone();de.applyMatrix4(Z.matrix),Z.geometry=de,Z.renderOrder=1/0,Z.position.set(0,0,0),Z.rotation.set(0,0,0),Z.scale.set(1,1,1),z.add(Z)}return z}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=b(R)),this.add(this.gizmo.rotate=b(y)),this.add(this.gizmo.scale=b(D)),this.add(this.picker.translate=b(S)),this.add(this.picker.rotate=b(P)),this.add(this.picker.scale=b(w)),this.add(this.helper.translate=b(_)),this.add(this.helper.rotate=b(N)),this.add(this.helper.scale=b(U)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(s){const e=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:cs;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let o=0;o<i.length;o++){const n=i[o];n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition);let r;if(this.camera.isOrthographicCamera?r=(this.camera.top-this.camera.bottom)/this.camera.zoom:r=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(r*this.size/4),n.tag==="helper"){n.visible=!1,n.name==="AXIS"?(n.visible=!!this.axis,this.axis==="X"&&(Q.setFromEuler(is.set(0,0,0)),n.quaternion.copy(e).multiply(Q),Math.abs(W.copy(_e).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Y"&&(Q.setFromEuler(is.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(Q),Math.abs(W.copy(Ht).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Z"&&(Q.setFromEuler(is.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(Q),Math.abs(W.copy(ye).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="XYZE"&&(Q.setFromEuler(is.set(0,Math.PI/2,0)),W.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(In.lookAt(un,W,Ht)),n.quaternion.multiply(Q),n.visible=this.dragging),this.axis==="E"&&(n.visible=!1)):n.name==="START"?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):n.name==="END"?(n.position.copy(this.worldPosition),n.visible=this.dragging):n.name==="DELTA"?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),it.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),it.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(it),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=this.axis.search(n.name)!==-1));continue}n.quaternion.copy(e),this.mode==="translate"||this.mode==="scale"?(n.name==="X"&&Math.abs(W.copy(_e).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Y"&&Math.abs(W.copy(Ht).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Z"&&Math.abs(W.copy(ye).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XY"&&Math.abs(W.copy(ye).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="YZ"&&Math.abs(W.copy(_e).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XZ"&&Math.abs(W.copy(Ht).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)):this.mode==="rotate"&&(ns.copy(e),W.copy(this.eye).applyQuaternion(Q.copy(e).invert()),n.name.search("E")!==-1&&n.quaternion.setFromRotationMatrix(In.lookAt(this.eye,un,Ht)),n.name==="X"&&(Q.setFromAxisAngle(_e,Math.atan2(-W.y,W.z)),Q.multiplyQuaternions(ns,Q),n.quaternion.copy(Q)),n.name==="Y"&&(Q.setFromAxisAngle(Ht,Math.atan2(W.x,W.z)),Q.multiplyQuaternions(ns,Q),n.quaternion.copy(Q)),n.name==="Z"&&(Q.setFromAxisAngle(ye,Math.atan2(W.y,W.x)),Q.multiplyQuaternions(ns,Q),n.quaternion.copy(Q))),n.visible=n.visible&&(n.name.indexOf("X")===-1||this.showX),n.visible=n.visible&&(n.name.indexOf("Y")===-1||this.showY),n.visible=n.visible&&(n.name.indexOf("Z")===-1||this.showZ),n.visible=n.visible&&(n.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(a){return n.name===a}))&&(n.material.color.setHex(16776960),n.material.opacity=1)}super.updateMatrixWorld(s)}}class wr extends C.Mesh{constructor(){super(new C.PlaneGeometry(1e5,1e5,2,2),new C.MeshBasicMaterial({visible:!1,wireframe:!0,side:C.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(s){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),os.copy(_e).applyQuaternion(t==="local"?this.worldQuaternion:cs),Oe.copy(Ht).applyQuaternion(t==="local"?this.worldQuaternion:cs),Se.copy(ye).applyQuaternion(t==="local"?this.worldQuaternion:cs),W.copy(Oe),this.mode){case"translate":case"scale":switch(this.axis){case"X":W.copy(this.eye).cross(os),At.copy(os).cross(W);break;case"Y":W.copy(this.eye).cross(Oe),At.copy(Oe).cross(W);break;case"Z":W.copy(this.eye).cross(Se),At.copy(Se).cross(W);break;case"XY":At.copy(Se);break;case"YZ":At.copy(os);break;case"XZ":W.copy(Se),At.copy(Oe);break;case"XYZ":case"E":At.set(0,0,0);break}break;case"rotate":default:At.set(0,0,0)}At.length()===0?this.quaternion.copy(this.cameraQuaternion):(fn.lookAt(it.set(0,0,0),At,W),this.quaternion.setFromRotationMatrix(fn)),super.updateMatrixWorld(s)}}class Ms{constructor(s,t,e,i,o,n=5,r=!0){u(this,"onDraggingStarted",new M);u(this,"onDraggingEnded",new M);u(this,"onDisposed",new M);u(this,"normal");u(this,"origin");u(this,"three",new g.Plane);u(this,"components");u(this,"world");u(this,"type","default");u(this,"_helper");u(this,"_visible",!0);u(this,"_enabled",!0);u(this,"_controlsActive",!1);u(this,"_arrowBoundBox",new g.Mesh);u(this,"_planeMesh");u(this,"_controls");u(this,"_hiddenMaterial",new g.MeshBasicMaterial({visible:!1}));u(this,"update",()=>{this._enabled&&this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position)});u(this,"changeDrag",s=>{this._visible=!s.value,this.preventCameraMovement(),this.notifyDraggingChanged(s)});if(this.components=s,this.world=t,!t.renderer)throw new Error("The given world must have a renderer!");this.normal=i,this.origin=e,t.renderer.setPlane(!0,this.three),this._planeMesh=Ms.newPlaneMesh(n,o),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(i,e),r&&this.toggleControls(!0)}get enabled(){return this._enabled}set enabled(s){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");this._enabled=s,this.world.renderer.setPlane(s,this.three)}get visible(){return this._visible}set visible(s){this._visible=s,this._controls.visible=s,this._helper.visible=s,this.toggleControls(s)}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(s){this._planeMesh.material=s}get size(){return this._planeMesh.scale.x}set size(s){this._planeMesh.scale.set(s,s,s)}get helper(){return this._helper}setFromNormalAndCoplanarPoint(s,t){this.reset(),this.normal.equals(s)||(this.normal.copy(s),this._helper.lookAt(s)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix(),this.update()}dispose(){this._enabled=!1,this.onDraggingStarted.reset(),this.onDraggingEnded.reset(),this._helper.removeFromParent(),this.world.renderer&&this.world.renderer.setPlane(!1,this.three),this._arrowBoundBox.removeFromParent(),this._arrowBoundBox.geometry.dispose(),this._planeMesh.geometry.dispose(),this._controls.removeFromParent(),this._controls.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}reset(){const s=new g.Vector3(1,0,0),t=new g.Vector3;this.normal.equals(s)||(this.normal.copy(s),this._helper.lookAt(s)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix()}toggleControls(s){if(s){if(this._controlsActive)return;this._controls.addEventListener("change",this.update),this._controls.addEventListener("dragging-changed",this.changeDrag)}else this._controls.removeEventListener("change",this.update),this._controls.removeEventListener("dragging-changed",this.changeDrag);this._controlsActive=s}newTransformControls(){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");const s=this.world.camera.three,t=this.world.renderer.three.domElement,e=new Or(s,t);return this.initializeControls(e),this.world.scene.three.add(e),e}initializeControls(s){s.attach(this._helper),s.showX=!1,s.showY=!1,s.setSpace("local"),this.createArrowBoundingBox(),s.children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new g.CylinderGeometry(.18,.18,1.2),this._arrowBoundBox.material=this._hiddenMaterial,this._arrowBoundBox.rotateX(Math.PI/2),this._arrowBoundBox.updateMatrix(),this._arrowBoundBox.geometry.applyMatrix4(this._arrowBoundBox.matrix)}notifyDraggingChanged(s){s.value?this.onDraggingStarted.trigger():this.onDraggingEnded.trigger()}preventCameraMovement(){this.world.camera.enabled=this._visible}newHelper(){const s=new g.Object3D;return s.lookAt(this.normal),s.position.copy(this.origin),this._planeMesh.position.z+=.01,s.add(this._planeMesh),this.world.scene.three.add(s),s}static newPlaneMesh(s,t){const e=new g.PlaneGeometry(1),i=new g.Mesh(e,t);return i.scale.set(s,s,s),i}}const Me=class Me extends ${constructor(t){super(t);u(this,"onBeforeDrag",new M);u(this,"onAfterDrag",new M);u(this,"onBeforeCreate",new M);u(this,"onBeforeCancel",new M);u(this,"onAfterCancel",new M);u(this,"onBeforeDelete",new M);u(this,"onAfterCreate",new M);u(this,"onAfterDelete",new M);u(this,"onDisposed",new M);u(this,"orthogonalY",!1);u(this,"toleranceOrthogonalY",.7);u(this,"Type",Ms);u(this,"list",[]);u(this,"_material",new g.MeshBasicMaterial({color:12255487,side:g.DoubleSide,transparent:!0,opacity:.2}));u(this,"_size",5);u(this,"_enabled",!1);u(this,"_visible",!0);u(this,"_onStartDragging",()=>{this.onBeforeDrag.trigger()});u(this,"_onEndDragging",()=>{this.onAfterDrag.trigger()});this.components.add(Me.uuid,this)}get enabled(){return this._enabled}set enabled(t){this._enabled=t;for(const e of this.list)e.enabled=t;this.updateMaterialsAndPlanes()}get visible(){return this._visible}set visible(t){this._visible=t;for(const e of this.list)e.visible=t}get material(){return this._material}set material(t){this._material=t;for(const e of this.list)e.planeMaterial=t}get size(){return this._size}set size(t){this._size=t;for(const e of this.list)e.size=t}dispose(){this._enabled=!1;for(const t of this.list)t.dispose();this.list.length=0,this._material.dispose(),this.onBeforeCreate.reset(),this.onBeforeCancel.reset(),this.onBeforeDelete.reset(),this.onBeforeDrag.reset(),this.onAfterCreate.reset(),this.onAfterCancel.reset(),this.onAfterDelete.reset(),this.onAfterDrag.reset(),this.onDisposed.trigger(Me.uuid),this.onDisposed.reset()}create(t){const o=this.components.get(le).get(t).castRay();return o?this.createPlaneFromIntersection(t,o):null}createFromNormalAndCoplanarPoint(t,e,i){const o=this.newPlane(t,i,e);return this.updateMaterialsAndPlanes(),o}delete(t,e){e||(e=this.pickPlane(t)),e&&this.deletePlane(e)}deleteAll(t){const e=[...this.list];for(const i of e)if(!t||t.has(i.type)){this.delete(i.world,i);const o=this.list.indexOf(i);o!==-1&&this.list.splice(o,1)}}deletePlane(t){const e=this.list.indexOf(t);if(e!==-1){if(this.list.splice(e,1),!t.world.renderer)throw new Error("Renderer not found for this plane's world!");t.world.renderer.setPlane(!1,t.three),t.dispose(),this.updateMaterialsAndPlanes(),this.onAfterDelete.trigger(t)}}pickPlane(t){const i=this.components.get(le).get(t),o=this.getAllPlaneMeshes(),n=i.castRay(o);if(n){const r=n.object;return this.list.find(a=>a.meshes.includes(r))}}getAllPlaneMeshes(){const t=[];for(const e of this.list)t.push(...e.meshes);return t}createPlaneFromIntersection(t,e){var a;if(!t.renderer)throw new Error("The given world must have a renderer!");const i=e.point.distanceTo(new g.Vector3(0,0,0)),o=(a=e.face)==null?void 0:a.normal;if(!i||!o)return null;const n=this.getWorldNormal(e,o),r=this.newPlane(t,e.point,n.negate());return r.visible=this._visible,r.size=this._size,t.renderer.setPlane(!0,r.three),this.updateMaterialsAndPlanes(),r}getWorldNormal(t,e){const i=t.object;let o=t.object.matrixWorld.clone();if(i instanceof g.InstancedMesh&&t.instanceId!==void 0){const c=new g.Matrix4;i.getMatrixAt(t.instanceId,c),o=c.multiply(o)}const r=new g.Matrix3().getNormalMatrix(o),a=e.clone().applyMatrix3(r).normalize();return this.normalizePlaneDirectionY(a),a}normalizePlaneDirectionY(t){this.orthogonalY&&(t.y>this.toleranceOrthogonalY&&(t.x=0,t.y=1,t.z=0),t.y<-this.toleranceOrthogonalY&&(t.x=0,t.y=-1,t.z=0))}newPlane(t,e,i){const o=new this.Type(this.components,t,e,i,this._material);return o.onDraggingStarted.add(this._onStartDragging),o.onDraggingEnded.add(this._onEndDragging),this.list.push(o),this.onAfterCreate.trigger(o),o}updateMaterialsAndPlanes(){const t=this.components.get(ds);for(const[e,i]of t.list){if(!i.renderer)continue;i.renderer.updateClippingPlanes();const{clippingPlanes:o}=i.renderer;for(const n of i.meshes)if(n.material)if(Array.isArray(n.material))for(const r of n.material)r.clippingPlanes=o;else n.material.clippingPlanes=o}}};u(Me,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let pi=Me;class Un{constructor(s){u(this,"onDisposed",new M);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onResize",new M);u(this,"frontOffset",0);u(this,"overrideMaterial",new g.MeshDepthMaterial);u(this,"backgroundColor",new g.Color(395274));u(this,"renderer");u(this,"enabled",!0);u(this,"world");u(this,"_lockRotation",!0);u(this,"_camera");u(this,"_plane");u(this,"_size",new g.Vector2(320,160));u(this,"_tempVector1",new g.Vector3);u(this,"_tempVector2",new g.Vector3);u(this,"_tempTarget",new g.Vector3);u(this,"down",new g.Vector3(0,-1,0));u(this,"updatePlanes",()=>{if(!this.world.renderer)throw new Error("The given world must have a renderer!");const s=[],t=this.world.renderer.three;for(const e of t.clippingPlanes)s.push(e);s.push(this._plane),this.renderer.clippingPlanes=s});if(this.world=s,!this.world.renderer)throw new Error("The given world must have a renderer!");this.renderer=new g.WebGLRenderer,this.renderer.setSize(this._size.x,this._size.y);const t=1,e=this._size.x/this._size.y;this._camera=new g.OrthographicCamera(t*e/-2,t*e/2,t/2,t/-2),this.world.renderer.onClippingPlanesUpdated.add(this.updatePlanes),this._camera.position.set(0,200,0),this._camera.zoom=.1,this._camera.rotation.x=-Math.PI/2,this._plane=new g.Plane(this.down,200),this.updatePlanes()}get lockRotation(){return this._lockRotation}set lockRotation(s){this._lockRotation=s,s&&(this._camera.rotation.z=0)}get zoom(){return this._camera.zoom}set zoom(s){this._camera.zoom=s,this._camera.updateProjectionMatrix()}dispose(){this.enabled=!1,this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.onResize.reset(),this.overrideMaterial.dispose(),this.renderer.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get(){return this._camera}update(){if(!this.enabled)return;this.onBeforeUpdate.trigger();const s=this.world.scene.three,t=this.world.camera;if(!t.hasCameraControls())throw new Error("The given world must use camera controls!");if(!(s instanceof g.Scene))throw new Error("The given world must have a THREE.Scene as a root!");const e=t.controls;if(e.getPosition(this._tempVector1),this._camera.position.x=this._tempVector1.x,this._camera.position.z=this._tempVector1.z,this.frontOffset!==0&&(e.getTarget(this._tempVector2),this._tempVector2.sub(this._tempVector1),this._tempVector2.normalize().multiplyScalar(this.frontOffset),this._camera.position.x+=this._tempVector2.x,this._camera.position.z+=this._tempVector2.z),!this._lockRotation){e.getTarget(this._tempTarget);const o=Math.atan2(this._tempTarget.x-this._tempVector1.x,this._tempTarget.z-this._tempVector1.z);this._camera.rotation.z=o+Math.PI}this._plane.set(this.down,this._tempVector1.y);const i=s.background;s.background=this.backgroundColor,this.renderer.render(s,this._camera),s.background=i,this.onAfterUpdate.trigger()}getSize(){return this._size}resize(s=this._size){this._size.copy(s),this.renderer.setSize(s.x,s.y);const t=s.x/s.y,e=1;this._camera.left=e*t/-2,this._camera.right=e*t/2,this._camera.top=e/2,this._camera.bottom=-e/2,this._camera.updateProjectionMatrix(),this.onResize.trigger(s)}}const Rs=class Rs extends ${constructor(t){super(t);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onDisposed",new M);u(this,"enabled",!0);u(this,"list",new Map);this.components.add(Rs.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a minimap!");const e=new Un(t);return this.list.set(t.uuid,e),e}delete(t){const e=this.list.get(t);e&&e.dispose(),this.list.delete(t)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}update(){for(const[t,e]of this.list)e.update()}};u(Rs,"uuid","39ad6aad-84c8-4adf-a1e0-7f25313a9e7f");let Ci=Rs;class bn{constructor(s){u(this,"enabled",!1);u(this,"id","FirstPerson");this.camera=s}set(s){if(this.enabled=s,s){if(this.camera.projection.current!=="Perspective"){this.camera.set("Orbit");return}this.setupFirstPersonCamera()}}setupFirstPersonCamera(){const s=this.camera.controls,t=new g.Vector3;s.distance--,s.getPosition(t),s.minDistance=1,s.maxDistance=1,s.distance=1,s.moveTo(t.x,t.y,t.z),s.truckSpeed=50,s.mouseButtons.wheel=nt.ACTION.DOLLY,s.touches.two=nt.ACTION.TOUCH_ZOOM_TRUCK}}class vn{constructor(s){u(this,"enabled",!0);u(this,"id","Orbit");this.camera=s,this.activateOrbitControls()}set(s){this.enabled=s,s&&this.activateOrbitControls()}activateOrbitControls(){const s=this.camera.controls;s.minDistance=1,s.maxDistance=300;const t=new g.Vector3;s.getPosition(t);const e=t.length();s.distance=e,s.truckSpeed=2;const{rotation:i}=this.camera.three,o=new g.Vector3(0,0,-1).applyEuler(i),n=t.addScaledVector(o,e);s.moveTo(n.x,n.y,n.z)}}class Bn{constructor(s){u(this,"enabled",!1);u(this,"id","Plan");u(this,"mouseAction1");u(this,"mouseAction2");u(this,"mouseInitialized",!1);u(this,"defaultAzimuthSpeed");u(this,"defaultPolarSpeed");this.camera=s,this.defaultAzimuthSpeed=s.controls.azimuthRotateSpeed,this.defaultPolarSpeed=s.controls.polarRotateSpeed}set(s){this.enabled=s;const t=this.camera.controls;t.azimuthRotateSpeed=s?0:this.defaultAzimuthSpeed,t.polarRotateSpeed=s?0:this.defaultPolarSpeed,this.mouseInitialized||(this.mouseAction1=t.touches.one,this.mouseAction2=t.touches.two,this.mouseInitialized=!0),s?(t.mouseButtons.left=nt.ACTION.TRUCK,t.touches.one=nt.ACTION.TOUCH_TRUCK,t.touches.two=nt.ACTION.TOUCH_ZOOM):(t.mouseButtons.left=nt.ACTION.ROTATE,t.touches.one=this.mouseAction1,t.touches.two=this.mouseAction2)}}class Vn{constructor(s){u(this,"onChanged",new M);u(this,"current","Perspective");u(this,"camera");u(this,"matchOrthoDistanceEnabled",!1);u(this,"_component");u(this,"_previousDistance",-1);this._component=s,this.camera=s.three}async set(s){this.current!==s&&(s==="Orthographic"?this.setOrthoCamera():await this.setPerspectiveCamera(),this.onChanged.trigger(this.camera))}async toggle(){const t=this.current==="Perspective"?"Orthographic":"Perspective";await this.set(t)}setOrthoCamera(){if(this._component.mode===null||this._component.mode.id==="FirstPerson")return;this._previousDistance=this._component.controls.distance,this._component.controls.distance=200;const s=this.getPerspectiveDims();if(!s)return;const{width:t,height:e}=s;this.setupOrthoCamera(e,t),this.camera=this._component.threeOrtho,this.current="Orthographic"}getPerspectiveDims(){const s=this._component.currentWorld;if(!s||!s.renderer)return null;const t=new g.Vector3;this._component.threePersp.getWorldDirection(t);const e=new g.Vector3;this._component.controls.getTarget(e);const o=e.clone().sub(this._component.threePersp.position).dot(t),n=s.renderer.getSize(),r=n.x/n.y,a=this._component.threePersp,c=o*2*Math.atan(a.fov*(Math.PI/180)/2);return{width:c*r,height:c}}setupOrthoCamera(s,t){this._component.controls.mouseButtons.wheel=nt.ACTION.ZOOM,this._component.controls.mouseButtons.middle=nt.ACTION.ZOOM;const e=this._component.threePersp,i=this._component.threeOrtho;i.zoom=1,i.left=t/-2,i.right=t/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix(),i.position.copy(e.position),i.quaternion.copy(e.quaternion),this._component.controls.camera=i}getDistance(){const s=this._component.threePersp,t=this._component.threeOrtho;return(t.top-t.bottom)/t.zoom/(2*Math.atan(s.fov*(Math.PI/180)/2))}async setPerspectiveCamera(){this._component.controls.mouseButtons.wheel=nt.ACTION.DOLLY,this._component.controls.mouseButtons.middle=nt.ACTION.DOLLY;const s=this._component.threePersp,t=this._component.threeOrtho;s.position.copy(t.position),s.quaternion.copy(t.quaternion),this._component.controls.mouseButtons.wheel=nt.ACTION.DOLLY,this.matchOrthoDistanceEnabled?this._component.controls.distance=this.getDistance():this._component.controls.distance=this._previousDistance,await this._component.controls.zoomTo(1),s.updateProjectionMatrix(),this._component.controls.camera=s,this.camera=s,this.current="Perspective"}}class Mr extends ce{constructor(t){super(t);u(this,"projection");u(this,"threeOrtho");u(this,"threePersp");u(this,"_userInputButtons",{});u(this,"_frustumSize",50);u(this,"_navigationModes",new Map);u(this,"_mode",null);u(this,"previousSize",null);this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new Vn(this),this.onAspectUpdated.add(()=>{this.setOrthoPerspCameraAspect()}),this.projection.onChanged.add(e=>{this.three=e,this.updateAspect()}),this.onWorldChanged.add(({action:e})=>{e==="added"&&(this._navigationModes.clear(),this._navigationModes.set("Orbit",new vn(this)),this._navigationModes.set("FirstPerson",new bn(this)),this._navigationModes.set("Plan",new Bn(this)),this._mode=this._navigationModes.get("Orbit"),this.mode.set(!0,{preventTargetAdjustment:!0}),this.currentWorld&&this.currentWorld.renderer&&(this.previousSize=this.currentWorld.renderer.getSize().clone()))})}get mode(){if(!this._mode)throw new Error("Mode not found, camera not initialized");return this._mode}dispose(){super.dispose(),this.threeOrtho.removeFromParent()}set(t){if(this.mode!==null&&this.mode.id!==t){if(this.mode.set(!1),!this._navigationModes.has(t))throw new Error("The specified mode does not exist!");this._mode=this._navigationModes.get(t),this.mode.set(!0)}}async fit(t,e=1.5){if(!this.enabled)return;const i=Number.MAX_VALUE,o=Number.MIN_VALUE,n=new g.Vector3(i,i,i),r=new g.Vector3(o,o,o);for(const I of t){const f=new g.Box3().setFromObject(I);f.min.x<n.x&&(n.x=f.min.x),f.min.y<n.y&&(n.y=f.min.y),f.min.z<n.z&&(n.z=f.min.z),f.max.x>r.x&&(r.x=f.max.x),f.max.y>r.y&&(r.y=f.max.y),f.max.z>r.z&&(r.z=f.max.z)}const a=new g.Box3(n,r),c=new g.Vector3;a.getSize(c);const h=new g.Vector3;a.getCenter(h);const E=Math.max(c.x,c.y,c.z)*e,d=new g.Sphere(h,E);await this.controls.fitToSphere(d,!0)}setUserInput(t){t?this.enableUserInput():this.disableUserInput()}disableUserInput(){this._userInputButtons.left=this.controls.mouseButtons.left,this._userInputButtons.right=this.controls.mouseButtons.right,this._userInputButtons.middle=this.controls.mouseButtons.middle,this._userInputButtons.wheel=this.controls.mouseButtons.wheel,this.controls.mouseButtons.left=0,this.controls.mouseButtons.right=0,this.controls.mouseButtons.middle=0,this.controls.mouseButtons.wheel=0}enableUserInput(){Object.keys(this._userInputButtons).length!==0&&(this.controls.mouseButtons.left=this._userInputButtons.left,this.controls.mouseButtons.right=this._userInputButtons.right,this.controls.mouseButtons.middle=this._userInputButtons.middle,this.controls.mouseButtons.wheel=this._userInputButtons.wheel)}newOrthoCamera(){const t=window.innerWidth/window.innerHeight;return new g.OrthographicCamera(this._frustumSize*t/-2,this._frustumSize*t/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer||!this.previousSize)return;const t=this.currentWorld.renderer.getSize(),e=this.threeOrtho.top,i=this.threeOrtho.right,o=t.y/this.previousSize.y,n=t.x/this.previousSize.x,r=e*o,a=i*n;this.threeOrtho.left=-a,this.threeOrtho.right=a,this.threeOrtho.top=r,this.threeOrtho.bottom=-r,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(t)}}const Dr=new Map([[x.IFCRELAGGREGATES,{forRelated:"Decomposes",forRelating:"IsDecomposedBy"}],[x.IFCRELASSOCIATESMATERIAL,{forRelated:"HasAssociations",forRelating:"AssociatedTo"}],[x.IFCRELASSOCIATESCLASSIFICATION,{forRelated:"HasAssociations",forRelating:"ClassificationForObjects"}],[x.IFCRELASSIGNSTOGROUP,{forRelated:"HasAssignments",forRelating:"IsGroupedBy"}],[x.IFCRELDEFINESBYPROPERTIES,{forRelated:"IsDefinedBy",forRelating:"DefinesOcurrence"}],[x.IFCRELDEFINESBYTYPE,{forRelated:"IsTypedBy",forRelating:"Types"}],[x.IFCRELDEFINESBYTEMPLATE,{forRelated:"IsDefinedBy",forRelating:"Defines"}],[x.IFCRELCONTAINEDINSPATIALSTRUCTURE,{forRelated:"ContainedInStructure",forRelating:"ContainsElements"}],[x.IFCRELFLOWCONTROLELEMENTS,{forRelated:"AssignedToFlowElement",forRelating:"HasControlElements"}],[x.IFCRELCONNECTSELEMENTS,{forRelated:"ConnectedFrom",forRelating:"ConnectedTo"}],[x.IFCRELASSIGNSTOPRODUCT,{forRelated:"HasAssignments",forRelating:"ReferencedBy"}]]),De=class De extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"onRelationsIndexed",new M);u(this,"relationMaps",{});u(this,"enabled",!0);u(this,"_relToAttributesMap",Dr);u(this,"_inverseAttributes",["IsDecomposedBy","Decomposes","AssociatedTo","HasAssociations","ClassificationForObjects","IsGroupedBy","HasAssignments","IsDefinedBy","DefinesOcurrence","IsTypedBy","Types","Defines","ContainedInStructure","ContainsElements","HasControlElements","AssignedToFlowElement","ConnectedTo","ConnectedFrom","ReferencedBy"]);u(this,"_ifcRels",[x.IFCRELAGGREGATES,x.IFCRELASSOCIATESMATERIAL,x.IFCRELASSOCIATESCLASSIFICATION,x.IFCRELASSIGNSTOGROUP,x.IFCRELDEFINESBYPROPERTIES,x.IFCRELDEFINESBYTYPE,x.IFCRELDEFINESBYTEMPLATE,x.IFCRELCONTAINEDINSPATIALSTRUCTURE,x.IFCRELFLOWCONTROLELEMENTS,x.IFCRELCONNECTSELEMENTS,x.IFCRELASSIGNSTOPRODUCT]);u(this,"onFragmentsDisposed",t=>{delete this.relationMaps[t.groupID]});this.components.add(De.uuid,this),t.get(ot).onFragmentsDisposed.add(this.onFragmentsDisposed)}indexRelations(t,e,i,o){const n=Object.keys(e).find(d=>d.startsWith("Relating")),r=Object.keys(e).find(d=>d.startsWith("Related"));if(!(n&&r))return;const a=e[n].value,c=e[r].map(d=>d.value),h=t.get(a)??new Map,E=this.getAttributeIndex(o);E!==null&&(h.set(E,c),t.set(a,h));for(const d of c){const I=t.get(d)??new Map,f=this.getAttributeIndex(i);if(!f)continue;const T=I.get(f)??[];T.push(a),I.set(f,T),t.set(d,I)}}getAttributeIndex(t){const e=this._inverseAttributes.indexOf(t);return e===-1?null:e}setRelationMap(t,e){this.relationMaps[t.uuid]=e,this.onRelationsIndexed.trigger({modelID:t.uuid,relationsMap:e})}async process(t){if(!t.hasProperties)throw new Error("FragmentsGroup properties not found");let e=this.relationMaps[t.uuid];if(e)return e;e=new Map;for(const i of this._ifcRels){const o=await t.getAllPropertiesOfType(i);if(!o)continue;const n=this._relToAttributesMap.get(i);if(!n)continue;const{forRelated:r,forRelating:a}=n;for(const c in o){const h=o[c];this.indexRelations(e,h,r,a)}}return this.setRelationMap(t,e),e}async processFromWebIfc(t,e){const i=new Map;for(const o of this._ifcRels){const n=this._relToAttributesMap.get(o);if(!n)continue;const{forRelated:r,forRelating:a}=n,c=t.GetLineIDsWithType(e,o);for(let h=0;h<c.size();h++){const E=await t.properties.getItemProperties(e,c.get(h));this.indexRelations(i,E,r,a)}}return this.onRelationsIndexed.trigger({modelID:e.toString(),relationsMap:i}),i}getEntityRelations(t,e,i){const o=this.relationMaps[t.uuid];if(!o)throw new Error(`IfcRelationsIndexer: model ${t.uuid} has no relations indexed.`);const n=o.get(e),r=this.getAttributeIndex(i);if(n===void 0||r===null)return null;const a=n.get(r);return a||null}serializeRelations(t){const e={};for(const[i,o]of t.entries()){e[i]||(e[i]={});for(const[n,r]of o.entries())e[i][n]=r}return JSON.stringify(e)}serializeModelRelations(t){const e=this.relationMaps[t.uuid];return e?this.serializeRelations(e):null}serializeAllRelations(){const t={};for(const e in this.relationMaps){const i=this.relationMaps[e],o={};for(const[n,r]of i.entries()){o[n]||(o[n]={});for(const[a,c]of r.entries())o[n][a]=c}t[e]=o}return JSON.stringify(t)}getRelationsMapFromJSON(t){const e=JSON.parse(t),i=new Map;for(const o in e){const n=e[o],r=new Map;for(const a in n)r.set(Number(a),n[a]);i.set(Number(o),r)}return i}dispose(){this.relationMaps={},this.components.get(ot).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(De.uuid),this.onDisposed.reset()}addEntityRelations(t,e,i,...o){const n=this.getEntityRelations(t,e,i);if(n)n.push(...o);else{const r=this.getAttributeIndex(i);if(!r)throw new Error(`IfcRelationsIndexer: ${i} is not a valid relation name.`);const a=this.relationMaps[t.uuid].get(e);a==null||a.set(r,o)}}getEntityChildren(t,e,i=new Set){if(i.add(e),this.relationMaps[t.uuid]===void 0)throw new Error("The provided model has no indices. You have to generate them first.");const n=this.getEntityRelations(t,e,"IsDecomposedBy");if(n)for(const a of n)this.getEntityChildren(t,a,i);const r=this.getEntityRelations(t,e,"ContainsElements");if(r)for(const a of r)this.getEntityChildren(t,a,i);return i}};u(De,"uuid","23a889ab-83b3-44a4-8bee-ead83438370b");let Wt=De;const Fs=class Fs extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"onFragmentsLoaded",new M);u(this,"onFragmentsDisposed",new M);u(this,"list",new di);u(this,"groups",new di);u(this,"baseCoordinationModel","");u(this,"baseCoordinationMatrix",new g.Matrix4);u(this,"enabled",!0);u(this,"_loader",new pn.Serializer);this.components.add(Fs.uuid,this)}get meshes(){const t=[];for(const[e,i]of this.list)t.push(i.mesh);return t}dispose(){for(const[t,e]of this.groups)e.dispose(!0);this.baseCoordinationModel="",this.groups.clear(),this.list.clear(),this.onFragmentsLoaded.reset(),this.onFragmentsDisposed.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}disposeGroup(t){const{uuid:e}=t,i=[];for(const o of t.items)i.push(o.id),this.list.delete(o.id);t.dispose(!0),this.groups.delete(t.uuid),this.onFragmentsDisposed.trigger({groupID:e,fragmentIDs:i})}load(t,e){const o={...{coordinate:!0},...e},{coordinate:n,name:r,properties:a,relationsMap:c}=o,h=this._loader.import(t);e&&(h.isStreamed=e.isStreamed||!1),r&&(h.name=r);for(const E of h.items)E.group=h,this.list.set(E.id,E);return n&&this.coordinate([h]),this.groups.set(h.uuid,h),a&&h.setLocalProperties(a),c&&this.components.get(Wt).setRelationMap(h,c),this.onFragmentsLoaded.trigger(h),h}export(t){return this._loader.export(t)}getModelIdMap(t){const e={};for(const i in t){const o=this.list.get(i);if(!(o&&o.group))continue;const n=o.group;n.uuid in e||(e[n.uuid]=new Set);const r=t[i];for(const a of r)e[n.uuid].add(a)}return e}modelIdToFragmentIdMap(t){let e={};for(const i in t){const o=this.groups.get(i);if(!o)continue;const n=t[i],r=o.getFragmentMap(n);e={...e,...r}}return e}coordinate(t=Array.from(this.groups.values())){if(this.baseCoordinationModel.length===0){const i=t.pop();if(!i)return;this.baseCoordinationModel=i.uuid,this.baseCoordinationMatrix=i.coordinationMatrix.clone()}if(t.length)for(const i of t)i.coordinationMatrix.equals(this.baseCoordinationMatrix)||(i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),i.updateMatrix(),this.applyBaseCoordinateSystem(i,i.coordinationMatrix))}applyBaseCoordinateSystem(t,e){t.applyMatrix4(e.clone().invert()),t.applyMatrix4(this.baseCoordinationMatrix)}clone(t,e){const i=t.cloneGroup(e);this.groups.set(i.uuid,i);for(const o of i.items)this.list.set(o.id,o);return i}};u(Fs,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let ot=Fs;const Tt=class Tt extends ${constructor(t){super(t);u(this,"enabled",!0);u(this,"onDisposed",new M);u(this,"_absoluteMin");u(this,"_absoluteMax");u(this,"_meshes",[]);this.components.add(Tt.uuid,this),this._absoluteMin=Tt.newBound(!0),this._absoluteMax=Tt.newBound(!1)}static getDimensions(t){const{min:e,max:i}=t,o=Math.abs(i.x-e.x),n=Math.abs(i.y-e.y),r=Math.abs(i.z-e.z),a=new g.Vector3;return a.subVectors(i,e).divideScalar(2).add(e),{width:o,height:n,depth:r,center:a}}static newBound(t){const e=t?1:-1;return new g.Vector3(e*Number.MAX_VALUE,e*Number.MAX_VALUE,e*Number.MAX_VALUE)}static getBounds(t,e,i){const o=i||this.newBound(!1),n=e||this.newBound(!0);for(const r of t)r.x<n.x&&(n.x=r.x),r.y<n.y&&(n.y=r.y),r.z<n.z&&(n.z=r.z),r.x>o.x&&(o.x=r.x),r.y>o.y&&(o.y=r.y),r.z>o.z&&(o.z=r.z);return new g.Box3(e,i)}dispose(){const t=this.components.get(_t);for(const e of this._meshes)t.destroy(e);this._meshes=[],this.onDisposed.trigger(Tt.uuid),this.onDisposed.reset()}get(){const t=this._absoluteMin.clone(),e=this._absoluteMax.clone();return new g.Box3(t,e)}getSphere(){const t=this._absoluteMin.clone(),e=this._absoluteMax.clone(),i=Math.abs((e.x-t.x)/2),o=Math.abs((e.y-t.y)/2),n=Math.abs((e.z-t.z)/2),r=new g.Vector3(t.x+i,t.y+o,t.z+n),a=r.distanceTo(t);return new g.Sphere(r,a)}getMesh(){const t=new g.Box3(this._absoluteMin,this._absoluteMax),e=Tt.getDimensions(t),{width:i,height:o,depth:n,center:r}=e,a=new g.BoxGeometry(i,o,n),c=new g.Mesh(a);return this._meshes.push(c),c.position.copy(r),c}reset(){this._absoluteMin=Tt.newBound(!0),this._absoluteMax=Tt.newBound(!1)}add(t){for(const e of t.items)this.addMesh(e.mesh)}addMesh(t,e){if(!t.geometry.index)return;const i=Tt.getFragmentBounds(t);t.updateMatrixWorld();const o=t.matrixWorld,n=new g.Matrix4,r=t instanceof g.InstancedMesh,a=new Set;if(e&&t instanceof Dt.FragmentMesh)for(const c of e){const h=t.fragment.getInstancesIDs(c);if(h)for(const E of h)a.add(E)}else a.add(0);for(const c of a){const h=i.min.clone(),E=i.max.clone();r&&(t.getMatrixAt(c,n),h.applyMatrix4(n),E.applyMatrix4(n)),h.applyMatrix4(o),E.applyMatrix4(o),h.x<this._absoluteMin.x&&(this._absoluteMin.x=h.x),h.y<this._absoluteMin.y&&(this._absoluteMin.y=h.y),h.z<this._absoluteMin.z&&(this._absoluteMin.z=h.z),h.x>this._absoluteMax.x&&(this._absoluteMax.x=h.x),h.y>this._absoluteMax.y&&(this._absoluteMax.y=h.y),h.z>this._absoluteMax.z&&(this._absoluteMax.z=h.z),E.x>this._absoluteMax.x&&(this._absoluteMax.x=E.x),E.y>this._absoluteMax.y&&(this._absoluteMax.y=E.y),E.z>this._absoluteMax.z&&(this._absoluteMax.z=E.z),E.x<this._absoluteMin.x&&(this._absoluteMin.x=E.x),E.y<this._absoluteMin.y&&(this._absoluteMin.y=E.y),E.z<this._absoluteMin.z&&(this._absoluteMin.z=E.z)}}addFragmentIdMap(t){const e=this.components.get(ot);for(const i in t){const o=e.list.get(i);if(!o)continue;const n=t[i];this.addMesh(o.mesh,n)}}static getFragmentBounds(t){const e=t.geometry.attributes.position,i=Number.MAX_VALUE,o=-i,n=new g.Vector3(i,i,i),r=new g.Vector3(o,o,o);if(!t.geometry.index)throw new Error("Geometry must be indexed!");const a=Array.from(t.geometry.index.array);for(let c=0;c<a.length;c++){if(c%3===0&&a[c]===0&&a[c+1]===0&&a[c+2]===0){c+=2;continue}const h=a[c],E=e.getX(h),d=e.getY(h),I=e.getZ(h);E<n.x&&(n.x=E),d<n.y&&(n.y=d),I<n.z&&(n.z=I),E>r.x&&(r.x=E),d>r.y&&(r.y=d),I>r.z&&(r.z=I)}return new g.Box3(n,r)}};u(Tt,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Ti=Tt;const Li=new Set([1123145078,574549367,1675464909,2059837836,3798115385,32440307,3125803723,3207858831,2740243338,2624227202,4240577450,3615266464,3724593414,220341763,477187591,1878645084,1300840506,3303107099,1607154358,1878645084,846575682,1351298697,2417041796,3049322572,3331915920,1416205885,776857604,3285139300,3958052878,2827736869,2732653382,673634403,3448662350,4142052618,2924175390,803316827,2556980723,1809719519,2205249479,807026263,3737207727,1660063152,2347385850,2705031697,3732776249,2485617015,2611217952,1704287377,2937912522,2770003689,1281925730,1484403080,3448662350,4142052618,3800577675,4006246654,3590301190,1383045692,2775532180,2047409740,370225590,3593883385,2665983363,4124623270,812098782,3649129432,987898635,1105321065,3510044353,1635779807,2603310189,3406155212,1310608509,4261334040,2736907675,3649129432,1136057603,1260505505,4182860854,2713105998,2898889636,59481748,3749851601,3486308946,3150382593,1062206242,3264961684,15328376,1485152156,370225590,1981873012,2859738748,45288368,2614616156,2732653382,775493141,2147822146,2601014836,2629017746,1186437898,2367409068,1213902940,3632507154,3900360178,476780140,1472233963,2804161546,3008276851,738692330,374418227,315944413,3905492369,3570813810,2571569899,178912537,2294589976,1437953363,2133299955,572779678,3092502836,388784114,2624227202,1425443689,3057273783,2347385850,1682466193,2519244187,2839578677,3958567839,2513912981,2830218821,427810014]),As=class As extends ${constructor(t){super(t);u(this,"enabled",!0);t.add(As.uuid,this)}async export(t,e,i=!1,o=!0){const n={},r=new Set(t.GetIfcEntityList(e)),a=new Set([x.IFCPROJECT,x.IFCSITE,x.IFCBUILDING,x.IFCBUILDINGSTOREY,x.IFCSPACE]);for(const c of a)r.add(c);for(const c of r){if(Li.has(c))continue;const h=a.has(c)&&o,E=t.GetLineIDsWithType(e,c);for(const d of E){const I=t.GetLine(0,d,h,i);n[I.expressID]=I}}return n}};u(As,"uuid","b32c4332-cd67-436e-ba7f-196646c7a635");let us=As;const Yn={103090709:"IFCPROJECT",4097777520:"IFCSITE",4031249490:"IFCBUILDING",3124254112:"IFCBUILDINGSTOREY",3856911033:"IFCSPACE",1674181508:"IFCANNOTATION",25142252:"IFCCONTROLLER",32344328:"IFCBOILER",76236018:"IFCLAMP",90941305:"IFCPUMP",177149247:"IFCAIRTERMINALBOX",182646315:"IFCFLOWINSTRUMENT",263784265:"IFCFURNISHINGELEMENT",264262732:"IFCELECTRICGENERATOR",277319702:"IFCAUDIOVISUALAPPLIANCE",310824031:"IFCPIPEFITTING",331165859:"IFCSTAIR",342316401:"IFCDUCTFITTING",377706215:"IFCMECHANICALFASTENER",395920057:"IFCDOOR",402227799:"IFCELECTRICMOTOR",413509423:"IFCSYSTEMFURNITUREELEMENT",484807127:"IFCEVAPORATOR",486154966:"IFCWINDOWSTANDARDCASE",629592764:"IFCLIGHTFIXTURE",630975310:"IFCUNITARYCONTROLELEMENT",635142910:"IFCCABLECARRIERFITTING",639361253:"IFCCOIL",647756555:"IFCFASTENER",707683696:"IFCFLOWSTORAGEDEVICE",738039164:"IFCPROTECTIVEDEVICE",753842376:"IFCBEAM",812556717:"IFCTANK",819412036:"IFCFILTER",843113511:"IFCCOLUMN",862014818:"IFCELECTRICDISTRIBUTIONBOARD",900683007:"IFCFOOTING",905975707:"IFCCOLUMNSTANDARDCASE",926996030:"IFCVOIDINGFEATURE",979691226:"IFCREINFORCINGBAR",987401354:"IFCFLOWSEGMENT",1003880860:"IFCELECTRICTIMECONTROL",1051757585:"IFCCABLEFITTING",1052013943:"IFCDISTRIBUTIONCHAMBERELEMENT",1062813311:"IFCDISTRIBUTIONCONTROLELEMENT",1073191201:"IFCMEMBER",1095909175:"IFCBUILDINGELEMENTPROXY",1156407060:"IFCPLATESTANDARDCASE",1162798199:"IFCSWITCHINGDEVICE",1329646415:"IFCSHADINGDEVICE",1335981549:"IFCDISCRETEACCESSORY",1360408905:"IFCDUCTSILENCER",1404847402:"IFCSTACKTERMINAL",1426591983:"IFCFIRESUPPRESSIONTERMINAL",1437502449:"IFCMEDICALDEVICE",1509553395:"IFCFURNITURE",1529196076:"IFCSLAB",1620046519:"IFCTRANSPORTELEMENT",1634111441:"IFCAIRTERMINAL",1658829314:"IFCENERGYCONVERSIONDEVICE",1677625105:"IFCCIVILELEMENT",1687234759:"IFCPILE",1904799276:"IFCELECTRICAPPLIANCE",1911478936:"IFCMEMBERSTANDARDCASE",1945004755:"IFCDISTRIBUTIONELEMENT",1973544240:"IFCCOVERING",1999602285:"IFCSPACEHEATER",2016517767:"IFCROOF",2056796094:"IFCAIRTOAIRHEATRECOVERY",2058353004:"IFCFLOWCONTROLLER",2068733104:"IFCHUMIDIFIER",2176052936:"IFCJUNCTIONBOX",2188021234:"IFCFLOWMETER",2223149337:"IFCFLOWTERMINAL",2262370178:"IFCRAILING",2272882330:"IFCCONDENSER",2295281155:"IFCPROTECTIVEDEVICETRIPPINGUNIT",2320036040:"IFCREINFORCINGMESH",2347447852:"IFCTENDONANCHOR",2391383451:"IFCVIBRATIONISOLATOR",2391406946:"IFCWALL",2474470126:"IFCMOTORCONNECTION",2769231204:"IFCVIRTUALELEMENT",2814081492:"IFCENGINE",2906023776:"IFCBEAMSTANDARDCASE",2938176219:"IFCBURNER",2979338954:"IFCBUILDINGELEMENTPART",3024970846:"IFCRAMP",3026737570:"IFCTUBEBUNDLE",3027962421:"IFCSLABSTANDARDCASE",3040386961:"IFCDISTRIBUTIONFLOWELEMENT",3053780830:"IFCSANITARYTERMINAL",3079942009:"IFCOPENINGSTANDARDCASE",3087945054:"IFCALARM",3101698114:"IFCSURFACEFEATURE",3127900445:"IFCSLABELEMENTEDCASE",3132237377:"IFCFLOWMOVINGDEVICE",3171933400:"IFCPLATE",3221913625:"IFCCOMMUNICATIONSAPPLIANCE",3242481149:"IFCDOORSTANDARDCASE",3283111854:"IFCRAMPFLIGHT",3296154744:"IFCCHIMNEY",3304561284:"IFCWINDOW",3310460725:"IFCELECTRICFLOWSTORAGEDEVICE",3319311131:"IFCHEATEXCHANGER",3415622556:"IFCFAN",3420628829:"IFCSOLARDEVICE",3493046030:"IFCGEOGRAPHICELEMENT",3495092785:"IFCCURTAINWALL",3508470533:"IFCFLOWTREATMENTDEVICE",3512223829:"IFCWALLSTANDARDCASE",3518393246:"IFCDUCTSEGMENT",3571504051:"IFCCOMPRESSOR",3588315303:"IFCOPENINGELEMENT",3612865200:"IFCPIPESEGMENT",3640358203:"IFCCOOLINGTOWER",3651124850:"IFCPROJECTIONELEMENT",3694346114:"IFCOUTLET",3747195512:"IFCEVAPORATIVECOOLER",3758799889:"IFCCABLECARRIERSEGMENT",3824725483:"IFCTENDON",3825984169:"IFCTRANSFORMER",3902619387:"IFCCHILLER",4074379575:"IFCDAMPER",4086658281:"IFCSENSOR",4123344466:"IFCELEMENTASSEMBLY",4136498852:"IFCCOOLEDBEAM",4156078855:"IFCWALLELEMENTEDCASE",4175244083:"IFCINTERCEPTOR",4207607924:"IFCVALVE",4217484030:"IFCCABLESEGMENT",4237592921:"IFCWASTETERMINAL",4252922144:"IFCSTAIRFLIGHT",4278956645:"IFCFLOWFITTING",4288193352:"IFCACTUATOR",4292641817:"IFCUNITARYEQUIPMENT",3009204131:"IFCGRID"};class xr{getAll(s,t){const e={},i=Object.keys(Yn).map(o=>parseInt(o,10));for(let o=0;o<i.length;o++){const n=i[o],r=s.GetLineIDsWithType(t,n),a=r.size();for(let c=0;c<a;c++)e[r.get(c)]=n}return e}}const Pi={950732822:"IFCURIREFERENCE",4075327185:"IFCTIME",1209108979:"IFCTEMPERATURERATEOFCHANGEMEASURE",3457685358:"IFCSOUNDPRESSURELEVELMEASURE",4157543285:"IFCSOUNDPOWERLEVELMEASURE",2798247006:"IFCPROPERTYSETDEFINITIONSET",1790229001:"IFCPOSITIVEINTEGER",525895558:"IFCNONNEGATIVELENGTHMEASURE",1774176899:"IFCLINEINDEX",1275358634:"IFCLANGUAGEID",2541165894:"IFCDURATION",3701338814:"IFCDAYINWEEKNUMBER",2195413836:"IFCDATETIME",937566702:"IFCDATE",1683019596:"IFCCARDINALPOINTREFERENCE",2314439260:"IFCBINARY",1500781891:"IFCAREADENSITYMEASURE",3683503648:"IFCARCINDEX",4065007721:"IFCYEARNUMBER",1718600412:"IFCWARPINGMOMENTMEASURE",51269191:"IFCWARPINGCONSTANTMEASURE",2593997549:"IFCVOLUMETRICFLOWRATEMEASURE",3458127941:"IFCVOLUMEMEASURE",3345633955:"IFCVAPORPERMEABILITYMEASURE",1278329552:"IFCTORQUEMEASURE",2591213694:"IFCTIMESTAMP",2726807636:"IFCTIMEMEASURE",743184107:"IFCTHERMODYNAMICTEMPERATUREMEASURE",2016195849:"IFCTHERMALTRANSMITTANCEMEASURE",857959152:"IFCTHERMALRESISTANCEMEASURE",2281867870:"IFCTHERMALEXPANSIONCOEFFICIENTMEASURE",2645777649:"IFCTHERMALCONDUCTIVITYMEASURE",232962298:"IFCTHERMALADMITTANCEMEASURE",296282323:"IFCTEXTTRANSFORMATION",603696268:"IFCTEXTFONTNAME",3490877962:"IFCTEXTDECORATION",1460886941:"IFCTEXTALIGNMENT",2801250643:"IFCTEXT",58845555:"IFCTEMPERATUREGRADIENTMEASURE",361837227:"IFCSPECULARROUGHNESS",2757832317:"IFCSPECULAREXPONENT",3477203348:"IFCSPECIFICHEATCAPACITYMEASURE",993287707:"IFCSOUNDPRESSUREMEASURE",846465480:"IFCSOUNDPOWERMEASURE",3471399674:"IFCSOLIDANGLEMEASURE",408310005:"IFCSHEARMODULUSMEASURE",2190458107:"IFCSECTIONALAREAINTEGRALMEASURE",3467162246:"IFCSECTIONMODULUSMEASURE",2766185779:"IFCSECONDINMINUTE",3211557302:"IFCROTATIONALSTIFFNESSMEASURE",1755127002:"IFCROTATIONALMASSMEASURE",2133746277:"IFCROTATIONALFREQUENCYMEASURE",200335297:"IFCREAL",96294661:"IFCRATIOMEASURE",3972513137:"IFCRADIOACTIVITYMEASURE",3665567075:"IFCPRESSUREMEASURE",2169031380:"IFCPRESENTABLETEXT",1364037233:"IFCPOWERMEASURE",1245737093:"IFCPOSITIVERATIOMEASURE",3054510233:"IFCPOSITIVEPLANEANGLEMEASURE",2815919920:"IFCPOSITIVELENGTHMEASURE",4042175685:"IFCPLANEANGLEMEASURE",2642773653:"IFCPLANARFORCEMEASURE",2260317790:"IFCPARAMETERVALUE",929793134:"IFCPHMEASURE",2395907400:"IFCNUMERICMEASURE",2095195183:"IFCNORMALISEDRATIOMEASURE",765770214:"IFCMONTHINYEARNUMBER",2615040989:"IFCMONETARYMEASURE",3114022597:"IFCMOMENTOFINERTIAMEASURE",1648970520:"IFCMOLECULARWEIGHTMEASURE",3177669450:"IFCMOISTUREDIFFUSIVITYMEASURE",1753493141:"IFCMODULUSOFSUBGRADEREACTIONMEASURE",1052454078:"IFCMODULUSOFROTATIONALSUBGRADEREACTIONMEASURE",2173214787:"IFCMODULUSOFLINEARSUBGRADEREACTIONMEASURE",3341486342:"IFCMODULUSOFELASTICITYMEASURE",102610177:"IFCMINUTEINHOUR",3531705166:"IFCMASSPERLENGTHMEASURE",3124614049:"IFCMASSMEASURE",4017473158:"IFCMASSFLOWRATEMEASURE",1477762836:"IFCMASSDENSITYMEASURE",2486716878:"IFCMAGNETICFLUXMEASURE",286949696:"IFCMAGNETICFLUXDENSITYMEASURE",151039812:"IFCLUMINOUSINTENSITYMEASURE",2755797622:"IFCLUMINOUSINTENSITYDISTRIBUTIONMEASURE",2095003142:"IFCLUMINOUSFLUXMEASURE",503418787:"IFCLOGICAL",3086160713:"IFCLINEARVELOCITYMEASURE",1307019551:"IFCLINEARSTIFFNESSMEASURE",2128979029:"IFCLINEARMOMENTMEASURE",191860431:"IFCLINEARFORCEMEASURE",1243674935:"IFCLENGTHMEASURE",3258342251:"IFCLABEL",2054016361:"IFCKINEMATICVISCOSITYMEASURE",3192672207:"IFCISOTHERMALMOISTURECAPACITYMEASURE",3686016028:"IFCIONCONCENTRATIONMEASURE",3809634241:"IFCINTEGERCOUNTRATEMEASURE",1939436016:"IFCINTEGER",2679005408:"IFCINDUCTANCEMEASURE",3358199106:"IFCILLUMINANCEMEASURE",983778844:"IFCIDENTIFIER",2589826445:"IFCHOURINDAY",1158859006:"IFCHEATINGVALUEMEASURE",3113092358:"IFCHEATFLUXDENSITYMEASURE",3064340077:"IFCGLOBALLYUNIQUEID",3044325142:"IFCFREQUENCYMEASURE",1361398929:"IFCFORCEMEASURE",2590844177:"IFCFONTWEIGHT",2715512545:"IFCFONTVARIANT",1102727119:"IFCFONTSTYLE",2078135608:"IFCENERGYMEASURE",2506197118:"IFCELECTRICVOLTAGEMEASURE",2951915441:"IFCELECTRICRESISTANCEMEASURE",3790457270:"IFCELECTRICCURRENTMEASURE",2093906313:"IFCELECTRICCONDUCTANCEMEASURE",3818826038:"IFCELECTRICCHARGEMEASURE",1827137117:"IFCELECTRICCAPACITANCEMEASURE",69416015:"IFCDYNAMICVISCOSITYMEASURE",524656162:"IFCDOSEEQUIVALENTMEASURE",4134073009:"IFCDIMENSIONCOUNT",1514641115:"IFCDESCRIPTIVEMEASURE",300323983:"IFCDAYLIGHTSAVINGHOUR",86635668:"IFCDAYINMONTHNUMBER",94842927:"IFCCURVATUREMEASURE",1778710042:"IFCCOUNTMEASURE",3238673880:"IFCCONTEXTDEPENDENTMEASURE",3812528620:"IFCCOMPOUNDPLANEANGLEMEASURE",2991860651:"IFCCOMPLEXNUMBER",1867003952:"IFCBOXALIGNMENT",2735952531:"IFCBOOLEAN",2650437152:"IFCAREAMEASURE",632304761:"IFCANGULARVELOCITYMEASURE",360377573:"IFCAMOUNTOFSUBSTANCEMEASURE",4182062534:"IFCACCELERATIONMEASURE",3699917729:"IFCABSORBEDDOSEMEASURE",1971632696:"IFCGEOSLICE",2680139844:"IFCGEOMODEL",24726584:"IFCELECTRICFLOWTREATMENTDEVICE",3693000487:"IFCDISTRIBUTIONBOARD",3460952963:"IFCCONVEYORSEGMENT",3999819293:"IFCCAISSONFOUNDATION",3314249567:"IFCBOREHOLE",4196446775:"IFCBEARING",325726236:"IFCALIGNMENT",3425753595:"IFCTRACKELEMENT",991950508:"IFCSIGNAL",3798194928:"IFCREINFORCEDSOIL",3290496277:"IFCRAIL",1383356374:"IFCPAVEMENT",2182337498:"IFCNAVIGATIONELEMENT",234836483:"IFCMOORINGDEVICE",2078563270:"IFCMOBILETELECOMMUNICATIONSAPPLIANCE",1638804497:"IFCLIQUIDTERMINAL",1154579445:"IFCLINEARPOSITIONINGELEMENT",2696325953:"IFCKERB",2713699986:"IFCGEOTECHNICALASSEMBLY",2142170206:"IFCELECTRICFLOWTREATMENTDEVICETYPE",3376911765:"IFCEARTHWORKSFILL",1077100507:"IFCEARTHWORKSELEMENT",3071239417:"IFCEARTHWORKSCUT",479945903:"IFCDISTRIBUTIONBOARDTYPE",3426335179:"IFCDEEPFOUNDATION",1502416096:"IFCCOURSE",2940368186:"IFCCONVEYORSEGMENTTYPE",3203706013:"IFCCAISSONFOUNDATIONTYPE",3862327254:"IFCBUILTSYSTEM",1876633798:"IFCBUILTELEMENT",963979645:"IFCBRIDGEPART",644574406:"IFCBRIDGE",3649138523:"IFCBEARINGTYPE",1662888072:"IFCALIGNMENTVERTICAL",317615605:"IFCALIGNMENTSEGMENT",1545765605:"IFCALIGNMENTHORIZONTAL",4266260250:"IFCALIGNMENTCANT",3956297820:"IFCVIBRATIONDAMPERTYPE",1530820697:"IFCVIBRATIONDAMPER",840318589:"IFCVEHICLE",1953115116:"IFCTRANSPORTATIONDEVICE",618700268:"IFCTRACKELEMENTTYPE",2281632017:"IFCTENDONCONDUITTYPE",3663046924:"IFCTENDONCONDUIT",42703149:"IFCSINESPIRAL",1894708472:"IFCSIGNALTYPE",3599934289:"IFCSIGNTYPE",33720170:"IFCSIGN",1027922057:"IFCSEVENTHORDERPOLYNOMIALSPIRAL",544395925:"IFCSEGMENTEDREFERENCECURVE",3649235739:"IFCSECONDORDERPOLYNOMIALSPIRAL",550521510:"IFCROADPART",146592293:"IFCROAD",3818125796:"IFCRELADHERESTOELEMENT",4021432810:"IFCREFERENT",1891881377:"IFCRAILWAYPART",3992365140:"IFCRAILWAY",1763565496:"IFCRAILTYPE",1946335990:"IFCPOSITIONINGELEMENT",514975943:"IFCPAVEMENTTYPE",506776471:"IFCNAVIGATIONELEMENTTYPE",710110818:"IFCMOORINGDEVICETYPE",1950438474:"IFCMOBILETELECOMMUNICATIONSAPPLIANCETYPE",976884017:"IFCMARINEPART",525669439:"IFCMARINEFACILITY",1770583370:"IFCLIQUIDTERMINALTYPE",2176059722:"IFCLINEARELEMENT",679976338:"IFCKERBTYPE",3948183225:"IFCIMPACTPROTECTIONDEVICETYPE",2568555532:"IFCIMPACTPROTECTIONDEVICE",2898700619:"IFCGRADIENTCURVE",1594536857:"IFCGEOTECHNICALSTRATUM",4230923436:"IFCGEOTECHNICALELEMENT",4228831410:"IFCFACILITYPARTCOMMON",1310830890:"IFCFACILITYPART",24185140:"IFCFACILITY",4234616927:"IFCDIRECTRIXDERIVEDREFERENCESWEPTAREASOLID",1306400036:"IFCDEEPFOUNDATIONTYPE",4189326743:"IFCCOURSETYPE",2000195564:"IFCCOSINESPIRAL",3497074424:"IFCCLOTHOID",1626504194:"IFCBUILTELEMENTTYPE",3651464721:"IFCVEHICLETYPE",1229763772:"IFCTRIANGULATEDIRREGULARNETWORK",3665877780:"IFCTRANSPORTATIONDEVICETYPE",782932809:"IFCTHIRDORDERPOLYNOMIALSPIRAL",2735484536:"IFCSPIRAL",1356537516:"IFCSECTIONEDSURFACE",1290935644:"IFCSECTIONEDSOLIDHORIZONTAL",1862484736:"IFCSECTIONEDSOLID",1441486842:"IFCRELPOSITIONS",1033248425:"IFCRELASSOCIATESPROFILEDEF",3381221214:"IFCPOLYNOMIALCURVE",2485787929:"IFCOFFSETCURVEBYDISTANCES",590820931:"IFCOFFSETCURVE",3465909080:"IFCINDEXEDPOLYGONALTEXTUREMAP",593015953:"IFCDIRECTRIXCURVESWEPTAREASOLID",4212018352:"IFCCURVESEGMENT",3425423356:"IFCAXIS2PLACEMENTLINEAR",823603102:"IFCSEGMENT",2165702409:"IFCPOINTBYDISTANCEEXPRESSION",182550632:"IFCOPENCROSSPROFILEDEF",388784114:"IFCLINEARPLACEMENT",536804194:"IFCALIGNMENTHORIZONTALSEGMENT",3752311538:"IFCALIGNMENTCANTSEGMENT",1010789467:"IFCTEXTURECOORDINATEINDICESWITHVOIDS",222769930:"IFCTEXTURECOORDINATEINDICES",2691318326:"IFCQUANTITYNUMBER",3633395639:"IFCALIGNMENTVERTICALSEGMENT",2879124712:"IFCALIGNMENTPARAMETERSEGMENT",25142252:"IFCCONTROLLER",3087945054:"IFCALARM",4288193352:"IFCACTUATOR",630975310:"IFCUNITARYCONTROLELEMENT",4086658281:"IFCSENSOR",2295281155:"IFCPROTECTIVEDEVICETRIPPINGUNIT",182646315:"IFCFLOWINSTRUMENT",1426591983:"IFCFIRESUPPRESSIONTERMINAL",819412036:"IFCFILTER",3415622556:"IFCFAN",1003880860:"IFCELECTRICTIMECONTROL",402227799:"IFCELECTRICMOTOR",264262732:"IFCELECTRICGENERATOR",3310460725:"IFCELECTRICFLOWSTORAGEDEVICE",862014818:"IFCELECTRICDISTRIBUTIONBOARD",1904799276:"IFCELECTRICAPPLIANCE",1360408905:"IFCDUCTSILENCER",3518393246:"IFCDUCTSEGMENT",342316401:"IFCDUCTFITTING",562808652:"IFCDISTRIBUTIONCIRCUIT",4074379575:"IFCDAMPER",3640358203:"IFCCOOLINGTOWER",4136498852:"IFCCOOLEDBEAM",2272882330:"IFCCONDENSER",3571504051:"IFCCOMPRESSOR",3221913625:"IFCCOMMUNICATIONSAPPLIANCE",639361253:"IFCCOIL",3902619387:"IFCCHILLER",4217484030:"IFCCABLESEGMENT",1051757585:"IFCCABLEFITTING",3758799889:"IFCCABLECARRIERSEGMENT",635142910:"IFCCABLECARRIERFITTING",2938176219:"IFCBURNER",32344328:"IFCBOILER",2906023776:"IFCBEAMSTANDARDCASE",277319702:"IFCAUDIOVISUALAPPLIANCE",2056796094:"IFCAIRTOAIRHEATRECOVERY",177149247:"IFCAIRTERMINALBOX",1634111441:"IFCAIRTERMINAL",486154966:"IFCWINDOWSTANDARDCASE",4237592921:"IFCWASTETERMINAL",4156078855:"IFCWALLELEMENTEDCASE",4207607924:"IFCVALVE",4292641817:"IFCUNITARYEQUIPMENT",3179687236:"IFCUNITARYCONTROLELEMENTTYPE",3026737570:"IFCTUBEBUNDLE",3825984169:"IFCTRANSFORMER",812556717:"IFCTANK",1162798199:"IFCSWITCHINGDEVICE",385403989:"IFCSTRUCTURALLOADCASE",1404847402:"IFCSTACKTERMINAL",1999602285:"IFCSPACEHEATER",3420628829:"IFCSOLARDEVICE",3027962421:"IFCSLABSTANDARDCASE",3127900445:"IFCSLABELEMENTEDCASE",1329646415:"IFCSHADINGDEVICE",3053780830:"IFCSANITARYTERMINAL",2572171363:"IFCREINFORCINGBARTYPE",1232101972:"IFCRATIONALBSPLINECURVEWITHKNOTS",90941305:"IFCPUMP",655969474:"IFCPROTECTIVEDEVICETRIPPINGUNITTYPE",738039164:"IFCPROTECTIVEDEVICE",1156407060:"IFCPLATESTANDARDCASE",3612865200:"IFCPIPESEGMENT",310824031:"IFCPIPEFITTING",3694346114:"IFCOUTLET",144952367:"IFCOUTERBOUNDARYCURVE",2474470126:"IFCMOTORCONNECTION",1911478936:"IFCMEMBERSTANDARDCASE",1437502449:"IFCMEDICALDEVICE",629592764:"IFCLIGHTFIXTURE",76236018:"IFCLAMP",2176052936:"IFCJUNCTIONBOX",4175244083:"IFCINTERCEPTOR",2068733104:"IFCHUMIDIFIER",3319311131:"IFCHEATEXCHANGER",2188021234:"IFCFLOWMETER",1209101575:"IFCEXTERNALSPATIALELEMENT",484807127:"IFCEVAPORATOR",3747195512:"IFCEVAPORATIVECOOLER",2814081492:"IFCENGINE",2417008758:"IFCELECTRICDISTRIBUTIONBOARDTYPE",3242481149:"IFCDOORSTANDARDCASE",3205830791:"IFCDISTRIBUTIONSYSTEM",400855858:"IFCCOMMUNICATIONSAPPLIANCETYPE",905975707:"IFCCOLUMNSTANDARDCASE",1677625105:"IFCCIVILELEMENT",3296154744:"IFCCHIMNEY",2674252688:"IFCCABLEFITTINGTYPE",2188180465:"IFCBURNERTYPE",1177604601:"IFCBUILDINGSYSTEM",39481116:"IFCBUILDINGELEMENTPARTTYPE",1136057603:"IFCBOUNDARYCURVE",2461110595:"IFCBSPLINECURVEWITHKNOTS",1532957894:"IFCAUDIOVISUALAPPLIANCETYPE",4088093105:"IFCWORKCALENDAR",4009809668:"IFCWINDOWTYPE",926996030:"IFCVOIDINGFEATURE",2391383451:"IFCVIBRATIONISOLATOR",2415094496:"IFCTENDONTYPE",3081323446:"IFCTENDONANCHORTYPE",413509423:"IFCSYSTEMFURNITUREELEMENT",3101698114:"IFCSURFACEFEATURE",3657597509:"IFCSTRUCTURALSURFACEACTION",2757150158:"IFCSTRUCTURALCURVEREACTION",1004757350:"IFCSTRUCTURALCURVEACTION",338393293:"IFCSTAIRTYPE",1072016465:"IFCSOLARDEVICETYPE",4074543187:"IFCSHADINGDEVICETYPE",2157484638:"IFCSEAMCURVE",2781568857:"IFCROOFTYPE",2310774935:"IFCREINFORCINGMESHTYPE",964333572:"IFCREINFORCINGELEMENTTYPE",683857671:"IFCRATIONALBSPLINESURFACEWITHKNOTS",1469900589:"IFCRAMPTYPE",2839578677:"IFCPOLYGONALFACESET",1158309216:"IFCPILETYPE",3079942009:"IFCOPENINGSTANDARDCASE",1114901282:"IFCMEDICALDEVICETYPE",3113134337:"IFCINTERSECTIONCURVE",3946677679:"IFCINTERCEPTORTYPE",2571569899:"IFCINDEXEDPOLYCURVE",3493046030:"IFCGEOGRAPHICELEMENT",1509553395:"IFCFURNITURE",1893162501:"IFCFOOTINGTYPE",2853485674:"IFCEXTERNALSPATIALSTRUCTUREELEMENT",4148101412:"IFCEVENT",132023988:"IFCENGINETYPE",2397081782:"IFCELEMENTASSEMBLYTYPE",2323601079:"IFCDOORTYPE",1213902940:"IFCCYLINDRICALSURFACE",1525564444:"IFCCONSTRUCTIONPRODUCTRESOURCETYPE",4105962743:"IFCCONSTRUCTIONMATERIALRESOURCETYPE",2185764099:"IFCCONSTRUCTIONEQUIPMENTRESOURCETYPE",15328376:"IFCCOMPOSITECURVEONSURFACE",3875453745:"IFCCOMPLEXPROPERTYTEMPLATE",3893394355:"IFCCIVILELEMENTTYPE",2197970202:"IFCCHIMNEYTYPE",167062518:"IFCBSPLINESURFACEWITHKNOTS",2887950389:"IFCBSPLINESURFACE",2603310189:"IFCADVANCEDBREPWITHVOIDS",1635779807:"IFCADVANCEDBREP",2916149573:"IFCTRIANGULATEDFACESET",1935646853:"IFCTOROIDALSURFACE",2387106220:"IFCTESSELLATEDFACESET",3206491090:"IFCTASKTYPE",699246055:"IFCSURFACECURVE",4095615324:"IFCSUBCONTRACTRESOURCETYPE",603775116:"IFCSTRUCTURALSURFACEREACTION",4015995234:"IFCSPHERICALSURFACE",2481509218:"IFCSPATIALZONETYPE",463610769:"IFCSPATIALZONE",710998568:"IFCSPATIALELEMENTTYPE",1412071761:"IFCSPATIALELEMENT",3663146110:"IFCSIMPLEPROPERTYTEMPLATE",3243963512:"IFCREVOLVEDAREASOLIDTAPERED",816062949:"IFCREPARAMETRISEDCOMPOSITECURVESEGMENT",1521410863:"IFCRELSPACEBOUNDARY2NDLEVEL",3523091289:"IFCRELSPACEBOUNDARY1STLEVEL",427948657:"IFCRELINTERFERESELEMENTS",307848117:"IFCRELDEFINESBYTEMPLATE",1462361463:"IFCRELDEFINESBYOBJECT",2565941209:"IFCRELDECLARES",1027710054:"IFCRELASSIGNSTOGROUPBYFACTOR",3521284610:"IFCPROPERTYTEMPLATE",492091185:"IFCPROPERTYSETTEMPLATE",653396225:"IFCPROJECTLIBRARY",569719735:"IFCPROCEDURETYPE",3967405729:"IFCPREDEFINEDPROPERTYSET",1682466193:"IFCPCURVE",428585644:"IFCLABORRESOURCETYPE",2294589976:"IFCINDEXEDPOLYGONALFACEWITHVOIDS",178912537:"IFCINDEXEDPOLYGONALFACE",4095422895:"IFCGEOGRAPHICELEMENTTYPE",2652556860:"IFCFIXEDREFERENCESWEPTAREASOLID",2804161546:"IFCEXTRUDEDAREASOLIDTAPERED",4024345920:"IFCEVENTTYPE",2629017746:"IFCCURVEBOUNDEDSURFACE",1815067380:"IFCCREWRESOURCETYPE",3419103109:"IFCCONTEXT",2574617495:"IFCCONSTRUCTIONRESOURCETYPE",2059837836:"IFCCARTESIANPOINTLIST3D",1675464909:"IFCCARTESIANPOINTLIST2D",574549367:"IFCCARTESIANPOINTLIST",3406155212:"IFCADVANCEDFACE",3698973494:"IFCTYPERESOURCE",3736923433:"IFCTYPEPROCESS",901063453:"IFCTESSELLATEDITEM",1096409881:"IFCSWEPTDISKSOLIDPOLYGONAL",1042787934:"IFCRESOURCETIME",1608871552:"IFCRESOURCECONSTRAINTRELATIONSHIP",2943643501:"IFCRESOURCEAPPROVALRELATIONSHIP",2090586900:"IFCQUANTITYSET",1482703590:"IFCPROPERTYTEMPLATEDEFINITION",3778827333:"IFCPREDEFINEDPROPERTIES",2998442950:"IFCMIRROREDPROFILEDEF",853536259:"IFCMATERIALRELATIONSHIP",3404854881:"IFCMATERIALPROFILESETUSAGETAPERING",3079605661:"IFCMATERIALPROFILESETUSAGE",2852063980:"IFCMATERIALCONSTITUENTSET",3708119e3:"IFCMATERIALCONSTITUENT",1585845231:"IFCLAGTIME",2133299955:"IFCINDEXEDTRIANGLETEXTUREMAP",1437953363:"IFCINDEXEDTEXTUREMAP",3570813810:"IFCINDEXEDCOLOURMAP",1437805879:"IFCEXTERNALREFERENCERELATIONSHIP",297599258:"IFCEXTENDEDPROPERTIES",211053100:"IFCEVENTTIME",2713554722:"IFCCONVERSIONBASEDUNITWITHOFFSET",3285139300:"IFCCOLOURRGBLIST",1236880293:"IFCWORKTIME",1199560280:"IFCTIMEPERIOD",3611470254:"IFCTEXTUREVERTEXLIST",2771591690:"IFCTASKTIMERECURRING",1549132990:"IFCTASKTIME",2043862942:"IFCTABLECOLUMN",2934153892:"IFCSURFACEREINFORCEMENTAREA",609421318:"IFCSTRUCTURALLOADORRESULT",3478079324:"IFCSTRUCTURALLOADCONFIGURATION",1054537805:"IFCSCHEDULINGTIME",2439245199:"IFCRESOURCELEVELRELATIONSHIP",2433181523:"IFCREFERENCE",3915482550:"IFCRECURRENCEPATTERN",986844984:"IFCPROPERTYABSTRACTION",3843373140:"IFCPROJECTEDCRS",677532197:"IFCPRESENTATIONITEM",1507914824:"IFCMATERIALUSAGEDEFINITION",552965576:"IFCMATERIALPROFILEWITHOFFSETS",164193824:"IFCMATERIALPROFILESET",2235152071:"IFCMATERIALPROFILE",1847252529:"IFCMATERIALLAYERWITHOFFSETS",760658860:"IFCMATERIALDEFINITION",3057273783:"IFCMAPCONVERSION",4294318154:"IFCEXTERNALINFORMATION",1466758467:"IFCCOORDINATEREFERENCESYSTEM",1785450214:"IFCCOORDINATEOPERATION",775493141:"IFCCONNECTIONVOLUMEGEOMETRY",979691226:"IFCREINFORCINGBAR",3700593921:"IFCELECTRICDISTRIBUTIONPOINT",1062813311:"IFCDISTRIBUTIONCONTROLELEMENT",1052013943:"IFCDISTRIBUTIONCHAMBERELEMENT",578613899:"IFCCONTROLLERTYPE",2454782716:"IFCCHAMFEREDGEFEATURE",753842376:"IFCBEAM",3001207471:"IFCALARMTYPE",2874132201:"IFCACTUATORTYPE",3304561284:"IFCWINDOW",3512223829:"IFCWALLSTANDARDCASE",2391406946:"IFCWALL",3313531582:"IFCVIBRATIONISOLATORTYPE",2347447852:"IFCTENDONANCHOR",3824725483:"IFCTENDON",2515109513:"IFCSTRUCTURALANALYSISMODEL",4252922144:"IFCSTAIRFLIGHT",331165859:"IFCSTAIR",1529196076:"IFCSLAB",1783015770:"IFCSENSORTYPE",1376911519:"IFCROUNDEDEDGEFEATURE",2016517767:"IFCROOF",2320036040:"IFCREINFORCINGMESH",3027567501:"IFCREINFORCINGELEMENT",3055160366:"IFCRATIONALBEZIERCURVE",3283111854:"IFCRAMPFLIGHT",3024970846:"IFCRAMP",2262370178:"IFCRAILING",3171933400:"IFCPLATE",1687234759:"IFCPILE",1073191201:"IFCMEMBER",900683007:"IFCFOOTING",3508470533:"IFCFLOWTREATMENTDEVICE",2223149337:"IFCFLOWTERMINAL",707683696:"IFCFLOWSTORAGEDEVICE",987401354:"IFCFLOWSEGMENT",3132237377:"IFCFLOWMOVINGDEVICE",4037862832:"IFCFLOWINSTRUMENTTYPE",4278956645:"IFCFLOWFITTING",2058353004:"IFCFLOWCONTROLLER",4222183408:"IFCFIRESUPPRESSIONTERMINALTYPE",1810631287:"IFCFILTERTYPE",346874300:"IFCFANTYPE",1658829314:"IFCENERGYCONVERSIONDEVICE",857184966:"IFCELECTRICALELEMENT",1634875225:"IFCELECTRICALCIRCUIT",712377611:"IFCELECTRICTIMECONTROLTYPE",1217240411:"IFCELECTRICMOTORTYPE",1365060375:"IFCELECTRICHEATERTYPE",1534661035:"IFCELECTRICGENERATORTYPE",3277789161:"IFCELECTRICFLOWSTORAGEDEVICETYPE",663422040:"IFCELECTRICAPPLIANCETYPE",855621170:"IFCEDGEFEATURE",2030761528:"IFCDUCTSILENCERTYPE",3760055223:"IFCDUCTSEGMENTTYPE",869906466:"IFCDUCTFITTINGTYPE",395920057:"IFCDOOR",3041715199:"IFCDISTRIBUTIONPORT",3040386961:"IFCDISTRIBUTIONFLOWELEMENT",1945004755:"IFCDISTRIBUTIONELEMENT",2063403501:"IFCDISTRIBUTIONCONTROLELEMENTTYPE",1599208980:"IFCDISTRIBUTIONCHAMBERELEMENTTYPE",2635815018:"IFCDISCRETEACCESSORYTYPE",1335981549:"IFCDISCRETEACCESSORY",4147604152:"IFCDIAMETERDIMENSION",3961806047:"IFCDAMPERTYPE",3495092785:"IFCCURTAINWALL",1973544240:"IFCCOVERING",2954562838:"IFCCOOLINGTOWERTYPE",335055490:"IFCCOOLEDBEAMTYPE",488727124:"IFCCONSTRUCTIONPRODUCTRESOURCE",1060000209:"IFCCONSTRUCTIONMATERIALRESOURCE",3898045240:"IFCCONSTRUCTIONEQUIPMENTRESOURCE",1163958913:"IFCCONDITIONCRITERION",2188551683:"IFCCONDITION",2816379211:"IFCCONDENSERTYPE",3850581409:"IFCCOMPRESSORTYPE",843113511:"IFCCOLUMN",2301859152:"IFCCOILTYPE",2611217952:"IFCCIRCLE",2951183804:"IFCCHILLERTYPE",1285652485:"IFCCABLESEGMENTTYPE",3293546465:"IFCCABLECARRIERSEGMENTTYPE",395041908:"IFCCABLECARRIERFITTINGTYPE",1909888760:"IFCBUILDINGELEMENTPROXYTYPE",1095909175:"IFCBUILDINGELEMENTPROXY",2979338954:"IFCBUILDINGELEMENTPART",52481810:"IFCBUILDINGELEMENTCOMPONENT",3299480353:"IFCBUILDINGELEMENT",231477066:"IFCBOILERTYPE",1916977116:"IFCBEZIERCURVE",819618141:"IFCBEAMTYPE",1967976161:"IFCBSPLINECURVE",3460190687:"IFCASSET",2470393545:"IFCANGULARDIMENSION",1871374353:"IFCAIRTOAIRHEATRECOVERYTYPE",3352864051:"IFCAIRTERMINALTYPE",1411407467:"IFCAIRTERMINALBOXTYPE",3821786052:"IFCACTIONREQUEST",1213861670:"IFC2DCOMPOSITECURVE",1033361043:"IFCZONE",3342526732:"IFCWORKSCHEDULE",4218914973:"IFCWORKPLAN",1028945134:"IFCWORKCONTROL",1133259667:"IFCWASTETERMINALTYPE",1898987631:"IFCWALLTYPE",2769231204:"IFCVIRTUALELEMENT",728799441:"IFCVALVETYPE",1911125066:"IFCUNITARYEQUIPMENTTYPE",1600972822:"IFCTUBEBUNDLETYPE",3593883385:"IFCTRIMMEDCURVE",1620046519:"IFCTRANSPORTELEMENT",1692211062:"IFCTRANSFORMERTYPE",1637806684:"IFCTIMESERIESSCHEDULE",5716631:"IFCTANKTYPE",2254336722:"IFCSYSTEM",2315554128:"IFCSWITCHINGDEVICETYPE",148013059:"IFCSUBCONTRACTRESOURCE",1975003073:"IFCSTRUCTURALSURFACECONNECTION",2986769608:"IFCSTRUCTURALRESULTGROUP",1235345126:"IFCSTRUCTURALPOINTREACTION",734778138:"IFCSTRUCTURALPOINTCONNECTION",2082059205:"IFCSTRUCTURALPOINTACTION",3987759626:"IFCSTRUCTURALPLANARACTIONVARYING",1621171031:"IFCSTRUCTURALPLANARACTION",1252848954:"IFCSTRUCTURALLOADGROUP",1721250024:"IFCSTRUCTURALLINEARACTIONVARYING",1807405624:"IFCSTRUCTURALLINEARACTION",2445595289:"IFCSTRUCTURALCURVEMEMBERVARYING",214636428:"IFCSTRUCTURALCURVEMEMBER",4243806635:"IFCSTRUCTURALCURVECONNECTION",1179482911:"IFCSTRUCTURALCONNECTION",682877961:"IFCSTRUCTURALACTION",1039846685:"IFCSTAIRFLIGHTTYPE",3112655638:"IFCSTACKTERMINALTYPE",3812236995:"IFCSPACETYPE",652456506:"IFCSPACEPROGRAM",1305183839:"IFCSPACEHEATERTYPE",3856911033:"IFCSPACE",2533589738:"IFCSLABTYPE",4097777520:"IFCSITE",4105383287:"IFCSERVICELIFE",3517283431:"IFCSCHEDULETIMECONTROL",1768891740:"IFCSANITARYTERMINALTYPE",2863920197:"IFCRELASSIGNSTASKS",160246688:"IFCRELAGGREGATES",2324767716:"IFCRAMPFLIGHTTYPE",2893384427:"IFCRAILINGTYPE",3248260540:"IFCRADIUSDIMENSION",2250791053:"IFCPUMPTYPE",1842657554:"IFCPROTECTIVEDEVICETYPE",3651124850:"IFCPROJECTIONELEMENT",3642467123:"IFCPROJECTORDERRECORD",2904328755:"IFCPROJECTORDER",2744685151:"IFCPROCEDURE",3740093272:"IFCPORT",3724593414:"IFCPOLYLINE",4017108033:"IFCPLATETYPE",4231323485:"IFCPIPESEGMENTTYPE",804291784:"IFCPIPEFITTINGTYPE",3327091369:"IFCPERMIT",2382730787:"IFCPERFORMANCEHISTORY",2837617999:"IFCOUTLETTYPE",3425660407:"IFCORDERACTION",3588315303:"IFCOPENINGELEMENT",4143007308:"IFCOCCUPANT",1916936684:"IFCMOVE",977012517:"IFCMOTORCONNECTIONTYPE",3181161470:"IFCMEMBERTYPE",2108223431:"IFCMECHANICALFASTENERTYPE",377706215:"IFCMECHANICALFASTENER",2506943328:"IFCLINEARDIMENSION",1161773419:"IFCLIGHTFIXTURETYPE",1051575348:"IFCLAMPTYPE",3827777499:"IFCLABORRESOURCE",4288270099:"IFCJUNCTIONBOXTYPE",2391368822:"IFCINVENTORY",1806887404:"IFCHUMIDIFIERTYPE",1251058090:"IFCHEATEXCHANGERTYPE",2706460486:"IFCGROUP",3009204131:"IFCGRID",200128114:"IFCGASTERMINALTYPE",814719939:"IFCFURNITURESTANDARD",263784265:"IFCFURNISHINGELEMENT",3009222698:"IFCFLOWTREATMENTDEVICETYPE",2297155007:"IFCFLOWTERMINALTYPE",1339347760:"IFCFLOWSTORAGEDEVICETYPE",1834744321:"IFCFLOWSEGMENTTYPE",1482959167:"IFCFLOWMOVINGDEVICETYPE",3815607619:"IFCFLOWMETERTYPE",3198132628:"IFCFLOWFITTINGTYPE",3907093117:"IFCFLOWCONTROLLERTYPE",1287392070:"IFCFEATUREELEMENTSUBTRACTION",2143335405:"IFCFEATUREELEMENTADDITION",2827207264:"IFCFEATUREELEMENT",2489546625:"IFCFASTENERTYPE",647756555:"IFCFASTENER",3737207727:"IFCFACETEDBREPWITHVOIDS",807026263:"IFCFACETEDBREP",3390157468:"IFCEVAPORATORTYPE",3174744832:"IFCEVAPORATIVECOOLERTYPE",3272907226:"IFCEQUIPMENTSTANDARD",1962604670:"IFCEQUIPMENTELEMENT",2107101300:"IFCENERGYCONVERSIONDEVICETYPE",1704287377:"IFCELLIPSE",2590856083:"IFCELEMENTCOMPONENTTYPE",1623761950:"IFCELEMENTCOMPONENT",4123344466:"IFCELEMENTASSEMBLY",1758889154:"IFCELEMENT",360485395:"IFCELECTRICALBASEPROPERTIES",3849074793:"IFCDISTRIBUTIONFLOWELEMENTTYPE",3256556792:"IFCDISTRIBUTIONELEMENTTYPE",681481545:"IFCDIMENSIONCURVEDIRECTEDCALLOUT",1457835157:"IFCCURTAINWALLTYPE",3295246426:"IFCCREWRESOURCE",1916426348:"IFCCOVERINGTYPE",1419761937:"IFCCOSTSCHEDULE",3895139033:"IFCCOSTITEM",3293443760:"IFCCONTROL",2559216714:"IFCCONSTRUCTIONRESOURCE",2510884976:"IFCCONIC",3732776249:"IFCCOMPOSITECURVE",300633059:"IFCCOLUMNTYPE",2937912522:"IFCCIRCLEHOLLOWPROFILEDEF",3124254112:"IFCBUILDINGSTOREY",1950629157:"IFCBUILDINGELEMENTTYPE",4031249490:"IFCBUILDING",1260505505:"IFCBOUNDEDCURVE",3649129432:"IFCBOOLEANCLIPPINGRESULT",1334484129:"IFCBLOCK",3207858831:"IFCASYMMETRICISHAPEPROFILEDEF",1674181508:"IFCANNOTATION",2296667514:"IFCACTOR",2097647324:"IFCTRANSPORTELEMENTTYPE",3473067441:"IFCTASK",1580310250:"IFCSYSTEMFURNITUREELEMENTTYPE",4124788165:"IFCSURFACEOFREVOLUTION",2809605785:"IFCSURFACEOFLINEAREXTRUSION",2028607225:"IFCSURFACECURVESWEPTAREASOLID",4070609034:"IFCSTRUCTUREDDIMENSIONCALLOUT",2218152070:"IFCSTRUCTURALSURFACEMEMBERVARYING",3979015343:"IFCSTRUCTURALSURFACEMEMBER",3689010777:"IFCSTRUCTURALREACTION",530289379:"IFCSTRUCTURALMEMBER",3136571912:"IFCSTRUCTURALITEM",3544373492:"IFCSTRUCTURALACTIVITY",451544542:"IFCSPHERE",3893378262:"IFCSPATIALSTRUCTUREELEMENTTYPE",2706606064:"IFCSPATIALSTRUCTUREELEMENT",3626867408:"IFCRIGHTCIRCULARCYLINDER",4158566097:"IFCRIGHTCIRCULARCONE",1856042241:"IFCREVOLVEDAREASOLID",2914609552:"IFCRESOURCE",1401173127:"IFCRELVOIDSELEMENT",3451746338:"IFCRELSPACEBOUNDARY",366585022:"IFCRELSERVICESBUILDINGS",4122056220:"IFCRELSEQUENCE",1058617721:"IFCRELSCHEDULESCOSTITEMS",1245217292:"IFCRELREFERENCEDINSPATIALSTRUCTURE",750771296:"IFCRELPROJECTSELEMENT",202636808:"IFCRELOVERRIDESPROPERTIES",2051452291:"IFCRELOCCUPIESSPACES",3268803585:"IFCRELNESTS",4189434867:"IFCRELINTERACTIONREQUIREMENTS",279856033:"IFCRELFLOWCONTROLELEMENTS",3940055652:"IFCRELFILLSELEMENT",781010003:"IFCRELDEFINESBYTYPE",4186316022:"IFCRELDEFINESBYPROPERTIES",693640335:"IFCRELDEFINES",2551354335:"IFCRELDECOMPOSES",2802773753:"IFCRELCOVERSSPACES",886880790:"IFCRELCOVERSBLDGELEMENTS",3242617779:"IFCRELCONTAINEDINSPATIALSTRUCTURE",3678494232:"IFCRELCONNECTSWITHREALIZINGELEMENTS",504942748:"IFCRELCONNECTSWITHECCENTRICITY",1638771189:"IFCRELCONNECTSSTRUCTURALMEMBER",3912681535:"IFCRELCONNECTSSTRUCTURALELEMENT",2127690289:"IFCRELCONNECTSSTRUCTURALACTIVITY",3190031847:"IFCRELCONNECTSPORTS",4201705270:"IFCRELCONNECTSPORTTOELEMENT",3945020480:"IFCRELCONNECTSPATHELEMENTS",1204542856:"IFCRELCONNECTSELEMENTS",826625072:"IFCRELCONNECTS",2851387026:"IFCRELASSOCIATESPROFILEPROPERTIES",2655215786:"IFCRELASSOCIATESMATERIAL",3840914261:"IFCRELASSOCIATESLIBRARY",982818633:"IFCRELASSOCIATESDOCUMENT",2728634034:"IFCRELASSOCIATESCONSTRAINT",919958153:"IFCRELASSOCIATESCLASSIFICATION",4095574036:"IFCRELASSOCIATESAPPROVAL",1327628568:"IFCRELASSOCIATESAPPLIEDVALUE",1865459582:"IFCRELASSOCIATES",205026976:"IFCRELASSIGNSTORESOURCE",3372526763:"IFCRELASSIGNSTOPROJECTORDER",2857406711:"IFCRELASSIGNSTOPRODUCT",4278684876:"IFCRELASSIGNSTOPROCESS",1307041759:"IFCRELASSIGNSTOGROUP",2495723537:"IFCRELASSIGNSTOCONTROL",1683148259:"IFCRELASSIGNSTOACTOR",3939117080:"IFCRELASSIGNS",3454111270:"IFCRECTANGULARTRIMMEDSURFACE",2798486643:"IFCRECTANGULARPYRAMID",2770003689:"IFCRECTANGLEHOLLOWPROFILEDEF",3219374653:"IFCPROXY",1451395588:"IFCPROPERTYSET",4194566429:"IFCPROJECTIONCURVE",103090709:"IFCPROJECT",4208778838:"IFCPRODUCT",2945172077:"IFCPROCESS",220341763:"IFCPLANE",603570806:"IFCPLANARBOX",3566463478:"IFCPERMEABLECOVERINGPROPERTIES",3505215534:"IFCOFFSETCURVE3D",3388369263:"IFCOFFSETCURVE2D",3888040117:"IFCOBJECT",1425443689:"IFCMANIFOLDSOLIDBREP",1281925730:"IFCLINE",572779678:"IFCLSHAPEPROFILEDEF",1484403080:"IFCISHAPEPROFILEDEF",987898635:"IFCGEOMETRICCURVESET",1268542332:"IFCFURNITURETYPE",4238390223:"IFCFURNISHINGELEMENTTYPE",3455213021:"IFCFLUIDFLOWPROPERTIES",315944413:"IFCFILLAREASTYLETILES",4203026998:"IFCFILLAREASTYLETILESYMBOLWITHSTYLE",374418227:"IFCFILLAREASTYLEHATCHING",2047409740:"IFCFACEBASEDSURFACEMODEL",477187591:"IFCEXTRUDEDAREASOLID",80994333:"IFCENERGYPROPERTIES",2835456948:"IFCELLIPSEPROFILEDEF",2777663545:"IFCELEMENTARYSURFACE",339256511:"IFCELEMENTTYPE",1883228015:"IFCELEMENTQUANTITY",1472233963:"IFCEDGELOOP",4006246654:"IFCDRAUGHTINGPREDEFINEDCURVEFONT",445594917:"IFCDRAUGHTINGPREDEFINEDCOLOUR",3073041342:"IFCDRAUGHTINGCALLOUT",526551008:"IFCDOORSTYLE",1714330368:"IFCDOORPANELPROPERTIES",2963535650:"IFCDOORLININGPROPERTIES",32440307:"IFCDIRECTION",4054601972:"IFCDIMENSIONCURVETERMINATOR",606661476:"IFCDIMENSIONCURVE",693772133:"IFCDEFINEDSYMBOL",2827736869:"IFCCURVEBOUNDEDPLANE",2601014836:"IFCCURVE",2147822146:"IFCCSGSOLID",2506170314:"IFCCSGPRIMITIVE3D",194851669:"IFCCRANERAILFSHAPEPROFILEDEF",4133800736:"IFCCRANERAILASHAPEPROFILEDEF",2485617015:"IFCCOMPOSITECURVESEGMENT",2205249479:"IFCCLOSEDSHELL",1383045692:"IFCCIRCLEPROFILEDEF",1416205885:"IFCCARTESIANTRANSFORMATIONOPERATOR3DNONUNIFORM",3331915920:"IFCCARTESIANTRANSFORMATIONOPERATOR3D",3486308946:"IFCCARTESIANTRANSFORMATIONOPERATOR2DNONUNIFORM",3749851601:"IFCCARTESIANTRANSFORMATIONOPERATOR2D",59481748:"IFCCARTESIANTRANSFORMATIONOPERATOR",1123145078:"IFCCARTESIANPOINT",2898889636:"IFCCSHAPEPROFILEDEF",2713105998:"IFCBOXEDHALFSPACE",2581212453:"IFCBOUNDINGBOX",4182860854:"IFCBOUNDEDSURFACE",2736907675:"IFCBOOLEANRESULT",2740243338:"IFCAXIS2PLACEMENT3D",3125803723:"IFCAXIS2PLACEMENT2D",4261334040:"IFCAXIS1PLACEMENT",1302238472:"IFCANNOTATIONSURFACE",2265737646:"IFCANNOTATIONFILLAREAOCCURRENCE",669184980:"IFCANNOTATIONFILLAREA",3288037868:"IFCANNOTATIONCURVEOCCURRENCE",2543172580:"IFCZSHAPEPROFILEDEF",1299126871:"IFCWINDOWSTYLE",512836454:"IFCWINDOWPANELPROPERTIES",336235671:"IFCWINDOWLININGPROPERTIES",2759199220:"IFCVERTEXLOOP",1417489154:"IFCVECTOR",427810014:"IFCUSHAPEPROFILEDEF",2347495698:"IFCTYPEPRODUCT",1628702193:"IFCTYPEOBJECT",1345879162:"IFCTWODIRECTIONREPEATFACTOR",2715220739:"IFCTRAPEZIUMPROFILEDEF",3124975700:"IFCTEXTLITERALWITHEXTENT",4282788508:"IFCTEXTLITERAL",3028897424:"IFCTERMINATORSYMBOL",3071757647:"IFCTSHAPEPROFILEDEF",230924584:"IFCSWEPTSURFACE",1260650574:"IFCSWEPTDISKSOLID",2247615214:"IFCSWEPTAREASOLID",1878645084:"IFCSURFACESTYLERENDERING",2513912981:"IFCSURFACE",2233826070:"IFCSUBEDGE",3653947884:"IFCSTRUCTURALSTEELPROFILEPROPERTIES",3843319758:"IFCSTRUCTURALPROFILEPROPERTIES",1190533807:"IFCSTRUCTURALLOADSINGLEFORCEWARPING",1597423693:"IFCSTRUCTURALLOADSINGLEFORCE",1973038258:"IFCSTRUCTURALLOADSINGLEDISPLACEMENTDISTORTION",2473145415:"IFCSTRUCTURALLOADSINGLEDISPLACEMENT",2668620305:"IFCSTRUCTURALLOADPLANARFORCE",1595516126:"IFCSTRUCTURALLOADLINEARFORCE",390701378:"IFCSPACETHERMALLOADPROPERTIES",1202362311:"IFCSOUNDVALUE",2485662743:"IFCSOUNDPROPERTIES",723233188:"IFCSOLIDMODEL",2609359061:"IFCSLIPPAGECONNECTIONCONDITION",4124623270:"IFCSHELLBASEDSURFACEMODEL",2411513650:"IFCSERVICELIFEFACTOR",1509187699:"IFCSECTIONEDSPINE",2778083089:"IFCROUNDEDRECTANGLEPROFILEDEF",478536968:"IFCRELATIONSHIP",3765753017:"IFCREINFORCEMENTDEFINITIONPROPERTIES",3413951693:"IFCREGULARTIMESERIES",3615266464:"IFCRECTANGLEPROFILEDEF",110355661:"IFCPROPERTYTABLEVALUE",3650150729:"IFCPROPERTYSINGLEVALUE",3357820518:"IFCPROPERTYSETDEFINITION",941946838:"IFCPROPERTYREFERENCEVALUE",2752243245:"IFCPROPERTYLISTVALUE",4166981789:"IFCPROPERTYENUMERATEDVALUE",1680319473:"IFCPROPERTYDEFINITION",871118103:"IFCPROPERTYBOUNDEDVALUE",673634403:"IFCPRODUCTDEFINITIONSHAPE",179317114:"IFCPREDEFINEDPOINTMARKERSYMBOL",433424934:"IFCPREDEFINEDDIMENSIONSYMBOL",2559016684:"IFCPREDEFINEDCURVEFONT",759155922:"IFCPREDEFINEDCOLOUR",2775532180:"IFCPOLYGONALBOUNDEDHALFSPACE",2924175390:"IFCPOLYLOOP",1423911732:"IFCPOINTONSURFACE",4022376103:"IFCPOINTONCURVE",2067069095:"IFCPOINT",1663979128:"IFCPLANAREXTENT",2004835150:"IFCPLACEMENT",597895409:"IFCPIXELTEXTURE",3021840470:"IFCPHYSICALCOMPLEXQUANTITY",2519244187:"IFCPATH",2529465313:"IFCPARAMETERIZEDPROFILEDEF",1029017970:"IFCORIENTEDEDGE",2665983363:"IFCOPENSHELL",2833995503:"IFCONEDIRECTIONREPEATFACTOR",219451334:"IFCOBJECTDEFINITION",1430189142:"IFCMECHANICALCONCRETEMATERIALPROPERTIES",2022407955:"IFCMATERIALDEFINITIONREPRESENTATION",2347385850:"IFCMAPPEDITEM",1008929658:"IFCLOOP",2624227202:"IFCLOCALPLACEMENT",3422422726:"IFCLIGHTSOURCESPOT",1520743889:"IFCLIGHTSOURCEPOSITIONAL",4266656042:"IFCLIGHTSOURCEGONIOMETRIC",2604431987:"IFCLIGHTSOURCEDIRECTIONAL",125510826:"IFCLIGHTSOURCEAMBIENT",1402838566:"IFCLIGHTSOURCE",3741457305:"IFCIRREGULARTIMESERIES",3905492369:"IFCIMAGETEXTURE",2445078500:"IFCHYGROSCOPICMATERIALPROPERTIES",812098782:"IFCHALFSPACESOLID",178086475:"IFCGRIDPLACEMENT",3590301190:"IFCGEOMETRICSET",4142052618:"IFCGEOMETRICREPRESENTATIONSUBCONTEXT",2453401579:"IFCGEOMETRICREPRESENTATIONITEM",3448662350:"IFCGEOMETRICREPRESENTATIONCONTEXT",1446786286:"IFCGENERALPROFILEPROPERTIES",803998398:"IFCGENERALMATERIALPROPERTIES",3857492461:"IFCFUELPROPERTIES",738692330:"IFCFILLAREASTYLE",4219587988:"IFCFAILURECONNECTIONCONDITION",3008276851:"IFCFACESURFACE",803316827:"IFCFACEOUTERBOUND",1809719519:"IFCFACEBOUND",2556980723:"IFCFACE",1860660968:"IFCEXTENDEDMATERIALPROPERTIES",476780140:"IFCEDGECURVE",3900360178:"IFCEDGE",4170525392:"IFCDRAUGHTINGPREDEFINEDTEXTFONT",3732053477:"IFCDOCUMENTREFERENCE",1694125774:"IFCDIMENSIONPAIR",2273265877:"IFCDIMENSIONCALLOUTRELATIONSHIP",3632507154:"IFCDERIVEDPROFILEDEF",3800577675:"IFCCURVESTYLE",2889183280:"IFCCONVERSIONBASEDUNIT",3050246964:"IFCCONTEXTDEPENDENTUNIT",45288368:"IFCCONNECTIONPOINTECCENTRICITY",1981873012:"IFCCONNECTIONCURVEGEOMETRY",370225590:"IFCCONNECTEDFACESET",1485152156:"IFCCOMPOSITEPROFILEDEF",2542286263:"IFCCOMPLEXPROPERTY",776857604:"IFCCOLOURRGB",647927063:"IFCCLASSIFICATIONREFERENCE",3150382593:"IFCCENTERLINEPROFILEDEF",616511568:"IFCBLOBTEXTURE",2705031697:"IFCARBITRARYPROFILEDEFWITHVOIDS",1310608509:"IFCARBITRARYOPENPROFILEDEF",3798115385:"IFCARBITRARYCLOSEDPROFILEDEF",2297822566:"IFCANNOTATIONTEXTOCCURRENCE",3612888222:"IFCANNOTATIONSYMBOLOCCURRENCE",962685235:"IFCANNOTATIONSURFACEOCCURRENCE",2442683028:"IFCANNOTATIONOCCURRENCE",1065908215:"IFCWATERPROPERTIES",891718957:"IFCVIRTUALGRIDINTERSECTION",1907098498:"IFCVERTEXPOINT",3304826586:"IFCVERTEXBASEDTEXTUREMAP",2799835756:"IFCVERTEX",180925521:"IFCUNITASSIGNMENT",1735638870:"IFCTOPOLOGYREPRESENTATION",1377556343:"IFCTOPOLOGICALREPRESENTATIONITEM",581633288:"IFCTIMESERIESVALUE",1718945513:"IFCTIMESERIESREFERENCERELATIONSHIP",3101149627:"IFCTIMESERIES",3317419933:"IFCTHERMALMATERIALPROPERTIES",1210645708:"IFCTEXTUREVERTEX",2552916305:"IFCTEXTUREMAP",1742049831:"IFCTEXTURECOORDINATEGENERATOR",280115917:"IFCTEXTURECOORDINATE",1484833681:"IFCTEXTSTYLEWITHBOXCHARACTERISTICS",1640371178:"IFCTEXTSTYLETEXTMODEL",2636378356:"IFCTEXTSTYLEFORDEFINEDFONT",1983826977:"IFCTEXTSTYLEFONTMODEL",1447204868:"IFCTEXTSTYLE",912023232:"IFCTELECOMADDRESS",531007025:"IFCTABLEROW",985171141:"IFCTABLE",1290481447:"IFCSYMBOLSTYLE",626085974:"IFCSURFACETEXTURE",1351298697:"IFCSURFACESTYLEWITHTEXTURES",846575682:"IFCSURFACESTYLESHADING",1607154358:"IFCSURFACESTYLEREFRACTION",3303107099:"IFCSURFACESTYLELIGHTING",1300840506:"IFCSURFACESTYLE",3049322572:"IFCSTYLEDREPRESENTATION",3958052878:"IFCSTYLEDITEM",2830218821:"IFCSTYLEMODEL",3408363356:"IFCSTRUCTURALLOADTEMPERATURE",2525727697:"IFCSTRUCTURALLOADSTATIC",2162789131:"IFCSTRUCTURALLOAD",2273995522:"IFCSTRUCTURALCONNECTIONCONDITION",3692461612:"IFCSIMPLEPROPERTY",4240577450:"IFCSHAPEREPRESENTATION",3982875396:"IFCSHAPEMODEL",867548509:"IFCSHAPEASPECT",4165799628:"IFCSECTIONREINFORCEMENTPROPERTIES",2042790032:"IFCSECTIONPROPERTIES",448429030:"IFCSIUNIT",2341007311:"IFCROOT",3679540991:"IFCRIBPLATEPROFILEPROPERTIES",1660063152:"IFCREPRESENTATIONMAP",3008791417:"IFCREPRESENTATIONITEM",3377609919:"IFCREPRESENTATIONCONTEXT",1076942058:"IFCREPRESENTATION",1222501353:"IFCRELAXATION",1580146022:"IFCREINFORCEMENTBARPROPERTIES",2692823254:"IFCREFERENCESVALUEDOCUMENT",825690147:"IFCQUANTITYWEIGHT",2405470396:"IFCQUANTITYVOLUME",3252649465:"IFCQUANTITYTIME",931644368:"IFCQUANTITYLENGTH",2093928680:"IFCQUANTITYCOUNT",2044713172:"IFCQUANTITYAREA",3710013099:"IFCPROPERTYENUMERATION",148025276:"IFCPROPERTYDEPENDENCYRELATIONSHIP",3896028662:"IFCPROPERTYCONSTRAINTRELATIONSHIP",2598011224:"IFCPROPERTY",2802850158:"IFCPROFILEPROPERTIES",3958567839:"IFCPROFILEDEF",2267347899:"IFCPRODUCTSOFCOMBUSTIONPROPERTIES",2095639259:"IFCPRODUCTREPRESENTATION",2417041796:"IFCPRESENTATIONSTYLEASSIGNMENT",3119450353:"IFCPRESENTATIONSTYLE",1304840413:"IFCPRESENTATIONLAYERWITHSTYLE",2022622350:"IFCPRESENTATIONLAYERASSIGNMENT",1775413392:"IFCPREDEFINEDTEXTFONT",3213052703:"IFCPREDEFINEDTERMINATORSYMBOL",990879717:"IFCPREDEFINEDSYMBOL",3727388367:"IFCPREDEFINEDITEM",3355820592:"IFCPOSTALADDRESS",2226359599:"IFCPHYSICALSIMPLEQUANTITY",2483315170:"IFCPHYSICALQUANTITY",101040310:"IFCPERSONANDORGANIZATION",2077209135:"IFCPERSON",1207048766:"IFCOWNERHISTORY",1411181986:"IFCORGANIZATIONRELATIONSHIP",4251960020:"IFCORGANIZATION",1227763645:"IFCOPTICALMATERIALPROPERTIES",2251480897:"IFCOBJECTIVE",3701648758:"IFCOBJECTPLACEMENT",1918398963:"IFCNAMEDUNIT",2706619895:"IFCMONETARYUNIT",3368373690:"IFCMETRIC",677618848:"IFCMECHANICALSTEELMATERIALPROPERTIES",4256014907:"IFCMECHANICALMATERIALPROPERTIES",2597039031:"IFCMEASUREWITHUNIT",3265635763:"IFCMATERIALPROPERTIES",2199411900:"IFCMATERIALLIST",1303795690:"IFCMATERIALLAYERSETUSAGE",3303938423:"IFCMATERIALLAYERSET",248100487:"IFCMATERIALLAYER",1847130766:"IFCMATERIALCLASSIFICATIONRELATIONSHIP",1838606355:"IFCMATERIAL",30780891:"IFCLOCALTIME",1566485204:"IFCLIGHTINTENSITYDISTRIBUTION",4162380809:"IFCLIGHTDISTRIBUTIONDATA",3452421091:"IFCLIBRARYREFERENCE",2655187982:"IFCLIBRARYINFORMATION",3020489413:"IFCIRREGULARTIMESERIESVALUE",852622518:"IFCGRIDAXIS",3548104201:"IFCEXTERNALLYDEFINEDTEXTFONT",3207319532:"IFCEXTERNALLYDEFINEDSYMBOL",1040185647:"IFCEXTERNALLYDEFINEDSURFACESTYLE",2242383968:"IFCEXTERNALLYDEFINEDHATCHSTYLE",3200245327:"IFCEXTERNALREFERENCE",1648886627:"IFCENVIRONMENTALIMPACTVALUE",3796139169:"IFCDRAUGHTINGCALLOUTRELATIONSHIP",770865208:"IFCDOCUMENTINFORMATIONRELATIONSHIP",1154170062:"IFCDOCUMENTINFORMATION",1376555844:"IFCDOCUMENTELECTRONICFORMAT",2949456006:"IFCDIMENSIONALEXPONENTS",1045800335:"IFCDERIVEDUNITELEMENT",1765591967:"IFCDERIVEDUNIT",1072939445:"IFCDATEANDTIME",3510044353:"IFCCURVESTYLEFONTPATTERN",2367409068:"IFCCURVESTYLEFONTANDSCALING",1105321065:"IFCCURVESTYLEFONT",539742890:"IFCCURRENCYRELATIONSHIP",602808272:"IFCCOSTVALUE",1065062679:"IFCCOORDINATEDUNIVERSALTIMEOFFSET",347226245:"IFCCONSTRAINTRELATIONSHIP",613356794:"IFCCONSTRAINTCLASSIFICATIONRELATIONSHIP",1658513725:"IFCCONSTRAINTAGGREGATIONRELATIONSHIP",1959218052:"IFCCONSTRAINT",2732653382:"IFCCONNECTIONSURFACEGEOMETRY",4257277454:"IFCCONNECTIONPORTGEOMETRY",2614616156:"IFCCONNECTIONPOINTGEOMETRY",2859738748:"IFCCONNECTIONGEOMETRY",3264961684:"IFCCOLOURSPECIFICATION",3639012971:"IFCCLASSIFICATIONNOTATIONFACET",938368621:"IFCCLASSIFICATIONNOTATION",1098599126:"IFCCLASSIFICATIONITEMRELATIONSHIP",1767535486:"IFCCLASSIFICATIONITEM",747523909:"IFCCLASSIFICATION",622194075:"IFCCALENDARDATE",2069777674:"IFCBOUNDARYNODECONDITIONWARPING",1387855156:"IFCBOUNDARYNODECONDITION",3367102660:"IFCBOUNDARYFACECONDITION",1560379544:"IFCBOUNDARYEDGECONDITION",4037036970:"IFCBOUNDARYCONDITION",3869604511:"IFCAPPROVALRELATIONSHIP",390851274:"IFCAPPROVALPROPERTYRELATIONSHIP",2080292479:"IFCAPPROVALACTORRELATIONSHIP",130549933:"IFCAPPROVAL",1110488051:"IFCAPPLIEDVALUERELATIONSHIP",411424972:"IFCAPPLIEDVALUE",639542469:"IFCAPPLICATION",618182010:"IFCADDRESS",3630933823:"IFCACTORROLE",599546466:"FILE_DESCRIPTION",1390159747:"FILE_NAME",1109904537:"FILE_SCHEMA"};class xt{static async getUnits(s){var n,r,a;const{IFCUNITASSIGNMENT:t}=x,e=await s.getAllPropertiesOfType(t);if(!e)return 1;const i=Object.keys(e),o=e[parseInt(i[0],10)];for(const c of o.Units){if(c.value===void 0||c.value===null)continue;const h=await s.getProperties(c.value);if(!h||!h.UnitType||!h.UnitType.value||h.UnitType.value!=="LENGTHUNIT")continue;let d=1,I=1;return h.Name.value==="METRE"&&(I=1),h.Name.value==="FOOT"&&(I=.3048),((n=h.Prefix)==null?void 0:n.value)==="MILLI"?d=.001:((r=h.Prefix)==null?void 0:r.value)==="CENTI"?d=.01:((a=h.Prefix)==null?void 0:a.value)==="DECI"&&(d=.1),I*d}return 1}static async findItemByGuid(s,t){var i;const e=s.getAllPropertiesIDs();for(const o of e){const n=await s.getProperties(o);if(n&&((i=n.GlobalId)==null?void 0:i.value)===t)return n}return null}static async getRelationMap(s,t,e){var a;const o=e??(async()=>{}),n={},r=s.getAllPropertiesIDs();for(const c of r){const h=await s.getProperties(c);if(!h)continue;const E=h.type===t,d=Object.keys(h).find(m=>m.startsWith("Relating")),I=Object.keys(h).find(m=>m.startsWith("Related"));if(!(E&&d&&I))continue;const f=await s.getProperties((a=h[d])==null?void 0:a.value),T=h[I];if(!f||!T||!(T&&Array.isArray(T)))continue;const F=T.map(m=>m.value);await o(f.expressID,F),n[f.expressID]=F}return n}static async getQsetQuantities(s,t,e){const o=e??(()=>{}),n=await s.getProperties(t);return!n||n.type!==x.IFCELEMENTQUANTITY?null:(n.Quantities??[{}]).map(c=>(c.value&&o(c.value),c.value)).filter(c=>c!==null)}static async getPsetProps(s,t,e){const o=e??(()=>{}),n=await s.getProperties(t);return!n||n.type!==x.IFCPROPERTYSET?null:(n.HasProperties??[{}]).map(c=>(c.value&&o(c.value),c.value)).filter(c=>c!==null)}static async getPsetRel(s,t){var r;if(!await s.getProperties(t))return null;const i=await s.getAllPropertiesOfType(x.IFCRELDEFINESBYPROPERTIES);if(!i)return null;const o=Object.values(i);let n=null;for(const a of o)((r=a.RelatingPropertyDefinition)==null?void 0:r.value)===t&&(n=a.expressID);return n}static async getQsetRel(s,t){return xt.getPsetRel(s,t)}static async getEntityName(s,t){var n;const e=await s.getProperties(t);if(!e)return{key:null,name:null};const i=Object.keys(e).find(r=>r.endsWith("Name"))??null,o=i?(n=e[i])==null?void 0:n.value:null;return{key:i,name:o}}static async getQuantityValue(s,t){const e=await s.getProperties(t);if(!e)return{key:null,value:null};const i=Object.keys(e).find(n=>n.endsWith("Value"))??null;let o;return i===null||e[i]===void 0||e[i]===null?o=null:o=e[i].value,{key:i,value:o}}static isRel(s){return Pi[s].startsWith("IFCREL")}static async attributeExists(s,t,e){const i=await s.getProperties(t);return i?Object.keys(i).includes(e):!1}static async groupEntitiesByType(s,t){var i;const e=new Map;for(const o of t){const n=await s.getProperties(o);if(!n)continue;const r=n.type;e.get(r)||e.set(r,new Set),(i=e.get(r))==null||i.add(o)}return e}}class Ur{constructor(){u(this,"factor",1);u(this,"complement",1)}apply(s){const e=this.getScaleMatrix().multiply(s);s.copy(e)}setUp(s){var o,n,r;this.factor=1;const t=this.getLengthUnits(s);if(!t)return;const e=t==null,i=t.Name===void 0||t.Name===null;e||i||(t.Name.value==="FOOT"&&(this.factor=.3048),((o=t.Prefix)==null?void 0:o.value)==="MILLI"?this.complement=.001:((n=t.Prefix)==null?void 0:n.value)==="CENTI"?this.complement=.01:((r=t.Prefix)==null?void 0:r.value)==="DECI"&&(this.complement=.01))}getLengthUnits(s){try{const e=s.GetLineIDsWithType(0,x.IFCUNITASSIGNMENT).get(0),i=s.GetLine(0,e);for(const o of i.Units){if(!o||o.value===null||o.value===void 0)continue;const n=s.GetLine(0,o.value);if(n.UnitType&&n.UnitType.value==="LENGTHUNIT")return n}return null}catch{return console.log("Could not get units"),null}}getScaleMatrix(){const s=this.factor;return new g.Matrix4().fromArray([s,0,0,0,0,s,0,0,0,0,s,0,0,0,0,1])}}class Gn{constructor(){u(this,"itemsByFloor",{});u(this,"_units",new Ur)}setUp(s){this._units.setUp(s),this.cleanUp();try{const t=s.GetLineIDsWithType(0,x.IFCRELCONTAINEDINSPATIALSTRUCTURE),e=new Set,i=s.GetLineIDsWithType(0,x.IFCSPACE);for(let c=0;c<i.size();c++)e.add(i.get(c));const o=s.GetLineIDsWithType(0,x.IFCRELAGGREGATES),n=o.size();for(let c=0;c<n;c++){const h=o.get(c),E=s.GetLine(0,h);if(!E||!E.RelatingObject||!E.RelatedObjects)continue;const d=E.RelatingObject.value,I=E.RelatedObjects;for(const f of I){const T=f.value;e.has(T)&&(this.itemsByFloor[T]=d)}}const r={},a=t.size();for(let c=0;c<a;c++){const h=t.get(c),E=s.GetLine(0,h);if(!E||!E.RelatingStructure||!E.RelatedElements)continue;const d=E.RelatingStructure.value,I=E.RelatedElements;if(e.has(d))for(const f of I){r[d]||(r[d]=[]);const T=f.value;r[d].push(T)}else for(const f of I){const T=f.value;this.itemsByFloor[T]=d}}for(const c in r){const h=this.itemsByFloor[c];if(h!==void 0){const E=r[c];for(const d of E)this.itemsByFloor[d]=h}}for(let c=0;c<n;c++){const h=o.get(c),E=s.GetLine(0,h);if(!E||!E.RelatingObject||!E.RelatedObjects)continue;const d=E.RelatingObject.value,I=E.RelatedObjects;for(const f of I){const T=f.value,F=this.itemsByFloor[d];F!==void 0&&(this.itemsByFloor[T]=F)}}}catch{console.log("Could not get floors.")}}cleanUp(){this.itemsByFloor={}}}class Ds{constructor(){u(this,"includeProperties",!0);u(this,"optionalCategories",[x.IFCSPACE]);u(this,"coordinate",!0);u(this,"wasm",{path:"",absolute:!1,logLevel:x.LogLevel.LOG_LEVEL_OFF});u(this,"excludedCategories",new Set);u(this,"includedCategories",new Set);u(this,"saveLocations",!1);u(this,"webIfc",{COORDINATE_TO_ORIGIN:!0});u(this,"autoSetWasm",!0);u(this,"customLocateFileHandler",null)}}class zn{constructor(){u(this,"defLineMat",new g.LineBasicMaterial({color:16777215}))}read(s){const t=s.GetAllAlignments(0),e=s.GetAllCrossSections2D(0),i=s.GetAllCrossSections3D(0),o={IfcAlignment:t,IfcCrossSection2D:e,IfcCrossSection3D:i};return this.get(o)}get(s){if(s.IfcAlignment){const t=new Map;for(const e of s.IfcAlignment){const i=new Dt.Alignment;i.absolute=this.getCurves(e.curve3D,i),i.horizontal=this.getCurves(e.horizontal,i),i.vertical=this.getCurves(e.vertical,i),t.set(t.size,i)}return{alignments:t,coordinationMatrix:new g.Matrix4}}}getCurves(s,t){const e=[];let i=0;for(const o of s){const n={};if(o.data)for(const d of o.data){const[I,f]=d.split(": "),T=parseFloat(f);n[I]=T||f}const{points:r}=o,a=new Float32Array(r.length*3);for(let d=0;d<r.length;d++){const{x:I,y:f,z:T}=r[d];a[d*3]=I,a[d*3+1]=f,a[d*3+2]=T||0}const c=new g.BufferAttribute(a,3),h=new g.EdgesGeometry;h.setAttribute("position",c);const E=new Dt.CurveMesh(i,n,t,h,this.defLineMat);e.push(E.curve),i++}return e}}class Hn{getNameInfo(s){var E;const t={},{arguments:e}=s.GetHeaderLine(0,x.FILE_NAME)||{};if(!e)return t;const[i,o,n,r,a,c,h]=e;if(i!=null&&i.value&&(t.name=i.value),o!=null&&o.value&&(t.creationDate=new Date(o.value)),n){t.author={};const[d,I]=n;d!=null&&d.value&&(t.author.name=d.value),I!=null&&I.value&&(t.author.email=I.value)}return(E=r[0])!=null&&E.value&&(t.organization=r[0].value),a!=null&&a.value&&(t.preprocessorVersion=a==null?void 0:a.value),c!=null&&c.value&&(t.originatingSystem=c==null?void 0:c.value),h!=null&&h.value&&(t.authorization=h==null?void 0:h.value),t}getDescriptionInfo(s){var n;const t={},{arguments:e}=s.GetHeaderLine(0,x.FILE_DESCRIPTION)||{};if(!e)return t;const[i,o]=e;if((n=i[0])!=null&&n.value){const r=i[0].value.match(/\[([^\]]+)\]/);r&&r[1]&&(t.viewDefinition=r[1])}return o!=null&&o.value&&(t.implementationLevel=o.value),t}}class Wn{static get(s,t){const e=[x.IFCPROJECT,x.IFCSITE,x.IFCBUILDING,x.IFCBUILDINGSTOREY,x.IFCSPACE,x.IFCROAD,x.IFCFACILITY,x.IFCFACILITYPART,x.IFCBRIDGE],i=s.data;for(const o of e){const n=t.GetLineIDsWithType(0,o),r=n.size();for(let a=0;a<r;a++){const c=n.get(a);i.has(c)||i.set(c,[[],[0,o]])}}}}const xe=class xe extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"onIfcStartedLoading",new M);u(this,"onSetup",new M);u(this,"settings",new Ds);u(this,"webIfc",new x.IfcAPI);u(this,"enabled",!0);u(this,"_material",new g.MeshLambertMaterial);u(this,"_spatialTree",new Gn);u(this,"_metaData",new Hn);u(this,"_fragmentInstances",new Map);u(this,"_civil",new zn);u(this,"_visitedFragments",new Map);u(this,"_materialT",new g.MeshLambertMaterial({transparent:!0,opacity:.5}));this.components.add(xe.uuid,this),this.settings.excludedCategories.add(x.IFCOPENINGELEMENT)}dispose(){try{this.webIfc.Dispose()}catch{}this.webIfc=null,this.onDisposed.trigger(xe.uuid),this.onDisposed.reset()}async setup(t){this.settings={...this.settings,...t},this.settings.autoSetWasm&&await this.autoSetWasm(),this.onSetup.trigger()}async load(t,e=!0){const i=performance.now();this.onIfcStartedLoading.trigger(),await this.readIfcFile(t);const o=await this.getAllGeometries(),r=await this.components.get(us).export(this.webIfc,0);o.setLocalProperties(r);const a=this.components.get(ot);a.groups.set(o.uuid,o);for(const c of o.items)a.list.set(c.id,c),c.mesh.uuid=c.id,c.group=o;a.onFragmentsLoaded.trigger(o),e&&a.coordinate([o]);for(const[c]of o.data){const h=r[c];if(!h||!h.GlobalId)continue;const E=h.GlobalId.value||h.GlobalId;o.globalToExpressIDs.set(E,c)}return Wn.get(o,this.webIfc),this.cleanUp(),console.log(`Streaming the IFC took ${performance.now()-i} ms!`),o}async readIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;return this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(this.settings.customLocateFileHandler||void 0),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModel(t,this.settings.webIfc)}cleanUp(){try{this.webIfc.Dispose()}catch{}this.webIfc=null,this.webIfc=new x.IfcAPI,this._visitedFragments.clear(),this._fragmentInstances.clear()}async getAllGeometries(){this._spatialTree.setUp(this.webIfc);const t=this.webIfc.GetIfcEntityList(0),e=new Dt.FragmentsGroup;e.ifcMetadata={name:"",description:"",...this._metaData.getNameInfo(this.webIfc),...this._metaData.getDescriptionInfo(this.webIfc),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};const i=[];for(const n of t){if(!this.webIfc.IsIfcElement(n)&&n!==x.IFCSPACE)continue;const r=this.settings.includedCategories;if(r.size>0&&!r.has(n))continue;if(this.settings.excludedCategories.has(n))continue;const a=this.webIfc.GetLineIDsWithType(0,n),c=a.size();for(let h=0;h<c;h++){const E=a.get(h);i.push(E);const d=this._spatialTree.itemsByFloor[E]||0;e.data.set(E,[[],[d,n]])}}this._spatialTree.cleanUp(),this.webIfc.StreamMeshes(0,i,n=>{this.getMesh(n,e)});for(const n of this._visitedFragments){const{index:r,fragment:a}=n[1];e.keyFragments.set(r,a.id)}for(const n of e.items){const r=this._fragmentInstances.get(n.id);if(!r)throw new Error("Fragment not found!");const a=[];for(const[c,h]of r)a.push(h);n.add(a)}const o=this.webIfc.GetCoordinationMatrix(0);return e.coordinationMatrix.fromArray(o),e.civilData=this._civil.read(this.webIfc),e}getMesh(t,e){const i=t.geometries.size(),o=t.expressID;for(let n=0;n<i;n++){const r=t.geometries.get(n),{x:a,y:c,z:h,w:E}=r.color,d=E!==1,{geometryExpressID:I}=r,f=`${I}-${d}`;if(!this._visitedFragments.has(f)){const R=this.getGeometry(this.webIfc,I),S=d?this._materialT:this._material,_=new Dt.Fragment(R,S,1);e.add(_.mesh),e.items.push(_);const y=this._visitedFragments.size;this._visitedFragments.set(f,{index:y,fragment:_})}const T=new g.Color().setRGB(a,c,h,"srgb"),F=new g.Matrix4;F.fromArray(r.flatTransformation);const m=this._visitedFragments.get(f);if(m===void 0)throw new Error("Error getting geometry data for streaming!");const A=e.data.get(o);if(!A)throw new Error("Data not found!");A[0].push(m.index);const{fragment:O}=m;this._fragmentInstances.has(O.id)||this._fragmentInstances.set(O.id,new Map);const p=this._fragmentInstances.get(O.id);if(!p)throw new Error("Instances not found!");if(p.has(o)){const R=p.get(o);if(!R)throw new Error("Instance not found!");R.transforms.push(F),R.colors&&R.colors.push(T)}else p.set(o,{id:o,transforms:[F],colors:[T]})}}getGeometry(t,e){const i=t.GetGeometry(0,e),o=t.GetIndexArray(i.GetIndexData(),i.GetIndexDataSize()),n=t.GetVertexArray(i.GetVertexData(),i.GetVertexDataSize()),r=new Float32Array(n.length/2),a=new Float32Array(n.length/2);for(let d=0;d<n.length;d+=6)r[d/2]=n[d],r[d/2+1]=n[d+1],r[d/2+2]=n[d+2],a[d/2]=n[d+3],a[d/2+1]=n[d+4],a[d/2+2]=n[d+5];const c=new g.BufferGeometry,h=new g.BufferAttribute(r,3),E=new g.BufferAttribute(a,3);return c.setAttribute("position",h),c.setAttribute("normal",E),c.setIndex(Array.from(o)),i.delete(),c}async autoSetWasm(){const t=await fetch(`https://unpkg.com/@thatopen/components@${hs.release}/package.json`);if(!t.ok){console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");return}const e=await t.json();if(!("web-ifc"in e.peerDependencies))console.warn("Couldn't get web-ifc from peer dependencies in openbim-components. Set wasm settings manually.");else{const i=e.peerDependencies["web-ifc"];this.settings.wasm.path=`https://unpkg.com/web-ifc@${i}/`,this.settings.wasm.absolute=!0}}};u(xe,"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");let Is=xe;const wt=class wt extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"onRequestFile",new M);u(this,"ifcToExport",null);u(this,"onElementToPset",new M);u(this,"onPropToPset",new M);u(this,"onPsetRemoved",new M);u(this,"onDataChanged",new M);u(this,"wasm",{path:"/",absolute:!1});u(this,"enabled",!0);u(this,"attributeListeners",{});u(this,"selectedModel");u(this,"changeMap",{});this.components.add(wt.uuid,this)}dispose(){this.selectedModel=void 0,this.attributeListeners={},this.changeMap={},this.onElementToPset.reset(),this.onPropToPset.reset(),this.onPsetRemoved.reset(),this.onDataChanged.reset(),this.onDisposed.trigger(wt.uuid),this.onDisposed.reset()}static getIFCSchema(t){const e=t.ifcMetadata.schema;if(!e)throw new Error("IFC Schema not found");return e.startsWith("IFC2X3")?"IFC2X3":e.startsWith("IFC4")&&e.replace("IFC4","")===""?"IFC4":e.startsWith("IFC4X3")?"IFC4X3":e}async setData(t,...e){for(const i of e){const o=i.expressID;o&&(await t.setProperties(o,i),this.registerChange(t,o))}}async newPset(t,e,i){const o=wt.getIFCSchema(t),{ownerHistoryHandle:n}=await this.getOwnerHistory(t),r=this.newGUID(t),a=new x[o].IfcLabel(e),c=i?new x[o].IfcText(i):null,h=new x[o].IfcPropertySet(r,n,a,c,[]);h.expressID=this.increaseMaxID(t);const E=this.newGUID(t),d=new x[o].IfcRelDefinesByProperties(E,n,null,null,[],new x.Handle(h.expressID));return d.expressID=this.increaseMaxID(t),await this.setData(t,h,d),{pset:h,rel:d}}async removePset(t,...e){for(const i of e){const o=await t.getProperties(i);if((o==null?void 0:o.type)!==x.IFCPROPERTYSET)continue;const n=await xt.getPsetRel(t,i);if(n&&(await t.setProperties(n,null),this.registerChange(t,n)),o){for(const r of o.HasProperties)await t.setProperties(r.value,null);await t.setProperties(i,null),this.onPsetRemoved.trigger({model:t,psetID:i}),this.registerChange(t,i)}}}newSingleStringProperty(t,e,i,o){return this.newSingleProperty(t,e,i,o)}newSingleNumericProperty(t,e,i,o){return this.newSingleProperty(t,e,i,o)}newSingleBooleanProperty(t,e,i,o){return this.newSingleProperty(t,e,i,o)}async removePsetProp(t,e,i){const o=await t.getProperties(e),n=await t.getProperties(i);!o||!n||o.type===x.IFCPROPERTYSET&&n&&(o.HasProperties=o.HasProperties.filter(r=>r.value!==i),await t.setProperties(i,null),this.registerChange(t,e,i))}async addElementToPset(t,e,...i){const o=await xt.getPsetRel(t,e);if(!o)return;const n=await t.getProperties(o);if(!n)return;for(const a of i){const c=new x.Handle(a);n.RelatedObjects.push(c),this.onElementToPset.trigger({model:t,psetID:e,elementID:a})}this.registerChange(t,e);const r=this.components.get(Wt);for(const a of i)r.addEntityRelations(t,a,"IsDefinedBy",e)}async addPropToPset(t,e,...i){const o=await t.getProperties(e);if(o){for(const n of i){if(o.HasProperties.includes(n))continue;const r=new x.Handle(n);o.HasProperties.push(r),this.onPropToPset.trigger({model:t,psetID:e,propID:n})}this.registerChange(t,e)}}async saveToIfc(t,e){const i=this.components.get(Is),o=i.webIfc,n=await i.readIfcFile(e),r=this.changeMap[t.uuid]??[];for(const c of r){const h=await t.getProperties(c);if(h)try{o.WriteLine(n,h)}catch{}else try{o.DeleteLine(n,c)}catch{}}const a=o.SaveModel(n);return i.webIfc.CloseModel(n),i.cleanUp(),a}async setAttributeListener(t,e,i){this.attributeListeners[t.uuid]||(this.attributeListeners[t.uuid]={});const o=this.attributeListeners[t.uuid][e]?this.attributeListeners[t.uuid][e][i]:null;if(o)return o;const n=await t.getProperties(e);if(!n)throw new Error(`Entity with expressID ${e} doesn't exists.`);const r=n[i];if(Array.isArray(r)||!r)throw new Error(`Attribute ${i} is array or null, and it can't have a listener.`);const a=r.value;if(a===void 0||a==null)throw new Error(`Attribute ${i} has a badly defined handle.`);const c=new M;return Object.defineProperty(n[i],"value",{get(){return this._value},async set(h){this._value=h,c.trigger(h)}}),n[i].value=a,this.attributeListeners[t.uuid][e]||(this.attributeListeners[t.uuid][e]={}),this.attributeListeners[t.uuid][e][i]=c,c}increaseMaxID(t){return t.ifcMetadata.maxExpressID++,t.ifcMetadata.maxExpressID}newGUID(t){const e=wt.getIFCSchema(t);return new x[e].IfcGloballyUniqueId(ae.create())}async getOwnerHistory(t){const e=await t.getAllPropertiesOfType(x.IFCOWNERHISTORY);if(!e)throw new Error("No OwnerHistory was found.");const i=Object.keys(e).map(r=>parseInt(r,10)),o=e[i[0]],n=new x.Handle(o.expressID);return{ownerHistory:o,ownerHistoryHandle:n}}registerChange(t,...e){this.changeMap[t.uuid]||(this.changeMap[t.uuid]=new Set);for(const i of e)this.changeMap[t.uuid].add(i),this.onDataChanged.trigger({model:t,expressID:i})}async newSingleProperty(t,e,i,o){const n=wt.getIFCSchema(t),r=new x[n].IfcIdentifier(i),a=new x[n][e](o),c=new x[n].IfcPropertySingleValue(r,null,a,null);return c.expressID=this.increaseMaxID(t),await this.setData(t,c),c}};u(wt,"uuid","58c2d9f0-183c-48d6-a402-dfcf5b9a34df");let mi=wt;const gs=class gs extends ${constructor(t){super(t);u(this,"enabled",!0);u(this,"list",{});u(this,"onDisposed",new M);u(this,"onFragmentsDisposed",t=>{const{groupID:e,fragmentIDs:i}=t;for(const o in this.list){const n=this.list[o],r=Object.keys(n);if(r.includes(e))delete n[e],Object.values(n).length===0&&delete this.list[o];else for(const a of r){const c=n[a];for(const h of i)delete c.map[h];Object.values(c).length===0&&delete n[a]}}});t.add(gs.uuid,this),t.get(ot).onFragmentsDisposed.add(this.onFragmentsDisposed)}dispose(){this.list={},this.components.get(ot).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(),this.onDisposed.reset()}remove(t){for(const e in this.list){const i=this.list[e];for(const o in i){const n=i[o];delete n.map[t]}}}find(t){const e=this.components.get(ot);if(!t){const r={};for(const[a,c]of e.list)r[a]=new Set(c.ids);return r}const i=Object.keys(t).length,o={};for(const r in t){const a=t[r];if(!this.list[r]){console.warn(`Classification ${r} does not exist.`);continue}for(const c of a){const h=this.list[r][c];if(h)for(const E in h.map){o[E]||(o[E]=new Map);for(const d of h.map[E]){const I=o[E].get(d);I===void 0?o[E].set(d,1):o[E].set(d,I+1)}}}}const n={};for(const r in o){const a=o[r];for(const[c,h]of a){if(h===void 0)throw new Error("Malformed fragments map!");h===i&&(n[r]||(n[r]=new Set),n[r].add(c))}}return n}byModel(t,e){this.list.models||(this.list.models={});const i=this.list.models;i[t]||(i[t]={map:{},id:null,name:t});const o=i[t];for(const[n,r]of e.data){const a=r[0];for(const c of a){const h=e.keyFragments.get(c);h&&(o.map[h]||(o.map[h]=new Set),o.map[h].add(n))}}}async byPredefinedType(t){var o;this.list.predefinedTypes||(this.list.predefinedTypes={});const e=this.list.predefinedTypes,i=t.getAllPropertiesIDs();for(const n of i){const r=await t.getProperties(n);if(!r)continue;const a=String((o=r.PredefinedType)==null?void 0:o.value).toUpperCase();e[a]||(e[a]={map:{},id:null,name:a});const c=e[a];for(const[h,E]of t.data){const d=E[0];for(const I of d){const f=t.keyFragments.get(I);if(!f)throw new Error("Fragment ID not found!");c.map[f]||(c.map[f]=new Set),c.map[f].add(r.expressID)}}}}byEntity(t){this.list.entities||(this.list.entities={});for(const[e,i]of t.data){const n=i[1][1],r=Pi[n];this.saveItem(t,"entities",r,e)}}async byIfcRel(t,e,i){xt.isRel(e)&&await xt.getRelationMap(t,e,async(o,n)=>{const{name:r}=await xt.getEntityName(t,o);for(const a of n)this.saveItem(t,i,r??"NO REL NAME",a)})}async bySpatialStructure(t,e={}){var c,h;const i=this.components.get(Wt),o=i.relationMaps[t.uuid];if(!o)throw new Error(`Classifier: model relations of ${t.name||t.uuid} have to exists to group by spatial structure.`);const n="spatialStructures",a=e.useProperties===void 0||e.useProperties;for(const[E]of o){if(e.isolate){const T=t.data.get(E);if(!T)continue;const F=T[1][1];if(F===void 0||!e.isolate.has(F))continue}const d=i.getEntityRelations(t,E,"Decomposes");if(d)for(const T of d){let F=T.toString();if(a){const m=await t.getProperties(T);if(!m)continue;F=(c=m.Name)==null?void 0:c.value}this.saveItem(t,n,F,E,T)}const I=i.getEntityRelations(t,E,"ContainsElements");if(!I)continue;let f=E.toString();if(a){const T=await t.getProperties(E);if(!T)continue;f=(h=T.Name)==null?void 0:h.value}for(const T of I){this.saveItem(t,n,f,T,E);const F=i.getEntityRelations(t,Number(T),"IsDecomposedBy");if(F)for(const m of F)this.saveItem(t,n,f,m,E)}}}setColor(t,e,i=!1){const o=this.components.get(ot);for(const n in t){const r=o.list.get(n);if(!r)continue;const a=t[n];r.setColor(e,a,i)}}resetColor(t){const e=this.components.get(ot);for(const i in t){const o=e.list.get(i);if(!o)continue;const n=t[i];o.resetColor(n)}}saveItem(t,e,i,o,n=null){this.list[e]||(this.list[e]={});const r=t.data.get(o);if(r)for(const a of r[0]){const c=t.keyFragments.get(a);if(c){const h=this.list[e];h[i]||(h[i]={map:{},id:n,name:i}),h[i].map[c]||(h[i].map[c]=new Set),h[i].map[c].add(o)}}}};u(gs,"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");let fs=gs;const Os=class Os extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"enabled",!0);u(this,"height",10);u(this,"groupName","spatialStructures");u(this,"list",new Set);t.add(Os.uuid,this)}dispose(){this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}set(t){if(!this.enabled)return;const e=this.components.get(fs),i=this.components.get(ot),o=t?1:-1;let n=0;const r=e.list[this.groupName],a=new g.Matrix4;for(const c in r){a.elements[13]=n*o*this.height;for(const h in r[c].map){const E=i.list.get(h),d=c+h,I=this.list.has(d);if(!E||t&&I||!t&&!I)continue;t?this.list.add(d):this.list.delete(d);const f=r[c].map[h];E.applyTransform(f,a),E.mesh.computeBoundingSphere(),E.mesh.computeBoundingBox()}n++}}};u(Os,"uuid","d260618b-ce88-4c7d-826c-6debb91de3e2");let Ri=Os;const Ss=class Ss extends ${constructor(t){super(t);u(this,"enabled",!0);this.components.add(Ss.uuid,this)}set(t,e){const i=this.components.get(ot);if(!e){for(const[o,n]of i.list)n&&(n.setVisibility(t),this.updateCulledVisibility(n));return}for(const o in e){const n=e[o],r=i.list.get(o);r&&(r.setVisibility(t,n),this.updateCulledVisibility(r))}}isolate(t){this.set(!1),this.set(!0,t)}updateCulledVisibility(t){const e=this.components.get(Es);for(const[i,o]of e.list){const n=o.colorMeshes.get(t.id);n&&(n.count=t.mesh.count)}}};u(Ss,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let Fi=Ss;class kn extends Ds{constructor(){super(...arguments);u(this,"minGeometrySize",10);u(this,"minAssetsSize",1e3)}}const _s=class _s extends ${constructor(t){super(t);u(this,"onGeometryStreamed",new M);u(this,"onAssetStreamed",new M);u(this,"onProgress",new M);u(this,"onIfcLoaded",new M);u(this,"onDisposed",new M);u(this,"settings",new kn);u(this,"enabled",!0);u(this,"webIfc",new x.IfcAPI);u(this,"_spatialTree",new Gn);u(this,"_metaData",new Hn);u(this,"_visitedGeometries",new Map);u(this,"_streamSerializer",new Dt.StreamSerializer);u(this,"_geometries",new Map);u(this,"_geometryCount",0);u(this,"_civil",new zn);u(this,"_groupSerializer",new Dt.Serializer);u(this,"_assets",[]);u(this,"_meshesWithHoles",new Set);this.components.add(_s.uuid,this),this.settings.excludedCategories.add(x.IFCOPENINGELEMENT)}dispose(){this.onIfcLoaded.reset(),this.onGeometryStreamed.reset(),this.onAssetStreamed.reset(),this.webIfc=null,this.onDisposed.trigger(),this.onDisposed.reset()}async streamFromBuffer(t){await this.readIfcFile(t),await this.streamAllGeometries(),this.cleanUp()}async streamFromCallBack(t){await this.streamIfcFile(t),await this.streamAllGeometries(),this.cleanUp()}async readIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModel(t,this.settings.webIfc)}async streamIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModelFromCallback(t,this.settings.webIfc)}async streamAllGeometries(){const{minGeometrySize:t,minAssetsSize:e}=this.settings;this._spatialTree.setUp(this.webIfc);const i=this.webIfc.GetIfcEntityList(0),o=[[]],n=new Dt.FragmentsGroup;n.ifcMetadata={name:"",description:"",...this._metaData.getNameInfo(this.webIfc),...this._metaData.getDescriptionInfo(this.webIfc),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};let r=0,a=0;for(const T of i){if(!this.webIfc.IsIfcElement(T)&&T!==x.IFCSPACE||this.settings.excludedCategories.has(T))continue;const F=this.webIfc.GetLineIDsWithType(0,T),m=F.size();for(let A=0;A<m;A++){r>t&&(r=0,a++,o.push([]));const O=F.get(A);o[a].push(O);const p=this.webIfc.GetLine(0,O);if(p.GlobalId){const S=(p==null?void 0:p.GlobalId.value)||(p==null?void 0:p.GlobalId);n.globalToExpressIDs.set(S,O)}const R=this._spatialTree.itemsByFloor[O]||0;n.data.set(O,[[],[R,T]]),r++}}this._spatialTree.cleanUp();let c=.01,h=0;for(const T of o){h++,this.webIfc.StreamMeshes(0,T,m=>{this.getMesh(this.webIfc,m,n)}),this._geometryCount>t&&await this.streamGeometries(),this._assets.length>e&&await this.streamAssets();const F=h/o.length;F>c&&(c+=.01,c=Math.max(c,F),this.onProgress.trigger(Math.round(c*100)/100))}this._geometryCount&&await this.streamGeometries(),this._assets.length&&await this.streamAssets();const{opaque:E,transparent:d}=n.geometryIDs;for(const[T,{index:F,uuid:m}]of this._visitedGeometries)n.keyFragments.set(F,m),(T>1?E:d).set(T,F);Wn.get(n,this.webIfc);const I=this.webIfc.GetCoordinationMatrix(0);n.coordinationMatrix.fromArray(I),n.civilData=this._civil.read(this.webIfc);const f=this._groupSerializer.export(n);this.onIfcLoaded.trigger(f),n.dispose(!0)}cleanUp(){try{this.webIfc.Dispose()}catch{}this.webIfc=null,this.webIfc=new x.IfcAPI,this._visitedGeometries.clear(),this._geometries.clear(),this._assets=[],this._meshesWithHoles.clear()}getMesh(t,e,i){const o=e.geometries.size(),n=e.expressID,r={id:n,geometries:[]};for(let a=0;a<o;a++){const c=e.geometries.get(a),h=c.geometryExpressID,E=c.color.w===1?1:-1,d=h*E;if(!this._visitedGeometries.has(d)){this._visitedGeometries.has(h)||this.getGeometry(t,h);const R=this._visitedGeometries.size,S=g.MathUtils.generateUUID();this._visitedGeometries.set(d,{uuid:S,index:R})}const I=this._visitedGeometries.get(d);if(I===void 0)throw new Error("Error getting geometry data for streaming!");const f=i.data.get(n);if(!f)throw new Error("Data not found!");f[0].push(I.index);const{x:T,y:F,z:m,w:A}=c.color,O=[T,F,m,A],p=c.flatTransformation;r.geometries.push({color:O,geometryID:h,transformation:p})}this._assets.push(r)}getGeometry(t,e){const i=t.GetGeometry(0,e),o=t.GetIndexArray(i.GetIndexData(),i.GetIndexDataSize()),n=t.GetVertexArray(i.GetVertexData(),i.GetVertexDataSize()),r=new Float32Array(n.length/2),a=new Float32Array(n.length/2);for(let I=0;I<n.length;I+=6)r[I/2]=n[I],r[I/2+1]=n[I+1],r[I/2+2]=n[I+2],a[I/2]=n[I+3],a[I/2+1]=n[I+4],a[I/2+2]=n[I+5];const c=On(r),h=new Float32Array(c.transformation.elements),E=[c.center.x,c.center.y,c.center.z];let d=!1;for(let I=0;I<r.length-2;I+=3){const f=r[I],T=r[I+1],F=r[I+2],m=a[I],A=a[I+1],O=a[I+2];if(Sn(E,[f,T,F],[m,A,O])){d=!0;break}}this._geometries.set(e,{position:r,normal:a,index:o,boundingBox:h,hasHoles:d}),i.delete(),this._geometryCount++}async streamAssets(){await this.onAssetStreamed.trigger(this._assets),this._assets=null,this._assets=[]}async streamGeometries(){let t=this._streamSerializer.export(this._geometries),e={};for(const[i,{boundingBox:o,hasHoles:n}]of this._geometries)e[i]={boundingBox:o,hasHoles:n};this.onGeometryStreamed.trigger({data:e,buffer:t}),e=null,t=null,this._geometries.clear(),this._geometryCount=0}};u(_s,"uuid","d9999a00-e1f5-4d3f-8cfe-c56e08609764");let Ai=_s;class Xn extends Ds{constructor(){super(...arguments);u(this,"propertiesSize",100)}}class Zn extends ${constructor(){super(...arguments);u(this,"onPropertiesStreamed",new Le);u(this,"onProgress",new Le);u(this,"onIndicesStreamed",new Le);u(this,"onDisposed",new M);u(this,"enabled",!0);u(this,"settings",new Xn);u(this,"webIfc",new x.IfcAPI)}async dispose(){this.onIndicesStreamed.reset(),this.onPropertiesStreamed.reset(),this.webIfc=null,this.onDisposed.reset()}async streamFromBuffer(t){await this.readIfcFile(t),await this.streamAllProperties(),this.cleanUp()}async streamFromCallBack(t){await this.streamIfcFile(t),await this.streamAllProperties(),this.cleanUp()}async readIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModel(t,this.settings.webIfc)}async streamIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModelFromCallback(t,this.settings.webIfc)}async streamAllProperties(){const{propertiesSize:t}=this.settings,e=new Set(this.webIfc.GetIfcEntityList(0)),i=new Set([x.IFCPROJECT,x.IFCSITE,x.IFCBUILDING,x.IFCBUILDINGSTOREY,x.IFCSPACE]);for(const c of i)e.add(c);let o=.01,n=0;for(const c of e){if(n++,Li.has(c))continue;const h=i.has(c),E=this.webIfc.GetLineIDsWithType(0,c),d=E.size();let I=0;for(let T=0;T<d-t;T+=t){const F={};for(let m=0;m<t;m++){I++;const A=E.get(T+m);try{const O=this.webIfc.GetLine(0,A,h);F[O.expressID]=O}catch{console.log(`Could not get property: ${A}`)}}await this.onPropertiesStreamed.trigger({type:c,data:F})}if(I!==d){const T={};for(let F=I;F<d;F++){const m=E.get(F);try{const A=this.webIfc.GetLine(0,m,h);T[A.expressID]=A}catch{console.log(`Could not get property: ${m}`)}}await this.onPropertiesStreamed.trigger({type:c,data:T})}n/e.size>o&&(o=Math.round(o*100)/100,await this.onProgress.trigger(o),o+=.01)}await this.onProgress.trigger(1);const a=await this.components.get(Wt).processFromWebIfc(this.webIfc,0);await this.onIndicesStreamed.trigger(a)}cleanUp(){this.webIfc.Dispose(),this.webIfc=null,this.webIfc=new x.IfcAPI}}u(Zn,"uuid","88d2c89c-ce32-47d7-8cb6-d51e4b311a0b");const ys=class ys extends ${constructor(t){super(t);u(this,"enabled",!0);t.add(ys.uuid,this)}static distanceFromPointToLine(t,e,i,o=!1){const n=new g.Line3,r=new g.Vector3;return n.set(e,i),n.closestPointToPoint(t,o,r),r.distanceTo(t)}getFace(t,e,i){if(!t.geometry.index)throw new Error("Geometry must be indexed!");const o=new Map,n=t.geometry.index.array,{plane:r}=this.getFaceData(e,i,t),a=[];for(let d=0;d<n.length/3;d++){const{plane:I,edges:f}=this.getFaceData(d,i,t);if(I.equals(r)){a.push({index:d,edges:f});for(const{id:T,points:F,distance:m}of f)o.set(T,{points:F,distance:m})}}let c=0;const h=new Map,E=new Map;for(const{index:d,edges:I}of a){const f=new Map;for(const{id:R}of I)if(h.has(R)){const S=h.get(R);f.set(R,S)}const T=I.map(R=>R.id);if(!f.size){const R=c++;for(const{id:S}of I)h.set(S,R);E.set(R,{edges:new Set(T),indices:new Set([d])});continue}let F=null;const m=new Set,A=new Set(T);for(const[R,S]of f){F===null?F=S:S!==F&&m.add(S),h.delete(R);const{edges:_}=E.get(S);_.delete(R),A.delete(R)}if(F===null)throw new Error("Error computing face!");const O=E.get(F),{indices:p}=O;p.add(d);for(const R of A){h.set(R,F);const{edges:S}=O;S.add(R)}for(const R of m){const S=E.get(R),{edges:_,indices:y}=S,N=E.get(F),{edges:P,indices:D}=N;for(const w of _)P.add(w),h.set(w,F);for(const w of y)D.add(w);E.delete(R)}}for(const[d,{indices:I,edges:f}]of E)if(I.has(e)){const T=[];for(const F of f){const m=o.get(F);T.push(m)}return{edges:T,indices:I}}return null}getVerticesAndNormal(t,e,i){if(!t.geometry.index)throw new Error("Geometry must be indexed!");const o=t.geometry.index.array,n=t.geometry.attributes.position.array,r=t.geometry.attributes.normal.array,a=o[e*3]*3,c=o[e*3+1]*3,h=o[e*3+2]*3,E=new g.Vector3(n[a],n[a+1],n[a+2]),d=new g.Vector3(n[c],n[c+1],n[c+2]),I=new g.Vector3(n[h],n[h+1],n[h+2]),f=new g.Vector3(r[a],r[a+1],r[a+2]),T=new g.Vector3(r[c],r[c+1],r[c+2]),F=new g.Vector3(r[h],r[h+1],r[h+2]),m=(f.x+T.x+F.x)/3,A=(f.y+T.y+F.y)/3,O=(f.z+T.z+F.z)/3,p=new g.Vector3(m,A,O);if(i!==void 0&&t instanceof g.InstancedMesh){const R=new g.Matrix4;t.getMatrixAt(i,R);const S=new g.Matrix4;S.extractRotation(R),p.applyMatrix4(S),E.applyMatrix4(R),d.applyMatrix4(R),I.applyMatrix4(R)}return{p1:E,p2:d,p3:I,faceNormal:p}}round(t){t.x=Math.trunc(t.x*1e3)/1e3,t.y=Math.trunc(t.y*1e3)/1e3,t.z=Math.trunc(t.z*1e3)/1e3}getVolumeFromFragments(t){const e=this.components.get(ot),i=new g.Matrix4,o=[];for(const r in t){const a=e.list.get(r);if(!a)continue;const c=t[r];let h=0;for(const I of c){const f=a.getInstancesIDs(I);f&&(h+=f.size)}const E=new g.InstancedMesh(a.mesh.geometry,void 0,h);let d=0;for(const I of c){const f=a.getInstancesIDs(I);if(f)for(const T of f)a.mesh.getMatrixAt(T,i),E.setMatrixAt(d++,i)}o.push(E)}const n=this.getVolumeFromMeshes(o);for(const r of o)r.geometry=null,r.material=[],r.dispose();return n}getVolumeFromMeshes(t){let e=0;for(const i of t)e+=this.getVolumeOfMesh(i);return e}getFaceData(t,e,i){const o=this.getVerticesAndNormal(i,t,e),{p1:n,p2:r,p3:a,faceNormal:c}=o;this.round(n),this.round(r),this.round(a),this.round(c);const h=[{id:`${n.x}|${n.y}|${n.z}`,value:n},{id:`${r.x}|${r.y}|${r.z}`,value:r},{id:`${a.x}|${a.y}|${a.z}`,value:a}];h.sort((O,p)=>O.id<p.id?-1:O.id>p.id?1:0);const[{id:E,value:d},{id:I,value:f},{id:T,value:F}]=h,m=[{id:`${E}|${I}`,distance:d.distanceTo(f),points:[d,f]},{id:`${I}|${T}`,distance:f.distanceTo(F),points:[f,F]},{id:`${E}|${T}`,distance:d.distanceTo(F),points:[d,F]}],A=new g.Plane;return A.setFromNormalAndCoplanarPoint(c,n),A.constant=Math.round(A.constant*10)/10,{plane:A,edges:m}}getVolumeOfMesh(t){let e=0;const i=new g.Vector3,o=new g.Vector3,n=new g.Vector3,{index:r}=t.geometry,a=t.geometry.attributes.position.array;if(!r)return console.warn("Geometry must be indexed to compute its volume!"),0;const c=[];if(t instanceof g.InstancedMesh)for(let E=0;E<t.count;E++){const d=new g.Matrix4;t.getMatrixAt(E,d),c.push(d)}else c.push(new g.Matrix4().identity());const{matrixWorld:h}=t;for(let E=0;E<r.array.length-2;E+=3)for(const d of c){const I=d.multiply(h),f=r.array[E]*3,T=r.array[E+1]*3,F=r.array[E+2]*3;i.set(a[f],a[f+1],a[f+2]).applyMatrix4(I),o.set(a[T],a[T+1],a[T+2]).applyMatrix4(I),n.set(a[F],a[F+1],a[F+2]).applyMatrix4(I),e+=this.getSignedVolumeOfTriangle(i,o,n)}return Math.abs(e)}getSignedVolumeOfTriangle(t,e,i){const o=i.x*e.y*t.z,n=e.x*i.y*t.z,r=i.x*t.y*e.z,a=t.x*i.y*e.z,c=e.x*t.y*i.z,h=t.x*e.y*i.z;return 1/6*(-o+n+r-a-c+h)}};u(ys,"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");let gi=ys;exports.AsyncEvent=Le;exports.Base=Ps;exports.BaseCamera=Fn;exports.BaseRenderer=An;exports.BaseScene=gn;exports.BaseWorldItem=ws;exports.BoundingBoxer=Ti;exports.Classifier=fs;exports.Clipper=pi;exports.Component=$;exports.Components=hs;exports.CullerRenderer=Pn;exports.Cullers=Es;exports.DataMap=di;exports.DataSet=or;exports.Disposer=_t;exports.Event=M;exports.Exploder=Ri;exports.FirstPersonMode=bn;exports.FragmentsManager=ot;exports.GeometryTypes=Li;exports.Grids=fi;exports.Hider=Fi;exports.IfcCategories=xr;exports.IfcCategoryMap=Pi;exports.IfcElements=Yn;exports.IfcFragmentSettings=Ds;exports.IfcGeometryTiler=Ai;exports.IfcJsonExporter=us;exports.IfcLoader=Is;exports.IfcPropertiesManager=mi;exports.IfcPropertiesTiler=Zn;exports.IfcPropertiesUtils=xt;exports.IfcRelationsIndexer=Wt;exports.IfcStreamingSettings=kn;exports.MaterialsUtils=Ii;exports.MeasurementUtils=gi;exports.MeshCullerRenderer=wn;exports.MiniMap=Un;exports.MiniMaps=Ci;exports.Mouse=Mn;exports.OrbitMode=vn;exports.OrthoPerspectiveCamera=Mr;exports.PlanMode=Bn;exports.ProjectionManager=Vn;exports.PropertiesStreamingSettings=Xn;exports.Raycasters=le;exports.ShadowedScene=gr;exports.SimpleCamera=ce;exports.SimpleGrid=xn;exports.SimplePlane=Ms;exports.SimpleRaycaster=Dn;exports.SimpleRenderer=fr;exports.SimpleScene=yn;exports.SimpleWorld=_n;exports.UUID=ae;exports.VertexPicker=Ir;exports.Worlds=ds;exports.isPointInFrontOfPlane=Sn;exports.obbFromPoints=On;exports.readPixelsAsync=Ni;
|
|
128
|
+
`,extensions:{derivatives:!0}});this.three=new g.Mesh(a,c),this.three.frustumCulled=!1,t.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(s){s?this.world.scene.three.add(this.three):this.three.removeFromParent()}get material(){return this.three.material}get fade(){return this._fade===3}set fade(s){this._fade=s?3:0,this.material.uniforms.uFade.value=this._fade}dispose(){this.setupEvents(!1),this.components.get(_t).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(s){if(this.world.isDisposing||!(this.world.camera instanceof ce))return;const t=this.world.camera.controls;s?t.addEventListener("update",this.updateZoom):t.removeEventListener("update",this.updateZoom)}}const ms=class ms extends ${constructor(t){super(t);u(this,"list",new Map);u(this,"config",{color:new g.Color(12303291),size1:1,size2:10,distance:500});u(this,"onDisposed",new M);u(this,"enabled",!0);t.add(ms.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");const e=new xn(this.components,t,this.config);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}};u(ms,"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");let fi=ms;const zt=new C.Raycaster,it=new C.Vector3,Nt=new C.Vector3,Q=new C.Quaternion,ln={X:new C.Vector3(1,0,0),Y:new C.Vector3(0,1,0),Z:new C.Vector3(0,0,1)},si={type:"change"},hn={type:"mouseDown"},dn={type:"mouseUp",mode:null},En={type:"objectChange"};class Or extends C.Object3D{constructor(s,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const e=new Pr;this._gizmo=e,this.add(e);const i=new wr;this._plane=i,this.add(i);const o=this;function n(A,O){let p=O;Object.defineProperty(o,A,{get:function(){return p!==void 0?p:O},set:function(R){p!==R&&(p=R,i[A]=R,e[A]=R,o.dispatchEvent({type:A+"-changed",value:R}),o.dispatchEvent(si))}}),o[A]=O,i[A]=O,e[A]=O}n("camera",s),n("object",void 0),n("enabled",!0),n("axis",null),n("mode","translate"),n("translationSnap",null),n("rotationSnap",null),n("scaleSnap",null),n("space","world"),n("size",1),n("dragging",!1),n("showX",!0),n("showY",!0),n("showZ",!0);const r=new C.Vector3,a=new C.Vector3,c=new C.Quaternion,h=new C.Quaternion,E=new C.Vector3,d=new C.Quaternion,I=new C.Vector3,f=new C.Vector3,T=new C.Vector3,F=0,m=new C.Vector3;n("worldPosition",r),n("worldPositionStart",a),n("worldQuaternion",c),n("worldQuaternionStart",h),n("cameraPosition",E),n("cameraQuaternion",d),n("pointStart",I),n("pointEnd",f),n("rotationAxis",T),n("rotationAngle",F),n("eye",m),this._offset=new C.Vector3,this._startNorm=new C.Vector3,this._endNorm=new C.Vector3,this._cameraScale=new C.Vector3,this._parentPosition=new C.Vector3,this._parentQuaternion=new C.Quaternion,this._parentQuaternionInv=new C.Quaternion,this._parentScale=new C.Vector3,this._worldScaleStart=new C.Vector3,this._worldQuaternionInv=new C.Quaternion,this._worldScale=new C.Vector3,this._positionStart=new C.Vector3,this._quaternionStart=new C.Quaternion,this._scaleStart=new C.Vector3,this._getPointer=Sr.bind(this),this._onPointerDown=yr.bind(this),this._onPointerHover=_r.bind(this),this._onPointerMove=Nr.bind(this),this._onPointerUp=Lr.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(s){if(this.object===void 0||this.dragging===!0)return;zt.setFromCamera(s,this.camera);const t=ii(this._gizmo.picker[this.mode],zt);t?this.axis=t.object.name:this.axis=null}pointerDown(s){if(!(this.object===void 0||this.dragging===!0||s.button!==0)&&this.axis!==null){zt.setFromCamera(s,this.camera);const t=ii(this._plane,zt,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,hn.mode=this.mode,this.dispatchEvent(hn)}}pointerMove(s){const t=this.axis,e=this.mode,i=this.object;let o=this.space;if(e==="scale"?o="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(o="world"),i===void 0||t===null||this.dragging===!1||s.button!==-1)return;zt.setFromCamera(s,this.camera);const n=ii(this._plane,zt,!0);if(n){if(this.pointEnd.copy(n.point).sub(this.worldPositionStart),e==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),o==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),o==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(o==="local"&&(i.position.applyQuaternion(Q.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),o==="world"&&(i.parent&&i.position.add(it.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(it.setFromMatrixPosition(i.parent.matrixWorld))));else if(e==="scale"){if(t.search("XYZ")!==-1){let r=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(r*=-1),Nt.set(r,r,r)}else it.copy(this.pointStart),Nt.copy(this.pointEnd),it.applyQuaternion(this._worldQuaternionInv),Nt.applyQuaternion(this._worldQuaternionInv),Nt.divide(it),t.search("X")===-1&&(Nt.x=1),t.search("Y")===-1&&(Nt.y=1),t.search("Z")===-1&&(Nt.z=1);i.scale.copy(this._scaleStart).multiply(Nt),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(e==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const r=20/this.worldPosition.distanceTo(it.setFromMatrixPosition(this.camera.matrixWorld));let a=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(it.copy(this.rotationAxis).cross(this.eye))*r):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(ln[t]),it.copy(ln[t]),o==="local"&&it.applyQuaternion(this.worldQuaternion),it.cross(this.eye),it.length()===0?a=!0:this.rotationAngle=this._offset.dot(it.normalize())*r),(t==="E"||a)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),o==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Q.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Q.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(si),this.dispatchEvent(En)}}pointerUp(s){s.button===0&&(this.dragging&&this.axis!==null&&(dn.mode=this.mode,this.dispatchEvent(dn)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(s){s.geometry&&s.geometry.dispose(),s.material&&s.material.dispose()})}attach(s){return this.object=s,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(si),this.dispatchEvent(En),this.pointStart.copy(this.pointEnd))}getRaycaster(){return zt}getMode(){return this.mode}setMode(s){this.mode=s}setTranslationSnap(s){this.translationSnap=s}setRotationSnap(s){this.rotationSnap=s}setScaleSnap(s){this.scaleSnap=s}setSize(s){this.size=s}setSpace(s){this.space=s}}function Sr(l){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:l.button};{const s=this.domElement.getBoundingClientRect();return{x:(l.clientX-s.left)/s.width*2-1,y:-(l.clientY-s.top)/s.height*2+1,button:l.button}}}function _r(l){if(this.enabled)switch(l.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(l));break}}function yr(l){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(l)),this.pointerDown(this._getPointer(l)))}function Nr(l){this.enabled&&this.pointerMove(this._getPointer(l))}function Lr(l){this.enabled&&(this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(l)))}function ii(l,s,t){const e=s.intersectObject(l,!0);for(let i=0;i<e.length;i++)if(e[i].object.visible||t)return e[i];return!1}const is=new C.Euler,W=new C.Vector3(0,1,0),un=new C.Vector3(0,0,0),In=new C.Matrix4,ns=new C.Quaternion,cs=new C.Quaternion,At=new C.Vector3,fn=new C.Matrix4,_e=new C.Vector3(1,0,0),Ht=new C.Vector3(0,1,0),ye=new C.Vector3(0,0,1),os=new C.Vector3,Oe=new C.Vector3,Se=new C.Vector3;class Pr extends C.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const s=new C.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new C.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=s.clone();e.opacity=.15;const i=t.clone();i.opacity=.5;const o=s.clone();o.color.setHex(16711680);const n=s.clone();n.color.setHex(65280);const r=s.clone();r.color.setHex(255);const a=s.clone();a.color.setHex(16711680),a.opacity=.5;const c=s.clone();c.color.setHex(65280),c.opacity=.5;const h=s.clone();h.color.setHex(255),h.opacity=.5;const E=s.clone();E.opacity=.25;const d=s.clone();d.color.setHex(16776960),d.opacity=.25,s.clone().color.setHex(16776960);const f=s.clone();f.color.setHex(7895160);const T=new C.CylinderGeometry(0,.04,.1,12);T.translate(0,.05,0);const F=new C.BoxGeometry(.08,.08,.08);F.translate(0,.04,0);const m=new C.BufferGeometry;m.setAttribute("position",new C.Float32BufferAttribute([0,0,0,1,0,0],3));const A=new C.CylinderGeometry(.0075,.0075,.5,3);A.translate(0,.25,0);function O(v,z){const j=new C.TorusGeometry(v,.0075,3,64,z*Math.PI*2);return j.rotateY(Math.PI/2),j.rotateX(Math.PI/2),j}function p(){const v=new C.BufferGeometry;return v.setAttribute("position",new C.Float32BufferAttribute([0,0,0,1,1,1],3)),v}const R={X:[[new C.Mesh(T,o),[.5,0,0],[0,0,-Math.PI/2]],[new C.Mesh(T,o),[-.5,0,0],[0,0,Math.PI/2]],[new C.Mesh(A,o),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new C.Mesh(T,n),[0,.5,0]],[new C.Mesh(T,n),[0,-.5,0],[Math.PI,0,0]],[new C.Mesh(A,n)]],Z:[[new C.Mesh(T,r),[0,0,.5],[Math.PI/2,0,0]],[new C.Mesh(T,r),[0,0,-.5],[-Math.PI/2,0,0]],[new C.Mesh(A,r),null,[Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.OctahedronGeometry(.1,0),E.clone()),[0,0,0]]],XY:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),a.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[.3,0,0],[0,0,-Math.PI/2]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,.3,0]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,-.3,0],[0,0,Math.PI]]],Z:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,0,.3],[Math.PI/2,0,0]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.OctahedronGeometry(.2,0),e)]],XY:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[.15,.15,0]]],YZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[.15,0,.15],[-Math.PI/2,0,0]]]},_={START:[[new C.Mesh(new C.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new C.Mesh(new C.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new C.Line(p(),i),null,null,null,"helper"]],X:[[new C.Line(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new C.Line(m,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new C.Line(m,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},y={XYZE:[[new C.Mesh(O(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new C.Mesh(O(.5,.5),o)]],Y:[[new C.Mesh(O(.5,.5),n),null,[0,0,-Math.PI/2]]],Z:[[new C.Mesh(O(.5,.5),r),null,[0,Math.PI/2,0]]],E:[[new C.Mesh(O(.75,1),d),null,[0,Math.PI/2,0]]]},N={AXIS:[[new C.Line(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},P={XYZE:[[new C.Mesh(new C.SphereGeometry(.25,10,8),e)]],X:[[new C.Mesh(new C.TorusGeometry(.5,.1,4,24),e),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new C.Mesh(new C.TorusGeometry(.5,.1,4,24),e),[0,0,0],[Math.PI/2,0,0]]],Z:[[new C.Mesh(new C.TorusGeometry(.5,.1,4,24),e),[0,0,0],[0,0,-Math.PI/2]]],E:[[new C.Mesh(new C.TorusGeometry(.75,.1,2,24),e)]]},x={X:[[new C.Mesh(F,o),[.5,0,0],[0,0,-Math.PI/2]],[new C.Mesh(A,o),[0,0,0],[0,0,-Math.PI/2]],[new C.Mesh(F,o),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new C.Mesh(F,n),[0,.5,0]],[new C.Mesh(A,n)],[new C.Mesh(F,n),[0,-.5,0],[0,0,Math.PI]]],Z:[[new C.Mesh(F,r),[0,0,.5],[Math.PI/2,0,0]],[new C.Mesh(A,r),[0,0,0],[Math.PI/2,0,0]],[new C.Mesh(F,r),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.BoxGeometry(.1,.1,.1),E.clone())]]},w={X:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[.3,0,0],[0,0,-Math.PI/2]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,.3,0]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,-.3,0],[0,0,Math.PI]]],Z:[[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,0,.3],[Math.PI/2,0,0]],[new C.Mesh(new C.CylinderGeometry(.2,0,.6,4),e),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[.15,.15,0]]],YZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.01),e),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.BoxGeometry(.2,.2,.2),e),[0,0,0]]]},U={X:[[new C.Line(m,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new C.Line(m,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new C.Line(m,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function b(v){const z=new C.Object3D;for(const j in v)for(let et=v[j].length;et--;){const Z=v[j][et][0].clone(),bt=v[j][et][1],vt=v[j][et][2],Bt=v[j][et][3],Ue=v[j][et][4];Z.name=j,Z.tag=Ue,bt&&Z.position.set(bt[0],bt[1],bt[2]),vt&&Z.rotation.set(vt[0],vt[1],vt[2]),Bt&&Z.scale.set(Bt[0],Bt[1],Bt[2]),Z.updateMatrix();const de=Z.geometry.clone();de.applyMatrix4(Z.matrix),Z.geometry=de,Z.renderOrder=1/0,Z.position.set(0,0,0),Z.rotation.set(0,0,0),Z.scale.set(1,1,1),z.add(Z)}return z}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=b(R)),this.add(this.gizmo.rotate=b(y)),this.add(this.gizmo.scale=b(x)),this.add(this.picker.translate=b(S)),this.add(this.picker.rotate=b(P)),this.add(this.picker.scale=b(w)),this.add(this.helper.translate=b(_)),this.add(this.helper.rotate=b(N)),this.add(this.helper.scale=b(U)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(s){const e=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:cs;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let o=0;o<i.length;o++){const n=i[o];n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition);let r;if(this.camera.isOrthographicCamera?r=(this.camera.top-this.camera.bottom)/this.camera.zoom:r=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(r*this.size/4),n.tag==="helper"){n.visible=!1,n.name==="AXIS"?(n.visible=!!this.axis,this.axis==="X"&&(Q.setFromEuler(is.set(0,0,0)),n.quaternion.copy(e).multiply(Q),Math.abs(W.copy(_e).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Y"&&(Q.setFromEuler(is.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(Q),Math.abs(W.copy(Ht).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Z"&&(Q.setFromEuler(is.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(Q),Math.abs(W.copy(ye).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="XYZE"&&(Q.setFromEuler(is.set(0,Math.PI/2,0)),W.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(In.lookAt(un,W,Ht)),n.quaternion.multiply(Q),n.visible=this.dragging),this.axis==="E"&&(n.visible=!1)):n.name==="START"?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):n.name==="END"?(n.position.copy(this.worldPosition),n.visible=this.dragging):n.name==="DELTA"?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),it.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),it.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(it),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=this.axis.search(n.name)!==-1));continue}n.quaternion.copy(e),this.mode==="translate"||this.mode==="scale"?(n.name==="X"&&Math.abs(W.copy(_e).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Y"&&Math.abs(W.copy(Ht).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Z"&&Math.abs(W.copy(ye).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XY"&&Math.abs(W.copy(ye).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="YZ"&&Math.abs(W.copy(_e).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XZ"&&Math.abs(W.copy(Ht).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)):this.mode==="rotate"&&(ns.copy(e),W.copy(this.eye).applyQuaternion(Q.copy(e).invert()),n.name.search("E")!==-1&&n.quaternion.setFromRotationMatrix(In.lookAt(this.eye,un,Ht)),n.name==="X"&&(Q.setFromAxisAngle(_e,Math.atan2(-W.y,W.z)),Q.multiplyQuaternions(ns,Q),n.quaternion.copy(Q)),n.name==="Y"&&(Q.setFromAxisAngle(Ht,Math.atan2(W.x,W.z)),Q.multiplyQuaternions(ns,Q),n.quaternion.copy(Q)),n.name==="Z"&&(Q.setFromAxisAngle(ye,Math.atan2(W.y,W.x)),Q.multiplyQuaternions(ns,Q),n.quaternion.copy(Q))),n.visible=n.visible&&(n.name.indexOf("X")===-1||this.showX),n.visible=n.visible&&(n.name.indexOf("Y")===-1||this.showY),n.visible=n.visible&&(n.name.indexOf("Z")===-1||this.showZ),n.visible=n.visible&&(n.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(a){return n.name===a}))&&(n.material.color.setHex(16776960),n.material.opacity=1)}super.updateMatrixWorld(s)}}class wr extends C.Mesh{constructor(){super(new C.PlaneGeometry(1e5,1e5,2,2),new C.MeshBasicMaterial({visible:!1,wireframe:!0,side:C.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(s){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),os.copy(_e).applyQuaternion(t==="local"?this.worldQuaternion:cs),Oe.copy(Ht).applyQuaternion(t==="local"?this.worldQuaternion:cs),Se.copy(ye).applyQuaternion(t==="local"?this.worldQuaternion:cs),W.copy(Oe),this.mode){case"translate":case"scale":switch(this.axis){case"X":W.copy(this.eye).cross(os),At.copy(os).cross(W);break;case"Y":W.copy(this.eye).cross(Oe),At.copy(Oe).cross(W);break;case"Z":W.copy(this.eye).cross(Se),At.copy(Se).cross(W);break;case"XY":At.copy(Se);break;case"YZ":At.copy(os);break;case"XZ":W.copy(Se),At.copy(Oe);break;case"XYZ":case"E":At.set(0,0,0);break}break;case"rotate":default:At.set(0,0,0)}At.length()===0?this.quaternion.copy(this.cameraQuaternion):(fn.lookAt(it.set(0,0,0),At,W),this.quaternion.setFromRotationMatrix(fn)),super.updateMatrixWorld(s)}}class Ms{constructor(s,t,e,i,o,n=5,r=!0){u(this,"onDraggingStarted",new M);u(this,"onDraggingEnded",new M);u(this,"onDisposed",new M);u(this,"normal");u(this,"origin");u(this,"three",new g.Plane);u(this,"components");u(this,"world");u(this,"type","default");u(this,"_helper");u(this,"_visible",!0);u(this,"_enabled",!0);u(this,"_controlsActive",!1);u(this,"_arrowBoundBox",new g.Mesh);u(this,"_planeMesh");u(this,"_controls");u(this,"_hiddenMaterial",new g.MeshBasicMaterial({visible:!1}));u(this,"update",()=>{this._enabled&&this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position)});u(this,"changeDrag",s=>{this._visible=!s.value,this.preventCameraMovement(),this.notifyDraggingChanged(s)});if(this.components=s,this.world=t,!t.renderer)throw new Error("The given world must have a renderer!");this.normal=i,this.origin=e,t.renderer.setPlane(!0,this.three),this._planeMesh=Ms.newPlaneMesh(n,o),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(i,e),r&&this.toggleControls(!0)}get enabled(){return this._enabled}set enabled(s){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");this._enabled=s,this.world.renderer.setPlane(s,this.three)}get visible(){return this._visible}set visible(s){this._visible=s,this._controls.visible=s,this._helper.visible=s,this.toggleControls(s)}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(s){this._planeMesh.material=s}get size(){return this._planeMesh.scale.x}set size(s){this._planeMesh.scale.set(s,s,s)}get helper(){return this._helper}setFromNormalAndCoplanarPoint(s,t){this.reset(),this.normal.equals(s)||(this.normal.copy(s),this._helper.lookAt(s)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix(),this.update()}dispose(){this._enabled=!1,this.onDraggingStarted.reset(),this.onDraggingEnded.reset(),this._helper.removeFromParent(),this.world.renderer&&this.world.renderer.setPlane(!1,this.three),this._arrowBoundBox.removeFromParent(),this._arrowBoundBox.geometry.dispose(),this._planeMesh.geometry.dispose(),this._controls.removeFromParent(),this._controls.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}reset(){const s=new g.Vector3(1,0,0),t=new g.Vector3;this.normal.equals(s)||(this.normal.copy(s),this._helper.lookAt(s)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix()}toggleControls(s){if(s){if(this._controlsActive)return;this._controls.addEventListener("change",this.update),this._controls.addEventListener("dragging-changed",this.changeDrag)}else this._controls.removeEventListener("change",this.update),this._controls.removeEventListener("dragging-changed",this.changeDrag);this._controlsActive=s}newTransformControls(){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");const s=this.world.camera.three,t=this.world.renderer.three.domElement,e=new Or(s,t);return this.initializeControls(e),this.world.scene.three.add(e),e}initializeControls(s){s.attach(this._helper),s.showX=!1,s.showY=!1,s.setSpace("local"),this.createArrowBoundingBox(),s.children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new g.CylinderGeometry(.18,.18,1.2),this._arrowBoundBox.material=this._hiddenMaterial,this._arrowBoundBox.rotateX(Math.PI/2),this._arrowBoundBox.updateMatrix(),this._arrowBoundBox.geometry.applyMatrix4(this._arrowBoundBox.matrix)}notifyDraggingChanged(s){s.value?this.onDraggingStarted.trigger():this.onDraggingEnded.trigger()}preventCameraMovement(){this.world.camera.enabled=this._visible}newHelper(){const s=new g.Object3D;return s.lookAt(this.normal),s.position.copy(this.origin),this._planeMesh.position.z+=.01,s.add(this._planeMesh),this.world.scene.three.add(s),s}static newPlaneMesh(s,t){const e=new g.PlaneGeometry(1),i=new g.Mesh(e,t);return i.scale.set(s,s,s),i}}const Me=class Me extends ${constructor(t){super(t);u(this,"onBeforeDrag",new M);u(this,"onAfterDrag",new M);u(this,"onBeforeCreate",new M);u(this,"onBeforeCancel",new M);u(this,"onAfterCancel",new M);u(this,"onBeforeDelete",new M);u(this,"onAfterCreate",new M);u(this,"onAfterDelete",new M);u(this,"onDisposed",new M);u(this,"orthogonalY",!1);u(this,"toleranceOrthogonalY",.7);u(this,"Type",Ms);u(this,"list",[]);u(this,"_material",new g.MeshBasicMaterial({color:12255487,side:g.DoubleSide,transparent:!0,opacity:.2}));u(this,"_size",5);u(this,"_enabled",!1);u(this,"_visible",!0);u(this,"_onStartDragging",()=>{this.onBeforeDrag.trigger()});u(this,"_onEndDragging",()=>{this.onAfterDrag.trigger()});this.components.add(Me.uuid,this)}get enabled(){return this._enabled}set enabled(t){this._enabled=t;for(const e of this.list)e.enabled=t;this.updateMaterialsAndPlanes()}get visible(){return this._visible}set visible(t){this._visible=t;for(const e of this.list)e.visible=t}get material(){return this._material}set material(t){this._material=t;for(const e of this.list)e.planeMaterial=t}get size(){return this._size}set size(t){this._size=t;for(const e of this.list)e.size=t}dispose(){this._enabled=!1;for(const t of this.list)t.dispose();this.list.length=0,this._material.dispose(),this.onBeforeCreate.reset(),this.onBeforeCancel.reset(),this.onBeforeDelete.reset(),this.onBeforeDrag.reset(),this.onAfterCreate.reset(),this.onAfterCancel.reset(),this.onAfterDelete.reset(),this.onAfterDrag.reset(),this.onDisposed.trigger(Me.uuid),this.onDisposed.reset()}create(t){const o=this.components.get(le).get(t).castRay();return o?this.createPlaneFromIntersection(t,o):null}createFromNormalAndCoplanarPoint(t,e,i){const o=this.newPlane(t,i,e);return this.updateMaterialsAndPlanes(),o}delete(t,e){e||(e=this.pickPlane(t)),e&&this.deletePlane(e)}deleteAll(t){const e=[...this.list];for(const i of e)if(!t||t.has(i.type)){this.delete(i.world,i);const o=this.list.indexOf(i);o!==-1&&this.list.splice(o,1)}}deletePlane(t){const e=this.list.indexOf(t);if(e!==-1){if(this.list.splice(e,1),!t.world.renderer)throw new Error("Renderer not found for this plane's world!");t.world.renderer.setPlane(!1,t.three),t.dispose(),this.updateMaterialsAndPlanes(),this.onAfterDelete.trigger(t)}}pickPlane(t){const i=this.components.get(le).get(t),o=this.getAllPlaneMeshes(),n=i.castRay(o);if(n){const r=n.object;return this.list.find(a=>a.meshes.includes(r))}}getAllPlaneMeshes(){const t=[];for(const e of this.list)t.push(...e.meshes);return t}createPlaneFromIntersection(t,e){var a;if(!t.renderer)throw new Error("The given world must have a renderer!");const i=e.point.distanceTo(new g.Vector3(0,0,0)),o=(a=e.face)==null?void 0:a.normal;if(!i||!o)return null;const n=this.getWorldNormal(e,o),r=this.newPlane(t,e.point,n.negate());return r.visible=this._visible,r.size=this._size,t.renderer.setPlane(!0,r.three),this.updateMaterialsAndPlanes(),r}getWorldNormal(t,e){const i=t.object;let o=t.object.matrixWorld.clone();if(i instanceof g.InstancedMesh&&t.instanceId!==void 0){const c=new g.Matrix4;i.getMatrixAt(t.instanceId,c),o=c.multiply(o)}const r=new g.Matrix3().getNormalMatrix(o),a=e.clone().applyMatrix3(r).normalize();return this.normalizePlaneDirectionY(a),a}normalizePlaneDirectionY(t){this.orthogonalY&&(t.y>this.toleranceOrthogonalY&&(t.x=0,t.y=1,t.z=0),t.y<-this.toleranceOrthogonalY&&(t.x=0,t.y=-1,t.z=0))}newPlane(t,e,i){const o=new this.Type(this.components,t,e,i,this._material);return o.onDraggingStarted.add(this._onStartDragging),o.onDraggingEnded.add(this._onEndDragging),this.list.push(o),this.onAfterCreate.trigger(o),o}updateMaterialsAndPlanes(){const t=this.components.get(ds);for(const[e,i]of t.list){if(!i.renderer)continue;i.renderer.updateClippingPlanes();const{clippingPlanes:o}=i.renderer;for(const n of i.meshes)if(n.material)if(Array.isArray(n.material))for(const r of n.material)r.clippingPlanes=o;else n.material.clippingPlanes=o}}};u(Me,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let pi=Me;class Un{constructor(s){u(this,"onDisposed",new M);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onResize",new M);u(this,"frontOffset",0);u(this,"overrideMaterial",new g.MeshDepthMaterial);u(this,"backgroundColor",new g.Color(395274));u(this,"renderer");u(this,"enabled",!0);u(this,"world");u(this,"_lockRotation",!0);u(this,"_camera");u(this,"_plane");u(this,"_size",new g.Vector2(320,160));u(this,"_tempVector1",new g.Vector3);u(this,"_tempVector2",new g.Vector3);u(this,"_tempTarget",new g.Vector3);u(this,"down",new g.Vector3(0,-1,0));u(this,"updatePlanes",()=>{if(!this.world.renderer)throw new Error("The given world must have a renderer!");const s=[],t=this.world.renderer.three;for(const e of t.clippingPlanes)s.push(e);s.push(this._plane),this.renderer.clippingPlanes=s});if(this.world=s,!this.world.renderer)throw new Error("The given world must have a renderer!");this.renderer=new g.WebGLRenderer,this.renderer.setSize(this._size.x,this._size.y);const t=1,e=this._size.x/this._size.y;this._camera=new g.OrthographicCamera(t*e/-2,t*e/2,t/2,t/-2),this.world.renderer.onClippingPlanesUpdated.add(this.updatePlanes),this._camera.position.set(0,200,0),this._camera.zoom=.1,this._camera.rotation.x=-Math.PI/2,this._plane=new g.Plane(this.down,200),this.updatePlanes()}get lockRotation(){return this._lockRotation}set lockRotation(s){this._lockRotation=s,s&&(this._camera.rotation.z=0)}get zoom(){return this._camera.zoom}set zoom(s){this._camera.zoom=s,this._camera.updateProjectionMatrix()}dispose(){this.enabled=!1,this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.onResize.reset(),this.overrideMaterial.dispose(),this.renderer.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get(){return this._camera}update(){if(!this.enabled)return;this.onBeforeUpdate.trigger();const s=this.world.scene.three,t=this.world.camera;if(!t.hasCameraControls())throw new Error("The given world must use camera controls!");if(!(s instanceof g.Scene))throw new Error("The given world must have a THREE.Scene as a root!");const e=t.controls;if(e.getPosition(this._tempVector1),this._camera.position.x=this._tempVector1.x,this._camera.position.z=this._tempVector1.z,this.frontOffset!==0&&(e.getTarget(this._tempVector2),this._tempVector2.sub(this._tempVector1),this._tempVector2.normalize().multiplyScalar(this.frontOffset),this._camera.position.x+=this._tempVector2.x,this._camera.position.z+=this._tempVector2.z),!this._lockRotation){e.getTarget(this._tempTarget);const o=Math.atan2(this._tempTarget.x-this._tempVector1.x,this._tempTarget.z-this._tempVector1.z);this._camera.rotation.z=o+Math.PI}this._plane.set(this.down,this._tempVector1.y);const i=s.background;s.background=this.backgroundColor,this.renderer.render(s,this._camera),s.background=i,this.onAfterUpdate.trigger()}getSize(){return this._size}resize(s=this._size){this._size.copy(s),this.renderer.setSize(s.x,s.y);const t=s.x/s.y,e=1;this._camera.left=e*t/-2,this._camera.right=e*t/2,this._camera.top=e/2,this._camera.bottom=-e/2,this._camera.updateProjectionMatrix(),this.onResize.trigger(s)}}const Rs=class Rs extends ${constructor(t){super(t);u(this,"onAfterUpdate",new M);u(this,"onBeforeUpdate",new M);u(this,"onDisposed",new M);u(this,"enabled",!0);u(this,"list",new Map);this.components.add(Rs.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a minimap!");const e=new Un(t);return this.list.set(t.uuid,e),e}delete(t){const e=this.list.get(t);e&&e.dispose(),this.list.delete(t)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}update(){for(const[t,e]of this.list)e.update()}};u(Rs,"uuid","39ad6aad-84c8-4adf-a1e0-7f25313a9e7f");let Ci=Rs;class bn{constructor(s){u(this,"enabled",!1);u(this,"id","FirstPerson");this.camera=s}set(s){if(this.enabled=s,s){if(this.camera.projection.current!=="Perspective"){this.camera.set("Orbit");return}this.setupFirstPersonCamera()}}setupFirstPersonCamera(){const s=this.camera.controls,t=new g.Vector3;s.distance--,s.getPosition(t),s.minDistance=1,s.maxDistance=1,s.distance=1,s.moveTo(t.x,t.y,t.z),s.truckSpeed=50,s.mouseButtons.wheel=nt.ACTION.DOLLY,s.touches.two=nt.ACTION.TOUCH_ZOOM_TRUCK}}class vn{constructor(s){u(this,"enabled",!0);u(this,"id","Orbit");this.camera=s,this.activateOrbitControls()}set(s){this.enabled=s,s&&this.activateOrbitControls()}activateOrbitControls(){const s=this.camera.controls;s.minDistance=1,s.maxDistance=300;const t=new g.Vector3;s.getPosition(t);const e=t.length();s.distance=e,s.truckSpeed=2;const{rotation:i}=this.camera.three,o=new g.Vector3(0,0,-1).applyEuler(i),n=t.addScaledVector(o,e);s.moveTo(n.x,n.y,n.z)}}class Bn{constructor(s){u(this,"enabled",!1);u(this,"id","Plan");u(this,"mouseAction1");u(this,"mouseAction2");u(this,"mouseInitialized",!1);u(this,"defaultAzimuthSpeed");u(this,"defaultPolarSpeed");this.camera=s,this.defaultAzimuthSpeed=s.controls.azimuthRotateSpeed,this.defaultPolarSpeed=s.controls.polarRotateSpeed}set(s){this.enabled=s;const t=this.camera.controls;t.azimuthRotateSpeed=s?0:this.defaultAzimuthSpeed,t.polarRotateSpeed=s?0:this.defaultPolarSpeed,this.mouseInitialized||(this.mouseAction1=t.touches.one,this.mouseAction2=t.touches.two,this.mouseInitialized=!0),s?(t.mouseButtons.left=nt.ACTION.TRUCK,t.touches.one=nt.ACTION.TOUCH_TRUCK,t.touches.two=nt.ACTION.TOUCH_ZOOM):(t.mouseButtons.left=nt.ACTION.ROTATE,t.touches.one=this.mouseAction1,t.touches.two=this.mouseAction2)}}class Vn{constructor(s){u(this,"onChanged",new M);u(this,"current","Perspective");u(this,"camera");u(this,"matchOrthoDistanceEnabled",!1);u(this,"_component");u(this,"_previousDistance",-1);this._component=s,this.camera=s.three}async set(s){this.current!==s&&(s==="Orthographic"?this.setOrthoCamera():await this.setPerspectiveCamera(),this.onChanged.trigger(this.camera))}async toggle(){const t=this.current==="Perspective"?"Orthographic":"Perspective";await this.set(t)}setOrthoCamera(){if(this._component.mode===null||this._component.mode.id==="FirstPerson")return;this._previousDistance=this._component.controls.distance,this._component.controls.distance=200;const s=this.getPerspectiveDims();if(!s)return;const{width:t,height:e}=s;this.setupOrthoCamera(e,t),this.camera=this._component.threeOrtho,this.current="Orthographic"}getPerspectiveDims(){const s=this._component.currentWorld;if(!s||!s.renderer)return null;const t=new g.Vector3;this._component.threePersp.getWorldDirection(t);const e=new g.Vector3;this._component.controls.getTarget(e);const o=e.clone().sub(this._component.threePersp.position).dot(t),n=s.renderer.getSize(),r=n.x/n.y,a=this._component.threePersp,c=o*2*Math.atan(a.fov*(Math.PI/180)/2);return{width:c*r,height:c}}setupOrthoCamera(s,t){this._component.controls.mouseButtons.wheel=nt.ACTION.ZOOM,this._component.controls.mouseButtons.middle=nt.ACTION.ZOOM;const e=this._component.threePersp,i=this._component.threeOrtho;i.zoom=1,i.left=t/-2,i.right=t/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix(),i.position.copy(e.position),i.quaternion.copy(e.quaternion),this._component.controls.camera=i}getDistance(){const s=this._component.threePersp,t=this._component.threeOrtho;return(t.top-t.bottom)/t.zoom/(2*Math.atan(s.fov*(Math.PI/180)/2))}async setPerspectiveCamera(){this._component.controls.mouseButtons.wheel=nt.ACTION.DOLLY,this._component.controls.mouseButtons.middle=nt.ACTION.DOLLY;const s=this._component.threePersp,t=this._component.threeOrtho;s.position.copy(t.position),s.quaternion.copy(t.quaternion),this._component.controls.mouseButtons.wheel=nt.ACTION.DOLLY,this.matchOrthoDistanceEnabled?this._component.controls.distance=this.getDistance():this._component.controls.distance=this._previousDistance,await this._component.controls.zoomTo(1),s.updateProjectionMatrix(),this._component.controls.camera=s,this.camera=s,this.current="Perspective"}}class Mr extends ce{constructor(t){super(t);u(this,"projection");u(this,"threeOrtho");u(this,"threePersp");u(this,"_userInputButtons",{});u(this,"_frustumSize",50);u(this,"_navigationModes",new Map);u(this,"_mode",null);u(this,"previousSize",null);this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new Vn(this),this.onAspectUpdated.add(()=>{this.setOrthoPerspCameraAspect()}),this.projection.onChanged.add(e=>{this.three=e,this.updateAspect()}),this.onWorldChanged.add(({action:e})=>{e==="added"&&(this._navigationModes.clear(),this._navigationModes.set("Orbit",new vn(this)),this._navigationModes.set("FirstPerson",new bn(this)),this._navigationModes.set("Plan",new Bn(this)),this._mode=this._navigationModes.get("Orbit"),this.mode.set(!0,{preventTargetAdjustment:!0}),this.currentWorld&&this.currentWorld.renderer&&(this.previousSize=this.currentWorld.renderer.getSize().clone()))})}get mode(){if(!this._mode)throw new Error("Mode not found, camera not initialized");return this._mode}dispose(){super.dispose(),this.threeOrtho.removeFromParent()}set(t){if(this.mode!==null&&this.mode.id!==t){if(this.mode.set(!1),!this._navigationModes.has(t))throw new Error("The specified mode does not exist!");this._mode=this._navigationModes.get(t),this.mode.set(!0)}}async fit(t,e=1.5){if(!this.enabled)return;const i=Number.MAX_VALUE,o=Number.MIN_VALUE,n=new g.Vector3(i,i,i),r=new g.Vector3(o,o,o);for(const I of t){const f=new g.Box3().setFromObject(I);f.min.x<n.x&&(n.x=f.min.x),f.min.y<n.y&&(n.y=f.min.y),f.min.z<n.z&&(n.z=f.min.z),f.max.x>r.x&&(r.x=f.max.x),f.max.y>r.y&&(r.y=f.max.y),f.max.z>r.z&&(r.z=f.max.z)}const a=new g.Box3(n,r),c=new g.Vector3;a.getSize(c);const h=new g.Vector3;a.getCenter(h);const E=Math.max(c.x,c.y,c.z)*e,d=new g.Sphere(h,E);await this.controls.fitToSphere(d,!0)}setUserInput(t){t?this.enableUserInput():this.disableUserInput()}disableUserInput(){this._userInputButtons.left=this.controls.mouseButtons.left,this._userInputButtons.right=this.controls.mouseButtons.right,this._userInputButtons.middle=this.controls.mouseButtons.middle,this._userInputButtons.wheel=this.controls.mouseButtons.wheel,this.controls.mouseButtons.left=0,this.controls.mouseButtons.right=0,this.controls.mouseButtons.middle=0,this.controls.mouseButtons.wheel=0}enableUserInput(){Object.keys(this._userInputButtons).length!==0&&(this.controls.mouseButtons.left=this._userInputButtons.left,this.controls.mouseButtons.right=this._userInputButtons.right,this.controls.mouseButtons.middle=this._userInputButtons.middle,this.controls.mouseButtons.wheel=this._userInputButtons.wheel)}newOrthoCamera(){const t=window.innerWidth/window.innerHeight;return new g.OrthographicCamera(this._frustumSize*t/-2,this._frustumSize*t/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer||!this.previousSize)return;const t=this.currentWorld.renderer.getSize(),e=this.threeOrtho.top,i=this.threeOrtho.right,o=t.y/this.previousSize.y,n=t.x/this.previousSize.x,r=e*o,a=i*n;this.threeOrtho.left=-a,this.threeOrtho.right=a,this.threeOrtho.top=r,this.threeOrtho.bottom=-r,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(t)}}const Dr=new Map([[D.IFCRELAGGREGATES,{forRelated:"Decomposes",forRelating:"IsDecomposedBy"}],[D.IFCRELASSOCIATESMATERIAL,{forRelated:"HasAssociations",forRelating:"AssociatedTo"}],[D.IFCRELASSOCIATESCLASSIFICATION,{forRelated:"HasAssociations",forRelating:"ClassificationForObjects"}],[D.IFCRELASSIGNSTOGROUP,{forRelated:"HasAssignments",forRelating:"IsGroupedBy"}],[D.IFCRELDEFINESBYPROPERTIES,{forRelated:"IsDefinedBy",forRelating:"DefinesOcurrence"}],[D.IFCRELDEFINESBYTYPE,{forRelated:"IsTypedBy",forRelating:"Types"}],[D.IFCRELDEFINESBYTEMPLATE,{forRelated:"IsDefinedBy",forRelating:"Defines"}],[D.IFCRELCONTAINEDINSPATIALSTRUCTURE,{forRelated:"ContainedInStructure",forRelating:"ContainsElements"}],[D.IFCRELFLOWCONTROLELEMENTS,{forRelated:"AssignedToFlowElement",forRelating:"HasControlElements"}],[D.IFCRELCONNECTSELEMENTS,{forRelated:"ConnectedFrom",forRelating:"ConnectedTo"}],[D.IFCRELASSIGNSTOPRODUCT,{forRelated:"HasAssignments",forRelating:"ReferencedBy"}],[D.IFCRELDECLARES,{forRelated:"HasContext",forRelating:"Declares"}],[D.IFCRELASSIGNSTOCONTROL,{forRelated:"HasAssignments",forRelating:"Controls"}],[D.IFCRELNESTS,{forRelated:"Nests",forRelating:"IsNestedBy"}]]),De=class De extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"onRelationsIndexed",new M);u(this,"relationMaps",{});u(this,"enabled",!0);u(this,"_relToAttributesMap",Dr);u(this,"_inverseAttributes",["IsDecomposedBy","Decomposes","AssociatedTo","HasAssociations","ClassificationForObjects","IsGroupedBy","HasAssignments","IsDefinedBy","DefinesOcurrence","IsTypedBy","Types","Defines","ContainedInStructure","ContainsElements","HasControlElements","AssignedToFlowElement","ConnectedTo","ConnectedFrom","ReferencedBy","Declares","HasContext","Controls","IsNestedBy","Nests"]);u(this,"_ifcRels",[D.IFCRELAGGREGATES,D.IFCRELASSOCIATESMATERIAL,D.IFCRELASSOCIATESCLASSIFICATION,D.IFCRELASSIGNSTOGROUP,D.IFCRELDEFINESBYPROPERTIES,D.IFCRELDEFINESBYTYPE,D.IFCRELDEFINESBYTEMPLATE,D.IFCRELCONTAINEDINSPATIALSTRUCTURE,D.IFCRELFLOWCONTROLELEMENTS,D.IFCRELCONNECTSELEMENTS,D.IFCRELASSIGNSTOPRODUCT,D.IFCRELDECLARES,D.IFCRELASSIGNSTOCONTROL,D.IFCRELNESTS]);u(this,"onFragmentsDisposed",t=>{delete this.relationMaps[t.groupID]});this.components.add(De.uuid,this),t.get(ot).onFragmentsDisposed.add(this.onFragmentsDisposed)}indexRelations(t,e,i,o){const n=Object.keys(e).find(d=>d.startsWith("Relating")),r=Object.keys(e).find(d=>d.startsWith("Related"));if(!(n&&r))return;const a=e[n].value,c=e[r].map(d=>d.value),h=t.get(a)??new Map,E=this.getAttributeIndex(o);E!==null&&(h.set(E,c),t.set(a,h));for(const d of c){const I=t.get(d)??new Map,f=this.getAttributeIndex(i);if(!f)continue;const T=I.get(f)??[];T.push(a),I.set(f,T),t.set(d,I)}}getAttributeIndex(t){const e=this._inverseAttributes.indexOf(t);return e===-1?null:e}setRelationMap(t,e){this.relationMaps[t.uuid]=e,this.onRelationsIndexed.trigger({modelID:t.uuid,relationsMap:e})}async process(t){if(!t.hasProperties)throw new Error("FragmentsGroup properties not found");let e=this.relationMaps[t.uuid];if(e)return e;e=new Map;for(const i of this._ifcRels){const o=await t.getAllPropertiesOfType(i);if(!o)continue;const n=this._relToAttributesMap.get(i);if(!n)continue;const{forRelated:r,forRelating:a}=n;for(const c in o){const h=o[c];this.indexRelations(e,h,r,a)}}return this.setRelationMap(t,e),e}async processFromWebIfc(t,e){const i=new Map;for(const o of this._ifcRels){const n=this._relToAttributesMap.get(o);if(!n)continue;const{forRelated:r,forRelating:a}=n,c=t.GetLineIDsWithType(e,o);for(let h=0;h<c.size();h++){const E=await t.properties.getItemProperties(e,c.get(h));this.indexRelations(i,E,r,a)}}return this.onRelationsIndexed.trigger({modelID:e.toString(),relationsMap:i}),i}getEntityRelations(t,e,i){const o=this.relationMaps[t.uuid];if(!o)throw new Error(`IfcRelationsIndexer: model ${t.uuid} has no relations indexed.`);const n=o.get(e),r=this.getAttributeIndex(i);if(n===void 0||r===null)return null;const a=n.get(r);return a||null}serializeRelations(t){const e={};for(const[i,o]of t.entries()){e[i]||(e[i]={});for(const[n,r]of o.entries())e[i][n]=r}return JSON.stringify(e)}serializeModelRelations(t){const e=this.relationMaps[t.uuid];return e?this.serializeRelations(e):null}serializeAllRelations(){const t={};for(const e in this.relationMaps){const i=this.relationMaps[e],o={};for(const[n,r]of i.entries()){o[n]||(o[n]={});for(const[a,c]of r.entries())o[n][a]=c}t[e]=o}return JSON.stringify(t)}getRelationsMapFromJSON(t){const e=JSON.parse(t),i=new Map;for(const o in e){const n=e[o],r=new Map;for(const a in n)r.set(Number(a),n[a]);i.set(Number(o),r)}return i}dispose(){this.relationMaps={},this.components.get(ot).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(De.uuid),this.onDisposed.reset()}addEntityRelations(t,e,i,...o){const n=this.getEntityRelations(t,e,i);if(n)n.push(...o);else{const r=this.getAttributeIndex(i);if(!r)throw new Error(`IfcRelationsIndexer: ${i} is not a valid relation name.`);const a=this.relationMaps[t.uuid].get(e);a==null||a.set(r,o)}}getEntityChildren(t,e,i=new Set){if(i.add(e),this.relationMaps[t.uuid]===void 0)throw new Error("The provided model has no indices. You have to generate them first.");const n=this.getEntityRelations(t,e,"IsDecomposedBy");if(n)for(const a of n)this.getEntityChildren(t,a,i);const r=this.getEntityRelations(t,e,"ContainsElements");if(r)for(const a of r)this.getEntityChildren(t,a,i);return i}};u(De,"uuid","23a889ab-83b3-44a4-8bee-ead83438370b");let Wt=De;const Fs=class Fs extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"onFragmentsLoaded",new M);u(this,"onFragmentsDisposed",new M);u(this,"list",new di);u(this,"groups",new di);u(this,"baseCoordinationModel","");u(this,"baseCoordinationMatrix",new g.Matrix4);u(this,"enabled",!0);u(this,"_loader",new pn.Serializer);this.components.add(Fs.uuid,this)}get meshes(){const t=[];for(const[e,i]of this.list)t.push(i.mesh);return t}dispose(){for(const[t,e]of this.groups)e.dispose(!0);this.baseCoordinationModel="",this.groups.clear(),this.list.clear(),this.onFragmentsLoaded.reset(),this.onFragmentsDisposed.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}disposeGroup(t){const{uuid:e}=t,i=[];for(const o of t.items)i.push(o.id),this.list.delete(o.id);t.dispose(!0),this.groups.delete(t.uuid),this.onFragmentsDisposed.trigger({groupID:e,fragmentIDs:i})}load(t,e){const o={...{coordinate:!0},...e},{coordinate:n,name:r,properties:a,relationsMap:c}=o,h=this._loader.import(t);e&&(h.isStreamed=e.isStreamed||!1),r&&(h.name=r);for(const E of h.items)E.group=h,this.list.set(E.id,E);return n&&this.coordinate([h]),this.groups.set(h.uuid,h),a&&h.setLocalProperties(a),c&&this.components.get(Wt).setRelationMap(h,c),this.onFragmentsLoaded.trigger(h),h}export(t){return this._loader.export(t)}getModelIdMap(t){const e={};for(const i in t){const o=this.list.get(i);if(!(o&&o.group))continue;const n=o.group;n.uuid in e||(e[n.uuid]=new Set);const r=t[i];for(const a of r)e[n.uuid].add(a)}return e}modelIdToFragmentIdMap(t){let e={};for(const i in t){const o=this.groups.get(i);if(!o)continue;const n=t[i],r=o.getFragmentMap(n);e={...e,...r}}return e}coordinate(t=Array.from(this.groups.values())){if(this.baseCoordinationModel.length===0){const i=t.pop();if(!i)return;this.baseCoordinationModel=i.uuid,this.baseCoordinationMatrix=i.coordinationMatrix.clone()}if(t.length)for(const i of t)i.coordinationMatrix.equals(this.baseCoordinationMatrix)||(i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),i.updateMatrix(),this.applyBaseCoordinateSystem(i,i.coordinationMatrix))}applyBaseCoordinateSystem(t,e){t.applyMatrix4(e.clone().invert()),t.applyMatrix4(this.baseCoordinationMatrix)}clone(t,e){const i=t.cloneGroup(e);this.groups.set(i.uuid,i);for(const o of i.items)this.list.set(o.id,o);return i}};u(Fs,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let ot=Fs;const Tt=class Tt extends ${constructor(t){super(t);u(this,"enabled",!0);u(this,"onDisposed",new M);u(this,"_absoluteMin");u(this,"_absoluteMax");u(this,"_meshes",[]);this.components.add(Tt.uuid,this),this._absoluteMin=Tt.newBound(!0),this._absoluteMax=Tt.newBound(!1)}static getDimensions(t){const{min:e,max:i}=t,o=Math.abs(i.x-e.x),n=Math.abs(i.y-e.y),r=Math.abs(i.z-e.z),a=new g.Vector3;return a.subVectors(i,e).divideScalar(2).add(e),{width:o,height:n,depth:r,center:a}}static newBound(t){const e=t?1:-1;return new g.Vector3(e*Number.MAX_VALUE,e*Number.MAX_VALUE,e*Number.MAX_VALUE)}static getBounds(t,e,i){const o=i||this.newBound(!1),n=e||this.newBound(!0);for(const r of t)r.x<n.x&&(n.x=r.x),r.y<n.y&&(n.y=r.y),r.z<n.z&&(n.z=r.z),r.x>o.x&&(o.x=r.x),r.y>o.y&&(o.y=r.y),r.z>o.z&&(o.z=r.z);return new g.Box3(e,i)}dispose(){const t=this.components.get(_t);for(const e of this._meshes)t.destroy(e);this._meshes=[],this.onDisposed.trigger(Tt.uuid),this.onDisposed.reset()}get(){const t=this._absoluteMin.clone(),e=this._absoluteMax.clone();return new g.Box3(t,e)}getSphere(){const t=this._absoluteMin.clone(),e=this._absoluteMax.clone(),i=Math.abs((e.x-t.x)/2),o=Math.abs((e.y-t.y)/2),n=Math.abs((e.z-t.z)/2),r=new g.Vector3(t.x+i,t.y+o,t.z+n),a=r.distanceTo(t);return new g.Sphere(r,a)}getMesh(){const t=new g.Box3(this._absoluteMin,this._absoluteMax),e=Tt.getDimensions(t),{width:i,height:o,depth:n,center:r}=e,a=new g.BoxGeometry(i,o,n),c=new g.Mesh(a);return this._meshes.push(c),c.position.copy(r),c}reset(){this._absoluteMin=Tt.newBound(!0),this._absoluteMax=Tt.newBound(!1)}add(t){for(const e of t.items)this.addMesh(e.mesh)}addMesh(t,e){if(!t.geometry.index)return;const i=Tt.getFragmentBounds(t);t.updateMatrixWorld();const o=t.matrixWorld,n=new g.Matrix4,r=t instanceof g.InstancedMesh,a=new Set;if(e&&t instanceof Dt.FragmentMesh)for(const c of e){const h=t.fragment.getInstancesIDs(c);if(h)for(const E of h)a.add(E)}else a.add(0);for(const c of a){const h=i.min.clone(),E=i.max.clone();r&&(t.getMatrixAt(c,n),h.applyMatrix4(n),E.applyMatrix4(n)),h.applyMatrix4(o),E.applyMatrix4(o),h.x<this._absoluteMin.x&&(this._absoluteMin.x=h.x),h.y<this._absoluteMin.y&&(this._absoluteMin.y=h.y),h.z<this._absoluteMin.z&&(this._absoluteMin.z=h.z),h.x>this._absoluteMax.x&&(this._absoluteMax.x=h.x),h.y>this._absoluteMax.y&&(this._absoluteMax.y=h.y),h.z>this._absoluteMax.z&&(this._absoluteMax.z=h.z),E.x>this._absoluteMax.x&&(this._absoluteMax.x=E.x),E.y>this._absoluteMax.y&&(this._absoluteMax.y=E.y),E.z>this._absoluteMax.z&&(this._absoluteMax.z=E.z),E.x<this._absoluteMin.x&&(this._absoluteMin.x=E.x),E.y<this._absoluteMin.y&&(this._absoluteMin.y=E.y),E.z<this._absoluteMin.z&&(this._absoluteMin.z=E.z)}}addFragmentIdMap(t){const e=this.components.get(ot);for(const i in t){const o=e.list.get(i);if(!o)continue;const n=t[i];this.addMesh(o.mesh,n)}}static getFragmentBounds(t){const e=t.geometry.attributes.position,i=Number.MAX_VALUE,o=-i,n=new g.Vector3(i,i,i),r=new g.Vector3(o,o,o);if(!t.geometry.index)throw new Error("Geometry must be indexed!");const a=Array.from(t.geometry.index.array);for(let c=0;c<a.length;c++){if(c%3===0&&a[c]===0&&a[c+1]===0&&a[c+2]===0){c+=2;continue}const h=a[c],E=e.getX(h),d=e.getY(h),I=e.getZ(h);E<n.x&&(n.x=E),d<n.y&&(n.y=d),I<n.z&&(n.z=I),E>r.x&&(r.x=E),d>r.y&&(r.y=d),I>r.z&&(r.z=I)}return new g.Box3(n,r)}};u(Tt,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Ti=Tt;const Li=new Set([1123145078,574549367,1675464909,2059837836,3798115385,32440307,3125803723,3207858831,2740243338,2624227202,4240577450,3615266464,3724593414,220341763,477187591,1878645084,1300840506,3303107099,1607154358,1878645084,846575682,1351298697,2417041796,3049322572,3331915920,1416205885,776857604,3285139300,3958052878,2827736869,2732653382,673634403,3448662350,4142052618,2924175390,803316827,2556980723,1809719519,2205249479,807026263,3737207727,1660063152,2347385850,2705031697,3732776249,2485617015,2611217952,1704287377,2937912522,2770003689,1281925730,1484403080,3448662350,4142052618,3800577675,4006246654,3590301190,1383045692,2775532180,2047409740,370225590,3593883385,2665983363,4124623270,812098782,3649129432,987898635,1105321065,3510044353,1635779807,2603310189,3406155212,1310608509,4261334040,2736907675,3649129432,1136057603,1260505505,4182860854,2713105998,2898889636,59481748,3749851601,3486308946,3150382593,1062206242,3264961684,15328376,1485152156,370225590,1981873012,2859738748,45288368,2614616156,2732653382,775493141,2147822146,2601014836,2629017746,1186437898,2367409068,1213902940,3632507154,3900360178,476780140,1472233963,2804161546,3008276851,738692330,374418227,315944413,3905492369,3570813810,2571569899,178912537,2294589976,1437953363,2133299955,572779678,3092502836,388784114,2624227202,1425443689,3057273783,2347385850,1682466193,2519244187,2839578677,3958567839,2513912981,2830218821,427810014]),As=class As extends ${constructor(t){super(t);u(this,"enabled",!0);t.add(As.uuid,this)}async export(t,e,i=!1,o=!0){const n={},r=new Set(t.GetIfcEntityList(e)),a=new Set([D.IFCPROJECT,D.IFCSITE,D.IFCBUILDING,D.IFCBUILDINGSTOREY,D.IFCSPACE]);for(const c of a)r.add(c);for(const c of r){if(Li.has(c))continue;const h=a.has(c)&&o,E=t.GetLineIDsWithType(e,c);for(const d of E){const I=t.GetLine(0,d,h,i);n[I.expressID]=I}}return n}};u(As,"uuid","b32c4332-cd67-436e-ba7f-196646c7a635");let us=As;const Yn={103090709:"IFCPROJECT",4097777520:"IFCSITE",4031249490:"IFCBUILDING",3124254112:"IFCBUILDINGSTOREY",3856911033:"IFCSPACE",1674181508:"IFCANNOTATION",25142252:"IFCCONTROLLER",32344328:"IFCBOILER",76236018:"IFCLAMP",90941305:"IFCPUMP",177149247:"IFCAIRTERMINALBOX",182646315:"IFCFLOWINSTRUMENT",263784265:"IFCFURNISHINGELEMENT",264262732:"IFCELECTRICGENERATOR",277319702:"IFCAUDIOVISUALAPPLIANCE",310824031:"IFCPIPEFITTING",331165859:"IFCSTAIR",342316401:"IFCDUCTFITTING",377706215:"IFCMECHANICALFASTENER",395920057:"IFCDOOR",402227799:"IFCELECTRICMOTOR",413509423:"IFCSYSTEMFURNITUREELEMENT",484807127:"IFCEVAPORATOR",486154966:"IFCWINDOWSTANDARDCASE",629592764:"IFCLIGHTFIXTURE",630975310:"IFCUNITARYCONTROLELEMENT",635142910:"IFCCABLECARRIERFITTING",639361253:"IFCCOIL",647756555:"IFCFASTENER",707683696:"IFCFLOWSTORAGEDEVICE",738039164:"IFCPROTECTIVEDEVICE",753842376:"IFCBEAM",812556717:"IFCTANK",819412036:"IFCFILTER",843113511:"IFCCOLUMN",862014818:"IFCELECTRICDISTRIBUTIONBOARD",900683007:"IFCFOOTING",905975707:"IFCCOLUMNSTANDARDCASE",926996030:"IFCVOIDINGFEATURE",979691226:"IFCREINFORCINGBAR",987401354:"IFCFLOWSEGMENT",1003880860:"IFCELECTRICTIMECONTROL",1051757585:"IFCCABLEFITTING",1052013943:"IFCDISTRIBUTIONCHAMBERELEMENT",1062813311:"IFCDISTRIBUTIONCONTROLELEMENT",1073191201:"IFCMEMBER",1095909175:"IFCBUILDINGELEMENTPROXY",1156407060:"IFCPLATESTANDARDCASE",1162798199:"IFCSWITCHINGDEVICE",1329646415:"IFCSHADINGDEVICE",1335981549:"IFCDISCRETEACCESSORY",1360408905:"IFCDUCTSILENCER",1404847402:"IFCSTACKTERMINAL",1426591983:"IFCFIRESUPPRESSIONTERMINAL",1437502449:"IFCMEDICALDEVICE",1509553395:"IFCFURNITURE",1529196076:"IFCSLAB",1620046519:"IFCTRANSPORTELEMENT",1634111441:"IFCAIRTERMINAL",1658829314:"IFCENERGYCONVERSIONDEVICE",1677625105:"IFCCIVILELEMENT",1687234759:"IFCPILE",1904799276:"IFCELECTRICAPPLIANCE",1911478936:"IFCMEMBERSTANDARDCASE",1945004755:"IFCDISTRIBUTIONELEMENT",1973544240:"IFCCOVERING",1999602285:"IFCSPACEHEATER",2016517767:"IFCROOF",2056796094:"IFCAIRTOAIRHEATRECOVERY",2058353004:"IFCFLOWCONTROLLER",2068733104:"IFCHUMIDIFIER",2176052936:"IFCJUNCTIONBOX",2188021234:"IFCFLOWMETER",2223149337:"IFCFLOWTERMINAL",2262370178:"IFCRAILING",2272882330:"IFCCONDENSER",2295281155:"IFCPROTECTIVEDEVICETRIPPINGUNIT",2320036040:"IFCREINFORCINGMESH",2347447852:"IFCTENDONANCHOR",2391383451:"IFCVIBRATIONISOLATOR",2391406946:"IFCWALL",2474470126:"IFCMOTORCONNECTION",2769231204:"IFCVIRTUALELEMENT",2814081492:"IFCENGINE",2906023776:"IFCBEAMSTANDARDCASE",2938176219:"IFCBURNER",2979338954:"IFCBUILDINGELEMENTPART",3024970846:"IFCRAMP",3026737570:"IFCTUBEBUNDLE",3027962421:"IFCSLABSTANDARDCASE",3040386961:"IFCDISTRIBUTIONFLOWELEMENT",3053780830:"IFCSANITARYTERMINAL",3079942009:"IFCOPENINGSTANDARDCASE",3087945054:"IFCALARM",3101698114:"IFCSURFACEFEATURE",3127900445:"IFCSLABELEMENTEDCASE",3132237377:"IFCFLOWMOVINGDEVICE",3171933400:"IFCPLATE",3221913625:"IFCCOMMUNICATIONSAPPLIANCE",3242481149:"IFCDOORSTANDARDCASE",3283111854:"IFCRAMPFLIGHT",3296154744:"IFCCHIMNEY",3304561284:"IFCWINDOW",3310460725:"IFCELECTRICFLOWSTORAGEDEVICE",3319311131:"IFCHEATEXCHANGER",3415622556:"IFCFAN",3420628829:"IFCSOLARDEVICE",3493046030:"IFCGEOGRAPHICELEMENT",3495092785:"IFCCURTAINWALL",3508470533:"IFCFLOWTREATMENTDEVICE",3512223829:"IFCWALLSTANDARDCASE",3518393246:"IFCDUCTSEGMENT",3571504051:"IFCCOMPRESSOR",3588315303:"IFCOPENINGELEMENT",3612865200:"IFCPIPESEGMENT",3640358203:"IFCCOOLINGTOWER",3651124850:"IFCPROJECTIONELEMENT",3694346114:"IFCOUTLET",3747195512:"IFCEVAPORATIVECOOLER",3758799889:"IFCCABLECARRIERSEGMENT",3824725483:"IFCTENDON",3825984169:"IFCTRANSFORMER",3902619387:"IFCCHILLER",4074379575:"IFCDAMPER",4086658281:"IFCSENSOR",4123344466:"IFCELEMENTASSEMBLY",4136498852:"IFCCOOLEDBEAM",4156078855:"IFCWALLELEMENTEDCASE",4175244083:"IFCINTERCEPTOR",4207607924:"IFCVALVE",4217484030:"IFCCABLESEGMENT",4237592921:"IFCWASTETERMINAL",4252922144:"IFCSTAIRFLIGHT",4278956645:"IFCFLOWFITTING",4288193352:"IFCACTUATOR",4292641817:"IFCUNITARYEQUIPMENT",3009204131:"IFCGRID"};class xr{getAll(s,t){const e={},i=Object.keys(Yn).map(o=>parseInt(o,10));for(let o=0;o<i.length;o++){const n=i[o],r=s.GetLineIDsWithType(t,n),a=r.size();for(let c=0;c<a;c++)e[r.get(c)]=n}return e}}const Pi={950732822:"IFCURIREFERENCE",4075327185:"IFCTIME",1209108979:"IFCTEMPERATURERATEOFCHANGEMEASURE",3457685358:"IFCSOUNDPRESSURELEVELMEASURE",4157543285:"IFCSOUNDPOWERLEVELMEASURE",2798247006:"IFCPROPERTYSETDEFINITIONSET",1790229001:"IFCPOSITIVEINTEGER",525895558:"IFCNONNEGATIVELENGTHMEASURE",1774176899:"IFCLINEINDEX",1275358634:"IFCLANGUAGEID",2541165894:"IFCDURATION",3701338814:"IFCDAYINWEEKNUMBER",2195413836:"IFCDATETIME",937566702:"IFCDATE",1683019596:"IFCCARDINALPOINTREFERENCE",2314439260:"IFCBINARY",1500781891:"IFCAREADENSITYMEASURE",3683503648:"IFCARCINDEX",4065007721:"IFCYEARNUMBER",1718600412:"IFCWARPINGMOMENTMEASURE",51269191:"IFCWARPINGCONSTANTMEASURE",2593997549:"IFCVOLUMETRICFLOWRATEMEASURE",3458127941:"IFCVOLUMEMEASURE",3345633955:"IFCVAPORPERMEABILITYMEASURE",1278329552:"IFCTORQUEMEASURE",2591213694:"IFCTIMESTAMP",2726807636:"IFCTIMEMEASURE",743184107:"IFCTHERMODYNAMICTEMPERATUREMEASURE",2016195849:"IFCTHERMALTRANSMITTANCEMEASURE",857959152:"IFCTHERMALRESISTANCEMEASURE",2281867870:"IFCTHERMALEXPANSIONCOEFFICIENTMEASURE",2645777649:"IFCTHERMALCONDUCTIVITYMEASURE",232962298:"IFCTHERMALADMITTANCEMEASURE",296282323:"IFCTEXTTRANSFORMATION",603696268:"IFCTEXTFONTNAME",3490877962:"IFCTEXTDECORATION",1460886941:"IFCTEXTALIGNMENT",2801250643:"IFCTEXT",58845555:"IFCTEMPERATUREGRADIENTMEASURE",361837227:"IFCSPECULARROUGHNESS",2757832317:"IFCSPECULAREXPONENT",3477203348:"IFCSPECIFICHEATCAPACITYMEASURE",993287707:"IFCSOUNDPRESSUREMEASURE",846465480:"IFCSOUNDPOWERMEASURE",3471399674:"IFCSOLIDANGLEMEASURE",408310005:"IFCSHEARMODULUSMEASURE",2190458107:"IFCSECTIONALAREAINTEGRALMEASURE",3467162246:"IFCSECTIONMODULUSMEASURE",2766185779:"IFCSECONDINMINUTE",3211557302:"IFCROTATIONALSTIFFNESSMEASURE",1755127002:"IFCROTATIONALMASSMEASURE",2133746277:"IFCROTATIONALFREQUENCYMEASURE",200335297:"IFCREAL",96294661:"IFCRATIOMEASURE",3972513137:"IFCRADIOACTIVITYMEASURE",3665567075:"IFCPRESSUREMEASURE",2169031380:"IFCPRESENTABLETEXT",1364037233:"IFCPOWERMEASURE",1245737093:"IFCPOSITIVERATIOMEASURE",3054510233:"IFCPOSITIVEPLANEANGLEMEASURE",2815919920:"IFCPOSITIVELENGTHMEASURE",4042175685:"IFCPLANEANGLEMEASURE",2642773653:"IFCPLANARFORCEMEASURE",2260317790:"IFCPARAMETERVALUE",929793134:"IFCPHMEASURE",2395907400:"IFCNUMERICMEASURE",2095195183:"IFCNORMALISEDRATIOMEASURE",765770214:"IFCMONTHINYEARNUMBER",2615040989:"IFCMONETARYMEASURE",3114022597:"IFCMOMENTOFINERTIAMEASURE",1648970520:"IFCMOLECULARWEIGHTMEASURE",3177669450:"IFCMOISTUREDIFFUSIVITYMEASURE",1753493141:"IFCMODULUSOFSUBGRADEREACTIONMEASURE",1052454078:"IFCMODULUSOFROTATIONALSUBGRADEREACTIONMEASURE",2173214787:"IFCMODULUSOFLINEARSUBGRADEREACTIONMEASURE",3341486342:"IFCMODULUSOFELASTICITYMEASURE",102610177:"IFCMINUTEINHOUR",3531705166:"IFCMASSPERLENGTHMEASURE",3124614049:"IFCMASSMEASURE",4017473158:"IFCMASSFLOWRATEMEASURE",1477762836:"IFCMASSDENSITYMEASURE",2486716878:"IFCMAGNETICFLUXMEASURE",286949696:"IFCMAGNETICFLUXDENSITYMEASURE",151039812:"IFCLUMINOUSINTENSITYMEASURE",2755797622:"IFCLUMINOUSINTENSITYDISTRIBUTIONMEASURE",2095003142:"IFCLUMINOUSFLUXMEASURE",503418787:"IFCLOGICAL",3086160713:"IFCLINEARVELOCITYMEASURE",1307019551:"IFCLINEARSTIFFNESSMEASURE",2128979029:"IFCLINEARMOMENTMEASURE",191860431:"IFCLINEARFORCEMEASURE",1243674935:"IFCLENGTHMEASURE",3258342251:"IFCLABEL",2054016361:"IFCKINEMATICVISCOSITYMEASURE",3192672207:"IFCISOTHERMALMOISTURECAPACITYMEASURE",3686016028:"IFCIONCONCENTRATIONMEASURE",3809634241:"IFCINTEGERCOUNTRATEMEASURE",1939436016:"IFCINTEGER",2679005408:"IFCINDUCTANCEMEASURE",3358199106:"IFCILLUMINANCEMEASURE",983778844:"IFCIDENTIFIER",2589826445:"IFCHOURINDAY",1158859006:"IFCHEATINGVALUEMEASURE",3113092358:"IFCHEATFLUXDENSITYMEASURE",3064340077:"IFCGLOBALLYUNIQUEID",3044325142:"IFCFREQUENCYMEASURE",1361398929:"IFCFORCEMEASURE",2590844177:"IFCFONTWEIGHT",2715512545:"IFCFONTVARIANT",1102727119:"IFCFONTSTYLE",2078135608:"IFCENERGYMEASURE",2506197118:"IFCELECTRICVOLTAGEMEASURE",2951915441:"IFCELECTRICRESISTANCEMEASURE",3790457270:"IFCELECTRICCURRENTMEASURE",2093906313:"IFCELECTRICCONDUCTANCEMEASURE",3818826038:"IFCELECTRICCHARGEMEASURE",1827137117:"IFCELECTRICCAPACITANCEMEASURE",69416015:"IFCDYNAMICVISCOSITYMEASURE",524656162:"IFCDOSEEQUIVALENTMEASURE",4134073009:"IFCDIMENSIONCOUNT",1514641115:"IFCDESCRIPTIVEMEASURE",300323983:"IFCDAYLIGHTSAVINGHOUR",86635668:"IFCDAYINMONTHNUMBER",94842927:"IFCCURVATUREMEASURE",1778710042:"IFCCOUNTMEASURE",3238673880:"IFCCONTEXTDEPENDENTMEASURE",3812528620:"IFCCOMPOUNDPLANEANGLEMEASURE",2991860651:"IFCCOMPLEXNUMBER",1867003952:"IFCBOXALIGNMENT",2735952531:"IFCBOOLEAN",2650437152:"IFCAREAMEASURE",632304761:"IFCANGULARVELOCITYMEASURE",360377573:"IFCAMOUNTOFSUBSTANCEMEASURE",4182062534:"IFCACCELERATIONMEASURE",3699917729:"IFCABSORBEDDOSEMEASURE",1971632696:"IFCGEOSLICE",2680139844:"IFCGEOMODEL",24726584:"IFCELECTRICFLOWTREATMENTDEVICE",3693000487:"IFCDISTRIBUTIONBOARD",3460952963:"IFCCONVEYORSEGMENT",3999819293:"IFCCAISSONFOUNDATION",3314249567:"IFCBOREHOLE",4196446775:"IFCBEARING",325726236:"IFCALIGNMENT",3425753595:"IFCTRACKELEMENT",991950508:"IFCSIGNAL",3798194928:"IFCREINFORCEDSOIL",3290496277:"IFCRAIL",1383356374:"IFCPAVEMENT",2182337498:"IFCNAVIGATIONELEMENT",234836483:"IFCMOORINGDEVICE",2078563270:"IFCMOBILETELECOMMUNICATIONSAPPLIANCE",1638804497:"IFCLIQUIDTERMINAL",1154579445:"IFCLINEARPOSITIONINGELEMENT",2696325953:"IFCKERB",2713699986:"IFCGEOTECHNICALASSEMBLY",2142170206:"IFCELECTRICFLOWTREATMENTDEVICETYPE",3376911765:"IFCEARTHWORKSFILL",1077100507:"IFCEARTHWORKSELEMENT",3071239417:"IFCEARTHWORKSCUT",479945903:"IFCDISTRIBUTIONBOARDTYPE",3426335179:"IFCDEEPFOUNDATION",1502416096:"IFCCOURSE",2940368186:"IFCCONVEYORSEGMENTTYPE",3203706013:"IFCCAISSONFOUNDATIONTYPE",3862327254:"IFCBUILTSYSTEM",1876633798:"IFCBUILTELEMENT",963979645:"IFCBRIDGEPART",644574406:"IFCBRIDGE",3649138523:"IFCBEARINGTYPE",1662888072:"IFCALIGNMENTVERTICAL",317615605:"IFCALIGNMENTSEGMENT",1545765605:"IFCALIGNMENTHORIZONTAL",4266260250:"IFCALIGNMENTCANT",3956297820:"IFCVIBRATIONDAMPERTYPE",1530820697:"IFCVIBRATIONDAMPER",840318589:"IFCVEHICLE",1953115116:"IFCTRANSPORTATIONDEVICE",618700268:"IFCTRACKELEMENTTYPE",2281632017:"IFCTENDONCONDUITTYPE",3663046924:"IFCTENDONCONDUIT",42703149:"IFCSINESPIRAL",1894708472:"IFCSIGNALTYPE",3599934289:"IFCSIGNTYPE",33720170:"IFCSIGN",1027922057:"IFCSEVENTHORDERPOLYNOMIALSPIRAL",544395925:"IFCSEGMENTEDREFERENCECURVE",3649235739:"IFCSECONDORDERPOLYNOMIALSPIRAL",550521510:"IFCROADPART",146592293:"IFCROAD",3818125796:"IFCRELADHERESTOELEMENT",4021432810:"IFCREFERENT",1891881377:"IFCRAILWAYPART",3992365140:"IFCRAILWAY",1763565496:"IFCRAILTYPE",1946335990:"IFCPOSITIONINGELEMENT",514975943:"IFCPAVEMENTTYPE",506776471:"IFCNAVIGATIONELEMENTTYPE",710110818:"IFCMOORINGDEVICETYPE",1950438474:"IFCMOBILETELECOMMUNICATIONSAPPLIANCETYPE",976884017:"IFCMARINEPART",525669439:"IFCMARINEFACILITY",1770583370:"IFCLIQUIDTERMINALTYPE",2176059722:"IFCLINEARELEMENT",679976338:"IFCKERBTYPE",3948183225:"IFCIMPACTPROTECTIONDEVICETYPE",2568555532:"IFCIMPACTPROTECTIONDEVICE",2898700619:"IFCGRADIENTCURVE",1594536857:"IFCGEOTECHNICALSTRATUM",4230923436:"IFCGEOTECHNICALELEMENT",4228831410:"IFCFACILITYPARTCOMMON",1310830890:"IFCFACILITYPART",24185140:"IFCFACILITY",4234616927:"IFCDIRECTRIXDERIVEDREFERENCESWEPTAREASOLID",1306400036:"IFCDEEPFOUNDATIONTYPE",4189326743:"IFCCOURSETYPE",2000195564:"IFCCOSINESPIRAL",3497074424:"IFCCLOTHOID",1626504194:"IFCBUILTELEMENTTYPE",3651464721:"IFCVEHICLETYPE",1229763772:"IFCTRIANGULATEDIRREGULARNETWORK",3665877780:"IFCTRANSPORTATIONDEVICETYPE",782932809:"IFCTHIRDORDERPOLYNOMIALSPIRAL",2735484536:"IFCSPIRAL",1356537516:"IFCSECTIONEDSURFACE",1290935644:"IFCSECTIONEDSOLIDHORIZONTAL",1862484736:"IFCSECTIONEDSOLID",1441486842:"IFCRELPOSITIONS",1033248425:"IFCRELASSOCIATESPROFILEDEF",3381221214:"IFCPOLYNOMIALCURVE",2485787929:"IFCOFFSETCURVEBYDISTANCES",590820931:"IFCOFFSETCURVE",3465909080:"IFCINDEXEDPOLYGONALTEXTUREMAP",593015953:"IFCDIRECTRIXCURVESWEPTAREASOLID",4212018352:"IFCCURVESEGMENT",3425423356:"IFCAXIS2PLACEMENTLINEAR",823603102:"IFCSEGMENT",2165702409:"IFCPOINTBYDISTANCEEXPRESSION",182550632:"IFCOPENCROSSPROFILEDEF",388784114:"IFCLINEARPLACEMENT",536804194:"IFCALIGNMENTHORIZONTALSEGMENT",3752311538:"IFCALIGNMENTCANTSEGMENT",1010789467:"IFCTEXTURECOORDINATEINDICESWITHVOIDS",222769930:"IFCTEXTURECOORDINATEINDICES",2691318326:"IFCQUANTITYNUMBER",3633395639:"IFCALIGNMENTVERTICALSEGMENT",2879124712:"IFCALIGNMENTPARAMETERSEGMENT",25142252:"IFCCONTROLLER",3087945054:"IFCALARM",4288193352:"IFCACTUATOR",630975310:"IFCUNITARYCONTROLELEMENT",4086658281:"IFCSENSOR",2295281155:"IFCPROTECTIVEDEVICETRIPPINGUNIT",182646315:"IFCFLOWINSTRUMENT",1426591983:"IFCFIRESUPPRESSIONTERMINAL",819412036:"IFCFILTER",3415622556:"IFCFAN",1003880860:"IFCELECTRICTIMECONTROL",402227799:"IFCELECTRICMOTOR",264262732:"IFCELECTRICGENERATOR",3310460725:"IFCELECTRICFLOWSTORAGEDEVICE",862014818:"IFCELECTRICDISTRIBUTIONBOARD",1904799276:"IFCELECTRICAPPLIANCE",1360408905:"IFCDUCTSILENCER",3518393246:"IFCDUCTSEGMENT",342316401:"IFCDUCTFITTING",562808652:"IFCDISTRIBUTIONCIRCUIT",4074379575:"IFCDAMPER",3640358203:"IFCCOOLINGTOWER",4136498852:"IFCCOOLEDBEAM",2272882330:"IFCCONDENSER",3571504051:"IFCCOMPRESSOR",3221913625:"IFCCOMMUNICATIONSAPPLIANCE",639361253:"IFCCOIL",3902619387:"IFCCHILLER",4217484030:"IFCCABLESEGMENT",1051757585:"IFCCABLEFITTING",3758799889:"IFCCABLECARRIERSEGMENT",635142910:"IFCCABLECARRIERFITTING",2938176219:"IFCBURNER",32344328:"IFCBOILER",2906023776:"IFCBEAMSTANDARDCASE",277319702:"IFCAUDIOVISUALAPPLIANCE",2056796094:"IFCAIRTOAIRHEATRECOVERY",177149247:"IFCAIRTERMINALBOX",1634111441:"IFCAIRTERMINAL",486154966:"IFCWINDOWSTANDARDCASE",4237592921:"IFCWASTETERMINAL",4156078855:"IFCWALLELEMENTEDCASE",4207607924:"IFCVALVE",4292641817:"IFCUNITARYEQUIPMENT",3179687236:"IFCUNITARYCONTROLELEMENTTYPE",3026737570:"IFCTUBEBUNDLE",3825984169:"IFCTRANSFORMER",812556717:"IFCTANK",1162798199:"IFCSWITCHINGDEVICE",385403989:"IFCSTRUCTURALLOADCASE",1404847402:"IFCSTACKTERMINAL",1999602285:"IFCSPACEHEATER",3420628829:"IFCSOLARDEVICE",3027962421:"IFCSLABSTANDARDCASE",3127900445:"IFCSLABELEMENTEDCASE",1329646415:"IFCSHADINGDEVICE",3053780830:"IFCSANITARYTERMINAL",2572171363:"IFCREINFORCINGBARTYPE",1232101972:"IFCRATIONALBSPLINECURVEWITHKNOTS",90941305:"IFCPUMP",655969474:"IFCPROTECTIVEDEVICETRIPPINGUNITTYPE",738039164:"IFCPROTECTIVEDEVICE",1156407060:"IFCPLATESTANDARDCASE",3612865200:"IFCPIPESEGMENT",310824031:"IFCPIPEFITTING",3694346114:"IFCOUTLET",144952367:"IFCOUTERBOUNDARYCURVE",2474470126:"IFCMOTORCONNECTION",1911478936:"IFCMEMBERSTANDARDCASE",1437502449:"IFCMEDICALDEVICE",629592764:"IFCLIGHTFIXTURE",76236018:"IFCLAMP",2176052936:"IFCJUNCTIONBOX",4175244083:"IFCINTERCEPTOR",2068733104:"IFCHUMIDIFIER",3319311131:"IFCHEATEXCHANGER",2188021234:"IFCFLOWMETER",1209101575:"IFCEXTERNALSPATIALELEMENT",484807127:"IFCEVAPORATOR",3747195512:"IFCEVAPORATIVECOOLER",2814081492:"IFCENGINE",2417008758:"IFCELECTRICDISTRIBUTIONBOARDTYPE",3242481149:"IFCDOORSTANDARDCASE",3205830791:"IFCDISTRIBUTIONSYSTEM",400855858:"IFCCOMMUNICATIONSAPPLIANCETYPE",905975707:"IFCCOLUMNSTANDARDCASE",1677625105:"IFCCIVILELEMENT",3296154744:"IFCCHIMNEY",2674252688:"IFCCABLEFITTINGTYPE",2188180465:"IFCBURNERTYPE",1177604601:"IFCBUILDINGSYSTEM",39481116:"IFCBUILDINGELEMENTPARTTYPE",1136057603:"IFCBOUNDARYCURVE",2461110595:"IFCBSPLINECURVEWITHKNOTS",1532957894:"IFCAUDIOVISUALAPPLIANCETYPE",4088093105:"IFCWORKCALENDAR",4009809668:"IFCWINDOWTYPE",926996030:"IFCVOIDINGFEATURE",2391383451:"IFCVIBRATIONISOLATOR",2415094496:"IFCTENDONTYPE",3081323446:"IFCTENDONANCHORTYPE",413509423:"IFCSYSTEMFURNITUREELEMENT",3101698114:"IFCSURFACEFEATURE",3657597509:"IFCSTRUCTURALSURFACEACTION",2757150158:"IFCSTRUCTURALCURVEREACTION",1004757350:"IFCSTRUCTURALCURVEACTION",338393293:"IFCSTAIRTYPE",1072016465:"IFCSOLARDEVICETYPE",4074543187:"IFCSHADINGDEVICETYPE",2157484638:"IFCSEAMCURVE",2781568857:"IFCROOFTYPE",2310774935:"IFCREINFORCINGMESHTYPE",964333572:"IFCREINFORCINGELEMENTTYPE",683857671:"IFCRATIONALBSPLINESURFACEWITHKNOTS",1469900589:"IFCRAMPTYPE",2839578677:"IFCPOLYGONALFACESET",1158309216:"IFCPILETYPE",3079942009:"IFCOPENINGSTANDARDCASE",1114901282:"IFCMEDICALDEVICETYPE",3113134337:"IFCINTERSECTIONCURVE",3946677679:"IFCINTERCEPTORTYPE",2571569899:"IFCINDEXEDPOLYCURVE",3493046030:"IFCGEOGRAPHICELEMENT",1509553395:"IFCFURNITURE",1893162501:"IFCFOOTINGTYPE",2853485674:"IFCEXTERNALSPATIALSTRUCTUREELEMENT",4148101412:"IFCEVENT",132023988:"IFCENGINETYPE",2397081782:"IFCELEMENTASSEMBLYTYPE",2323601079:"IFCDOORTYPE",1213902940:"IFCCYLINDRICALSURFACE",1525564444:"IFCCONSTRUCTIONPRODUCTRESOURCETYPE",4105962743:"IFCCONSTRUCTIONMATERIALRESOURCETYPE",2185764099:"IFCCONSTRUCTIONEQUIPMENTRESOURCETYPE",15328376:"IFCCOMPOSITECURVEONSURFACE",3875453745:"IFCCOMPLEXPROPERTYTEMPLATE",3893394355:"IFCCIVILELEMENTTYPE",2197970202:"IFCCHIMNEYTYPE",167062518:"IFCBSPLINESURFACEWITHKNOTS",2887950389:"IFCBSPLINESURFACE",2603310189:"IFCADVANCEDBREPWITHVOIDS",1635779807:"IFCADVANCEDBREP",2916149573:"IFCTRIANGULATEDFACESET",1935646853:"IFCTOROIDALSURFACE",2387106220:"IFCTESSELLATEDFACESET",3206491090:"IFCTASKTYPE",699246055:"IFCSURFACECURVE",4095615324:"IFCSUBCONTRACTRESOURCETYPE",603775116:"IFCSTRUCTURALSURFACEREACTION",4015995234:"IFCSPHERICALSURFACE",2481509218:"IFCSPATIALZONETYPE",463610769:"IFCSPATIALZONE",710998568:"IFCSPATIALELEMENTTYPE",1412071761:"IFCSPATIALELEMENT",3663146110:"IFCSIMPLEPROPERTYTEMPLATE",3243963512:"IFCREVOLVEDAREASOLIDTAPERED",816062949:"IFCREPARAMETRISEDCOMPOSITECURVESEGMENT",1521410863:"IFCRELSPACEBOUNDARY2NDLEVEL",3523091289:"IFCRELSPACEBOUNDARY1STLEVEL",427948657:"IFCRELINTERFERESELEMENTS",307848117:"IFCRELDEFINESBYTEMPLATE",1462361463:"IFCRELDEFINESBYOBJECT",2565941209:"IFCRELDECLARES",1027710054:"IFCRELASSIGNSTOGROUPBYFACTOR",3521284610:"IFCPROPERTYTEMPLATE",492091185:"IFCPROPERTYSETTEMPLATE",653396225:"IFCPROJECTLIBRARY",569719735:"IFCPROCEDURETYPE",3967405729:"IFCPREDEFINEDPROPERTYSET",1682466193:"IFCPCURVE",428585644:"IFCLABORRESOURCETYPE",2294589976:"IFCINDEXEDPOLYGONALFACEWITHVOIDS",178912537:"IFCINDEXEDPOLYGONALFACE",4095422895:"IFCGEOGRAPHICELEMENTTYPE",2652556860:"IFCFIXEDREFERENCESWEPTAREASOLID",2804161546:"IFCEXTRUDEDAREASOLIDTAPERED",4024345920:"IFCEVENTTYPE",2629017746:"IFCCURVEBOUNDEDSURFACE",1815067380:"IFCCREWRESOURCETYPE",3419103109:"IFCCONTEXT",2574617495:"IFCCONSTRUCTIONRESOURCETYPE",2059837836:"IFCCARTESIANPOINTLIST3D",1675464909:"IFCCARTESIANPOINTLIST2D",574549367:"IFCCARTESIANPOINTLIST",3406155212:"IFCADVANCEDFACE",3698973494:"IFCTYPERESOURCE",3736923433:"IFCTYPEPROCESS",901063453:"IFCTESSELLATEDITEM",1096409881:"IFCSWEPTDISKSOLIDPOLYGONAL",1042787934:"IFCRESOURCETIME",1608871552:"IFCRESOURCECONSTRAINTRELATIONSHIP",2943643501:"IFCRESOURCEAPPROVALRELATIONSHIP",2090586900:"IFCQUANTITYSET",1482703590:"IFCPROPERTYTEMPLATEDEFINITION",3778827333:"IFCPREDEFINEDPROPERTIES",2998442950:"IFCMIRROREDPROFILEDEF",853536259:"IFCMATERIALRELATIONSHIP",3404854881:"IFCMATERIALPROFILESETUSAGETAPERING",3079605661:"IFCMATERIALPROFILESETUSAGE",2852063980:"IFCMATERIALCONSTITUENTSET",3708119e3:"IFCMATERIALCONSTITUENT",1585845231:"IFCLAGTIME",2133299955:"IFCINDEXEDTRIANGLETEXTUREMAP",1437953363:"IFCINDEXEDTEXTUREMAP",3570813810:"IFCINDEXEDCOLOURMAP",1437805879:"IFCEXTERNALREFERENCERELATIONSHIP",297599258:"IFCEXTENDEDPROPERTIES",211053100:"IFCEVENTTIME",2713554722:"IFCCONVERSIONBASEDUNITWITHOFFSET",3285139300:"IFCCOLOURRGBLIST",1236880293:"IFCWORKTIME",1199560280:"IFCTIMEPERIOD",3611470254:"IFCTEXTUREVERTEXLIST",2771591690:"IFCTASKTIMERECURRING",1549132990:"IFCTASKTIME",2043862942:"IFCTABLECOLUMN",2934153892:"IFCSURFACEREINFORCEMENTAREA",609421318:"IFCSTRUCTURALLOADORRESULT",3478079324:"IFCSTRUCTURALLOADCONFIGURATION",1054537805:"IFCSCHEDULINGTIME",2439245199:"IFCRESOURCELEVELRELATIONSHIP",2433181523:"IFCREFERENCE",3915482550:"IFCRECURRENCEPATTERN",986844984:"IFCPROPERTYABSTRACTION",3843373140:"IFCPROJECTEDCRS",677532197:"IFCPRESENTATIONITEM",1507914824:"IFCMATERIALUSAGEDEFINITION",552965576:"IFCMATERIALPROFILEWITHOFFSETS",164193824:"IFCMATERIALPROFILESET",2235152071:"IFCMATERIALPROFILE",1847252529:"IFCMATERIALLAYERWITHOFFSETS",760658860:"IFCMATERIALDEFINITION",3057273783:"IFCMAPCONVERSION",4294318154:"IFCEXTERNALINFORMATION",1466758467:"IFCCOORDINATEREFERENCESYSTEM",1785450214:"IFCCOORDINATEOPERATION",775493141:"IFCCONNECTIONVOLUMEGEOMETRY",979691226:"IFCREINFORCINGBAR",3700593921:"IFCELECTRICDISTRIBUTIONPOINT",1062813311:"IFCDISTRIBUTIONCONTROLELEMENT",1052013943:"IFCDISTRIBUTIONCHAMBERELEMENT",578613899:"IFCCONTROLLERTYPE",2454782716:"IFCCHAMFEREDGEFEATURE",753842376:"IFCBEAM",3001207471:"IFCALARMTYPE",2874132201:"IFCACTUATORTYPE",3304561284:"IFCWINDOW",3512223829:"IFCWALLSTANDARDCASE",2391406946:"IFCWALL",3313531582:"IFCVIBRATIONISOLATORTYPE",2347447852:"IFCTENDONANCHOR",3824725483:"IFCTENDON",2515109513:"IFCSTRUCTURALANALYSISMODEL",4252922144:"IFCSTAIRFLIGHT",331165859:"IFCSTAIR",1529196076:"IFCSLAB",1783015770:"IFCSENSORTYPE",1376911519:"IFCROUNDEDEDGEFEATURE",2016517767:"IFCROOF",2320036040:"IFCREINFORCINGMESH",3027567501:"IFCREINFORCINGELEMENT",3055160366:"IFCRATIONALBEZIERCURVE",3283111854:"IFCRAMPFLIGHT",3024970846:"IFCRAMP",2262370178:"IFCRAILING",3171933400:"IFCPLATE",1687234759:"IFCPILE",1073191201:"IFCMEMBER",900683007:"IFCFOOTING",3508470533:"IFCFLOWTREATMENTDEVICE",2223149337:"IFCFLOWTERMINAL",707683696:"IFCFLOWSTORAGEDEVICE",987401354:"IFCFLOWSEGMENT",3132237377:"IFCFLOWMOVINGDEVICE",4037862832:"IFCFLOWINSTRUMENTTYPE",4278956645:"IFCFLOWFITTING",2058353004:"IFCFLOWCONTROLLER",4222183408:"IFCFIRESUPPRESSIONTERMINALTYPE",1810631287:"IFCFILTERTYPE",346874300:"IFCFANTYPE",1658829314:"IFCENERGYCONVERSIONDEVICE",857184966:"IFCELECTRICALELEMENT",1634875225:"IFCELECTRICALCIRCUIT",712377611:"IFCELECTRICTIMECONTROLTYPE",1217240411:"IFCELECTRICMOTORTYPE",1365060375:"IFCELECTRICHEATERTYPE",1534661035:"IFCELECTRICGENERATORTYPE",3277789161:"IFCELECTRICFLOWSTORAGEDEVICETYPE",663422040:"IFCELECTRICAPPLIANCETYPE",855621170:"IFCEDGEFEATURE",2030761528:"IFCDUCTSILENCERTYPE",3760055223:"IFCDUCTSEGMENTTYPE",869906466:"IFCDUCTFITTINGTYPE",395920057:"IFCDOOR",3041715199:"IFCDISTRIBUTIONPORT",3040386961:"IFCDISTRIBUTIONFLOWELEMENT",1945004755:"IFCDISTRIBUTIONELEMENT",2063403501:"IFCDISTRIBUTIONCONTROLELEMENTTYPE",1599208980:"IFCDISTRIBUTIONCHAMBERELEMENTTYPE",2635815018:"IFCDISCRETEACCESSORYTYPE",1335981549:"IFCDISCRETEACCESSORY",4147604152:"IFCDIAMETERDIMENSION",3961806047:"IFCDAMPERTYPE",3495092785:"IFCCURTAINWALL",1973544240:"IFCCOVERING",2954562838:"IFCCOOLINGTOWERTYPE",335055490:"IFCCOOLEDBEAMTYPE",488727124:"IFCCONSTRUCTIONPRODUCTRESOURCE",1060000209:"IFCCONSTRUCTIONMATERIALRESOURCE",3898045240:"IFCCONSTRUCTIONEQUIPMENTRESOURCE",1163958913:"IFCCONDITIONCRITERION",2188551683:"IFCCONDITION",2816379211:"IFCCONDENSERTYPE",3850581409:"IFCCOMPRESSORTYPE",843113511:"IFCCOLUMN",2301859152:"IFCCOILTYPE",2611217952:"IFCCIRCLE",2951183804:"IFCCHILLERTYPE",1285652485:"IFCCABLESEGMENTTYPE",3293546465:"IFCCABLECARRIERSEGMENTTYPE",395041908:"IFCCABLECARRIERFITTINGTYPE",1909888760:"IFCBUILDINGELEMENTPROXYTYPE",1095909175:"IFCBUILDINGELEMENTPROXY",2979338954:"IFCBUILDINGELEMENTPART",52481810:"IFCBUILDINGELEMENTCOMPONENT",3299480353:"IFCBUILDINGELEMENT",231477066:"IFCBOILERTYPE",1916977116:"IFCBEZIERCURVE",819618141:"IFCBEAMTYPE",1967976161:"IFCBSPLINECURVE",3460190687:"IFCASSET",2470393545:"IFCANGULARDIMENSION",1871374353:"IFCAIRTOAIRHEATRECOVERYTYPE",3352864051:"IFCAIRTERMINALTYPE",1411407467:"IFCAIRTERMINALBOXTYPE",3821786052:"IFCACTIONREQUEST",1213861670:"IFC2DCOMPOSITECURVE",1033361043:"IFCZONE",3342526732:"IFCWORKSCHEDULE",4218914973:"IFCWORKPLAN",1028945134:"IFCWORKCONTROL",1133259667:"IFCWASTETERMINALTYPE",1898987631:"IFCWALLTYPE",2769231204:"IFCVIRTUALELEMENT",728799441:"IFCVALVETYPE",1911125066:"IFCUNITARYEQUIPMENTTYPE",1600972822:"IFCTUBEBUNDLETYPE",3593883385:"IFCTRIMMEDCURVE",1620046519:"IFCTRANSPORTELEMENT",1692211062:"IFCTRANSFORMERTYPE",1637806684:"IFCTIMESERIESSCHEDULE",5716631:"IFCTANKTYPE",2254336722:"IFCSYSTEM",2315554128:"IFCSWITCHINGDEVICETYPE",148013059:"IFCSUBCONTRACTRESOURCE",1975003073:"IFCSTRUCTURALSURFACECONNECTION",2986769608:"IFCSTRUCTURALRESULTGROUP",1235345126:"IFCSTRUCTURALPOINTREACTION",734778138:"IFCSTRUCTURALPOINTCONNECTION",2082059205:"IFCSTRUCTURALPOINTACTION",3987759626:"IFCSTRUCTURALPLANARACTIONVARYING",1621171031:"IFCSTRUCTURALPLANARACTION",1252848954:"IFCSTRUCTURALLOADGROUP",1721250024:"IFCSTRUCTURALLINEARACTIONVARYING",1807405624:"IFCSTRUCTURALLINEARACTION",2445595289:"IFCSTRUCTURALCURVEMEMBERVARYING",214636428:"IFCSTRUCTURALCURVEMEMBER",4243806635:"IFCSTRUCTURALCURVECONNECTION",1179482911:"IFCSTRUCTURALCONNECTION",682877961:"IFCSTRUCTURALACTION",1039846685:"IFCSTAIRFLIGHTTYPE",3112655638:"IFCSTACKTERMINALTYPE",3812236995:"IFCSPACETYPE",652456506:"IFCSPACEPROGRAM",1305183839:"IFCSPACEHEATERTYPE",3856911033:"IFCSPACE",2533589738:"IFCSLABTYPE",4097777520:"IFCSITE",4105383287:"IFCSERVICELIFE",3517283431:"IFCSCHEDULETIMECONTROL",1768891740:"IFCSANITARYTERMINALTYPE",2863920197:"IFCRELASSIGNSTASKS",160246688:"IFCRELAGGREGATES",2324767716:"IFCRAMPFLIGHTTYPE",2893384427:"IFCRAILINGTYPE",3248260540:"IFCRADIUSDIMENSION",2250791053:"IFCPUMPTYPE",1842657554:"IFCPROTECTIVEDEVICETYPE",3651124850:"IFCPROJECTIONELEMENT",3642467123:"IFCPROJECTORDERRECORD",2904328755:"IFCPROJECTORDER",2744685151:"IFCPROCEDURE",3740093272:"IFCPORT",3724593414:"IFCPOLYLINE",4017108033:"IFCPLATETYPE",4231323485:"IFCPIPESEGMENTTYPE",804291784:"IFCPIPEFITTINGTYPE",3327091369:"IFCPERMIT",2382730787:"IFCPERFORMANCEHISTORY",2837617999:"IFCOUTLETTYPE",3425660407:"IFCORDERACTION",3588315303:"IFCOPENINGELEMENT",4143007308:"IFCOCCUPANT",1916936684:"IFCMOVE",977012517:"IFCMOTORCONNECTIONTYPE",3181161470:"IFCMEMBERTYPE",2108223431:"IFCMECHANICALFASTENERTYPE",377706215:"IFCMECHANICALFASTENER",2506943328:"IFCLINEARDIMENSION",1161773419:"IFCLIGHTFIXTURETYPE",1051575348:"IFCLAMPTYPE",3827777499:"IFCLABORRESOURCE",4288270099:"IFCJUNCTIONBOXTYPE",2391368822:"IFCINVENTORY",1806887404:"IFCHUMIDIFIERTYPE",1251058090:"IFCHEATEXCHANGERTYPE",2706460486:"IFCGROUP",3009204131:"IFCGRID",200128114:"IFCGASTERMINALTYPE",814719939:"IFCFURNITURESTANDARD",263784265:"IFCFURNISHINGELEMENT",3009222698:"IFCFLOWTREATMENTDEVICETYPE",2297155007:"IFCFLOWTERMINALTYPE",1339347760:"IFCFLOWSTORAGEDEVICETYPE",1834744321:"IFCFLOWSEGMENTTYPE",1482959167:"IFCFLOWMOVINGDEVICETYPE",3815607619:"IFCFLOWMETERTYPE",3198132628:"IFCFLOWFITTINGTYPE",3907093117:"IFCFLOWCONTROLLERTYPE",1287392070:"IFCFEATUREELEMENTSUBTRACTION",2143335405:"IFCFEATUREELEMENTADDITION",2827207264:"IFCFEATUREELEMENT",2489546625:"IFCFASTENERTYPE",647756555:"IFCFASTENER",3737207727:"IFCFACETEDBREPWITHVOIDS",807026263:"IFCFACETEDBREP",3390157468:"IFCEVAPORATORTYPE",3174744832:"IFCEVAPORATIVECOOLERTYPE",3272907226:"IFCEQUIPMENTSTANDARD",1962604670:"IFCEQUIPMENTELEMENT",2107101300:"IFCENERGYCONVERSIONDEVICETYPE",1704287377:"IFCELLIPSE",2590856083:"IFCELEMENTCOMPONENTTYPE",1623761950:"IFCELEMENTCOMPONENT",4123344466:"IFCELEMENTASSEMBLY",1758889154:"IFCELEMENT",360485395:"IFCELECTRICALBASEPROPERTIES",3849074793:"IFCDISTRIBUTIONFLOWELEMENTTYPE",3256556792:"IFCDISTRIBUTIONELEMENTTYPE",681481545:"IFCDIMENSIONCURVEDIRECTEDCALLOUT",1457835157:"IFCCURTAINWALLTYPE",3295246426:"IFCCREWRESOURCE",1916426348:"IFCCOVERINGTYPE",1419761937:"IFCCOSTSCHEDULE",3895139033:"IFCCOSTITEM",3293443760:"IFCCONTROL",2559216714:"IFCCONSTRUCTIONRESOURCE",2510884976:"IFCCONIC",3732776249:"IFCCOMPOSITECURVE",300633059:"IFCCOLUMNTYPE",2937912522:"IFCCIRCLEHOLLOWPROFILEDEF",3124254112:"IFCBUILDINGSTOREY",1950629157:"IFCBUILDINGELEMENTTYPE",4031249490:"IFCBUILDING",1260505505:"IFCBOUNDEDCURVE",3649129432:"IFCBOOLEANCLIPPINGRESULT",1334484129:"IFCBLOCK",3207858831:"IFCASYMMETRICISHAPEPROFILEDEF",1674181508:"IFCANNOTATION",2296667514:"IFCACTOR",2097647324:"IFCTRANSPORTELEMENTTYPE",3473067441:"IFCTASK",1580310250:"IFCSYSTEMFURNITUREELEMENTTYPE",4124788165:"IFCSURFACEOFREVOLUTION",2809605785:"IFCSURFACEOFLINEAREXTRUSION",2028607225:"IFCSURFACECURVESWEPTAREASOLID",4070609034:"IFCSTRUCTUREDDIMENSIONCALLOUT",2218152070:"IFCSTRUCTURALSURFACEMEMBERVARYING",3979015343:"IFCSTRUCTURALSURFACEMEMBER",3689010777:"IFCSTRUCTURALREACTION",530289379:"IFCSTRUCTURALMEMBER",3136571912:"IFCSTRUCTURALITEM",3544373492:"IFCSTRUCTURALACTIVITY",451544542:"IFCSPHERE",3893378262:"IFCSPATIALSTRUCTUREELEMENTTYPE",2706606064:"IFCSPATIALSTRUCTUREELEMENT",3626867408:"IFCRIGHTCIRCULARCYLINDER",4158566097:"IFCRIGHTCIRCULARCONE",1856042241:"IFCREVOLVEDAREASOLID",2914609552:"IFCRESOURCE",1401173127:"IFCRELVOIDSELEMENT",3451746338:"IFCRELSPACEBOUNDARY",366585022:"IFCRELSERVICESBUILDINGS",4122056220:"IFCRELSEQUENCE",1058617721:"IFCRELSCHEDULESCOSTITEMS",1245217292:"IFCRELREFERENCEDINSPATIALSTRUCTURE",750771296:"IFCRELPROJECTSELEMENT",202636808:"IFCRELOVERRIDESPROPERTIES",2051452291:"IFCRELOCCUPIESSPACES",3268803585:"IFCRELNESTS",4189434867:"IFCRELINTERACTIONREQUIREMENTS",279856033:"IFCRELFLOWCONTROLELEMENTS",3940055652:"IFCRELFILLSELEMENT",781010003:"IFCRELDEFINESBYTYPE",4186316022:"IFCRELDEFINESBYPROPERTIES",693640335:"IFCRELDEFINES",2551354335:"IFCRELDECOMPOSES",2802773753:"IFCRELCOVERSSPACES",886880790:"IFCRELCOVERSBLDGELEMENTS",3242617779:"IFCRELCONTAINEDINSPATIALSTRUCTURE",3678494232:"IFCRELCONNECTSWITHREALIZINGELEMENTS",504942748:"IFCRELCONNECTSWITHECCENTRICITY",1638771189:"IFCRELCONNECTSSTRUCTURALMEMBER",3912681535:"IFCRELCONNECTSSTRUCTURALELEMENT",2127690289:"IFCRELCONNECTSSTRUCTURALACTIVITY",3190031847:"IFCRELCONNECTSPORTS",4201705270:"IFCRELCONNECTSPORTTOELEMENT",3945020480:"IFCRELCONNECTSPATHELEMENTS",1204542856:"IFCRELCONNECTSELEMENTS",826625072:"IFCRELCONNECTS",2851387026:"IFCRELASSOCIATESPROFILEPROPERTIES",2655215786:"IFCRELASSOCIATESMATERIAL",3840914261:"IFCRELASSOCIATESLIBRARY",982818633:"IFCRELASSOCIATESDOCUMENT",2728634034:"IFCRELASSOCIATESCONSTRAINT",919958153:"IFCRELASSOCIATESCLASSIFICATION",4095574036:"IFCRELASSOCIATESAPPROVAL",1327628568:"IFCRELASSOCIATESAPPLIEDVALUE",1865459582:"IFCRELASSOCIATES",205026976:"IFCRELASSIGNSTORESOURCE",3372526763:"IFCRELASSIGNSTOPROJECTORDER",2857406711:"IFCRELASSIGNSTOPRODUCT",4278684876:"IFCRELASSIGNSTOPROCESS",1307041759:"IFCRELASSIGNSTOGROUP",2495723537:"IFCRELASSIGNSTOCONTROL",1683148259:"IFCRELASSIGNSTOACTOR",3939117080:"IFCRELASSIGNS",3454111270:"IFCRECTANGULARTRIMMEDSURFACE",2798486643:"IFCRECTANGULARPYRAMID",2770003689:"IFCRECTANGLEHOLLOWPROFILEDEF",3219374653:"IFCPROXY",1451395588:"IFCPROPERTYSET",4194566429:"IFCPROJECTIONCURVE",103090709:"IFCPROJECT",4208778838:"IFCPRODUCT",2945172077:"IFCPROCESS",220341763:"IFCPLANE",603570806:"IFCPLANARBOX",3566463478:"IFCPERMEABLECOVERINGPROPERTIES",3505215534:"IFCOFFSETCURVE3D",3388369263:"IFCOFFSETCURVE2D",3888040117:"IFCOBJECT",1425443689:"IFCMANIFOLDSOLIDBREP",1281925730:"IFCLINE",572779678:"IFCLSHAPEPROFILEDEF",1484403080:"IFCISHAPEPROFILEDEF",987898635:"IFCGEOMETRICCURVESET",1268542332:"IFCFURNITURETYPE",4238390223:"IFCFURNISHINGELEMENTTYPE",3455213021:"IFCFLUIDFLOWPROPERTIES",315944413:"IFCFILLAREASTYLETILES",4203026998:"IFCFILLAREASTYLETILESYMBOLWITHSTYLE",374418227:"IFCFILLAREASTYLEHATCHING",2047409740:"IFCFACEBASEDSURFACEMODEL",477187591:"IFCEXTRUDEDAREASOLID",80994333:"IFCENERGYPROPERTIES",2835456948:"IFCELLIPSEPROFILEDEF",2777663545:"IFCELEMENTARYSURFACE",339256511:"IFCELEMENTTYPE",1883228015:"IFCELEMENTQUANTITY",1472233963:"IFCEDGELOOP",4006246654:"IFCDRAUGHTINGPREDEFINEDCURVEFONT",445594917:"IFCDRAUGHTINGPREDEFINEDCOLOUR",3073041342:"IFCDRAUGHTINGCALLOUT",526551008:"IFCDOORSTYLE",1714330368:"IFCDOORPANELPROPERTIES",2963535650:"IFCDOORLININGPROPERTIES",32440307:"IFCDIRECTION",4054601972:"IFCDIMENSIONCURVETERMINATOR",606661476:"IFCDIMENSIONCURVE",693772133:"IFCDEFINEDSYMBOL",2827736869:"IFCCURVEBOUNDEDPLANE",2601014836:"IFCCURVE",2147822146:"IFCCSGSOLID",2506170314:"IFCCSGPRIMITIVE3D",194851669:"IFCCRANERAILFSHAPEPROFILEDEF",4133800736:"IFCCRANERAILASHAPEPROFILEDEF",2485617015:"IFCCOMPOSITECURVESEGMENT",2205249479:"IFCCLOSEDSHELL",1383045692:"IFCCIRCLEPROFILEDEF",1416205885:"IFCCARTESIANTRANSFORMATIONOPERATOR3DNONUNIFORM",3331915920:"IFCCARTESIANTRANSFORMATIONOPERATOR3D",3486308946:"IFCCARTESIANTRANSFORMATIONOPERATOR2DNONUNIFORM",3749851601:"IFCCARTESIANTRANSFORMATIONOPERATOR2D",59481748:"IFCCARTESIANTRANSFORMATIONOPERATOR",1123145078:"IFCCARTESIANPOINT",2898889636:"IFCCSHAPEPROFILEDEF",2713105998:"IFCBOXEDHALFSPACE",2581212453:"IFCBOUNDINGBOX",4182860854:"IFCBOUNDEDSURFACE",2736907675:"IFCBOOLEANRESULT",2740243338:"IFCAXIS2PLACEMENT3D",3125803723:"IFCAXIS2PLACEMENT2D",4261334040:"IFCAXIS1PLACEMENT",1302238472:"IFCANNOTATIONSURFACE",2265737646:"IFCANNOTATIONFILLAREAOCCURRENCE",669184980:"IFCANNOTATIONFILLAREA",3288037868:"IFCANNOTATIONCURVEOCCURRENCE",2543172580:"IFCZSHAPEPROFILEDEF",1299126871:"IFCWINDOWSTYLE",512836454:"IFCWINDOWPANELPROPERTIES",336235671:"IFCWINDOWLININGPROPERTIES",2759199220:"IFCVERTEXLOOP",1417489154:"IFCVECTOR",427810014:"IFCUSHAPEPROFILEDEF",2347495698:"IFCTYPEPRODUCT",1628702193:"IFCTYPEOBJECT",1345879162:"IFCTWODIRECTIONREPEATFACTOR",2715220739:"IFCTRAPEZIUMPROFILEDEF",3124975700:"IFCTEXTLITERALWITHEXTENT",4282788508:"IFCTEXTLITERAL",3028897424:"IFCTERMINATORSYMBOL",3071757647:"IFCTSHAPEPROFILEDEF",230924584:"IFCSWEPTSURFACE",1260650574:"IFCSWEPTDISKSOLID",2247615214:"IFCSWEPTAREASOLID",1878645084:"IFCSURFACESTYLERENDERING",2513912981:"IFCSURFACE",2233826070:"IFCSUBEDGE",3653947884:"IFCSTRUCTURALSTEELPROFILEPROPERTIES",3843319758:"IFCSTRUCTURALPROFILEPROPERTIES",1190533807:"IFCSTRUCTURALLOADSINGLEFORCEWARPING",1597423693:"IFCSTRUCTURALLOADSINGLEFORCE",1973038258:"IFCSTRUCTURALLOADSINGLEDISPLACEMENTDISTORTION",2473145415:"IFCSTRUCTURALLOADSINGLEDISPLACEMENT",2668620305:"IFCSTRUCTURALLOADPLANARFORCE",1595516126:"IFCSTRUCTURALLOADLINEARFORCE",390701378:"IFCSPACETHERMALLOADPROPERTIES",1202362311:"IFCSOUNDVALUE",2485662743:"IFCSOUNDPROPERTIES",723233188:"IFCSOLIDMODEL",2609359061:"IFCSLIPPAGECONNECTIONCONDITION",4124623270:"IFCSHELLBASEDSURFACEMODEL",2411513650:"IFCSERVICELIFEFACTOR",1509187699:"IFCSECTIONEDSPINE",2778083089:"IFCROUNDEDRECTANGLEPROFILEDEF",478536968:"IFCRELATIONSHIP",3765753017:"IFCREINFORCEMENTDEFINITIONPROPERTIES",3413951693:"IFCREGULARTIMESERIES",3615266464:"IFCRECTANGLEPROFILEDEF",110355661:"IFCPROPERTYTABLEVALUE",3650150729:"IFCPROPERTYSINGLEVALUE",3357820518:"IFCPROPERTYSETDEFINITION",941946838:"IFCPROPERTYREFERENCEVALUE",2752243245:"IFCPROPERTYLISTVALUE",4166981789:"IFCPROPERTYENUMERATEDVALUE",1680319473:"IFCPROPERTYDEFINITION",871118103:"IFCPROPERTYBOUNDEDVALUE",673634403:"IFCPRODUCTDEFINITIONSHAPE",179317114:"IFCPREDEFINEDPOINTMARKERSYMBOL",433424934:"IFCPREDEFINEDDIMENSIONSYMBOL",2559016684:"IFCPREDEFINEDCURVEFONT",759155922:"IFCPREDEFINEDCOLOUR",2775532180:"IFCPOLYGONALBOUNDEDHALFSPACE",2924175390:"IFCPOLYLOOP",1423911732:"IFCPOINTONSURFACE",4022376103:"IFCPOINTONCURVE",2067069095:"IFCPOINT",1663979128:"IFCPLANAREXTENT",2004835150:"IFCPLACEMENT",597895409:"IFCPIXELTEXTURE",3021840470:"IFCPHYSICALCOMPLEXQUANTITY",2519244187:"IFCPATH",2529465313:"IFCPARAMETERIZEDPROFILEDEF",1029017970:"IFCORIENTEDEDGE",2665983363:"IFCOPENSHELL",2833995503:"IFCONEDIRECTIONREPEATFACTOR",219451334:"IFCOBJECTDEFINITION",1430189142:"IFCMECHANICALCONCRETEMATERIALPROPERTIES",2022407955:"IFCMATERIALDEFINITIONREPRESENTATION",2347385850:"IFCMAPPEDITEM",1008929658:"IFCLOOP",2624227202:"IFCLOCALPLACEMENT",3422422726:"IFCLIGHTSOURCESPOT",1520743889:"IFCLIGHTSOURCEPOSITIONAL",4266656042:"IFCLIGHTSOURCEGONIOMETRIC",2604431987:"IFCLIGHTSOURCEDIRECTIONAL",125510826:"IFCLIGHTSOURCEAMBIENT",1402838566:"IFCLIGHTSOURCE",3741457305:"IFCIRREGULARTIMESERIES",3905492369:"IFCIMAGETEXTURE",2445078500:"IFCHYGROSCOPICMATERIALPROPERTIES",812098782:"IFCHALFSPACESOLID",178086475:"IFCGRIDPLACEMENT",3590301190:"IFCGEOMETRICSET",4142052618:"IFCGEOMETRICREPRESENTATIONSUBCONTEXT",2453401579:"IFCGEOMETRICREPRESENTATIONITEM",3448662350:"IFCGEOMETRICREPRESENTATIONCONTEXT",1446786286:"IFCGENERALPROFILEPROPERTIES",803998398:"IFCGENERALMATERIALPROPERTIES",3857492461:"IFCFUELPROPERTIES",738692330:"IFCFILLAREASTYLE",4219587988:"IFCFAILURECONNECTIONCONDITION",3008276851:"IFCFACESURFACE",803316827:"IFCFACEOUTERBOUND",1809719519:"IFCFACEBOUND",2556980723:"IFCFACE",1860660968:"IFCEXTENDEDMATERIALPROPERTIES",476780140:"IFCEDGECURVE",3900360178:"IFCEDGE",4170525392:"IFCDRAUGHTINGPREDEFINEDTEXTFONT",3732053477:"IFCDOCUMENTREFERENCE",1694125774:"IFCDIMENSIONPAIR",2273265877:"IFCDIMENSIONCALLOUTRELATIONSHIP",3632507154:"IFCDERIVEDPROFILEDEF",3800577675:"IFCCURVESTYLE",2889183280:"IFCCONVERSIONBASEDUNIT",3050246964:"IFCCONTEXTDEPENDENTUNIT",45288368:"IFCCONNECTIONPOINTECCENTRICITY",1981873012:"IFCCONNECTIONCURVEGEOMETRY",370225590:"IFCCONNECTEDFACESET",1485152156:"IFCCOMPOSITEPROFILEDEF",2542286263:"IFCCOMPLEXPROPERTY",776857604:"IFCCOLOURRGB",647927063:"IFCCLASSIFICATIONREFERENCE",3150382593:"IFCCENTERLINEPROFILEDEF",616511568:"IFCBLOBTEXTURE",2705031697:"IFCARBITRARYPROFILEDEFWITHVOIDS",1310608509:"IFCARBITRARYOPENPROFILEDEF",3798115385:"IFCARBITRARYCLOSEDPROFILEDEF",2297822566:"IFCANNOTATIONTEXTOCCURRENCE",3612888222:"IFCANNOTATIONSYMBOLOCCURRENCE",962685235:"IFCANNOTATIONSURFACEOCCURRENCE",2442683028:"IFCANNOTATIONOCCURRENCE",1065908215:"IFCWATERPROPERTIES",891718957:"IFCVIRTUALGRIDINTERSECTION",1907098498:"IFCVERTEXPOINT",3304826586:"IFCVERTEXBASEDTEXTUREMAP",2799835756:"IFCVERTEX",180925521:"IFCUNITASSIGNMENT",1735638870:"IFCTOPOLOGYREPRESENTATION",1377556343:"IFCTOPOLOGICALREPRESENTATIONITEM",581633288:"IFCTIMESERIESVALUE",1718945513:"IFCTIMESERIESREFERENCERELATIONSHIP",3101149627:"IFCTIMESERIES",3317419933:"IFCTHERMALMATERIALPROPERTIES",1210645708:"IFCTEXTUREVERTEX",2552916305:"IFCTEXTUREMAP",1742049831:"IFCTEXTURECOORDINATEGENERATOR",280115917:"IFCTEXTURECOORDINATE",1484833681:"IFCTEXTSTYLEWITHBOXCHARACTERISTICS",1640371178:"IFCTEXTSTYLETEXTMODEL",2636378356:"IFCTEXTSTYLEFORDEFINEDFONT",1983826977:"IFCTEXTSTYLEFONTMODEL",1447204868:"IFCTEXTSTYLE",912023232:"IFCTELECOMADDRESS",531007025:"IFCTABLEROW",985171141:"IFCTABLE",1290481447:"IFCSYMBOLSTYLE",626085974:"IFCSURFACETEXTURE",1351298697:"IFCSURFACESTYLEWITHTEXTURES",846575682:"IFCSURFACESTYLESHADING",1607154358:"IFCSURFACESTYLEREFRACTION",3303107099:"IFCSURFACESTYLELIGHTING",1300840506:"IFCSURFACESTYLE",3049322572:"IFCSTYLEDREPRESENTATION",3958052878:"IFCSTYLEDITEM",2830218821:"IFCSTYLEMODEL",3408363356:"IFCSTRUCTURALLOADTEMPERATURE",2525727697:"IFCSTRUCTURALLOADSTATIC",2162789131:"IFCSTRUCTURALLOAD",2273995522:"IFCSTRUCTURALCONNECTIONCONDITION",3692461612:"IFCSIMPLEPROPERTY",4240577450:"IFCSHAPEREPRESENTATION",3982875396:"IFCSHAPEMODEL",867548509:"IFCSHAPEASPECT",4165799628:"IFCSECTIONREINFORCEMENTPROPERTIES",2042790032:"IFCSECTIONPROPERTIES",448429030:"IFCSIUNIT",2341007311:"IFCROOT",3679540991:"IFCRIBPLATEPROFILEPROPERTIES",1660063152:"IFCREPRESENTATIONMAP",3008791417:"IFCREPRESENTATIONITEM",3377609919:"IFCREPRESENTATIONCONTEXT",1076942058:"IFCREPRESENTATION",1222501353:"IFCRELAXATION",1580146022:"IFCREINFORCEMENTBARPROPERTIES",2692823254:"IFCREFERENCESVALUEDOCUMENT",825690147:"IFCQUANTITYWEIGHT",2405470396:"IFCQUANTITYVOLUME",3252649465:"IFCQUANTITYTIME",931644368:"IFCQUANTITYLENGTH",2093928680:"IFCQUANTITYCOUNT",2044713172:"IFCQUANTITYAREA",3710013099:"IFCPROPERTYENUMERATION",148025276:"IFCPROPERTYDEPENDENCYRELATIONSHIP",3896028662:"IFCPROPERTYCONSTRAINTRELATIONSHIP",2598011224:"IFCPROPERTY",2802850158:"IFCPROFILEPROPERTIES",3958567839:"IFCPROFILEDEF",2267347899:"IFCPRODUCTSOFCOMBUSTIONPROPERTIES",2095639259:"IFCPRODUCTREPRESENTATION",2417041796:"IFCPRESENTATIONSTYLEASSIGNMENT",3119450353:"IFCPRESENTATIONSTYLE",1304840413:"IFCPRESENTATIONLAYERWITHSTYLE",2022622350:"IFCPRESENTATIONLAYERASSIGNMENT",1775413392:"IFCPREDEFINEDTEXTFONT",3213052703:"IFCPREDEFINEDTERMINATORSYMBOL",990879717:"IFCPREDEFINEDSYMBOL",3727388367:"IFCPREDEFINEDITEM",3355820592:"IFCPOSTALADDRESS",2226359599:"IFCPHYSICALSIMPLEQUANTITY",2483315170:"IFCPHYSICALQUANTITY",101040310:"IFCPERSONANDORGANIZATION",2077209135:"IFCPERSON",1207048766:"IFCOWNERHISTORY",1411181986:"IFCORGANIZATIONRELATIONSHIP",4251960020:"IFCORGANIZATION",1227763645:"IFCOPTICALMATERIALPROPERTIES",2251480897:"IFCOBJECTIVE",3701648758:"IFCOBJECTPLACEMENT",1918398963:"IFCNAMEDUNIT",2706619895:"IFCMONETARYUNIT",3368373690:"IFCMETRIC",677618848:"IFCMECHANICALSTEELMATERIALPROPERTIES",4256014907:"IFCMECHANICALMATERIALPROPERTIES",2597039031:"IFCMEASUREWITHUNIT",3265635763:"IFCMATERIALPROPERTIES",2199411900:"IFCMATERIALLIST",1303795690:"IFCMATERIALLAYERSETUSAGE",3303938423:"IFCMATERIALLAYERSET",248100487:"IFCMATERIALLAYER",1847130766:"IFCMATERIALCLASSIFICATIONRELATIONSHIP",1838606355:"IFCMATERIAL",30780891:"IFCLOCALTIME",1566485204:"IFCLIGHTINTENSITYDISTRIBUTION",4162380809:"IFCLIGHTDISTRIBUTIONDATA",3452421091:"IFCLIBRARYREFERENCE",2655187982:"IFCLIBRARYINFORMATION",3020489413:"IFCIRREGULARTIMESERIESVALUE",852622518:"IFCGRIDAXIS",3548104201:"IFCEXTERNALLYDEFINEDTEXTFONT",3207319532:"IFCEXTERNALLYDEFINEDSYMBOL",1040185647:"IFCEXTERNALLYDEFINEDSURFACESTYLE",2242383968:"IFCEXTERNALLYDEFINEDHATCHSTYLE",3200245327:"IFCEXTERNALREFERENCE",1648886627:"IFCENVIRONMENTALIMPACTVALUE",3796139169:"IFCDRAUGHTINGCALLOUTRELATIONSHIP",770865208:"IFCDOCUMENTINFORMATIONRELATIONSHIP",1154170062:"IFCDOCUMENTINFORMATION",1376555844:"IFCDOCUMENTELECTRONICFORMAT",2949456006:"IFCDIMENSIONALEXPONENTS",1045800335:"IFCDERIVEDUNITELEMENT",1765591967:"IFCDERIVEDUNIT",1072939445:"IFCDATEANDTIME",3510044353:"IFCCURVESTYLEFONTPATTERN",2367409068:"IFCCURVESTYLEFONTANDSCALING",1105321065:"IFCCURVESTYLEFONT",539742890:"IFCCURRENCYRELATIONSHIP",602808272:"IFCCOSTVALUE",1065062679:"IFCCOORDINATEDUNIVERSALTIMEOFFSET",347226245:"IFCCONSTRAINTRELATIONSHIP",613356794:"IFCCONSTRAINTCLASSIFICATIONRELATIONSHIP",1658513725:"IFCCONSTRAINTAGGREGATIONRELATIONSHIP",1959218052:"IFCCONSTRAINT",2732653382:"IFCCONNECTIONSURFACEGEOMETRY",4257277454:"IFCCONNECTIONPORTGEOMETRY",2614616156:"IFCCONNECTIONPOINTGEOMETRY",2859738748:"IFCCONNECTIONGEOMETRY",3264961684:"IFCCOLOURSPECIFICATION",3639012971:"IFCCLASSIFICATIONNOTATIONFACET",938368621:"IFCCLASSIFICATIONNOTATION",1098599126:"IFCCLASSIFICATIONITEMRELATIONSHIP",1767535486:"IFCCLASSIFICATIONITEM",747523909:"IFCCLASSIFICATION",622194075:"IFCCALENDARDATE",2069777674:"IFCBOUNDARYNODECONDITIONWARPING",1387855156:"IFCBOUNDARYNODECONDITION",3367102660:"IFCBOUNDARYFACECONDITION",1560379544:"IFCBOUNDARYEDGECONDITION",4037036970:"IFCBOUNDARYCONDITION",3869604511:"IFCAPPROVALRELATIONSHIP",390851274:"IFCAPPROVALPROPERTYRELATIONSHIP",2080292479:"IFCAPPROVALACTORRELATIONSHIP",130549933:"IFCAPPROVAL",1110488051:"IFCAPPLIEDVALUERELATIONSHIP",411424972:"IFCAPPLIEDVALUE",639542469:"IFCAPPLICATION",618182010:"IFCADDRESS",3630933823:"IFCACTORROLE",599546466:"FILE_DESCRIPTION",1390159747:"FILE_NAME",1109904537:"FILE_SCHEMA"};class xt{static async getUnits(s){var n,r,a;const{IFCUNITASSIGNMENT:t}=D,e=await s.getAllPropertiesOfType(t);if(!e)return 1;const i=Object.keys(e),o=e[parseInt(i[0],10)];for(const c of o.Units){if(c.value===void 0||c.value===null)continue;const h=await s.getProperties(c.value);if(!h||!h.UnitType||!h.UnitType.value||h.UnitType.value!=="LENGTHUNIT")continue;let d=1,I=1;return h.Name.value==="METRE"&&(I=1),h.Name.value==="FOOT"&&(I=.3048),((n=h.Prefix)==null?void 0:n.value)==="MILLI"?d=.001:((r=h.Prefix)==null?void 0:r.value)==="CENTI"?d=.01:((a=h.Prefix)==null?void 0:a.value)==="DECI"&&(d=.1),I*d}return 1}static async findItemByGuid(s,t){var i;const e=s.getAllPropertiesIDs();for(const o of e){const n=await s.getProperties(o);if(n&&((i=n.GlobalId)==null?void 0:i.value)===t)return n}return null}static async getRelationMap(s,t,e){var a;const o=e??(async()=>{}),n={},r=s.getAllPropertiesIDs();for(const c of r){const h=await s.getProperties(c);if(!h)continue;const E=h.type===t,d=Object.keys(h).find(m=>m.startsWith("Relating")),I=Object.keys(h).find(m=>m.startsWith("Related"));if(!(E&&d&&I))continue;const f=await s.getProperties((a=h[d])==null?void 0:a.value),T=h[I];if(!f||!T||!(T&&Array.isArray(T)))continue;const F=T.map(m=>m.value);await o(f.expressID,F),n[f.expressID]=F}return n}static async getQsetQuantities(s,t,e){const o=e??(()=>{}),n=await s.getProperties(t);return!n||n.type!==D.IFCELEMENTQUANTITY?null:(n.Quantities??[{}]).map(c=>(c.value&&o(c.value),c.value)).filter(c=>c!==null)}static async getPsetProps(s,t,e){const o=e??(()=>{}),n=await s.getProperties(t);return!n||n.type!==D.IFCPROPERTYSET?null:(n.HasProperties??[{}]).map(c=>(c.value&&o(c.value),c.value)).filter(c=>c!==null)}static async getPsetRel(s,t){var r;if(!await s.getProperties(t))return null;const i=await s.getAllPropertiesOfType(D.IFCRELDEFINESBYPROPERTIES);if(!i)return null;const o=Object.values(i);let n=null;for(const a of o)((r=a.RelatingPropertyDefinition)==null?void 0:r.value)===t&&(n=a.expressID);return n}static async getQsetRel(s,t){return xt.getPsetRel(s,t)}static async getEntityName(s,t){var n;const e=await s.getProperties(t);if(!e)return{key:null,name:null};const i=Object.keys(e).find(r=>r.endsWith("Name"))??null,o=i?(n=e[i])==null?void 0:n.value:null;return{key:i,name:o}}static async getQuantityValue(s,t){const e=await s.getProperties(t);if(!e)return{key:null,value:null};const i=Object.keys(e).find(n=>n.endsWith("Value"))??null;let o;return i===null||e[i]===void 0||e[i]===null?o=null:o=e[i].value,{key:i,value:o}}static isRel(s){return Pi[s].startsWith("IFCREL")}static async attributeExists(s,t,e){const i=await s.getProperties(t);return i?Object.keys(i).includes(e):!1}static async groupEntitiesByType(s,t){var i;const e=new Map;for(const o of t){const n=await s.getProperties(o);if(!n)continue;const r=n.type;e.get(r)||e.set(r,new Set),(i=e.get(r))==null||i.add(o)}return e}}class Ur{constructor(){u(this,"factor",1);u(this,"complement",1)}apply(s){const e=this.getScaleMatrix().multiply(s);s.copy(e)}setUp(s){var o,n,r;this.factor=1;const t=this.getLengthUnits(s);if(!t)return;const e=t==null,i=t.Name===void 0||t.Name===null;e||i||(t.Name.value==="FOOT"&&(this.factor=.3048),((o=t.Prefix)==null?void 0:o.value)==="MILLI"?this.complement=.001:((n=t.Prefix)==null?void 0:n.value)==="CENTI"?this.complement=.01:((r=t.Prefix)==null?void 0:r.value)==="DECI"&&(this.complement=.01))}getLengthUnits(s){try{const e=s.GetLineIDsWithType(0,D.IFCUNITASSIGNMENT).get(0),i=s.GetLine(0,e);for(const o of i.Units){if(!o||o.value===null||o.value===void 0)continue;const n=s.GetLine(0,o.value);if(n.UnitType&&n.UnitType.value==="LENGTHUNIT")return n}return null}catch{return console.log("Could not get units"),null}}getScaleMatrix(){const s=this.factor;return new g.Matrix4().fromArray([s,0,0,0,0,s,0,0,0,0,s,0,0,0,0,1])}}class Gn{constructor(){u(this,"itemsByFloor",{});u(this,"_units",new Ur)}setUp(s){this._units.setUp(s),this.cleanUp();try{const t=s.GetLineIDsWithType(0,D.IFCRELCONTAINEDINSPATIALSTRUCTURE),e=new Set,i=s.GetLineIDsWithType(0,D.IFCSPACE);for(let c=0;c<i.size();c++)e.add(i.get(c));const o=s.GetLineIDsWithType(0,D.IFCRELAGGREGATES),n=o.size();for(let c=0;c<n;c++){const h=o.get(c),E=s.GetLine(0,h);if(!E||!E.RelatingObject||!E.RelatedObjects)continue;const d=E.RelatingObject.value,I=E.RelatedObjects;for(const f of I){const T=f.value;e.has(T)&&(this.itemsByFloor[T]=d)}}const r={},a=t.size();for(let c=0;c<a;c++){const h=t.get(c),E=s.GetLine(0,h);if(!E||!E.RelatingStructure||!E.RelatedElements)continue;const d=E.RelatingStructure.value,I=E.RelatedElements;if(e.has(d))for(const f of I){r[d]||(r[d]=[]);const T=f.value;r[d].push(T)}else for(const f of I){const T=f.value;this.itemsByFloor[T]=d}}for(const c in r){const h=this.itemsByFloor[c];if(h!==void 0){const E=r[c];for(const d of E)this.itemsByFloor[d]=h}}for(let c=0;c<n;c++){const h=o.get(c),E=s.GetLine(0,h);if(!E||!E.RelatingObject||!E.RelatedObjects)continue;const d=E.RelatingObject.value,I=E.RelatedObjects;for(const f of I){const T=f.value,F=this.itemsByFloor[d];F!==void 0&&(this.itemsByFloor[T]=F)}}}catch{console.log("Could not get floors.")}}cleanUp(){this.itemsByFloor={}}}class Ds{constructor(){u(this,"includeProperties",!0);u(this,"optionalCategories",[D.IFCSPACE]);u(this,"coordinate",!0);u(this,"wasm",{path:"",absolute:!1,logLevel:D.LogLevel.LOG_LEVEL_OFF});u(this,"excludedCategories",new Set);u(this,"includedCategories",new Set);u(this,"saveLocations",!1);u(this,"webIfc",{COORDINATE_TO_ORIGIN:!0});u(this,"autoSetWasm",!0);u(this,"customLocateFileHandler",null)}}class zn{constructor(){u(this,"defLineMat",new g.LineBasicMaterial({color:16777215}))}read(s){const t=s.GetAllAlignments(0),e=s.GetAllCrossSections2D(0),i=s.GetAllCrossSections3D(0),o={IfcAlignment:t,IfcCrossSection2D:e,IfcCrossSection3D:i};return this.get(o)}get(s){if(s.IfcAlignment){const t=new Map;for(const e of s.IfcAlignment){const i=new Dt.Alignment;i.absolute=this.getCurves(e.curve3D,i),i.horizontal=this.getCurves(e.horizontal,i),i.vertical=this.getCurves(e.vertical,i),t.set(t.size,i)}return{alignments:t,coordinationMatrix:new g.Matrix4}}}getCurves(s,t){const e=[];let i=0;for(const o of s){const n={};if(o.data)for(const d of o.data){const[I,f]=d.split(": "),T=parseFloat(f);n[I]=T||f}const{points:r}=o,a=new Float32Array(r.length*3);for(let d=0;d<r.length;d++){const{x:I,y:f,z:T}=r[d];a[d*3]=I,a[d*3+1]=f,a[d*3+2]=T||0}const c=new g.BufferAttribute(a,3),h=new g.EdgesGeometry;h.setAttribute("position",c);const E=new Dt.CurveMesh(i,n,t,h,this.defLineMat);e.push(E.curve),i++}return e}}class Hn{getNameInfo(s){var E;const t={},{arguments:e}=s.GetHeaderLine(0,D.FILE_NAME)||{};if(!e)return t;const[i,o,n,r,a,c,h]=e;if(i!=null&&i.value&&(t.name=i.value),o!=null&&o.value&&(t.creationDate=new Date(o.value)),n){t.author={};const[d,I]=n;d!=null&&d.value&&(t.author.name=d.value),I!=null&&I.value&&(t.author.email=I.value)}return(E=r[0])!=null&&E.value&&(t.organization=r[0].value),a!=null&&a.value&&(t.preprocessorVersion=a==null?void 0:a.value),c!=null&&c.value&&(t.originatingSystem=c==null?void 0:c.value),h!=null&&h.value&&(t.authorization=h==null?void 0:h.value),t}getDescriptionInfo(s){var n;const t={},{arguments:e}=s.GetHeaderLine(0,D.FILE_DESCRIPTION)||{};if(!e)return t;const[i,o]=e;if((n=i[0])!=null&&n.value){const r=i[0].value.match(/\[([^\]]+)\]/);r&&r[1]&&(t.viewDefinition=r[1])}return o!=null&&o.value&&(t.implementationLevel=o.value),t}}class Wn{static get(s,t){const e=[D.IFCPROJECT,D.IFCSITE,D.IFCBUILDING,D.IFCBUILDINGSTOREY,D.IFCSPACE,D.IFCROAD,D.IFCFACILITY,D.IFCFACILITYPART,D.IFCBRIDGE],i=s.data;for(const o of e){const n=t.GetLineIDsWithType(0,o),r=n.size();for(let a=0;a<r;a++){const c=n.get(a);i.has(c)||i.set(c,[[],[0,o]])}}}}const xe=class xe extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"onIfcStartedLoading",new M);u(this,"onSetup",new M);u(this,"settings",new Ds);u(this,"webIfc",new D.IfcAPI);u(this,"enabled",!0);u(this,"_material",new g.MeshLambertMaterial);u(this,"_spatialTree",new Gn);u(this,"_metaData",new Hn);u(this,"_fragmentInstances",new Map);u(this,"_civil",new zn);u(this,"_visitedFragments",new Map);u(this,"_materialT",new g.MeshLambertMaterial({transparent:!0,opacity:.5}));this.components.add(xe.uuid,this),this.settings.excludedCategories.add(D.IFCOPENINGELEMENT)}dispose(){try{this.webIfc.Dispose()}catch{}this.webIfc=null,this.onDisposed.trigger(xe.uuid),this.onDisposed.reset()}async setup(t){this.settings={...this.settings,...t},this.settings.autoSetWasm&&await this.autoSetWasm(),this.onSetup.trigger()}async load(t,e=!0){const i=performance.now();this.onIfcStartedLoading.trigger(),await this.readIfcFile(t);const o=await this.getAllGeometries(),r=await this.components.get(us).export(this.webIfc,0);o.setLocalProperties(r);const a=this.components.get(ot);a.groups.set(o.uuid,o);for(const c of o.items)a.list.set(c.id,c),c.mesh.uuid=c.id,c.group=o;a.onFragmentsLoaded.trigger(o),e&&a.coordinate([o]);for(const[c]of o.data){const h=r[c];if(!h||!h.GlobalId)continue;const E=h.GlobalId.value||h.GlobalId;o.globalToExpressIDs.set(E,c)}return Wn.get(o,this.webIfc),this.cleanUp(),console.log(`Streaming the IFC took ${performance.now()-i} ms!`),o}async readIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;return this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(this.settings.customLocateFileHandler||void 0),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModel(t,this.settings.webIfc)}cleanUp(){try{this.webIfc.Dispose()}catch{}this.webIfc=null,this.webIfc=new D.IfcAPI,this._visitedFragments.clear(),this._fragmentInstances.clear()}async getAllGeometries(){this._spatialTree.setUp(this.webIfc);const t=this.webIfc.GetIfcEntityList(0),e=new Dt.FragmentsGroup;e.ifcMetadata={name:"",description:"",...this._metaData.getNameInfo(this.webIfc),...this._metaData.getDescriptionInfo(this.webIfc),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};const i=[];for(const n of t){if(!this.webIfc.IsIfcElement(n)&&n!==D.IFCSPACE)continue;const r=this.settings.includedCategories;if(r.size>0&&!r.has(n))continue;if(this.settings.excludedCategories.has(n))continue;const a=this.webIfc.GetLineIDsWithType(0,n),c=a.size();for(let h=0;h<c;h++){const E=a.get(h);i.push(E);const d=this._spatialTree.itemsByFloor[E]||0;e.data.set(E,[[],[d,n]])}}this._spatialTree.cleanUp(),this.webIfc.StreamMeshes(0,i,n=>{this.getMesh(n,e)});for(const n of this._visitedFragments){const{index:r,fragment:a}=n[1];e.keyFragments.set(r,a.id)}for(const n of e.items){const r=this._fragmentInstances.get(n.id);if(!r)throw new Error("Fragment not found!");const a=[];for(const[c,h]of r)a.push(h);n.add(a)}const o=this.webIfc.GetCoordinationMatrix(0);return e.coordinationMatrix.fromArray(o),e.civilData=this._civil.read(this.webIfc),e}getMesh(t,e){const i=t.geometries.size(),o=t.expressID;for(let n=0;n<i;n++){const r=t.geometries.get(n),{x:a,y:c,z:h,w:E}=r.color,d=E!==1,{geometryExpressID:I}=r,f=`${I}-${d}`;if(!this._visitedFragments.has(f)){const R=this.getGeometry(this.webIfc,I),S=d?this._materialT:this._material,_=new Dt.Fragment(R,S,1);e.add(_.mesh),e.items.push(_);const y=this._visitedFragments.size;this._visitedFragments.set(f,{index:y,fragment:_})}const T=new g.Color().setRGB(a,c,h,"srgb"),F=new g.Matrix4;F.fromArray(r.flatTransformation);const m=this._visitedFragments.get(f);if(m===void 0)throw new Error("Error getting geometry data for streaming!");const A=e.data.get(o);if(!A)throw new Error("Data not found!");A[0].push(m.index);const{fragment:O}=m;this._fragmentInstances.has(O.id)||this._fragmentInstances.set(O.id,new Map);const p=this._fragmentInstances.get(O.id);if(!p)throw new Error("Instances not found!");if(p.has(o)){const R=p.get(o);if(!R)throw new Error("Instance not found!");R.transforms.push(F),R.colors&&R.colors.push(T)}else p.set(o,{id:o,transforms:[F],colors:[T]})}}getGeometry(t,e){const i=t.GetGeometry(0,e),o=t.GetIndexArray(i.GetIndexData(),i.GetIndexDataSize()),n=t.GetVertexArray(i.GetVertexData(),i.GetVertexDataSize()),r=new Float32Array(n.length/2),a=new Float32Array(n.length/2);for(let d=0;d<n.length;d+=6)r[d/2]=n[d],r[d/2+1]=n[d+1],r[d/2+2]=n[d+2],a[d/2]=n[d+3],a[d/2+1]=n[d+4],a[d/2+2]=n[d+5];const c=new g.BufferGeometry,h=new g.BufferAttribute(r,3),E=new g.BufferAttribute(a,3);return c.setAttribute("position",h),c.setAttribute("normal",E),c.setIndex(Array.from(o)),i.delete(),c}async autoSetWasm(){const t=await fetch(`https://unpkg.com/@thatopen/components@${hs.release}/package.json`);if(!t.ok){console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");return}const e=await t.json();if(!("web-ifc"in e.peerDependencies))console.warn("Couldn't get web-ifc from peer dependencies in openbim-components. Set wasm settings manually.");else{const i=e.peerDependencies["web-ifc"];this.settings.wasm.path=`https://unpkg.com/web-ifc@${i}/`,this.settings.wasm.absolute=!0}}};u(xe,"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");let Is=xe;const wt=class wt extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"onRequestFile",new M);u(this,"ifcToExport",null);u(this,"onElementToPset",new M);u(this,"onPropToPset",new M);u(this,"onPsetRemoved",new M);u(this,"onDataChanged",new M);u(this,"wasm",{path:"/",absolute:!1});u(this,"enabled",!0);u(this,"attributeListeners",{});u(this,"selectedModel");u(this,"changeMap",{});this.components.add(wt.uuid,this)}dispose(){this.selectedModel=void 0,this.attributeListeners={},this.changeMap={},this.onElementToPset.reset(),this.onPropToPset.reset(),this.onPsetRemoved.reset(),this.onDataChanged.reset(),this.onDisposed.trigger(wt.uuid),this.onDisposed.reset()}static getIFCSchema(t){const e=t.ifcMetadata.schema;if(!e)throw new Error("IFC Schema not found");return e.startsWith("IFC2X3")?"IFC2X3":e.startsWith("IFC4")&&e.replace("IFC4","")===""?"IFC4":e.startsWith("IFC4X3")?"IFC4X3":e}async setData(t,...e){for(const i of e){const o=i.expressID;o&&(await t.setProperties(o,i),this.registerChange(t,o))}}async newPset(t,e,i){const o=wt.getIFCSchema(t),{ownerHistoryHandle:n}=await this.getOwnerHistory(t),r=this.newGUID(t),a=new D[o].IfcLabel(e),c=i?new D[o].IfcText(i):null,h=new D[o].IfcPropertySet(r,n,a,c,[]);h.expressID=this.increaseMaxID(t);const E=this.newGUID(t),d=new D[o].IfcRelDefinesByProperties(E,n,null,null,[],new D.Handle(h.expressID));return d.expressID=this.increaseMaxID(t),await this.setData(t,h,d),{pset:h,rel:d}}async removePset(t,...e){for(const i of e){const o=await t.getProperties(i);if((o==null?void 0:o.type)!==D.IFCPROPERTYSET)continue;const n=await xt.getPsetRel(t,i);if(n&&(await t.setProperties(n,null),this.registerChange(t,n)),o){for(const r of o.HasProperties)await t.setProperties(r.value,null);await t.setProperties(i,null),this.onPsetRemoved.trigger({model:t,psetID:i}),this.registerChange(t,i)}}}newSingleStringProperty(t,e,i,o){return this.newSingleProperty(t,e,i,o)}newSingleNumericProperty(t,e,i,o){return this.newSingleProperty(t,e,i,o)}newSingleBooleanProperty(t,e,i,o){return this.newSingleProperty(t,e,i,o)}async removePsetProp(t,e,i){const o=await t.getProperties(e),n=await t.getProperties(i);!o||!n||o.type===D.IFCPROPERTYSET&&n&&(o.HasProperties=o.HasProperties.filter(r=>r.value!==i),await t.setProperties(i,null),this.registerChange(t,e,i))}async addElementToPset(t,e,...i){const o=await xt.getPsetRel(t,e);if(!o)return;const n=await t.getProperties(o);if(!n)return;for(const a of i){const c=new D.Handle(a);n.RelatedObjects.push(c),this.onElementToPset.trigger({model:t,psetID:e,elementID:a})}this.registerChange(t,e);const r=this.components.get(Wt);for(const a of i)r.addEntityRelations(t,a,"IsDefinedBy",e)}async addPropToPset(t,e,...i){const o=await t.getProperties(e);if(o){for(const n of i){if(o.HasProperties.includes(n))continue;const r=new D.Handle(n);o.HasProperties.push(r),this.onPropToPset.trigger({model:t,psetID:e,propID:n})}this.registerChange(t,e)}}async saveToIfc(t,e){const i=this.components.get(Is),o=i.webIfc,n=await i.readIfcFile(e),r=this.changeMap[t.uuid]??[];for(const c of r){const h=await t.getProperties(c);if(h)try{o.WriteLine(n,h)}catch{}else try{o.DeleteLine(n,c)}catch{}}const a=o.SaveModel(n);return i.webIfc.CloseModel(n),i.cleanUp(),a}async setAttributeListener(t,e,i){this.attributeListeners[t.uuid]||(this.attributeListeners[t.uuid]={});const o=this.attributeListeners[t.uuid][e]?this.attributeListeners[t.uuid][e][i]:null;if(o)return o;const n=await t.getProperties(e);if(!n)throw new Error(`Entity with expressID ${e} doesn't exists.`);const r=n[i];if(Array.isArray(r)||!r)throw new Error(`Attribute ${i} is array or null, and it can't have a listener.`);const a=r.value;if(a===void 0||a==null)throw new Error(`Attribute ${i} has a badly defined handle.`);const c=new M;return Object.defineProperty(n[i],"value",{get(){return this._value},async set(h){this._value=h,c.trigger(h)}}),n[i].value=a,this.attributeListeners[t.uuid][e]||(this.attributeListeners[t.uuid][e]={}),this.attributeListeners[t.uuid][e][i]=c,c}increaseMaxID(t){return t.ifcMetadata.maxExpressID++,t.ifcMetadata.maxExpressID}newGUID(t){const e=wt.getIFCSchema(t);return new D[e].IfcGloballyUniqueId(ae.create())}async getOwnerHistory(t){const e=await t.getAllPropertiesOfType(D.IFCOWNERHISTORY);if(!e)throw new Error("No OwnerHistory was found.");const i=Object.keys(e).map(r=>parseInt(r,10)),o=e[i[0]],n=new D.Handle(o.expressID);return{ownerHistory:o,ownerHistoryHandle:n}}registerChange(t,...e){this.changeMap[t.uuid]||(this.changeMap[t.uuid]=new Set);for(const i of e)this.changeMap[t.uuid].add(i),this.onDataChanged.trigger({model:t,expressID:i})}async newSingleProperty(t,e,i,o){const n=wt.getIFCSchema(t),r=new D[n].IfcIdentifier(i),a=new D[n][e](o),c=new D[n].IfcPropertySingleValue(r,null,a,null);return c.expressID=this.increaseMaxID(t),await this.setData(t,c),c}};u(wt,"uuid","58c2d9f0-183c-48d6-a402-dfcf5b9a34df");let mi=wt;const gs=class gs extends ${constructor(t){super(t);u(this,"enabled",!0);u(this,"list",{});u(this,"onDisposed",new M);u(this,"onFragmentsDisposed",t=>{const{groupID:e,fragmentIDs:i}=t;for(const o in this.list){const n=this.list[o],r=Object.keys(n);if(r.includes(e))delete n[e],Object.values(n).length===0&&delete this.list[o];else for(const a of r){const c=n[a];for(const h of i)delete c.map[h];Object.values(c).length===0&&delete n[a]}}});t.add(gs.uuid,this),t.get(ot).onFragmentsDisposed.add(this.onFragmentsDisposed)}dispose(){this.list={},this.components.get(ot).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(),this.onDisposed.reset()}remove(t){for(const e in this.list){const i=this.list[e];for(const o in i){const n=i[o];delete n.map[t]}}}find(t){const e=this.components.get(ot);if(!t){const r={};for(const[a,c]of e.list)r[a]=new Set(c.ids);return r}const i=Object.keys(t).length,o={};for(const r in t){const a=t[r];if(!this.list[r]){console.warn(`Classification ${r} does not exist.`);continue}for(const c of a){const h=this.list[r][c];if(h)for(const E in h.map){o[E]||(o[E]=new Map);for(const d of h.map[E]){const I=o[E].get(d);I===void 0?o[E].set(d,1):o[E].set(d,I+1)}}}}const n={};for(const r in o){const a=o[r];for(const[c,h]of a){if(h===void 0)throw new Error("Malformed fragments map!");h===i&&(n[r]||(n[r]=new Set),n[r].add(c))}}return n}byModel(t,e){this.list.models||(this.list.models={});const i=this.list.models;i[t]||(i[t]={map:{},id:null,name:t});const o=i[t];for(const[n,r]of e.data){const a=r[0];for(const c of a){const h=e.keyFragments.get(c);h&&(o.map[h]||(o.map[h]=new Set),o.map[h].add(n))}}}async byPredefinedType(t){var o;this.list.predefinedTypes||(this.list.predefinedTypes={});const e=this.list.predefinedTypes,i=t.getAllPropertiesIDs();for(const n of i){const r=await t.getProperties(n);if(!r)continue;const a=String((o=r.PredefinedType)==null?void 0:o.value).toUpperCase();e[a]||(e[a]={map:{},id:null,name:a});const c=e[a];for(const[h,E]of t.data){const d=E[0];for(const I of d){const f=t.keyFragments.get(I);if(!f)throw new Error("Fragment ID not found!");c.map[f]||(c.map[f]=new Set),c.map[f].add(r.expressID)}}}}byEntity(t){this.list.entities||(this.list.entities={});for(const[e,i]of t.data){const n=i[1][1],r=Pi[n];this.saveItem(t,"entities",r,e)}}async byIfcRel(t,e,i){xt.isRel(e)&&await xt.getRelationMap(t,e,async(o,n)=>{const{name:r}=await xt.getEntityName(t,o);for(const a of n)this.saveItem(t,i,r??"NO REL NAME",a)})}async bySpatialStructure(t,e={}){var c,h;const i=this.components.get(Wt),o=i.relationMaps[t.uuid];if(!o)throw new Error(`Classifier: model relations of ${t.name||t.uuid} have to exists to group by spatial structure.`);const n="spatialStructures",a=e.useProperties===void 0||e.useProperties;for(const[E]of o){if(e.isolate){const T=t.data.get(E);if(!T)continue;const F=T[1][1];if(F===void 0||!e.isolate.has(F))continue}const d=i.getEntityRelations(t,E,"Decomposes");if(d)for(const T of d){let F=T.toString();if(a){const m=await t.getProperties(T);if(!m)continue;F=(c=m.Name)==null?void 0:c.value}this.saveItem(t,n,F,E,T)}const I=i.getEntityRelations(t,E,"ContainsElements");if(!I)continue;let f=E.toString();if(a){const T=await t.getProperties(E);if(!T)continue;f=(h=T.Name)==null?void 0:h.value}for(const T of I){this.saveItem(t,n,f,T,E);const F=i.getEntityRelations(t,Number(T),"IsDecomposedBy");if(F)for(const m of F)this.saveItem(t,n,f,m,E)}}}setColor(t,e,i=!1){const o=this.components.get(ot);for(const n in t){const r=o.list.get(n);if(!r)continue;const a=t[n];r.setColor(e,a,i)}}resetColor(t){const e=this.components.get(ot);for(const i in t){const o=e.list.get(i);if(!o)continue;const n=t[i];o.resetColor(n)}}saveItem(t,e,i,o,n=null){this.list[e]||(this.list[e]={});const r=t.data.get(o);if(r)for(const a of r[0]){const c=t.keyFragments.get(a);if(c){const h=this.list[e];h[i]||(h[i]={map:{},id:n,name:i}),h[i].map[c]||(h[i].map[c]=new Set),h[i].map[c].add(o)}}}};u(gs,"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");let fs=gs;const Os=class Os extends ${constructor(t){super(t);u(this,"onDisposed",new M);u(this,"enabled",!0);u(this,"height",10);u(this,"groupName","spatialStructures");u(this,"list",new Set);t.add(Os.uuid,this)}dispose(){this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}set(t){if(!this.enabled)return;const e=this.components.get(fs),i=this.components.get(ot),o=t?1:-1;let n=0;const r=e.list[this.groupName],a=new g.Matrix4;for(const c in r){a.elements[13]=n*o*this.height;for(const h in r[c].map){const E=i.list.get(h),d=c+h,I=this.list.has(d);if(!E||t&&I||!t&&!I)continue;t?this.list.add(d):this.list.delete(d);const f=r[c].map[h];E.applyTransform(f,a),E.mesh.computeBoundingSphere(),E.mesh.computeBoundingBox()}n++}}};u(Os,"uuid","d260618b-ce88-4c7d-826c-6debb91de3e2");let Ri=Os;const Ss=class Ss extends ${constructor(t){super(t);u(this,"enabled",!0);this.components.add(Ss.uuid,this)}set(t,e){const i=this.components.get(ot);if(!e){for(const[o,n]of i.list)n&&(n.setVisibility(t),this.updateCulledVisibility(n));return}for(const o in e){const n=e[o],r=i.list.get(o);r&&(r.setVisibility(t,n),this.updateCulledVisibility(r))}}isolate(t){this.set(!1),this.set(!0,t)}updateCulledVisibility(t){const e=this.components.get(Es);for(const[i,o]of e.list){const n=o.colorMeshes.get(t.id);n&&(n.count=t.mesh.count)}}};u(Ss,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let Fi=Ss;class kn extends Ds{constructor(){super(...arguments);u(this,"minGeometrySize",10);u(this,"minAssetsSize",1e3)}}const _s=class _s extends ${constructor(t){super(t);u(this,"onGeometryStreamed",new M);u(this,"onAssetStreamed",new M);u(this,"onProgress",new M);u(this,"onIfcLoaded",new M);u(this,"onDisposed",new M);u(this,"settings",new kn);u(this,"enabled",!0);u(this,"webIfc",new D.IfcAPI);u(this,"_spatialTree",new Gn);u(this,"_metaData",new Hn);u(this,"_visitedGeometries",new Map);u(this,"_streamSerializer",new Dt.StreamSerializer);u(this,"_geometries",new Map);u(this,"_geometryCount",0);u(this,"_civil",new zn);u(this,"_groupSerializer",new Dt.Serializer);u(this,"_assets",[]);u(this,"_meshesWithHoles",new Set);this.components.add(_s.uuid,this),this.settings.excludedCategories.add(D.IFCOPENINGELEMENT)}dispose(){this.onIfcLoaded.reset(),this.onGeometryStreamed.reset(),this.onAssetStreamed.reset(),this.webIfc=null,this.onDisposed.trigger(),this.onDisposed.reset()}async streamFromBuffer(t){await this.readIfcFile(t),await this.streamAllGeometries(),this.cleanUp()}async streamFromCallBack(t){await this.streamIfcFile(t),await this.streamAllGeometries(),this.cleanUp()}async readIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModel(t,this.settings.webIfc)}async streamIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModelFromCallback(t,this.settings.webIfc)}async streamAllGeometries(){const{minGeometrySize:t,minAssetsSize:e}=this.settings;this._spatialTree.setUp(this.webIfc);const i=this.webIfc.GetIfcEntityList(0),o=[[]],n=new Dt.FragmentsGroup;n.ifcMetadata={name:"",description:"",...this._metaData.getNameInfo(this.webIfc),...this._metaData.getDescriptionInfo(this.webIfc),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};let r=0,a=0;for(const T of i){if(!this.webIfc.IsIfcElement(T)&&T!==D.IFCSPACE||this.settings.excludedCategories.has(T))continue;const F=this.webIfc.GetLineIDsWithType(0,T),m=F.size();for(let A=0;A<m;A++){r>t&&(r=0,a++,o.push([]));const O=F.get(A);o[a].push(O);const p=this.webIfc.GetLine(0,O);if(p.GlobalId){const S=(p==null?void 0:p.GlobalId.value)||(p==null?void 0:p.GlobalId);n.globalToExpressIDs.set(S,O)}const R=this._spatialTree.itemsByFloor[O]||0;n.data.set(O,[[],[R,T]]),r++}}this._spatialTree.cleanUp();let c=.01,h=0;for(const T of o){h++,this.webIfc.StreamMeshes(0,T,m=>{this.getMesh(this.webIfc,m,n)}),this._geometryCount>t&&await this.streamGeometries(),this._assets.length>e&&await this.streamAssets();const F=h/o.length;F>c&&(c+=.01,c=Math.max(c,F),this.onProgress.trigger(Math.round(c*100)/100))}this._geometryCount&&await this.streamGeometries(),this._assets.length&&await this.streamAssets();const{opaque:E,transparent:d}=n.geometryIDs;for(const[T,{index:F,uuid:m}]of this._visitedGeometries)n.keyFragments.set(F,m),(T>1?E:d).set(T,F);Wn.get(n,this.webIfc);const I=this.webIfc.GetCoordinationMatrix(0);n.coordinationMatrix.fromArray(I),n.civilData=this._civil.read(this.webIfc);const f=this._groupSerializer.export(n);this.onIfcLoaded.trigger(f),n.dispose(!0)}cleanUp(){try{this.webIfc.Dispose()}catch{}this.webIfc=null,this.webIfc=new D.IfcAPI,this._visitedGeometries.clear(),this._geometries.clear(),this._assets=[],this._meshesWithHoles.clear()}getMesh(t,e,i){const o=e.geometries.size(),n=e.expressID,r={id:n,geometries:[]};for(let a=0;a<o;a++){const c=e.geometries.get(a),h=c.geometryExpressID,E=c.color.w===1?1:-1,d=h*E;if(!this._visitedGeometries.has(d)){this._visitedGeometries.has(h)||this.getGeometry(t,h);const R=this._visitedGeometries.size,S=g.MathUtils.generateUUID();this._visitedGeometries.set(d,{uuid:S,index:R})}const I=this._visitedGeometries.get(d);if(I===void 0)throw new Error("Error getting geometry data for streaming!");const f=i.data.get(n);if(!f)throw new Error("Data not found!");f[0].push(I.index);const{x:T,y:F,z:m,w:A}=c.color,O=[T,F,m,A],p=c.flatTransformation;r.geometries.push({color:O,geometryID:h,transformation:p})}this._assets.push(r)}getGeometry(t,e){const i=t.GetGeometry(0,e),o=t.GetIndexArray(i.GetIndexData(),i.GetIndexDataSize()),n=t.GetVertexArray(i.GetVertexData(),i.GetVertexDataSize()),r=new Float32Array(n.length/2),a=new Float32Array(n.length/2);for(let I=0;I<n.length;I+=6)r[I/2]=n[I],r[I/2+1]=n[I+1],r[I/2+2]=n[I+2],a[I/2]=n[I+3],a[I/2+1]=n[I+4],a[I/2+2]=n[I+5];const c=On(r),h=new Float32Array(c.transformation.elements),E=[c.center.x,c.center.y,c.center.z];let d=!1;for(let I=0;I<r.length-2;I+=3){const f=r[I],T=r[I+1],F=r[I+2],m=a[I],A=a[I+1],O=a[I+2];if(Sn(E,[f,T,F],[m,A,O])){d=!0;break}}this._geometries.set(e,{position:r,normal:a,index:o,boundingBox:h,hasHoles:d}),i.delete(),this._geometryCount++}async streamAssets(){await this.onAssetStreamed.trigger(this._assets),this._assets=null,this._assets=[]}async streamGeometries(){let t=this._streamSerializer.export(this._geometries),e={};for(const[i,{boundingBox:o,hasHoles:n}]of this._geometries)e[i]={boundingBox:o,hasHoles:n};this.onGeometryStreamed.trigger({data:e,buffer:t}),e=null,t=null,this._geometries.clear(),this._geometryCount=0}};u(_s,"uuid","d9999a00-e1f5-4d3f-8cfe-c56e08609764");let Ai=_s;class Xn extends Ds{constructor(){super(...arguments);u(this,"propertiesSize",100)}}class Zn extends ${constructor(){super(...arguments);u(this,"onPropertiesStreamed",new Le);u(this,"onProgress",new Le);u(this,"onIndicesStreamed",new Le);u(this,"onDisposed",new M);u(this,"enabled",!0);u(this,"settings",new Xn);u(this,"webIfc",new D.IfcAPI)}async dispose(){this.onIndicesStreamed.reset(),this.onPropertiesStreamed.reset(),this.webIfc=null,this.onDisposed.reset()}async streamFromBuffer(t){await this.readIfcFile(t),await this.streamAllProperties(),this.cleanUp()}async streamFromCallBack(t){await this.streamIfcFile(t),await this.streamAllProperties(),this.cleanUp()}async readIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModel(t,this.settings.webIfc)}async streamIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModelFromCallback(t,this.settings.webIfc)}async streamAllProperties(){const{propertiesSize:t}=this.settings,e=new Set(this.webIfc.GetIfcEntityList(0)),i=new Set([D.IFCPROJECT,D.IFCSITE,D.IFCBUILDING,D.IFCBUILDINGSTOREY,D.IFCSPACE]);for(const c of i)e.add(c);let o=.01,n=0;for(const c of e){if(n++,Li.has(c))continue;const h=i.has(c),E=this.webIfc.GetLineIDsWithType(0,c),d=E.size();let I=0;for(let T=0;T<d-t;T+=t){const F={};for(let m=0;m<t;m++){I++;const A=E.get(T+m);try{const O=this.webIfc.GetLine(0,A,h);F[O.expressID]=O}catch{console.log(`Could not get property: ${A}`)}}await this.onPropertiesStreamed.trigger({type:c,data:F})}if(I!==d){const T={};for(let F=I;F<d;F++){const m=E.get(F);try{const A=this.webIfc.GetLine(0,m,h);T[A.expressID]=A}catch{console.log(`Could not get property: ${m}`)}}await this.onPropertiesStreamed.trigger({type:c,data:T})}n/e.size>o&&(o=Math.round(o*100)/100,await this.onProgress.trigger(o),o+=.01)}await this.onProgress.trigger(1);const a=await this.components.get(Wt).processFromWebIfc(this.webIfc,0);await this.onIndicesStreamed.trigger(a)}cleanUp(){this.webIfc.Dispose(),this.webIfc=null,this.webIfc=new D.IfcAPI}}u(Zn,"uuid","88d2c89c-ce32-47d7-8cb6-d51e4b311a0b");const ys=class ys extends ${constructor(t){super(t);u(this,"enabled",!0);t.add(ys.uuid,this)}static distanceFromPointToLine(t,e,i,o=!1){const n=new g.Line3,r=new g.Vector3;return n.set(e,i),n.closestPointToPoint(t,o,r),r.distanceTo(t)}getFace(t,e,i){if(!t.geometry.index)throw new Error("Geometry must be indexed!");const o=new Map,n=t.geometry.index.array,{plane:r}=this.getFaceData(e,i,t),a=[];for(let d=0;d<n.length/3;d++){const{plane:I,edges:f}=this.getFaceData(d,i,t);if(I.equals(r)){a.push({index:d,edges:f});for(const{id:T,points:F,distance:m}of f)o.set(T,{points:F,distance:m})}}let c=0;const h=new Map,E=new Map;for(const{index:d,edges:I}of a){const f=new Map;for(const{id:R}of I)if(h.has(R)){const S=h.get(R);f.set(R,S)}const T=I.map(R=>R.id);if(!f.size){const R=c++;for(const{id:S}of I)h.set(S,R);E.set(R,{edges:new Set(T),indices:new Set([d])});continue}let F=null;const m=new Set,A=new Set(T);for(const[R,S]of f){F===null?F=S:S!==F&&m.add(S),h.delete(R);const{edges:_}=E.get(S);_.delete(R),A.delete(R)}if(F===null)throw new Error("Error computing face!");const O=E.get(F),{indices:p}=O;p.add(d);for(const R of A){h.set(R,F);const{edges:S}=O;S.add(R)}for(const R of m){const S=E.get(R),{edges:_,indices:y}=S,N=E.get(F),{edges:P,indices:x}=N;for(const w of _)P.add(w),h.set(w,F);for(const w of y)x.add(w);E.delete(R)}}for(const[d,{indices:I,edges:f}]of E)if(I.has(e)){const T=[];for(const F of f){const m=o.get(F);T.push(m)}return{edges:T,indices:I}}return null}getVerticesAndNormal(t,e,i){if(!t.geometry.index)throw new Error("Geometry must be indexed!");const o=t.geometry.index.array,n=t.geometry.attributes.position.array,r=t.geometry.attributes.normal.array,a=o[e*3]*3,c=o[e*3+1]*3,h=o[e*3+2]*3,E=new g.Vector3(n[a],n[a+1],n[a+2]),d=new g.Vector3(n[c],n[c+1],n[c+2]),I=new g.Vector3(n[h],n[h+1],n[h+2]),f=new g.Vector3(r[a],r[a+1],r[a+2]),T=new g.Vector3(r[c],r[c+1],r[c+2]),F=new g.Vector3(r[h],r[h+1],r[h+2]),m=(f.x+T.x+F.x)/3,A=(f.y+T.y+F.y)/3,O=(f.z+T.z+F.z)/3,p=new g.Vector3(m,A,O);if(i!==void 0&&t instanceof g.InstancedMesh){const R=new g.Matrix4;t.getMatrixAt(i,R);const S=new g.Matrix4;S.extractRotation(R),p.applyMatrix4(S),E.applyMatrix4(R),d.applyMatrix4(R),I.applyMatrix4(R)}return{p1:E,p2:d,p3:I,faceNormal:p}}round(t){t.x=Math.trunc(t.x*1e3)/1e3,t.y=Math.trunc(t.y*1e3)/1e3,t.z=Math.trunc(t.z*1e3)/1e3}getVolumeFromFragments(t){const e=this.components.get(ot),i=new g.Matrix4,o=[];for(const r in t){const a=e.list.get(r);if(!a)continue;const c=t[r];let h=0;for(const I of c){const f=a.getInstancesIDs(I);f&&(h+=f.size)}const E=new g.InstancedMesh(a.mesh.geometry,void 0,h);let d=0;for(const I of c){const f=a.getInstancesIDs(I);if(f)for(const T of f)a.mesh.getMatrixAt(T,i),E.setMatrixAt(d++,i)}o.push(E)}const n=this.getVolumeFromMeshes(o);for(const r of o)r.geometry=null,r.material=[],r.dispose();return n}getVolumeFromMeshes(t){let e=0;for(const i of t)e+=this.getVolumeOfMesh(i);return e}getFaceData(t,e,i){const o=this.getVerticesAndNormal(i,t,e),{p1:n,p2:r,p3:a,faceNormal:c}=o;this.round(n),this.round(r),this.round(a),this.round(c);const h=[{id:`${n.x}|${n.y}|${n.z}`,value:n},{id:`${r.x}|${r.y}|${r.z}`,value:r},{id:`${a.x}|${a.y}|${a.z}`,value:a}];h.sort((O,p)=>O.id<p.id?-1:O.id>p.id?1:0);const[{id:E,value:d},{id:I,value:f},{id:T,value:F}]=h,m=[{id:`${E}|${I}`,distance:d.distanceTo(f),points:[d,f]},{id:`${I}|${T}`,distance:f.distanceTo(F),points:[f,F]},{id:`${E}|${T}`,distance:d.distanceTo(F),points:[d,F]}],A=new g.Plane;return A.setFromNormalAndCoplanarPoint(c,n),A.constant=Math.round(A.constant*10)/10,{plane:A,edges:m}}getVolumeOfMesh(t){let e=0;const i=new g.Vector3,o=new g.Vector3,n=new g.Vector3,{index:r}=t.geometry,a=t.geometry.attributes.position.array;if(!r)return console.warn("Geometry must be indexed to compute its volume!"),0;const c=[];if(t instanceof g.InstancedMesh)for(let E=0;E<t.count;E++){const d=new g.Matrix4;t.getMatrixAt(E,d),c.push(d)}else c.push(new g.Matrix4().identity());const{matrixWorld:h}=t;for(let E=0;E<r.array.length-2;E+=3)for(const d of c){const I=d.multiply(h),f=r.array[E]*3,T=r.array[E+1]*3,F=r.array[E+2]*3;i.set(a[f],a[f+1],a[f+2]).applyMatrix4(I),o.set(a[T],a[T+1],a[T+2]).applyMatrix4(I),n.set(a[F],a[F+1],a[F+2]).applyMatrix4(I),e+=this.getSignedVolumeOfTriangle(i,o,n)}return Math.abs(e)}getSignedVolumeOfTriangle(t,e,i){const o=i.x*e.y*t.z,n=e.x*i.y*t.z,r=i.x*t.y*e.z,a=t.x*i.y*e.z,c=e.x*t.y*i.z,h=t.x*e.y*i.z;return 1/6*(-o+n+r-a-c+h)}};u(ys,"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");let gi=ys;exports.AsyncEvent=Le;exports.Base=Ps;exports.BaseCamera=Fn;exports.BaseRenderer=An;exports.BaseScene=gn;exports.BaseWorldItem=ws;exports.BoundingBoxer=Ti;exports.Classifier=fs;exports.Clipper=pi;exports.Component=$;exports.Components=hs;exports.CullerRenderer=Pn;exports.Cullers=Es;exports.DataMap=di;exports.DataSet=or;exports.Disposer=_t;exports.Event=M;exports.Exploder=Ri;exports.FirstPersonMode=bn;exports.FragmentsManager=ot;exports.GeometryTypes=Li;exports.Grids=fi;exports.Hider=Fi;exports.IfcCategories=xr;exports.IfcCategoryMap=Pi;exports.IfcElements=Yn;exports.IfcFragmentSettings=Ds;exports.IfcGeometryTiler=Ai;exports.IfcJsonExporter=us;exports.IfcLoader=Is;exports.IfcPropertiesManager=mi;exports.IfcPropertiesTiler=Zn;exports.IfcPropertiesUtils=xt;exports.IfcRelationsIndexer=Wt;exports.IfcStreamingSettings=kn;exports.MaterialsUtils=Ii;exports.MeasurementUtils=gi;exports.MeshCullerRenderer=wn;exports.MiniMap=Un;exports.MiniMaps=Ci;exports.Mouse=Mn;exports.OrbitMode=vn;exports.OrthoPerspectiveCamera=Mr;exports.PlanMode=Bn;exports.ProjectionManager=Vn;exports.PropertiesStreamingSettings=Xn;exports.Raycasters=le;exports.ShadowedScene=gr;exports.SimpleCamera=ce;exports.SimpleGrid=xn;exports.SimplePlane=Ms;exports.SimpleRaycaster=Dn;exports.SimpleRenderer=fr;exports.SimpleScene=yn;exports.SimpleWorld=_n;exports.UUID=ae;exports.VertexPicker=Ir;exports.Worlds=ds;exports.isPointInFrontOfPlane=Sn;exports.obbFromPoints=On;exports.readPixelsAsync=Ni;
|