@thatopen/components 1.5.0 → 2.0.0-alpha.1

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.
Files changed (85) hide show
  1. package/dist/core/Clipper/index.d.ts +104 -0
  2. package/dist/core/Clipper/src/index.d.ts +1 -0
  3. package/dist/core/Clipper/src/simple-plane.d.ts +61 -0
  4. package/dist/core/Components/index.d.ts +52 -0
  5. package/dist/core/Cullers/index.d.ts +23 -0
  6. package/dist/core/Cullers/src/culler-renderer.d.ts +66 -0
  7. package/dist/core/Cullers/src/index.d.ts +3 -0
  8. package/dist/core/Cullers/src/mesh-culler-renderer.d.ts +27 -0
  9. package/dist/core/Cullers/src/screen-culler-helper.d.ts +1 -0
  10. package/dist/core/Disposer/index.d.ts +43 -0
  11. package/dist/core/Grids/index.d.ts +13 -0
  12. package/dist/core/Grids/src/index.d.ts +1 -0
  13. package/dist/core/Grids/src/simple-grid.d.ts +48 -0
  14. package/dist/core/Materials/index.d.ts +61 -0
  15. package/dist/core/Raycasters/index.d.ts +13 -0
  16. package/dist/core/Raycasters/src/index.d.ts +2 -0
  17. package/dist/core/Raycasters/src/mouse.d.ts +26 -0
  18. package/dist/core/Raycasters/src/simple-raycaster.d.ts +36 -0
  19. package/dist/core/Types/index.d.ts +1 -0
  20. package/dist/core/Types/src/base-camera.d.ts +11 -0
  21. package/dist/core/Types/src/base-renderer.d.ts +40 -0
  22. package/dist/core/Types/src/base-scene.d.ts +13 -0
  23. package/dist/core/Types/src/base-world-item.d.ts +17 -0
  24. package/dist/core/Types/src/base.d.ts +19 -0
  25. package/dist/core/Types/src/component.d.ts +18 -0
  26. package/dist/core/Types/src/event.d.ts +34 -0
  27. package/dist/core/Types/src/index.d.ts +9 -0
  28. package/dist/core/Types/src/interfaces.d.ts +134 -0
  29. package/dist/core/Types/src/world.d.ts +12 -0
  30. package/dist/core/Worlds/index.d.ts +17 -0
  31. package/dist/core/Worlds/src/index.d.ts +4 -0
  32. package/dist/core/Worlds/src/simple-camera.d.ts +46 -0
  33. package/dist/core/Worlds/src/simple-renderer.d.ts +32 -0
  34. package/dist/core/Worlds/src/simple-scene.d.ts +30 -0
  35. package/dist/core/Worlds/src/simple-world.d.ts +26 -0
  36. package/dist/core/index.d.ts +9 -0
  37. package/dist/fragments/FragmentBoundingBox/index.d.ts +36 -0
  38. package/dist/fragments/FragmentClassifier/index.d.ts +30 -0
  39. package/dist/fragments/FragmentExploder/index.d.ts +15 -0
  40. package/dist/fragments/FragmentIfcLoader/index.d.ts +33 -0
  41. package/dist/fragments/FragmentIfcLoader/src/civil-reader.d.ts +15 -0
  42. package/dist/fragments/FragmentIfcLoader/src/ifc-fragment-settings.d.ts +27 -0
  43. package/dist/fragments/FragmentIfcLoader/src/ifc-metadata-reader.d.ts +4 -0
  44. package/dist/fragments/FragmentIfcLoader/src/index.d.ts +3 -0
  45. package/dist/fragments/FragmentIfcLoader/src/spatial-structure.d.ts +8 -0
  46. package/dist/fragments/FragmentIfcLoader/src/transform-helper.d.ts +5 -0
  47. package/dist/fragments/FragmentIfcLoader/src/units.d.ts +10 -0
  48. package/dist/fragments/FragmentIfcStreamer/index.d.ts +1 -0
  49. package/dist/fragments/FragmentIfcStreamer/src/base-types.d.ts +15 -0
  50. package/dist/fragments/FragmentIfcStreamer/src/fragment-ifc-stream-converter.d.ts +41 -0
  51. package/dist/fragments/FragmentIfcStreamer/src/fragment-props-stream-converter.d.ts +27 -0
  52. package/dist/fragments/FragmentIfcStreamer/src/index.d.ts +4 -0
  53. package/dist/fragments/FragmentIfcStreamer/src/streaming-settings.d.ts +10 -0
  54. package/dist/fragments/FragmentManager/index.d.ts +44 -0
  55. package/dist/fragments/index.d.ts +5 -0
  56. package/dist/ifc/IfcJsonExporter/index.d.ts +16 -0
  57. package/dist/ifc/IfcJsonExporter/src/ifc-geometry-types.d.ts +1 -0
  58. package/dist/ifc/IfcPropertiesFinder/index.d.ts +37 -0
  59. package/dist/ifc/IfcPropertiesFinder/src/types.d.ts +23 -0
  60. package/dist/ifc/IfcPropertiesIndexer/index.d.ts +31 -0
  61. package/dist/ifc/IfcPropertiesManager/index.d.ts +73 -0
  62. package/dist/ifc/Utils/ifc-categories.d.ts +7 -0
  63. package/dist/ifc/Utils/ifc-category-map.d.ts +3 -0
  64. package/dist/ifc/Utils/ifc-elements-map.d.ts +3 -0
  65. package/dist/ifc/Utils/index.d.ts +4 -0
  66. package/dist/ifc/Utils/properties-utils.d.ts +25 -0
  67. package/dist/ifc/index.d.ts +5 -0
  68. package/dist/index.cjs +88 -0
  69. package/dist/index.d.ts +4 -0
  70. package/dist/index.mjs +9024 -0
  71. package/dist/namespace.d.ts +1744 -0
  72. package/dist/navigation/OrthoPerspectiveCamera/index.d.ts +49 -0
  73. package/dist/navigation/OrthoPerspectiveCamera/src/first-person-mode.d.ts +16 -0
  74. package/dist/navigation/OrthoPerspectiveCamera/src/index.d.ts +5 -0
  75. package/dist/navigation/OrthoPerspectiveCamera/src/orbit-mode.d.ts +16 -0
  76. package/dist/navigation/OrthoPerspectiveCamera/src/plan-mode.d.ts +20 -0
  77. package/dist/navigation/OrthoPerspectiveCamera/src/projections.d.ts +37 -0
  78. package/dist/navigation/OrthoPerspectiveCamera/src/types.d.ts +27 -0
  79. package/dist/navigation/index.d.ts +1 -0
  80. package/dist/utils/bbox.d.ts +7 -0
  81. package/dist/utils/geometry.d.ts +1 -0
  82. package/dist/utils/index.d.ts +4 -0
  83. package/dist/utils/materials.d.ts +4 -0
  84. package/dist/utils/uuid.d.ts +6 -0
  85. package/package.json +10 -5
package/dist/index.cjs ADDED
@@ -0,0 +1,88 @@
1
+ "use strict";var Pn=Object.defineProperty;var Mn=(c,s,t)=>s in c?Pn(c,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[s]=t;var f=(c,s,t)=>(Mn(c,typeof s!="symbol"?s+"":s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("three"),wn=require("web-ifc"),en=require("bim-fragment");function Ei(c){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(s,t,e.get?e:{enumerable:!0,get:()=>c[t]})}}return s.default=c,Object.freeze(s)}const L=Ei(C),b=Ei(wn),Ht=Ei(en),sn=0,Dn=1,Un=2,mi=2,_s=1.25,Ri=1,os=6*4+4+4,Ts=65535,xn=Math.pow(2,-24),Ns=Symbol("SKIP_GENERATION");function bn(c){return c.index?c.index.count:c.attributes.position.count}function re(c){return bn(c)/3}function vn(c,s=ArrayBuffer){return c>65535?new Uint32Array(new s(4*c)):new Uint16Array(new s(2*c))}function Bn(c,s){if(!c.index){const t=c.attributes.position.count,e=s.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=vn(t,e);c.setIndex(new C.BufferAttribute(i,1));for(let o=0;o<t;o++)i[o]=o}}function nn(c){const s=re(c),t=c.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 on(c){if(!c.groups||!c.groups.length)return nn(c);const s=[],t=new Set,e=c.drawRange,i=e.start/3,o=(e.start+e.count)/3;for(const r of c.groups){const a=r.start/3,l=(r.start+r.count)/3;t.add(Math.max(i,a)),t.add(Math.min(o,l))}const n=Array.from(t.values()).sort((r,a)=>r-a);for(let r=0;r<n.length-1;r++){const a=n[r],l=n[r+1];s.push({offset:Math.floor(a),count:Math.floor(l-a)})}return s}function Yn(c){if(c.groups.length===0)return!1;const s=re(c),t=on(c).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 j(c,s,t){return t.min.x=s[c],t.min.y=s[c+1],t.min.z=s[c+2],t.max.x=s[c+3],t.max.y=s[c+4],t.max.z=s[c+5],t}function Vn(c){c[0]=c[1]=c[2]=1/0,c[3]=c[4]=c[5]=-1/0}function Fi(c){let s=-1,t=-1/0;for(let e=0;e<3;e++){const i=c[e+3]-c[e];i>t&&(t=i,s=e)}return s}function Ai(c,s){s.set(c)}function Oi(c,s,t){let e,i;for(let o=0;o<3;o++){const n=o+3;e=c[o],i=s[o],t[o]=e<i?e:i,e=c[n],i=s[n],t[n]=e>i?e:i}}function be(c,s,t){for(let e=0;e<3;e++){const i=s[c+2*e],o=s[c+2*e+1],n=i-o,r=i+o;n<t[e]&&(t[e]=n),r>t[e+3]&&(t[e+3]=r)}}function le(c){const s=c[3]-c[0],t=c[4]-c[1],e=c[5]-c[2];return 2*(s*t+t*e+e*s)}function ys(c,s,t,e,i=null){let o=1/0,n=1/0,r=1/0,a=-1/0,l=-1/0,E=-1/0,I=1/0,h=1/0,d=1/0,p=-1/0,F=-1/0,A=-1/0;const T=i!==null;for(let m=s*6,O=(s+t)*6;m<O;m+=6){const u=c[m+0],R=c[m+1],S=u-R,g=u+R;S<o&&(o=S),g>a&&(a=g),T&&u<I&&(I=u),T&&u>p&&(p=u);const _=c[m+2],N=c[m+3],P=_-N,w=_+N;P<n&&(n=P),w>l&&(l=w),T&&_<h&&(h=_),T&&_>F&&(F=_);const M=c[m+4],D=c[m+5],x=M-D,v=M+D;x<r&&(r=x),v>E&&(E=v),T&&M<d&&(d=M),T&&M>A&&(A=M)}e[0]=o,e[1]=n,e[2]=r,e[3]=a,e[4]=l,e[5]=E,T&&(i[0]=I,i[1]=h,i[2]=d,i[3]=p,i[4]=F,i[5]=A)}function Gn(c,s,t,e){let i=1/0,o=1/0,n=1/0,r=-1/0,a=-1/0,l=-1/0;for(let E=s*6,I=(s+t)*6;E<I;E+=6){const h=c[E+0];h<i&&(i=h),h>r&&(r=h);const d=c[E+2];d<o&&(o=d),d>a&&(a=d);const p=c[E+4];p<n&&(n=p),p>l&&(l=p)}e[0]=i,e[1]=o,e[2]=n,e[3]=r,e[4]=a,e[5]=l}function Hn(c,s){Vn(s);const t=c.attributes.position,e=c.index?c.index.array:null,i=re(c),o=new Float32Array(i*6),n=t.normalized,r=t.array,a=t.offset||0;let l=3;t.isInterleavedBufferAttribute&&(l=t.data.stride);const E=["getX","getY","getZ"];for(let I=0;I<i;I++){const h=I*3,d=I*6;let p=h+0,F=h+1,A=h+2;e&&(p=e[p],F=e[F],A=e[A]),n||(p=p*l+a,F=F*l+a,A=A*l+a);for(let T=0;T<3;T++){let m,O,u;n?(m=t[E[T]](p),O=t[E[T]](F),u=t[E[T]](A)):(m=r[p+T],O=r[F+T],u=r[A+T]);let R=m;O<R&&(R=O),u<R&&(R=u);let S=m;O>S&&(S=O),u>S&&(S=u);const g=(S-R)/2,_=T*2;o[d+_+0]=R+g,o[d+_+1]=g+(Math.abs(R)+g)*xn,R<s[T]&&(s[T]=R),S>s[T+3]&&(s[T+3]=S)}}return o}const St=32,zn=(c,s)=>c.candidate-s.candidate,Nt=new Array(St).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ve=new Float32Array(6);function kn(c,s,t,e,i,o){let n=-1,r=0;if(o===sn)n=Fi(s),n!==-1&&(r=(s[n]+s[n+3])/2);else if(o===Dn)n=Fi(c),n!==-1&&(r=Wn(t,e,i,n));else if(o===Un){const a=le(c);let l=_s*i;const E=e*6,I=(e+i)*6;for(let h=0;h<3;h++){const d=s[h],A=(s[h+3]-d)/St;if(i<St/4){const T=[...Nt];T.length=i;let m=0;for(let u=E;u<I;u+=6,m++){const R=T[m];R.candidate=t[u+2*h],R.count=0;const{bounds:S,leftCacheBounds:g,rightCacheBounds:_}=R;for(let N=0;N<3;N++)_[N]=1/0,_[N+3]=-1/0,g[N]=1/0,g[N+3]=-1/0,S[N]=1/0,S[N+3]=-1/0;be(u,t,S)}T.sort(zn);let O=i;for(let u=0;u<O;u++){const R=T[u];for(;u+1<O&&T[u+1].candidate===R.candidate;)T.splice(u+1,1),O--}for(let u=E;u<I;u+=6){const R=t[u+2*h];for(let S=0;S<O;S++){const g=T[S];R>=g.candidate?be(u,t,g.rightCacheBounds):(be(u,t,g.leftCacheBounds),g.count++)}}for(let u=0;u<O;u++){const R=T[u],S=R.count,g=i-R.count,_=R.leftCacheBounds,N=R.rightCacheBounds;let P=0;S!==0&&(P=le(_)/a);let w=0;g!==0&&(w=le(N)/a);const M=Ri+_s*(P*S+w*g);M<l&&(n=h,l=M,r=R.candidate)}}else{for(let O=0;O<St;O++){const u=Nt[O];u.count=0,u.candidate=d+A+O*A;const R=u.bounds;for(let S=0;S<3;S++)R[S]=1/0,R[S+3]=-1/0}for(let O=E;O<I;O+=6){let S=~~((t[O+2*h]-d)/A);S>=St&&(S=St-1);const g=Nt[S];g.count++,be(O,t,g.bounds)}const T=Nt[St-1];Ai(T.bounds,T.rightCacheBounds);for(let O=St-2;O>=0;O--){const u=Nt[O],R=Nt[O+1];Oi(u.bounds,R.rightCacheBounds,u.rightCacheBounds)}let m=0;for(let O=0;O<St-1;O++){const u=Nt[O],R=u.count,S=u.bounds,_=Nt[O+1].rightCacheBounds;R!==0&&(m===0?Ai(S,ve):Oi(S,ve,ve)),m+=R;let N=0,P=0;m!==0&&(N=le(ve)/a);const w=i-m;w!==0&&(P=le(_)/a);const M=Ri+_s*(N*m+P*w);M<l&&(n=h,l=M,r=u.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${o} used.`);return{axis:n,pos:r}}function Wn(c,s,t,e){let i=0;for(let o=s,n=s+t;o<n;o++)i+=c[o*6+e*2];return i/t}class Be{constructor(){}}function Xn(c,s,t,e,i,o){let n=e,r=e+i-1;const a=o.pos,l=o.axis*2;for(;;){for(;n<=r&&t[n*6+l]<a;)n++;for(;n<=r&&t[r*6+l]>=a;)r--;if(n<r){for(let E=0;E<3;E++){let I=s[n*3+E];s[n*3+E]=s[r*3+E],s[r*3+E]=I}for(let E=0;E<6;E++){let I=t[n*6+E];t[n*6+E]=t[r*6+E],t[r*6+E]=I}n++,r--}else return n}}function Zn(c,s,t,e,i,o){let n=e,r=e+i-1;const a=o.pos,l=o.axis*2;for(;;){for(;n<=r&&t[n*6+l]<a;)n++;for(;n<=r&&t[r*6+l]>=a;)r--;if(n<r){let E=c[n];c[n]=c[r],c[r]=E;for(let I=0;I<6;I++){let h=t[n*6+I];t[n*6+I]=t[r*6+I],t[r*6+I]=h}n++,r--}else return n}}function Qn(c,s){const t=(c.index?c.index.count:c.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 qn(c,s){const t=c.geometry,e=t.index?t.index.array:null,i=s.maxDepth,o=s.verbose,n=s.maxLeafTris,r=s.strategy,a=s.onProgress,l=re(t),E=c._indirectBuffer;let I=!1;const h=new Float32Array(6),d=new Float32Array(6),p=Hn(t,h),F=s.indirect?Zn:Xn,A=[],T=s.indirect?nn(t):on(t);if(T.length===1){const u=T[0],R=new Be;R.boundingData=h,Gn(p,u.offset,u.count,d),O(R,u.offset,u.count,d),A.push(R)}else for(let u of T){const R=new Be;R.boundingData=new Float32Array(6),ys(p,u.offset,u.count,R.boundingData,d),O(R,u.offset,u.count,d),A.push(R)}return A;function m(u){a&&a(u/l)}function O(u,R,S,g=null,_=0){if(!I&&_>=i&&(I=!0,o&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),S<=n||_>=i)return m(R+S),u.offset=R,u.count=S,u;const N=kn(u.boundingData,g,p,R,S,r);if(N.axis===-1)return m(R+S),u.offset=R,u.count=S,u;const P=F(E,e,p,R,S,N);if(P===R||P===R+S)m(R+S),u.offset=R,u.count=S;else{u.splitAxis=N.axis;const w=new Be,M=R,D=P-R;u.left=w,w.boundingData=new Float32Array(6),ys(p,M,D,w.boundingData,d),O(w,M,D,d,_+1);const x=new Be,v=P,H=S-D;u.right=x,x.boundingData=new Float32Array(6),ys(p,v,H,x.boundingData,d),O(x,v,H,d,_+1)}return u}}function jn(c,s){const t=c.geometry;s.indirect&&(c._indirectBuffer=Qn(t,s.useSharedArrayBuffer),Yn(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.')),c._indirectBuffer||Bn(t,s);const e=qn(c,s);let i,o,n;const r=[],a=s.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let I=0;I<e.length;I++){const h=e[I];let d=l(h);const p=new a(os*d);i=new Float32Array(p),o=new Uint32Array(p),n=new Uint16Array(p),E(0,h),r.push(p)}c._roots=r;return;function l(I){return I.count?1:1+l(I.left)+l(I.right)}function E(I,h){const d=I/4,p=I/2,F=!!h.count,A=h.boundingData;for(let T=0;T<6;T++)i[d+T]=A[T];if(F){const T=h.offset,m=h.count;return o[d+6]=T,n[p+14]=m,n[p+15]=Ts,I+os}else{const T=h.left,m=h.right,O=h.splitAxis;let u;if(u=E(I+os,T),u/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return o[d+6]=u/4,u=E(u,m),o[d+7]=O,u}}}class gt{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}}gt.prototype.setFromBox=function(){const c=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 l=0;l<=1;l++)for(let E=0;E<=1;E++){c.x=i.x*a+o.x*(1-a),c.y=i.y*l+o.y*(1-l),c.z=i.z*E+o.z*(1-E);const I=t.dot(c);n=Math.min(I,n),r=Math.max(I,r)}this.min=n,this.max=r}}();const Kn=function(){const c=new C.Vector3,s=new C.Vector3,t=new C.Vector3;return function(i,o,n){const r=i.start,a=c,l=o.start,E=s;t.subVectors(r,l),c.subVectors(i.end,i.start),s.subVectors(o.end,o.start);const I=t.dot(E),h=E.dot(a),d=E.dot(E),p=t.dot(a),A=a.dot(a)*d-h*h;let T,m;A!==0?T=(I*h-p*d)/A:T=0,m=(I+T*h)/d,n.x=T,n.y=m}}(),Ii=function(){const c=new C.Vector2,s=new C.Vector3,t=new C.Vector3;return function(i,o,n,r){Kn(i,o,c);let a=c.x,l=c.y;if(a>=0&&a<=1&&l>=0&&l<=1){i.at(a,n),o.at(l,r);return}else if(a>=0&&a<=1){l<0?o.at(0,r):o.at(1,r),i.closestPointToPoint(r,!0,n);return}else if(l>=0&&l<=1){a<0?i.at(0,n):i.at(1,n),o.closestPointToPoint(n,!0,r);return}else{let E;a<0?E=i.start:E=i.end;let I;l<0?I=o.start:I=o.end;const h=s,d=t;if(i.closestPointToPoint(I,!0,s),o.closestPointToPoint(E,!0,t),h.distanceToSquared(I)<=d.distanceToSquared(E)){n.copy(h),r.copy(I);return}else{n.copy(E),r.copy(d);return}}}}(),$n=function(){const c=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:l,b:E,c:I}=n;if(e.start=l,e.end=E,e.closestPointToPoint(a,!0,c).distanceTo(a)<=r||(e.start=l,e.end=I,e.closestPointToPoint(a,!0,c).distanceTo(a)<=r)||(e.start=E,e.end=I,e.closestPointToPoint(a,!0,c).distanceTo(a)<=r))return!0;const F=n.getPlane(t);if(Math.abs(F.distanceToPoint(a))<=r){const T=F.projectPoint(a,s);if(n.containsPoint(T))return!0}return!1}}(),Jn=1e-15;function Ls(c){return Math.abs(c)<Jn}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 gt),this.points=[this.a,this.b,this.c],this.sphere=new C.Sphere,this.plane=new C.Plane,this.needsUpdate=!0}intersectsSphere(s){return $n(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 l=o[1],E=n[1];l.subVectors(s,t),E.setFromPoints(l,i);const I=o[2],h=n[2];I.subVectors(t,e),h.setFromPoints(I,i);const d=o[3],p=n[3];d.subVectors(e,s),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(r,s),this.needsUpdate=!1}}mt.prototype.closestPointToSegment=function(){const c=new C.Vector3,s=new C.Vector3,t=new C.Line3;return function(i,o=null,n=null){const{start:r,end:a}=i,l=this.points;let E,I=1/0;for(let h=0;h<3;h++){const d=(h+1)%3;t.start.copy(l[h]),t.end.copy(l[d]),Ii(t,i,c,s),E=c.distanceToSquared(s),E<I&&(I=E,o&&o.copy(c),n&&n.copy(s))}return this.closestPointToPoint(r,c),E=r.distanceToSquared(c),E<I&&(I=E,o&&o.copy(c),n&&n.copy(r)),this.closestPointToPoint(a,c),E=a.distanceToSquared(c),E<I&&(I=E,o&&o.copy(c),n&&n.copy(a)),Math.sqrt(I)}}();mt.prototype.intersectsTriangle=function(){const c=new mt,s=new Array(3),t=new Array(3),e=new gt,i=new gt,o=new C.Vector3,n=new C.Vector3,r=new C.Vector3,a=new C.Vector3,l=new C.Vector3,E=new C.Line3,I=new C.Line3,h=new C.Line3,d=new C.Vector3;function p(F,A,T){const m=F.points;let O=0,u=-1;for(let R=0;R<3;R++){const{start:S,end:g}=E;S.copy(m[R]),g.copy(m[(R+1)%3]),E.delta(n);const _=Ls(A.distanceToPoint(S));if(Ls(A.normal.dot(n))&&_){T.copy(E),O=2;break}const N=A.intersectLine(E,d);if(!N&&_&&d.copy(S),(N||_)&&!Ls(d.distanceTo(g))){if(O<=1)(O===1?T.start:T.end).copy(d),_&&(u=O);else if(O>=2){(u===1?T.start:T.end).copy(d),O=2;break}if(O++,O===2&&u===-1)break}}return O}return function(A,T=null,m=!1){this.needsUpdate&&this.update(),A.isExtendedTriangle?A.needsUpdate&&A.update():(c.copy(A),c.update(),A=c);const O=this.plane,u=A.plane;if(Math.abs(O.normal.dot(u.normal))>1-1e-10){const R=this.satBounds,S=this.satAxes;t[0]=A.a,t[1]=A.b,t[2]=A.c;for(let N=0;N<4;N++){const P=R[N],w=S[N];if(e.setFromPoints(w,t),P.isSeparated(e))return!1}const g=A.satBounds,_=A.satAxes;s[0]=this.a,s[1]=this.b,s[2]=this.c;for(let N=0;N<4;N++){const P=g[N],w=_[N];if(e.setFromPoints(w,s),P.isSeparated(e))return!1}for(let N=0;N<4;N++){const P=S[N];for(let w=0;w<4;w++){const M=_[w];if(o.crossVectors(P,M),e.setFromPoints(o,s),i.setFromPoints(o,t),e.isSeparated(i))return!1}}return T&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),T.start.set(0,0,0),T.end.set(0,0,0)),!0}else{const R=p(this,u,I);if(R===1&&A.containsPoint(I.end))return T&&(T.start.copy(I.end),T.end.copy(I.end)),!0;if(R!==2)return!1;const S=p(A,O,h);if(S===1&&this.containsPoint(h.end))return T&&(T.start.copy(h.end),T.end.copy(h.end)),!0;if(S!==2)return!1;if(I.delta(r),h.delta(a),r.dot(a)<0){let D=h.start;h.start=h.end,h.end=D}const g=I.start.dot(r),_=I.end.dot(r),N=h.start.dot(r),P=h.end.dot(r),w=_<N,M=g<P;return g!==P&&N!==_&&w===M?!1:(T&&(l.subVectors(I.start,h.start),l.dot(r)>0?T.start.copy(I.start):T.start.copy(h.start),l.subVectors(I.end,h.end),l.dot(r)<0?T.end.copy(I.end):T.end.copy(h.end)),!0)}}}();mt.prototype.distanceToPoint=function(){const c=new C.Vector3;return function(t){return this.closestPointToPoint(t,c),t.distanceTo(c)}}();mt.prototype.distanceToTriangle=function(){const c=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 l=r||a?e:null;if(this.intersectsTriangle(n,l))return(r||a)&&(r&&l.getCenter(r),a&&l.getCenter(a)),0;let E=1/0;for(let I=0;I<3;I++){let h;const d=t[I],p=n[d];this.closestPointToPoint(p,c),h=p.distanceToSquared(c),h<E&&(E=h,r&&r.copy(c),a&&a.copy(p));const F=this[d];n.closestPointToPoint(F,c),h=F.distanceToSquared(c),h<E&&(E=h,r&&r.copy(F),a&&a.copy(c))}for(let I=0;I<3;I++){const h=t[I],d=t[(I+1)%3];e.set(this[h],this[d]);for(let p=0;p<3;p++){const F=t[p],A=t[(p+1)%3];i.set(n[F],n[A]),Ii(e,i,c,s);const T=c.distanceToSquared(s);T<E&&(E=T,r&&r.copy(c),a&&a.copy(s))}}return Math.sqrt(E)}}();class nt{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 gt),this.alignedSatBounds=new Array(3).fill().map(()=>new gt),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}}nt.prototype.update=function(){return function(){const s=this.matrix,t=this.min,e=this.max,i=this.points;for(let l=0;l<=1;l++)for(let E=0;E<=1;E++)for(let I=0;I<=1;I++){const h=1*l|2*E|4*I,d=i[h];d.x=l?e.x:t.x,d.y=E?e.y:t.y,d.z=I?e.z:t.z,d.applyMatrix4(s)}const o=this.satBounds,n=this.satAxes,r=i[0];for(let l=0;l<3;l++){const E=n[l],I=o[l],h=1<<l,d=i[h];E.subVectors(r,d),I.setFromPoints(E,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}}();nt.prototype.intersectsBox=function(){const c=new gt;return function(t){this.needsUpdate&&this.update();const e=t.min,i=t.max,o=this.satBounds,n=this.satAxes,r=this.alignedSatBounds;if(c.min=e.x,c.max=i.x,r[0].isSeparated(c)||(c.min=e.y,c.max=i.y,r[1].isSeparated(c))||(c.min=e.z,c.max=i.z,r[2].isSeparated(c)))return!1;for(let a=0;a<3;a++){const l=n[a],E=o[a];if(c.setFromBox(l,t),E.isSeparated(c))return!1}return!0}}();nt.prototype.intersectsTriangle=function(){const c=new mt,s=new Array(3),t=new gt,e=new gt,i=new C.Vector3;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(c.copy(n),c.update(),n=c);const r=this.satBounds,a=this.satAxes;s[0]=n.a,s[1]=n.b,s[2]=n.c;for(let h=0;h<3;h++){const d=r[h],p=a[h];if(t.setFromPoints(p,s),d.isSeparated(t))return!1}const l=n.satBounds,E=n.satAxes,I=this.points;for(let h=0;h<3;h++){const d=l[h],p=E[h];if(t.setFromPoints(p,I),d.isSeparated(t))return!1}for(let h=0;h<3;h++){const d=a[h];for(let p=0;p<4;p++){const F=E[p];if(i.crossVectors(d,F),t.setFromPoints(i,s),e.setFromPoints(i,I),t.isSeparated(e))return!1}}return!0}}();nt.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}}();nt.prototype.distanceToPoint=function(){const c=new C.Vector3;return function(t){return this.closestPointToPoint(t,c),t.distanceTo(c)}}();nt.prototype.distanceToBox=function(){const c=["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,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(a||l)&&(n.getCenter(i),this.closestPointToPoint(i,e),n.closestPointToPoint(e,i),a&&a.copy(e),l&&l.copy(i)),0;const E=r*r,I=n.min,h=n.max,d=this.points;let p=1/0;for(let A=0;A<8;A++){const T=d[A];i.copy(T).clamp(I,h);const m=T.distanceToSquared(i);if(m<p&&(p=m,a&&a.copy(T),l&&l.copy(i),m<E))return Math.sqrt(m)}let F=0;for(let A=0;A<3;A++)for(let T=0;T<=1;T++)for(let m=0;m<=1;m++){const O=(A+1)%3,u=(A+2)%3,R=T<<O|m<<u,S=1<<A|T<<O|m<<u,g=d[R],_=d[S];s[F].set(g,_);const P=c[A],w=c[O],M=c[u],D=t[F],x=D.start,v=D.end;x[P]=I[P],x[w]=T?I[w]:h[w],x[M]=m?I[M]:h[w],v[P]=h[P],v[w]=T?I[w]:h[w],v[M]=m?I[M]:h[w],F++}for(let A=0;A<=1;A++)for(let T=0;T<=1;T++)for(let m=0;m<=1;m++){i.x=A?h.x:I.x,i.y=T?h.y:I.y,i.z=m?h.z:I.z,this.closestPointToPoint(i,e);const O=i.distanceToSquared(e);if(O<p&&(p=O,a&&a.copy(e),l&&l.copy(i),O<E))return Math.sqrt(O)}for(let A=0;A<12;A++){const T=s[A];for(let m=0;m<12;m++){const O=t[m];Ii(T,O,e,i);const u=e.distanceToSquared(i);if(u<p&&(p=u,a&&a.copy(e),l&&l.copy(i),u<E))return Math.sqrt(u)}}return Math.sqrt(p)}}();class di{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 to extends di{constructor(){super(()=>new mt)}}const lt=new to;function rt(c,s){return s[c+15]===65535}function at(c,s){return s[c+6]}function ht(c,s){return s[c+14]}function Et(c){return c+8}function It(c,s){return s[c+6]}function rn(c,s){return s[c+7]}class eo{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 eo;let wt,ne;const kt=[],Ye=new di(()=>new C.Box3);function so(c,s,t,e,i,o){wt=Ye.getPrimitive(),ne=Ye.getPrimitive(),kt.push(wt,ne),X.setBuffer(c._roots[s]);const n=Zs(0,c.geometry,t,e,i,o);X.clearBuffer(),Ye.releasePrimitive(wt),Ye.releasePrimitive(ne),kt.pop(),kt.pop();const r=kt.length;return r>0&&(ne=kt[r-1],wt=kt[r-2]),n}function Zs(c,s,t,e,i=null,o=0,n=0){const{float32Array:r,uint16Array:a,uint32Array:l}=X;let E=c*2;if(rt(E,a)){const h=at(c,l),d=ht(E,a);return j(c,r,wt),e(h,d,!1,n,o+c,wt)}else{let P=function(M){const{uint16Array:D,uint32Array:x}=X;let v=M*2;for(;!rt(v,D);)M=Et(M),v=M*2;return at(M,x)},w=function(M){const{uint16Array:D,uint32Array:x}=X;let v=M*2;for(;!rt(v,D);)M=It(M,x),v=M*2;return at(M,x)+ht(v,D)};const h=Et(c),d=It(c,l);let p=h,F=d,A,T,m,O;if(i&&(m=wt,O=ne,j(p,r,m),j(F,r,O),A=i(m),T=i(O),T<A)){p=d,F=h;const M=A;A=T,T=M,m=O}m||(m=wt,j(p,r,m));const u=rt(p*2,a),R=t(m,u,A,n+1,o+p);let S;if(R===mi){const M=P(p),x=w(p)-M;S=e(M,x,!0,n+1,o+p,m)}else S=R&&Zs(p,s,t,e,i,o,n+1);if(S)return!0;O=ne,j(F,r,O);const g=rt(F*2,a),_=t(O,g,T,n+1,o+F);let N;if(_===mi){const M=P(F),x=w(F)-M;N=e(M,x,!0,n+1,o+F,O)}else N=_&&Zs(F,s,t,e,i,o,n+1);return!!N}}const he=new C.Vector3,Ps=new C.Vector3;function io(c,s,t={},e=0,i=1/0){const o=e*e,n=i*i;let r=1/0,a=null;if(c.shapecast({boundsTraverseOrder:E=>(he.copy(s).clamp(E.min,E.max),he.distanceToSquared(s)),intersectsBounds:(E,I,h)=>h<r&&h<n,intersectsTriangle:(E,I)=>{E.closestPointToPoint(s,he);const h=s.distanceToSquared(he);return h<r&&(Ps.copy(he),r=h,a=I),h<o}}),r===1/0)return null;const l=Math.sqrt(r);return t.point?t.point.copy(Ps):t.point=Ps.clone(),t.distance=l,t.faceIndex=a,t}const Wt=new C.Vector3,Xt=new C.Vector3,Zt=new C.Vector3,Ve=new C.Vector2,Ge=new C.Vector2,He=new C.Vector2,Si=new C.Vector3,gi=new C.Vector3,_i=new C.Vector3,ze=new C.Vector3;function no(c,s,t,e,i,o){let n;return o===C.BackSide?n=c.intersectTriangle(e,t,s,!0,i):n=c.intersectTriangle(s,t,e,o!==C.DoubleSide,i),n===null?null:{distance:c.origin.distanceTo(i),point:i.clone()}}function oo(c,s,t,e,i,o,n,r,a){Wt.fromBufferAttribute(s,o),Xt.fromBufferAttribute(s,n),Zt.fromBufferAttribute(s,r);const l=no(c,Wt,Xt,Zt,ze,a);if(l){e&&(Ve.fromBufferAttribute(e,o),Ge.fromBufferAttribute(e,n),He.fromBufferAttribute(e,r),l.uv=C.Triangle.getInterpolation(ze,Wt,Xt,Zt,Ve,Ge,He,new C.Vector2)),i&&(Ve.fromBufferAttribute(i,o),Ge.fromBufferAttribute(i,n),He.fromBufferAttribute(i,r),l.uv1=C.Triangle.getInterpolation(ze,Wt,Xt,Zt,Ve,Ge,He,new C.Vector2)),t&&(Si.fromBufferAttribute(t,o),gi.fromBufferAttribute(t,n),_i.fromBufferAttribute(t,r),l.normal=C.Triangle.getInterpolation(ze,Wt,Xt,Zt,Si,gi,_i,new C.Vector3),l.normal.dot(c.direction)>0&&l.normal.multiplyScalar(-1));const E={a:o,b:n,c:r,normal:new C.Vector3,materialIndex:0};C.Triangle.getNormal(Wt,Xt,Zt,E.normal),l.face=E,l.faceIndex=o}return l}function ms(c,s,t,e,i){const o=e*3;let n=o+0,r=o+1,a=o+2;const l=c.index;c.index&&(n=l.getX(n),r=l.getX(r),a=l.getX(a));const{position:E,normal:I,uv:h,uv1:d}=c.attributes,p=oo(t,E,I,h,d,n,r,a,s);return p?(p.faceIndex=e,i&&i.push(p),p):null}function J(c,s,t,e){const i=c.a,o=c.b,n=c.c;let r=s,a=s+1,l=s+2;t&&(r=t.getX(r),a=t.getX(a),l=t.getX(l)),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(l),n.y=e.getY(l),n.z=e.getZ(l)}function ro(c,s,t,e,i,o){const{geometry:n,_indirectBuffer:r}=c;for(let a=e,l=e+i;a<l;a++)ms(n,s,t,a,o)}function ao(c,s,t,e,i){const{geometry:o,_indirectBuffer:n}=c;let r=1/0,a=null;for(let l=e,E=e+i;l<E;l++){let I;I=ms(o,s,t,l),I&&I.distance<r&&(a=I,r=I.distance)}return a}function co(c,s,t,e,i,o,n){const{geometry:r}=t,{index:a}=r,l=r.attributes.position;for(let E=c,I=s+c;E<I;E++){let h;if(h=E,J(n,h*3,a,l),n.needsUpdate=!0,e(n,h,i,o))return!0}return!1}function lo(c,s=null){s&&Array.isArray(s)&&(s=new Set(s));const t=c.geometry,e=t.index?t.index.array:null,i=t.attributes.position;let o,n,r,a,l=0;const E=c._roots;for(let h=0,d=E.length;h<d;h++)o=E[h],n=new Uint32Array(o),r=new Uint16Array(o),a=new Float32Array(o),I(0,l),l+=o.byteLength;function I(h,d,p=!1){const F=h*2;if(r[F+15]===Ts){const T=n[h+6],m=r[F+14];let O=1/0,u=1/0,R=1/0,S=-1/0,g=-1/0,_=-1/0;for(let N=3*T,P=3*(T+m);N<P;N++){let w=e[N];const M=i.getX(w),D=i.getY(w),x=i.getZ(w);M<O&&(O=M),M>S&&(S=M),D<u&&(u=D),D>g&&(g=D),x<R&&(R=x),x>_&&(_=x)}return a[h+0]!==O||a[h+1]!==u||a[h+2]!==R||a[h+3]!==S||a[h+4]!==g||a[h+5]!==_?(a[h+0]=O,a[h+1]=u,a[h+2]=R,a[h+3]=S,a[h+4]=g,a[h+5]=_,!0):!1}else{const T=h+8,m=n[h+6],O=T+d,u=m+d;let R=p,S=!1,g=!1;s?R||(S=s.has(O),g=s.has(u),R=!S&&!g):(S=!0,g=!0);const _=R||S,N=R||g;let P=!1;_&&(P=I(T,d,R));let w=!1;N&&(w=I(m,d,R));const M=P||w;if(M)for(let D=0;D<3;D++){const x=T+D,v=m+D,H=a[x],q=a[x+3],tt=a[v],Z=a[v+3];a[h+D]=H<tt?H:tt,a[h+D+3]=q>Z?q:Z}return M}}}const Ni=new C.Box3;function Dt(c,s,t,e){return j(c,s,Ni),t.intersectBox(Ni,e)}function ho(c,s,t,e,i,o){const{geometry:n,_indirectBuffer:r}=c;for(let a=e,l=e+i;a<l;a++){let E=r?r[a]:a;ms(n,s,t,E,o)}}function Eo(c,s,t,e,i){const{geometry:o,_indirectBuffer:n}=c;let r=1/0,a=null;for(let l=e,E=e+i;l<E;l++){let I;I=ms(o,s,t,n?n[l]:l),I&&I.distance<r&&(a=I,r=I.distance)}return a}function Io(c,s,t,e,i,o,n){const{geometry:r}=t,{index:a}=r,l=r.attributes.position;for(let E=c,I=s+c;E<I;E++){let h;if(h=t.resolveTriangleIndex(E),J(n,h*3,a,l),n.needsUpdate=!0,e(n,h,i,o))return!0}return!1}const yi=new C.Vector3;function uo(c,s,t,e,i){X.setBuffer(c._roots[s]),Qs(0,c,t,e,i),X.clearBuffer()}function Qs(c,s,t,e,i){const{float32Array:o,uint16Array:n,uint32Array:r}=X,a=c*2;if(rt(a,n)){const E=at(c,r),I=ht(a,n);ro(s,t,e,E,I,i)}else{const E=Et(c);Dt(E,o,e,yi)&&Qs(E,s,t,e,i);const I=It(c,r);Dt(I,o,e,yi)&&Qs(I,s,t,e,i)}}const Li=new C.Vector3,fo=["x","y","z"];function Co(c,s,t,e){X.setBuffer(c._roots[s]);const i=qs(0,c,t,e);return X.clearBuffer(),i}function qs(c,s,t,e){const{float32Array:i,uint16Array:o,uint32Array:n}=X;let r=c*2;if(rt(r,o)){const l=at(c,n),E=ht(r,o);return ao(s,t,e,l,E)}else{const l=rn(c,n),E=fo[l],h=e.direction[E]>=0;let d,p;h?(d=Et(c),p=It(c,n)):(d=It(c,n),p=Et(c));const A=Dt(d,i,e,Li)?qs(d,s,t,e):null;if(A){const O=A.point[E];if(h?O<=i[p+l]:O>=i[p+l+3])return A}const m=Dt(p,i,e,Li)?qs(p,s,t,e):null;return A&&m?A.distance<=m.distance?A:m:A||m||null}}const ke=new C.Box3,Qt=new mt,qt=new mt,Ee=new C.Matrix4,Pi=new nt,We=new nt;function po(c,s,t,e){X.setBuffer(c._roots[s]);const i=js(0,c,t,e);return X.clearBuffer(),i}function js(c,s,t,e,i=null){const{float32Array:o,uint16Array:n,uint32Array:r}=X;let a=c*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Pi.set(t.boundingBox.min,t.boundingBox.max,e),i=Pi),rt(a,n)){const E=s.geometry,I=E.index,h=E.attributes.position,d=t.index,p=t.attributes.position,F=at(c,r),A=ht(a,n);if(Ee.copy(e).invert(),t.boundsTree)return j(c,o,We),We.matrix.copy(Ee),We.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:m=>We.intersectsBox(m),intersectsTriangle:m=>{m.a.applyMatrix4(e),m.b.applyMatrix4(e),m.c.applyMatrix4(e),m.needsUpdate=!0;for(let O=F*3,u=(A+F)*3;O<u;O+=3)if(J(qt,O,I,h),qt.needsUpdate=!0,m.intersectsTriangle(qt))return!0;return!1}});for(let T=F*3,m=(A+F)*3;T<m;T+=3){J(Qt,T,I,h),Qt.a.applyMatrix4(Ee),Qt.b.applyMatrix4(Ee),Qt.c.applyMatrix4(Ee),Qt.needsUpdate=!0;for(let O=0,u=d.count;O<u;O+=3)if(J(qt,O,d,p),qt.needsUpdate=!0,Qt.intersectsTriangle(qt))return!0}}else{const E=c+8,I=r[c+6];return j(E,o,ke),!!(i.intersectsBox(ke)&&js(E,s,t,e,i)||(j(I,o,ke),i.intersectsBox(ke)&&js(I,s,t,e,i)))}}const Xe=new C.Matrix4,Ms=new nt,Ie=new nt,To=new C.Vector3,mo=new C.Vector3,Ro=new C.Vector3,Fo=new C.Vector3;function Ao(c,s,t,e={},i={},o=0,n=1/0){s.boundingBox||s.computeBoundingBox(),Ms.set(s.boundingBox.min,s.boundingBox.max,t),Ms.needsUpdate=!0;const r=c.geometry,a=r.attributes.position,l=r.index,E=s.attributes.position,I=s.index,h=lt.getPrimitive(),d=lt.getPrimitive();let p=To,F=mo,A=null,T=null;i&&(A=Ro,T=Fo);let m=1/0,O=null,u=null;return Xe.copy(t).invert(),Ie.matrix.copy(Xe),c.shapecast({boundsTraverseOrder:R=>Ms.distanceToBox(R),intersectsBounds:(R,S,g)=>g<m&&g<n?(S&&(Ie.min.copy(R.min),Ie.max.copy(R.max),Ie.needsUpdate=!0),!0):!1,intersectsRange:(R,S)=>{if(s.boundsTree)return s.boundsTree.shapecast({boundsTraverseOrder:_=>Ie.distanceToBox(_),intersectsBounds:(_,N,P)=>P<m&&P<n,intersectsRange:(_,N)=>{for(let P=_,w=_+N;P<w;P++){J(d,3*P,I,E),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=R,D=R+S;M<D;M++){J(h,3*M,l,a),h.needsUpdate=!0;const x=h.distanceToTriangle(d,p,A);if(x<m&&(F.copy(p),T&&T.copy(A),m=x,O=M,u=P),x<o)return!0}}}});{const g=re(s);for(let _=0,N=g;_<N;_++){J(d,3*_,I,E),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=R,w=R+S;P<w;P++){J(h,3*P,l,a),h.needsUpdate=!0;const M=h.distanceToTriangle(d,p,A);if(M<m&&(F.copy(p),T&&T.copy(A),m=M,O=P,u=_),M<o)return!0}}}}}),lt.releasePrimitive(h),lt.releasePrimitive(d),m===1/0?null:(e.point?e.point.copy(F):e.point=F.clone(),e.distance=m,e.faceIndex=O,i&&(i.point?i.point.copy(T):i.point=T.clone(),i.point.applyMatrix4(Xe),F.applyMatrix4(Xe),i.distance=F.sub(i.point).length(),i.faceIndex=u),e)}function Oo(c,s=null){s&&Array.isArray(s)&&(s=new Set(s));const t=c.geometry,e=t.index?t.index.array:null,i=t.attributes.position;let o,n,r,a,l=0;const E=c._roots;for(let h=0,d=E.length;h<d;h++)o=E[h],n=new Uint32Array(o),r=new Uint16Array(o),a=new Float32Array(o),I(0,l),l+=o.byteLength;function I(h,d,p=!1){const F=h*2;if(r[F+15]===Ts){const T=n[h+6],m=r[F+14];let O=1/0,u=1/0,R=1/0,S=-1/0,g=-1/0,_=-1/0;for(let N=T,P=T+m;N<P;N++){const w=3*c.resolveTriangleIndex(N);for(let M=0;M<3;M++){let D=w+M;D=e?e[D]:D;const x=i.getX(D),v=i.getY(D),H=i.getZ(D);x<O&&(O=x),x>S&&(S=x),v<u&&(u=v),v>g&&(g=v),H<R&&(R=H),H>_&&(_=H)}}return a[h+0]!==O||a[h+1]!==u||a[h+2]!==R||a[h+3]!==S||a[h+4]!==g||a[h+5]!==_?(a[h+0]=O,a[h+1]=u,a[h+2]=R,a[h+3]=S,a[h+4]=g,a[h+5]=_,!0):!1}else{const T=h+8,m=n[h+6],O=T+d,u=m+d;let R=p,S=!1,g=!1;s?R||(S=s.has(O),g=s.has(u),R=!S&&!g):(S=!0,g=!0);const _=R||S,N=R||g;let P=!1;_&&(P=I(T,d,R));let w=!1;N&&(w=I(m,d,R));const M=P||w;if(M)for(let D=0;D<3;D++){const x=T+D,v=m+D,H=a[x],q=a[x+3],tt=a[v],Z=a[v+3];a[h+D]=H<tt?H:tt,a[h+D+3]=q>Z?q:Z}return M}}}const Mi=new C.Vector3;function So(c,s,t,e,i){X.setBuffer(c._roots[s]),Ks(0,c,t,e,i),X.clearBuffer()}function Ks(c,s,t,e,i){const{float32Array:o,uint16Array:n,uint32Array:r}=X,a=c*2;if(rt(a,n)){const E=at(c,r),I=ht(a,n);ho(s,t,e,E,I,i)}else{const E=Et(c);Dt(E,o,e,Mi)&&Ks(E,s,t,e,i);const I=It(c,r);Dt(I,o,e,Mi)&&Ks(I,s,t,e,i)}}const wi=new C.Vector3,go=["x","y","z"];function _o(c,s,t,e){X.setBuffer(c._roots[s]);const i=$s(0,c,t,e);return X.clearBuffer(),i}function $s(c,s,t,e){const{float32Array:i,uint16Array:o,uint32Array:n}=X;let r=c*2;if(rt(r,o)){const l=at(c,n),E=ht(r,o);return Eo(s,t,e,l,E)}else{const l=rn(c,n),E=go[l],h=e.direction[E]>=0;let d,p;h?(d=Et(c),p=It(c,n)):(d=It(c,n),p=Et(c));const A=Dt(d,i,e,wi)?$s(d,s,t,e):null;if(A){const O=A.point[E];if(h?O<=i[p+l]:O>=i[p+l+3])return A}const m=Dt(p,i,e,wi)?$s(p,s,t,e):null;return A&&m?A.distance<=m.distance?A:m:A||m||null}}const Ze=new C.Box3,jt=new mt,Kt=new mt,de=new C.Matrix4,Di=new nt,Qe=new nt;function No(c,s,t,e){X.setBuffer(c._roots[s]);const i=Js(0,c,t,e);return X.clearBuffer(),i}function Js(c,s,t,e,i=null){const{float32Array:o,uint16Array:n,uint32Array:r}=X;let a=c*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Di.set(t.boundingBox.min,t.boundingBox.max,e),i=Di),rt(a,n)){const E=s.geometry,I=E.index,h=E.attributes.position,d=t.index,p=t.attributes.position,F=at(c,r),A=ht(a,n);if(de.copy(e).invert(),t.boundsTree)return j(c,o,Qe),Qe.matrix.copy(de),Qe.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:m=>Qe.intersectsBox(m),intersectsTriangle:m=>{m.a.applyMatrix4(e),m.b.applyMatrix4(e),m.c.applyMatrix4(e),m.needsUpdate=!0;for(let O=F,u=A+F;O<u;O++)if(J(Kt,3*s.resolveTriangleIndex(O),I,h),Kt.needsUpdate=!0,m.intersectsTriangle(Kt))return!0;return!1}});for(let T=F,m=A+F;T<m;T++){const O=s.resolveTriangleIndex(T);J(jt,3*O,I,h),jt.a.applyMatrix4(de),jt.b.applyMatrix4(de),jt.c.applyMatrix4(de),jt.needsUpdate=!0;for(let u=0,R=d.count;u<R;u+=3)if(J(Kt,u,d,p),Kt.needsUpdate=!0,jt.intersectsTriangle(Kt))return!0}}else{const E=c+8,I=r[c+6];return j(E,o,Ze),!!(i.intersectsBox(Ze)&&Js(E,s,t,e,i)||(j(I,o,Ze),i.intersectsBox(Ze)&&Js(I,s,t,e,i)))}}const qe=new C.Matrix4,ws=new nt,ue=new nt,yo=new C.Vector3,Lo=new C.Vector3,Po=new C.Vector3,Mo=new C.Vector3;function wo(c,s,t,e={},i={},o=0,n=1/0){s.boundingBox||s.computeBoundingBox(),ws.set(s.boundingBox.min,s.boundingBox.max,t),ws.needsUpdate=!0;const r=c.geometry,a=r.attributes.position,l=r.index,E=s.attributes.position,I=s.index,h=lt.getPrimitive(),d=lt.getPrimitive();let p=yo,F=Lo,A=null,T=null;i&&(A=Po,T=Mo);let m=1/0,O=null,u=null;return qe.copy(t).invert(),ue.matrix.copy(qe),c.shapecast({boundsTraverseOrder:R=>ws.distanceToBox(R),intersectsBounds:(R,S,g)=>g<m&&g<n?(S&&(ue.min.copy(R.min),ue.max.copy(R.max),ue.needsUpdate=!0),!0):!1,intersectsRange:(R,S)=>{if(s.boundsTree){const g=s.boundsTree;return g.shapecast({boundsTraverseOrder:_=>ue.distanceToBox(_),intersectsBounds:(_,N,P)=>P<m&&P<n,intersectsRange:(_,N)=>{for(let P=_,w=_+N;P<w;P++){const M=g.resolveTriangleIndex(P);J(d,3*M,I,E),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let D=R,x=R+S;D<x;D++){const v=c.resolveTriangleIndex(D);J(h,3*v,l,a),h.needsUpdate=!0;const H=h.distanceToTriangle(d,p,A);if(H<m&&(F.copy(p),T&&T.copy(A),m=H,O=D,u=P),H<o)return!0}}}})}else{const g=re(s);for(let _=0,N=g;_<N;_++){J(d,3*_,I,E),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=R,w=R+S;P<w;P++){const M=c.resolveTriangleIndex(P);J(h,3*M,l,a),h.needsUpdate=!0;const D=h.distanceToTriangle(d,p,A);if(D<m&&(F.copy(p),T&&T.copy(A),m=D,O=P,u=_),D<o)return!0}}}}}),lt.releasePrimitive(h),lt.releasePrimitive(d),m===1/0?null:(e.point?e.point.copy(F):e.point=F.clone(),e.distance=m,e.faceIndex=O,i&&(i.point?i.point.copy(T):i.point=T.clone(),i.point.applyMatrix4(qe),F.applyMatrix4(qe),i.distance=F.sub(i.point).length(),i.faceIndex=u),e)}function Do(){return typeof SharedArrayBuffer<"u"}const Se=new X.constructor,cs=new X.constructor,Pt=new di(()=>new C.Box3),$t=new C.Box3,Jt=new C.Box3,Ds=new C.Box3,Us=new C.Box3;let xs=!1;function Uo(c,s,t,e){if(xs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");xs=!0;const i=c._roots,o=s._roots;let n,r=0,a=0;const l=new C.Matrix4().copy(t).invert();for(let E=0,I=i.length;E<I;E++){Se.setBuffer(i[E]),a=0;const h=Pt.getPrimitive();j(0,Se.float32Array,h),h.applyMatrix4(l);for(let d=0,p=o.length;d<p&&(cs.setBuffer(o[E]),n=ft(0,0,t,l,e,r,a,0,0,h),cs.clearBuffer(),a+=o[d].length,!n);d++);if(Pt.releasePrimitive(h),Se.clearBuffer(),r+=i[E].length,n)break}return xs=!1,n}function ft(c,s,t,e,i,o=0,n=0,r=0,a=0,l=null,E=!1){let I,h;E?(I=cs,h=Se):(I=Se,h=cs);const d=I.float32Array,p=I.uint32Array,F=I.uint16Array,A=h.float32Array,T=h.uint32Array,m=h.uint16Array,O=c*2,u=s*2,R=rt(O,F),S=rt(u,m);let g=!1;if(S&&R)E?g=i(at(s,T),ht(s*2,m),at(c,p),ht(c*2,F),a,n+s,r,o+c):g=i(at(c,p),ht(c*2,F),at(s,T),ht(s*2,m),r,o+c,a,n+s);else if(S){const _=Pt.getPrimitive();j(s,A,_),_.applyMatrix4(t);const N=Et(c),P=It(c,p);j(N,d,$t),j(P,d,Jt);const w=_.intersectsBox($t),M=_.intersectsBox(Jt);g=w&&ft(s,N,e,t,i,n,o,a,r+1,_,!E)||M&&ft(s,P,e,t,i,n,o,a,r+1,_,!E),Pt.releasePrimitive(_)}else{const _=Et(s),N=It(s,T);j(_,A,Ds),j(N,A,Us);const P=l.intersectsBox(Ds),w=l.intersectsBox(Us);if(P&&w)g=ft(c,_,t,e,i,o,n,r,a+1,l,E)||ft(c,N,t,e,i,o,n,r,a+1,l,E);else if(P)if(R)g=ft(c,_,t,e,i,o,n,r,a+1,l,E);else{const M=Pt.getPrimitive();M.copy(Ds).applyMatrix4(t);const D=Et(c),x=It(c,p);j(D,d,$t),j(x,d,Jt);const v=M.intersectsBox($t),H=M.intersectsBox(Jt);g=v&&ft(_,D,e,t,i,n,o,a,r+1,M,!E)||H&&ft(_,x,e,t,i,n,o,a,r+1,M,!E),Pt.releasePrimitive(M)}else if(w)if(R)g=ft(c,N,t,e,i,o,n,r,a+1,l,E);else{const M=Pt.getPrimitive();M.copy(Us).applyMatrix4(t);const D=Et(c),x=It(c,p);j(D,d,$t),j(x,d,Jt);const v=M.intersectsBox($t),H=M.intersectsBox(Jt);g=v&&ft(N,D,e,t,i,n,o,a,r+1,M,!E)||H&&ft(N,x,e,t,i,n,o,a,r+1,M,!E),Pt.releasePrimitive(M)}}return g}const je=new nt,Ui=new C.Box3;class ui{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 ui(t,{...e,[Ns]:!0});if(r._roots=o,r._indirectBuffer=n||null,e.setIndex){const a=t.getIndex();if(a===null){const l=new C.BufferAttribute(s.index,1,!1);t.setIndex(l)}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:sn,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[Ns]:!1},t),t.useSharedArrayBuffer&&!Do())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=s,this._roots=null,this._indirectBuffer=null,t[Ns]||(jn(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?Oo:lo)(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 l=r*2,E=o[l+15]===Ts;if(E){const I=i[r+6],h=o[l+14];s(a,E,new Float32Array(e,r*4,6),I,h)}else{const I=r+os/4,h=i[r+6],d=i[r+7];s(a,E,new Float32Array(e,r*4,6),d)||(n(I,a+1),n(h,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,l=n?t.side:t,E=this.indirect?So:uo;for(let I=0,h=e.length;I<h;I++){const d=r?t[a[I].materialIndex].side:l,p=o.length;if(E(this,I,d,s,o),r){const F=a[I].materialIndex;for(let A=p,T=o.length;A<T;A++)o[A].face.materialIndex=F}}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,l=o?t.side:t,E=this.indirect?_o:Co;for(let I=0,h=e.length;I<h;I++){const d=n?t[a[I].materialIndex].side:l,p=E(this,I,d,s);p!=null&&(r==null||p.distance<r.distance)&&(r=p,n&&(p.face.materialIndex=a[I].materialIndex))}return r}intersectsGeometry(s,t){let e=!1;const i=this._roots,o=this.indirect?No:po;for(let n=0,r=i.length;n<r&&(e=o(this,n,s,t),!e);n++);return e}shapecast(s){const t=lt.getPrimitive(),e=this.indirect?Io:co;let{boundsTraverseOrder:i,intersectsBounds:o,intersectsRange:n,intersectsTriangle:r}=s;if(n&&r){const I=n;n=(h,d,p,F,A)=>I(h,d,p,F,A)?!0:e(h,d,this,r,p,F,t)}else n||(r?n=(I,h,d,p)=>e(I,h,this,r,d,p,t):n=(I,h,d)=>d);let a=!1,l=0;const E=this._roots;for(let I=0,h=E.length;I<h;I++){const d=E[I];if(a=so(this,I,o,n,i,l),a)break;l+=d.byteLength}return lt.releasePrimitive(t),a}bvhcast(s,t,e){let{intersectsRanges:i,intersectsTriangles:o}=e;const n=lt.getPrimitive(),r=this.geometry.index,a=this.geometry.attributes.position,l=this.indirect?p=>{const F=this.resolveTriangleIndex(p);J(n,F*3,r,a)}:p=>{J(n,p*3,r,a)},E=lt.getPrimitive(),I=s.geometry.index,h=s.geometry.attributes.position,d=s.indirect?p=>{const F=s.resolveTriangleIndex(p);J(E,F*3,I,h)}:p=>{J(E,p*3,I,h)};if(o){const p=(F,A,T,m,O,u,R,S)=>{for(let g=T,_=T+m;g<_;g++){d(g),E.a.applyMatrix4(t),E.b.applyMatrix4(t),E.c.applyMatrix4(t),E.needsUpdate=!0;for(let N=F,P=F+A;N<P;N++)if(l(N),n.needsUpdate=!0,o(n,E,N,g,O,u,R,S))return!0}return!1};if(i){const F=i;i=function(A,T,m,O,u,R,S,g){return F(A,T,m,O,u,R,S,g)?!0:p(A,T,m,O,u,R,S,g)}}else i=p}return Uo(this,s,t,i)}intersectsBox(s,t){return je.set(s.min,s.max,t),je.needsUpdate=!0,this.shapecast({intersectsBounds:e=>je.intersectsBox(e),intersectsTriangle:e=>je.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?wo:Ao)(this,s,t,e,i,o,n)}closestPointToPoint(s,t={},e=0,i=1/0){return io(this,s,t,e,i)}getBoundingBox(s){return s.makeEmpty(),this._roots.forEach(e=>{j(0,new Float32Array(e),Ui),s.union(Ui)}),s}}function xi(c,s,t){return c===null||(c.point.applyMatrix4(s.matrixWorld),c.distance=c.point.distanceTo(t.ray.origin),c.object=s,c.distance<t.near||c.distance>t.far)?null:c}const bs=new C.Ray,bi=new C.Matrix4,xo=C.Mesh.prototype.raycast;function bo(c,s){if(this.geometry.boundsTree){if(this.material===void 0)return;bi.copy(this.matrixWorld).invert(),bs.copy(c.ray).applyMatrix4(bi);const t=this.geometry.boundsTree;if(c.firstHitOnly===!0){const e=xi(t.raycastFirst(bs,this.material),this,c);e&&s.push(e)}else{const e=t.raycast(bs,this.material);for(let i=0,o=e.length;i<o;i++){const n=xi(e[i],this,c);n&&s.push(n)}}}else xo.call(this,c,s)}function vo(c){return this.boundsTree=new ui(this,c),this.boundsTree}function Bo(){this.boundsTree=null}class U{constructor(){f(this,"trigger",s=>{const t=this.handlers.slice(0);for(const e of t)e(s)});f(this,"handlers",[])}add(s){this.handlers.push(s)}remove(s){this.handlers=this.handlers.filter(t=>t!==s)}reset(){this.handlers.length=0}}class Rs{constructor(s){f(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this);f(this,"isResizeable",()=>"resize"in this&&"getSize"in this);f(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this);f(this,"isHideable",()=>"visible"in this);f(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this);this.components=s}}class st extends Rs{}class Fs extends Rs{constructor(t){super(t);f(this,"worlds",new Map);f(this,"onWorldChanged",new U);f(this,"currentWorld",null);this.onWorldChanged.add(({world:e,action:i})=>{i==="removed"&&this.worlds.delete(e.uuid)})}}class an extends Fs{constructor(){super(...arguments);f(this,"hasCameraControls",()=>"controls"in this)}}class cn extends Fs{constructor(){super(...arguments);f(this,"onAfterUpdate",new U);f(this,"onBeforeUpdate",new U);f(this,"onDisposed",new U);f(this,"onResize",new U);f(this,"onClippingPlanesUpdated",new U);f(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 ge=class ge extends st{constructor(t){super(t);f(this,"_disposedComponents",new Set);f(this,"enabled",!0);t.add(ge.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){const e=t;e.boundsTree&&e.disposeBoundsTree(),t.dispose()}disposeGeometryAndMaterials(t,e){const i=t;i.geometry&&this.disposeGeometry(i.geometry),e&&i.material&&ge.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()}};f(ge,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let _t=ge;class ln extends Fs{constructor(t){super(t);f(this,"onDisposed",new U)}dispose(){const t=this.components.get(_t);for(const e of this.three.children){const i=e;i.geometry&&t.destroy(i)}this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}}const rs=0,Yo=1,Vo=new C.Vector3,vi=new C.Line3,vs=new C.Plane,Bi=new C.Vector3,Ke=new C.Triangle;class Go{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new Yi,this.unassigned=new Yi,this.vertices=[]}setFromPoints(s){if(s.length>=4){this.makeEmpty();for(let t=0,e=s.length;t<e;t++)this.vertices.push(new Ho(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],l=a.distanceToPoint(s.origin),E=a.normal.dot(s.direction);if(l>0&&E>=0)return null;const I=E!==0?-l/E:0;if(!(I<=0)&&(E>0?o=Math.min(I,o):i=Math.max(I,i),i>o))return null}return i!==-1/0?s.at(i,t):s.at(o,t),t}intersectsRay(s){return this.intersectRay(s,Vo)!==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===rs){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 l=0;l<3;l++)a.getComponent(l)<s.getComponent(l)&&(s.setComponent(l,a.getComponent(l)),e[l]=r);for(let l=0;l<3;l++)a.getComponent(l)>t.getComponent(l)&&(t.setComponent(l,a.getComponent(l)),i[l]=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 h=0;h<3;h++){const d=i[h].point.getComponent(h)-e[h].point.getComponent(h);d>o&&(o=d,n=h)}const r=e[n],a=i[n];let l,E;o=0,vi.set(r.point,a.point);for(let h=0,d=this.vertices.length;h<d;h++){const p=s[h];if(p!==r&&p!==a){vi.closestPointToPoint(p.point,!0,Bi);const F=Bi.distanceToSquared(p.point);F>o&&(o=F,l=p)}}o=-1,vs.setFromCoplanarPoints(r.point,a.point,l.point);for(let h=0,d=this.vertices.length;h<d;h++){const p=s[h];if(p!==r&&p!==a&&p!==l){const F=Math.abs(vs.distanceToPoint(p.point));F>o&&(o=F,E=p)}}const I=[];if(vs.distanceToPoint(E.point)<0){I.push(pt.create(r,a,l),pt.create(E,a,r),pt.create(E,l,a),pt.create(E,r,l));for(let h=0;h<3;h++){const d=(h+1)%3;I[h+1].getEdge(2).setTwin(I[0].getEdge(d)),I[h+1].getEdge(1).setTwin(I[d+1].getEdge(0))}}else{I.push(pt.create(r,l,a),pt.create(E,r,a),pt.create(E,a,l),pt.create(E,l,r));for(let h=0;h<3;h++){const d=(h+1)%3;I[h+1].getEdge(2).setTwin(I[0].getEdge((3-h)%3)),I[h+1].getEdge(0).setTwin(I[d+1].getEdge(1))}}for(let h=0;h<4;h++)this.faces.push(I[h]);for(let h=0,d=s.length;h<d;h++){const p=s[h];if(p!==r&&p!==a&&p!==l&&p!==E){o=this.tolerance;let F=null;for(let A=0;A<4;A++){const T=this.faces[A].distanceToPoint(p.point);T>o&&(o=T,F=this.faces[A])}F!==null&&this.addVertexToFace(p,F)}}return this}reindexFaces(){const s=[];for(let t=0;t<this.faces.length;t++){const e=this.faces[t];e.mark===rs&&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=Yo;let o;t===null?o=t=e.getEdge(0):o=t.next;do{const n=o.twin,r=n.face;r.mark===rs&&(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=pt.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 pt{constructor(){this.normal=new C.Vector3,this.midpoint=new C.Vector3,this.area=0,this.constant=0,this.outside=null,this.mark=rs,this.edge=null}static create(s,t,e){const i=new pt,o=new Bs(s,i),n=new Bs(t,i),r=new Bs(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 Ke.set(s.point,t.point,e.point),Ke.getNormal(this.normal),Ke.getMidpoint(this.midpoint),this.area=Ke.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(s){return this.normal.dot(s)-this.constant}}class Bs{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 Ho{constructor(s){this.point=s,this.prev=null,this.next=null,this.face=null}}class Yi{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 ti=[2,2,1],ei=[1,0,0];function Ot(c,s){return c*3+s}function zo(c){const s=c.elements;let t=0;for(let e=0;e<9;e++)t+=s[e]*s[e];return Math.sqrt(t)}function ko(c){const s=c.elements;let t=0;for(let e=0;e<3;e++){const i=s[Ot(ti[e],ei[e])];t+=2*i*i}return Math.sqrt(t)}function Wo(c,s){let t=0,e=1;const i=c.elements;for(let l=0;l<3;l++){const E=Math.abs(i[Ot(ti[l],ei[l])]);E>t&&(t=E,e=l)}let o=1,n=0;const r=ei[e],a=ti[e];if(Math.abs(i[Ot(a,r)])>Number.EPSILON){const l=i[Ot(a,a)],E=i[Ot(r,r)],I=i[Ot(a,r)],h=(l-E)/2/I;let d;h<0?d=-1/(-h+Math.sqrt(1+h*h)):d=1/(h+Math.sqrt(1+h*h)),o=1/Math.sqrt(1+d*d),n=d*o}return s.identity(),s.elements[Ot(r,r)]=o,s.elements[Ot(a,a)]=o,s.elements[Ot(a,r)]=n,s.elements[Ot(r,a)]=-n,s}function Xo(c,s){let t=0,e=0;const i=10;s.unitary.identity(),s.diagonal.copy(c);const o=s.unitary,n=s.diagonal,r=new L.Matrix3,a=new L.Matrix3,l=Number.EPSILON*zo(n);for(;e<i&&ko(n)>l;)Wo(n,r),a.copy(r).transpose(),n.multiply(r),n.premultiply(a),o.multiply(r),++t>2&&(e++,t=0);return s}function hn(c){const s=[];for(let et=0;et<c.length-2;et+=3){const vt=c[et],$=c[et+1],zt=c[et+2];s.push(new L.Vector3(vt,$,zt))}const t=new Go;t.setFromPoints(s);const e={unitary:new L.Matrix3,diagonal:new L.Matrix3},i=t.faces,o=[],n=[];for(let et=0,vt=i.length;et<vt;et++){const $=i[et];let zt=$.edge;o.length=0;do o.push(zt),zt=zt.next;while(zt!==$.edge);const yn=o.length-2;for(let xe=1,Ln=yn;xe<=Ln;xe++){const Os=o[0].vertex,Ss=o[xe+0].vertex,gs=o[xe+1].vertex;n.push(Os.point.x,Os.point.y,Os.point.z),n.push(Ss.point.x,Ss.point.y,Ss.point.z),n.push(gs.point.x,gs.point.y,gs.point.z)}}const r=new L.Vector3,a=new L.Vector3,l=new L.Vector3,E=new L.Vector3,I=new L.Vector3,h=new L.Vector3,d=new L.Vector3,p=new L.Vector3;let F=0,A=0,T=0,m=0,O=0,u=0,R=0;for(let et=0,vt=n.length;et<vt;et+=9){r.fromArray(n,et),a.fromArray(n,et+3),l.fromArray(n,et+6),d.set(0,0,0),d.add(r).add(a).add(l).divideScalar(3),E.subVectors(a,r),I.subVectors(l,r);const $=h.crossVectors(E,I).length()/2;p.add(h.copy(d).multiplyScalar($)),F+=$,A+=(9*d.x*d.x+r.x*r.x+a.x*a.x+l.x*l.x)*($/12),T+=(9*d.x*d.y+r.x*r.y+a.x*a.y+l.x*l.y)*($/12),m+=(9*d.x*d.z+r.x*r.z+a.x*a.z+l.x*l.z)*($/12),O+=(9*d.y*d.y+r.y*r.y+a.y*a.y+l.y*l.y)*($/12),u+=(9*d.y*d.z+r.y*r.z+a.y*a.z+l.y*l.z)*($/12),R+=(9*d.z*d.z+r.z*r.z+a.z*a.z+l.z*l.z)*($/12)}p.divideScalar(F),A/=F,T/=F,m/=F,O/=F,u/=F,R/=F,A-=p.x*p.x,T-=p.x*p.y,m-=p.x*p.z,O-=p.y*p.y,u-=p.y*p.z,R-=p.z*p.z;const S=new L.Matrix3;S.elements[0]=A,S.elements[1]=T,S.elements[2]=m,S.elements[3]=T,S.elements[4]=O,S.elements[5]=u,S.elements[6]=m,S.elements[7]=u,S.elements[8]=R,Xo(S,e);const g=e.unitary,_=new L.Vector3,N=new L.Vector3,P=new L.Vector3;g.extractBasis(_,N,P);let w=-1/0,M=-1/0,D=-1/0,x=1/0,v=1/0,H=1/0;for(let et=0,vt=s.length;et<vt;et++){const $=s[et];w=Math.max(_.dot($),w),M=Math.max(N.dot($),M),D=Math.max(P.dot($),D),x=Math.min(_.dot($),x),v=Math.min(N.dot($),v),H=Math.min(P.dot($),H)}_.multiplyScalar(.5*(x+w)),N.multiplyScalar(.5*(v+M)),P.multiplyScalar(.5*(H+D));const q=new L.Vector3,tt=new L.Vector3,Z=new L.Matrix3;q.add(_).add(N).add(P),tt.x=w-x,tt.y=M-v,tt.z=D-H,tt.multiplyScalar(.5),Z.copy(g);const{x:Ut,y:xt,z:bt}=tt,Ue=new L.Matrix4;Ue.makeScale(Ut*2,xt*2,bt*2);const ae=new L.Matrix4;ae.makeTranslation(-Ut,-xt,-bt);const pi=new L.Matrix4;pi.makeTranslation(q.x,q.y,q.z);const Ti=new L.Matrix4;Ti.setFromMatrix3(Z);const ce=new L.Matrix4;return ce.multiply(pi),ce.multiply(Ti),ce.multiply(ae),ce.multiply(Ue),{center:q,halfSizes:tt,rotation:Z,transformation:ce}}function En(c,s,t){const e=[c[0]-s[0],c[1]-s[1],c[2]-s[2]];return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]>0}class si{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
+
3
+ - If you're the tool creator, you can take one from https://www.uuidgenerator.net/.
4
+
5
+ - If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};f(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}$/),f(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 oe=K;const Is=class Is{constructor(){f(this,"onDisposed",new U);f(this,"list",new Map);f(this,"enabled",!1);f(this,"_clock");f(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 L.Clock,Is.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 intance. Use Components.get() instead.");oe.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(){L.BufferGeometry.prototype.computeBoundsTree=vo,L.BufferGeometry.prototype.disposeBoundsTree=Bo,L.Mesh.prototype.raycast=bo}};f(Is,"release","1.4.21");let ls=Is;class Zo{constructor(s){f(this,"_event");f(this,"_position",new L.Vector2);f(this,"onDisposed",new U);f(this,"updateMouseInfo",s=>{this._event=s});this.dom=s,this.setupEvents(!0)}get position(){if(this._event){const s=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(s,this._event),this._position.y=this.getPositionY(s,this._event)}return this._position}dispose(){this.setupEvents(!1),this.onDisposed.trigger(),this.onDisposed.reset()}getPositionY(s,t){return-((t.clientY-s.top)/(s.bottom-s.top))*2+1}getPositionX(s,t){return(t.clientX-s.left)/(s.right-s.left)*2-1}setupEvents(s){s?this.dom.addEventListener("mousemove",this.updateMouseInfo):this.dom.removeEventListener("mousemove",this.updateMouseInfo)}}class Qo{constructor(s,t){f(this,"enabled",!0);f(this,"components");f(this,"onDisposed",new U);f(this,"mouse");f(this,"three",new L.Raycaster);f(this,"world");const e=t.renderer;if(!e)throw new Error("A renderer is needed for the raycaster to work!");this.world=t,this.mouse=new Zo(e.three.domElement),this.components=s}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRay(s=Array.from(this.world.meshes)){if(!this.world)throw new Error("A world is needed to cast rays!");const t=this.world.camera.three;return this.three.setFromCamera(this.mouse.position,t),this.intersect(s)}castRayFromVector(s,t,e=Array.from(this.world.meshes)){return this.three.set(s,t),this.intersect(e)}intersect(s=Array.from(this.world.meshes)){const t=this.three.intersectObjects(s),e=this.filterClippingPlanes(t);return e.length>0?e[0]:null}filterClippingPlanes(s){if(!this.world.renderer)throw new Error("Renderer not found!");const t=this.world.renderer.three;if(!t.clippingPlanes)return s;const e=t.clippingPlanes;return s.length<=0||!e||(e==null?void 0:e.length)<=0?s:s.filter(i=>e.every(o=>o.distanceToPoint(i.point)>0))}}const ds=class ds extends st{constructor(t){super(t);f(this,"enabled",!0);f(this,"list",new Map);f(this,"onDisposed",new U);t.add(ds.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new Qo(this.components,t);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()}};f(ds,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let Me=ds;class In extends Rs{constructor(t){super(t);f(this,"meshes",new Set);f(this,"onAfterUpdate",new U);f(this,"onBeforeUpdate",new U);f(this,"enabled",!0);f(this,"uuid",oe.create());f(this,"onDisposed",new U);f(this,"_scene");f(this,"_camera");f(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.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 qo extends ln{constructor(t){super(t);f(this,"isSetup",!1);f(this,"three");f(this,"onSetup",new U);f(this,"config",{directionalLight:{color:new L.Color("white"),intensity:1.5,position:new L.Vector3(5,10,3)},ambientLight:{color:new L.Color("white"),intensity:1}});this.three=new L.Scene,this.three.background=new L.Color(2107698)}setup(t){this.config={...this.config,...t};const e=new L.DirectionalLight(this.config.directionalLight.color,this.config.directionalLight.intensity);e.position.copy(this.config.directionalLight.position);const i=new L.AmbientLight(this.config.ambientLight.color,this.config.ambientLight.intensity);this.three.add(e,i),this.isSetup=!0,this.onSetup.trigger(this)}}class jo extends cn{constructor(t,e,i){super(t);f(this,"enabled",!0);f(this,"container");f(this,"three");f(this,"_canvas");f(this,"_parameters");f(this,"onContainerUpdated",new U);f(this,"resize",t=>{if(this.updateContainer(),!this.container)return;const e=t?t.x:this.container.clientWidth,i=t?t.y:this.container.clientHeight;this.three.setSize(e,i),this.onResize.trigger(new L.Vector2(e,i))});f(this,"resizeEvent",()=>{this.resize()});f(this,"onContextLost",t=>{t.preventDefault(),this.components.enabled=!1});f(this,"onContextBack",()=>{this.three.setRenderTarget(null),this.three.dispose(),this.three=new L.WebGLRenderer({canvas:this._canvas,antialias:!0,alpha:!0,...this._parameters}),this.components.enabled=!0});this.container=e||null,this._parameters=i,this.three=new L.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 L.Vector2(this.three.domElement.clientWidth,this.three.domElement.clientHeight)}setupEvents(t){const e=this.three.domElement;t?e.addEventListener("resize",this.resizeEvent):e.removeEventListener("resize",this.resizeEvent)}setupRenderer(){this.three.localClippingEnabled=!0,this.container&&this.container.appendChild(this.three.domElement),this.updateContainer()}updateContainer(){if(!this.container){const t=this.three.domElement.parentElement;t&&(this.container=t,this.onContainerUpdated.trigger(t))}}}/*!
6
+ * camera-controls
7
+ * https://github.com/yomotsu/camera-controls
8
+ * (c) 2017 @yomotsu
9
+ * Released under the MIT License.
10
+ */const Y={LEFT:1,RIGHT:2,MIDDLE:4},y=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}),te={NONE:0,IN:1,OUT:-1};function Bt(c){return c.isPerspectiveCamera}function Lt(c){return c.isOrthographicCamera}const ee=Math.PI*2,Vi=Math.PI/2,dn=1e-5,fe=Math.PI/180;function Ct(c,s,t){return Math.max(s,Math.min(t,c))}function W(c,s=dn){return Math.abs(c)<s}function z(c,s,t=dn){return W(c-s,t)}function Gi(c,s){return Math.round(c/s)*s}function Ce(c){return isFinite(c)?c:c<0?-Number.MAX_VALUE:Number.MAX_VALUE}function pe(c){return Math.abs(c)<Number.MAX_VALUE?c:c*(1/0)}function $e(c,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 l=c-s;const E=s,I=i*e;l=Ct(l,-I,I),s=c-l;const h=(t.value+n*l)*o;t.value=(t.value-n*h)*a;let d=s+(l+h)*a;return E-c>0==d>E&&(d=E,t.value=(d-E)/o),d}function Hi(c,s,t,e,i=1/0,o,n){e=Math.max(1e-4,e);const r=2/e,a=r*o,l=1/(1+a+.48*a*a+.235*a*a*a);let E=s.x,I=s.y,h=s.z,d=c.x-E,p=c.y-I,F=c.z-h;const A=E,T=I,m=h,O=i*e,u=O*O,R=d*d+p*p+F*F;if(R>u){const v=Math.sqrt(R);d=d/v*O,p=p/v*O,F=F/v*O}E=c.x-d,I=c.y-p,h=c.z-F;const S=(t.x+r*d)*o,g=(t.y+r*p)*o,_=(t.z+r*F)*o;t.x=(t.x-r*S)*l,t.y=(t.y-r*g)*l,t.z=(t.z-r*_)*l,n.x=E+(d+S)*l,n.y=I+(p+g)*l,n.z=h+(F+_)*l;const N=A-c.x,P=T-c.y,w=m-c.z,M=n.x-A,D=n.y-T,x=n.z-m;return N*M+P*D+w*x>0&&(n.x=A,n.y=T,n.z=m,t.x=(n.x-A)/o,t.y=(n.y-T)/o,t.z=(n.z-m)/o),n}function Ys(c,s){s.set(0,0),c.forEach(t=>{s.x+=t.clientX,s.y+=t.clientY}),s.x/=c.length,s.y/=c.length}function Vs(c,s){return Lt(c)?(console.warn(`${s} is not supported in OrthographicCamera`),!0):!1}class Ko{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 $o="2.7.3",Je=1/8,un=typeof window<"u",Jo=un&&/Mac/.test(navigator.platform),tr=!(un&&"PointerEvent"in window);let B,zi,ts,Gs,ot,V,G,se,Te,Rt,Ft,Yt,ki,Wi,ct,me,ie,Xi,Hs,Zi,zs,ks,es;class we extends Ko{static install(s){B=s.THREE,zi=Object.freeze(new B.Vector3(0,0,0)),ts=Object.freeze(new B.Vector3(0,1,0)),Gs=Object.freeze(new B.Vector3(0,0,1)),ot=new B.Vector2,V=new B.Vector3,G=new B.Vector3,se=new B.Vector3,Te=new B.Vector3,Rt=new B.Vector3,Ft=new B.Vector3,Yt=new B.Vector3,ki=new B.Vector3,Wi=new B.Vector3,ct=new B.Spherical,me=new B.Spherical,ie=new B.Box3,Xi=new B.Box3,Hs=new B.Sphere,Zi=new B.Quaternion,zs=new B.Quaternion,ks=new B.Matrix4,es=new B.Raycaster}static get ACTION(){return y}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=y.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=te.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=(u,R,S)=>{let g,_;if(Bt(this._camera)){const N=V.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*fe,w=N.length()*Math.tan(P*.5);g=this.truckSpeed*u*w/this._elementRect.height,_=this.truckSpeed*R*w/this._elementRect.height}else if(Lt(this._camera)){const N=this._camera;g=u*(N.right-N.left)/N.zoom/this._elementRect.width,_=R*(N.top-N.bottom)/N.zoom/this._elementRect.height}else return;this.verticalDragToForward?(S?this.setFocalOffset(this._focalOffsetEnd.x+g,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(g,0,!0),this.forward(-_,!0)):S?this.setFocalOffset(this._focalOffsetEnd.x+g,this._focalOffsetEnd.y+_,this._focalOffsetEnd.z,!0):this.truck(g,_,!0)},this._rotateInternal=(u,R)=>{const S=ee*this.azimuthRotateSpeed*u/this._elementRect.height,g=ee*this.polarRotateSpeed*R/this._elementRect.height;this.rotate(S,g,!0)},this._dollyInternal=(u,R,S)=>{const g=Math.pow(.95,-u*this.dollySpeed),_=this._sphericalEnd.radius,N=this._sphericalEnd.radius*g,P=Ct(N,this.minDistance,this.maxDistance),w=P-N;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(N,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(w,!0),this._dollyToNoClamp(P,!0)):this._dollyToNoClamp(P,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?N:P)-_,this._dollyControlCoord.set(R,S)),this._lastDollyDirection=Math.sign(-u)},this._zoomInternal=(u,R,S)=>{const g=Math.pow(.95,u*this.dollySpeed),_=this._zoom,N=this._zoom*g;this.zoomTo(N,!0),this.dollyToCursor&&(this._changedZoom+=N-_,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,ts),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=y.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(V.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:y.ROTATE,middle:y.DOLLY,right:y.TRUCK,wheel:Bt(this._camera)?y.DOLLY:Lt(this._camera)?y.ZOOM:y.NONE},this.touches={one:y.TOUCH_ROTATE,two:Bt(this._camera)?y.TOUCH_DOLLY_TRUCK:Lt(this._camera)?y.TOUCH_ZOOM_TRUCK:y.NONE,three:y.TOUCH_TRUCK};const e=new B.Vector2,i=new B.Vector2,o=new B.Vector2,n=u=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const g=this._domElement.getBoundingClientRect(),_=u.clientX/g.width,N=u.clientY/g.height;if(_<this._interactiveArea.left||_>this._interactiveArea.right||N<this._interactiveArea.top||N>this._interactiveArea.bottom)return}const R=u.pointerType!=="mouse"?null:(u.buttons&Y.LEFT)===Y.LEFT?Y.LEFT:(u.buttons&Y.MIDDLE)===Y.MIDDLE?Y.MIDDLE:(u.buttons&Y.RIGHT)===Y.RIGHT?Y.RIGHT:null;if(R!==null){const g=this._findPointerByMouseButton(R);g&&this._disposePointer(g)}if((u.buttons&Y.LEFT)===Y.LEFT&&this._lockedPointer)return;const S={pointerId:u.pointerId,clientX:u.clientX,clientY:u.clientY,deltaX:0,deltaY:0,mouseButton:R};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",E),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",E),this._isDragging=!0,F(u)},r=u=>{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 g=this._domElement.getBoundingClientRect(),_=u.clientX/g.width,N=u.clientY/g.height;if(_<this._interactiveArea.left||_>this._interactiveArea.right||N<this._interactiveArea.top||N>this._interactiveArea.bottom)return}const R=(u.buttons&Y.LEFT)===Y.LEFT?Y.LEFT:(u.buttons&Y.MIDDLE)===Y.MIDDLE?Y.MIDDLE:(u.buttons&Y.RIGHT)===Y.RIGHT?Y.RIGHT:null;if(R!==null){const g=this._findPointerByMouseButton(R);g&&this._disposePointer(g)}const S={pointerId:1,clientX:u.clientX,clientY:u.clientY,deltaX:0,deltaY:0,mouseButton:(u.buttons&Y.LEFT)===Y.LEFT?Y.LEFT:(u.buttons&Y.MIDDLE)===Y.LEFT?Y.MIDDLE:(u.buttons&Y.RIGHT)===Y.LEFT?Y.RIGHT:null};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("mousemove",l),this._domElement.ownerDocument.removeEventListener("mouseup",I),this._domElement.ownerDocument.addEventListener("mousemove",l),this._domElement.ownerDocument.addEventListener("mouseup",I),this._isDragging=!0,F(u)},a=u=>{u.cancelable&&u.preventDefault();const R=u.pointerId,S=this._lockedPointer||this._findPointerById(R);if(S){if(S.clientX=u.clientX,S.clientY=u.clientY,S.deltaX=u.movementX,S.deltaY=u.movementY,this._state=0,u.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&&(u.buttons&Y.LEFT)===Y.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(u.buttons&Y.MIDDLE)===Y.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(u.buttons&Y.RIGHT)===Y.RIGHT&&(this._state=this._state|this.mouseButtons.right);A()}},l=u=>{const R=this._lockedPointer||this._findPointerById(1);R&&(R.clientX=u.clientX,R.clientY=u.clientY,R.deltaX=u.movementX,R.deltaY=u.movementY,this._state=0,(this._lockedPointer||(u.buttons&Y.LEFT)===Y.LEFT)&&(this._state=this._state|this.mouseButtons.left),(u.buttons&Y.MIDDLE)===Y.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(u.buttons&Y.RIGHT)===Y.RIGHT&&(this._state=this._state|this.mouseButtons.right),A())},E=u=>{const R=this._findPointerById(u.pointerId);if(!(R&&R===this._lockedPointer)){if(R&&this._disposePointer(R),u.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=y.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=y.NONE;T()}},I=()=>{const u=this._findPointerById(1);u&&u===this._lockedPointer||(u&&this._disposePointer(u),this._state=y.NONE,T())};let h=-1;const d=u=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===y.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=u.clientX/N.width,w=u.clientY/N.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||w<this._interactiveArea.top||w>this._interactiveArea.bottom)return}if(u.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===y.ROTATE||this.mouseButtons.wheel===y.TRUCK){const N=performance.now();h-N<1e3&&this._getClientRect(this._elementRect),h=N}const R=Jo?-1:-3,S=u.deltaMode===1?u.deltaY/R:u.deltaY/(R*10),g=this.dollyToCursor?(u.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,_=this.dollyToCursor?(u.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case y.ROTATE:{this._rotateInternal(u.deltaX,u.deltaY),this._isUserControllingRotate=!0;break}case y.TRUCK:{this._truckInternal(u.deltaX,u.deltaY,!1),this._isUserControllingTruck=!0;break}case y.OFFSET:{this._truckInternal(u.deltaX,u.deltaY,!0),this._isUserControllingOffset=!0;break}case y.DOLLY:{this._dollyInternal(-S,g,_),this._isUserControllingDolly=!0;break}case y.ZOOM:{this._zoomInternal(-S,g,_),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},p=u=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===we.ACTION.NONE){const R=u instanceof PointerEvent?u.pointerId:(u instanceof MouseEvent,0),S=this._findPointerById(R);S&&this._disposePointer(S),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",E),this._domElement.ownerDocument.removeEventListener("mousemove",l),this._domElement.ownerDocument.removeEventListener("mouseup",I);return}u.preventDefault()}},F=u=>{if(!this._enabled)return;if(Ys(this._activePointers,ot),this._getClientRect(this._elementRect),e.copy(ot),i.copy(ot),this._activePointers.length>=2){const S=ot.x-this._activePointers[1].clientX,g=ot.y-this._activePointers[1].clientY,_=Math.sqrt(S*S+g*g);o.set(0,_);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,!u)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in u&&u.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&&(u.buttons&Y.LEFT)===Y.LEFT&&(this._state=this._state|this.mouseButtons.left),(u.buttons&Y.MIDDLE)===Y.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(u.buttons&Y.RIGHT)===Y.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&y.ROTATE)===y.ROTATE||(this._state&y.TOUCH_ROTATE)===y.TOUCH_ROTATE||(this._state&y.TOUCH_DOLLY_ROTATE)===y.TOUCH_DOLLY_ROTATE||(this._state&y.TOUCH_ZOOM_ROTATE)===y.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&y.TRUCK)===y.TRUCK||(this._state&y.TOUCH_TRUCK)===y.TOUCH_TRUCK||(this._state&y.TOUCH_DOLLY_TRUCK)===y.TOUCH_DOLLY_TRUCK||(this._state&y.TOUCH_ZOOM_TRUCK)===y.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&y.DOLLY)===y.DOLLY||(this._state&y.TOUCH_DOLLY)===y.TOUCH_DOLLY||(this._state&y.TOUCH_DOLLY_TRUCK)===y.TOUCH_DOLLY_TRUCK||(this._state&y.TOUCH_DOLLY_OFFSET)===y.TOUCH_DOLLY_OFFSET||(this._state&y.TOUCH_DOLLY_ROTATE)===y.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&y.ZOOM)===y.ZOOM||(this._state&y.TOUCH_ZOOM)===y.TOUCH_ZOOM||(this._state&y.TOUCH_ZOOM_TRUCK)===y.TOUCH_ZOOM_TRUCK||(this._state&y.TOUCH_ZOOM_OFFSET)===y.TOUCH_ZOOM_OFFSET||(this._state&y.TOUCH_ZOOM_ROTATE)===y.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&y.OFFSET)===y.OFFSET||(this._state&y.TOUCH_OFFSET)===y.TOUCH_OFFSET||(this._state&y.TOUCH_DOLLY_OFFSET)===y.TOUCH_DOLLY_OFFSET||(this._state&y.TOUCH_ZOOM_OFFSET)===y.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},A=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,Ys(this._activePointers,ot);const R=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,S=R?-R.deltaX:i.x-ot.x,g=R?-R.deltaY:i.y-ot.y;if(i.copy(ot),((this._state&y.ROTATE)===y.ROTATE||(this._state&y.TOUCH_ROTATE)===y.TOUCH_ROTATE||(this._state&y.TOUCH_DOLLY_ROTATE)===y.TOUCH_DOLLY_ROTATE||(this._state&y.TOUCH_ZOOM_ROTATE)===y.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(S,g),this._isUserControllingRotate=!0),(this._state&y.DOLLY)===y.DOLLY||(this._state&y.ZOOM)===y.ZOOM){const _=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&y.DOLLY)===y.DOLLY?(this._dollyInternal(P*g*Je,_,N),this._isUserControllingDolly=!0):(this._zoomInternal(P*g*Je,_,N),this._isUserControllingZoom=!0)}if((this._state&y.TOUCH_DOLLY)===y.TOUCH_DOLLY||(this._state&y.TOUCH_ZOOM)===y.TOUCH_ZOOM||(this._state&y.TOUCH_DOLLY_TRUCK)===y.TOUCH_DOLLY_TRUCK||(this._state&y.TOUCH_ZOOM_TRUCK)===y.TOUCH_ZOOM_TRUCK||(this._state&y.TOUCH_DOLLY_OFFSET)===y.TOUCH_DOLLY_OFFSET||(this._state&y.TOUCH_ZOOM_OFFSET)===y.TOUCH_ZOOM_OFFSET||(this._state&y.TOUCH_DOLLY_ROTATE)===y.TOUCH_DOLLY_ROTATE||(this._state&y.TOUCH_ZOOM_ROTATE)===y.TOUCH_ZOOM_ROTATE){const _=ot.x-this._activePointers[1].clientX,N=ot.y-this._activePointers[1].clientY,P=Math.sqrt(_*_+N*N),w=o.y-P;o.set(0,P);const M=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,D=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&y.TOUCH_DOLLY)===y.TOUCH_DOLLY||(this._state&y.TOUCH_DOLLY_ROTATE)===y.TOUCH_DOLLY_ROTATE||(this._state&y.TOUCH_DOLLY_TRUCK)===y.TOUCH_DOLLY_TRUCK||(this._state&y.TOUCH_DOLLY_OFFSET)===y.TOUCH_DOLLY_OFFSET?(this._dollyInternal(w*Je,M,D),this._isUserControllingDolly=!0):(this._zoomInternal(w*Je,M,D),this._isUserControllingZoom=!0)}((this._state&y.TRUCK)===y.TRUCK||(this._state&y.TOUCH_TRUCK)===y.TOUCH_TRUCK||(this._state&y.TOUCH_DOLLY_TRUCK)===y.TOUCH_DOLLY_TRUCK||(this._state&y.TOUCH_ZOOM_TRUCK)===y.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(S,g,!1),this._isUserControllingTruck=!0),((this._state&y.OFFSET)===y.OFFSET||(this._state&y.TOUCH_OFFSET)===y.TOUCH_OFFSET||(this._state&y.TOUCH_DOLLY_OFFSET)===y.TOUCH_DOLLY_OFFSET||(this._state&y.TOUCH_ZOOM_OFFSET)===y.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(S,g,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},T=()=>{Ys(this._activePointers,ot),i.copy(ot),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",l),this._domElement.ownerDocument.removeEventListener("pointerup",E),this._domElement.ownerDocument.removeEventListener("mouseup",I),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",E),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",m),this._domElement.ownerDocument.addEventListener("pointerlockerror",O),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",E),F())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",m),this._domElement.ownerDocument.removeEventListener("pointerlockerror",O))};const m=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},O=()=>{this.unlockPointer()};this._addAllEventListeners=u=>{this._domElement=u,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",n),tr&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",E),this._domElement.addEventListener("wheel",d,{passive:!1}),this._domElement.addEventListener("contextmenu",p)},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",E),this._domElement.removeEventListener("wheel",d,{passive:!1}),this._domElement.removeEventListener("contextmenu",p),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",l),this._domElement.ownerDocument.removeEventListener("pointerup",E),this._domElement.ownerDocument.removeEventListener("mouseup",I),this._domElement.ownerDocument.removeEventListener("pointerlockchange",m),this._domElement.ownerDocument.removeEventListener("pointerlockerror",O))},this.cancel=()=>{this._state!==y.NONE&&(this._state=y.NONE,this._activePointers.length=0,T())},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=Ct(s.width,0,1),this._interactiveArea.height=Ct(s.height,0,1),this._interactiveArea.x=Ct(s.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ct(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=Ct(s,this.minAzimuthAngle,this.maxAzimuthAngle),o=Ct(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||z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(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=te.NONE,this._changedDolly=0,this._dollyToNoClamp(Ct(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=z(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||z(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(o)}dollyInFixed(s,t=!1){this._targetEnd.add(this._getCameraDirection(Te).multiplyScalar(s)),t||this._target.copy(this._targetEnd);const e=!t||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(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=Ct(s,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const e=!t||z(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=V.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){V.setFromMatrixColumn(this._camera.matrix,0),V.crossVectors(this._camera.up,V),V.multiplyScalar(s);const e=G.copy(this._targetEnd).add(V);return this.moveTo(e.x,e.y,e.z,t)}elevate(s,t=!1){return V.copy(this._camera.up).multiplyScalar(s),this.moveTo(this._targetEnd.x+V.x,this._targetEnd.y+V.y,this._targetEnd.z+V.z,t)}moveTo(s,t,e,i=!1){this._isUserControllingTruck=!1;const o=V.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||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}lookInDirectionOf(s,t,e,i=!1){const r=V.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=[],l=s.isBox3?ie.copy(s):ie.setFromObject(s);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const E=Gi(this._sphericalEnd.theta,Vi),I=Gi(this._sphericalEnd.phi,Vi);a.push(this.rotateTo(E,I,t));const h=V.setFromSpherical(this._sphericalEnd).normalize(),d=Zi.setFromUnitVectors(h,Gs),p=z(Math.abs(h.y),1);p&&d.multiply(zs.setFromAxisAngle(ts,E)),d.multiply(this._yAxisUpSpaceInverse);const F=Xi.makeEmpty();G.copy(l.min).applyQuaternion(d),F.expandByPoint(G),G.copy(l.min).setX(l.max.x).applyQuaternion(d),F.expandByPoint(G),G.copy(l.min).setY(l.max.y).applyQuaternion(d),F.expandByPoint(G),G.copy(l.max).setZ(l.min.z).applyQuaternion(d),F.expandByPoint(G),G.copy(l.min).setZ(l.max.z).applyQuaternion(d),F.expandByPoint(G),G.copy(l.max).setY(l.min.y).applyQuaternion(d),F.expandByPoint(G),G.copy(l.max).setX(l.min.x).applyQuaternion(d),F.expandByPoint(G),G.copy(l.max).applyQuaternion(d),F.expandByPoint(G),F.min.x-=i,F.min.y-=n,F.max.x+=o,F.max.y+=r,d.setFromUnitVectors(Gs,h),p&&d.premultiply(zs.invert()),d.premultiply(this._yAxisUpSpace);const A=F.getSize(V),T=F.getCenter(G).applyQuaternion(d);if(Bt(this._camera)){const m=this.getDistanceToFitBox(A.x,A.y,A.z,e);a.push(this.moveTo(T.x,T.y,T.z,t)),a.push(this.dollyTo(m,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(Lt(this._camera)){const m=this._camera,O=m.right-m.left,u=m.top-m.bottom,R=e?Math.max(O/A.x,u/A.y):Math.min(O/A.x,u/A.y);a.push(this.moveTo(T.x,T.y,T.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?Hs.copy(s):we.createBoundingSphere(s,Hs);if(e.push(this.moveTo(o.center.x,o.center.y,o.center.z,t)),Bt(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,l=Math.min(n/a,r/a);e.push(this.zoomTo(l,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=te.NONE,this._changedDolly=0;const a=G.set(i,o,n),l=V.set(s,t,e);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(l.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const E=!r||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold)&&z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&z(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(E)}lerpLookAt(s,t,e,i,o,n,r,a,l,E,I,h,d,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=te.NONE,this._changedDolly=0;const F=V.set(i,o,n),A=G.set(s,t,e);ct.setFromVector3(A.sub(F).applyQuaternion(this._yAxisUpSpace));const T=se.set(E,I,h),m=G.set(r,a,l);me.setFromVector3(m.sub(T).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(F.lerp(T,d));const O=me.theta-ct.theta,u=me.phi-ct.phi,R=me.radius-ct.radius;this._sphericalEnd.set(ct.radius+R*d,ct.phi+u*d,ct.theta+O*d),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const S=!p||z(this._target.x,this._targetEnd.x,this.restThreshold)&&z(this._target.y,this._targetEnd.y,this.restThreshold)&&z(this._target.z,this._targetEnd.z,this.restThreshold)&&z(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&z(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&z(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(V),n=this.setLookAt(o.x,o.y,o.z,s,t,e,i);return this._sphericalEnd.phi=Ct(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||z(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&z(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&z(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),Yt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=V.set(s,t,e),o=i.distanceTo(this._camera.position),n=i.sub(this._camera.position);Rt.multiplyScalar(n.x),Ft.multiplyScalar(n.y),Yt.multiplyScalar(n.z),V.copy(Rt).add(Ft).add(Yt),V.z=V.z+o,this.dollyTo(o,!1),this.setFocalOffset(-V.x,V.y,-V.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(Vs(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=s/t,n=this._camera.getEffectiveFOV()*fe,r=this._camera.aspect;return((i?o>r:o<r)?t:s/r)*.5/Math.tan(n*.5)+e*.5}getDistanceToFitSphere(s){if(Vs(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*fe,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%ee,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=ee),this._spherical.theta+=ee*Math.round((this._sphericalEnd.theta-this._spherical.theta)/ee)}reset(s=!1){if(!z(this._camera.up.x,this._cameraUp0.x)||!z(this._camera.up.y,this._cameraUp0.y)||!z(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const e=this.getPosition(V);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,ts),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const s=V.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(V);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=ki.subVectors(this._targetEnd,this._target),n=Wi.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(W(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const I=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=$e(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,I,1/0,s),this._needsUpdate=!0}if(W(e))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const I=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=$e(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,I,1/0,s),this._needsUpdate=!0}if(W(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const I=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=$e(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,I,this.maxSpeed,s),this._needsUpdate=!0}if(W(o.x)&&W(o.y)&&W(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const I=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Hi(this._target,this._targetEnd,this._targetVelocity,I,this.maxSpeed,s,this._target),this._needsUpdate=!0}if(W(n.x)&&W(n.y)&&W(n.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const I=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Hi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,I,this.maxSpeed,s,this._focalOffset),this._needsUpdate=!0}if(W(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const I=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=$e(this._zoom,this._zoomEnd,this._zoomVelocity,I,1/0,s)}if(this.dollyToCursor){if(Bt(this._camera)&&this._changedDolly!==0){const I=this._spherical.radius-this._lastDistance,h=this._camera,d=this._getCameraDirection(Te),p=V.copy(d).cross(h.up).normalize();p.lengthSq()===0&&(p.x=1);const F=G.crossVectors(p,d),A=this._sphericalEnd.radius*Math.tan(h.getEffectiveFOV()*fe*.5),m=(this._sphericalEnd.radius-I-this._sphericalEnd.radius)/this._sphericalEnd.radius,O=se.copy(this._targetEnd).add(p.multiplyScalar(this._dollyControlCoord.x*A*h.aspect)).add(F.multiplyScalar(this._dollyControlCoord.y*A)),u=V.copy(this._targetEnd).lerp(O,m),R=this._lastDollyDirection===te.IN&&this._spherical.radius<=this.minDistance,S=this._lastDollyDirection===te.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(R||S)){this._sphericalEnd.radius-=I,this._spherical.radius-=I;const _=G.copy(d).multiplyScalar(-I);u.add(_)}this._boundary.clampPoint(u,u);const g=G.subVectors(u,this._targetEnd);this._targetEnd.copy(u),this._target.add(g),this._changedDolly-=I,W(this._changedDolly)&&(this._changedDolly=0)}else if(Lt(this._camera)&&this._changedZoom!==0){const I=this._zoom-this._lastZoom,h=this._camera,d=V.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(h.near+h.far)/(h.near-h.far)).unproject(h),p=G.set(0,0,-1).applyQuaternion(h.quaternion),F=se.copy(d).add(p.multiplyScalar(-d.dot(h.up))),T=-(this._zoom-I-this._zoom)/this._zoom,m=this._getCameraDirection(Te),O=this._targetEnd.dot(m),u=V.copy(this._targetEnd).lerp(F,T),R=u.dot(m),S=m.multiplyScalar(R-O);u.sub(S),this._boundary.clampPoint(u,u);const g=G.subVectors(u,this._targetEnd);this._targetEnd.copy(u),this._target.add(g),this._changedZoom-=I,W(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),(!W(this._focalOffset.x)||!W(this._focalOffset.y)||!W(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Rt.setFromMatrixColumn(this._camera.matrix,0),Ft.setFromMatrixColumn(this._camera.matrix,1),Yt.setFromMatrixColumn(this._camera.matrix,2),Rt.multiplyScalar(this._focalOffset.x),Ft.multiplyScalar(-this._focalOffset.y),Yt.multiplyScalar(this._focalOffset.z),V.copy(Rt).add(Ft).add(Yt),this._camera.position.add(V)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),V.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const E=this._needsUpdate;return E&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):E?(this.dispatchEvent({type:"update"}),W(t,this.restThreshold)&&W(e,this.restThreshold)&&W(i,this.restThreshold)&&W(o.x,this.restThreshold)&&W(o.y,this.restThreshold)&&W(o.z,this.restThreshold)&&W(n.x,this.restThreshold)&&W(n.y,this.restThreshold)&&W(n.z,this.restThreshold)&&W(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!E&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=E,this._needsUpdate=!1,E}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Ce(this.maxDistance),minZoom:this.minZoom,maxZoom:Ce(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Ce(this.maxPolarAngle),minAzimuthAngle:Ce(this.minAzimuthAngle),maxAzimuthAngle:Ce(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:V.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=pe(e.maxDistance),this.minZoom=e.minZoom,this.maxZoom=pe(e.maxZoom),this.minPolarAngle=e.minPolarAngle,this.maxPolarAngle=pe(e.maxPolarAngle),this.minAzimuthAngle=pe(e.minAzimuthAngle),this.maxAzimuthAngle=pe(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),ct.setFromVector3(V.fromArray(e.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ct.theta,ct.phi,t),this.dollyTo(ct.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",$o),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,se).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 l=1+e*a/t.dot(r);return s.add(G.copy(t).multiplyScalar(l)).add(r.multiplyScalar(1-e))}}_updateNearPlaneCorners(){if(Bt(this._camera)){const s=this._camera,t=s.near,e=s.getEffectiveFOV()*fe,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)||Vs(this._camera,"_collisionTest"))return s;const e=this._getTargetDirection(Te);ks.lookAt(zi,e,this._camera.up);for(let i=0;i<4;i++){const o=G.copy(this._nearPlaneCorners[i]);o.applyMatrix4(ks);const n=se.addVectors(this._target,o);es.set(n,e),es.far=this._spherical.radius+1;const r=es.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;ie.makeEmpty(),s.traverseVisible(n=>{n.isMesh&&ie.expandByObject(n)}),ie.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 E=a.attributes.position;for(let I=0,h=E.count;I<h;I++)V.fromBufferAttribute(E,I),o=Math.max(o,i.distanceToSquared(V))}),e.radius=Math.sqrt(o),e}}class De extends an{constructor(t){super(t);f(this,"onBeforeUpdate",new U);f(this,"onAfterUpdate",new U);f(this,"onAspectUpdated",new U);f(this,"onDisposed",new U);f(this,"three");f(this,"_allControls",new Map);f(this,"updateAspect",()=>{var t;if(!(!this.currentWorld||!this.currentWorld.renderer)&&(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.controls.enabled=t}dispose(){this.setupEvents(!1),this.enabled=!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 L.PerspectiveCamera(60,t,1,1e3);return e.position.set(50,50,50),e.lookAt(new L.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!");we.install({THREE:De.getSubsetOfThree()});const{domElement:t}=this.currentWorld.renderer.three,e=new we(this.three,t);return e.smoothTime=.2,e.dollyToCursor=!0,e.infinityDolly=!0,e}setupEvents(t){t?window.addEventListener("resize",this.updateAspect):window.removeEventListener("resize",this.updateAspect)}static getSubsetOfThree(){return{MOUSE:L.MOUSE,Vector2:L.Vector2,Vector3:L.Vector3,Vector4:L.Vector4,Quaternion:L.Quaternion,Matrix4:L.Matrix4,Spherical:L.Spherical,Box3:L.Box3,Sphere:L.Sphere,Raycaster:L.Raycaster,MathUtils:L.MathUtils}}}const us=class us extends st{constructor(t){super(t);f(this,"onAfterUpdate",new U);f(this,"onBeforeUpdate",new U);f(this,"onDisposed",new U);f(this,"list",new Map);f(this,"enabled",!0);t.add(us.uuid,this)}create(){const t=new In(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),t}delete(t){this.list.delete(t.uuid),t.dispose()}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)}};f(us,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let hs=us;class er{constructor(s,t,e){f(this,"onDisposed",new U);f(this,"world");f(this,"components");f(this,"_grid");f(this,"_fade",3);f(this,"updateZoom",()=>{this.world.camera instanceof De&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)});this.world=t;const{color:i,size1:o,size2:n,distance:r}=e;this.components=s;const a=new L.PlaneGeometry(2,2,1,1),l=new L.ShaderMaterial({side:L.DoubleSide,uniforms:{uSize1:{value:o},uSize2:{value:n},uColor:{value:i},uDistance:{value:r},uFade:{value:this._fade},uZoom:{value:1}},transparent:!0,vertexShader:`
11
+
12
+ varying vec3 worldPosition;
13
+
14
+ uniform float uDistance;
15
+
16
+ void main() {
17
+
18
+ vec3 pos = position.xzy * uDistance;
19
+ pos.xz += cameraPosition.xz;
20
+
21
+ worldPosition = pos;
22
+
23
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
24
+
25
+ }
26
+ `,fragmentShader:`
27
+
28
+ varying vec3 worldPosition;
29
+
30
+ uniform float uZoom;
31
+ uniform float uFade;
32
+ uniform float uSize1;
33
+ uniform float uSize2;
34
+ uniform vec3 uColor;
35
+ uniform float uDistance;
36
+
37
+
38
+
39
+ float getGrid(float size) {
40
+
41
+ vec2 r = worldPosition.xz / size;
42
+
43
+
44
+ vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
45
+ float line = min(grid.x, grid.y);
46
+
47
+
48
+ return 1.0 - min(line, 1.0);
49
+ }
50
+
51
+ void main() {
52
+
53
+
54
+ float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / uDistance, 1.0);
55
+
56
+ float g1 = getGrid(uSize1);
57
+ float g2 = getGrid(uSize2);
58
+
59
+ // Ortho camera fades the grid away when zooming out
60
+ float minZoom = step(0.2, uZoom);
61
+ float zoomFactor = pow(min(uZoom, 1.), 2.) * minZoom;
62
+
63
+ gl_FragColor = vec4(uColor.rgb, mix(g2, g1, g1) * pow(d, uFade));
64
+ gl_FragColor.a = mix(0.5 * gl_FragColor.a, gl_FragColor.a, g2) * zoomFactor;
65
+
66
+ if ( gl_FragColor.a <= 0.0 ) discard;
67
+
68
+
69
+ }
70
+
71
+ `,extensions:{derivatives:!0}});this._grid=new L.Mesh(a,l),this._grid.frustumCulled=!1,t.scene.three.add(this._grid),this.setupEvents(!0)}get visible(){return this._grid.visible}set visible(s){s?this.world.scene.three.add(this._grid):this._grid.removeFromParent()}get material(){return this._grid.material}get fade(){return this._fade===3}set fade(s){this._fade=s?3:0,this.material.uniforms.uFade.value=this._fade}[Symbol.dispose](){throw new Error("Method not implemented.")}get(){return this._grid}dispose(){this.setupEvents(!1),this.components.get(_t).destroy(this._grid),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(s){if(!(this.world.camera instanceof De))return;const t=this.world.camera.controls;s?t.addEventListener("update",this.updateZoom):t.removeEventListener("update",this.updateZoom)}}class fn extends st{constructor(){super(...arguments);f(this,"list",new Map);f(this,"onDisposed",new U);f(this,"config",{color:new L.Color(12303291),size1:1,size2:10,distance:500});f(this,"enabled",!0)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");const e=new er(this.components,t,this.config);this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)})}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()}}f(fn,"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");const Vt=new C.Raycaster,it=new C.Vector3,yt=new C.Vector3,Q=new C.Quaternion,Qi={X:new C.Vector3(1,0,0),Y:new C.Vector3(0,1,0),Z:new C.Vector3(0,0,1)},Ws={type:"change"},qi={type:"mouseDown"},ji={type:"mouseUp",mode:null},Ki={type:"objectChange"};class sr 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 cr;this._gizmo=e,this.add(e);const i=new lr;this._plane=i,this.add(i);const o=this;function n(m,O){let u=O;Object.defineProperty(o,m,{get:function(){return u!==void 0?u:O},set:function(R){u!==R&&(u=R,i[m]=R,e[m]=R,o.dispatchEvent({type:m+"-changed",value:R}),o.dispatchEvent(Ws))}}),o[m]=O,i[m]=O,e[m]=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,l=new C.Quaternion,E=new C.Quaternion,I=new C.Vector3,h=new C.Quaternion,d=new C.Vector3,p=new C.Vector3,F=new C.Vector3,A=0,T=new C.Vector3;n("worldPosition",r),n("worldPositionStart",a),n("worldQuaternion",l),n("worldQuaternionStart",E),n("cameraPosition",I),n("cameraQuaternion",h),n("pointStart",d),n("pointEnd",p),n("rotationAxis",F),n("rotationAngle",A),n("eye",T),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=ir.bind(this),this._onPointerDown=or.bind(this),this._onPointerHover=nr.bind(this),this._onPointerMove=rr.bind(this),this._onPointerUp=ar.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;Vt.setFromCamera(s,this.camera);const t=Xs(this._gizmo.picker[this.mode],Vt);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){Vt.setFromCamera(s,this.camera);const t=Xs(this._plane,Vt,!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,qi.mode=this.mode,this.dispatchEvent(qi)}}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;Vt.setFromCamera(s,this.camera);const n=Xs(this._plane,Vt,!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),yt.set(r,r,r)}else it.copy(this.pointStart),yt.copy(this.pointEnd),it.applyQuaternion(this._worldQuaternionInv),yt.applyQuaternion(this._worldQuaternionInv),yt.divide(it),t.search("X")===-1&&(yt.x=1),t.search("Y")===-1&&(yt.y=1),t.search("Z")===-1&&(yt.z=1);i.scale.copy(this._scaleStart).multiply(yt),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(Qi[t]),it.copy(Qi[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(Ws),this.dispatchEvent(Ki)}}pointerUp(s){s.button===0&&(this.dragging&&this.axis!==null&&(ji.mode=this.mode,this.dispatchEvent(ji)),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(Ws),this.dispatchEvent(Ki),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Vt}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 ir(c){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:c.button};{const s=this.domElement.getBoundingClientRect();return{x:(c.clientX-s.left)/s.width*2-1,y:-(c.clientY-s.top)/s.height*2+1,button:c.button}}}function nr(c){if(this.enabled)switch(c.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(c));break}}function or(c){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(c.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(c)),this.pointerDown(this._getPointer(c)))}function rr(c){this.enabled&&this.pointerMove(this._getPointer(c))}function ar(c){this.enabled&&(this.domElement.releasePointerCapture(c.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(c)))}function Xs(c,s,t){const e=s.intersectObject(c,!0);for(let i=0;i<e.length;i++)if(e[i].object.visible||t)return e[i];return!1}const ss=new C.Euler,k=new C.Vector3(0,1,0),$i=new C.Vector3(0,0,0),Ji=new C.Matrix4,is=new C.Quaternion,as=new C.Quaternion,At=new C.Vector3,tn=new C.Matrix4,Ae=new C.Vector3(1,0,0),Gt=new C.Vector3(0,1,0),Oe=new C.Vector3(0,0,1),ns=new C.Vector3,Re=new C.Vector3,Fe=new C.Vector3;class cr 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 l=s.clone();l.color.setHex(65280),l.opacity=.5;const E=s.clone();E.color.setHex(255),E.opacity=.5;const I=s.clone();I.opacity=.25;const h=s.clone();h.color.setHex(16776960),h.opacity=.25,s.clone().color.setHex(16776960);const p=s.clone();p.color.setHex(7895160);const F=new C.CylinderGeometry(0,.04,.1,12);F.translate(0,.05,0);const A=new C.BoxGeometry(.08,.08,.08);A.translate(0,.04,0);const T=new C.BufferGeometry;T.setAttribute("position",new C.Float32BufferAttribute([0,0,0,1,0,0],3));const m=new C.CylinderGeometry(.0075,.0075,.5,3);m.translate(0,.25,0);function O(v,H){const q=new C.TorusGeometry(v,.0075,3,64,H*Math.PI*2);return q.rotateY(Math.PI/2),q.rotateX(Math.PI/2),q}function u(){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(F,o),[.5,0,0],[0,0,-Math.PI/2]],[new C.Mesh(F,o),[-.5,0,0],[0,0,Math.PI/2]],[new C.Mesh(m,o),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new C.Mesh(F,n),[0,.5,0]],[new C.Mesh(F,n),[0,-.5,0],[Math.PI,0,0]],[new C.Mesh(m,n)]],Z:[[new C.Mesh(F,r),[0,0,.5],[Math.PI/2,0,0]],[new C.Mesh(F,r),[0,0,-.5],[-Math.PI/2,0,0]],[new C.Mesh(m,r),null,[Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.OctahedronGeometry(.1,0),I.clone()),[0,0,0]]],XY:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),E.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),l.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]]]},g={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(u(),i),null,null,null,"helper"]],X:[[new C.Line(T,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new C.Line(T,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new C.Line(T,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},_={XYZE:[[new C.Mesh(O(.5,1),p),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),h),null,[0,Math.PI/2,0]]]},N={AXIS:[[new C.Line(T,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)]]},w={X:[[new C.Mesh(A,o),[.5,0,0],[0,0,-Math.PI/2]],[new C.Mesh(m,o),[0,0,0],[0,0,-Math.PI/2]],[new C.Mesh(A,o),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new C.Mesh(A,n),[0,.5,0]],[new C.Mesh(m,n)],[new C.Mesh(A,n),[0,-.5,0],[0,0,Math.PI]]],Z:[[new C.Mesh(A,r),[0,0,.5],[Math.PI/2,0,0]],[new C.Mesh(m,r),[0,0,0],[Math.PI/2,0,0]],[new C.Mesh(A,r),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new C.Mesh(new C.BoxGeometry(.15,.15,.01),E),[.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),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C.Mesh(new C.BoxGeometry(.1,.1,.1),I.clone())]]},M={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]]]},D={X:[[new C.Line(T,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new C.Line(T,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new C.Line(T,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function x(v){const H=new C.Object3D;for(const q in v)for(let tt=v[q].length;tt--;){const Z=v[q][tt][0].clone(),Ut=v[q][tt][1],xt=v[q][tt][2],bt=v[q][tt][3],Ue=v[q][tt][4];Z.name=q,Z.tag=Ue,Ut&&Z.position.set(Ut[0],Ut[1],Ut[2]),xt&&Z.rotation.set(xt[0],xt[1],xt[2]),bt&&Z.scale.set(bt[0],bt[1],bt[2]),Z.updateMatrix();const ae=Z.geometry.clone();ae.applyMatrix4(Z.matrix),Z.geometry=ae,Z.renderOrder=1/0,Z.position.set(0,0,0),Z.rotation.set(0,0,0),Z.scale.set(1,1,1),H.add(Z)}return H}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=x(R)),this.add(this.gizmo.rotate=x(_)),this.add(this.gizmo.scale=x(w)),this.add(this.picker.translate=x(S)),this.add(this.picker.rotate=x(P)),this.add(this.picker.scale=x(M)),this.add(this.helper.translate=x(g)),this.add(this.helper.rotate=x(N)),this.add(this.helper.scale=x(D)),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:as;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(ss.set(0,0,0)),n.quaternion.copy(e).multiply(Q),Math.abs(k.copy(Ae).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Y"&&(Q.setFromEuler(ss.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(Q),Math.abs(k.copy(Gt).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Z"&&(Q.setFromEuler(ss.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(Q),Math.abs(k.copy(Oe).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="XYZE"&&(Q.setFromEuler(ss.set(0,Math.PI/2,0)),k.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(Ji.lookAt($i,k,Gt)),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(k.copy(Ae).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Y"&&Math.abs(k.copy(Gt).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Z"&&Math.abs(k.copy(Oe).applyQuaternion(e).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XY"&&Math.abs(k.copy(Oe).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="YZ"&&Math.abs(k.copy(Ae).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XZ"&&Math.abs(k.copy(Gt).applyQuaternion(e).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)):this.mode==="rotate"&&(is.copy(e),k.copy(this.eye).applyQuaternion(Q.copy(e).invert()),n.name.search("E")!==-1&&n.quaternion.setFromRotationMatrix(Ji.lookAt(this.eye,$i,Gt)),n.name==="X"&&(Q.setFromAxisAngle(Ae,Math.atan2(-k.y,k.z)),Q.multiplyQuaternions(is,Q),n.quaternion.copy(Q)),n.name==="Y"&&(Q.setFromAxisAngle(Gt,Math.atan2(k.x,k.z)),Q.multiplyQuaternions(is,Q),n.quaternion.copy(Q)),n.name==="Z"&&(Q.setFromAxisAngle(Oe,Math.atan2(k.y,k.x)),Q.multiplyQuaternions(is,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 lr 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"),ns.copy(Ae).applyQuaternion(t==="local"?this.worldQuaternion:as),Re.copy(Gt).applyQuaternion(t==="local"?this.worldQuaternion:as),Fe.copy(Oe).applyQuaternion(t==="local"?this.worldQuaternion:as),k.copy(Re),this.mode){case"translate":case"scale":switch(this.axis){case"X":k.copy(this.eye).cross(ns),At.copy(ns).cross(k);break;case"Y":k.copy(this.eye).cross(Re),At.copy(Re).cross(k);break;case"Z":k.copy(this.eye).cross(Fe),At.copy(Fe).cross(k);break;case"XY":At.copy(Fe);break;case"YZ":At.copy(ns);break;case"XZ":k.copy(Fe),At.copy(Re);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):(tn.lookAt(it.set(0,0,0),At,k),this.quaternion.setFromRotationMatrix(tn)),super.updateMatrixWorld(s)}}class As{constructor(s,t,e,i,o,n=5,r=!0){f(this,"onDraggingStarted",new U);f(this,"onDraggingEnded",new U);f(this,"onDisposed",new U);f(this,"normal");f(this,"origin");f(this,"three",new L.Plane);f(this,"_helper");f(this,"_visible",!0);f(this,"_enabled",!0);f(this,"components");f(this,"world");f(this,"_controlsActive",!1);f(this,"_arrowBoundBox",new L.Mesh);f(this,"_planeMesh");f(this,"_controls");f(this,"_hiddenMaterial",new L.MeshBasicMaterial({visible:!1}));f(this,"update",async()=>{this._enabled&&this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position)});f(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=As.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}async 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(),await 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 L.Vector3(1,0,0),t=new L.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 sr(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 L.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 L.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 L.PlaneGeometry(1),i=new L.Mesh(e,t);return i.scale.set(s,s,s),i}}const _e=class _e extends st{constructor(t){super(t);f(this,"onAfterCreate",new U);f(this,"onAfterDelete",new U);f(this,"onBeforeDrag",new U);f(this,"onAfterDrag",new U);f(this,"onBeforeCreate",new U);f(this,"onBeforeCancel",new U);f(this,"onAfterCancel",new U);f(this,"onBeforeDelete",new U);f(this,"onDisposed",new U);f(this,"orthogonalY",!1);f(this,"toleranceOrthogonalY",.7);f(this,"list",[]);f(this,"PlaneType");f(this,"_material",new L.MeshBasicMaterial({color:16776960,side:L.DoubleSide,transparent:!0,opacity:.2}));f(this,"_size",5);f(this,"_enabled",!1);f(this,"_visible",!1);f(this,"_onStartDragging",()=>{this.onBeforeDrag.trigger()});f(this,"_onEndDragging",()=>{this.onAfterDrag.trigger()});this.components.add(_e.uuid,this),this.PlaneType=As}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}endCreation(){}cancelCreation(){}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(_e.uuid),this.onDisposed.reset()}create(t){if(!this.enabled)return;const o=this.components.get(Me).get(t).castRay();o&&this.createPlaneFromIntersection(t,o)}createFromNormalAndCoplanarPoint(t,e,i){const o=this.newPlane(t,i,e);return this.updateMaterialsAndPlanes(),o}delete(t,e){this.enabled&&(e||(e=this.pickPlane(t)),e&&this.deletePlane(e))}deleteAll(){for(;this.list.length>0;){const t=this.list[0];this.delete(t.world,t)}}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(Me).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 L.Vector3(0,0,0)),o=(a=e.face)==null?void 0:a.normal;if(!i||!o)return;const n=this.getWorldNormal(e,o),r=this.newPlane(t,e.point,n.negate());t.renderer.setPlane(!0,r.three),this.updateMaterialsAndPlanes()}getWorldNormal(t,e){const i=t.object;let o=t.object.matrixWorld.clone();if(i instanceof L.InstancedMesh&&t.instanceId!==void 0){const l=new L.Matrix4;i.getMatrixAt(t.instanceId,l),o=l.multiply(o)}const r=new L.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=this.newPlaneInstance(t,e,i);return o.onDraggingStarted.add(this._onStartDragging),o.onDraggingEnded.add(this._onEndDragging),this.list.push(o),this.onAfterCreate.trigger(o),o}newPlaneInstance(t,e,i){return new this.PlaneType(this.components,t,e,i,this._material)}updateMaterialsAndPlanes(){const t=this.components.get(hs);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(Array.isArray(n.material))for(const r of n.material)r.clippingPlanes=o;else n.material.clippingPlanes=o}}};f(_e,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let ii=_e;const Ne=class Ne extends st{constructor(t){super(t);f(this,"enabled",!0);f(this,"_originalBackground",new Map);f(this,"onDisposed",new U);f(this,"list",{});f(this,"_originals",{});this.components.add(Ne.uuid,this)}set(t,e=Object.keys(this.list)){for(const i of e){const{material:o,meshes:n}=this.list[i];for(const r of n)if(t)this._originals[r.uuid]||(this._originals[r.uuid]={material:r.material}),r instanceof L.InstancedMesh&&r.instanceColor&&(this._originals[r.uuid].instances=r.instanceColor,r.instanceColor=null),r.material=o;else{if(!this._originals[r.uuid])continue;r.material=this._originals[r.uuid].material;const a=this._originals[r.uuid].instances;r instanceof L.InstancedMesh&&a&&(r.instanceColor=a)}}}dispose(){for(const t in this.list){const{material:e}=this.list[t];e.dispose()}this.list={},this._originals={},this.onDisposed.trigger(Ne.uuid),this.onDisposed.reset(),this._originalBackground.clear()}setBackgroundColor(t,e){const i=e.scene.three;i instanceof L.Scene&&(this._originalBackground.has(e.uuid)||this._originalBackground.set(e.uuid,i.background),this._originalBackground&&(i.background=t))}resetBackgroundColor(t){const e=t.scene.three;if(!(e instanceof L.Scene))return;const i=this._originalBackground.get(t.uuid);i&&(e.background=i)}addMaterial(t,e){if(this.list[t])throw new Error("This ID already exists!");this.list[t]={material:e,meshes:new Set}}addMeshes(t,e){if(!this.list[t])throw new Error("This ID doesn't exists!");for(const i of e)this.list[t].meshes.add(i)}removeMeshes(t,e){if(!this.list[t])throw new Error("This ID doesn't exists!");for(const i of e)this.list[t].meshes.delete(i)}};f(Ne,"uuid","24989d27-fa2f-4797-8b08-35918f74e502");let ni=Ne;function hr(c,s,t,e){return new Promise((i,o)=>{function n(){const r=c.clientWaitSync(s,t,0);if(r===c.WAIT_FAILED){o();return}if(r===c.TIMEOUT_EXPIRED){setTimeout(n,e);return}i()}n()})}async function Er(c,s,t,e,i,o,n){const r=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);c.flush(),await hr(c,r,0,10),c.deleteSync(r),c.bindBuffer(s,t),c.getBufferSubData(s,e,i,o,n),c.bindBuffer(s,null)}async function Cn(c,s,t,e,i,o,n,r){const a=c.createBuffer();return c.bindBuffer(c.PIXEL_PACK_BUFFER,a),c.bufferData(c.PIXEL_PACK_BUFFER,r.byteLength,c.STREAM_READ),c.readPixels(s,t,e,i,o,n,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),await Er(c,c.PIXEL_PACK_BUFFER,a,0,r),c.deleteBuffer(a),r}class pn{constructor(s,t,e){f(this,"onDisposed",new U);f(this,"onViewUpdated",new U);f(this,"enabled",!0);f(this,"needsUpdate",!1);f(this,"renderDebugFrame",!1);f(this,"components");f(this,"world");f(this,"renderer");f(this,"autoUpdate",!0);f(this,"updateInterval",1e3);f(this,"worker");f(this,"scene",new L.Scene);f(this,"_width",512);f(this,"_height",512);f(this,"_availableColor",1);f(this,"renderTarget");f(this,"bufferSize");f(this,"_buffer");f(this,"updateVisibility",async s=>{if(!this.enabled||!this.needsUpdate&&!s)return;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 Cn(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 L.WebGLRenderer,this.renderTarget=new L.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=`
72
+ addEventListener("message", (event) => {
73
+ const { buffer } = event.data;
74
+ const colors = new Map();
75
+ for (let i = 0; i < buffer.length; i += 4) {
76
+ const r = buffer[i];
77
+ const g = buffer[i + 1];
78
+ const b = buffer[i + 2];
79
+ const code = "" + r + "-" + g + "-" + b;
80
+ if(colors.has(code)) {
81
+ colors.set(code, colors.get(code) + 1);
82
+ } else {
83
+ colors.set(code, 1);
84
+ }
85
+ }
86
+ postMessage({ colors });
87
+ });
88
+ `,o=new Blob([i],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(o))}dispose(){this.enabled=!1;for(const s of this.scene.children)s.removeFromParent();this.onViewUpdated.reset(),this.worker.terminate(),this.renderer.dispose(),this.renderTarget.dispose(),this._buffer=null,this.onDisposed.reset()}getAvailableColor(){let s=BigInt(this._availableColor.toString());const t=[];do t.unshift(Number(s%256n)),s/=256n;while(s);for(;t.length!==3;)t.unshift(0);const[e,i,o]=t,n=`${e}-${i}-${o}`;return{r:e,g:i,b:o,code:n}}increaseColor(){if(this._availableColor===256*256*256){console.warn("Color can't be increased over 256 x 256 x 256!");return}this._availableColor++}decreaseColor(){if(this._availableColor===1){console.warn("Color can't be decreased under 0!");return}this._availableColor--}applySettings(s){s&&(s.updateInterval!==void 0&&(this.updateInterval=s.updateInterval),s.height!==void 0&&(this._height=s.height),s.width!==void 0&&(this._width=s.width),s.autoUpdate!==void 0&&(this.autoUpdate=s.autoUpdate))}}class Tn extends pn{constructor(t,e,i){super(t,e,i);f(this,"threshold",100);f(this,"onViewUpdated",new U);f(this,"colorMeshes",new Map);f(this,"isProcessing",!1);f(this,"_colorCodeMeshMap",new Map);f(this,"_meshIDColorCodeMap",new Map);f(this,"_currentVisibleMeshes",new Set);f(this,"_recentlyHiddenMeshes",new Set);f(this,"_transparentMat",new L.MeshBasicMaterial({transparent:!0,opacity:0}));f(this,"handleWorkerMessage",async t=>{if(this.isProcessing)return;const e=t.data.colors;this._recentlyHiddenMeshes=new Set(this._currentVisibleMeshes),this._currentVisibleMeshes.clear();for(const[i,o]of e){if(o<this.threshold)continue;const n=this._colorCodeMeshMap.get(i);n&&(this._currentVisibleMeshes.add(n),this._recentlyHiddenMeshes.delete(n))}this.onViewUpdated.trigger({seen:this._currentVisibleMeshes,unseen:this._recentlyHiddenMeshes})});this.worker.addEventListener("message",this.handleWorkerMessage),this.autoUpdate&&window.setInterval(async()=>{this.isProcessing||await this.updateVisibility()},this.updateInterval),this.onViewUpdated.add(({seen:o,unseen:n})=>{for(const r of o)r.visible=!0;for(const r of n)r.visible=!1})}dispose(){super.dispose(),this._currentVisibleMeshes.clear(),this._recentlyHiddenMeshes.clear(),this._meshIDColorCodeMap.clear(),this._transparentMat.dispose(),this._colorCodeMeshMap.clear();const t=this.components.get(_t);for(const e in this.colorMeshes){const i=this.colorMeshes.get(e);i&&t.destroy(i,!0)}this.colorMeshes.clear()}add(t){if(!this.enabled)return;if(this.isProcessing){console.log("Culler processing not finished yet.");return}this.isProcessing=!0;const e=t instanceof L.InstancedMesh,{geometry:i,material:o}=t,{colorMaterial:n,code:r}=this.getAvailableMaterial();let a;if(Array.isArray(o)){let I=!0;const h=[];for(const d of o)si.isTransparent(d)?h.push(this._transparentMat):(I=!1,h.push(n));if(I){n.dispose(),this.isProcessing=!1;return}a=h}else if(si.isTransparent(o)){n.dispose(),this.isProcessing=!1;return}else a=n;this._colorCodeMeshMap.set(r,t),this._meshIDColorCodeMap.set(t.uuid,r);const l=e?t.count:1,E=new L.InstancedMesh(i,a,l);e?E.instanceMatrix=t.instanceMatrix:E.setMatrixAt(0,new L.Matrix4),t.visible=!1,E.applyMatrix4(t.matrix),E.updateMatrix(),this.scene.add(E),this.colorMeshes.set(t.uuid,E),this.increaseColor(),this.isProcessing=!1}remove(t){if(this.isProcessing){console.log("Culler processing not finished yet.");return}this.isProcessing=!0;const e=this.components.get(_t);this._currentVisibleMeshes.delete(t),this._recentlyHiddenMeshes.delete(t);const i=this.colorMeshes.get(t.uuid),o=this._meshIDColorCodeMap.get(t.uuid);if(!i||!o){this.isProcessing=!1,console.log(t.visible);return}this._colorCodeMeshMap.delete(o),this._meshIDColorCodeMap.delete(t.uuid),this.colorMeshes.delete(t.uuid),i.geometry=void 0,i.material=[],e.destroy(i,!0),this._recentlyHiddenMeshes.delete(t),this._currentVisibleMeshes.delete(t),this.isProcessing=!1}getAvailableMaterial(){const{r:t,g:e,b:i,code:o}=this.getAvailableColor(),n=L.ColorManagement.enabled;L.ColorManagement.enabled=!1;const r=new L.Color(`rgb(${t}, ${e}, ${i})`);if(!this.world.renderer)throw new Error("Renderer not found in the world!");const a=this.world.renderer.clippingPlanes,l=new L.MeshBasicMaterial({color:r,clippingPlanes:a,side:L.DoubleSide});return L.ColorManagement.enabled=n,{colorMaterial:l,code:o}}}const ye=class ye extends st{constructor(t){super(t);f(this,"_enabled",!0);f(this,"list",new Map);f(this,"onDisposed",new U);t.add(ye.uuid,this)}get enabled(){return this._enabled}set enabled(t){this._enabled=t;for(const[e,i]of this.list)i.enabled=t}create(t,e){if(this.list.has(t.uuid))return this.list.get(t.uuid);const i=new Tn(this.components,t,e);return this.list.set(t.uuid,i),i}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){this.enabled=!1,this.onDisposed.trigger(ye.uuid),this.onDisposed.reset();for(const[t,e]of this.list)e.dispose();this.list.clear()}};f(ye,"uuid","69f2a50d-c266-44fc-b1bd-fa4d34be89e6");let oi=ye;const Tt=class Tt extends st{constructor(t){super(t);f(this,"enabled",!0);f(this,"onDisposed",new U);f(this,"_absoluteMin");f(this,"_absoluteMax");f(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 L.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 L.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 L.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 L.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 L.Vector3(t.x+i,t.y+o,t.z+n),a=r.distanceTo(t);return new L.Sphere(r,a)}getMesh(){const t=new L.Box3(this._absoluteMin,this._absoluteMax),e=Tt.getDimensions(t),{width:i,height:o,depth:n,center:r}=e,a=new L.BoxGeometry(i,o,n),l=new L.Mesh(a);return this._meshes.push(l),l.position.copy(r),l}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){if(!t.geometry.index)return;const e=Tt.getFragmentBounds(t);t.updateMatrixWorld();const i=t.matrixWorld,o=new L.Matrix4,n=t instanceof L.InstancedMesh,r=n?t.count:1;for(let a=0;a<r;a++){const l=e.min.clone(),E=e.max.clone();n&&(t.getMatrixAt(a,o),l.applyMatrix4(o),E.applyMatrix4(o)),l.applyMatrix4(i),E.applyMatrix4(i),l.x<this._absoluteMin.x&&(this._absoluteMin.x=l.x),l.y<this._absoluteMin.y&&(this._absoluteMin.y=l.y),l.z<this._absoluteMin.z&&(this._absoluteMin.z=l.z),l.x>this._absoluteMax.x&&(this._absoluteMax.x=l.x),l.y>this._absoluteMax.y&&(this._absoluteMax.y=l.y),l.z>this._absoluteMax.z&&(this._absoluteMax.z=l.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)}}static getFragmentBounds(t){const e=t.geometry.attributes.position,i=Number.MAX_VALUE,o=-i,n=new L.Vector3(i,i,i),r=new L.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 l=0;l<a.length;l++){if(l%3===0&&a[l]===0&&a[l+1]===0&&a[l+2]===0){l+=2;continue}const E=a[l],I=e.getX(E),h=e.getY(E),d=e.getZ(E);I<n.x&&(n.x=I),h<n.y&&(n.y=h),d<n.z&&(n.z=d),I>r.x&&(r.x=I),h>r.y&&(r.y=h),d>r.z&&(r.z=d)}return new L.Box3(n,r)}};f(Tt,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let ri=Tt;const mn=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,3940055652,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]);class Rn{async export(s,t,e=!1,i=!0){const o={},n=new Set(s.GetIfcEntityList(t)),r=new Set([b.IFCPROJECT,b.IFCSITE,b.IFCBUILDING,b.IFCBUILDINGSTOREY,b.IFCSPACE]);for(const a of r)n.add(a);for(const a of n){if(mn.has(a))continue;const l=r.has(a)&&i,E=s.GetLineIDsWithType(t,a);for(const I of E){const h=s.GetLine(0,I,l,e);o[h.expressID]=h}}return o}}const Fn={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 Ir{getAll(s,t){const e={},i=Object.keys(Fn).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 l=0;l<a;l++)e[r.get(l)]=n}return e}}const fi={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 dt{static async getUnits(s){var n;const{IFCUNITASSIGNMENT:t}=b,e=await s.getAllPropertiesOfType(t);if(!e)return 1;const i=Object.keys(e),o=e[parseInt(i[0],10)];for(const r of o.Units){if(r.value===void 0||r.value===null)continue;const a=await s.getProperties(r.value);if(!a||!a.UnitType||!a.UnitType.value||a.UnitType.value!=="LENGTHUNIT")continue;let E=1,I=1;return a.Name.value==="METRE"&&(I=1),a.Name.value==="FOOT"&&(I=.3048),((n=a.Prefix)==null?void 0:n.value)==="MILLI"&&(E=.001),I*E}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??(()=>{}),n={},r=s.getAllPropertiesIDs();for(const l of r){const E=await s.getProperties(l);if(!E)continue;const I=E.type===t,h=Object.keys(E).find(T=>T.startsWith("Relating")),d=Object.keys(E).find(T=>T.startsWith("Related"));if(!(I&&h&&d))continue;const p=await s.getProperties((a=E[h])==null?void 0:a.value),F=E[d];if(!p||!F||!(F&&Array.isArray(F)))continue;const A=F.map(T=>T.value);o(p.expressID,A),n[p.expressID]=A}return n}static async getQsetQuantities(s,t,e){const o=e??(()=>{}),n=await s.getProperties(t);return!n||n.type!==b.IFCELEMENTQUANTITY?null:(n.Quantities??[{}]).map(l=>(l.value&&o(l.value),l.value)).filter(l=>l!==null)}static async getPsetProps(s,t,e){const o=e??(()=>{}),n=await s.getProperties(t);return!n||n.type!==b.IFCPROPERTYSET?null:(n.HasProperties??[{}]).map(l=>(l.value&&o(l.value),l.value)).filter(l=>l!==null)}static async getPsetRel(s,t){var r;if(!await s.getProperties(t))return null;const i=await s.getAllPropertiesOfType(b.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 dt.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 fi[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}}const fs=class fs extends st{constructor(t){super(t);f(this,"onDisposed",new U);f(this,"onFragmentsLoaded",new U);f(this,"onFragmentsDisposed",new U);f(this,"list",new Map);f(this,"groups",new Map);f(this,"enabled",!0);f(this,"baseCoordinationModel","");f(this,"_loader",new en.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=!0){const i=this._loader.import(t);for(const o of i.items)o.group=i,this.list.set(o.id,o);return e&&this.coordinate([i]),this.groups.set(i.uuid,i),this.onFragmentsLoaded.trigger(i),i}export(t){return this._loader.export(t)}coordinate(t=Array.from(this.groups.values())){if(this.baseCoordinationModel.length===0){const o=t.pop();if(!o)return;this.baseCoordinationModel=o.uuid}if(!t.length)return;const i=this.groups.get(this.baseCoordinationModel);if(!i){console.log("No base model found for coordination!");return}for(const o of t)o!==i&&(o.position.set(0,0,0),o.rotation.set(0,0,0),o.scale.set(1,1,1),o.updateMatrix(),o.applyMatrix4(o.coordinationMatrix.clone().invert()),o.applyMatrix4(i.coordinationMatrix))}};f(fs,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let ut=fs;class dr extends st{constructor(t){super(t);f(this,"onFound",new U);f(this,"onDisposed",new U);f(this,"enabled",!0);f(this,"indexedModels",{});f(this,"_conditionFunctions");f(this,"_noHandleAttributes",["type"]);f(this,"onFragmentsDisposed",t=>{delete this.indexedModels[t.groupID]});this._conditionFunctions=this.getConditionFunctions(),t.get(ut).onFragmentsDisposed.add(this.onFragmentsDisposed)}dispose(){this.indexedModels={},this.onFound.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}async indexEntityRelations(t){const e={};await dt.getRelationMap(t,b.IFCRELDEFINESBYPROPERTIES,async(o,n)=>{e[o]||(e[o]=new Set);const r=[];await dt.getPsetProps(t,o,a=>{r.push(a),e[o].add(a),e[a]||(e[a]=new Set),e[a].add(o)});for(const a of n){e[o].add(a);for(const l of r)e[l].add(a);e[a]||(e[a]=new Set),e[a].add(a)}});const i=[b.IFCRELCONTAINEDINSPATIALSTRUCTURE,b.IFCRELDEFINESBYTYPE,b.IFCRELASSIGNSTOGROUP];for(const o of i)await dt.getRelationMap(t,o,async(n,r)=>{e[n]||(e[n]=new Set);for(const a of r)e[n].add(a),e[a]||(e[a]=new Set),e[a].add(a)});return this.indexedModels[t.uuid]=e,e}async find(t,e){const i=this.components.get(ut),o=e||i.groups.values(),n={};for(const a of o){let l=this.indexedModels[a.uuid];l||(l=await this.indexEntityRelations(a));let E=[];for(const[d,p]of t.entries()){const F=new Set,A=this.simpleQuery(a,p,F),T=[];for(const m of A){const O=l[m];if(O){T.push(m);for(const u of O)F.has(u)||T.push(u)}}E=p.operator==="AND"&&d>0?this.getCommonElements(E,T):[...E,...T]}const I=new Set;for(const[d]of a.data)E.includes(d)&&I.add(d);const h=new Set;for(const d of E)I.has(d)||h.add(d);n[a.uuid]={modelEntities:I,otherEntities:h}}const r=this.toFragmentMap(n);return this.onFound.trigger(r),r}toFragmentMap(t){const e=this.components.get(ut),i={};for(const o in t){const n=e.groups.get(o);if(!n)continue;const r=t[o].modelEntities;for(const a of r){const l=n.data.get(a);if(l)for(const E of l[0]){const I=n.keyFragments.get(E);if(!I)throw new Error("Fragment ID not found!");i[I]||(i[I]=new Set),i[I].add(a)}}}return i}simpleQuery(t,e,i){const o=t.getLocalProperties();if(!o)throw new Error("Model has no properties");let n={},r=0,a=[];for(const l of e.queries){let E=[];const I=l.operator==="AND"?n:o;if(l.condition){const d=this.getMatchingEntities(I,l,i);E=d.expressIDs,n={...n,...d.entities}}else E=[...this.simpleQuery(t,l,i)];a=r===0?E:this.combineArrays(a,E,l.operator??"AND"),r++}return new Set(a)}getMatchingEntities(t,e,i){const{attribute:o,condition:n}=e;let{value:r}=e;const a=!this._noHandleAttributes.includes(o),l=[],E=[];for(const I in t){const h=t[I];if(h===void 0)continue;const d=h[o];let p=a?d==null?void 0:d.value:d;if(p==null)continue;const F=typeof r,A=typeof p;F==="number"&&A==="string"?r=r.toString():F==="string"&&A==="number"&&(p=p.toString());let T=this._conditionFunctions[n](p,r);if(e.negateResult&&(T=!T),!T){e.negateResult&&i.add(h.expressID);continue}l.push(h.expressID),E.push(h)}return{expressIDs:l,entities:E,excludedItems:i}}combineArrays(t,e,i){return i?i==="AND"?this.arrayIntersection(t,e):this.arrayUnion(t,e):e}getCommonElements(...t){const e=[],i=new Map;for(const o of t){const n=new Set(o);for(const r of n)i.has(r)?i.set(r,i.get(r)+1):i.set(r,1)}for(const[o,n]of i)n===t.length&&e.push(o);return e}arrayIntersection(t,e){return t.filter(i=>e.includes(i))}arrayUnion(t,e){return[...t,...e]}getConditionFunctions(){return{is:(t,e)=>t===e,includes:(t,e)=>t.toString().includes(e.toString()),startsWith:(t,e)=>t.toString().startsWith(e.toString()),endsWith:(t,e)=>t.toString().endsWith(e.toString()),matches:(t,e)=>new RegExp(e.toString()).test(t.toString())}}}const Le=class Le extends st{constructor(t){super(t);f(this,"onDisposed",new U);f(this,"enabled",!0);f(this,"relationsToProcess",[b.IFCRELDEFINESBYPROPERTIES,b.IFCRELDEFINESBYTYPE,b.IFCRELASSOCIATESMATERIAL,b.IFCRELCONTAINEDINSPATIALSTRUCTURE,b.IFCRELASSOCIATESCLASSIFICATION,b.IFCRELASSIGNSTOGROUP]);f(this,"indexMap",{});f(this,"_propertiesManager",null);f(this,"onPropertiesManagerSet",new U);f(this,"onFragmentsDisposed",t=>{delete this.indexMap[t.groupID]});this.components.add(Le.uuid,this),t.get(ut).onFragmentsDisposed.add(this.onFragmentsDisposed)}set propertiesManager(t){this._propertiesManager||(this._propertiesManager=t,t&&(t.onElementToPset.add(async({model:e,psetID:i,elementID:o})=>{this.indexMap[e.uuid]&&this.setEntityIndex(e,o).add(i)}),this.onPropertiesManagerSet.trigger(t)))}get propertiesManager(){return this._propertiesManager}async dispose(){this.indexMap={},this.propertiesManager=null,this.onPropertiesManagerSet.reset(),this.components.get(ut).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(Le.uuid),this.onDisposed.reset()}async getProperties(t,e){if(!t.hasProperties)return null;const i=t.getLocalProperties();if(i===void 0)return null;const o=this.indexMap[t.uuid];if(!o)return null;const n=o[e],r=parseInt(e,10),a=await t.getProperties(r);if(!a)throw new Error("Properties not found!");const l=this.cloneProperty(a);if(!l)throw new Error("Properties not found!");const E=[l];if(n)for(const I of n){const h=await t.getProperties(I);if(!h)continue;const d=this.cloneProperty(h);d&&(this.getPsetProperties(d,i),this.getNestedPsets(d,i),E.push(d))}return E}getNestedPsets(t,e){if(t.HasPropertySets)for(const i of t.HasPropertySets){const o=i.value;i.value=this.cloneProperty(e[o]),this.getPsetProperties(i.value,e)}}getPsetProperties(t,e){if(t.HasProperties)for(const i of t.HasProperties){const o=i.value,n=this.cloneProperty(e[o]);i.value={...n}}}async process(t){if(!t.hasProperties)throw new Error("FragmentsGroup properties not found");this.indexMap[t.uuid]={};const e=[b.IFCPROPERTYSET,b.IFCELEMENTQUANTITY];for(const i of this.relationsToProcess)await dt.getRelationMap(t,i,async(o,n)=>{const r=await t.getProperties(o);if(r){e.includes(r.type)||this.setEntityIndex(t,o);for(const a of n)this.setEntityIndex(t,a).add(o)}})}setEntityIndex(t,e){return this.indexMap[t.uuid][e]||(this.indexMap[t.uuid][e]=new Set),this.indexMap[t.uuid][e]}cloneProperty(t,e={}){if(!t)return e;for(const i in t){const o=t[i],n=Array.isArray(o),r=typeof o=="object"&&!n&&o!==null;if(n){e[i]=[];const a=e[i];this.clonePropertyArray(o,a)}else if(r){e[i]={};const a=e[i];this.cloneProperty(o,a)}else e[i]=o}return e}clonePropertyArray(t,e){for(const i of t){const o=Array.isArray(i),n=typeof i=="object"&&!o&&i!==null;if(o){const r=[];e.push(r),this.clonePropertyArray(i,r)}else if(n){const r={};e.push(r),this.cloneProperty(i,r)}else e.push(i)}}};f(Le,"uuid","23a889ab-83b3-44a4-8bee-ead83438370b");let ai=Le;class ur{constructor(){f(this,"factor",1);f(this,"complement",1)}apply(s){const e=this.getScaleMatrix().multiply(s);s.copy(e)}setUp(s){var o;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))}getLengthUnits(s){try{const e=s.GetLineIDsWithType(0,b.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 L.Matrix4().fromArray([s,0,0,0,0,s,0,0,0,0,s,0,0,0,0,1])}}class An{constructor(){f(this,"itemsByFloor",{});f(this,"_units",new ur)}setUp(s){this._units.setUp(s),this.cleanUp();try{const t=s.GetLineIDsWithType(0,b.IFCRELCONTAINEDINSPATIALSTRUCTURE),e=new Set,i=s.GetLineIDsWithType(0,b.IFCSPACE);for(let l=0;l<i.size();l++)e.add(i.get(l));const o=s.GetLineIDsWithType(0,b.IFCRELAGGREGATES),n=o.size();for(let l=0;l<n;l++){const E=o.get(l),I=s.GetLine(0,E);if(!I||!I.RelatingObject||!I.RelatedObjects)continue;const h=I.RelatingObject.value,d=I.RelatedObjects;for(const p of d){const F=p.value;e.has(F)&&(this.itemsByFloor[F]=h)}}const r={},a=t.size();for(let l=0;l<a;l++){const E=t.get(l),I=s.GetLine(0,E);if(!I||!I.RelatingStructure||!I.RelatedElements)continue;const h=I.RelatingStructure.value,d=I.RelatedElements;if(e.has(h))for(const p of d){r[h]||(r[h]=[]);const F=p.value;r[h].push(F)}else for(const p of d){const F=p.value;this.itemsByFloor[F]=h}}for(const l in r){const E=this.itemsByFloor[l];if(E!==void 0){const I=r[l];for(const h of I)this.itemsByFloor[h]=E}}for(let l=0;l<n;l++){const E=o.get(l),I=s.GetLine(0,E);if(!I||!I.RelatingObject||!I.RelatedObjects)continue;const h=I.RelatingObject.value,d=I.RelatedObjects;for(const p of d){const F=p.value,A=this.itemsByFloor[h];A!==void 0&&(this.itemsByFloor[F]=A)}}}catch{console.log("Could not get floors.")}}cleanUp(){this.itemsByFloor={}}}class Ci{constructor(){f(this,"includeProperties",!0);f(this,"optionalCategories",[b.IFCSPACE]);f(this,"coordinate",!0);f(this,"wasm",{path:"",absolute:!1,logLevel:b.LogLevel.LOG_LEVEL_OFF});f(this,"excludedCategories",new Set);f(this,"saveLocations",!1);f(this,"webIfc",{COORDINATE_TO_ORIGIN:!0,OPTIMIZE_PROFILES:!0});f(this,"autoSetWasm",!0);f(this,"customLocateFileHandler",null)}}class On{constructor(){f(this,"defLineMat",new L.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 Ht.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 L.Matrix4}}}getCurves(s,t){const e=[];let i=0;for(const o of s){const n={};if(o.data)for(const h of o.data){const[d,p]=h.split(": "),F=parseFloat(p);n[d]=F||p}const{points:r}=o,a=new Float32Array(r.length*3);for(let h=0;h<r.length;h++){const{x:d,y:p,z:F}=r[h];a[h*3]=d,a[h*3+1]=p,a[h*3+2]=F||0}const l=new L.BufferAttribute(a,3),E=new L.EdgesGeometry;E.setAttribute("position",l);const I=new Ht.CurveMesh(i,n,t,E,this.defLineMat);e.push(I.curve),i++}return e}}class Sn{get(s,t){let e="";const i=s.GetHeaderLine(0,t)||"";if(!i)return e;for(const o of i.arguments)if(o!=null)if(Array.isArray(o))for(const n of o)e+=`${n.value}|`;else e+=`${o.value}|`;return e}}const Pe=class Pe extends st{constructor(t){super(t);f(this,"onIfcLoaded",new U);f(this,"onIfcStartedLoading",new U);f(this,"onSetup",new U);f(this,"onDisposed",new U);f(this,"settings",new Ci);f(this,"enabled",!0);f(this,"webIfc",new b.IfcAPI);f(this,"_material",new L.MeshLambertMaterial);f(this,"_spatialTree",new An);f(this,"_metaData",new Sn);f(this,"_fragmentInstances",new Map);f(this,"_civil",new On);f(this,"_propertyExporter",new Rn);f(this,"_visitedFragments",new Map);f(this,"_materialT",new L.MeshLambertMaterial({transparent:!0,opacity:.5}));this.components.add(Pe.uuid,this),this.settings.excludedCategories.add(b.IFCOPENINGELEMENT)}dispose(){this.onIfcLoaded.reset(),this.webIfc=null,this.onDisposed.trigger(Pe.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(),n=await this._propertyExporter.export(this.webIfc,0);o.setLocalProperties(n),this.cleanUp(),console.log(`Streaming the IFC took ${performance.now()-i} ms!`);const r=this.components.get(ut);r.groups.set(o.uuid,o);for(const a of o.items)r.list.set(a.id,a),a.mesh.uuid=a.id,a.group=o;return e&&r.coordinate([o]),this.onIfcLoaded.trigger(o),o}async readIfcFile(t){const{path:e,absolute:i,logLevel:o}=this.settings.wasm;return this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(),o&&this.webIfc.SetLogLevel(o),this.webIfc.OpenModel(t,this.settings.webIfc)}async getAllGeometries(){this._spatialTree.setUp(this.webIfc);const t=this.webIfc.GetIfcEntityList(0),e=new Ht.FragmentsGroup,{FILE_NAME:i,FILE_DESCRIPTION:o}=b;e.ifcMetadata={name:this._metaData.get(this.webIfc,i),description:this._metaData.get(this.webIfc,o),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};const n=[];for(const a of t){if(!this.webIfc.IsIfcElement(a)&&a!==b.IFCSPACE||this.settings.excludedCategories.has(a))continue;const l=this.webIfc.GetLineIDsWithType(0,a),E=l.size();for(let I=0;I<E;I++){const h=l.get(I);n.push(h);const d=this._spatialTree.itemsByFloor[h]||0;e.data.set(h,[[],[d,a]])}}this._spatialTree.cleanUp(),this.webIfc.StreamMeshes(0,n,a=>{this.getMesh(a,e)});for(const a of this._visitedFragments){const{index:l,fragment:E}=a[1];e.keyFragments.set(l,E.id)}for(const a of e.items){const l=this._fragmentInstances.get(a.id);if(!l)throw new Error("Fragment not found!");const E=[];for(const[I,h]of l)E.push(h);a.add(E)}const r=this.webIfc.GetCoordinationMatrix(0);return e.coordinationMatrix.fromArray(r),e.civilData=this._civil.read(this.webIfc),e}cleanUp(){this.webIfc=null,this.webIfc=new b.IfcAPI,this._visitedFragments.clear(),this._fragmentInstances.clear()}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:l,z:E,w:I}=r.color,h=I!==1,{geometryExpressID:d}=r,p=`${d}-${h}`;if(!this._visitedFragments.has(p)){const R=this.getGeometry(this.webIfc,d),S=h?this._materialT:this._material,g=new Ht.Fragment(R,S,1);e.add(g.mesh),e.items.push(g);const _=this._visitedFragments.size;this._visitedFragments.set(p,{index:_,fragment:g})}const F=new L.Color().setRGB(a,l,E,"srgb"),A=new L.Matrix4;A.fromArray(r.flatTransformation);const T=this._visitedFragments.get(p);if(T===void 0)throw new Error("Error getting geometry data for streaming!");const m=e.data.get(o);if(!m)throw new Error("Data not found!");m[0].push(T.index);const{fragment:O}=T;this._fragmentInstances.has(O.id)||this._fragmentInstances.set(O.id,new Map);const u=this._fragmentInstances.get(O.id);if(!u)throw new Error("Instances not found!");if(u.has(o)){const R=u.get(o);if(!R)throw new Error("Instance not found!");R.transforms.push(A),R.colors&&R.colors.push(F)}else u.set(o,{id:o,transforms:[A],colors:[F]})}}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 h=0;h<n.length;h+=6)r[h/2]=n[h],r[h/2+1]=n[h+1],r[h/2+2]=n[h+2],a[h/2]=n[h+3],a[h/2+1]=n[h+4],a[h/2+2]=n[h+5];const l=new L.BufferGeometry,E=new L.BufferAttribute(r,3),I=new L.BufferAttribute(a,3);return l.setAttribute("position",E),l.setAttribute("normal",I),l.setIndex(Array.from(o)),i.delete(),l}async autoSetWasm(){const t=await fetch(`https://unpkg.com/openbim-components@${ls.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}}};f(Pe,"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");let Es=Pe;const Mt=class Mt extends st{constructor(t){super(t);f(this,"onDisposed",new U);f(this,"onRequestFile",new U);f(this,"ifcToExport",null);f(this,"onElementToPset",new U);f(this,"onPropToPset",new U);f(this,"onPsetRemoved",new U);f(this,"onDataChanged",new U);f(this,"wasm",{path:"/",absolute:!1});f(this,"enabled",!0);f(this,"attributeListeners",{});f(this,"selectedModel");f(this,"_changeMap",{});this.components.add(Mt.uuid,this)}get(){return this._changeMap}dispose(){this.selectedModel=void 0,this.attributeListeners={},this._changeMap={},this.onElementToPset.reset(),this.onPropToPset.reset(),this.onPsetRemoved.reset(),this.onDataChanged.reset(),this.onDisposed.trigger(Mt.uuid),this.onDisposed.reset()}increaseMaxID(t){return t.ifcMetadata.maxExpressID++,t.ifcMetadata.maxExpressID}static getIFCSchema(t){const e=t.ifcMetadata.schema;if(!e)throw new Error("IFC Schema not found");return e}newGUID(t){const e=Mt.getIFCSchema(t);return new b[e].IfcGloballyUniqueId(oe.create())}async getOwnerHistory(t){const e=await t.getAllPropertiesOfType(b.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 b.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 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=Mt.getIFCSchema(t),{ownerHistoryHandle:n}=await this.getOwnerHistory(t),r=this.newGUID(t),a=new b[o].IfcLabel(e),l=i?new b[o].IfcText(i):null,E=new b[o].IfcPropertySet(r,n,a,l,[]);E.expressID=this.increaseMaxID(t);const I=this.newGUID(t),h=new b[o].IfcRelDefinesByProperties(I,n,null,null,[],new b.Handle(E.expressID));return h.expressID=this.increaseMaxID(t),await this.setData(t,E,h),{pset:E,rel:h}}async removePset(t,...e){for(const i of e){const o=await t.getProperties(i);if((o==null?void 0:o.type)!==b.IFCPROPERTYSET)continue;const n=await dt.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)}}}async newSingleProperty(t,e,i,o){const n=Mt.getIFCSchema(t),r=new b[n].IfcIdentifier(i),a=new b[n][e](o),l=new b[n].IfcPropertySingleValue(r,null,a,null);return l.expressID=this.increaseMaxID(t),await this.setData(t,l),l}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===b.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 dt.getPsetRel(t,e);if(!o)return;const n=await t.getProperties(o);if(n){for(const r of i){const a=new b.Handle(r);n.RelatedObjects.push(a),this.onElementToPset.trigger({model:t,psetID:e,elementID:r})}this.registerChange(t,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 b.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(Es),o=i.webIfc,n=await i.readIfcFile(e),r=this._changeMap[t.uuid]??[];for(const l of r){const E=await t.getProperties(l);if(E)try{o.WriteLine(n,E)}catch{}else try{o.DeleteLine(n,l)}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 l=new U;return Object.defineProperty(n[i],"value",{get(){return this._value},async set(E){this._value=E,l.trigger(E)}}),n[i].value=a,this.attributeListeners[t.uuid][e]||(this.attributeListeners[t.uuid][e]={}),this.attributeListeners[t.uuid][e][i]=l,l}};f(Mt,"uuid","58c2d9f0-183c-48d6-a402-dfcf5b9a34df");let ci=Mt;const Cs=class Cs extends st{constructor(t){super(t);f(this,"enabled",!0);f(this,"_groupSystems",{});f(this,"onDisposed",new U);f(this,"onFragmentsDisposed",t=>{const{groupID:e,fragmentIDs:i}=t;for(const o in this._groupSystems){const n=this._groupSystems[o],r=Object.keys(n);if(r.includes(e))delete n[e],Object.values(n).length===0&&delete this._groupSystems[o];else for(const a of r){const l=n[a];for(const E of i)delete l[E];Object.values(l).length===0&&delete n[a]}}});t.add(Cs.uuid,this),t.get(ut).onFragmentsDisposed.add(this.onFragmentsDisposed)}get(){return this._groupSystems}dispose(){this._groupSystems={},this.components.get(ut).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(),this.onDisposed.reset()}remove(t){for(const e in this._groupSystems){const i=this._groupSystems[e];for(const o in i){const n=i[o];delete n[t]}}}find(t){const e=this.components.get(ut);if(!t){const r={};for(const[a,l]of e.list)r[a]=new Set(l.ids);return r}const i=Object.keys(t).length,o={};for(const r in t){const a=t[r];if(!this._groupSystems[r]){console.warn(`Classification ${r} does not exist.`);continue}for(const l of a){const E=this._groupSystems[r][l];if(E)for(const I in E){o[I]||(o[I]=new Map);for(const h of E[I]){const d=o[I].get(h);d===void 0?o[I].set(h,1):o[I].set(h,d+1)}}}}const n={};for(const r in o){const a=o[r];for(const[l,E]of a){if(E===void 0)throw new Error("Malformed fragments map!");E===i&&(n[r]||(n[r]=new Set),n[r].add(l))}}return n}byModel(t,e){this._groupSystems.model||(this._groupSystems.model={});const i=this._groupSystems.model;i[t]||(i[t]={});const o=i[t];for(const[n,r]of e.data){const a=r[0];for(const l of a){const E=e.keyFragments.get(l);E&&(o[E]||(o[E]=new Set),o[E].add(n))}}}async byPredefinedType(t){var o;this._groupSystems.predefinedTypes||(this._groupSystems.predefinedTypes={});const e=this._groupSystems.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]={});const l=e[a];for(const[E,I]of t.data){const h=I[0];for(const d of h){const p=t.keyFragments.get(d);if(!p)throw new Error("Fragment ID not found!");l[p]||(l[p]=new Set),l[p].add(r.expressID)}}}}byEntity(t){this._groupSystems.entities||(this._groupSystems.entities={});for(const[e,i]of t.data){const n=i[1][1],r=fi[n];this.saveItem(t,"entities",r,e)}}byStorey(t){for(const[e,i]of t.data){const r=i[1][0].toString();this.saveItem(t,"storeys",r,e)}}async byIfcRel(t,e,i){dt.isRel(e)&&await dt.getRelationMap(t,e,async(o,n)=>{const{name:r}=await dt.getEntityName(t,o);for(const a of n)this.saveItem(t,i,r??"NO REL NAME",a)})}saveItem(t,e,i,o){this._groupSystems[e]||(this._groupSystems[e]={});const n=t.data.get(o);if(n)for(const r of n[0]){const a=t.keyFragments.get(r);if(a){const l=this._groupSystems[e];l[i]||(l[i]={}),l[i][a]||(l[i][a]=new Set),l[i][a].add(o)}}}};f(Cs,"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");let li=Cs;class gn extends Ci{constructor(){super(...arguments);f(this,"minGeometrySize",10);f(this,"minAssetsSize",1e3)}}class _n extends Ci{constructor(){super(...arguments);f(this,"propertiesSize",100)}}class Nn extends st{constructor(){super(...arguments);f(this,"onPropertiesStreamed",new U);f(this,"onProgress",new U);f(this,"onIndicesStreamed",new U);f(this,"onDisposed",new U);f(this,"enabled",!0);f(this,"settings",new _n);f(this,"webIfc",new b.IfcAPI)}async dispose(){this.onIndicesStreamed.reset(),this.onPropertiesStreamed.reset(),this.webIfc=null,this.onDisposed.reset()}async streamFromBuffer(t){const e=performance.now();await this.readIfcFile(t),await this.streamAllProperties(),this.cleanUp(),console.log(`Streaming the IFC took ${performance.now()-e} ms!`)}async streamFromCallBack(t){const e=performance.now();await this.streamIfcFile(t),await this.streamAllProperties(),this.cleanUp(),console.log(`Streaming the IFC took ${performance.now()-e} ms!`)}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=[b.IFCRELDEFINESBYPROPERTIES,b.IFCRELDEFINESBYTYPE,b.IFCRELASSOCIATESMATERIAL,b.IFCRELCONTAINEDINSPATIALSTRUCTURE,b.IFCRELASSOCIATESCLASSIFICATION,b.IFCRELASSIGNSTOGROUP],o=new Map,n=new Set([b.IFCPROJECT,b.IFCSITE,b.IFCBUILDING,b.IFCBUILDINGSTOREY,b.IFCSPACE]);for(const E of n)e.add(E);let r=.01,a=0;for(const E of e){if(a++,mn.has(E))continue;const I=n.has(E),h=this.webIfc.GetLineIDsWithType(0,E),d=h.size();let p=0;for(let A=0;A<d-t;A+=t){const T={};for(let m=0;m<t;m++){p++;const O=h.get(A+m);try{const u=this.webIfc.GetLine(0,O,I);i.includes(E)&&this.getIndices(u,O,o),T[u.expressID]=u}catch{console.log(`Could not get property: ${O}`)}}await this.onPropertiesStreamed.trigger({type:E,data:T})}if(p!==d){const A={};for(let T=p;T<d;T++){const m=h.get(T);try{const O=this.webIfc.GetLine(0,m,I);i.includes(E)&&this.getIndices(O,m,o),A[O.expressID]=O}catch{console.log(`Could not get property: ${m}`)}}await this.onPropertiesStreamed.trigger({type:E,data:A})}const F=a/e.size;F>r&&(r+=.01,r=Math.max(r,F),await this.onProgress.trigger(Math.round(r*100)/100))}const l=[];for(const[E,I]of o)l.push([E,...I]);await this.onIndicesStreamed.trigger(l)}getIndices(t,e,i){const o=t.RelatedObjects||t.RelatedElements;if(!o){console.log(`Related objects not found: ${e}`);return}const n=t.RelatingType||t.RelatingMaterial||t.RelatingStructure||t.RelatingPropertyDefinition||t.RelatingGroup||t.RelatingClassification;if(!n){console.log(`Relating object not found: ${e}`);return}if(!Array.isArray(o)||n.value===void 0)return;const r=n.value;for(const a of o){if(a.value===void 0||a.value===null)continue;const l=a.value;i.has(l)||i.set(l,new Set),i.get(l).add(r)}}cleanUp(){this.webIfc=null,this.webIfc=new b.IfcAPI}}f(Nn,"uuid","88d2c89c-ce32-47d7-8cb6-d51e4b311a0b");const ps=class ps extends st{constructor(t){super(t);f(this,"onGeometryStreamed",new U);f(this,"onAssetStreamed",new U);f(this,"onProgress",new U);f(this,"onIfcLoaded",new U);f(this,"onDisposed",new U);f(this,"settings",new gn);f(this,"enabled",!0);f(this,"webIfc",new b.IfcAPI);f(this,"_spatialTree",new An);f(this,"_metaData",new Sn);f(this,"_visitedGeometries",new Map);f(this,"_streamSerializer",new Ht.StreamSerializer);f(this,"_geometries",new Map);f(this,"_geometryCount",0);f(this,"_civil",new On);f(this,"_groupSerializer",new Ht.Serializer);f(this,"_assets",[]);f(this,"_meshesWithHoles",new Set);this.components.add(ps.uuid,this),this.settings.excludedCategories.add(b.IFCOPENINGELEMENT)}dispose(){this.onIfcLoaded.reset(),this.onGeometryStreamed.reset(),this.onAssetStreamed.reset(),this.webIfc=null,this.onDisposed.trigger(),this.onDisposed.reset()}async streamFromBuffer(t){const e=performance.now();await this.readIfcFile(t),await this.streamAllGeometries(),this.cleanUp(),console.log(`Streaming the IFC took ${performance.now()-e} ms!`)}async streamFromCallBack(t){const e=performance.now();await this.streamIfcFile(t),await this.streamAllGeometries(),this.cleanUp(),console.log(`Streaming the IFC took ${performance.now()-e} ms!`)}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 Ht.FragmentsGroup,{FILE_NAME:r,FILE_DESCRIPTION:a}=b;n.ifcMetadata={name:this._metaData.get(this.webIfc,r),description:this._metaData.get(this.webIfc,a),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};let l=0,E=0;for(const m of i){if(!this.webIfc.IsIfcElement(m)&&m!==b.IFCSPACE||this.settings.excludedCategories.has(m))continue;const O=this.webIfc.GetLineIDsWithType(0,m),u=O.size();for(let R=0;R<u;R++){l>t&&(l=0,E++,o.push([]));const S=O.get(R);o[E].push(S);const g=this._spatialTree.itemsByFloor[S]||0;n.data.set(S,[[],[g,m]]),l++}}this._spatialTree.cleanUp();let I=.01,h=0;for(const m of o){h++,this.webIfc.StreamMeshes(0,m,u=>{this.getMesh(this.webIfc,u,n)}),this._geometryCount>t&&await this.streamGeometries(),this._assets.length>e&&await this.streamAssets();const O=h/o.length;O>I&&(I+=.01,I=Math.max(I,O),this.onProgress.trigger(Math.round(I*100)/100))}this._geometryCount&&await this.streamGeometries(),this._assets.length&&await this.streamAssets();const{opaque:d,transparent:p}=n.geometryIDs;for(const[m,{index:O,uuid:u}]of this._visitedGeometries)n.keyFragments.set(O,u),(m>1?d:p).set(m,O);const F=n.data.keys();for(const m of F){const[O]=n.data.get(m);O.length||n.data.delete(m)}const A=this.webIfc.GetCoordinationMatrix(0);n.coordinationMatrix.fromArray(A),n.civilData=this._civil.read(this.webIfc);const T=this._groupSerializer.export(n);this.onIfcLoaded.trigger(T),n.dispose(!0)}cleanUp(){this.webIfc=null,this.webIfc=new b.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:[]};e.expressID===664833&&console.log("Heyyy");for(let a=0;a<o;a++){const l=e.geometries.get(a),E=l.geometryExpressID,I=l.color.w===1?1:-1,h=E*I;if(!this._visitedGeometries.has(h)){this._visitedGeometries.has(E)||this.getGeometry(t,E);const R=this._visitedGeometries.size,S=L.MathUtils.generateUUID();this._visitedGeometries.set(h,{uuid:S,index:R})}const d=this._visitedGeometries.get(h);if(d===void 0)throw new Error("Error getting geometry data for streaming!");const p=i.data.get(n);if(!p)throw new Error("Data not found!");p[0].push(d.index);const{x:F,y:A,z:T,w:m}=l.color,O=[F,A,T,m],u=l.flatTransformation;r.geometries.push({color:O,geometryID:E,transformation:u})}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 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 l=hn(r),E=new Float32Array(l.transformation.elements),I=[l.center.x,l.center.y,l.center.z];let h=!1;for(let d=0;d<r.length-2;d+=3){const p=r[d],F=r[d+1],A=r[d+2],T=a[d],m=a[d+1],O=a[d+2];if(En(I,[p,F,A],[T,m,O])){h=!0;break}}this._geometries.set(e,{position:r,normal:a,index:o,boundingBox:E,hasHoles:h}),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}};f(ps,"uuid","d9999a00-e1f5-4d3f-8cfe-c56e08609764");let hi=ps;exports.Base=Rs;exports.BaseCamera=an;exports.BaseRenderer=cn;exports.BaseScene=ln;exports.BaseWorldItem=Fs;exports.Clipper=ii;exports.Component=st;exports.Components=ls;exports.CullerRenderer=pn;exports.Cullers=oi;exports.Disposer=_t;exports.Event=U;exports.FragmentBoundingBox=ri;exports.FragmentClassifier=li;exports.FragmentIfcLoader=Es;exports.FragmentIfcStreamConverter=hi;exports.FragmentManager=ut;exports.FragmentPropsStreamConverter=Nn;exports.Grids=fn;exports.IfcCategories=Ir;exports.IfcCategoryMap=fi;exports.IfcElements=Fn;exports.IfcJsonExporter=Rn;exports.IfcPropertiesFinder=dr;exports.IfcPropertiesIndexer=ai;exports.IfcPropertiesManager=ci;exports.IfcPropertiesUtils=dt;exports.IfcStreamingSettings=gn;exports.Materials=ni;exports.MaterialsUtils=si;exports.MeshCullerRenderer=Tn;exports.PropertiesStreamingSettings=_n;exports.Raycasters=Me;exports.SimpleCamera=De;exports.SimplePlane=As;exports.SimpleRenderer=jo;exports.SimpleScene=qo;exports.SimpleWorld=In;exports.UUID=oe;exports.Worlds=hs;exports.isPointInFrontOfPlane=En;exports.obbFromPoints=hn;exports.readPixelsAsync=Cn;