shop-components 0.1.64 → 0.1.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shop-components",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "description": "Shop components",
5
5
  "main": "dist/shop-components.umd.js",
6
6
  "module": "dist/shop-components.mjs",
@@ -1,5 +0,0 @@
1
- (function(){"use strict";/**
2
- * @license
3
- * Copyright 2010-2024 Three.js Authors
4
- * SPDX-License-Identifier: MIT
5
- */const ze="164",ss="";class Jt{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,o=i.length;n<o;n++)i[n].call(this,t);t.target=null}}}const R=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Ae=1234567;const Se=Math.PI/180,Te=180/Math.PI;function Tt(){const u=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(R[u&255]+R[u>>8&255]+R[u>>16&255]+R[u>>24&255]+"-"+R[t&255]+R[t>>8&255]+"-"+R[t>>16&15|64]+R[t>>24&255]+"-"+R[e&63|128]+R[e>>8&255]+"-"+R[e>>16&255]+R[e>>24&255]+R[s&255]+R[s>>8&255]+R[s>>16&255]+R[s>>24&255]).toLowerCase()}function q(u,t,e){return Math.max(t,Math.min(e,u))}function Be(u,t){return(u%t+t)%t}function is(u,t,e,s,i){return s+(u-t)*(i-s)/(e-t)}function ns(u,t,e){return u!==t?(e-u)/(t-u):0}function Pe(u,t,e){return(1-e)*u+e*t}function rs(u,t,e,s){return Pe(u,t,1-Math.exp(-e*s))}function os(u,t=1){return t-Math.abs(Be(u,t*2)-t)}function as(u,t,e){return u<=t?0:u>=e?1:(u=(u-t)/(e-t),u*u*(3-2*u))}function hs(u,t,e){return u<=t?0:u>=e?1:(u=(u-t)/(e-t),u*u*u*(u*(u*6-15)+10))}function cs(u,t){return u+Math.floor(Math.random()*(t-u+1))}function us(u,t){return u+Math.random()*(t-u)}function ls(u){return u*(.5-Math.random())}function ds(u){u!==void 0&&(Ae=u);let t=Ae+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function ms(u){return u*Se}function fs(u){return u*Te}function ps(u){return(u&u-1)===0&&u!==0}function ys(u){return Math.pow(2,Math.ceil(Math.log(u)/Math.LN2))}function xs(u){return Math.pow(2,Math.floor(Math.log(u)/Math.LN2))}function gs(u,t,e,s,i){const n=Math.cos,o=Math.sin,r=n(e/2),a=o(e/2),c=n((t+s)/2),h=o((t+s)/2),l=n((t-s)/2),d=o((t-s)/2),m=n((s-t)/2),f=o((s-t)/2);switch(i){case"XYX":u.set(r*h,a*l,a*d,r*c);break;case"YZY":u.set(a*d,r*h,a*l,r*c);break;case"ZXZ":u.set(a*l,a*d,r*h,r*c);break;case"XZX":u.set(r*h,a*f,a*m,r*c);break;case"YXY":u.set(a*m,r*h,a*f,r*c);break;case"ZYZ":u.set(a*f,a*m,r*h,r*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function mt(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 D(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.")}}const bs={DEG2RAD:Se,RAD2DEG:Te,generateUUID:Tt,clamp:q,euclideanModulo:Be,mapLinear:is,inverseLerp:ns,lerp:Pe,damp:rs,pingpong:os,smoothstep:as,smootherstep:hs,randInt:cs,randFloat:us,randFloatSpread:ls,seededRandom:ds,degToRad:ms,radToDeg:fs,isPowerOfTwo:ps,ceilPowerOfTwo:ys,floorPowerOfTwo:xs,setQuaternionFromProperEuler:gs,normalize:D,denormalize:mt};class Y{constructor(t=0,e=0){Y.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(q(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,o=this.y-t.y;return this.x=n*s-o*i+t.x,this.y=n*i+o*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ht{constructor(t,e,s,i,n,o,r,a,c){ht.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,o,r,a,c)}set(t,e,s,i,n,o,r,a,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=r,h[3]=e,h[4]=n,h[5]=a,h[6]=s,h[7]=o,h[8]=c,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,o=s[0],r=s[3],a=s[6],c=s[1],h=s[4],l=s[7],d=s[2],m=s[5],f=s[8],x=i[0],y=i[3],p=i[6],A=i[1],b=i[4],M=i[7],w=i[2],z=i[5],_=i[8];return n[0]=o*x+r*A+a*w,n[3]=o*y+r*b+a*z,n[6]=o*p+r*M+a*_,n[1]=c*x+h*A+l*w,n[4]=c*y+h*b+l*z,n[7]=c*p+h*M+l*_,n[2]=d*x+m*A+f*w,n[5]=d*y+m*b+f*z,n[8]=d*p+m*M+f*_,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],o=t[4],r=t[5],a=t[6],c=t[7],h=t[8];return e*o*h-e*r*c-s*n*h+s*r*a+i*n*c-i*o*a}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],o=t[4],r=t[5],a=t[6],c=t[7],h=t[8],l=h*o-r*c,d=r*a-h*n,m=c*n-o*a,f=e*l+s*d+i*m;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/f;return t[0]=l*x,t[1]=(i*c-h*s)*x,t[2]=(r*s-i*o)*x,t[3]=d*x,t[4]=(h*e-i*a)*x,t[5]=(i*n-r*e)*x,t[6]=m*x,t[7]=(s*a-c*e)*x,t[8]=(o*e-s*n)*x,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,o,r){const a=Math.cos(n),c=Math.sin(n);return this.set(s*a,s*c,-s*(a*o+c*r)+o+t,-i*c,i*a,-i*(-c*o+a*r)+r+e,0,0,1),this}scale(t,e){return this.premultiply(Qt.makeScale(t,e)),this}rotate(t){return this.premultiply(Qt.makeRotation(-t)),this}translate(t,e){return this.premultiply(Qt.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 Qt=new ht;function ws(u){for(let t=u.length-1;t>=0;--t)if(u[t]>=65535)return!0;return!1}function Ce(u){return document.createElementNS("http://www.w3.org/1999/xhtml",u)}const Ee={};function Ms(u){u in Ee||(Ee[u]=!0,console.warn(u))}function Kt(u){return u<.04045?u*.0773993808:Math.pow(u*.9478672986+.0521327014,2.4)}let ft;class _s{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ft===void 0&&(ft=Ce("canvas")),ft.width=t.width,ft.height=t.height;const s=ft.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),e=ft}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=Ce("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 o=0;o<n.length;o++)n[o]=Kt(n[o]/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(Kt(e[s]/255)*255):e[s]=Kt(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 zs=0;class As{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zs++}),this.uuid=Tt(),this.data=t,this.dataReady=!0,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 o=0,r=i.length;o<r;o++)i[o].isDataTexture?n.push(te(i[o].image)):n.push(te(i[o]))}else n=te(i);s.url=n}return e||(t.images[this.uuid]=s),s}}function te(u){return typeof HTMLImageElement<"u"&&u instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&u instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&u instanceof ImageBitmap?_s.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 Ss=0;class et extends Jt{constructor(t=et.DEFAULT_IMAGE,e=et.DEFAULT_MAPPING,s=1001,i=1001,n=1006,o=1008,r=1023,a=1009,c=et.DEFAULT_ANISOTROPY,h=ss){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ss++}),this.uuid=Tt(),this.name="",this.source=new As(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=n,this.minFilter=o,this.anisotropy=c,this.format=r,this.internalFormat=null,this.type=a,this.offset=new Y(0,0),this.repeat=new Y(1,1),this.center=new Y(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ht,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}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)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}et.DEFAULT_IMAGE=null,et.DEFAULT_MAPPING=300,et.DEFAULT_ANISOTROPY=1;class Bt{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,o,r){let a=s[i+0],c=s[i+1],h=s[i+2],l=s[i+3];const d=n[o+0],m=n[o+1],f=n[o+2],x=n[o+3];if(r===0){t[e+0]=a,t[e+1]=c,t[e+2]=h,t[e+3]=l;return}if(r===1){t[e+0]=d,t[e+1]=m,t[e+2]=f,t[e+3]=x;return}if(l!==x||a!==d||c!==m||h!==f){let y=1-r;const p=a*d+c*m+h*f+l*x,A=p>=0?1:-1,b=1-p*p;if(b>Number.EPSILON){const w=Math.sqrt(b),z=Math.atan2(w,p*A);y=Math.sin(y*z)/w,r=Math.sin(r*z)/w}const M=r*A;if(a=a*y+d*M,c=c*y+m*M,h=h*y+f*M,l=l*y+x*M,y===1-r){const w=1/Math.sqrt(a*a+c*c+h*h+l*l);a*=w,c*=w,h*=w,l*=w}}t[e]=a,t[e+1]=c,t[e+2]=h,t[e+3]=l}static multiplyQuaternionsFlat(t,e,s,i,n,o){const r=s[i],a=s[i+1],c=s[i+2],h=s[i+3],l=n[o],d=n[o+1],m=n[o+2],f=n[o+3];return t[e]=r*f+h*l+a*m-c*d,t[e+1]=a*f+h*d+c*l-r*m,t[e+2]=c*f+h*m+r*d-a*l,t[e+3]=h*f-r*l-a*d-c*m,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=!0){const s=t._x,i=t._y,n=t._z,o=t._order,r=Math.cos,a=Math.sin,c=r(s/2),h=r(i/2),l=r(n/2),d=a(s/2),m=a(i/2),f=a(n/2);switch(o){case"XYZ":this._x=d*h*l+c*m*f,this._y=c*m*l-d*h*f,this._z=c*h*f+d*m*l,this._w=c*h*l-d*m*f;break;case"YXZ":this._x=d*h*l+c*m*f,this._y=c*m*l-d*h*f,this._z=c*h*f-d*m*l,this._w=c*h*l+d*m*f;break;case"ZXY":this._x=d*h*l-c*m*f,this._y=c*m*l+d*h*f,this._z=c*h*f+d*m*l,this._w=c*h*l-d*m*f;break;case"ZYX":this._x=d*h*l-c*m*f,this._y=c*m*l+d*h*f,this._z=c*h*f-d*m*l,this._w=c*h*l+d*m*f;break;case"YZX":this._x=d*h*l+c*m*f,this._y=c*m*l+d*h*f,this._z=c*h*f-d*m*l,this._w=c*h*l-d*m*f;break;case"XZY":this._x=d*h*l-c*m*f,this._y=c*m*l-d*h*f,this._z=c*h*f+d*m*l,this._w=c*h*l+d*m*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&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],o=e[1],r=e[5],a=e[9],c=e[2],h=e[6],l=e[10],d=s+r+l;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(h-a)*m,this._y=(n-c)*m,this._z=(o-i)*m}else if(s>r&&s>l){const m=2*Math.sqrt(1+s-r-l);this._w=(h-a)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(n+c)/m}else if(r>l){const m=2*Math.sqrt(1+r-s-l);this._w=(n-c)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(a+h)/m}else{const m=2*Math.sqrt(1+l-s-r);this._w=(o-i)/m,this._x=(n+c)/m,this._y=(a+h)/m,this._z=.25*m}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(q(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,o=t._w,r=e._x,a=e._y,c=e._z,h=e._w;return this._x=s*h+o*r+i*c-n*a,this._y=i*h+o*a+n*r-s*c,this._z=n*h+o*c+s*a-i*r,this._w=o*h-s*r-i*a-n*c,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,o=this._w;let r=o*t._w+s*t._x+i*t._y+n*t._z;if(r<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,r=-r):this.copy(t),r>=1)return this._w=o,this._x=s,this._y=i,this._z=n,this;const a=1-r*r;if(a<=Number.EPSILON){const m=1-e;return this._w=m*o+e*this._w,this._x=m*s+e*this._x,this._y=m*i+e*this._y,this._z=m*n+e*this._z,this.normalize(),this}const c=Math.sqrt(a),h=Math.atan2(c,r),l=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=o*l+this._w*d,this._x=s*l+this._x*d,this._y=i*l+this._y*d,this._z=n*l+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}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._onChangeCallback(),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 g{constructor(t=0,e=0,s=0){g.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(Fe.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Fe.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,o=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])*o,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*o,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*o,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,n=t.x,o=t.y,r=t.z,a=t.w,c=2*(o*i-r*s),h=2*(r*e-n*i),l=2*(n*s-o*e);return this.x=e+a*c+o*l-r*h,this.y=s+a*h+r*c-n*l,this.z=i+a*l+n*h-o*c,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,o=e.x,r=e.y,a=e.z;return this.x=i*a-n*r,this.y=n*o-s*a,this.z=s*r-i*o,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 ee.copy(this).projectOnVector(t),this.sub(ee)}reflect(t){return this.sub(ee.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(q(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()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ee=new g,Fe=new Bt;class G{constructor(t=new g(1/0,1/0,1/0),e=new g(-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(O.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(O.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=O.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 o=0,r=n.count;o<r;o++)t.isMesh===!0?t.getVertexPosition(o,O):O.fromBufferAttribute(n,o),O.applyMatrix4(t.matrixWorld),this.expandByPoint(O);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Dt.copy(t.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),Dt.copy(s.boundingBox)),Dt.applyMatrix4(t.matrixWorld),this.union(Dt)}const i=t.children;for(let n=0,o=i.length;n<o;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,O),O.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(Pt),Lt.subVectors(this.max,Pt),pt.subVectors(t.a,Pt),yt.subVectors(t.b,Pt),xt.subVectors(t.c,Pt),st.subVectors(yt,pt),it.subVectors(xt,yt),ct.subVectors(pt,xt);let e=[0,-st.z,st.y,0,-it.z,it.y,0,-ct.z,ct.y,st.z,0,-st.x,it.z,0,-it.x,ct.z,0,-ct.x,-st.y,st.x,0,-it.y,it.x,0,-ct.y,ct.x,0];return!se(e,pt,yt,xt,Lt)||(e=[1,0,0,0,1,0,0,0,1],!se(e,pt,yt,xt,Lt))?!1:(Nt.crossVectors(st,it),e=[Nt.x,Nt.y,Nt.z],se(e,pt,yt,xt,Lt))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,O).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(O).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:(H[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),H[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),H[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),H[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),H[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),H[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),H[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),H[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(H),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 H=[new g,new g,new g,new g,new g,new g,new g,new g],O=new g,Dt=new G,pt=new g,yt=new g,xt=new g,st=new g,it=new g,ct=new g,Pt=new g,Lt=new g,Nt=new g,ut=new g;function se(u,t,e,s,i){for(let n=0,o=u.length-3;n<=o;n+=3){ut.fromArray(u,n);const r=i.x*Math.abs(ut.x)+i.y*Math.abs(ut.y)+i.z*Math.abs(ut.z),a=t.dot(ut),c=e.dot(ut),h=s.dot(ut);if(Math.max(-Math.max(a,c,h),Math.min(a,c,h))>r)return!1}return!0}const Ts=new G,Ct=new g,ie=new g;class ke{constructor(t=new g,e=-1){this.isSphere=!0,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):Ts.setFromPoints(t).getCenter(s);let i=0;for(let n=0,o=t.length;n<o;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;Ct.subVectors(t,this.center);const e=Ct.lengthSq();if(e>this.radius*this.radius){const s=Math.sqrt(e),i=(s-this.radius)*.5;this.center.addScaledVector(Ct,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):(ie.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ct.copy(t.center).add(ie)),this.expandByPoint(Ct.copy(t.center).sub(ie))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}class Z{constructor(t,e,s,i,n,o,r,a,c,h,l,d,m,f,x,y){Z.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,o,r,a,c,h,l,d,m,f,x,y)}set(t,e,s,i,n,o,r,a,c,h,l,d,m,f,x,y){const p=this.elements;return p[0]=t,p[4]=e,p[8]=s,p[12]=i,p[1]=n,p[5]=o,p[9]=r,p[13]=a,p[2]=c,p[6]=h,p[10]=l,p[14]=d,p[3]=m,p[7]=f,p[11]=x,p[15]=y,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 Z().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/gt.setFromMatrixColumn(t,0).length(),n=1/gt.setFromMatrixColumn(t,1).length(),o=1/gt.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]*o,e[9]=s[9]*o,e[10]=s[10]*o,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,o=Math.cos(s),r=Math.sin(s),a=Math.cos(i),c=Math.sin(i),h=Math.cos(n),l=Math.sin(n);if(t.order==="XYZ"){const d=o*h,m=o*l,f=r*h,x=r*l;e[0]=a*h,e[4]=-a*l,e[8]=c,e[1]=m+f*c,e[5]=d-x*c,e[9]=-r*a,e[2]=x-d*c,e[6]=f+m*c,e[10]=o*a}else if(t.order==="YXZ"){const d=a*h,m=a*l,f=c*h,x=c*l;e[0]=d+x*r,e[4]=f*r-m,e[8]=o*c,e[1]=o*l,e[5]=o*h,e[9]=-r,e[2]=m*r-f,e[6]=x+d*r,e[10]=o*a}else if(t.order==="ZXY"){const d=a*h,m=a*l,f=c*h,x=c*l;e[0]=d-x*r,e[4]=-o*l,e[8]=f+m*r,e[1]=m+f*r,e[5]=o*h,e[9]=x-d*r,e[2]=-o*c,e[6]=r,e[10]=o*a}else if(t.order==="ZYX"){const d=o*h,m=o*l,f=r*h,x=r*l;e[0]=a*h,e[4]=f*c-m,e[8]=d*c+x,e[1]=a*l,e[5]=x*c+d,e[9]=m*c-f,e[2]=-c,e[6]=r*a,e[10]=o*a}else if(t.order==="YZX"){const d=o*a,m=o*c,f=r*a,x=r*c;e[0]=a*h,e[4]=x-d*l,e[8]=f*l+m,e[1]=l,e[5]=o*h,e[9]=-r*h,e[2]=-c*h,e[6]=m*l+f,e[10]=d-x*l}else if(t.order==="XZY"){const d=o*a,m=o*c,f=r*a,x=r*c;e[0]=a*h,e[4]=-l,e[8]=c*h,e[1]=d*l+x,e[5]=o*h,e[9]=m*l-f,e[2]=f*l-m,e[6]=r*h,e[10]=x*l+d}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(Bs,t,Ps)}lookAt(t,e,s){const i=this.elements;return L.subVectors(t,e),L.lengthSq()===0&&(L.z=1),L.normalize(),nt.crossVectors(s,L),nt.lengthSq()===0&&(Math.abs(s.z)===1?L.x+=1e-4:L.z+=1e-4,L.normalize(),nt.crossVectors(s,L)),nt.normalize(),Vt.crossVectors(L,nt),i[0]=nt.x,i[4]=Vt.x,i[8]=L.x,i[1]=nt.y,i[5]=Vt.y,i[9]=L.y,i[2]=nt.z,i[6]=Vt.z,i[10]=L.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,o=s[0],r=s[4],a=s[8],c=s[12],h=s[1],l=s[5],d=s[9],m=s[13],f=s[2],x=s[6],y=s[10],p=s[14],A=s[3],b=s[7],M=s[11],w=s[15],z=i[0],_=i[4],T=i[8],S=i[12],P=i[1],B=i[5],E=i[9],C=i[13],k=i[2],U=i[6],tt=i[10],X=i[14],dt=i[3],Ht=i[7],jt=i[11],$t=i[15];return n[0]=o*z+r*P+a*k+c*dt,n[4]=o*_+r*B+a*U+c*Ht,n[8]=o*T+r*E+a*tt+c*jt,n[12]=o*S+r*C+a*X+c*$t,n[1]=h*z+l*P+d*k+m*dt,n[5]=h*_+l*B+d*U+m*Ht,n[9]=h*T+l*E+d*tt+m*jt,n[13]=h*S+l*C+d*X+m*$t,n[2]=f*z+x*P+y*k+p*dt,n[6]=f*_+x*B+y*U+p*Ht,n[10]=f*T+x*E+y*tt+p*jt,n[14]=f*S+x*C+y*X+p*$t,n[3]=A*z+b*P+M*k+w*dt,n[7]=A*_+b*B+M*U+w*Ht,n[11]=A*T+b*E+M*tt+w*jt,n[15]=A*S+b*C+M*X+w*$t,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],o=t[1],r=t[5],a=t[9],c=t[13],h=t[2],l=t[6],d=t[10],m=t[14],f=t[3],x=t[7],y=t[11],p=t[15];return f*(+n*a*l-i*c*l-n*r*d+s*c*d+i*r*m-s*a*m)+x*(+e*a*m-e*c*d+n*o*d-i*o*m+i*c*h-n*a*h)+y*(+e*c*l-e*r*m-n*o*l+s*o*m+n*r*h-s*c*h)+p*(-i*r*h-e*a*l+e*r*d+i*o*l-s*o*d+s*a*h)}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],o=t[4],r=t[5],a=t[6],c=t[7],h=t[8],l=t[9],d=t[10],m=t[11],f=t[12],x=t[13],y=t[14],p=t[15],A=l*y*c-x*d*c+x*a*m-r*y*m-l*a*p+r*d*p,b=f*d*c-h*y*c-f*a*m+o*y*m+h*a*p-o*d*p,M=h*x*c-f*l*c+f*r*m-o*x*m-h*r*p+o*l*p,w=f*l*a-h*x*a-f*r*d+o*x*d+h*r*y-o*l*y,z=e*A+s*b+i*M+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 _=1/z;return t[0]=A*_,t[1]=(x*d*n-l*y*n-x*i*m+s*y*m+l*i*p-s*d*p)*_,t[2]=(r*y*n-x*a*n+x*i*c-s*y*c-r*i*p+s*a*p)*_,t[3]=(l*a*n-r*d*n-l*i*c+s*d*c+r*i*m-s*a*m)*_,t[4]=b*_,t[5]=(h*y*n-f*d*n+f*i*m-e*y*m-h*i*p+e*d*p)*_,t[6]=(f*a*n-o*y*n-f*i*c+e*y*c+o*i*p-e*a*p)*_,t[7]=(o*d*n-h*a*n+h*i*c-e*d*c-o*i*m+e*a*m)*_,t[8]=M*_,t[9]=(f*l*n-h*x*n-f*s*m+e*x*m+h*s*p-e*l*p)*_,t[10]=(o*x*n-f*r*n+f*s*c-e*x*c-o*s*p+e*r*p)*_,t[11]=(h*r*n-o*l*n-h*s*c+e*l*c+o*s*m-e*r*m)*_,t[12]=w*_,t[13]=(h*x*i-f*l*i+f*s*d-e*x*d-h*s*y+e*l*y)*_,t[14]=(f*r*i-o*x*i-f*s*a+e*x*a+o*s*y-e*r*y)*_,t[15]=(o*l*i-h*r*i+h*s*a-e*l*a-o*s*d+e*r*d)*_,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,o=t.x,r=t.y,a=t.z,c=n*o,h=n*r;return this.set(c*o+s,c*r-i*a,c*a+i*r,0,c*r+i*a,h*r+s,h*a-i*o,0,c*a-i*r,h*a+i*o,n*a*a+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,o){return this.set(1,s,n,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,n=e._x,o=e._y,r=e._z,a=e._w,c=n+n,h=o+o,l=r+r,d=n*c,m=n*h,f=n*l,x=o*h,y=o*l,p=r*l,A=a*c,b=a*h,M=a*l,w=s.x,z=s.y,_=s.z;return i[0]=(1-(x+p))*w,i[1]=(m+M)*w,i[2]=(f-b)*w,i[3]=0,i[4]=(m-M)*z,i[5]=(1-(d+p))*z,i[6]=(y+A)*z,i[7]=0,i[8]=(f+b)*_,i[9]=(y-A)*_,i[10]=(1-(d+x))*_,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=gt.set(i[0],i[1],i[2]).length();const o=gt.set(i[4],i[5],i[6]).length(),r=gt.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],W.copy(this);const c=1/n,h=1/o,l=1/r;return W.elements[0]*=c,W.elements[1]*=c,W.elements[2]*=c,W.elements[4]*=h,W.elements[5]*=h,W.elements[6]*=h,W.elements[8]*=l,W.elements[9]*=l,W.elements[10]*=l,e.setFromRotationMatrix(W),s.x=n,s.y=o,s.z=r,this}makePerspective(t,e,s,i,n,o,r=2e3){const a=this.elements,c=2*n/(e-t),h=2*n/(s-i),l=(e+t)/(e-t),d=(s+i)/(s-i);let m,f;if(r===2e3)m=-(o+n)/(o-n),f=-2*o*n/(o-n);else if(r===2001)m=-o/(o-n),f=-o*n/(o-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+r);return a[0]=c,a[4]=0,a[8]=l,a[12]=0,a[1]=0,a[5]=h,a[9]=d,a[13]=0,a[2]=0,a[6]=0,a[10]=m,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,s,i,n,o,r=2e3){const a=this.elements,c=1/(e-t),h=1/(s-i),l=1/(o-n),d=(e+t)*c,m=(s+i)*h;let f,x;if(r===2e3)f=(o+n)*l,x=-2*l;else if(r===2001)f=n*l,x=-1*l;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+r);return a[0]=2*c,a[4]=0,a[8]=0,a[12]=-d,a[1]=0,a[5]=2*h,a[9]=0,a[13]=-m,a[2]=0,a[6]=0,a[10]=x,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[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 gt=new g,W=new Z,Bs=new g(0,0,0),Ps=new g(1,1,1),nt=new g,Vt=new g,L=new g,Ie=new Z,Re=new Bt;class qt{constructor(t=0,e=0,s=0,i=qt.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],o=i[4],r=i[8],a=i[1],c=i[5],h=i[9],l=i[2],d=i[6],m=i[10];switch(e){case"XYZ":this._y=Math.asin(q(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-o,n)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-q(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(r,m),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-l,n),this._z=0);break;case"ZXY":this._x=Math.asin(q(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-l,m),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,n));break;case"ZYX":this._y=Math.asin(-q(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(a,n)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(q(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-l,n)):(this._x=0,this._y=Math.atan2(r,m));break;case"XZY":this._z=Math.asin(-q(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(r,n)):(this._x=Math.atan2(-h,m),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 Ie.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ie,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Re.setFromEuler(this),this.setFromQuaternion(Re,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}}qt.DEFAULT_ORDER="XYZ";class Cs{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 Es=0;const Ue=new g,bt=new Bt,j=new Z,Ot=new g,Et=new g,Fs=new g,ks=new Bt,De=new g(1,0,0),Le=new g(0,1,0),Ne=new g(0,0,1),Ve={type:"added"},Is={type:"removed"},wt={type:"childadded",child:null},ne={type:"childremoved",child:null};class rt extends Jt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Es++}),this.uuid=Tt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=rt.DEFAULT_UP.clone();const t=new g,e=new qt,s=new Bt,i=new g(1,1,1);function n(){s.setFromEuler(e,!1)}function o(){e.setFromQuaternion(s,void 0,!1)}e._onChange(n),s._onChange(o),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 Z},normalMatrix:{value:new ht}}),this.matrix=new Z,this.matrixWorld=new Z,this.matrixAutoUpdate=rt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Cs,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 bt.setFromAxisAngle(t,e),this.quaternion.multiply(bt),this}rotateOnWorldAxis(t,e){return bt.setFromAxisAngle(t,e),this.quaternion.premultiply(bt),this}rotateX(t){return this.rotateOnAxis(De,t)}rotateY(t){return this.rotateOnAxis(Le,t)}rotateZ(t){return this.rotateOnAxis(Ne,t)}translateOnAxis(t,e){return Ue.copy(t).applyQuaternion(this.quaternion),this.position.add(Ue.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(De,t)}translateY(t){return this.translateOnAxis(Le,t)}translateZ(t){return this.translateOnAxis(Ne,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(j.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?Ot.copy(t):Ot.set(t,e,s);const i=this.parent;this.updateWorldMatrix(!0,!1),Et.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?j.lookAt(Et,Ot,this.up):j.lookAt(Ot,Et,this.up),this.quaternion.setFromRotationMatrix(j),i&&(j.extractRotation(i.matrixWorld),bt.setFromRotationMatrix(j),this.quaternion.premultiply(bt.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.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Ve),wt.child=t,this.dispatchEvent(wt),wt.child=null):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(Is),ne.child=t,this.dispatchEvent(ne),ne.child=null),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),j.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),j.multiply(t.parent.matrixWorld)),t.applyMatrix4(j),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Ve),wt.child=t,this.dispatchEvent(wt),wt.child=null,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 o=this.children[s].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const i=this.children;for(let n=0,o=i.length;n<o;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(Et,t,Fs),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Et,ks,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,o=i.length;n<o;n++){const r=i[n];r.matrixWorldAutoUpdate===!0&&r.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(r=>({boxInitialized:r.boxInitialized,boxMin:r.box.min.toArray(),boxMax:r.box.max.toArray(),sphereInitialized:r.sphereInitialized,sphereRadius:r.sphere.radius,sphereCenter:r.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(r,a){return r[a.uuid]===void 0&&(r[a.uuid]=a.toJSON(t)),a.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 r=this.geometry.parameters;if(r!==void 0&&r.shapes!==void 0){const a=r.shapes;if(Array.isArray(a))for(let c=0,h=a.length;c<h;c++){const l=a[c];n(t.shapes,l)}else n(t.shapes,a)}}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 r=[];for(let a=0,c=this.material.length;a<c;a++)r.push(n(t.materials,this.material[a]));i.material=r}else i.material=n(t.materials,this.material);if(this.children.length>0){i.children=[];for(let r=0;r<this.children.length;r++)i.children.push(this.children[r].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let r=0;r<this.animations.length;r++){const a=this.animations[r];i.animations.push(n(t.animations,a))}}if(e){const r=o(t.geometries),a=o(t.materials),c=o(t.textures),h=o(t.images),l=o(t.shapes),d=o(t.skeletons),m=o(t.animations),f=o(t.nodes);r.length>0&&(s.geometries=r),a.length>0&&(s.materials=a),c.length>0&&(s.textures=c),h.length>0&&(s.images=h),l.length>0&&(s.shapes=l),d.length>0&&(s.skeletons=d),m.length>0&&(s.animations=m),f.length>0&&(s.nodes=f)}return s.object=i,s;function o(r){const a=[];for(const c in r){const h=r[c];delete h.metadata,a.push(h)}return a}}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}}rt.DEFAULT_UP=new g(0,1,0),rt.DEFAULT_MATRIX_AUTO_UPDATE=!0,rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const v=new g,$=new g,re=new g,J=new g,Mt=new g,_t=new g,qe=new g,oe=new g,ae=new g,he=new g;class lt{constructor(t=new g,e=new g,s=new g){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,i){i.subVectors(s,e),v.subVectors(t,e),i.cross(v);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){v.subVectors(i,e),$.subVectors(s,e),re.subVectors(t,e);const o=v.dot(v),r=v.dot($),a=v.dot(re),c=$.dot($),h=$.dot(re),l=o*c-r*r;if(l===0)return n.set(0,0,0),null;const d=1/l,m=(c*a-r*h)*d,f=(o*h-r*a)*d;return n.set(1-m-f,f,m)}static containsPoint(t,e,s,i){return this.getBarycoord(t,e,s,i,J)===null?!1:J.x>=0&&J.y>=0&&J.x+J.y<=1}static getInterpolation(t,e,s,i,n,o,r,a){return this.getBarycoord(t,e,s,i,J)===null?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(n,J.x),a.addScaledVector(o,J.y),a.addScaledVector(r,J.z),a)}static isFrontFacing(t,e,s,i){return v.subVectors(s,e),$.subVectors(t,e),v.cross($).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 v.subVectors(this.c,this.b),$.subVectors(this.a,this.b),v.cross($).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return lt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return lt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,i,n){return lt.getInterpolation(t,this.a,this.b,this.c,e,s,i,n)}containsPoint(t){return lt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return lt.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 o,r;Mt.subVectors(i,s),_t.subVectors(n,s),oe.subVectors(t,s);const a=Mt.dot(oe),c=_t.dot(oe);if(a<=0&&c<=0)return e.copy(s);ae.subVectors(t,i);const h=Mt.dot(ae),l=_t.dot(ae);if(h>=0&&l<=h)return e.copy(i);const d=a*l-h*c;if(d<=0&&a>=0&&h<=0)return o=a/(a-h),e.copy(s).addScaledVector(Mt,o);he.subVectors(t,n);const m=Mt.dot(he),f=_t.dot(he);if(f>=0&&m<=f)return e.copy(n);const x=m*c-a*f;if(x<=0&&c>=0&&f<=0)return r=c/(c-f),e.copy(s).addScaledVector(_t,r);const y=h*f-m*l;if(y<=0&&l-h>=0&&m-f>=0)return qe.subVectors(n,i),r=(l-h)/(l-h+(m-f)),e.copy(i).addScaledVector(qe,r);const p=1/(y+x+d);return o=x*p,r=d*p,e.copy(s).addScaledVector(Mt,o).addScaledVector(_t,r)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const F=new g,Wt=new Y;class ot{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 Ms("THREE.BufferAttribute: updateRange() is deprecated and will be 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++)Wt.fromBufferAttribute(this,e),Wt.applyMatrix3(t),this.setXY(e,Wt.x,Wt.y);else if(this.itemSize===3)for(let e=0,s=this.count;e<s;e++)F.fromBufferAttribute(this,e),F.applyMatrix3(t),this.setXYZ(e,F.x,F.y,F.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)F.fromBufferAttribute(this,e),F.applyMatrix4(t),this.setXYZ(e,F.x,F.y,F.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)F.fromBufferAttribute(this,e),F.applyNormalMatrix(t),this.setXYZ(e,F.x,F.y,F.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)F.fromBufferAttribute(this,e),F.transformDirection(t),this.setXYZ(e,F.x,F.y,F.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=mt(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=D(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=mt(e,this.array)),e}setX(t,e){return this.normalized&&(e=D(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=mt(e,this.array)),e}setY(t,e){return this.normalized&&(e=D(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=mt(e,this.array)),e}setZ(t,e){return this.normalized&&(e=D(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=mt(e,this.array)),e}setW(t,e){return this.normalized&&(e=D(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=D(e,this.array),s=D(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=D(e,this.array),s=D(s,this.array),i=D(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=D(e,this.array),s=D(s,this.array),i=D(i,this.array),n=D(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 Rs extends ot{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class Us extends ot{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class Ds extends ot{constructor(t,e,s){super(new Float32Array(t),e,s)}}let Ls=0;const V=new Z,ce=new rt,zt=new g,N=new G,Ft=new G,I=new g;class ue extends Jt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ls++}),this.uuid=Tt(),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(ws(t)?Us:Rs)(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 ht().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 V.makeRotationFromQuaternion(t),this.applyMatrix4(V),this}rotateX(t){return V.makeRotationX(t),this.applyMatrix4(V),this}rotateY(t){return V.makeRotationY(t),this.applyMatrix4(V),this}rotateZ(t){return V.makeRotationZ(t),this.applyMatrix4(V),this}translate(t,e,s){return V.makeTranslation(t,e,s),this.applyMatrix4(V),this}scale(t,e,s){return V.makeScale(t,e,s),this.applyMatrix4(V),this}lookAt(t){return ce.lookAt(t),ce.updateMatrix(),this.applyMatrix4(ce.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zt).negate(),this.translate(zt.x,zt.y,zt.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 Ds(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new G);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new g(-1/0,-1/0,-1/0),new g(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];N.setFromBufferAttribute(n),this.morphTargetsRelative?(I.addVectors(this.boundingBox.min,N.min),this.boundingBox.expandByPoint(I),I.addVectors(this.boundingBox.max,N.max),this.boundingBox.expandByPoint(I)):(this.boundingBox.expandByPoint(N.min),this.boundingBox.expandByPoint(N.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 ke);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new g,1/0);return}if(t){const s=this.boundingSphere.center;if(N.setFromBufferAttribute(t),e)for(let n=0,o=e.length;n<o;n++){const r=e[n];Ft.setFromBufferAttribute(r),this.morphTargetsRelative?(I.addVectors(N.min,Ft.min),N.expandByPoint(I),I.addVectors(N.max,Ft.max),N.expandByPoint(I)):(N.expandByPoint(Ft.min),N.expandByPoint(Ft.max))}N.getCenter(s);let i=0;for(let n=0,o=t.count;n<o;n++)I.fromBufferAttribute(t,n),i=Math.max(i,s.distanceToSquared(I));if(e)for(let n=0,o=e.length;n<o;n++){const r=e[n],a=this.morphTargetsRelative;for(let c=0,h=r.count;c<h;c++)I.fromBufferAttribute(r,c),a&&(zt.fromBufferAttribute(t,c),I.add(zt)),i=Math.max(i,s.distanceToSquared(I))}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=e.position,i=e.normal,n=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ot(new Float32Array(4*s.count),4));const o=this.getAttribute("tangent"),r=[],a=[];for(let T=0;T<s.count;T++)r[T]=new g,a[T]=new g;const c=new g,h=new g,l=new g,d=new Y,m=new Y,f=new Y,x=new g,y=new g;function p(T,S,P){c.fromBufferAttribute(s,T),h.fromBufferAttribute(s,S),l.fromBufferAttribute(s,P),d.fromBufferAttribute(n,T),m.fromBufferAttribute(n,S),f.fromBufferAttribute(n,P),h.sub(c),l.sub(c),m.sub(d),f.sub(d);const B=1/(m.x*f.y-f.x*m.y);isFinite(B)&&(x.copy(h).multiplyScalar(f.y).addScaledVector(l,-m.y).multiplyScalar(B),y.copy(l).multiplyScalar(m.x).addScaledVector(h,-f.x).multiplyScalar(B),r[T].add(x),r[S].add(x),r[P].add(x),a[T].add(y),a[S].add(y),a[P].add(y))}let A=this.groups;A.length===0&&(A=[{start:0,count:t.count}]);for(let T=0,S=A.length;T<S;++T){const P=A[T],B=P.start,E=P.count;for(let C=B,k=B+E;C<k;C+=3)p(t.getX(C+0),t.getX(C+1),t.getX(C+2))}const b=new g,M=new g,w=new g,z=new g;function _(T){w.fromBufferAttribute(i,T),z.copy(w);const S=r[T];b.copy(S),b.sub(w.multiplyScalar(w.dot(S))).normalize(),M.crossVectors(z,S);const B=M.dot(a[T])<0?-1:1;o.setXYZW(T,b.x,b.y,b.z,B)}for(let T=0,S=A.length;T<S;++T){const P=A[T],B=P.start,E=P.count;for(let C=B,k=B+E;C<k;C+=3)_(t.getX(C+0)),_(t.getX(C+1)),_(t.getX(C+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 ot(new Float32Array(e.count*3),3),this.setAttribute("normal",s);else for(let d=0,m=s.count;d<m;d++)s.setXYZ(d,0,0,0);const i=new g,n=new g,o=new g,r=new g,a=new g,c=new g,h=new g,l=new g;if(t)for(let d=0,m=t.count;d<m;d+=3){const f=t.getX(d+0),x=t.getX(d+1),y=t.getX(d+2);i.fromBufferAttribute(e,f),n.fromBufferAttribute(e,x),o.fromBufferAttribute(e,y),h.subVectors(o,n),l.subVectors(i,n),h.cross(l),r.fromBufferAttribute(s,f),a.fromBufferAttribute(s,x),c.fromBufferAttribute(s,y),r.add(h),a.add(h),c.add(h),s.setXYZ(f,r.x,r.y,r.z),s.setXYZ(x,a.x,a.y,a.z),s.setXYZ(y,c.x,c.y,c.z)}else for(let d=0,m=e.count;d<m;d+=3)i.fromBufferAttribute(e,d+0),n.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),h.subVectors(o,n),l.subVectors(i,n),h.cross(l),s.setXYZ(d+0,h.x,h.y,h.z),s.setXYZ(d+1,h.x,h.y,h.z),s.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)I.fromBufferAttribute(t,e),I.normalize(),t.setXYZ(e,I.x,I.y,I.z)}toNonIndexed(){function t(r,a){const c=r.array,h=r.itemSize,l=r.normalized,d=new c.constructor(a.length*h);let m=0,f=0;for(let x=0,y=a.length;x<y;x++){r.isInterleavedBufferAttribute?m=a[x]*r.data.stride+r.offset:m=a[x]*h;for(let p=0;p<h;p++)d[f++]=c[m++]}return new ot(d,h,l)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ue,s=this.index.array,i=this.attributes;for(const r in i){const a=i[r],c=t(a,s);e.setAttribute(r,c)}const n=this.morphAttributes;for(const r in n){const a=[],c=n[r];for(let h=0,l=c.length;h<l;h++){const d=c[h],m=t(d,s);a.push(m)}e.morphAttributes[r]=a}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let r=0,a=o.length;r<a;r++){const c=o[r];e.addGroup(c.start,c.count,c.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 a=this.parameters;for(const c in a)a[c]!==void 0&&(t[c]=a[c]);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 a in s){const c=s[a];t.data.attributes[a]=c.toJSON(t.data)}const i={};let n=!1;for(const a in this.morphAttributes){const c=this.morphAttributes[a],h=[];for(let l=0,d=c.length;l<d;l++){const m=c[l];h.push(m.toJSON(t.data))}h.length>0&&(i[a]=h,n=!0)}n&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const r=this.boundingSphere;return r!==null&&(t.data.boundingSphere={center:r.center.toArray(),radius:r.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 c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const n=t.morphAttributes;for(const c in n){const h=[],l=n[c];for(let d=0,m=l.length;d<m;d++)h.push(l[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const l=o[c];this.addGroup(l.start,l.count,l.materialIndex)}const r=t.boundingBox;r!==null&&(this.boundingBox=r.clone());const a=t.boundingSphere;return a!==null&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const le=new g,Ns=new g,Vs=new ht;class Oe{constructor(t=new g(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=le.subVectors(s,e).cross(Ns.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(le),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||Vs.getNormalMatrix(t),i=this.coplanarPoint(le).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 qs extends et{constructor(t,e,s,i,n,o,r,a,c,h){if(h=h!==void 0?h:1026,h!==1026&&h!==1027)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");s===void 0&&h===1026&&(s=1014),s===void 0&&h===1027&&(s=1020),super(null,i,n,o,r,a,h,s,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=r!==void 0?r:1003,this.minFilter=a!==void 0?a: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 Os=new qs(1,1);Os.compareFunction=515;const We=new g,vt=new g;class Q{constructor(t=new g,e=new g){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){We.subVectors(t,this.start),vt.subVectors(this.end,this.start);const s=vt.dot(vt);let n=vt.dot(We)/s;return e&&(n=q(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:ze}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ze);class Ws{get workerCount(){return this.workers.length}constructor(t){this.workers=[],this._getWorker=t}setWorkerCount(t){const e=this.workers;for(;e.length<t;)e.push(this._getWorker());for(;e.length>t;)e.pop().terminate()}runSubTask(t,e,s){return new Promise((i,n)=>{const o=this.workers[t];if(o.isRunning)throw new Error(`${this.name}: Worker ${t} is already running.`);o.isRunning=!0,o.postMessage(e),o.onerror=r=>{o.isRunning=!1,n(r)},o.onmessage=r=>{r.data.type==="progress"?s&&s(r.data.progress):(s&&s(1),o.isRunning=!1,i(r.data))}})}}const ve=0,vs=1,Xs=2,de=1.25,Xe=1,kt=6*4+4+4,Ys=65535,Zs=Math.pow(2,-24);function Gs(u){return u.index?u.index.count:u.attributes.position.count}function Xt(u){return Gs(u)/3}function Ye(u){const t=Xt(u),e=u.drawRange,s=e.start/3,i=(e.start+e.count)/3,n=Math.max(0,s),o=Math.min(t,i)-n;return[{offset:Math.floor(n),count:Math.floor(o)}]}function Hs(u){if(!u.groups||!u.groups.length)return Ye(u);const t=[],e=new Set,s=u.drawRange,i=s.start/3,n=(s.start+s.count)/3;for(const r of u.groups){const a=r.start/3,c=(r.start+r.count)/3;e.add(Math.max(i,a)),e.add(Math.min(n,c))}const o=Array.from(e.values()).sort((r,a)=>r-a);for(let r=0;r<o.length-1;r++){const a=o[r],c=o[r+1];t.push({offset:Math.floor(a),count:Math.floor(c-a)})}return t}function me(u,t,e,s,i){let n=1/0,o=1/0,r=1/0,a=-1/0,c=-1/0,h=-1/0,l=1/0,d=1/0,m=1/0,f=-1/0,x=-1/0,y=-1/0;for(let p=t*6,A=(t+e)*6;p<A;p+=6){const b=u[p+0],M=u[p+1],w=b-M,z=b+M;w<n&&(n=w),z>a&&(a=z),b<l&&(l=b),b>f&&(f=b);const _=u[p+2],T=u[p+3],S=_-T,P=_+T;S<o&&(o=S),P>c&&(c=P),_<d&&(d=_),_>x&&(x=_);const B=u[p+4],E=u[p+5],C=B-E,k=B+E;C<r&&(r=C),k>h&&(h=k),B<m&&(m=B),B>y&&(y=B)}s[0]=n,s[1]=o,s[2]=r,s[3]=a,s[4]=c,s[5]=h,i[0]=l,i[1]=d,i[2]=m,i[3]=f,i[4]=x,i[5]=y}function js(u,t=null,e=null,s=null){const i=u.attributes.position,n=u.index?u.index.array:null,o=Xt(u),r=i.normalized;let a;t===null?(a=new Float32Array(o*6*4),e=0,s=o):(a=t,e=e||0,s=s||o);const c=i.array,h=i.offset||0;let l=3;i.isInterleavedBufferAttribute&&(l=i.data.stride);const d=["getX","getY","getZ"];for(let m=e;m<e+s;m++){const f=m*3,x=m*6;let y=f+0,p=f+1,A=f+2;n&&(y=n[y],p=n[p],A=n[A]),r||(y=y*l+h,p=p*l+h,A=A*l+h);for(let b=0;b<3;b++){let M,w,z;r?(M=i[d[b]](y),w=i[d[b]](p),z=i[d[b]](A)):(M=c[y+b],w=c[p+b],z=c[A+b]);let _=M;w<_&&(_=w),z<_&&(_=z);let T=M;w>T&&(T=w),z>T&&(T=z);const S=(T-_)/2,P=b*2;a[x+P+0]=_+S,a[x+P+1]=S+(Math.abs(_)+S)*Zs}}return a}function Ze(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 Ge(u,t){t.set(u)}function He(u,t,e){let s,i;for(let n=0;n<3;n++){const o=n+3;s=u[n],i=t[n],e[n]=s<i?s:i,s=u[o],i=t[o],e[o]=s>i?s:i}}function Yt(u,t,e){for(let s=0;s<3;s++){const i=t[u+2*s],n=t[u+2*s+1],o=i-n,r=i+n;o<e[s]&&(e[s]=o),r>e[s+3]&&(e[s+3]=r)}}function It(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)}const K=32,$s=(u,t)=>u.candidate-t.candidate,at=new Array(K).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Zt=new Float32Array(6);function Js(u,t,e,s,i,n){let o=-1,r=0;if(n===ve)o=Ze(t),o!==-1&&(r=(t[o]+t[o+3])/2);else if(n===vs)o=Ze(u),o!==-1&&(r=Qs(e,s,i,o));else if(n===Xs){const a=It(u);let c=de*i;const h=s*6,l=(s+i)*6;for(let d=0;d<3;d++){const m=t[d],y=(t[d+3]-m)/K;if(i<K/4){const p=[...at];p.length=i;let A=0;for(let M=h;M<l;M+=6,A++){const w=p[A];w.candidate=e[M+2*d],w.count=0;const{bounds:z,leftCacheBounds:_,rightCacheBounds:T}=w;for(let S=0;S<3;S++)T[S]=1/0,T[S+3]=-1/0,_[S]=1/0,_[S+3]=-1/0,z[S]=1/0,z[S+3]=-1/0;Yt(M,e,z)}p.sort($s);let b=i;for(let M=0;M<b;M++){const w=p[M];for(;M+1<b&&p[M+1].candidate===w.candidate;)p.splice(M+1,1),b--}for(let M=h;M<l;M+=6){const w=e[M+2*d];for(let z=0;z<b;z++){const _=p[z];w>=_.candidate?Yt(M,e,_.rightCacheBounds):(Yt(M,e,_.leftCacheBounds),_.count++)}}for(let M=0;M<b;M++){const w=p[M],z=w.count,_=i-w.count,T=w.leftCacheBounds,S=w.rightCacheBounds;let P=0;z!==0&&(P=It(T)/a);let B=0;_!==0&&(B=It(S)/a);const E=Xe+de*(P*z+B*_);E<c&&(o=d,c=E,r=w.candidate)}}else{for(let b=0;b<K;b++){const M=at[b];M.count=0,M.candidate=m+y+b*y;const w=M.bounds;for(let z=0;z<3;z++)w[z]=1/0,w[z+3]=-1/0}for(let b=h;b<l;b+=6){let z=~~((e[b+2*d]-m)/y);z>=K&&(z=K-1);const _=at[z];_.count++,Yt(b,e,_.bounds)}const p=at[K-1];Ge(p.bounds,p.rightCacheBounds);for(let b=K-2;b>=0;b--){const M=at[b],w=at[b+1];He(M.bounds,w.rightCacheBounds,M.rightCacheBounds)}let A=0;for(let b=0;b<K-1;b++){const M=at[b],w=M.count,z=M.bounds,T=at[b+1].rightCacheBounds;w!==0&&(A===0?Ge(z,Zt):He(z,Zt,Zt)),A+=w;let S=0,P=0;A!==0&&(S=It(Zt)/a);const B=i-A;B!==0&&(P=It(T)/a);const E=Xe+de*(S*A+P*B);E<c&&(o=d,c=E,r=M.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:o,pos:r}}function Qs(u,t,e,s){let i=0;for(let n=t,o=t+e;n<o;n++)i+=u[n*6+s*2];return i/e}class fe{constructor(){this.boundingData=new Float32Array(6)}}function Ks(u,t,e,s,i,n){let o=s,r=s+i-1;const a=n.pos,c=n.axis*2;for(;;){for(;o<=r&&e[o*6+c]<a;)o++;for(;o<=r&&e[r*6+c]>=a;)r--;if(o<r){for(let h=0;h<3;h++){let l=t[o*3+h];t[o*3+h]=t[r*3+h],t[r*3+h]=l}for(let h=0;h<6;h++){let l=e[o*6+h];e[o*6+h]=e[r*6+h],e[r*6+h]=l}o++,r--}else return o}}function ti(u,t,e,s,i,n){let o=s,r=s+i-1;const a=n.pos,c=n.axis*2;for(;;){for(;o<=r&&e[o*6+c]<a;)o++;for(;o<=r&&e[r*6+c]>=a;)r--;if(o<r){let h=u[o];u[o]=u[r],u[r]=h;for(let l=0;l<6;l++){let d=e[o*6+l];e[o*6+l]=e[r*6+l],e[r*6+l]=d}o++,r--}else return o}}function ei(u,t){return t[u+15]===65535}let je,Rt,Gt,$e;const si=Math.pow(2,32);function pe(u){return"count"in u?1:1+pe(u.left)+pe(u.right)}function Je(u,t,e){return je=new Float32Array(e),Rt=new Uint32Array(e),Gt=new Uint16Array(e),$e=new Uint8Array(e),ye(u,t)}function ye(u,t){const e=u/4,s=u/2,i="count"in t,n=t.boundingData;for(let o=0;o<6;o++)je[e+o]=n[o];if(i)if(t.buffer){const o=t.buffer;$e.set(new Uint8Array(o),u);for(let r=u,a=u+o.byteLength;r<a;r+=kt){const c=r/2;ei(c,Gt)||(Rt[r/4+6]+=e)}return u+o.byteLength}else{const o=t.offset,r=t.count;return Rt[e+6]=o,Gt[s+14]=r,Gt[s+15]=Ys,u+kt}else{const o=t.left,r=t.right,a=t.splitAxis;let c;if(c=ye(u+kt,o),c/4>si)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Rt[e+6]=c/4,c=ye(c,r),Rt[e+7]=a,c}}function ii(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),o=s?new Uint32Array(n):new Uint16Array(n);for(let r=0,a=o.length;r<a;r++)o[r]=r;return o}function Qe(u,t,e,s,i){const{maxDepth:n,verbose:o,maxLeafTris:r,strategy:a,onProgress:c,indirect:h}=i,l=u._indirectBuffer,d=u.geometry,m=d.index?d.index.array:null,f=h?ti:Ks,x=Xt(d),y=new Float32Array(6);let p=!1;const A=new fe;return me(t,e,s,A.boundingData,y),M(A,e,s,y),A;function b(w){c&&c(w/x)}function M(w,z,_,T=null,S=0){if(!p&&S>=n&&(p=!0,o&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(d))),_<=r||S>=n)return b(z+_),w.offset=z,w.count=_,w;const P=Js(w.boundingData,T,t,z,_,a);if(P.axis===-1)return b(z+_),w.offset=z,w.count=_,w;const B=f(l,m,t,z,_,P);if(B===z||B===z+_)b(z+_),w.offset=z,w.count=_;else{w.splitAxis=P.axis;const E=new fe,C=z,k=B-z;w.left=E,me(t,C,k,E.boundingData,y),M(E,C,k,y,S+1);const U=new fe,tt=B,X=_-k;w.right=U,me(t,tt,X,U.boundingData,y),M(U,tt,X,y,S+1)}return w}}class At{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let s=1/0,i=-1/0;for(let n=0,o=t.length;n<o;n++){const a=t[n][e];s=a<s?a:s,i=a>i?a:i}this.min=s,this.max=i}setFromPoints(t,e){let s=1/0,i=-1/0;for(let n=0,o=e.length;n<o;n++){const r=e[n],a=t.dot(r);s=a<s?a:s,i=a>i?a:i}this.min=s,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}}At.prototype.setFromBox=function(){const u=new g;return function(e,s){const i=s.min,n=s.max;let o=1/0,r=-1/0;for(let a=0;a<=1;a++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){u.x=i.x*a+n.x*(1-a),u.y=i.y*c+n.y*(1-c),u.z=i.z*h+n.z*(1-h);const l=e.dot(u);o=Math.min(l,o),r=Math.max(l,r)}this.min=o,this.max=r}}();const ni=function(){const u=new g,t=new g,e=new g;return function(i,n,o){const r=i.start,a=u,c=n.start,h=t;e.subVectors(r,c),u.subVectors(i.end,i.start),t.subVectors(n.end,n.start);const l=e.dot(h),d=h.dot(a),m=h.dot(h),f=e.dot(a),y=a.dot(a)*m-d*d;let p,A;y!==0?p=(l*d-f*m)/y:p=0,A=(l+p*d)/m,o.x=p,o.y=A}}(),xe=function(){const u=new Y,t=new g,e=new g;return function(i,n,o,r){ni(i,n,u);let a=u.x,c=u.y;if(a>=0&&a<=1&&c>=0&&c<=1){i.at(a,o),n.at(c,r);return}else if(a>=0&&a<=1){c<0?n.at(0,r):n.at(1,r),i.closestPointToPoint(r,!0,o);return}else if(c>=0&&c<=1){a<0?i.at(0,o):i.at(1,o),n.closestPointToPoint(o,!0,r);return}else{let h;a<0?h=i.start:h=i.end;let l;c<0?l=n.start:l=n.end;const d=t,m=e;if(i.closestPointToPoint(l,!0,t),n.closestPointToPoint(h,!0,e),d.distanceToSquared(l)<=m.distanceToSquared(h)){o.copy(d),r.copy(l);return}else{o.copy(h),r.copy(m);return}}}}(),ri=function(){const u=new g,t=new g,e=new Oe,s=new Q;return function(n,o){const{radius:r,center:a}=n,{a:c,b:h,c:l}=o;if(s.start=c,s.end=h,s.closestPointToPoint(a,!0,u).distanceTo(a)<=r||(s.start=c,s.end=l,s.closestPointToPoint(a,!0,u).distanceTo(a)<=r)||(s.start=h,s.end=l,s.closestPointToPoint(a,!0,u).distanceTo(a)<=r))return!0;const x=o.getPlane(e);if(Math.abs(x.distanceToPoint(a))<=r){const p=x.projectPoint(a,t);if(o.containsPoint(p))return!0}return!1}}(),oi=1e-15;function ge(u){return Math.abs(u)<oi}class St extends lt{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new g),this.satBounds=new Array(4).fill().map(()=>new At),this.points=[this.a,this.b,this.c],this.sphere=new ke,this.plane=new Oe,this.needsUpdate=!0}intersectsSphere(t){return ri(t,this)}update(){const t=this.a,e=this.b,s=this.c,i=this.points,n=this.satAxes,o=this.satBounds,r=n[0],a=o[0];this.getNormal(r),a.setFromPoints(r,i);const c=n[1],h=o[1];c.subVectors(t,e),h.setFromPoints(c,i);const l=n[2],d=o[2];l.subVectors(e,s),d.setFromPoints(l,i);const m=n[3],f=o[3];m.subVectors(s,t),f.setFromPoints(m,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(r,t),this.needsUpdate=!1}}St.prototype.closestPointToSegment=function(){const u=new g,t=new g,e=new Q;return function(i,n=null,o=null){const{start:r,end:a}=i,c=this.points;let h,l=1/0;for(let d=0;d<3;d++){const m=(d+1)%3;e.start.copy(c[d]),e.end.copy(c[m]),xe(e,i,u,t),h=u.distanceToSquared(t),h<l&&(l=h,n&&n.copy(u),o&&o.copy(t))}return this.closestPointToPoint(r,u),h=r.distanceToSquared(u),h<l&&(l=h,n&&n.copy(u),o&&o.copy(r)),this.closestPointToPoint(a,u),h=a.distanceToSquared(u),h<l&&(l=h,n&&n.copy(u),o&&o.copy(a)),Math.sqrt(l)}}(),St.prototype.intersectsTriangle=function(){const u=new St,t=new Array(3),e=new Array(3),s=new At,i=new At,n=new g,o=new g,r=new g,a=new g,c=new g,h=new Q,l=new Q,d=new Q,m=new g;function f(x,y,p){const A=x.points;let b=0,M=-1;for(let w=0;w<3;w++){const{start:z,end:_}=h;z.copy(A[w]),_.copy(A[(w+1)%3]),h.delta(o);const T=ge(y.distanceToPoint(z));if(ge(y.normal.dot(o))&&T){p.copy(h),b=2;break}const S=y.intersectLine(h,m);if(!S&&T&&m.copy(z),(S||T)&&!ge(m.distanceTo(_))){if(b<=1)(b===1?p.start:p.end).copy(m),T&&(M=b);else if(b>=2){(M===1?p.start:p.end).copy(m),b=2;break}if(b++,b===2&&M===-1)break}}return b}return function(y,p=null,A=!1){this.needsUpdate&&this.update(),y.isExtendedTriangle?y.needsUpdate&&y.update():(u.copy(y),u.update(),y=u);const b=this.plane,M=y.plane;if(Math.abs(b.normal.dot(M.normal))>1-1e-10){const w=this.satBounds,z=this.satAxes;e[0]=y.a,e[1]=y.b,e[2]=y.c;for(let S=0;S<4;S++){const P=w[S],B=z[S];if(s.setFromPoints(B,e),P.isSeparated(s))return!1}const _=y.satBounds,T=y.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let S=0;S<4;S++){const P=_[S],B=T[S];if(s.setFromPoints(B,t),P.isSeparated(s))return!1}for(let S=0;S<4;S++){const P=z[S];for(let B=0;B<4;B++){const E=T[B];if(n.crossVectors(P,E),s.setFromPoints(n,t),i.setFromPoints(n,e),s.isSeparated(i))return!1}}return p&&(A||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{const w=f(this,M,l);if(w===1&&y.containsPoint(l.end))return p&&(p.start.copy(l.end),p.end.copy(l.end)),!0;if(w!==2)return!1;const z=f(y,b,d);if(z===1&&this.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(z!==2)return!1;if(l.delta(r),d.delta(a),r.dot(a)<0){let C=d.start;d.start=d.end,d.end=C}const _=l.start.dot(r),T=l.end.dot(r),S=d.start.dot(r),P=d.end.dot(r),B=T<S,E=_<P;return _!==P&&S!==T&&B===E?!1:(p&&(c.subVectors(l.start,d.start),c.dot(r)>0?p.start.copy(l.start):p.start.copy(d.start),c.subVectors(l.end,d.end),c.dot(r)<0?p.end.copy(l.end):p.end.copy(d.end)),!0)}}}(),St.prototype.distanceToPoint=function(){const u=new g;return function(e){return this.closestPointToPoint(e,u),e.distanceTo(u)}}(),St.prototype.distanceToTriangle=function(){const u=new g,t=new g,e=["a","b","c"],s=new Q,i=new Q;return function(o,r=null,a=null){const c=r||a?s:null;if(this.intersectsTriangle(o,c))return(r||a)&&(r&&c.getCenter(r),a&&c.getCenter(a)),0;let h=1/0;for(let l=0;l<3;l++){let d;const m=e[l],f=o[m];this.closestPointToPoint(f,u),d=f.distanceToSquared(u),d<h&&(h=d,r&&r.copy(u),a&&a.copy(f));const x=this[m];o.closestPointToPoint(x,u),d=x.distanceToSquared(u),d<h&&(h=d,r&&r.copy(x),a&&a.copy(u))}for(let l=0;l<3;l++){const d=e[l],m=e[(l+1)%3];s.set(this[d],this[m]);for(let f=0;f<3;f++){const x=e[f],y=e[(f+1)%3];i.set(o[x],o[y]),xe(s,i,u,t);const p=u.distanceToSquared(t);p<h&&(h=p,r&&r.copy(u),a&&a.copy(t))}}return Math.sqrt(h)}}(),function(){const u=new St,t=new Array(3),e=new At,s=new At,i=new g;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(u.copy(o),u.update(),o=u);const r=this.satBounds,a=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let d=0;d<3;d++){const m=r[d],f=a[d];if(e.setFromPoints(f,t),m.isSeparated(e))return!1}const c=o.satBounds,h=o.satAxes,l=this.points;for(let d=0;d<3;d++){const m=c[d],f=h[d];if(e.setFromPoints(f,l),m.isSeparated(e))return!1}for(let d=0;d<3;d++){const m=a[d];for(let f=0;f<4;f++){const x=h[f];if(i.crossVectors(m,x),e.setFromPoints(i,t),s.setFromPoints(i,l),e.isSeparated(s))return!1}}return!0}}(),function(){const u=new g;return function(e){return this.closestPointToPoint(e,u),e.distanceTo(u)}}(),function(){const u=["x","y","z"],t=new Array(12).fill().map(()=>new Q),e=new Array(12).fill().map(()=>new Q),s=new g,i=new g;return function(o,r=0,a=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(a||c)&&(o.getCenter(i),this.closestPointToPoint(i,s),o.closestPointToPoint(s,i),a&&a.copy(s),c&&c.copy(i)),0;const h=r*r,l=o.min,d=o.max,m=this.points;let f=1/0;for(let y=0;y<8;y++){const p=m[y];i.copy(p).clamp(l,d);const A=p.distanceToSquared(i);if(A<f&&(f=A,a&&a.copy(p),c&&c.copy(i),A<h))return Math.sqrt(A)}let x=0;for(let y=0;y<3;y++)for(let p=0;p<=1;p++)for(let A=0;A<=1;A++){const b=(y+1)%3,M=(y+2)%3,w=p<<b|A<<M,z=1<<y|p<<b|A<<M,_=m[w],T=m[z];t[x].set(_,T);const P=u[y],B=u[b],E=u[M],C=e[x],k=C.start,U=C.end;k[P]=l[P],k[B]=p?l[B]:d[B],k[E]=A?l[E]:d[B],U[P]=d[P],U[B]=p?l[B]:d[B],U[E]=A?l[E]:d[B],x++}for(let y=0;y<=1;y++)for(let p=0;p<=1;p++)for(let A=0;A<=1;A++){i.x=y?d.x:l.x,i.y=p?d.y:l.y,i.z=A?d.z:l.z,this.closestPointToPoint(i,s);const b=i.distanceToSquared(s);if(b<f&&(f=b,a&&a.copy(s),c&&c.copy(i),b<h))return Math.sqrt(b)}for(let y=0;y<12;y++){const p=t[y];for(let A=0;A<12;A++){const b=e[A];xe(p,b,s,i);const M=s.distanceToSquared(i);if(M<f&&(f=M,a&&a.copy(s),c&&c.copy(i),M<h))return Math.sqrt(M)}}return Math.sqrt(f)}}();class ai{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 Ke=new ai;new Ke.constructor,new Ke.constructor,new G,new G,new G,new G;const be={strategy:ve,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};let we=!1,ts=0;const Ut=new Ws(()=>new Worker(self.location.href,{type:"module"}));onmessage=async({data:u})=>{if(we)throw new Error("Worker is already running a task.");const{operation:t}=u;if(t==="BUILD_BVH"){we=!0;const{maxWorkerCount:e,index:s,position:i,options:n}=u;Ut.setWorkerCount(bs.floorPowerOfTwo(e));const o=_e(s,i),r=n.indirect?Ye(o):Hs(o),a=n.indirect?ii(o,!0):null,c=Xt(o),h=new Float32Array(new SharedArrayBuffer(c*6*4)),l=[];for(let y=0,p=Ut.workerCount;y<p;y++){const A=Math.ceil(c/p),b=y*A,M=Math.min(A,c-b);l.push(Ut.runSubTask(y,{operation:"BUILD_TRIANGLE_BOUNDS",offset:b,count:M,index:s,position:i,triangleBounds:h}))}await Promise.all(l);const d={_indirectBuffer:a,geometry:o};let m=0;const f={...be,...n,verbose:!1,maxDepth:Math.round(Math.log2(Ut.workerCount)),onProgress:n.includedProgressCallback?es(y=>{m+=.1*y,Me(m)}):null},x=[];for(let y=0,p=r.length;y<p;y++){const A=[],b=r[y],M=Qe(d,h,b.offset,b.count,f),w=hi(M);let z=0,_=0,T=0;for(let B=0,E=w.length;B<E;B++){const C=w[B];if(!!C.count){const U={...be,...n};U.maxDepth=U.maxDepth-C.depth;const tt=Ut.runSubTask(T++,{operation:"BUILD_SUBTREE",offset:C.offset,count:C.count,indirectBuffer:a,index:s,position:i,triangleBounds:h,options:U},es(X=>{m+=.9*X/T,Me(m)})).then(X=>{const dt=X.buffer;C.buffer=dt,z+=dt.byteLength});A.push(tt)}else _++}await Promise.all(A);const S=n.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,P=new S(z+_*kt);Je(0,M,P),x.push(P)}postMessage({error:null,serialized:{roots:x,index:s,indirectBuffer:a},position:i,progress:1}),we=!1}else if(t==="BUILD_SUBTREE"){const{offset:e,count:s,indirectBuffer:i,index:n,position:o,triangleBounds:r,options:a}=u,c={_indirectBuffer:i,geometry:_e(n,o)},h={...be,...a,onProgress:a.includedProgressCallback?Me:null},l=Qe(c,r,e,s,h),d=pe(l),m=new ArrayBuffer(kt*d);Je(0,l,m),postMessage({type:"result",buffer:m,progress:1},[m])}else if(t==="BUILD_TRIANGLE_BOUNDS"){const{index:e,position:s,triangleBounds:i,offset:n,count:o}=u,r=_e(e,s);js(r,i,n,o),postMessage({type:"result"})}};function es(u){let t=0;return function(s){u(s-t),t=s}}function Me(u){u=Math.min(u,1);const t=performance.now();t-ts>=10&&u!==1&&(postMessage({error:null,progress:u,type:"progress"}),ts=t)}function _e(u,t){const e=new ue;return u&&(e.index=new ot(u,1,!1)),e.setAttribute("position",new ot(t,3)),e}function hi(u){const t=[];return e(u),t;function e(s,i=0){s.depth=i,t.push(s),!!s.count||(e(s.left,i+1),e(s.right,i+1))}}})();