shop-components 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .slot-item{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:12px;height:12px;background:#fff0;border:1px solid #fff;border-radius:50%;transition:background .2s,width .14s,height .14s,border .14s}.slot-item.disable{cursor:not-allowed}.slot-item.hidden{display:none}.slot-item.drag-over{border-color:red}.slot-item.can-install{position:relative;width:34px;height:34px;background:#0066ff1a;border-color:#06f}.slot-item.filled{border-color:#00ff95}.slot-item:hover{background:#ffffff80}.slot-item:hover:after{pointer-events:auto;transition:all .2s ease-in-out;opacity:1;transform:translate3d(-50%,-4px,0)}.slot-item:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shop-components",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Shop components",
5
5
  "main": "dist/shop-components.umd.js",
6
6
  "module": "dist/shop-components.mjs",
@@ -47,6 +47,7 @@
47
47
  "pixi-viewport": "^5.0.2",
48
48
  "pixi.js": "^7.4.0",
49
49
  "stats-fps.js": "0.0.6",
50
+ "stylus": "^0.63.0",
50
51
  "three-gpu-pathtracer": "^0.0.17",
51
52
  "three-mesh-bvh": "^0.7.0",
52
53
  "tweakpane": "^4.0.3",
@@ -1,5 +0,0 @@
1
- (function(){"use strict";/**
2
- * @license
3
- * Copyright 2010-2023 Three.js Authors
4
- * SPDX-License-Identifier: MIT
5
- */const zs="159",We="",Oe="srgb";class Xe{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const s=this._listeners[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let n=0,r=i.length;n<r;n++)i[n].call(this,t);t.target=null}}}const N=["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"];function le(){const u=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(N[u&255]+N[u>>8&255]+N[u>>16&255]+N[u>>24&255]+"-"+N[t&255]+N[t>>8&255]+"-"+N[t>>16&15|64]+N[t>>24&255]+"-"+N[e&63|128]+N[e>>8&255]+"-"+N[e>>16&255]+N[e>>24&255]+N[s&255]+N[s>>8&255]+N[s>>16&255]+N[s>>24&255]).toLowerCase()}function ot(u,t,e){return Math.max(t,Math.min(e,u))}function Jt(u,t){switch(t.constructor){case Float32Array:return u;case Uint32Array:return u/4294967295;case Uint16Array:return u/65535;case Uint8Array:return u/255;case Int32Array:return Math.max(u/2147483647,-1);case Int16Array:return Math.max(u/32767,-1);case Int8Array:return Math.max(u/127,-1);default:throw new Error("Invalid component type.")}}function X(u,t){switch(t.constructor){case Float32Array:return u;case Uint32Array:return Math.round(u*4294967295);case Uint16Array:return Math.round(u*65535);case Uint8Array:return Math.round(u*255);case Int32Array:return Math.round(u*2147483647);case Int16Array:return Math.round(u*32767);case Int8Array:return Math.round(u*127);default:throw new Error("Invalid component type.")}}class W{constructor(t=0,e=0){W.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(ot(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,r=this.y-t.y;return this.x=n*s-r*i+t.x,this.y=n*i+r*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Bt{constructor(t,e,s,i,n,r,a,o,h){Bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,r,a,o,h)}set(t,e,s,i,n,r,a,o,h){const c=this.elements;return c[0]=t,c[1]=i,c[2]=a,c[3]=e,c[4]=n,c[5]=o,c[6]=s,c[7]=r,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,r=s[0],a=s[3],o=s[6],h=s[1],c=s[4],f=s[7],l=s[2],d=s[5],p=s[8],y=i[0],x=i[3],m=i[6],b=i[1],_=i[4],g=i[7],w=i[2],z=i[5],A=i[8];return n[0]=r*y+a*b+o*w,n[3]=r*x+a*_+o*z,n[6]=r*m+a*g+o*A,n[1]=h*y+c*b+f*w,n[4]=h*x+c*_+f*z,n[7]=h*m+c*g+f*A,n[2]=l*y+d*b+p*w,n[5]=l*x+d*_+p*z,n[8]=l*m+d*g+p*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8];return e*r*c-e*a*h-s*n*c+s*a*o+i*n*h-i*r*o}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8],f=c*r-a*h,l=a*o-c*n,d=h*n-r*o,p=e*f+s*l+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/p;return t[0]=f*y,t[1]=(i*h-c*s)*y,t[2]=(a*s-i*r)*y,t[3]=l*y,t[4]=(c*e-i*o)*y,t[5]=(i*n-a*e)*y,t[6]=d*y,t[7]=(s*o-h*e)*y,t[8]=(r*e-s*n)*y,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,r,a){const o=Math.cos(n),h=Math.sin(n);return this.set(s*o,s*h,-s*(o*r+h*a)+r+t,-i*h,i*o,-i*(-h*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Ye.makeScale(t,e)),this}rotate(t){return this.premultiply(Ye.makeRotation(-t)),this}translate(t,e){return this.premultiply(Ye.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Ye=new Bt;function ni(u){for(let t=u.length-1;t>=0;--t)if(u[t]>=65535)return!0;return!1}function Ss(u){return document.createElementNS("http://www.w3.org/1999/xhtml",u)}const Ts={};function He(u){u in Ts||(Ts[u]=!0,console.warn(u))}function Ze(u){return u<.04045?u*.0773993808:Math.pow(u*.9478672986+.0521327014,2.4)}let Et;class ri{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Et===void 0&&(Et=Ss("canvas")),Et.width=t.width,Et.height=t.height;const s=Et.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),e=Et}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Ss("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const i=s.getImageData(0,0,t.width,t.height),n=i.data;for(let r=0;r<n.length;r++)n[r]=Ze(n[r]/255)*255;return s.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let s=0;s<e.length;s++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[s]=Math.floor(Ze(e[s]/255)*255):e[s]=Ze(e[s]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let oi=0;class ai{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:oi++}),this.uuid=le(),this.data=t,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let n;if(Array.isArray(i)){n=[];for(let r=0,a=i.length;r<a;r++)i[r].isDataTexture?n.push($e(i[r].image)):n.push($e(i[r]))}else n=$e(i);s.url=n}return e||(t.images[this.uuid]=s),s}}function $e(u){return typeof HTMLImageElement<"u"&&u instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&u instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&u instanceof ImageBitmap?ri.getDataURL(u):u.data?{data:Array.from(u.data),width:u.width,height:u.height,type:u.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let ci=0;class gt extends Xe{constructor(t=gt.DEFAULT_IMAGE,e=gt.DEFAULT_MAPPING,s=1001,i=1001,n=1006,r=1008,a=1023,o=1009,h=gt.DEFAULT_ANISOTROPY,c=We){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ci++}),this.uuid=le(),this.name="",this.source=new ai(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=n,this.minFilter=r,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=o,this.offset=new W(0,0),this.repeat=new W(1,1),this.center=new W(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Bt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof c=="string"?this.colorSpace=c:(He("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=c===3001?Oe:We),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const s={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return He("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Oe?3001:3e3}set encoding(t){He("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===3001?Oe:We}}gt.DEFAULT_IMAGE=null,gt.DEFAULT_MAPPING=300,gt.DEFAULT_ANISOTROPY=1;class Qt{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,n,r,a){let o=s[i+0],h=s[i+1],c=s[i+2],f=s[i+3];const l=n[r+0],d=n[r+1],p=n[r+2],y=n[r+3];if(a===0){t[e+0]=o,t[e+1]=h,t[e+2]=c,t[e+3]=f;return}if(a===1){t[e+0]=l,t[e+1]=d,t[e+2]=p,t[e+3]=y;return}if(f!==y||o!==l||h!==d||c!==p){let x=1-a;const m=o*l+h*d+c*p+f*y,b=m>=0?1:-1,_=1-m*m;if(_>Number.EPSILON){const w=Math.sqrt(_),z=Math.atan2(w,m*b);x=Math.sin(x*z)/w,a=Math.sin(a*z)/w}const g=a*b;if(o=o*x+l*g,h=h*x+d*g,c=c*x+p*g,f=f*x+y*g,x===1-a){const w=1/Math.sqrt(o*o+h*h+c*c+f*f);o*=w,h*=w,c*=w,f*=w}}t[e]=o,t[e+1]=h,t[e+2]=c,t[e+3]=f}static multiplyQuaternionsFlat(t,e,s,i,n,r){const a=s[i],o=s[i+1],h=s[i+2],c=s[i+3],f=n[r],l=n[r+1],d=n[r+2],p=n[r+3];return t[e]=a*p+c*f+o*d-h*l,t[e+1]=o*p+c*l+h*f-a*d,t[e+2]=h*p+c*d+a*l-o*f,t[e+3]=c*p-a*f-o*l-h*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,i){return this._x=t,this._y=e,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){const s=t._x,i=t._y,n=t._z,r=t._order,a=Math.cos,o=Math.sin,h=a(s/2),c=a(i/2),f=a(n/2),l=o(s/2),d=o(i/2),p=o(n/2);switch(r){case"XYZ":this._x=l*c*f+h*d*p,this._y=h*d*f-l*c*p,this._z=h*c*p+l*d*f,this._w=h*c*f-l*d*p;break;case"YXZ":this._x=l*c*f+h*d*p,this._y=h*d*f-l*c*p,this._z=h*c*p-l*d*f,this._w=h*c*f+l*d*p;break;case"ZXY":this._x=l*c*f-h*d*p,this._y=h*d*f+l*c*p,this._z=h*c*p+l*d*f,this._w=h*c*f-l*d*p;break;case"ZYX":this._x=l*c*f-h*d*p,this._y=h*d*f+l*c*p,this._z=h*c*p-l*d*f,this._w=h*c*f+l*d*p;break;case"YZX":this._x=l*c*f+h*d*p,this._y=h*d*f+l*c*p,this._z=h*c*p-l*d*f,this._w=h*c*f-l*d*p;break;case"XZY":this._x=l*c*f-h*d*p,this._y=h*d*f-l*c*p,this._z=h*c*p+l*d*f,this._w=h*c*f+l*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],n=e[8],r=e[1],a=e[5],o=e[9],h=e[2],c=e[6],f=e[10],l=s+a+f;if(l>0){const d=.5/Math.sqrt(l+1);this._w=.25/d,this._x=(c-o)*d,this._y=(n-h)*d,this._z=(r-i)*d}else if(s>a&&s>f){const d=2*Math.sqrt(1+s-a-f);this._w=(c-o)/d,this._x=.25*d,this._y=(i+r)/d,this._z=(n+h)/d}else if(a>f){const d=2*Math.sqrt(1+a-s-f);this._w=(n-h)/d,this._x=(i+r)/d,this._y=.25*d,this._z=(o+c)/d}else{const d=2*Math.sqrt(1+f-s-a);this._w=(r-i)/d,this._x=(n+h)/d,this._y=(o+c)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ot(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,i=t._y,n=t._z,r=t._w,a=e._x,o=e._y,h=e._z,c=e._w;return this._x=s*c+r*a+i*h-n*o,this._y=i*c+r*o+n*a-s*h,this._z=n*c+r*h+s*o-i*a,this._w=r*c-s*a-i*o-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,i=this._y,n=this._z,r=this._w;let a=r*t._w+s*t._x+i*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=s,this._y=i,this._z=n,this;const o=1-a*a;if(o<=Number.EPSILON){const d=1-e;return this._w=d*r+e*this._w,this._x=d*s+e*this._x,this._y=d*i+e*this._y,this._z=d*n+e*this._z,this.normalize(),this._onChangeCallback(),this}const h=Math.sqrt(o),c=Math.atan2(h,a),f=Math.sin((1-e)*c)/h,l=Math.sin(e*c)/h;return this._w=r*f+this._w*l,this._x=s*f+this._x*l,this._y=i*f+this._y*l,this._z=n*f+this._z*l,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=Math.random(),e=Math.sqrt(1-t),s=Math.sqrt(t),i=2*Math.PI*Math.random(),n=2*Math.PI*Math.random();return this.set(e*Math.cos(i),s*Math.sin(n),s*Math.cos(n),e*Math.sin(i))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class M{constructor(t=0,e=0,s=0){M.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Bs.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Bs.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,n=t.elements,r=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*r,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*r,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*r,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,n=t.x,r=t.y,a=t.z,o=t.w,h=2*(r*i-a*s),c=2*(a*e-n*i),f=2*(n*s-r*e);return this.x=e+o*h+r*f-a*c,this.y=s+o*c+a*h-n*f,this.z=i+o*f+n*c-r*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,n=t.z,r=e.x,a=e.y,o=e.z;return this.x=i*o-n*a,this.y=n*r-s*o,this.z=s*a-i*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return je.copy(this).projectOnVector(t),this.sub(je)}reflect(t){return this.sub(je.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(ot(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=(Math.random()-.5)*2,e=Math.random()*Math.PI*2,s=Math.sqrt(1-t**2);return this.x=s*Math.cos(e),this.y=s*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const je=new M,Bs=new Qt;class v{constructor(t=new M(1/0,1/0,1/0),e=new M(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(et.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(et.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=et.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const s=t.geometry;if(s!==void 0){const n=s.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let r=0,a=n.count;r<a;r++)t.isMesh===!0?t.getVertexPosition(r,et):et.fromBufferAttribute(n,r),et.applyMatrix4(t.matrixWorld),this.expandByPoint(et);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),ue.copy(t.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),ue.copy(s.boundingBox)),ue.applyMatrix4(t.matrixWorld),this.union(ue)}const i=t.children;for(let n=0,r=i.length;n<r;n++)this.expandByObject(i[n],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,et),et.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Kt),fe.subVectors(this.max,Kt),Ft.subVectors(t.a,Kt),Rt.subVectors(t.b,Kt),Ut.subVectors(t.c,Kt),bt.subVectors(Rt,Ft),wt.subVectors(Ut,Rt),Pt.subVectors(Ft,Ut);let e=[0,-bt.z,bt.y,0,-wt.z,wt.y,0,-Pt.z,Pt.y,bt.z,0,-bt.x,wt.z,0,-wt.x,Pt.z,0,-Pt.x,-bt.y,bt.x,0,-wt.y,wt.x,0,-Pt.y,Pt.x,0];return!Ge(e,Ft,Rt,Ut,fe)||(e=[1,0,0,0,1,0,0,0,1],!Ge(e,Ft,Rt,Ut,fe))?!1:(de.crossVectors(bt,wt),e=[de.x,de.y,de.z],Ge(e,Ft,Rt,Ut,fe))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,et).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(et).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(ut[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ut[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ut[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ut[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ut[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ut[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ut[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ut[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ut),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ut=[new M,new M,new M,new M,new M,new M,new M,new M],et=new M,ue=new v,Ft=new M,Rt=new M,Ut=new M,bt=new M,wt=new M,Pt=new M,Kt=new M,fe=new M,de=new M,Ct=new M;function Ge(u,t,e,s,i){for(let n=0,r=u.length-3;n<=r;n+=3){Ct.fromArray(u,n);const a=i.x*Math.abs(Ct.x)+i.y*Math.abs(Ct.y)+i.z*Math.abs(Ct.z),o=t.dot(Ct),h=e.dot(Ct),c=s.dot(Ct);if(Math.max(-Math.max(o,h,c),Math.min(o,h,c))>a)return!1}return!0}const hi=new v,te=new M,Je=new M;class Ps{constructor(t=new M,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const s=this.center;e!==void 0?s.copy(e):hi.setFromPoints(t).getCenter(s);let i=0;for(let n=0,r=t.length;n<r;n++)i=Math.max(i,s.distanceToSquared(t[n]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const s=this.center.distanceToSquared(t);return e.copy(t),s>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;te.subVectors(t,this.center);const e=te.lengthSq();if(e>this.radius*this.radius){const s=Math.sqrt(e),i=(s-this.radius)*.5;this.center.addScaledVector(te,i/s),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Je.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(te.copy(t.center).add(Je)),this.expandByPoint(te.copy(t.center).sub(Je))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}class q{constructor(t,e,s,i,n,r,a,o,h,c,f,l,d,p,y,x){q.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,r,a,o,h,c,f,l,d,p,y,x)}set(t,e,s,i,n,r,a,o,h,c,f,l,d,p,y,x){const m=this.elements;return m[0]=t,m[4]=e,m[8]=s,m[12]=i,m[1]=n,m[5]=r,m[9]=a,m[13]=o,m[2]=h,m[6]=c,m[10]=f,m[14]=l,m[3]=d,m[7]=p,m[11]=y,m[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new q().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,i=1/kt.setFromMatrixColumn(t,0).length(),n=1/kt.setFromMatrixColumn(t,1).length(),r=1/kt.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*r,e[9]=s[9]*r,e[10]=s[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,n=t.z,r=Math.cos(s),a=Math.sin(s),o=Math.cos(i),h=Math.sin(i),c=Math.cos(n),f=Math.sin(n);if(t.order==="XYZ"){const l=r*c,d=r*f,p=a*c,y=a*f;e[0]=o*c,e[4]=-o*f,e[8]=h,e[1]=d+p*h,e[5]=l-y*h,e[9]=-a*o,e[2]=y-l*h,e[6]=p+d*h,e[10]=r*o}else if(t.order==="YXZ"){const l=o*c,d=o*f,p=h*c,y=h*f;e[0]=l+y*a,e[4]=p*a-d,e[8]=r*h,e[1]=r*f,e[5]=r*c,e[9]=-a,e[2]=d*a-p,e[6]=y+l*a,e[10]=r*o}else if(t.order==="ZXY"){const l=o*c,d=o*f,p=h*c,y=h*f;e[0]=l-y*a,e[4]=-r*f,e[8]=p+d*a,e[1]=d+p*a,e[5]=r*c,e[9]=y-l*a,e[2]=-r*h,e[6]=a,e[10]=r*o}else if(t.order==="ZYX"){const l=r*c,d=r*f,p=a*c,y=a*f;e[0]=o*c,e[4]=p*h-d,e[8]=l*h+y,e[1]=o*f,e[5]=y*h+l,e[9]=d*h-p,e[2]=-h,e[6]=a*o,e[10]=r*o}else if(t.order==="YZX"){const l=r*o,d=r*h,p=a*o,y=a*h;e[0]=o*c,e[4]=y-l*f,e[8]=p*f+d,e[1]=f,e[5]=r*c,e[9]=-a*c,e[2]=-h*c,e[6]=d*f+p,e[10]=l-y*f}else if(t.order==="XZY"){const l=r*o,d=r*h,p=a*o,y=a*h;e[0]=o*c,e[4]=-f,e[8]=h*c,e[1]=l*f+y,e[5]=r*c,e[9]=d*f-p,e[2]=p*f-d,e[6]=a*c,e[10]=y*f+l}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(li,t,ui)}lookAt(t,e,s){const i=this.elements;return Y.subVectors(t,e),Y.lengthSq()===0&&(Y.z=1),Y.normalize(),_t.crossVectors(s,Y),_t.lengthSq()===0&&(Math.abs(s.z)===1?Y.x+=1e-4:Y.z+=1e-4,Y.normalize(),_t.crossVectors(s,Y)),_t.normalize(),pe.crossVectors(Y,_t),i[0]=_t.x,i[4]=pe.x,i[8]=Y.x,i[1]=_t.y,i[5]=pe.y,i[9]=Y.y,i[2]=_t.z,i[6]=pe.z,i[10]=Y.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,n=this.elements,r=s[0],a=s[4],o=s[8],h=s[12],c=s[1],f=s[5],l=s[9],d=s[13],p=s[2],y=s[6],x=s[10],m=s[14],b=s[3],_=s[7],g=s[11],w=s[15],z=i[0],A=i[4],B=i[8],P=i[12],S=i[1],C=i[5],T=i[9],E=i[13],F=i[2],R=i[6],U=i[10],ct=i[14],ht=i[3],lt=i[7],Ne=i[11],ve=i[15];return n[0]=r*z+a*S+o*F+h*ht,n[4]=r*A+a*C+o*R+h*lt,n[8]=r*B+a*T+o*U+h*Ne,n[12]=r*P+a*E+o*ct+h*ve,n[1]=c*z+f*S+l*F+d*ht,n[5]=c*A+f*C+l*R+d*lt,n[9]=c*B+f*T+l*U+d*Ne,n[13]=c*P+f*E+l*ct+d*ve,n[2]=p*z+y*S+x*F+m*ht,n[6]=p*A+y*C+x*R+m*lt,n[10]=p*B+y*T+x*U+m*Ne,n[14]=p*P+y*E+x*ct+m*ve,n[3]=b*z+_*S+g*F+w*ht,n[7]=b*A+_*C+g*R+w*lt,n[11]=b*B+_*T+g*U+w*Ne,n[15]=b*P+_*E+g*ct+w*ve,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],r=t[1],a=t[5],o=t[9],h=t[13],c=t[2],f=t[6],l=t[10],d=t[14],p=t[3],y=t[7],x=t[11],m=t[15];return p*(+n*o*f-i*h*f-n*a*l+s*h*l+i*a*d-s*o*d)+y*(+e*o*d-e*h*l+n*r*l-i*r*d+i*h*c-n*o*c)+x*(+e*h*f-e*a*d-n*r*f+s*r*d+n*a*c-s*h*c)+m*(-i*a*c-e*o*f+e*a*l+i*r*f-s*r*l+s*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8],f=t[9],l=t[10],d=t[11],p=t[12],y=t[13],x=t[14],m=t[15],b=f*x*h-y*l*h+y*o*d-a*x*d-f*o*m+a*l*m,_=p*l*h-c*x*h-p*o*d+r*x*d+c*o*m-r*l*m,g=c*y*h-p*f*h+p*a*d-r*y*d-c*a*m+r*f*m,w=p*f*o-c*y*o-p*a*l+r*y*l+c*a*x-r*f*x,z=e*b+s*_+i*g+n*w;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/z;return t[0]=b*A,t[1]=(y*l*n-f*x*n-y*i*d+s*x*d+f*i*m-s*l*m)*A,t[2]=(a*x*n-y*o*n+y*i*h-s*x*h-a*i*m+s*o*m)*A,t[3]=(f*o*n-a*l*n-f*i*h+s*l*h+a*i*d-s*o*d)*A,t[4]=_*A,t[5]=(c*x*n-p*l*n+p*i*d-e*x*d-c*i*m+e*l*m)*A,t[6]=(p*o*n-r*x*n-p*i*h+e*x*h+r*i*m-e*o*m)*A,t[7]=(r*l*n-c*o*n+c*i*h-e*l*h-r*i*d+e*o*d)*A,t[8]=g*A,t[9]=(p*f*n-c*y*n-p*s*d+e*y*d+c*s*m-e*f*m)*A,t[10]=(r*y*n-p*a*n+p*s*h-e*y*h-r*s*m+e*a*m)*A,t[11]=(c*a*n-r*f*n-c*s*h+e*f*h+r*s*d-e*a*d)*A,t[12]=w*A,t[13]=(c*y*i-p*f*i+p*s*l-e*y*l-c*s*x+e*f*x)*A,t[14]=(p*a*i-r*y*i-p*s*o+e*y*o+r*s*x-e*a*x)*A,t[15]=(r*f*i-c*a*i+c*s*o-e*f*o-r*s*l+e*a*l)*A,this}scale(t){const e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),n=1-s,r=t.x,a=t.y,o=t.z,h=n*r,c=n*a;return this.set(h*r+s,h*a-i*o,h*o+i*a,0,h*a+i*o,c*a+s,c*o-i*r,0,h*o-i*a,c*o+i*r,n*o*o+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,r){return this.set(1,s,n,0,t,1,r,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,n=e._x,r=e._y,a=e._z,o=e._w,h=n+n,c=r+r,f=a+a,l=n*h,d=n*c,p=n*f,y=r*c,x=r*f,m=a*f,b=o*h,_=o*c,g=o*f,w=s.x,z=s.y,A=s.z;return i[0]=(1-(y+m))*w,i[1]=(d+g)*w,i[2]=(p-_)*w,i[3]=0,i[4]=(d-g)*z,i[5]=(1-(l+m))*z,i[6]=(x+b)*z,i[7]=0,i[8]=(p+_)*A,i[9]=(x-b)*A,i[10]=(1-(l+y))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;let n=kt.set(i[0],i[1],i[2]).length();const r=kt.set(i[4],i[5],i[6]).length(),a=kt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],st.copy(this);const h=1/n,c=1/r,f=1/a;return st.elements[0]*=h,st.elements[1]*=h,st.elements[2]*=h,st.elements[4]*=c,st.elements[5]*=c,st.elements[6]*=c,st.elements[8]*=f,st.elements[9]*=f,st.elements[10]*=f,e.setFromRotationMatrix(st),s.x=n,s.y=r,s.z=a,this}makePerspective(t,e,s,i,n,r,a=2e3){const o=this.elements,h=2*n/(e-t),c=2*n/(s-i),f=(e+t)/(e-t),l=(s+i)/(s-i);let d,p;if(a===2e3)d=-(r+n)/(r-n),p=-2*r*n/(r-n);else if(a===2001)d=-r/(r-n),p=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return o[0]=h,o[4]=0,o[8]=f,o[12]=0,o[1]=0,o[5]=c,o[9]=l,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,s,i,n,r,a=2e3){const o=this.elements,h=1/(e-t),c=1/(s-i),f=1/(r-n),l=(e+t)*h,d=(s+i)*c;let p,y;if(a===2e3)p=(r+n)*f,y=-2*f;else if(a===2001)p=n*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-l,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=y,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const kt=new M,st=new q,li=new M(0,0,0),ui=new M(1,1,1),_t=new M,pe=new M,Y=new M,Cs=new q,Es=new Qt;class me{constructor(t=0,e=0,s=0,i=me.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const i=t.elements,n=i[0],r=i[4],a=i[8],o=i[1],h=i[5],c=i[9],f=i[2],l=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(ot(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(l,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ot(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-f,n),this._z=0);break;case"ZXY":this._x=Math.asin(ot(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(-f,d),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-ot(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(l,d),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(ot(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-f,n)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-ot(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(l,h),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return Cs.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Cs,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Es.setFromEuler(this),this.setFromQuaternion(Es,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}me.DEFAULT_ORDER="XYZ";class fi{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let di=0;const Fs=new M,It=new Qt,ft=new q,ye=new M,ee=new M,pi=new M,mi=new Qt,Rs=new M(1,0,0),Us=new M(0,1,0),ks=new M(0,0,1),yi={type:"added"},xi={type:"removed"};class Mt extends Xe{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:di++}),this.uuid=le(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Mt.DEFAULT_UP.clone();const t=new M,e=new me,s=new Qt,i=new M(1,1,1);function n(){s.setFromEuler(e,!1)}function r(){e.setFromQuaternion(s,void 0,!1)}e._onChange(n),s._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new q},normalMatrix:{value:new Bt}}),this.matrix=new q,this.matrixWorld=new q,this.matrixAutoUpdate=Mt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return It.setFromAxisAngle(t,e),this.quaternion.multiply(It),this}rotateOnWorldAxis(t,e){return It.setFromAxisAngle(t,e),this.quaternion.premultiply(It),this}rotateX(t){return this.rotateOnAxis(Rs,t)}rotateY(t){return this.rotateOnAxis(Us,t)}rotateZ(t){return this.rotateOnAxis(ks,t)}translateOnAxis(t,e){return Fs.copy(t).applyQuaternion(this.quaternion),this.position.add(Fs.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Rs,t)}translateY(t){return this.translateOnAxis(Us,t)}translateZ(t){return this.translateOnAxis(ks,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(ft.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?ye.copy(t):ye.set(t,e,s);const i=this.parent;this.updateWorldMatrix(!0,!1),ee.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ft.lookAt(ee,ye,this.up):ft.lookAt(ye,ee,this.up),this.quaternion.setFromRotationMatrix(ft),i&&(ft.extractRotation(i.matrixWorld),It.setFromRotationMatrix(ft),this.quaternion.premultiply(It.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.parent!==null&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(yi)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(xi)),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),ft.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),ft.multiply(t.parent.matrixWorld)),t.applyMatrix4(ft),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let s=0,i=this.children.length;s<i;s++){const r=this.children[s].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const i=this.children;for(let n=0,r=i.length;n<r;n++)i[n].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ee,t,pi),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ee,mi,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let s=0,i=e.length;s<i;s++){const n=e[s];(n.matrixWorldAutoUpdate===!0||t===!0)&&n.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const s=this.parent;if(t===!0&&s!==null&&s.matrixWorldAutoUpdate===!0&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){const i=this.children;for(let n=0,r=i.length;n<r;n++){const a=i[n];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=t===void 0||typeof t=="string",s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function n(a,o){return a[o.uuid]===void 0&&(a[o.uuid]=o.toJSON(t)),o.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const o=a.shapes;if(Array.isArray(o))for(let h=0,c=o.length;h<c;h++){const f=o[h];n(t.shapes,f)}else n(t.shapes,o)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let o=0,h=this.material.length;o<h;o++)a.push(n(t.materials,this.material[o]));i.material=a}else i.material=n(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const o=this.animations[a];i.animations.push(n(t.animations,o))}}if(e){const a=r(t.geometries),o=r(t.materials),h=r(t.textures),c=r(t.images),f=r(t.shapes),l=r(t.skeletons),d=r(t.animations),p=r(t.nodes);a.length>0&&(s.geometries=a),o.length>0&&(s.materials=o),h.length>0&&(s.textures=h),c.length>0&&(s.images=c),f.length>0&&(s.shapes=f),l.length>0&&(s.skeletons=l),d.length>0&&(s.animations=d),p.length>0&&(s.nodes=p)}return s.object=i,s;function r(a){const o=[];for(const h in a){const c=a[h];delete c.metadata,o.push(c)}return o}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let s=0;s<t.children.length;s++){const i=t.children[s];this.add(i.clone())}return this}}Mt.DEFAULT_UP=new M(0,1,0),Mt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const it=new M,dt=new M,Qe=new M,pt=new M,Lt=new M,Vt=new M,Is=new M,Ke=new M,ts=new M,es=new M;let xe=!1;class j{constructor(t=new M,e=new M,s=new M){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,i){i.subVectors(s,e),it.subVectors(t,e),i.cross(it);const n=i.lengthSq();return n>0?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)}static getBarycoord(t,e,s,i,n){it.subVectors(i,e),dt.subVectors(s,e),Qe.subVectors(t,e);const r=it.dot(it),a=it.dot(dt),o=it.dot(Qe),h=dt.dot(dt),c=dt.dot(Qe),f=r*h-a*a;if(f===0)return n.set(-2,-1,-1);const l=1/f,d=(h*o-a*c)*l,p=(r*c-a*o)*l;return n.set(1-d-p,p,d)}static containsPoint(t,e,s,i){return this.getBarycoord(t,e,s,i,pt),pt.x>=0&&pt.y>=0&&pt.x+pt.y<=1}static getUV(t,e,s,i,n,r,a,o){return xe===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),xe=!0),this.getInterpolation(t,e,s,i,n,r,a,o)}static getInterpolation(t,e,s,i,n,r,a,o){return this.getBarycoord(t,e,s,i,pt),o.setScalar(0),o.addScaledVector(n,pt.x),o.addScaledVector(r,pt.y),o.addScaledVector(a,pt.z),o}static isFrontFacing(t,e,s,i){return it.subVectors(s,e),dt.subVectors(t,e),it.cross(dt).dot(i)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,i){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,s,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return it.subVectors(this.c,this.b),dt.subVectors(this.a,this.b),it.cross(dt).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return j.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return j.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,s,i,n){return xe===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),xe=!0),j.getInterpolation(t,this.a,this.b,this.c,e,s,i,n)}getInterpolation(t,e,s,i,n){return j.getInterpolation(t,this.a,this.b,this.c,e,s,i,n)}containsPoint(t){return j.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return j.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const s=this.a,i=this.b,n=this.c;let r,a;Lt.subVectors(i,s),Vt.subVectors(n,s),Ke.subVectors(t,s);const o=Lt.dot(Ke),h=Vt.dot(Ke);if(o<=0&&h<=0)return e.copy(s);ts.subVectors(t,i);const c=Lt.dot(ts),f=Vt.dot(ts);if(c>=0&&f<=c)return e.copy(i);const l=o*f-c*h;if(l<=0&&o>=0&&c<=0)return r=o/(o-c),e.copy(s).addScaledVector(Lt,r);es.subVectors(t,n);const d=Lt.dot(es),p=Vt.dot(es);if(p>=0&&d<=p)return e.copy(n);const y=d*h-o*p;if(y<=0&&h>=0&&p<=0)return a=h/(h-p),e.copy(s).addScaledVector(Vt,a);const x=c*p-d*f;if(x<=0&&f-c>=0&&d-p>=0)return Is.subVectors(n,i),a=(f-c)/(f-c+(d-p)),e.copy(i).addScaledVector(Is,a);const m=1/(x+y+l);return r=y*m,a=l*m,e.copy(s).addScaledVector(Lt,r).addScaledVector(Vt,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const L=new M,ge=new W;class at{constructor(t,e,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=s,this.usage=35044,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,s){t*=this.itemSize,s*=e.itemSize;for(let i=0,n=this.itemSize;i<n;i++)this.array[t+i]=e.array[s+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,s=this.count;e<s;e++)ge.fromBufferAttribute(this,e),ge.applyMatrix3(t),this.setXY(e,ge.x,ge.y);else if(this.itemSize===3)for(let e=0,s=this.count;e<s;e++)L.fromBufferAttribute(this,e),L.applyMatrix3(t),this.setXYZ(e,L.x,L.y,L.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)L.fromBufferAttribute(this,e),L.applyMatrix4(t),this.setXYZ(e,L.x,L.y,L.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)L.fromBufferAttribute(this,e),L.applyNormalMatrix(t),this.setXYZ(e,L.x,L.y,L.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)L.fromBufferAttribute(this,e),L.transformDirection(t),this.setXYZ(e,L.x,L.y,L.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let s=this.array[t*this.itemSize+e];return this.normalized&&(s=Jt(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=X(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Jt(e,this.array)),e}setX(t,e){return this.normalized&&(e=X(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Jt(e,this.array)),e}setY(t,e){return this.normalized&&(e=X(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Jt(e,this.array)),e}setZ(t,e){return this.normalized&&(e=X(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Jt(e,this.array)),e}setW(t,e){return this.normalized&&(e=X(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=X(e,this.array),s=X(s,this.array)),this.array[t+0]=e,this.array[t+1]=s,this}setXYZ(t,e,s,i){return t*=this.itemSize,this.normalized&&(e=X(e,this.array),s=X(s,this.array),i=X(i,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this}setXYZW(t,e,s,i,n){return t*=this.itemSize,this.normalized&&(e=X(e,this.array),s=X(s,this.array),i=X(i,this.array),n=X(n,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this.array[t+3]=n,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==35044&&(t.usage=this.usage),t}}class gi extends at{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class bi extends at{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class wi extends at{constructor(t,e,s){super(new Float32Array(t),e,s)}}let _i=0;const G=new q,ss=new Mt,Dt=new M,H=new v,se=new v,D=new M;class is extends Xe{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_i++}),this.uuid=le(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(ni(t)?bi:gi)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,s=0){this.groups.push({start:t,count:e,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const n=new Bt().getNormalMatrix(t);s.applyNormalMatrix(n),s.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return G.makeRotationFromQuaternion(t),this.applyMatrix4(G),this}rotateX(t){return G.makeRotationX(t),this.applyMatrix4(G),this}rotateY(t){return G.makeRotationY(t),this.applyMatrix4(G),this}rotateZ(t){return G.makeRotationZ(t),this.applyMatrix4(G),this}translate(t,e,s){return G.makeTranslation(t,e,s),this.applyMatrix4(G),this}scale(t,e,s){return G.makeScale(t,e,s),this.applyMatrix4(G),this}lookAt(t){return ss.lookAt(t),ss.updateMatrix(),this.applyMatrix4(ss.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Dt).negate(),this.translate(Dt.x,Dt.y,Dt.z),this}setFromPoints(t){const e=[];for(let s=0,i=t.length;s<i;s++){const n=t[s];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new wi(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new v);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new M(-1/0,-1/0,-1/0),new M(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let s=0,i=e.length;s<i;s++){const n=e[s];H.setFromBufferAttribute(n),this.morphTargetsRelative?(D.addVectors(this.boundingBox.min,H.min),this.boundingBox.expandByPoint(D),D.addVectors(this.boundingBox.max,H.max),this.boundingBox.expandByPoint(D)):(this.boundingBox.expandByPoint(H.min),this.boundingBox.expandByPoint(H.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ps);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new M,1/0);return}if(t){const s=this.boundingSphere.center;if(H.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const a=e[n];se.setFromBufferAttribute(a),this.morphTargetsRelative?(D.addVectors(H.min,se.min),H.expandByPoint(D),D.addVectors(H.max,se.max),H.expandByPoint(D)):(H.expandByPoint(se.min),H.expandByPoint(se.max))}H.getCenter(s);let i=0;for(let n=0,r=t.count;n<r;n++)D.fromBufferAttribute(t,n),i=Math.max(i,s.distanceToSquared(D));if(e)for(let n=0,r=e.length;n<r;n++){const a=e[n],o=this.morphTargetsRelative;for(let h=0,c=a.count;h<c;h++)D.fromBufferAttribute(a,h),o&&(Dt.fromBufferAttribute(t,h),D.add(Dt)),i=Math.max(i,s.distanceToSquared(D))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=t.array,i=e.position.array,n=e.normal.array,r=e.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new at(new Float32Array(4*a),4));const o=this.getAttribute("tangent").array,h=[],c=[];for(let S=0;S<a;S++)h[S]=new M,c[S]=new M;const f=new M,l=new M,d=new M,p=new W,y=new W,x=new W,m=new M,b=new M;function _(S,C,T){f.fromArray(i,S*3),l.fromArray(i,C*3),d.fromArray(i,T*3),p.fromArray(r,S*2),y.fromArray(r,C*2),x.fromArray(r,T*2),l.sub(f),d.sub(f),y.sub(p),x.sub(p);const E=1/(y.x*x.y-x.x*y.y);isFinite(E)&&(m.copy(l).multiplyScalar(x.y).addScaledVector(d,-y.y).multiplyScalar(E),b.copy(d).multiplyScalar(y.x).addScaledVector(l,-x.x).multiplyScalar(E),h[S].add(m),h[C].add(m),h[T].add(m),c[S].add(b),c[C].add(b),c[T].add(b))}let g=this.groups;g.length===0&&(g=[{start:0,count:s.length}]);for(let S=0,C=g.length;S<C;++S){const T=g[S],E=T.start,F=T.count;for(let R=E,U=E+F;R<U;R+=3)_(s[R+0],s[R+1],s[R+2])}const w=new M,z=new M,A=new M,B=new M;function P(S){A.fromArray(n,S*3),B.copy(A);const C=h[S];w.copy(C),w.sub(A.multiplyScalar(A.dot(C))).normalize(),z.crossVectors(B,C);const E=z.dot(c[S])<0?-1:1;o[S*4]=w.x,o[S*4+1]=w.y,o[S*4+2]=w.z,o[S*4+3]=E}for(let S=0,C=g.length;S<C;++S){const T=g[S],E=T.start,F=T.count;for(let R=E,U=E+F;R<U;R+=3)P(s[R+0]),P(s[R+1]),P(s[R+2])}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let s=this.getAttribute("normal");if(s===void 0)s=new at(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let l=0,d=s.count;l<d;l++)s.setXYZ(l,0,0,0);const i=new M,n=new M,r=new M,a=new M,o=new M,h=new M,c=new M,f=new M;if(t)for(let l=0,d=t.count;l<d;l+=3){const p=t.getX(l+0),y=t.getX(l+1),x=t.getX(l+2);i.fromBufferAttribute(e,p),n.fromBufferAttribute(e,y),r.fromBufferAttribute(e,x),c.subVectors(r,n),f.subVectors(i,n),c.cross(f),a.fromBufferAttribute(s,p),o.fromBufferAttribute(s,y),h.fromBufferAttribute(s,x),a.add(c),o.add(c),h.add(c),s.setXYZ(p,a.x,a.y,a.z),s.setXYZ(y,o.x,o.y,o.z),s.setXYZ(x,h.x,h.y,h.z)}else for(let l=0,d=e.count;l<d;l+=3)i.fromBufferAttribute(e,l+0),n.fromBufferAttribute(e,l+1),r.fromBufferAttribute(e,l+2),c.subVectors(r,n),f.subVectors(i,n),c.cross(f),s.setXYZ(l+0,c.x,c.y,c.z),s.setXYZ(l+1,c.x,c.y,c.z),s.setXYZ(l+2,c.x,c.y,c.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)D.fromBufferAttribute(t,e),D.normalize(),t.setXYZ(e,D.x,D.y,D.z)}toNonIndexed(){function t(a,o){const h=a.array,c=a.itemSize,f=a.normalized,l=new h.constructor(o.length*c);let d=0,p=0;for(let y=0,x=o.length;y<x;y++){a.isInterleavedBufferAttribute?d=o[y]*a.data.stride+a.offset:d=o[y]*c;for(let m=0;m<c;m++)l[p++]=h[d++]}return new at(l,c,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new is,s=this.index.array,i=this.attributes;for(const a in i){const o=i[a],h=t(o,s);e.setAttribute(a,h)}const n=this.morphAttributes;for(const a in n){const o=[],h=n[a];for(let c=0,f=h.length;c<f;c++){const l=h[c],d=t(l,s);o.push(d)}e.morphAttributes[a]=o}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let a=0,o=r.length;a<o;a++){const h=r[a];e.addGroup(h.start,h.count,h.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const o=this.parameters;for(const h in o)o[h]!==void 0&&(t[h]=o[h]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const s=this.attributes;for(const o in s){const h=s[o];t.data.attributes[o]=h.toJSON(t.data)}const i={};let n=!1;for(const o in this.morphAttributes){const h=this.morphAttributes[o],c=[];for(let f=0,l=h.length;f<l;f++){const d=h[f];c.push(d.toJSON(t.data))}c.length>0&&(i[o]=c,n=!0)}n&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const s=t.index;s!==null&&this.setIndex(s.clone(e));const i=t.attributes;for(const h in i){const c=i[h];this.setAttribute(h,c.clone(e))}const n=t.morphAttributes;for(const h in n){const c=[],f=n[h];for(let l=0,d=f.length;l<d;l++)c.push(f[l].clone(e));this.morphAttributes[h]=c}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let h=0,c=r.length;h<c;h++){const f=r[h];this.addGroup(f.start,f.count,f.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const o=t.boundingSphere;return o!==null&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ns=new M,Mi=new M,Ai=new Bt;class Ls{constructor(t=new M(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,i){return this.normal.set(t,e,s),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const i=ns.subVectors(s,e).cross(Mi.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const s=t.delta(ns),i=this.normal.dot(s);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const n=-(t.start.dot(this.normal)+this.constant)/i;return n<0||n>1?null:e.copy(t.start).addScaledVector(s,n)}intersectsLine(t){const e=this.distanceToPoint(t.start),s=this.distanceToPoint(t.end);return e<0&&s>0||s<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||Ai.getNormalMatrix(t),i=this.coplanarPoint(ns).applyMatrix4(t),n=this.normal.applyMatrix3(s).normalize();return this.constant=-i.dot(n),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}class zi extends gt{constructor(t,e,s,i,n,r,a,o,h,c){if(c=c!==void 0?c:1026,c!==1026&&c!==1027)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");s===void 0&&c===1026&&(s=1014),s===void 0&&c===1027&&(s=1020),super(null,i,n,r,a,o,c,s,h),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:1003,this.minFilter=o!==void 0?o:1003,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const Si=new zi(1,1);Si.compareFunction=515;const Vs=new M,be=new M;class mt{constructor(t=new M,e=new M){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Vs.subVectors(t,this.start),be.subVectors(this.end,this.start);const s=be.dot(be);let n=be.dot(Vs)/s;return e&&(n=ot(n,0,1)),n}closestPointToPoint(t,e,s){const i=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:zs}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=zs);const Ds=0,Ti=1,Bi=2,qs=2,rs=1.25,Ns=1,we=6*4+4+4,_e=65535,Pi=Math.pow(2,-24),os=Symbol("SKIP_GENERATION");function Ci(u){return u.index?u.index.count:u.attributes.position.count}function qt(u){return Ci(u)/3}function Ei(u,t=ArrayBuffer){return u>65535?new Uint32Array(new t(4*u)):new Uint16Array(new t(2*u))}function Fi(u,t){if(!u.index){const e=u.attributes.position.count,s=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Ei(e,s);u.setIndex(new at(i,1));for(let n=0;n<e;n++)i[n]=n}}function vs(u){const t=qt(u),e=u.drawRange,s=e.start/3,i=(e.start+e.count)/3,n=Math.max(0,s),r=Math.min(t,i)-n;return[{offset:Math.floor(n),count:Math.floor(r)}]}function Ws(u){if(!u.groups||!u.groups.length)return vs(u);const t=[],e=new Set,s=u.drawRange,i=s.start/3,n=(s.start+s.count)/3;for(const a of u.groups){const o=a.start/3,h=(a.start+a.count)/3;e.add(Math.max(i,o)),e.add(Math.min(n,h))}const r=Array.from(e.values()).sort((a,o)=>a-o);for(let a=0;a<r.length-1;a++){const o=r[a],h=r[a+1];t.push({offset:Math.floor(o),count:Math.floor(h-o)})}return t}function Ri(u){if(u.groups.length===0)return!1;const t=qt(u),e=Ws(u).sort((n,r)=>n.offset-r.offset),s=e[e.length-1];s.count=Math.min(t-s.offset,s.count);let i=0;return e.forEach(({count:n})=>i+=n),t!==i}function I(u,t,e){return e.min.x=t[u],e.min.y=t[u+1],e.min.z=t[u+2],e.max.x=t[u+3],e.max.y=t[u+4],e.max.z=t[u+5],e}function Ui(u){u[0]=u[1]=u[2]=1/0,u[3]=u[4]=u[5]=-1/0}function Os(u){let t=-1,e=-1/0;for(let s=0;s<3;s++){const i=u[s+3]-u[s];i>e&&(e=i,t=s)}return t}function Xs(u,t){t.set(u)}function Ys(u,t,e){let s,i;for(let n=0;n<3;n++){const r=n+3;s=u[n],i=t[n],e[n]=s<i?s:i,s=u[r],i=t[r],e[r]=s>i?s:i}}function Me(u,t,e){for(let s=0;s<3;s++){const i=t[u+2*s],n=t[u+2*s+1],r=i-n,a=i+n;r<e[s]&&(e[s]=r),a>e[s+3]&&(e[s+3]=a)}}function ie(u){const t=u[3]-u[0],e=u[4]-u[1],s=u[5]-u[2];return 2*(t*e+e*s+s*t)}function as(u,t,e,s,i=null){let n=1/0,r=1/0,a=1/0,o=-1/0,h=-1/0,c=-1/0,f=1/0,l=1/0,d=1/0,p=-1/0,y=-1/0,x=-1/0;const m=i!==null;for(let b=t*6,_=(t+e)*6;b<_;b+=6){const g=u[b+0],w=u[b+1],z=g-w,A=g+w;z<n&&(n=z),A>o&&(o=A),m&&g<f&&(f=g),m&&g>p&&(p=g);const B=u[b+2],P=u[b+3],S=B-P,C=B+P;S<r&&(r=S),C>h&&(h=C),m&&B<l&&(l=B),m&&B>y&&(y=B);const T=u[b+4],E=u[b+5],F=T-E,R=T+E;F<a&&(a=F),R>c&&(c=R),m&&T<d&&(d=T),m&&T>x&&(x=T)}s[0]=n,s[1]=r,s[2]=a,s[3]=o,s[4]=h,s[5]=c,m&&(i[0]=f,i[1]=l,i[2]=d,i[3]=p,i[4]=y,i[5]=x)}function ki(u,t,e,s){let i=1/0,n=1/0,r=1/0,a=-1/0,o=-1/0,h=-1/0;for(let c=t*6,f=(t+e)*6;c<f;c+=6){const l=u[c+0];l<i&&(i=l),l>a&&(a=l);const d=u[c+2];d<n&&(n=d),d>o&&(o=d);const p=u[c+4];p<r&&(r=p),p>h&&(h=p)}s[0]=i,s[1]=n,s[2]=r,s[3]=a,s[4]=o,s[5]=h}function Ii(u,t){Ui(t);const e=u.attributes.position,s=u.index?u.index.array:null,i=qt(u),n=new Float32Array(i*6),r=e.normalized,a=e.array,o=e.offset||0;let h=3;e.isInterleavedBufferAttribute&&(h=e.data.stride);const c=["getX","getY","getZ"];for(let f=0;f<i;f++){const l=f*3,d=f*6;let p=l+0,y=l+1,x=l+2;s&&(p=s[p],y=s[y],x=s[x]),r||(p=p*h+o,y=y*h+o,x=x*h+o);for(let m=0;m<3;m++){let b,_,g;r?(b=e[c[m]](p),_=e[c[m]](y),g=e[c[m]](x)):(b=a[p+m],_=a[y+m],g=a[x+m]);let w=b;_<w&&(w=_),g<w&&(w=g);let z=b;_>z&&(z=_),g>z&&(z=g);const A=(z-w)/2,B=m*2;n[d+B+0]=w+A,n[d+B+1]=A+(Math.abs(w)+A)*Pi,w<t[m]&&(t[m]=w),z>t[m+3]&&(t[m+3]=z)}}return n}const yt=32,Li=(u,t)=>u.candidate-t.candidate,At=new Array(yt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ae=new Float32Array(6);function Vi(u,t,e,s,i,n){let r=-1,a=0;if(n===Ds)r=Os(t),r!==-1&&(a=(t[r]+t[r+3])/2);else if(n===Ti)r=Os(u),r!==-1&&(a=Di(e,s,i,r));else if(n===Bi){const o=ie(u);let h=rs*i;const c=s*6,f=(s+i)*6;for(let l=0;l<3;l++){const d=t[l],x=(t[l+3]-d)/yt;if(i<yt/4){const m=[...At];m.length=i;let b=0;for(let g=c;g<f;g+=6,b++){const w=m[b];w.candidate=e[g+2*l],w.count=0;const{bounds:z,leftCacheBounds:A,rightCacheBounds:B}=w;for(let P=0;P<3;P++)B[P]=1/0,B[P+3]=-1/0,A[P]=1/0,A[P+3]=-1/0,z[P]=1/0,z[P+3]=-1/0;Me(g,e,z)}m.sort(Li);let _=i;for(let g=0;g<_;g++){const w=m[g];for(;g+1<_&&m[g+1].candidate===w.candidate;)m.splice(g+1,1),_--}for(let g=c;g<f;g+=6){const w=e[g+2*l];for(let z=0;z<_;z++){const A=m[z];w>=A.candidate?Me(g,e,A.rightCacheBounds):(Me(g,e,A.leftCacheBounds),A.count++)}}for(let g=0;g<_;g++){const w=m[g],z=w.count,A=i-w.count,B=w.leftCacheBounds,P=w.rightCacheBounds;let S=0;z!==0&&(S=ie(B)/o);let C=0;A!==0&&(C=ie(P)/o);const T=Ns+rs*(S*z+C*A);T<h&&(r=l,h=T,a=w.candidate)}}else{for(let _=0;_<yt;_++){const g=At[_];g.count=0,g.candidate=d+x+_*x;const w=g.bounds;for(let z=0;z<3;z++)w[z]=1/0,w[z+3]=-1/0}for(let _=c;_<f;_+=6){let z=~~((e[_+2*l]-d)/x);z>=yt&&(z=yt-1);const A=At[z];A.count++,Me(_,e,A.bounds)}const m=At[yt-1];Xs(m.bounds,m.rightCacheBounds);for(let _=yt-2;_>=0;_--){const g=At[_],w=At[_+1];Ys(g.bounds,w.rightCacheBounds,g.rightCacheBounds)}let b=0;for(let _=0;_<yt-1;_++){const g=At[_],w=g.count,z=g.bounds,B=At[_+1].rightCacheBounds;w!==0&&(b===0?Xs(z,Ae):Ys(z,Ae,Ae)),b+=w;let P=0,S=0;b!==0&&(P=ie(Ae)/o);const C=i-b;C!==0&&(S=ie(B)/o);const T=Ns+rs*(P*b+S*C);T<h&&(r=l,h=T,a=g.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:r,pos:a}}function Di(u,t,e,s){let i=0;for(let n=t,r=t+e;n<r;n++)i+=u[n*6+s*2];return i/e}class ze{constructor(){}}function qi(u,t,e,s,i,n){let r=s,a=s+i-1;const o=n.pos,h=n.axis*2;for(;;){for(;r<=a&&e[r*6+h]<o;)r++;for(;r<=a&&e[a*6+h]>=o;)a--;if(r<a){for(let c=0;c<3;c++){let f=t[r*3+c];t[r*3+c]=t[a*3+c],t[a*3+c]=f}for(let c=0;c<6;c++){let f=e[r*6+c];e[r*6+c]=e[a*6+c],e[a*6+c]=f}r++,a--}else return r}}function Ni(u,t,e,s,i,n){let r=s,a=s+i-1;const o=n.pos,h=n.axis*2;for(;;){for(;r<=a&&e[r*6+h]<o;)r++;for(;r<=a&&e[a*6+h]>=o;)a--;if(r<a){let c=u[r];u[r]=u[a],u[a]=c;for(let f=0;f<6;f++){let l=e[r*6+f];e[r*6+f]=e[a*6+f],e[a*6+f]=l}r++,a--}else return r}}function vi(u,t){const e=(u.index?u.index.count:u.attributes.position.count)/3,s=e>2**16,i=s?4:2,n=t?new SharedArrayBuffer(e*i):new ArrayBuffer(e*i),r=s?new Uint32Array(n):new Uint16Array(n);for(let a=0,o=r.length;a<o;a++)r[a]=a;return r}function Wi(u,t){const e=u.geometry,s=e.index?e.index.array:null,i=t.maxDepth,n=t.verbose,r=t.maxLeafTris,a=t.strategy,o=t.onProgress,h=qt(e),c=u._indirectBuffer;let f=!1;const l=new Float32Array(6),d=new Float32Array(6),p=Ii(e,l),y=t.indirect?Ni:qi,x=[],m=t.indirect?vs(e):Ws(e);if(m.length===1){const g=m[0],w=new ze;w.boundingData=l,ki(p,g.offset,g.count,d),_(w,g.offset,g.count,d),x.push(w)}else for(let g of m){const w=new ze;w.boundingData=new Float32Array(6),as(p,g.offset,g.count,w.boundingData,d),_(w,g.offset,g.count,d),x.push(w)}return x;function b(g){o&&o(g/h)}function _(g,w,z,A=null,B=0){if(!f&&B>=i&&(f=!0,n&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),z<=r||B>=i)return b(w+z),g.offset=w,g.count=z,g;const P=Vi(g.boundingData,A,p,w,z,a);if(P.axis===-1)return b(w+z),g.offset=w,g.count=z,g;const S=y(c,s,p,w,z,P);if(S===w||S===w+z)b(w+z),g.offset=w,g.count=z;else{g.splitAxis=P.axis;const C=new ze,T=w,E=S-w;g.left=C,C.boundingData=new Float32Array(6),as(p,T,E,C.boundingData,d),_(C,T,E,d,B+1);const F=new ze,R=S,U=z-E;g.right=F,F.boundingData=new Float32Array(6),as(p,R,U,F.boundingData,d),_(F,R,U,d,B+1)}return g}}function Oi(u,t){const e=u.geometry;t.indirect&&(u._indirectBuffer=vi(e,t.useSharedArrayBuffer),Ri(e)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),u._indirectBuffer||Fi(e,t);const s=Wi(u,t);let i,n,r;const a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let f=0;f<s.length;f++){const l=s[f];let d=h(l);const p=new o(we*d);i=new Float32Array(p),n=new Uint32Array(p),r=new Uint16Array(p),c(0,l),a.push(p)}u._roots=a;return;function h(f){return f.count?1:1+h(f.left)+h(f.right)}function c(f,l){const d=f/4,p=f/2,y=!!l.count,x=l.boundingData;for(let m=0;m<6;m++)i[d+m]=x[m];if(y){const m=l.offset,b=l.count;return n[d+6]=m,r[p+14]=b,r[p+15]=_e,f+we}else{const m=l.left,b=l.right,_=l.splitAxis;let g;if(g=c(f+we,m),g/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=g/4,g=c(g,b),n[d+7]=_,g}}}class xt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let s=1/0,i=-1/0;for(let n=0,r=t.length;n<r;n++){const o=t[n][e];s=o<s?o:s,i=o>i?o:i}this.min=s,this.max=i}setFromPoints(t,e){let s=1/0,i=-1/0;for(let n=0,r=e.length;n<r;n++){const a=e[n],o=t.dot(a);s=o<s?o:s,i=o>i?o:i}this.min=s,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}}xt.prototype.setFromBox=function(){const u=new M;return function(e,s){const i=s.min,n=s.max;let r=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){u.x=i.x*o+n.x*(1-o),u.y=i.y*h+n.y*(1-h),u.z=i.z*c+n.z*(1-c);const f=e.dot(u);r=Math.min(f,r),a=Math.max(f,a)}this.min=r,this.max=a}}();const Xi=function(){const u=new M,t=new M,e=new M;return function(i,n,r){const a=i.start,o=u,h=n.start,c=t;e.subVectors(a,h),u.subVectors(i.end,i.start),t.subVectors(n.end,n.start);const f=e.dot(c),l=c.dot(o),d=c.dot(c),p=e.dot(o),x=o.dot(o)*d-l*l;let m,b;x!==0?m=(f*l-p*d)/x:m=0,b=(f+m*l)/d,r.x=m,r.y=b}}(),cs=function(){const u=new W,t=new M,e=new M;return function(i,n,r,a){Xi(i,n,u);let o=u.x,h=u.y;if(o>=0&&o<=1&&h>=0&&h<=1){i.at(o,r),n.at(h,a);return}else if(o>=0&&o<=1){h<0?n.at(0,a):n.at(1,a),i.closestPointToPoint(a,!0,r);return}else if(h>=0&&h<=1){o<0?i.at(0,r):i.at(1,r),n.closestPointToPoint(r,!0,a);return}else{let c;o<0?c=i.start:c=i.end;let f;h<0?f=n.start:f=n.end;const l=t,d=e;if(i.closestPointToPoint(f,!0,t),n.closestPointToPoint(c,!0,e),l.distanceToSquared(f)<=d.distanceToSquared(c)){r.copy(l),a.copy(f);return}else{r.copy(c),a.copy(d);return}}}}(),Yi=function(){const u=new M,t=new M,e=new Ls,s=new mt;return function(n,r){const{radius:a,center:o}=n,{a:h,b:c,c:f}=r;if(s.start=h,s.end=c,s.closestPointToPoint(o,!0,u).distanceTo(o)<=a||(s.start=h,s.end=f,s.closestPointToPoint(o,!0,u).distanceTo(o)<=a)||(s.start=c,s.end=f,s.closestPointToPoint(o,!0,u).distanceTo(o)<=a))return!0;const y=r.getPlane(e);if(Math.abs(y.distanceToPoint(o))<=a){const m=y.projectPoint(o,t);if(r.containsPoint(m))return!0}return!1}}(),Hi=1e-15;function hs(u){return Math.abs(u)<Hi}class nt extends j{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M),this.satBounds=new Array(4).fill().map(()=>new xt),this.points=[this.a,this.b,this.c],this.sphere=new Ps,this.plane=new Ls,this.needsUpdate=!0}intersectsSphere(t){return Yi(t,this)}update(){const t=this.a,e=this.b,s=this.c,i=this.points,n=this.satAxes,r=this.satBounds,a=n[0],o=r[0];this.getNormal(a),o.setFromPoints(a,i);const h=n[1],c=r[1];h.subVectors(t,e),c.setFromPoints(h,i);const f=n[2],l=r[2];f.subVectors(e,s),l.setFromPoints(f,i);const d=n[3],p=r[3];d.subVectors(s,t),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}nt.prototype.closestPointToSegment=function(){const u=new M,t=new M,e=new mt;return function(i,n=null,r=null){const{start:a,end:o}=i,h=this.points;let c,f=1/0;for(let l=0;l<3;l++){const d=(l+1)%3;e.start.copy(h[l]),e.end.copy(h[d]),cs(e,i,u,t),c=u.distanceToSquared(t),c<f&&(f=c,n&&n.copy(u),r&&r.copy(t))}return this.closestPointToPoint(a,u),c=a.distanceToSquared(u),c<f&&(f=c,n&&n.copy(u),r&&r.copy(a)),this.closestPointToPoint(o,u),c=o.distanceToSquared(u),c<f&&(f=c,n&&n.copy(u),r&&r.copy(o)),Math.sqrt(f)}}(),nt.prototype.intersectsTriangle=function(){const u=new nt,t=new Array(3),e=new Array(3),s=new xt,i=new xt,n=new M,r=new M,a=new M,o=new M,h=new M,c=new mt,f=new mt,l=new mt,d=new M;function p(y,x,m){const b=y.points;let _=0,g=-1;for(let w=0;w<3;w++){const{start:z,end:A}=c;z.copy(b[w]),A.copy(b[(w+1)%3]),c.delta(r);const B=hs(x.distanceToPoint(z));if(hs(x.normal.dot(r))&&B){m.copy(c),_=2;break}const P=x.intersectLine(c,d);if(!P&&B&&d.copy(z),(P||B)&&!hs(d.distanceTo(A))){if(_<=1)(_===1?m.start:m.end).copy(d),B&&(g=_);else if(_>=2){(g===1?m.start:m.end).copy(d),_=2;break}if(_++,_===2&&g===-1)break}}return _}return function(x,m=null,b=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(u.copy(x),u.update(),x=u);const _=this.plane,g=x.plane;if(Math.abs(_.normal.dot(g.normal))>1-1e-10){const w=this.satBounds,z=this.satAxes;e[0]=x.a,e[1]=x.b,e[2]=x.c;for(let P=0;P<4;P++){const S=w[P],C=z[P];if(s.setFromPoints(C,e),S.isSeparated(s))return!1}const A=x.satBounds,B=x.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let P=0;P<4;P++){const S=A[P],C=B[P];if(s.setFromPoints(C,t),S.isSeparated(s))return!1}for(let P=0;P<4;P++){const S=z[P];for(let C=0;C<4;C++){const T=B[C];if(n.crossVectors(S,T),s.setFromPoints(n,t),i.setFromPoints(n,e),s.isSeparated(i))return!1}}return m&&(b||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{const w=p(this,g,f);if(w===1&&x.containsPoint(f.end))return m&&(m.start.copy(f.end),m.end.copy(f.end)),!0;if(w!==2)return!1;const z=p(x,_,l);if(z===1&&this.containsPoint(l.end))return m&&(m.start.copy(l.end),m.end.copy(l.end)),!0;if(z!==2)return!1;if(f.delta(a),l.delta(o),a.dot(o)<0){let E=l.start;l.start=l.end,l.end=E}const A=f.start.dot(a),B=f.end.dot(a),P=l.start.dot(a),S=l.end.dot(a),C=B<P,T=A<S;return A!==S&&P!==B&&C===T?!1:(m&&(h.subVectors(f.start,l.start),h.dot(a)>0?m.start.copy(f.start):m.start.copy(l.start),h.subVectors(f.end,l.end),h.dot(a)<0?m.end.copy(f.end):m.end.copy(l.end)),!0)}}}(),nt.prototype.distanceToPoint=function(){const u=new M;return function(e){return this.closestPointToPoint(e,u),e.distanceTo(u)}}(),nt.prototype.distanceToTriangle=function(){const u=new M,t=new M,e=["a","b","c"],s=new mt,i=new mt;return function(r,a=null,o=null){const h=a||o?s:null;if(this.intersectsTriangle(r,h))return(a||o)&&(a&&h.getCenter(a),o&&h.getCenter(o)),0;let c=1/0;for(let f=0;f<3;f++){let l;const d=e[f],p=r[d];this.closestPointToPoint(p,u),l=p.distanceToSquared(u),l<c&&(c=l,a&&a.copy(u),o&&o.copy(p));const y=this[d];r.closestPointToPoint(y,u),l=y.distanceToSquared(u),l<c&&(c=l,a&&a.copy(y),o&&o.copy(u))}for(let f=0;f<3;f++){const l=e[f],d=e[(f+1)%3];s.set(this[l],this[d]);for(let p=0;p<3;p++){const y=e[p],x=e[(p+1)%3];i.set(r[y],r[x]),cs(s,i,u,t);const m=u.distanceToSquared(t);m<c&&(c=m,a&&a.copy(u),o&&o.copy(t))}}return Math.sqrt(c)}}();class O{constructor(t,e,s){this.isOrientedBox=!0,this.min=new M,this.max=new M,this.matrix=new q,this.invMatrix=new q,this.points=new Array(8).fill().map(()=>new M),this.satAxes=new Array(3).fill().map(()=>new M),this.satBounds=new Array(3).fill().map(()=>new xt),this.alignedSatBounds=new Array(3).fill().map(()=>new xt),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),s&&this.matrix.copy(s)}set(t,e,s){this.min.copy(t),this.max.copy(e),this.matrix.copy(s),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}O.prototype.update=function(){return function(){const t=this.matrix,e=this.min,s=this.max,i=this.points;for(let h=0;h<=1;h++)for(let c=0;c<=1;c++)for(let f=0;f<=1;f++){const l=1*h|2*c|4*f,d=i[l];d.x=h?s.x:e.x,d.y=c?s.y:e.y,d.z=f?s.z:e.z,d.applyMatrix4(t)}const n=this.satBounds,r=this.satAxes,a=i[0];for(let h=0;h<3;h++){const c=r[h],f=n[h],l=1<<h,d=i[l];c.subVectors(a,d),f.setFromPoints(c,i)}const o=this.alignedSatBounds;o[0].setFromPointsField(i,"x"),o[1].setFromPointsField(i,"y"),o[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),O.prototype.intersectsBox=function(){const u=new xt;return function(e){this.needsUpdate&&this.update();const s=e.min,i=e.max,n=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(u.min=s.x,u.max=i.x,a[0].isSeparated(u)||(u.min=s.y,u.max=i.y,a[1].isSeparated(u))||(u.min=s.z,u.max=i.z,a[2].isSeparated(u)))return!1;for(let o=0;o<3;o++){const h=r[o],c=n[o];if(u.setFromBox(h,e),c.isSeparated(u))return!1}return!0}}(),O.prototype.intersectsTriangle=function(){const u=new nt,t=new Array(3),e=new xt,s=new xt,i=new M;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(u.copy(r),u.update(),r=u);const a=this.satBounds,o=this.satAxes;t[0]=r.a,t[1]=r.b,t[2]=r.c;for(let l=0;l<3;l++){const d=a[l],p=o[l];if(e.setFromPoints(p,t),d.isSeparated(e))return!1}const h=r.satBounds,c=r.satAxes,f=this.points;for(let l=0;l<3;l++){const d=h[l],p=c[l];if(e.setFromPoints(p,f),d.isSeparated(e))return!1}for(let l=0;l<3;l++){const d=o[l];for(let p=0;p<4;p++){const y=c[p];if(i.crossVectors(d,y),e.setFromPoints(i,t),s.setFromPoints(i,f),e.isSeparated(s))return!1}}return!0}}(),O.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),O.prototype.distanceToPoint=function(){const u=new M;return function(e){return this.closestPointToPoint(e,u),e.distanceTo(u)}}(),O.prototype.distanceToBox=function(){const u=["x","y","z"],t=new Array(12).fill().map(()=>new mt),e=new Array(12).fill().map(()=>new mt),s=new M,i=new M;return function(r,a=0,o=null,h=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(o||h)&&(r.getCenter(i),this.closestPointToPoint(i,s),r.closestPointToPoint(s,i),o&&o.copy(s),h&&h.copy(i)),0;const c=a*a,f=r.min,l=r.max,d=this.points;let p=1/0;for(let x=0;x<8;x++){const m=d[x];i.copy(m).clamp(f,l);const b=m.distanceToSquared(i);if(b<p&&(p=b,o&&o.copy(m),h&&h.copy(i),b<c))return Math.sqrt(b)}let y=0;for(let x=0;x<3;x++)for(let m=0;m<=1;m++)for(let b=0;b<=1;b++){const _=(x+1)%3,g=(x+2)%3,w=m<<_|b<<g,z=1<<x|m<<_|b<<g,A=d[w],B=d[z];t[y].set(A,B);const S=u[x],C=u[_],T=u[g],E=e[y],F=E.start,R=E.end;F[S]=f[S],F[C]=m?f[C]:l[C],F[T]=b?f[T]:l[C],R[S]=l[S],R[C]=m?f[C]:l[C],R[T]=b?f[T]:l[C],y++}for(let x=0;x<=1;x++)for(let m=0;m<=1;m++)for(let b=0;b<=1;b++){i.x=x?l.x:f.x,i.y=m?l.y:f.y,i.z=b?l.z:f.z,this.closestPointToPoint(i,s);const _=i.distanceToSquared(s);if(_<p&&(p=_,o&&o.copy(s),h&&h.copy(i),_<c))return Math.sqrt(_)}for(let x=0;x<12;x++){const m=t[x];for(let b=0;b<12;b++){const _=e[b];cs(m,_,s,i);const g=s.distanceToSquared(i);if(g<p&&(p=g,o&&o.copy(s),h&&h.copy(i),g<c))return Math.sqrt(g)}}return Math.sqrt(p)}}();class ls{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){const t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}}class Zi extends ls{constructor(){super(()=>new nt)}}const J=new Zi;function Z(u,t){return t[u+15]===65535}function $(u,t){return t[u+6]}function Q(u,t){return t[u+14]}function K(u){return u+8}function tt(u,t){return t[u+6]}function Hs(u,t){return t[u+7]}function Jn(u){return u}class $i{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=s=>{e&&t.push(e),e=s,this.float32Array=new Float32Array(s),this.uint16Array=new Uint16Array(s),this.uint32Array=new Uint32Array(s)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}}const k=new $i;let zt,Nt;const vt=[],Se=new ls(()=>new v);function ji(u,t,e,s,i,n){zt=Se.getPrimitive(),Nt=Se.getPrimitive(),vt.push(zt,Nt),k.setBuffer(u._roots[t]);const r=us(0,u.geometry,e,s,i,n);k.clearBuffer(),Se.releasePrimitive(zt),Se.releasePrimitive(Nt),vt.pop(),vt.pop();const a=vt.length;return a>0&&(Nt=vt[a-1],zt=vt[a-2]),r}function us(u,t,e,s,i=null,n=0,r=0){const{float32Array:a,uint16Array:o,uint32Array:h}=k;let c=u*2;if(Z(c,o)){const l=$(u,h),d=Q(c,o);return I(u,a,zt),s(l,d,!1,r,n+u,zt)}else{let S=function(T){const{uint16Array:E,uint32Array:F}=k;let R=T*2;for(;!Z(R,E);)T=K(T),R=T*2;return $(T,F)},C=function(T){const{uint16Array:E,uint32Array:F}=k;let R=T*2;for(;!Z(R,E);)T=tt(T,F),R=T*2;return $(T,F)+Q(R,E)};const l=K(u),d=tt(u,h);let p=l,y=d,x,m,b,_;if(i&&(b=zt,_=Nt,I(p,a,b),I(y,a,_),x=i(b),m=i(_),m<x)){p=d,y=l;const T=x;x=m,m=T,b=_}b||(b=zt,I(p,a,b));const g=Z(p*2,o),w=e(b,g,x,r+1,n+p);let z;if(w===qs){const T=S(p),F=C(p)-T;z=s(T,F,!0,r+1,n+p,b)}else z=w&&us(p,t,e,s,i,n,r+1);if(z)return!0;_=Nt,I(y,a,_);const A=Z(y*2,o),B=e(_,A,m,r+1,n+y);let P;if(B===qs){const T=S(y),F=C(y)-T;P=s(T,F,!0,r+1,n+y,_)}else P=B&&us(y,t,e,s,i,n,r+1);return!!P}}const ne=new M,fs=new M;function Gi(u,t,e={},s=0,i=1/0){const n=s*s,r=i*i;let a=1/0,o=null;if(u.shapecast({boundsTraverseOrder:c=>(ne.copy(t).clamp(c.min,c.max),ne.distanceToSquared(t)),intersectsBounds:(c,f,l)=>l<a&&l<r,intersectsTriangle:(c,f)=>{c.closestPointToPoint(t,ne);const l=t.distanceToSquared(ne);return l<a&&(fs.copy(ne),a=l,o=f),l<n}}),a===1/0)return null;const h=Math.sqrt(a);return e.point?e.point.copy(fs):e.point=fs.clone(),e.distance=h,e.faceIndex=o,e}const Wt=new M,Ot=new M,Xt=new M,Te=new W,Be=new W,Pe=new W,Zs=new M,$s=new M,js=new M,Ce=new M;function Ji(u,t,e,s,i,n){let r;return n===1?r=u.intersectTriangle(s,e,t,!0,i):r=u.intersectTriangle(t,e,s,n!==2,i),r===null?null:{distance:u.origin.distanceTo(i),point:i.clone()}}function Qi(u,t,e,s,i,n,r,a,o){Wt.fromBufferAttribute(t,n),Ot.fromBufferAttribute(t,r),Xt.fromBufferAttribute(t,a);const h=Ji(u,Wt,Ot,Xt,Ce,o);if(h){s&&(Te.fromBufferAttribute(s,n),Be.fromBufferAttribute(s,r),Pe.fromBufferAttribute(s,a),h.uv=j.getInterpolation(Ce,Wt,Ot,Xt,Te,Be,Pe,new W)),i&&(Te.fromBufferAttribute(i,n),Be.fromBufferAttribute(i,r),Pe.fromBufferAttribute(i,a),h.uv1=j.getInterpolation(Ce,Wt,Ot,Xt,Te,Be,Pe,new W)),e&&(Zs.fromBufferAttribute(e,n),$s.fromBufferAttribute(e,r),js.fromBufferAttribute(e,a),h.normal=j.getInterpolation(Ce,Wt,Ot,Xt,Zs,$s,js,new M),h.normal.dot(u.direction)>0&&h.normal.multiplyScalar(-1));const c={a:n,b:r,c:a,normal:new M,materialIndex:0};j.getNormal(Wt,Ot,Xt,c.normal),h.face=c,h.faceIndex=n}return h}function Ee(u,t,e,s,i){const n=s*3;let r=n+0,a=n+1,o=n+2;const h=u.index;u.index&&(r=h.getX(r),a=h.getX(a),o=h.getX(o));const{position:c,normal:f,uv:l,uv1:d}=u.attributes,p=Qi(e,c,f,l,d,r,a,o,t);return p?(p.faceIndex=s,i&&i.push(p),p):null}function V(u,t,e,s){const i=u.a,n=u.b,r=u.c;let a=t,o=t+1,h=t+2;e&&(a=e.getX(a),o=e.getX(o),h=e.getX(h)),i.x=s.getX(a),i.y=s.getY(a),i.z=s.getZ(a),n.x=s.getX(o),n.y=s.getY(o),n.z=s.getZ(o),r.x=s.getX(h),r.y=s.getY(h),r.z=s.getZ(h)}function Ki(u,t,e,s,i,n){const{geometry:r,_indirectBuffer:a}=u;for(let o=s,h=s+i;o<h;o++)Ee(r,t,e,o,n)}function tn(u,t,e,s,i){const{geometry:n,_indirectBuffer:r}=u;let a=1/0,o=null;for(let h=s,c=s+i;h<c;h++){let f;f=Ee(n,t,e,h),f&&f.distance<a&&(o=f,a=f.distance)}return o}function en(u,t,e,s,i,n,r){const{geometry:a}=e,{index:o}=a,h=a.attributes.position;for(let c=u,f=t+u;c<f;c++){let l;if(l=c,V(r,l*3,o,h),r.needsUpdate=!0,s(r,l,i,n))return!0}return!1}function sn(u,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=u.geometry,s=e.index?e.index.array:null,i=e.attributes.position;let n,r,a,o,h=0;const c=u._roots;for(let l=0,d=c.length;l<d;l++)n=c[l],r=new Uint32Array(n),a=new Uint16Array(n),o=new Float32Array(n),f(0,h),h+=n.byteLength;function f(l,d,p=!1){const y=l*2;if(a[y+15]===_e){const m=r[l+6],b=a[y+14];let _=1/0,g=1/0,w=1/0,z=-1/0,A=-1/0,B=-1/0;for(let P=3*m,S=3*(m+b);P<S;P++){let C=s[P];const T=i.getX(C),E=i.getY(C),F=i.getZ(C);T<_&&(_=T),T>z&&(z=T),E<g&&(g=E),E>A&&(A=E),F<w&&(w=F),F>B&&(B=F)}return o[l+0]!==_||o[l+1]!==g||o[l+2]!==w||o[l+3]!==z||o[l+4]!==A||o[l+5]!==B?(o[l+0]=_,o[l+1]=g,o[l+2]=w,o[l+3]=z,o[l+4]=A,o[l+5]=B,!0):!1}else{const m=l+8,b=r[l+6],_=m+d,g=b+d;let w=p,z=!1,A=!1;t?w||(z=t.has(_),A=t.has(g),w=!z&&!A):(z=!0,A=!0);const B=w||z,P=w||A;let S=!1;B&&(S=f(m,d,w));let C=!1;P&&(C=f(b,d,w));const T=S||C;if(T)for(let E=0;E<3;E++){const F=m+E,R=b+E,U=o[F],ct=o[F+3],ht=o[R],lt=o[R+3];o[l+E]=U<ht?U:ht,o[l+E+3]=ct>lt?ct:lt}return T}}}const Gs=new v;function St(u,t,e,s){return I(u,t,Gs),e.intersectBox(Gs,s)}function nn(u,t,e,s,i,n){const{geometry:r,_indirectBuffer:a}=u;for(let o=s,h=s+i;o<h;o++){let c=a?a[o]:o;Ee(r,t,e,c,n)}}function rn(u,t,e,s,i){const{geometry:n,_indirectBuffer:r}=u;let a=1/0,o=null;for(let h=s,c=s+i;h<c;h++){let f;f=Ee(n,t,e,r?r[h]:h),f&&f.distance<a&&(o=f,a=f.distance)}return o}function on(u,t,e,s,i,n,r){const{geometry:a}=e,{index:o}=a,h=a.attributes.position;for(let c=u,f=t+u;c<f;c++){let l;if(l=e.resolveTriangleIndex(c),V(r,l*3,o,h),r.needsUpdate=!0,s(r,l,i,n))return!0}return!1}const Js=new M;function an(u,t,e,s,i){k.setBuffer(u._roots[t]),ds(0,u,e,s,i),k.clearBuffer()}function ds(u,t,e,s,i){const{float32Array:n,uint16Array:r,uint32Array:a}=k,o=u*2;if(Z(o,r)){const c=$(u,a),f=Q(o,r);Ki(t,e,s,c,f,i)}else{const c=K(u);St(c,n,s,Js)&&ds(c,t,e,s,i);const f=tt(u,a);St(f,n,s,Js)&&ds(f,t,e,s,i)}}const Qs=new M,cn=["x","y","z"];function hn(u,t,e,s){k.setBuffer(u._roots[t]);const i=ps(0,u,e,s);return k.clearBuffer(),i}function ps(u,t,e,s){const{float32Array:i,uint16Array:n,uint32Array:r}=k;let a=u*2;if(Z(a,n)){const h=$(u,r),c=Q(a,n);return tn(t,e,s,h,c)}else{const h=Hs(u,r),c=cn[h],l=s.direction[c]>=0;let d,p;l?(d=K(u),p=tt(u,r)):(d=tt(u,r),p=K(u));const x=St(d,i,s,Qs)?ps(d,t,e,s):null;if(x){const _=x.point[c];if(l?_<=i[p+h]:_>=i[p+h+3])return x}const b=St(p,i,s,Qs)?ps(p,t,e,s):null;return x&&b?x.distance<=b.distance?x:b:x||b||null}}const Fe=new v,Yt=new nt,Ht=new nt,re=new q,Ks=new O,Re=new O;function ln(u,t,e,s){k.setBuffer(u._roots[t]);const i=ms(0,u,e,s);return k.clearBuffer(),i}function ms(u,t,e,s,i=null){const{float32Array:n,uint16Array:r,uint32Array:a}=k;let o=u*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),Ks.set(e.boundingBox.min,e.boundingBox.max,s),i=Ks),Z(o,r)){const c=t.geometry,f=c.index,l=c.attributes.position,d=e.index,p=e.attributes.position,y=$(u,a),x=Q(o,r);if(re.copy(s).invert(),e.boundsTree)return I(u,n,Re),Re.matrix.copy(re),Re.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:b=>Re.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(s),b.b.applyMatrix4(s),b.c.applyMatrix4(s),b.needsUpdate=!0;for(let _=y*3,g=(x+y)*3;_<g;_+=3)if(V(Ht,_,f,l),Ht.needsUpdate=!0,b.intersectsTriangle(Ht))return!0;return!1}});for(let m=y*3,b=(x+y)*3;m<b;m+=3){V(Yt,m,f,l),Yt.a.applyMatrix4(re),Yt.b.applyMatrix4(re),Yt.c.applyMatrix4(re),Yt.needsUpdate=!0;for(let _=0,g=d.count;_<g;_+=3)if(V(Ht,_,d,p),Ht.needsUpdate=!0,Yt.intersectsTriangle(Ht))return!0}}else{const c=u+8,f=a[u+6];return I(c,n,Fe),!!(i.intersectsBox(Fe)&&ms(c,t,e,s,i)||(I(f,n,Fe),i.intersectsBox(Fe)&&ms(f,t,e,s,i)))}}const Ue=new q,ys=new O,oe=new O,un=new M,fn=new M,dn=new M,pn=new M;function mn(u,t,e,s={},i={},n=0,r=1/0){t.boundingBox||t.computeBoundingBox(),ys.set(t.boundingBox.min,t.boundingBox.max,e),ys.needsUpdate=!0;const a=u.geometry,o=a.attributes.position,h=a.index,c=t.attributes.position,f=t.index,l=J.getPrimitive(),d=J.getPrimitive();let p=un,y=fn,x=null,m=null;i&&(x=dn,m=pn);let b=1/0,_=null,g=null;return Ue.copy(e).invert(),oe.matrix.copy(Ue),u.shapecast({boundsTraverseOrder:w=>ys.distanceToBox(w),intersectsBounds:(w,z,A)=>A<b&&A<r?(z&&(oe.min.copy(w.min),oe.max.copy(w.max),oe.needsUpdate=!0),!0):!1,intersectsRange:(w,z)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:B=>oe.distanceToBox(B),intersectsBounds:(B,P,S)=>S<b&&S<r,intersectsRange:(B,P)=>{for(let S=B,C=B+P;S<C;S++){V(d,3*S,f,c),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let T=w,E=w+z;T<E;T++){V(l,3*T,h,o),l.needsUpdate=!0;const F=l.distanceToTriangle(d,p,x);if(F<b&&(y.copy(p),m&&m.copy(x),b=F,_=T,g=S),F<n)return!0}}}});{const A=qt(t);for(let B=0,P=A;B<P;B++){V(d,3*B,f,c),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let S=w,C=w+z;S<C;S++){V(l,3*S,h,o),l.needsUpdate=!0;const T=l.distanceToTriangle(d,p,x);if(T<b&&(y.copy(p),m&&m.copy(x),b=T,_=S,g=B),T<n)return!0}}}}}),J.releasePrimitive(l),J.releasePrimitive(d),b===1/0?null:(s.point?s.point.copy(y):s.point=y.clone(),s.distance=b,s.faceIndex=_,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Ue),y.applyMatrix4(Ue),i.distance=y.sub(i.point).length(),i.faceIndex=g),s)}function yn(u,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=u.geometry,s=e.index?e.index.array:null,i=e.attributes.position;let n,r,a,o,h=0;const c=u._roots;for(let l=0,d=c.length;l<d;l++)n=c[l],r=new Uint32Array(n),a=new Uint16Array(n),o=new Float32Array(n),f(0,h),h+=n.byteLength;function f(l,d,p=!1){const y=l*2;if(a[y+15]===_e){const m=r[l+6],b=a[y+14];let _=1/0,g=1/0,w=1/0,z=-1/0,A=-1/0,B=-1/0;for(let P=m,S=m+b;P<S;P++){const C=3*u.resolveTriangleIndex(P);for(let T=0;T<3;T++){let E=C+T;E=s?s[E]:E;const F=i.getX(E),R=i.getY(E),U=i.getZ(E);F<_&&(_=F),F>z&&(z=F),R<g&&(g=R),R>A&&(A=R),U<w&&(w=U),U>B&&(B=U)}}return o[l+0]!==_||o[l+1]!==g||o[l+2]!==w||o[l+3]!==z||o[l+4]!==A||o[l+5]!==B?(o[l+0]=_,o[l+1]=g,o[l+2]=w,o[l+3]=z,o[l+4]=A,o[l+5]=B,!0):!1}else{const m=l+8,b=r[l+6],_=m+d,g=b+d;let w=p,z=!1,A=!1;t?w||(z=t.has(_),A=t.has(g),w=!z&&!A):(z=!0,A=!0);const B=w||z,P=w||A;let S=!1;B&&(S=f(m,d,w));let C=!1;P&&(C=f(b,d,w));const T=S||C;if(T)for(let E=0;E<3;E++){const F=m+E,R=b+E,U=o[F],ct=o[F+3],ht=o[R],lt=o[R+3];o[l+E]=U<ht?U:ht,o[l+E+3]=ct>lt?ct:lt}return T}}}const ti=new M;function xn(u,t,e,s,i){k.setBuffer(u._roots[t]),xs(0,u,e,s,i),k.clearBuffer()}function xs(u,t,e,s,i){const{float32Array:n,uint16Array:r,uint32Array:a}=k,o=u*2;if(Z(o,r)){const c=$(u,a),f=Q(o,r);nn(t,e,s,c,f,i)}else{const c=K(u);St(c,n,s,ti)&&xs(c,t,e,s,i);const f=tt(u,a);St(f,n,s,ti)&&xs(f,t,e,s,i)}}const ei=new M,gn=["x","y","z"];function bn(u,t,e,s){k.setBuffer(u._roots[t]);const i=gs(0,u,e,s);return k.clearBuffer(),i}function gs(u,t,e,s){const{float32Array:i,uint16Array:n,uint32Array:r}=k;let a=u*2;if(Z(a,n)){const h=$(u,r),c=Q(a,n);return rn(t,e,s,h,c)}else{const h=Hs(u,r),c=gn[h],l=s.direction[c]>=0;let d,p;l?(d=K(u),p=tt(u,r)):(d=tt(u,r),p=K(u));const x=St(d,i,s,ei)?gs(d,t,e,s):null;if(x){const _=x.point[c];if(l?_<=i[p+h]:_>=i[p+h+3])return x}const b=St(p,i,s,ei)?gs(p,t,e,s):null;return x&&b?x.distance<=b.distance?x:b:x||b||null}}const ke=new v,Zt=new nt,$t=new nt,ae=new q,si=new O,Ie=new O;function wn(u,t,e,s){k.setBuffer(u._roots[t]);const i=bs(0,u,e,s);return k.clearBuffer(),i}function bs(u,t,e,s,i=null){const{float32Array:n,uint16Array:r,uint32Array:a}=k;let o=u*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),si.set(e.boundingBox.min,e.boundingBox.max,s),i=si),Z(o,r)){const c=t.geometry,f=c.index,l=c.attributes.position,d=e.index,p=e.attributes.position,y=$(u,a),x=Q(o,r);if(ae.copy(s).invert(),e.boundsTree)return I(u,n,Ie),Ie.matrix.copy(ae),Ie.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:b=>Ie.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(s),b.b.applyMatrix4(s),b.c.applyMatrix4(s),b.needsUpdate=!0;for(let _=y,g=x+y;_<g;_++)if(V($t,3*t.resolveTriangleIndex(_),f,l),$t.needsUpdate=!0,b.intersectsTriangle($t))return!0;return!1}});for(let m=y,b=x+y;m<b;m++){const _=t.resolveTriangleIndex(m);V(Zt,3*_,f,l),Zt.a.applyMatrix4(ae),Zt.b.applyMatrix4(ae),Zt.c.applyMatrix4(ae),Zt.needsUpdate=!0;for(let g=0,w=d.count;g<w;g+=3)if(V($t,g,d,p),$t.needsUpdate=!0,Zt.intersectsTriangle($t))return!0}}else{const c=u+8,f=a[u+6];return I(c,n,ke),!!(i.intersectsBox(ke)&&bs(c,t,e,s,i)||(I(f,n,ke),i.intersectsBox(ke)&&bs(f,t,e,s,i)))}}const Le=new q,ws=new O,ce=new O,_n=new M,Mn=new M,An=new M,zn=new M;function Sn(u,t,e,s={},i={},n=0,r=1/0){t.boundingBox||t.computeBoundingBox(),ws.set(t.boundingBox.min,t.boundingBox.max,e),ws.needsUpdate=!0;const a=u.geometry,o=a.attributes.position,h=a.index,c=t.attributes.position,f=t.index,l=J.getPrimitive(),d=J.getPrimitive();let p=_n,y=Mn,x=null,m=null;i&&(x=An,m=zn);let b=1/0,_=null,g=null;return Le.copy(e).invert(),ce.matrix.copy(Le),u.shapecast({boundsTraverseOrder:w=>ws.distanceToBox(w),intersectsBounds:(w,z,A)=>A<b&&A<r?(z&&(ce.min.copy(w.min),ce.max.copy(w.max),ce.needsUpdate=!0),!0):!1,intersectsRange:(w,z)=>{if(t.boundsTree){const A=t.boundsTree;return A.shapecast({boundsTraverseOrder:B=>ce.distanceToBox(B),intersectsBounds:(B,P,S)=>S<b&&S<r,intersectsRange:(B,P)=>{for(let S=B,C=B+P;S<C;S++){const T=A.resolveTriangleIndex(S);V(d,3*T,f,c),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let E=w,F=w+z;E<F;E++){const R=u.resolveTriangleIndex(E);V(l,3*R,h,o),l.needsUpdate=!0;const U=l.distanceToTriangle(d,p,x);if(U<b&&(y.copy(p),m&&m.copy(x),b=U,_=E,g=S),U<n)return!0}}}})}else{const A=qt(t);for(let B=0,P=A;B<P;B++){V(d,3*B,f,c),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let S=w,C=w+z;S<C;S++){const T=u.resolveTriangleIndex(S);V(l,3*T,h,o),l.needsUpdate=!0;const E=l.distanceToTriangle(d,p,x);if(E<b&&(y.copy(p),m&&m.copy(x),b=E,_=S,g=B),E<n)return!0}}}}}),J.releasePrimitive(l),J.releasePrimitive(d),b===1/0?null:(s.point?s.point.copy(y):s.point=y.clone(),s.distance=b,s.faceIndex=_,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(Le),y.applyMatrix4(Le),i.distance=y.sub(i.point).length(),i.faceIndex=g),s)}function Tn(){return typeof SharedArrayBuffer<"u"}const he=new k.constructor,Ve=new k.constructor,Tt=new ls(()=>new v),jt=new v,Gt=new v,_s=new v,Ms=new v;let As=!1;function Bn(u,t,e,s){if(As)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");As=!0;const i=u._roots,n=t._roots;let r,a=0,o=0;const h=new q().copy(e).invert();for(let c=0,f=i.length;c<f;c++){he.setBuffer(i[c]),o=0;const l=Tt.getPrimitive();I(0,he.float32Array,l),l.applyMatrix4(h);for(let d=0,p=n.length;d<p&&(Ve.setBuffer(n[c]),r=rt(0,0,e,h,s,a,o,0,0,l),Ve.clearBuffer(),o+=n[d].length,!r);d++);if(Tt.releasePrimitive(l),he.clearBuffer(),a+=i[c].length,r)break}return As=!1,r}function rt(u,t,e,s,i,n=0,r=0,a=0,o=0,h=null,c=!1){let f,l;c?(f=Ve,l=he):(f=he,l=Ve);const d=f.float32Array,p=f.uint32Array,y=f.uint16Array,x=l.float32Array,m=l.uint32Array,b=l.uint16Array,_=u*2,g=t*2,w=Z(_,y),z=Z(g,b);let A=!1;if(z&&w)c?A=i($(t,m),Q(t*2,b),$(u,p),Q(u*2,y),o,r+t,a,n+u):A=i($(u,p),Q(u*2,y),$(t,m),Q(t*2,b),a,n+u,o,r+t);else if(z){const B=Tt.getPrimitive();I(t,x,B),B.applyMatrix4(e);const P=K(u),S=tt(u,p);I(P,d,jt),I(S,d,Gt);const C=B.intersectsBox(jt),T=B.intersectsBox(Gt);A=C&&rt(t,P,s,e,i,r,n,o,a+1,B,!c)||T&&rt(t,S,s,e,i,r,n,o,a+1,B,!c),Tt.releasePrimitive(B)}else{const B=K(t),P=tt(t,m);I(B,x,_s),I(P,x,Ms);const S=h.intersectsBox(_s),C=h.intersectsBox(Ms);if(S&&C)A=rt(u,B,e,s,i,n,r,a,o+1,h,c)||rt(u,P,e,s,i,n,r,a,o+1,h,c);else if(S)if(w)A=rt(u,B,e,s,i,n,r,a,o+1,h,c);else{const T=Tt.getPrimitive();T.copy(_s).applyMatrix4(e);const E=K(u),F=tt(u,p);I(E,d,jt),I(F,d,Gt);const R=T.intersectsBox(jt),U=T.intersectsBox(Gt);A=R&&rt(B,E,s,e,i,r,n,o,a+1,T,!c)||U&&rt(B,F,s,e,i,r,n,o,a+1,T,!c),Tt.releasePrimitive(T)}else if(C)if(w)A=rt(u,P,e,s,i,n,r,a,o+1,h,c);else{const T=Tt.getPrimitive();T.copy(Ms).applyMatrix4(e);const E=K(u),F=tt(u,p);I(E,d,jt),I(F,d,Gt);const R=T.intersectsBox(jt),U=T.intersectsBox(Gt);A=R&&rt(P,E,s,e,i,r,n,o,a+1,T,!c)||U&&rt(P,F,s,e,i,r,n,o,a+1,T,!c),Tt.releasePrimitive(T)}}return A}const De=new O,ii=new v;class qe{static serialize(t,e={}){e={cloneBuffers:!0,...e};const s=t.geometry,i=t._roots,n=t._indirectBuffer,r=s.getIndex();let a;return e.cloneBuffers?a={roots:i.map(o=>o.slice()),index:r.array.slice(),indirectBuffer:n?n.slice():null}:a={roots:i,index:r.array,indirectBuffer:n},a}static deserialize(t,e,s={}){s={setIndex:!0,indirect:!!t.indirectBuffer,...s};const{index:i,roots:n,indirectBuffer:r}=t,a=new qe(e,{...s,[os]:!0});if(a._roots=n,a._indirectBuffer=r||null,s.setIndex){const o=e.getIndex();if(o===null){const h=new at(t.index,1,!1);e.setIndex(h)}else o.array!==i&&(o.array.set(i),o.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:Ds,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[os]:!1},e),e.useSharedArrayBuffer&&!Tn())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[os]||(Oi(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new v)));const{_indirectBuffer:s}=this;this.resolveTriangleIndex=e.indirect?i=>s[i]:i=>i}refit(t=null){return(this.indirect?yn:sn)(this,t)}traverse(t,e=0){const s=this._roots[e],i=new Uint32Array(s),n=new Uint16Array(s);r(0);function r(a,o=0){const h=a*2,c=n[h+15]===_e;if(c){const f=i[a+6],l=n[h+14];t(o,c,new Float32Array(s,a*4,6),f,l)}else{const f=a+we/4,l=i[a+6],d=i[a+7];t(o,c,new Float32Array(s,a*4,6),d)||(r(f,o+1),r(l,o+1))}}}raycast(t,e=0){const s=this._roots,i=this.geometry,n=[],r=e.isMaterial,a=Array.isArray(e),o=i.groups,h=r?e.side:e,c=this.indirect?xn:an;for(let f=0,l=s.length;f<l;f++){const d=a?e[o[f].materialIndex].side:h,p=n.length;if(c(this,f,d,t,n),a){const y=o[f].materialIndex;for(let x=p,m=n.length;x<m;x++)n[x].face.materialIndex=y}}return n}raycastFirst(t,e=0){const s=this._roots,i=this.geometry,n=e.isMaterial,r=Array.isArray(e);let a=null;const o=i.groups,h=n?e.side:e,c=this.indirect?bn:hn;for(let f=0,l=s.length;f<l;f++){const d=r?e[o[f].materialIndex].side:h,p=c(this,f,d,t);p!=null&&(a==null||p.distance<a.distance)&&(a=p,r&&(p.face.materialIndex=o[f].materialIndex))}return a}intersectsGeometry(t,e){let s=!1;const i=this._roots,n=this.indirect?wn:ln;for(let r=0,a=i.length;r<a&&(s=n(this,r,t,e),!s);r++);return s}shapecast(t){const e=J.getPrimitive(),s=this.indirect?on:en;let{boundsTraverseOrder:i,intersectsBounds:n,intersectsRange:r,intersectsTriangle:a}=t;if(r&&a){const f=r;r=(l,d,p,y,x)=>f(l,d,p,y,x)?!0:s(l,d,this,a,p,y,e)}else r||(a?r=(f,l,d,p)=>s(f,l,this,a,d,p,e):r=(f,l,d)=>d);let o=!1,h=0;const c=this._roots;for(let f=0,l=c.length;f<l;f++){const d=c[f];if(o=ji(this,f,n,r,i,h),o)break;h+=d.byteLength}return J.releasePrimitive(e),o}bvhcast(t,e,s){let{intersectsRanges:i,intersectsTriangles:n}=s;const r=J.getPrimitive(),a=this.geometry.index,o=this.geometry.attributes.position,h=this.indirect?p=>{const y=this.resolveTriangleIndex(p);V(r,y*3,a,o)}:p=>{V(r,p*3,a,o)},c=J.getPrimitive(),f=t.geometry.index,l=t.geometry.attributes.position,d=t.indirect?p=>{const y=t.resolveTriangleIndex(p);V(c,y*3,f,l)}:p=>{V(c,p*3,f,l)};if(n){const p=(y,x,m,b,_,g,w,z)=>{for(let A=m,B=m+b;A<B;A++){d(A),c.a.applyMatrix4(e),c.b.applyMatrix4(e),c.c.applyMatrix4(e),c.needsUpdate=!0;for(let P=y,S=y+x;P<S;P++)if(h(P),r.needsUpdate=!0,n(r,c,P,A,_,g,w,z))return!0}return!1};if(i){const y=i;i=function(x,m,b,_,g,w,z,A){return y(x,m,b,_,g,w,z,A)?!0:p(x,m,b,_,g,w,z,A)}}else i=p}return Bn(this,t,e,i)}intersectsBox(t,e){return De.set(t.min,t.max,e),De.needsUpdate=!0,this.shapecast({intersectsBounds:s=>De.intersectsBox(s),intersectsTriangle:s=>De.intersectsTriangle(s)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,s={},i={},n=0,r=1/0){return(this.indirect?Sn:mn)(this,t,e,s,i,n,r)}closestPointToPoint(t,e={},s=0,i=1/0){return Gi(this,t,e,s,i)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(s=>{I(0,new Float32Array(s),ii),t.union(ii)}),t}}onmessage=function({data:u}){let t=performance.now();function e(r){const a=performance.now();(a-t>=10||r===1)&&(postMessage({error:null,serialized:null,position:null,progress:r}),t=a)}const{index:s,position:i,options:n}=u;try{const r=new is;if(r.setAttribute("position",new at(i,3,!1)),s&&r.setIndex(new at(s,1,!1)),n.includedProgressCallback&&(n.onProgress=e),n.groups){const c=n.groups;for(const f in c){const l=c[f];r.addGroup(l.start,l.count,l.materialIndex)}}const a=new qe(r,n),o=qe.serialize(a,{copyIndexBuffer:!1}),h=[o.index.buffer,i.buffer,...o.roots].filter(c=>typeof SharedArrayBuffer>"u"||!(c instanceof SharedArrayBuffer));a._indirectBuffer&&h.push(o.indirectBuffer.buffer),postMessage({error:null,serialized:o,position:i,progress:1},h)}catch(r){postMessage({error:r,serialized:null,position:null,progress:1})}}})();