light-and-ao-map
Version:
A package for light and AO map functionality
1 lines • 782 kB
JavaScript
import*as e from"three";import{BufferAttribute as t,Vector3 as n,Vector2 as r,Plane as i,Line3 as s,Triangle as a,Sphere as o,Matrix4 as l,Box3 as c,REVISION as h,BackSide as d,DoubleSide as p,FrontSide as u,Mesh as g,BatchedMesh as m,Ray as f,DataTextureLoader as y,HalfFloatType as b,FloatType as w,DataUtils as v,LinearSRGBColorSpace as x,LinearFilter as S,RGBAFormat as C,RedFormat as M,NoColorSpace as _}from"three";import{TransformControls as k}from"three/examples/jsm/controls/TransformControls.js";import{GUI as E}from"lil-gui";import{ViewHelper as T}from"three/examples/jsm/helpers/ViewHelper";import D from"stream";import A from"events";import L from"buffer";import H from"util";const P=1.25,N=65535,z=Math.pow(2,-24),I=Symbol("SKIP_GENERATION");function O(e){return function(e){return e.index?e.index.count:e.attributes.position.count}(e)/3}function B(e,n){if(!e.index){const r=e.attributes.position.count,i=function(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}(r,n.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new t(i,1));for(let e=0;e<r;e++)i[e]=e}}function R(e,t){const n=O(e),r=t||e.drawRange,i=r.start/3,s=(r.start+r.count)/3,a=Math.max(0,i),o=Math.min(n,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function F(e,t){if(!e.groups||!e.groups.length)return R(e,t);const n=[],r=new Set,i=t||e.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const t of e.groups){const e=t.start/3,n=(t.start+t.count)/3;r.add(Math.max(s,e)),r.add(Math.min(a,n))}const o=Array.from(r.values()).sort(((e,t)=>e-t));for(let e=0;e<o.length-1;e++){const t=o[e],r=o[e+1];n.push({offset:Math.floor(t),count:Math.floor(r-t)})}return n}function j(e,t,n,r,i){let s=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,h=-1/0,d=1/0,p=1/0,u=1/0,g=-1/0,m=-1/0,f=-1/0;for(let r=6*t,i=6*(t+n);r<i;r+=6){const t=e[r+0],n=e[r+1],i=t-n,y=t+n;i<s&&(s=i),y>l&&(l=y),t<d&&(d=t),t>g&&(g=t);const b=e[r+2],w=e[r+3],v=b-w,x=b+w;v<a&&(a=v),x>c&&(c=x),b<p&&(p=b),b>m&&(m=b);const S=e[r+4],C=e[r+5],M=S-C,_=S+C;M<o&&(o=M),_>h&&(h=_),S<u&&(u=S),S>f&&(f=S)}r[0]=s,r[1]=a,r[2]=o,r[3]=l,r[4]=c,r[5]=h,i[0]=d,i[1]=p,i[2]=u,i[3]=g,i[4]=m,i[5]=f}function U(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function $(e){let t=-1,n=-1/0;for(let r=0;r<3;r++){const i=e[r+3]-e[r];i>n&&(n=i,t=r)}return t}function G(e,t){t.set(e)}function V(e,t,n){let r,i;for(let s=0;s<3;s++){const a=s+3;r=e[s],i=t[s],n[s]=r<i?r:i,r=e[a],i=t[a],n[a]=r>i?r:i}}function q(e,t,n){for(let r=0;r<3;r++){const i=t[e+2*r],s=t[e+2*r+1],a=i-s,o=i+s;a<n[r]&&(n[r]=a),o>n[r+3]&&(n[r+3]=o)}}function W(e){const t=e[3]-e[0],n=e[4]-e[1],r=e[5]-e[2];return 2*(t*n+n*r+r*t)}const Y=32,X=(e,t)=>e.candidate-t.candidate,Z=new Array(Y).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),K=new Float32Array(6);class J{constructor(){this.boundingData=new Float32Array(6)}}function Q(e,t,n,r,i,s){let a=r,o=r+i-1;const l=s.pos,c=2*s.axis;for(;;){for(;a<=o&&n[6*a+c]<l;)a++;for(;a<=o&&n[6*o+c]>=l;)o--;if(!(a<o))return a;for(let e=0;e<3;e++){let n=t[3*a+e];t[3*a+e]=t[3*o+e],t[3*o+e]=n}for(let e=0;e<6;e++){let t=n[6*a+e];n[6*a+e]=n[6*o+e],n[6*o+e]=t}a++,o--}}function ee(e,t,n,r,i,s){let a=r,o=r+i-1;const l=s.pos,c=2*s.axis;for(;;){for(;a<=o&&n[6*a+c]<l;)a++;for(;a<=o&&n[6*o+c]>=l;)o--;if(!(a<o))return a;{let t=e[a];e[a]=e[o],e[o]=t;for(let e=0;e<6;e++){let t=n[6*a+e];n[6*a+e]=n[6*o+e],n[6*o+e]=t}a++,o--}}}function te(e,t){return 65535===t[e+15]}function ne(e,t){return t[e+6]}function re(e,t){return t[e+14]}function ie(e){return e+8}function se(e,t){return t[e+6]}function ae(e,t){return t[e+7]}let oe,le,ce,he;const de=Math.pow(2,32);function pe(e){return"count"in e?1:1+pe(e.left)+pe(e.right)}function ue(e,t,n){return oe=new Float32Array(n),le=new Uint32Array(n),ce=new Uint16Array(n),he=new Uint8Array(n),ge(e,t)}function ge(e,t){const n=e/4,r=e/2,i="count"in t,s=t.boundingData;for(let e=0;e<6;e++)oe[n+e]=s[e];if(i){if(t.buffer){const r=t.buffer;he.set(new Uint8Array(r),e);for(let t=e,i=e+r.byteLength;t<i;t+=32){te(t/2,ce)||(le[t/4+6]+=n)}return e+r.byteLength}{const i=t.offset,s=t.count;return le[n+6]=i,ce[r+14]=s,ce[r+15]=N,e+32}}{const r=t.left,i=t.right,s=t.splitAxis;let a;if(a=ge(e+32,r),a/4>de)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return le[n+6]=a/4,a=ge(a,i),le[n+7]=s,a}}function me(e,t,n,r,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:l,onProgress:c,indirect:h}=i,d=e._indirectBuffer,p=e.geometry,u=p.index?p.index.array:null,g=h?ee:Q,m=O(p),f=new Float32Array(6);let y=!1;const b=new J;return j(t,n,r,b.boundingData,f),function e(n,r,i,c=null,h=0){!y&&h>=s&&(y=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(p)));if(i<=o||h>=s)return w(r+i),n.offset=r,n.count=i,n;const m=function(e,t,n,r,i,s){let a=-1,o=0;if(0===s)a=$(t),-1!==a&&(o=(t[a]+t[a+3])/2);else if(1===s)a=$(e),-1!==a&&(o=function(e,t,n,r){let i=0;for(let s=t,a=t+n;s<a;s++)i+=e[6*s+2*r];return i/n}(n,r,i,a));else if(2===s){const s=W(e);let l=P*i;const c=6*r,h=6*(r+i);for(let e=0;e<3;e++){const r=t[e],d=(t[e+3]-r)/Y;if(i<8){const t=[...Z];t.length=i;let r=0;for(let i=c;i<h;i+=6,r++){const s=t[r];s.candidate=n[i+2*e],s.count=0;const{bounds:a,leftCacheBounds:o,rightCacheBounds:l}=s;for(let e=0;e<3;e++)l[e]=1/0,l[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0;q(i,n,a)}t.sort(X);let d=i;for(let e=0;e<d;e++){const n=t[e];for(;e+1<d&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),d--}for(let r=c;r<h;r+=6){const i=n[r+2*e];for(let e=0;e<d;e++){const s=t[e];i>=s.candidate?q(r,n,s.rightCacheBounds):(q(r,n,s.leftCacheBounds),s.count++)}}for(let n=0;n<d;n++){const r=t[n],c=r.count,h=i-r.count,d=r.leftCacheBounds,p=r.rightCacheBounds;let u=0;0!==c&&(u=W(d)/s);let g=0;0!==h&&(g=W(p)/s);const m=1+P*(u*c+g*h);m<l&&(a=e,l=m,o=r.candidate)}}else{for(let e=0;e<Y;e++){const t=Z[e];t.count=0,t.candidate=r+d+e*d;const n=t.bounds;for(let e=0;e<3;e++)n[e]=1/0,n[e+3]=-1/0}for(let t=c;t<h;t+=6){let i=~~((n[t+2*e]-r)/d);i>=Y&&(i=31);const s=Z[i];s.count++,q(t,n,s.bounds)}const t=Z[31];G(t.bounds,t.rightCacheBounds);for(let e=30;e>=0;e--){const t=Z[e],n=Z[e+1];V(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let p=0;for(let t=0;t<31;t++){const n=Z[t],r=n.count,c=n.bounds,h=Z[t+1].rightCacheBounds;0!==r&&(0===p?G(c,K):V(c,K,K)),p+=r;let d=0,u=0;0!==p&&(d=W(K)/s);const g=i-p;0!==g&&(u=W(h)/s);const m=1+P*(d*p+u*g);m<l&&(a=e,l=m,o=n.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}(n.boundingData,c,t,r,i,l);if(-1===m.axis)return w(r+i),n.offset=r,n.count=i,n;const b=g(d,u,t,r,i,m);if(b===r||b===r+i)w(r+i),n.offset=r,n.count=i;else{n.splitAxis=m.axis;const s=new J,a=r,o=b-r;n.left=s,j(t,a,o,s.boundingData,f),e(s,a,o,f,h+1);const l=new J,c=b,d=i-o;n.right=l,j(t,c,d,l.boundingData,f),e(l,c,d,f,h+1)}return n}(b,n,r,f),b;function w(e){c&&c(e/m)}}function fe(e,t){const n=e.geometry;t.indirect&&(e._indirectBuffer=function(e,t){const n=(e.index?e.index.count:e.attributes.position.count)/3,r=n>65536,i=r?4:2,s=t?new SharedArrayBuffer(n*i):new ArrayBuffer(n*i),a=r?new Uint32Array(s):new Uint16Array(s);for(let e=0,t=a.length;e<t;e++)a[e]=e;return a}(n,t.useSharedArrayBuffer),function(e,t){const n=O(e),r=F(e,t).sort(((e,t)=>e.offset-t.offset)),i=r[r.length-1];i.count=Math.min(n-i.offset,i.count);let s=0;return r.forEach((({count:e})=>s+=e)),n!==s}(n,t.range)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),e._indirectBuffer||B(n,t);const r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=function(e,t=null,n=null,r=null){const i=e.attributes.position,s=e.index?e.index.array:null,a=O(e),o=i.normalized;let l;null===t?(l=new Float32Array(6*a),n=0,r=a):(l=t,n=n||0,r=r||a);const c=i.array,h=i.offset||0;let d=3;i.isInterleavedBufferAttribute&&(d=i.data.stride);const p=["getX","getY","getZ"];for(let e=n;e<n+r;e++){const t=3*e,n=6*e;let r=t+0,a=t+1,u=t+2;s&&(r=s[r],a=s[a],u=s[u]),o||(r=r*d+h,a=a*d+h,u=u*d+h);for(let e=0;e<3;e++){let t,s,h;o?(t=i[p[e]](r),s=i[p[e]](a),h=i[p[e]](u)):(t=c[r+e],s=c[a+e],h=c[u+e]);let d=t;s<d&&(d=s),h<d&&(d=h);let g=t;s>g&&(g=s),h>g&&(g=h);const m=(g-d)/2,f=2*e;l[n+f+0]=d+m,l[n+f+1]=m+(Math.abs(d)+m)*z}}return l}(n),s=t.indirect?R(n,t.range):F(n,t.range);e._roots=s.map((n=>{const s=me(e,i,n.offset,n.count,t),a=pe(s),o=new r(32*a);return ue(0,s,o),o}))}class ye{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,r=-1/0;for(let i=0,s=e.length;i<s;i++){const s=e[i][t];n=s<n?s:n,r=s>r?s:r}this.min=n,this.max=r}setFromPoints(e,t){let n=1/0,r=-1/0;for(let i=0,s=t.length;i<s;i++){const s=t[i],a=e.dot(s);n=a<n?a:n,r=a>r?a:r}this.min=n,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}}ye.prototype.setFromBox=function(){const e=new n;return function(t,n){const r=n.min,i=n.max;let s=1/0,a=-1/0;for(let n=0;n<=1;n++)for(let o=0;o<=1;o++)for(let l=0;l<=1;l++){e.x=r.x*n+i.x*(1-n),e.y=r.y*o+i.y*(1-o),e.z=r.z*l+i.z*(1-l);const c=t.dot(e);s=Math.min(c,s),a=Math.max(c,a)}this.min=s,this.max=a}}(),function(){const e=new ye}();const be=function(){const e=new n,t=new n,r=new n;return function(n,i,s){const a=n.start,o=e,l=i.start,c=t;r.subVectors(a,l),e.subVectors(n.end,n.start),t.subVectors(i.end,i.start);const h=r.dot(c),d=c.dot(o),p=c.dot(c),u=r.dot(o),g=o.dot(o)*p-d*d;let m,f;m=0!==g?(h*d-u*p)/g:0,f=(h+m*d)/p,s.x=m,s.y=f}}(),we=function(){const e=new r,t=new n,i=new n;return function(n,r,s,a){be(n,r,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1)return n.at(o,s),void r.at(l,a);if(o>=0&&o<=1)return l<0?r.at(0,a):r.at(1,a),void n.closestPointToPoint(a,!0,s);if(l>=0&&l<=1)return o<0?n.at(0,s):n.at(1,s),void r.closestPointToPoint(s,!0,a);{let e,c;e=o<0?n.start:n.end,c=l<0?r.start:r.end;const h=t,d=i;return n.closestPointToPoint(c,!0,t),r.closestPointToPoint(e,!0,i),h.distanceToSquared(c)<=d.distanceToSquared(e)?(s.copy(h),void a.copy(c)):(s.copy(e),void a.copy(d))}}}(),ve=function(){const e=new n,t=new n,r=new i,a=new s;return function(n,i){const{radius:s,center:o}=n,{a:l,b:c,c:h}=i;a.start=l,a.end=c;if(a.closestPointToPoint(o,!0,e).distanceTo(o)<=s)return!0;a.start=l,a.end=h;if(a.closestPointToPoint(o,!0,e).distanceTo(o)<=s)return!0;a.start=c,a.end=h;if(a.closestPointToPoint(o,!0,e).distanceTo(o)<=s)return!0;const d=i.getPlane(r);if(Math.abs(d.distanceToPoint(o))<=s){const e=d.projectPoint(o,t);if(i.containsPoint(e))return!0}return!1}}();function xe(e){return Math.abs(e)<1e-15}class Se extends a{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new n)),this.satBounds=new Array(4).fill().map((()=>new ye)),this.points=[this.a,this.b,this.c],this.sphere=new o,this.plane=new i,this.needsUpdate=!0}intersectsSphere(e){return ve(e,this)}update(){const e=this.a,t=this.b,n=this.c,r=this.points,i=this.satAxes,s=this.satBounds,a=i[0],o=s[0];this.getNormal(a),o.setFromPoints(a,r);const l=i[1],c=s[1];l.subVectors(e,t),c.setFromPoints(l,r);const h=i[2],d=s[2];h.subVectors(t,n),d.setFromPoints(h,r);const p=i[3],u=s[3];p.subVectors(n,e),u.setFromPoints(p,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Se.prototype.closestPointToSegment=function(){const e=new n,t=new n,r=new s;return function(n,i=null,s=null){const{start:a,end:o}=n,l=this.points;let c,h=1/0;for(let a=0;a<3;a++){const o=(a+1)%3;r.start.copy(l[a]),r.end.copy(l[o]),we(r,n,e,t),c=e.distanceToSquared(t),c<h&&(h=c,i&&i.copy(e),s&&s.copy(t))}return this.closestPointToPoint(a,e),c=a.distanceToSquared(e),c<h&&(h=c,i&&i.copy(e),s&&s.copy(a)),this.closestPointToPoint(o,e),c=o.distanceToSquared(e),c<h&&(h=c,i&&i.copy(e),s&&s.copy(o)),Math.sqrt(h)}}(),Se.prototype.intersectsTriangle=function(){const e=new Se,t=new Array(3),r=new Array(3),i=new ye,a=new ye,o=new n,l=new n,c=new n,h=new n,d=new n,p=new s,u=new s,g=new s,m=new n;function f(e,t,n){const r=e.points;let i=0,s=-1;for(let e=0;e<3;e++){const{start:a,end:o}=p;a.copy(r[e]),o.copy(r[(e+1)%3]),p.delta(l);const c=xe(t.distanceToPoint(a));if(xe(t.normal.dot(l))&&c){n.copy(p),i=2;break}const h=t.intersectLine(p,m);if(!h&&c&&m.copy(a),(h||c)&&!xe(m.distanceTo(o))){if(i<=1){(1===i?n.start:n.end).copy(m),c&&(s=i)}else if(i>=2){(1===s?n.start:n.end).copy(m),i=2;break}if(i++,2===i&&-1===s)break}}return i}return function(n,s=null,l=!1){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);const p=this.plane,m=n.plane;if(Math.abs(p.normal.dot(m.normal))>1-1e-10){const e=this.satBounds,c=this.satAxes;r[0]=n.a,r[1]=n.b,r[2]=n.c;for(let t=0;t<4;t++){const n=e[t],s=c[t];if(i.setFromPoints(s,r),n.isSeparated(i))return!1}const h=n.satBounds,d=n.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let e=0;e<4;e++){const n=h[e],r=d[e];if(i.setFromPoints(r,t),n.isSeparated(i))return!1}for(let e=0;e<4;e++){const n=c[e];for(let e=0;e<4;e++){const s=d[e];if(o.crossVectors(n,s),i.setFromPoints(o,t),a.setFromPoints(o,r),i.isSeparated(a))return!1}}return s&&(l||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),s.start.set(0,0,0),s.end.set(0,0,0)),!0}{const e=f(this,m,u);if(1===e&&n.containsPoint(u.end))return s&&(s.start.copy(u.end),s.end.copy(u.end)),!0;if(2!==e)return!1;const t=f(n,p,g);if(1===t&&this.containsPoint(g.end))return s&&(s.start.copy(g.end),s.end.copy(g.end)),!0;if(2!==t)return!1;if(u.delta(c),g.delta(h),c.dot(h)<0){let e=g.start;g.start=g.end,g.end=e}const r=u.start.dot(c),i=u.end.dot(c),a=g.start.dot(c),o=g.end.dot(c);return(r===o||a===i||i<a!==r<o)&&(s&&(d.subVectors(u.start,g.start),d.dot(c)>0?s.start.copy(u.start):s.start.copy(g.start),d.subVectors(u.end,g.end),d.dot(c)<0?s.end.copy(u.end):s.end.copy(g.end)),!0)}}}(),Se.prototype.distanceToPoint=function(){const e=new n;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Se.prototype.distanceToTriangle=function(){const e=new n,t=new n,r=["a","b","c"],i=new s,a=new s;return function(n,s=null,o=null){const l=s||o?i:null;if(this.intersectsTriangle(n,l))return(s||o)&&(s&&l.getCenter(s),o&&l.getCenter(o)),0;let c=1/0;for(let t=0;t<3;t++){let i;const a=r[t],l=n[a];this.closestPointToPoint(l,e),i=l.distanceToSquared(e),i<c&&(c=i,s&&s.copy(e),o&&o.copy(l));const h=this[a];n.closestPointToPoint(h,e),i=h.distanceToSquared(e),i<c&&(c=i,s&&s.copy(h),o&&o.copy(e))}for(let l=0;l<3;l++){const h=r[l],d=r[(l+1)%3];i.set(this[h],this[d]);for(let l=0;l<3;l++){const h=r[l],d=r[(l+1)%3];a.set(n[h],n[d]),we(i,a,e,t);const p=e.distanceToSquared(t);p<c&&(c=p,s&&s.copy(e),o&&o.copy(t))}}return Math.sqrt(c)}}();class Ce{constructor(e,t,r){this.isOrientedBox=!0,this.min=new n,this.max=new n,this.matrix=new l,this.invMatrix=new l,this.points=new Array(8).fill().map((()=>new n)),this.satAxes=new Array(3).fill().map((()=>new n)),this.satBounds=new Array(3).fill().map((()=>new ye)),this.alignedSatBounds=new Array(3).fill().map((()=>new ye)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),r&&this.matrix.copy(r)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ce.prototype.update=function(){const e=this.matrix,t=this.min,n=this.max,r=this.points;for(let i=0;i<=1;i++)for(let s=0;s<=1;s++)for(let a=0;a<=1;a++){const o=r[1*i|2*s|4*a];o.x=i?n.x:t.x,o.y=s?n.y:t.y,o.z=a?n.z:t.z,o.applyMatrix4(e)}const i=this.satBounds,s=this.satAxes,a=r[0];for(let e=0;e<3;e++){const t=s[e],n=i[e],o=r[1<<e];t.subVectors(a,o),n.setFromPoints(t,r)}const o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},Ce.prototype.intersectsBox=function(){const e=new ye;return function(t){this.needsUpdate&&this.update();const n=t.min,r=t.max,i=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(e.min=n.x,e.max=r.x,a[0].isSeparated(e))return!1;if(e.min=n.y,e.max=r.y,a[1].isSeparated(e))return!1;if(e.min=n.z,e.max=r.z,a[2].isSeparated(e))return!1;for(let n=0;n<3;n++){const r=s[n],a=i[n];if(e.setFromBox(r,t),a.isSeparated(e))return!1}return!0}}(),Ce.prototype.intersectsTriangle=function(){const e=new Se,t=new Array(3),r=new ye,i=new ye,s=new n;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);const a=this.satBounds,o=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let e=0;e<3;e++){const n=a[e],i=o[e];if(r.setFromPoints(i,t),n.isSeparated(r))return!1}const l=n.satBounds,c=n.satAxes,h=this.points;for(let e=0;e<3;e++){const t=l[e],n=c[e];if(r.setFromPoints(n,h),t.isSeparated(r))return!1}for(let e=0;e<3;e++){const n=o[e];for(let e=0;e<4;e++){const a=c[e];if(s.crossVectors(n,a),r.setFromPoints(s,t),i.setFromPoints(s,h),r.isSeparated(i))return!1}}return!0}}(),Ce.prototype.closestPointToPoint=function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},Ce.prototype.distanceToPoint=function(){const e=new n;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Ce.prototype.distanceToBox=function(){const e=["x","y","z"],t=new Array(12).fill().map((()=>new s)),r=new Array(12).fill().map((()=>new s)),i=new n,a=new n;return function(n,s=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(o||l)&&(n.getCenter(a),this.closestPointToPoint(a,i),n.closestPointToPoint(i,a),o&&o.copy(i),l&&l.copy(a)),0;const c=s*s,h=n.min,d=n.max,p=this.points;let u=1/0;for(let e=0;e<8;e++){const t=p[e];a.copy(t).clamp(h,d);const n=t.distanceToSquared(a);if(n<u&&(u=n,o&&o.copy(t),l&&l.copy(a),n<c))return Math.sqrt(n)}let g=0;for(let n=0;n<3;n++)for(let i=0;i<=1;i++)for(let s=0;s<=1;s++){const a=(n+1)%3,o=(n+2)%3,l=1<<n|i<<a|s<<o,c=p[i<<a|s<<o],u=p[l];t[g].set(c,u);const m=e[n],f=e[a],y=e[o],b=r[g],w=b.start,v=b.end;w[m]=h[m],w[f]=i?h[f]:d[f],w[y]=s?h[y]:d[f],v[m]=d[m],v[f]=i?h[f]:d[f],v[y]=s?h[y]:d[f],g++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){a.x=e?d.x:h.x,a.y=t?d.y:h.y,a.z=n?d.z:h.z,this.closestPointToPoint(a,i);const r=a.distanceToSquared(i);if(r<u&&(u=r,o&&o.copy(i),l&&l.copy(a),r<c))return Math.sqrt(r)}for(let e=0;e<12;e++){const n=t[e];for(let e=0;e<12;e++){const t=r[e];we(n,t,i,a);const s=i.distanceToSquared(a);if(s<u&&(u=s,o&&o.copy(i),l&&l.copy(a),s<c))return Math.sqrt(s)}}return Math.sqrt(u)}}();class Me{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class _e extends Me{constructor(){super((()=>new Se))}}const ke=new _e;const Ee=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==e.length&&this.setBuffer(e.pop())}}};let Te,De;const Ae=[],Le=new Me((()=>new c));function He(e,t,n,r,i,s){Te=Le.getPrimitive(),De=Le.getPrimitive(),Ae.push(Te,De),Ee.setBuffer(e._roots[t]);const a=Pe(0,e.geometry,n,r,i,s);Ee.clearBuffer(),Le.releasePrimitive(Te),Le.releasePrimitive(De),Ae.pop(),Ae.pop();const o=Ae.length;return o>0&&(De=Ae[o-1],Te=Ae[o-2]),a}function Pe(e,t,n,r,i=null,s=0,a=0){const{float32Array:o,uint16Array:l,uint32Array:c}=Ee;let h=2*e;if(te(h,l)){const d=ne(e,c),p=re(h,l);return U(e,o,Te),r(d,p,!1,a,s+e,Te)}{const u=ie(e),g=se(e,c);let m,f,y,b,w=u,v=g;if(i&&(y=Te,b=De,U(w,o,y),U(v,o,b),m=i(y),f=i(b),f<m)){w=g,v=u;const E=m;m=f,f=E,y=b}y||(y=Te,U(w,o,y));const x=n(y,te(2*w,l),m,a+1,s+w);let S;if(2===x){const T=_(w);S=r(T,k(w)-T,!0,a+1,s+w,y)}else S=x&&Pe(w,t,n,r,i,s,a+1);if(S)return!0;b=De,U(v,o,b);const C=n(b,te(2*v,l),f,a+1,s+v);let M;if(2===C){const D=_(v);M=r(D,k(v)-D,!0,a+1,s+v,b)}else M=C&&Pe(v,t,n,r,i,s,a+1);return!!M;function _(e){const{uint16Array:t,uint32Array:n}=Ee;let r=2*e;for(;!te(r,t);)r=2*(e=ie(e));return ne(e,n)}function k(e){const{uint16Array:t,uint32Array:n}=Ee;let r=2*e;for(;!te(r,t);)r=2*(e=se(e,n));return ne(e,n)+re(r,t)}}}const Ne=new n,ze=new n;const Ie=parseInt(h)>=169,Oe=new n,Be=new n,Re=new n,Fe=new r,je=new r,Ue=new r,$e=new n,Ge=new n,Ve=new n,qe=new n;function We(e,t,i,s,o,l,c,h,u,g,m){Oe.fromBufferAttribute(t,l),Be.fromBufferAttribute(t,c),Re.fromBufferAttribute(t,h);const f=function(e,t,n,r,i,s,a,o){let l;if(l=s===d?e.intersectTriangle(r,n,t,!0,i):e.intersectTriangle(t,n,r,s!==p,i),null===l)return null;const c=e.origin.distanceTo(i);return c<a||c>o?null:{distance:c,point:i.clone()}}(e,Oe,Be,Re,qe,u,g,m);if(f){const t=new n;a.getBarycoord(qe,Oe,Be,Re,t),s&&(Fe.fromBufferAttribute(s,l),je.fromBufferAttribute(s,c),Ue.fromBufferAttribute(s,h),f.uv=a.getInterpolation(qe,Oe,Be,Re,Fe,je,Ue,new r)),o&&(Fe.fromBufferAttribute(o,l),je.fromBufferAttribute(o,c),Ue.fromBufferAttribute(o,h),f.uv1=a.getInterpolation(qe,Oe,Be,Re,Fe,je,Ue,new r)),i&&($e.fromBufferAttribute(i,l),Ge.fromBufferAttribute(i,c),Ve.fromBufferAttribute(i,h),f.normal=a.getInterpolation(qe,Oe,Be,Re,$e,Ge,Ve,new n),f.normal.dot(e.direction)>0&&f.normal.multiplyScalar(-1));const d={a:l,b:c,c:h,normal:new n,materialIndex:0};a.getNormal(Oe,Be,Re,d.normal),f.face=d,f.faceIndex=l,Ie&&(f.barycoord=t)}return f}function Ye(e,t,n,r,i,s,a){const o=3*r;let l=o+0,c=o+1,h=o+2;const d=e.index;e.index&&(l=d.getX(l),c=d.getX(c),h=d.getX(h));const{position:p,normal:u,uv:g,uv1:m}=e.attributes,f=We(n,p,u,g,m,l,c,h,t,s,a);return f?(f.faceIndex=r,i&&i.push(f),f):null}function Xe(e,t,n,r){const i=e.a,s=e.b,a=e.c;let o=t,l=t+1,c=t+2;n&&(o=n.getX(o),l=n.getX(l),c=n.getX(c)),i.x=r.getX(o),i.y=r.getY(o),i.z=r.getZ(o),s.x=r.getX(l),s.y=r.getY(l),s.z=r.getZ(l),a.x=r.getX(c),a.y=r.getY(c),a.z=r.getZ(c)}function Ze(e,t,n,r,i,s,a){const{geometry:o}=n,{index:l}=o,c=o.attributes.position;for(let n=e,o=t+e;n<o;n++){let e;if(e=n,Xe(a,3*e,l,c),a.needsUpdate=!0,r(a,e,i,s))return!0}return!1}function Ke(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const n=e.geometry,r=n.index?n.index.array:null,i=n.attributes.position;let s,a,o,l,c=0;const h=e._roots;for(let e=0,t=h.length;e<t;e++)s=h[e],a=new Uint32Array(s),o=new Uint16Array(s),l=new Float32Array(s),d(0,c),c+=s.byteLength;function d(e,n,s=!1){const c=2*e;if(o[c+15]===N){const t=a[e+6];let n=1/0,s=1/0,h=1/0,d=-1/0,p=-1/0,u=-1/0;for(let e=3*t,a=3*(t+o[c+14]);e<a;e++){let t=r[e];const a=i.getX(t),o=i.getY(t),l=i.getZ(t);a<n&&(n=a),a>d&&(d=a),o<s&&(s=o),o>p&&(p=o),l<h&&(h=l),l>u&&(u=l)}return(l[e+0]!==n||l[e+1]!==s||l[e+2]!==h||l[e+3]!==d||l[e+4]!==p||l[e+5]!==u)&&(l[e+0]=n,l[e+1]=s,l[e+2]=h,l[e+3]=d,l[e+4]=p,l[e+5]=u,!0)}{const r=e+8,i=a[e+6],o=r+n,c=i+n;let h=s,p=!1,u=!1;t?h||(p=t.has(o),u=t.has(c),h=!p&&!u):(p=!0,u=!0);const g=h||u;let m=!1;(h||p)&&(m=d(r,n,h));let f=!1;g&&(f=d(i,n,h));const y=m||f;if(y)for(let t=0;t<3;t++){const n=r+t,s=i+t,a=l[n],o=l[n+3],c=l[s],h=l[s+3];l[e+t]=a<c?a:c,l[e+t+3]=o>h?o:h}return y}}}function Je(e,t,n,r,i){let s,a,o,l,c,h;const d=1/n.direction.x,p=1/n.direction.y,u=1/n.direction.z,g=n.origin.x,m=n.origin.y,f=n.origin.z;let y=t[e],b=t[e+3],w=t[e+1],v=t[e+3+1],x=t[e+2],S=t[e+3+2];return d>=0?(s=(y-g)*d,a=(b-g)*d):(s=(b-g)*d,a=(y-g)*d),p>=0?(o=(w-m)*p,l=(v-m)*p):(o=(v-m)*p,l=(w-m)*p),!(s>l||o>a)&&((o>s||isNaN(s))&&(s=o),(l<a||isNaN(a))&&(a=l),u>=0?(c=(x-f)*u,h=(S-f)*u):(c=(S-f)*u,h=(x-f)*u),!(s>h||c>a)&&((c>s||s!=s)&&(s=c),(h<a||a!=a)&&(a=h),s<=i&&a>=r))}function Qe(e,t,n,r,i,s,a){const{geometry:o}=n,{index:l}=o,c=o.attributes.position;for(let o=e,h=t+e;o<h;o++){let e;if(e=n.resolveTriangleIndex(o),Xe(a,3*e,l,c),a.needsUpdate=!0,r(a,e,i,s))return!0}return!1}function et(e,t,n,r,i,s,a){Ee.setBuffer(e._roots[t]),tt(0,e,n,r,i,s,a),Ee.clearBuffer()}function tt(e,t,n,r,i,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=Ee,h=2*e;if(te(h,l)){!function(e,t,n,r,i,s,a,o){const{geometry:l,_indirectBuffer:c}=e;for(let e=r,c=r+i;e<c;e++)Ye(l,t,n,e,s,a,o)}(t,n,r,ne(e,c),re(h,l),i,s,a)}else{const l=ie(e);Je(l,o,r,s,a)&&tt(l,t,n,r,i,s,a);const h=se(e,c);Je(h,o,r,s,a)&&tt(h,t,n,r,i,s,a)}}const nt=["x","y","z"];function rt(e,t,n,r,i,s){Ee.setBuffer(e._roots[t]);const a=it(0,e,n,r,i,s);return Ee.clearBuffer(),a}function it(e,t,n,r,i,s){const{float32Array:a,uint16Array:o,uint32Array:l}=Ee;let c=2*e;if(te(c,o)){return function(e,t,n,r,i,s,a){const{geometry:o,_indirectBuffer:l}=e;let c=1/0,h=null;for(let e=r,l=r+i;e<l;e++){let r;r=Ye(o,t,n,e,null,s,a),r&&r.distance<c&&(h=r,c=r.distance)}return h}(t,n,r,ne(e,l),re(c,o),i,s)}{const o=ae(e,l),c=nt[o],h=r.direction[c]>=0;let d,p;h?(d=ie(e),p=se(e,l)):(d=se(e,l),p=ie(e));const u=Je(d,a,r,i,s)?it(d,t,n,r,i,s):null;if(u){const e=u.point[c];if(h?e<=a[p+o]:e>=a[p+o+3])return u}const g=Je(p,a,r,i,s)?it(p,t,n,r,i,s):null;return u&&g?u.distance<=g.distance?u:g:u||g||null}}const st=new c,at=new Se,ot=new Se,lt=new l,ct=new Ce,ht=new Ce;function dt(e,t,n,r){Ee.setBuffer(e._roots[t]);const i=pt(0,e,n,r);return Ee.clearBuffer(),i}function pt(e,t,n,r,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=Ee;let l=2*e;null===i&&(n.boundingBox||n.computeBoundingBox(),ct.set(n.boundingBox.min,n.boundingBox.max,r),i=ct);if(!te(l,a)){const a=e+8,l=o[e+6];U(a,s,st);if(i.intersectsBox(st)&&pt(a,t,n,r,i))return!0;U(l,s,st);return!!(i.intersectsBox(st)&&pt(l,t,n,r,i))}{const i=t.geometry,c=i.index,h=i.attributes.position,d=n.index,p=n.attributes.position,u=ne(e,o),g=re(l,a);if(lt.copy(r).invert(),n.boundsTree){U(e,s,ht),ht.matrix.copy(lt),ht.needsUpdate=!0;const t=n.boundsTree.shapecast({intersectsBounds:e=>ht.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.needsUpdate=!0;for(let t=3*u,n=3*(g+u);t<n;t+=3)if(Xe(ot,t,c,h),ot.needsUpdate=!0,e.intersectsTriangle(ot))return!0;return!1}});return t}for(let e=3*u,t=3*(g+u);e<t;e+=3){Xe(at,e,c,h),at.a.applyMatrix4(lt),at.b.applyMatrix4(lt),at.c.applyMatrix4(lt),at.needsUpdate=!0;for(let e=0,t=d.count;e<t;e+=3)if(Xe(ot,e,d,p),ot.needsUpdate=!0,at.intersectsTriangle(ot))return!0}}}const ut=new l,gt=new Ce,mt=new Ce,ft=new n,yt=new n,bt=new n,wt=new n;function vt(e,t,n,r={},i={},s=0,a=1/0){t.boundingBox||t.computeBoundingBox(),gt.set(t.boundingBox.min,t.boundingBox.max,n),gt.needsUpdate=!0;const o=e.geometry,l=o.attributes.position,c=o.index,h=t.attributes.position,d=t.index,p=ke.getPrimitive(),u=ke.getPrimitive();let g=ft,m=yt,f=null,y=null;i&&(f=bt,y=wt);let b=1/0,w=null,v=null;return ut.copy(n).invert(),mt.matrix.copy(ut),e.shapecast({boundsTraverseOrder:e=>gt.distanceToBox(e),intersectsBounds:(e,t,n)=>n<b&&n<a&&(t&&(mt.min.copy(e.min),mt.max.copy(e.max),mt.needsUpdate=!0),!0),intersectsRange:(e,r)=>{if(t.boundsTree){return t.boundsTree.shapecast({boundsTraverseOrder:e=>mt.distanceToBox(e),intersectsBounds:(e,t,n)=>n<b&&n<a,intersectsRange:(t,i)=>{for(let a=t,o=t+i;a<o;a++){Xe(u,3*a,d,h),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=e,n=e+r;t<n;t++){Xe(p,3*t,c,l),p.needsUpdate=!0;const e=p.distanceToTriangle(u,g,f);if(e<b&&(m.copy(g),y&&y.copy(f),b=e,w=t,v=a),e<s)return!0}}}})}for(let i=0,a=O(t);i<a;i++){Xe(u,3*i,d,h),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=e,n=e+r;t<n;t++){Xe(p,3*t,c,l),p.needsUpdate=!0;const e=p.distanceToTriangle(u,g,f);if(e<b&&(m.copy(g),y&&y.copy(f),b=e,w=t,v=i),e<s)return!0}}}}),ke.releasePrimitive(p),ke.releasePrimitive(u),b===1/0?null:(r.point?r.point.copy(m):r.point=m.clone(),r.distance=b,r.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ut),m.applyMatrix4(ut),i.distance=m.sub(i.point).length(),i.faceIndex=v),r)}function xt(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const n=e.geometry,r=n.index?n.index.array:null,i=n.attributes.position;let s,a,o,l,c=0;const h=e._roots;for(let e=0,t=h.length;e<t;e++)s=h[e],a=new Uint32Array(s),o=new Uint16Array(s),l=new Float32Array(s),d(0,c),c+=s.byteLength;function d(n,s,c=!1){const h=2*n;if(o[h+15]===N){const t=a[n+6];let s=1/0,c=1/0,d=1/0,p=-1/0,u=-1/0,g=-1/0;for(let n=t,a=t+o[h+14];n<a;n++){const t=3*e.resolveTriangleIndex(n);for(let e=0;e<3;e++){let n=t+e;n=r?r[n]:n;const a=i.getX(n),o=i.getY(n),l=i.getZ(n);a<s&&(s=a),a>p&&(p=a),o<c&&(c=o),o>u&&(u=o),l<d&&(d=l),l>g&&(g=l)}}return(l[n+0]!==s||l[n+1]!==c||l[n+2]!==d||l[n+3]!==p||l[n+4]!==u||l[n+5]!==g)&&(l[n+0]=s,l[n+1]=c,l[n+2]=d,l[n+3]=p,l[n+4]=u,l[n+5]=g,!0)}{const e=n+8,r=a[n+6],i=e+s,o=r+s;let h=c,p=!1,u=!1;t?h||(p=t.has(i),u=t.has(o),h=!p&&!u):(p=!0,u=!0);const g=h||u;let m=!1;(h||p)&&(m=d(e,s,h));let f=!1;g&&(f=d(r,s,h));const y=m||f;if(y)for(let t=0;t<3;t++){const i=e+t,s=r+t,a=l[i],o=l[i+3],c=l[s],h=l[s+3];l[n+t]=a<c?a:c,l[n+t+3]=o>h?o:h}return y}}}function St(e,t,n,r,i,s,a){Ee.setBuffer(e._roots[t]),Ct(0,e,n,r,i,s,a),Ee.clearBuffer()}function Ct(e,t,n,r,i,s,a){const{float32Array:o,uint16Array:l,uint32Array:c}=Ee,h=2*e;if(te(h,l)){!function(e,t,n,r,i,s,a,o){const{geometry:l,_indirectBuffer:c}=e;for(let e=r,h=r+i;e<h;e++)Ye(l,t,n,c?c[e]:e,s,a,o)}(t,n,r,ne(e,c),re(h,l),i,s,a)}else{const l=ie(e);Je(l,o,r,s,a)&&Ct(l,t,n,r,i,s,a);const h=se(e,c);Je(h,o,r,s,a)&&Ct(h,t,n,r,i,s,a)}}const Mt=["x","y","z"];function _t(e,t,n,r,i,s){Ee.setBuffer(e._roots[t]);const a=kt(0,e,n,r,i,s);return Ee.clearBuffer(),a}function kt(e,t,n,r,i,s){const{float32Array:a,uint16Array:o,uint32Array:l}=Ee;let c=2*e;if(te(c,o)){return function(e,t,n,r,i,s,a){const{geometry:o,_indirectBuffer:l}=e;let c=1/0,h=null;for(let e=r,d=r+i;e<d;e++){let r;r=Ye(o,t,n,l?l[e]:e,null,s,a),r&&r.distance<c&&(h=r,c=r.distance)}return h}(t,n,r,ne(e,l),re(c,o),i,s)}{const o=ae(e,l),c=Mt[o],h=r.direction[c]>=0;let d,p;h?(d=ie(e),p=se(e,l)):(d=se(e,l),p=ie(e));const u=Je(d,a,r,i,s)?kt(d,t,n,r,i,s):null;if(u){const e=u.point[c];if(h?e<=a[p+o]:e>=a[p+o+3])return u}const g=Je(p,a,r,i,s)?kt(p,t,n,r,i,s):null;return u&&g?u.distance<=g.distance?u:g:u||g||null}}const Et=new c,Tt=new Se,Dt=new Se,At=new l,Lt=new Ce,Ht=new Ce;function Pt(e,t,n,r){Ee.setBuffer(e._roots[t]);const i=Nt(0,e,n,r);return Ee.clearBuffer(),i}function Nt(e,t,n,r,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=Ee;let l=2*e;null===i&&(n.boundingBox||n.computeBoundingBox(),Lt.set(n.boundingBox.min,n.boundingBox.max,r),i=Lt);if(!te(l,a)){const a=e+8,l=o[e+6];U(a,s,Et);if(i.intersectsBox(Et)&&Nt(a,t,n,r,i))return!0;U(l,s,Et);return!!(i.intersectsBox(Et)&&Nt(l,t,n,r,i))}{const i=t.geometry,c=i.index,h=i.attributes.position,d=n.index,p=n.attributes.position,u=ne(e,o),g=re(l,a);if(At.copy(r).invert(),n.boundsTree){U(e,s,Ht),Ht.matrix.copy(At),Ht.needsUpdate=!0;const i=n.boundsTree.shapecast({intersectsBounds:e=>Ht.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.needsUpdate=!0;for(let n=u,r=g+u;n<r;n++)if(Xe(Dt,3*t.resolveTriangleIndex(n),c,h),Dt.needsUpdate=!0,e.intersectsTriangle(Dt))return!0;return!1}});return i}for(let e=u,n=g+u;e<n;e++){const n=t.resolveTriangleIndex(e);Xe(Tt,3*n,c,h),Tt.a.applyMatrix4(At),Tt.b.applyMatrix4(At),Tt.c.applyMatrix4(At),Tt.needsUpdate=!0;for(let e=0,t=d.count;e<t;e+=3)if(Xe(Dt,e,d,p),Dt.needsUpdate=!0,Tt.intersectsTriangle(Dt))return!0}}}const zt=new l,It=new Ce,Ot=new Ce,Bt=new n,Rt=new n,Ft=new n,jt=new n;function Ut(e,t,n,r={},i={},s=0,a=1/0){t.boundingBox||t.computeBoundingBox(),It.set(t.boundingBox.min,t.boundingBox.max,n),It.needsUpdate=!0;const o=e.geometry,l=o.attributes.position,c=o.index,h=t.attributes.position,d=t.index,p=ke.getPrimitive(),u=ke.getPrimitive();let g=Bt,m=Rt,f=null,y=null;i&&(f=Ft,y=jt);let b=1/0,w=null,v=null;return zt.copy(n).invert(),Ot.matrix.copy(zt),e.shapecast({boundsTraverseOrder:e=>It.distanceToBox(e),intersectsBounds:(e,t,n)=>n<b&&n<a&&(t&&(Ot.min.copy(e.min),Ot.max.copy(e.max),Ot.needsUpdate=!0),!0),intersectsRange:(r,i)=>{if(t.boundsTree){const o=t.boundsTree;return o.shapecast({boundsTraverseOrder:e=>Ot.distanceToBox(e),intersectsBounds:(e,t,n)=>n<b&&n<a,intersectsRange:(t,a)=>{for(let x=t,S=t+a;x<S;x++){const t=o.resolveTriangleIndex(x);Xe(u,3*t,d,h),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=r,n=r+i;t<n;t++){const n=e.resolveTriangleIndex(t);Xe(p,3*n,c,l),p.needsUpdate=!0;const r=p.distanceToTriangle(u,g,f);if(r<b&&(m.copy(g),y&&y.copy(f),b=r,w=t,v=x),r<s)return!0}}}})}for(let a=0,o=O(t);a<o;a++){Xe(u,3*a,d,h),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let t=r,n=r+i;t<n;t++){const n=e.resolveTriangleIndex(t);Xe(p,3*n,c,l),p.needsUpdate=!0;const r=p.distanceToTriangle(u,g,f);if(r<b&&(m.copy(g),y&&y.copy(f),b=r,w=t,v=a),r<s)return!0}}}}),ke.releasePrimitive(p),ke.releasePrimitive(u),b===1/0?null:(r.point?r.point.copy(m):r.point=m.clone(),r.distance=b,r.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(zt),m.applyMatrix4(zt),i.distance=m.sub(i.point).length(),i.faceIndex=v),r)}const $t=new Ee.constructor,Gt=new Ee.constructor,Vt=new Me((()=>new c)),qt=new c,Wt=new c,Yt=new c,Xt=new c;let Zt=!1;function Kt(e,t,n,r,i,s=0,a=0,o=0,l=0,c=null,h=!1){let d,p;h?(d=Gt,p=$t):(d=$t,p=Gt);const u=d.float32Array,g=d.uint32Array,m=d.uint16Array,f=p.float32Array,y=p.uint32Array,b=p.uint16Array,w=2*t,v=te(2*e,m),x=te(w,b);let S=!1;if(x&&v)S=h?i(ne(t,y),re(2*t,b),ne(e,g),re(2*e,m),l,a+t,o,s+e):i(ne(e,g),re(2*e,m),ne(t,y),re(2*t,b),o,s+e,l,a+t);else if(x){const c=Vt.getPrimitive();U(t,f,c),c.applyMatrix4(n);const d=ie(e),p=se(e,g);U(d,u,qt),U(p,u,Wt);const m=c.intersectsBox(qt),y=c.intersectsBox(Wt);S=m&&Kt(t,d,r,n,i,a,s,l,o+1,c,!h)||y&&Kt(t,p,r,n,i,a,s,l,o+1,c,!h),Vt.releasePrimitive(c)}else{const d=ie(t),p=se(t,y);U(d,f,Yt),U(p,f,Xt);const m=c.intersectsBox(Yt),b=c.intersectsBox(Xt);if(m&&b)S=Kt(e,d,n,r,i,s,a,o,l+1,c,h)||Kt(e,p,n,r,i,s,a,o,l+1,c,h);else if(m)if(v)S=Kt(e,d,n,r,i,s,a,o,l+1,c,h);else{const t=Vt.getPrimitive();t.copy(Yt).applyMatrix4(n);const c=ie(e),p=se(e,g);U(c,u,qt),U(p,u,Wt);const m=t.intersectsBox(qt),f=t.intersectsBox(Wt);S=m&&Kt(d,c,r,n,i,a,s,l,o+1,t,!h)||f&&Kt(d,p,r,n,i,a,s,l,o+1,t,!h),Vt.releasePrimitive(t)}else if(b)if(v)S=Kt(e,p,n,r,i,s,a,o,l+1,c,h);else{const t=Vt.getPrimitive();t.copy(Xt).applyMatrix4(n);const c=ie(e),d=se(e,g);U(c,u,qt),U(d,u,Wt);const m=t.intersectsBox(qt),f=t.intersectsBox(Wt);S=m&&Kt(p,c,r,n,i,a,s,l,o+1,t,!h)||f&&Kt(p,d,r,n,i,a,s,l,o+1,t,!h),Vt.releasePrimitive(t)}}return S}const Jt=new Ce,Qt=new c,en={strategy:0,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class tn{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,r=e._roots,i=e._indirectBuffer,s=n.getIndex();let a;return a=t.cloneBuffers?{roots:r.map((e=>e.slice())),index:s?s.array.slice():null,indirectBuffer:i?i.slice():null}:{roots:r,index:s?s.array:null,indirectBuffer:i},a}static deserialize(e,n,r={}){r={setIndex:!0,indirect:Boolean(e.indirectBuffer),...r};const{index:i,roots:s,indirectBuffer:a}=e,o=new tn(n,{...r,[I]:!0});if(o._roots=s,o._indirectBuffer=a||null,r.setIndex){const r=n.getIndex();if(null===r){const r=new t(e.index,1,!1);n.setIndex(r)}else r.array!==i&&(r.array.set(i),r.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({...en,[I]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[I]||(fe(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new c))),this.resolveTriangleIndex=t.indirect?e=>this._indirectBuffer[e]:e=>e}refit(e=null){return(this.indirect?xt:Ke)(this,e)}traverse(e,t=0){const n=this._roots[t],r=new Uint32Array(n),i=new Uint16Array(n);!function t(s,a=0){const o=2*s,l=i[o+15]===N;if(l){const t=r[s+6],c=i[o+14];e(a,l,new Float32Array(n,4*s,6),t,c)}else{const i=s+8,o=r[s+6],c=r[s+7];e(a,l,new Float32Array(n,4*s,6),c)||(t(i,a+1),t(o,a+1))}}(0)}raycast(e,t=u,n=0,r=1/0){const i=this._roots,s=this.geometry,a=[],o=t.isMaterial,l=Array.isArray(t),c=s.groups,h=o?t.side:t,d=this.indirect?St:et;for(let s=0,o=i.length;s<o;s++){const i=l?t[c[s].materialIndex].side:h,o=a.length;if(d(this,s,i,e,a,n,r),l){const e=c[s].materialIndex;for(let t=o,n=a.length;t<n;t++)a[t].face.materialIndex=e}}return a}raycastFirst(e,t=u,n=0,r=1/0){const i=this._roots,s=this.geometry,a=t.isMaterial,o=Array.isArray(t);let l=null;const c=s.groups,h=a?t.side:t,d=this.indirect?_t:rt;for(let s=0,a=i.length;s<a;s++){const i=d(this,s,o?t[c[s].materialIndex].side:h,e,n,r);null!=i&&(null==l||i.distance<l.distance)&&(l=i,o&&(i.face.materialIndex=c[s].materialIndex))}return l}intersectsGeometry(e,t){let n=!1;const r=this._roots,i=this.indirect?Pt:dt;for(let s=0,a=r.length;s<a&&(n=i(this,s,e,t),!n);s++);return n}shapecast(e){const t=ke.getPrimitive(),n=this.indirect?Qe:Ze;let{boundsTraverseOrder:r,intersectsBounds:i,intersectsRange:s,intersectsTriangle:a}=e;if(s&&a){const e=s;s=(r,i,s,o,l)=>!!e(r,i,s,o,l)||n(r,i,this,a,s,o,t)}else s||(s=a?(e,r,i,s)=>n(e,r,this,a,i,s,t):(e,t,n)=>n);let o=!1,l=0;const c=this._roots;for(let e=0,t=c.length;e<t;e++){const t=c[e];if(o=He(this,e,i,s,r,l),o)break;l+=t.byteLength}return ke.releasePrimitive(t),o}bvhcast(e,t,n){let{intersectsRanges:r,intersectsTriangles:i}=n;const s=ke.getPrimitive(),a=this.geometry.index,o=this.geometry.attributes.position,c=this.indirect?e=>{const t=this.resolveTriangleIndex(e);Xe(s,3*t,a,o)}:e=>{Xe(s,3*e,a,o)},h=ke.getPrimitive(),d=e.geometry.index,p=e.geometry.attributes.position,u=e.indirect?t=>{const n=e.resolveTriangleIndex(t);Xe(h,3*n,d,p)}:e=>{Xe(h,3*e,d,p)};if(i){const e=(e,n,r,a,o,l,d,p)=>{for(let g=r,m=r+a;g<m;g++){u(g),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let t=e,r=e+n;t<r;t++)if(c(t),s.needsUpdate=!0,i(s,h,t,g,o,l,d,p))return!0}return!1};if(r){const t=r;r=function(n,r,i,s,a,o,l,c){return!!t(n,r,i,s,a,o,l,c)||e(n,r,i,s,a,o,l,c)}}else r=e}return function(e,t,n,r){if(Zt)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Zt=!0;const i=e._roots,s=t._roots;let a,o=0,c=0;const h=(new l).copy(n).invert();for(let e=0,t=i.length;e<t;e++){$t.setBuffer(i[e]),c=0;const t=Vt.getPrimitive();U(0,$t.float32Array,t),t.applyMatrix4(h);for(let e=0,i=s.length;e<i&&(Gt.setBuffer(s[e]),a=Kt(0,0,n,h,r,o,c,0,0,t),Gt.clearBuffer(),c+=s[e].length,!a);e++);if(Vt.releasePrimitive(t),$t.clearBuffer(),o+=i[e].length,a)break}return Zt=!1,a}(this,e,t,r)}intersectsBox(e,t){return Jt.set(e.min,e.max,t),Jt.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Jt.intersectsBox(e),intersectsTriangle:e=>Jt.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},r={},i=0,s=1/0){return(this.indirect?Ut:vt)(this,e,t,n,r,i,s)}closestPointToPoint(e,t={},n=0,r=1/0){return function(e,t,n={},r=0,i=1/0){const s=r*r,a=i*i;let o=1/0,l=null;if(e.shapecast({boundsTraverseOrder:e=>(Ne.copy(t).clamp(e.min,e.max),Ne.distanceToSquared(t)),intersectsBounds:(e,t,n)=>n<o&&n<a,intersectsTriangle:(e,n)=>{e.closestPointToPoint(t,Ne);const r=t.distanceToSquared(Ne);return r<o&&(ze.copy(Ne),o=r,l=n),r<s}}),o===1/0)return null;const c=Math.sqrt(o);return n.point?n.point.copy(ze):n.point=ze.clone(),n.distance=c,n.faceIndex=l,n}(this,e,t,n,r)}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{U(0,new Float32Array(t),Qt),e.union(Qt)})),e}}function nn(e,t,n){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e)}const rn=new f,sn=new n,an=new l,on=g.prototype.raycast,ln=m.prototype.raycast,cn=new n,hn=new g,dn=[];function pn(e,t){if(this.boundsTrees){const n=this.boundsTrees,r=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;hn.material=this.material,hn.geometry=this.geometry;const a=hn.geometry.boundsTree,l=hn.geometry.drawRange;null===hn.geometry.boundingSphere&&(hn.geometry.boundingSphere=new o);for(let a=0,o=r.length;a<o;a++){if(!this.getVisibleAt(a))continue;const o=r[a].geometryIndex;if(hn.geometry.boundsTree=n[o],this.getMatrixAt(a,hn.matrixWorld).premultiply(s),!hn.geometry.boundsTree){this.getBoundingBoxAt(o,hn.geometry.boundingBox),this.getBoundingSphereAt(o,hn.geometry.boundingSphere);const e=i[o];hn.geometry.setDrawRange(e.start,e.count)}hn.raycast(e,dn);for(let e=0,n=dn.length;e<n;e++){const n=dn[e];n.object=this,n.batchId=a,t.push(n)}dn.length=0}hn.geometry.boundsTree=a,hn.geometry.drawRange=l,hn.material=null,hn.geometry=null}else ln.call(this,e,t)}function un(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;an.copy(this.matrixWorld).invert(),rn.copy(e.ray).applyMatrix4(an),cn.setFromMatrixScale(this.matrixWorld),sn.copy(rn.direction).multiply(cn);const n=sn.length(),r=e.near/n,i=e.far/n,s=this.geometry.boundsTree;if(!0===e.firstHitOnly){const n=nn(s.raycastFirst(rn,this.material,r,i),this,e);n&&t.push(n)}else{const n=s.raycast(rn,this.material,r,i);for(let r=0,i=n.length;r<i;r++){const i=nn(n[r],this,e);i&&t.push(i)}}}else on.call(this,e,t)}e.Mesh.prototype.raycast=function(e,t){this.isBatchedMesh?pn.call(this,e,t):un.call(this,e,t)};class gn{constructor(e){this.parent=e,this.raycaster=new mn(e.camera)}init(e){document.querySelector("#SceneCon").addEventListener("mousemove",(e=>{const t=this.raycaster.rayMeshArr(this.parent.sceneMeshArr,e);0!==t.length&&this.parent.modelTransformManager.setBox(t[0].object)}));let t=null;document.querySelector("#SceneCon").addEventListener("dblclick",(e=>{if(e.target,HTMLCanvasElement,t=e.target&&e.target instanceof HTMLCanvasElement,!1===t)return;const n=this.raycaster.rayMeshArr(this.parent.sceneMeshArr,e);if(0===n.length)return void this.parent.modelTransformManager.handleNoObjectClick();const r=n[0].object;this.parent.modelTransformManager.handleObjectClick(r)})),this.collectModels(e)}collectModels(e){e.traverse((e=>{e.isMesh&&(e.geometry.boundsTree=new tn(e.geometry),this.parent.sceneMeshArr.push(e))}))}destroy(){document.querySelector("#SceneCon").removeEventListener("mousemove",this.onMouseMove),document.querySelector("#SceneCon").removeEventListener("dblclick",this.onClick),this.mapModelArr=[]}}class mn{constructor(t,n){if(mn.instance||!t)return mn.instance;mn.instance=this,this.raycaster=new e.Raycaster,this.raycaster.firstHitOnly=!0,this.camera=t,this.domId=n||"SceneCon"}rayMeshArr(e,t){if(null==e)return[];const n=this.getMouse(t);this.raycaster.setFromCamera(n,this.camera);let r=[];return r=this.raycaster.intersectObjects(e,!0),r}rayMeshObj(e,t){const n=this.getMouse(t);this.raycaster.setFromCamera(n,this.camera);let r=[];return r=this.raycaster.intersectObject(e,!0),r}getMouse(t){let n=document.querySelector(`#${this.domId}`),r=new e.Vector2;return r.x=t.offsetX/n.offsetWidth*2-1,r.y=-t.offsetY/n.offsetHeight*2+1,r}destroy(){mn.instance=null}}function fn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function yn(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var bn,wn,vn,xn,Sn,Cn,Mn,_n,kn,En,Tn,Dn,An,Ln,Hn,Pn,Nn,zn={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},In={duration:.5,overwrite:!1,delay:0},On=1e8,Bn=1e-8,Rn=2*Math.PI,Fn=Rn/4,jn=0,Un=Math.sqrt,$n=Math.cos,Gn=Math.sin,Vn=function(e){return"string"==typeof e},qn=function(e){return"function"==typeof e},Wn=function(e){return"number"==typeof e},Yn=function(e){return void 0===e},Xn=function(e){return"object"==typeof e},Zn=function(e){return!1!==e},Kn=function(){return"undefined"!=typeof window},Jn=function(e){return qn(e)||Vn(e)},Qn="function"==typeof ArrayBuffer&&ArrayBuffer.isView||function(){},er=Array.isArray,tr=/(?:-?\.?\d|\.)+/gi,nr=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,rr=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,ir=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,sr=/[+-]=-?[.\d]+/,ar=/[^,'"\[\]\s]+/gi,or=/^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i,lr={},cr={},hr=function(e){return(cr=Rr(e,lr))&&Fs},dr=function(e,t){return console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()")},pr=function(e,t){return!t&&console.warn(e)},ur=function(e,t){return e&&(lr[e]=t)&&cr&&(cr[e]=t)||lr},gr=function(){return 0},mr={suppressEvents:!0,isStart:!0,kill:!1},fr={suppressEvents:!0,kill:!1},yr={suppressEvents:!0},br={},wr=[],vr={},xr={},Sr={},Cr=30,Mr=[],_r="",kr=function(e){var t,n,r=e[0];if(Xn(r)||qn(r)||(e=[e]),!(t=(r._gsap||{}).harness)){for(n=Mr.length;n--&&!Mr[n].targetTest(r););t=Mr[n]}for(n=e.length;n--;)e[n]&&(e[n]._gsap||(e[n]._gsap=new es(e[n],t)))||e.splice(n,1);return e},Er=function(e){return e._gsap||kr(yi(e))[0]._gsap},Tr=function(e,t,n){return(n=e[t])&&qn(n)?e[t]():Yn(n)&&e.getAttribute&&e.getAttribute(t)||n},Dr=function(e,t){return(e=e.split(",")).forEach(t)||e},Ar=function(e){return Math.round(1e5*e)/1e5||0},Lr=function(e){return Math.round(1e7*e)/1e7||0},Hr=function(e,t){var n=t.charAt(0),r=parseFloat(t.substr(2));return e=parseFloat(e),"+"===n?e+r:"-"===n?e-r:"*"===n?e*r:e/r},Pr=function(e,t){for(var n=t.length,r=0;e.indexOf(t[r])<0&&++r<n;);return r<n},Nr=function(){var e,t,n=wr.length,r=wr.slice(0);for(vr={},wr.length=0,e=0;e<n;e++)(t=r[e])&&t._lazy&&(t.render(t._lazy[0],t._lazy[1],!0)._lazy=0)},zr=function(e,t,n,r){wr.length&&!wn&&Nr(),e.render(t,n,r||wn&&t<0&&(e._initted||e._startAt)),wr.length&&!wn&&Nr()},Ir=function(e){var t=parseFloat(e);return(t||0===t)&&(e+"").match(ar).length<2?t:Vn(e)?e.trim():e},Or=function(e){return e},Br=function(e,t){for(var n in t)n in e||(e[n]=t[n]);return e},Rr=function(e,t){for(var n in t)e[n]=t[n];return e},Fr=function e(t,n){for(var r in n)"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(t[r]=Xn(n[r])?e(t[r]||(t[r]={}),n[r]):n[r]);return t},jr=function(e,t){var n,r={};for(n in e)n in t||(r[n]=e[n]);return r},Ur=function(e){var t,n=e.parent||xn,r=e.keyframes?(t=er(e.keyframes),function(e,n){for(var r in n)r in e||"duration"===r&&t||"ease"===r||(e[r]=n[r])}):Br;if(Zn(e.inherit))for(;n;)r(e,n.vars.defaults),n=n.parent||n._dp;return e},$r=function(e,t,n,r,i){void 0===n&&(n="_first"),void 0===r&&(r="_last");var s,a=e[r];if(i)for(s=t[i];a&&a[i]>s;)a=a._prev;return a?(t._next=a._next,a._next=t):(t._next=e[n],e[n]=t),t._next?t._next._prev=t:e[r]=t,t._prev=a,t.parent=t._dp=e,t},Gr=function(e,t,n,r){void 0===n&&(n="_first"),void 0===r&&(r="_last");var i=t._prev,s=t._next;i?i._next=s:e[n]===t&&(e[n]=s),s?s._prev=i:e[r]===t&&(e[r]=i),t._next=t._prev=t.parent=null},Vr=function(e,t){e.parent&&(!t||e.parent.autoRemoveChildren)&&e.parent.remove&&e.parent.remove(e),e._act=0},qr=function(e,t){if(e&&(!t||t._end>e._dur||t._start<0))for(var n=e;n;)n._dirty=1,n=n.parent;return e},Wr=function(e,t,n,r){return e._startAt&&(wn?e._startAt.revert(fr):e.vars.immediateRender&&!e.vars.autoRevert||e._startAt.render(t,!0,r))},Yr=function e(t){return!t||t._ts&&e(t.parent)},Xr=function(e){return e._repeat?Zr(e._tTime,e=e.duration()+e._rDelay)*e:0},Zr=function(e,t){var n=Math.floor(e/=t);return e&&n===e?n-1:n},Kr=function(e,t){return(e-t._start)*t._ts+(t._ts>=0?0:t._dirty?t.totalDuration():t._tDur)},Jr=function(e){return e._end=Lr(e._start+(e._tDur/Math.abs(e._ts||e._rts||Bn)||0))},Qr=function(e,t){var n=e._dp;return n&&n.smoothChildTiming&&e._ts&&(e._start=Lr(n._time-(e._ts>0?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),Jr(e),n._dirty||qr(n,e)),e},ei=function(e,t){var n;if((t._time||!t._dur&&t._initted||t._start<e._time&&(t._dur||!t.add))&&(n=Kr(e.rawTime(),t),(!t._dur||pi(0,t.totalDuration(),n)-t._tTime>Bn)&&t.render(n,!0)),qr(e,t)._dp&&e._initted&&e._time>=e._dur&&e._ts){if(e._dur<e.duration())for(n=e;n._dp;)n.rawTime()>=0&&n.totalTime(n._tTime),n=n._dp;e._zTime=-1e-8}},ti=function(e,t,n,r){return t.parent&&Vr(t),t._start=Lr((Wn(n)?n:n||e!==xn?ci(e,n,t):e._time)+t._delay),t._end=Lr(t._start+(t.totalDuration()/Math.abs(t.timeScale())||0)),$r(e,t,"_first","_last",e._sort?"_start":0),si(t)||(e._recent=t),r||ei(e,t),e._ts<0&&Qr(e,e._tTime),e},ni=function(e,t){return(lr.ScrollTrigger||dr("scrollTrigger",t))&&lr.ScrollTrigger.create(t,e)},ri=function(e,t,n,r,i){return ls(e,t,i),e._initted?!n&&e._pt&&!wn&&(e._dur&&!1!==e.vars.lazy||!e._dur&&e.vars.lazy)&&kn!==ji.frame?(wr.push(e),e._lazy=[i,r],1):void 0:1},ii=function e(t){var n=t.parent;return n&&n._ts&&n._initted&&!n._lock&&(n.rawTime()<0||e(n))},si=function(e){var t=e.data;return"isFromStart"===t||"isStart"===t},ai=function(e,t,n,r){var i=e._repeat,s=Lr(t)||0,a=e._tTime/e._tDur;return a&&!r&&(e._time*=s/e._dur),e._dur=s,e._tDur=i?i<0?1e10:Lr(s*(i+1)+e._rDelay*i):s,a>0&&!r&&Qr(e,e._tTime=e._tDur*a),e.parent&&Jr(e),n||qr(e.parent,e),e},oi=function(e){return e instanceof ns?qr(e):ai(e,e._dur)},li={_start:0,endTime:gr,totalDuration:gr},ci=function e(t,n,r){var i,s,a,o=t.labels,l=t._recent||li,c=t.duration()>=On?l.endTime(!1):t._dur;return Vn(n)&&(isNaN(n)||n in o)?(s=n.charAt(0),a="%"===n.substr(-1),i=n.indexOf("="),"<"===s||">"===s?(i>=0&&(n=n.replace(/=/,"")),("<"===s?l._start:l.endTime(l._repeat>=0))+(parseFloat(n.substr(1))||0)*(a?(i<0?l:r).totalDuration()/100:1)):i<0?(n in o||(o[n]=c),o[n]):(s=parseFloat(n.charAt(i-1)+n.substr(i+1)),a&&r&&(s=s/100*(er(r)?r[0]:r).totalDuration()),i>1?e(t,n.substr(0,i-1),r)+s:c+s)):null==n?c:+n},hi=function(e,t,n){va