@egjs/view3d
Version:
Fast & Customizable glTF 3D model viewer, packed with full of features!
9 lines • 725 kB
JavaScript
/*
Copyright (c) NAVER Corp.
name: @egjs/view3d
license: MIT
author: NAVER Corp.
repository: https://github.com/naver/egjs-view3d
version: 2.10.1
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).View3D=t()}(this,function(){"use strict";const W=0,j=1,X=2,R=1,C=3,Ne=0,Re=1,Fe=2,q=0,Y=1,Z=2,Q=3,$=4,ee=5,te=100,re=101,ne=102,ae=103,se=104,oe=200,le=201,he=202,ce=203,ue=204,de=205,pe=206,me=207,fe=208,ge=209,ve=210,_e=0,xe=1,ye=2,be=3,we=4,Me=5,Ee=6,Te=7,Ue=0,E=301,T=302,v=303,P=304,O=306,D=307,H=1e3,ze=1001,k=1002,Ce=1003,V=1004,Se=1005,B=1006,Ae=1007,Be=1008,He=1009,s=1010,N=1011,Le=1012,F=1013,ke=1014,Ge=1015,Ve=1016,U=1017,z=1018,We=1019,je=1020,Xe=1021,qe=1022,Pe=1023,Ye=1024,Ze=1025,Je=Pe,Ke=1026,Qe=1027,$e=1028,et=1029,tt=1030,it=1031,rt=1032,nt=1033,at=33776,st=33777,ot=33778,lt=33779,ht=35840,ct=35841,ut=35842,dt=35843,pt=36196,mt=37492,ft=37496,gt=37808,vt=37809,_t=37810,xt=37811,yt=37812,bt=37813,wt=37814,Mt=37815,Et=37816,Tt=37817,St=37818,At=37819,Lt=37820,Rt=37821,Ct=36492,Pt=37840,It=37841,Ot=37842,Dt=37843,Nt=37844,Ft=37845,Ut=37846,zt=37847,Bt=37848,Ht=37849,kt=37850,Gt=37851,Vt=37852,Wt=37853,jt=2300,Xt=2301,qt=2400,Yt=2401,Zt=3e3,Jt=3001,i=3201,Kt=0,Qt=1,$t=35044,ei=35048,ti="300 es";class ii{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){var i;return void 0!==this._listeners&&void 0!==(i=this._listeners)[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){var i;void 0!==this._listeners&&void 0!==(e=this._listeners[e])&&-1!==(i=e.indexOf(t))&&e.splice(i,1)}dispatchEvent(i){if(void 0!==this._listeners){var e=this._listeners[i.type];if(void 0!==e){i.target=this;var r=e.slice(0);for(let e=0,t=r.length;e<t;e++)r[e].call(this,i);i.target=null}}}}let ri=1234567;const ni=Math.PI/180,ai=180/Math.PI,si=[];for(let e=0;e<256;e++)si[e]=(e<16?"0":"")+e.toString(16);const oi="undefined"!=typeof crypto&&"randomUUID"in crypto;function li(){var e,t,i,r;return(oi?crypto.randomUUID():(e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0,si[255&e]+si[e>>8&255]+si[e>>16&255]+si[e>>24&255]+"-"+si[255&t]+si[t>>8&255]+"-"+si[t>>16&15|64]+si[t>>24&255]+"-"+si[63&i|128]+si[i>>8&255]+"-"+si[i>>16&255]+si[i>>24&255]+si[255&r]+si[r>>8&255]+si[r>>16&255]+si[r>>24&255])).toUpperCase()}function hi(e,t,i){return Math.max(t,Math.min(i,e))}function ci(e,t){return(e%t+t)%t}function ui(e,t,i){return(1-i)*e+i*t}function di(e){return 0==(e&e-1)&&0!==e}function pi(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function mi(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var fi=Object.freeze({__proto__:null,DEG2RAD:ni,RAD2DEG:ai,generateUUID:li,clamp:hi,euclideanModulo:ci,mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},inverseLerp:function(e,t,i){return e!==t?(i-e)/(t-e):0},lerp:ui,damp:function(e,t,i,r){return ui(e,t,1-Math.exp(-i*r))},pingpong:function(e,t=1){return t-Math.abs(ci(e,2*t)-t)},smoothstep:function(e,t,i){return e<=t?0:i<=e?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:i<=e?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return((ri=16807*(ri=void 0!==e?e%2147483647:ri)%2147483647)-1)/2147483646},degToRad:function(e){return e*ni},radToDeg:function(e){return e*ai},isPowerOfTwo:di,ceilPowerOfTwo:pi,floorPowerOfTwo:mi,setQuaternionFromProperEuler:function(e,t,i,r,n){var a=Math.cos,s=Math.sin,o=a(i/2),l=s(i/2),h=a((t+r)/2),c=s((t+r)/2),u=a((t-r)/2),d=s((t-r)/2),p=a((r-t)/2),m=s((r-t)/2);switch(n){case"XYX":e.set(o*c,l*u,l*d,o*h);break;case"YZY":e.set(l*d,o*c,l*u,o*h);break;case"ZXZ":e.set(l*u,l*d,o*c,o*h);break;case"XZX":e.set(o*c,l*m,l*p,o*h);break;case"YXY":e.set(l*p,o*c,l*m,o*h);break;case"ZYZ":e.set(l*m,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}});class ie{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){var t=this.x,i=this.y,e=e.elements;return this.x=e[0]*t+e[3]*i+e[6],this.y=e[1]*t+e[4]*i+e[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x,e=this.y-e.y;return t*t+e*e}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){var i=Math.cos(t),t=Math.sin(t),r=this.x-e.x,n=this.y-e.y;return this.x=r*i-n*t+e.x,this.y=r*t+n*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}ie.prototype.isVector2=!0;class gi{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,r,n,a,s,o,l){var h=this.elements;return h[0]=e,h[1]=r,h[2]=s,h[3]=t,h[4]=n,h[5]=o,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){var t=this.elements,e=e.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){e=e.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){var e=e.elements,t=t.elements,i=this.elements,r=e[0],n=e[3],a=e[6],s=e[1],o=e[4],l=e[7],h=e[2],c=e[5],e=e[8],u=t[0],d=t[3],p=t[6],m=t[1],f=t[4],g=t[7],v=t[2],_=t[5],t=t[8];return i[0]=r*u+n*m+a*v,i[3]=r*d+n*f+a*_,i[6]=r*p+n*g+a*t,i[1]=s*u+o*m+l*v,i[4]=s*d+o*f+l*_,i[7]=s*p+o*g+l*t,i[2]=h*u+c*m+e*v,i[5]=h*d+c*f+e*_,i[8]=h*p+c*g+e*t,this}multiplyScalar(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){var e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],s=e[5],o=e[6],l=e[7],e=e[8];return t*a*e-t*s*l-i*n*e+i*s*o+r*n*l-r*a*o}invert(){var e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=h*a-s*l,u=s*o-h*n,d=l*n-a*o,p=t*c+i*u+r*d;return 0==p?this.set(0,0,0,0,0,0,0,0,0):(e[0]=c*(c=1/p),e[1]=(r*l-h*i)*c,e[2]=(s*i-r*a)*c,e[3]=u*c,e[4]=(h*t-r*o)*c,e[5]=(r*n-s*t)*c,e[6]=d*c,e[7]=(i*o-l*t)*c,e[8]=(a*t-i*n)*c,this)}transpose(){var e=this.elements,t=e[1];return 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(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,n,a,s){var o=Math.cos(n),n=Math.sin(n);return this.set(i*o,i*n,-i*(o*a+n*s)+a+e,-r*n,r*o,-r*(-n*a+o*s)+s+t,0,0,1),this}scale(e,t){var i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this}rotate(e){var t=Math.cos(e),e=Math.sin(e),i=this.elements,r=i[0],n=i[3],a=i[6],s=i[1],o=i[4],l=i[7];return i[0]=t*r+e*s,i[3]=t*n+e*o,i[6]=t*a+e*l,i[1]=-e*r+t*s,i[4]=-e*n+t*o,i[7]=-e*a+t*l,this}translate(e,t){var i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this}equals(e){var t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(t,i=0){for(let e=0;e<9;e++)this.elements[e]=t[e+i];return this}toArray(e=[],t=0){var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}function vi(i){if(0===i.length)return-1/0;let r=i[0];for(let e=1,t=i.length;e<t;++e)i[e]>r&&(r=i[e]);return r}function _i(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function xi(i,e=0){let r=3735928559^e,n=1103547991^e;for(let e=0,t;e<i.length;e++)t=i.charCodeAt(e),r=Math.imul(r^t,2654435761),n=Math.imul(n^t,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&(n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909)))+(r>>>0)}gi.prototype.isMatrix3=!0;let yi;class bi{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;var i;return 2048<(t=e instanceof HTMLCanvasElement?e:((yi=void 0===yi?_i("canvas"):yi).width=e.width,yi.height=e.height,i=yi.getContext("2d"),e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),yi)).width||2048<t.height?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let wi=0;class Mi extends ii{constructor(e=Mi.DEFAULT_IMAGE,t=Mi.DEFAULT_MAPPING,i=ze,r=ze,n=B,a=Be,s=Pe,o=He,l=1,h=Zt){super(),Object.defineProperty(this,"id",{value:wi++}),this.uuid=li(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=r,this.magFilter=n,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new ie(0,0),this.repeat=new ie(1,1),this.center=new ie(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new gi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}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(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=li()),!t&&void 0===e.images[r.uuid]){let i;if(Array.isArray(r)){i=[];for(let e=0,t=r.length;e<t;e++)r[e].isDataTexture?i.push(Ei(r[e].image)):i.push(Ei(r[e]))}else i=Ei(r);e.images[r.uuid]={uuid:r.uuid,url:i}}i.image=r.uuid}return"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300===this.mapping){if(e.applyMatrix3(this.matrix),e.x<0||1<e.x)switch(this.wrapS){case H:e.x=e.x-Math.floor(e.x);break;case ze:e.x=e.x<0?0:1;break;case k:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||1<e.y)switch(this.wrapT){case H:e.y=e.y-Math.floor(e.y);break;case ze:e.y=e.y<0?0:1;break;case k:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}return e}set needsUpdate(e){!0===e&&this.version++}}function Ei(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?bi.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}Mi.DEFAULT_IMAGE=void 0,Mi.DEFAULT_MAPPING=300,Mi.prototype.isTexture=!0;class Ie{constructor(e=0,t=0,i=0,r=1){this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){var t=this.x,i=this.y,r=this.z,n=this.w,e=e.elements;return this.x=e[0]*t+e[4]*i+e[8]*r+e[12]*n,this.y=e[1]*t+e[5]*i+e[9]*r+e[13]*n,this.z=e[2]*t+e[6]*i+e[10]*r+e[14]*n,this.w=e[3]*t+e[7]*i+e[11]*r+e[15]*n,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(t){let e,i,r,n;var a,s,o,l,h,c,t=t.elements,u=t[0],d=t[4],p=t[8],m=t[1],f=t[5],g=t[9],v=t[2],_=t[6],t=t[10];if(Math.abs(d-m)<.01&&Math.abs(p-v)<.01&&Math.abs(g-_)<.01)Math.abs(d+m)<.1&&Math.abs(p+v)<.1&&Math.abs(g+_)<.1&&Math.abs(u+f+t-3)<.1?this.set(1,0,0,0):(e=Math.PI,o=(t+1)/2,l=(d+m)/4,h=(p+v)/4,c=(g+_)/4,(s=(f+1)/2)<(a=(u+1)/2)&&o<a?n=a<.01?(i=0,r=.707106781):(i=Math.sqrt(a),r=l/i,h/i):o<s?n=s<.01?(i=.707106781,r=0,.707106781):(r=Math.sqrt(s),i=l/r,c/r):o<.01?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(o),i=h/n,r=c/n),this.set(i,r,n,e));else{let e=Math.sqrt((_-g)*(_-g)+(p-v)*(p-v)+(m-d)*(m-d));Math.abs(e)<.001&&(e=1),this.x=(_-g)/e,this.y=(p-v)/e,this.z=(m-d)/e,this.w=Math.acos((u+f+t-1)/2)}return this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}Ie.prototype.isVector4=!0;class Ti extends ii{constructor(e,t,i={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new Ie(0,0,e,t),this.scissorTest=!1,this.viewport=new Ie(0,0,e,t),this.texture=new Mi(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:B,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,i=1){this.width===e&&this.height===t&&this.depth===i||(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image={...this.texture.image},this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Ti.prototype.isWebGLRenderTarget=!0;(class extends Ti{});class Si extends Ti{constructor(e,t,i){super(e,t,i),this.samples=4}copy(e){return super.copy.call(this,e),this.samples=e.samples,this}}Si.prototype.isWebGLMultisampleRenderTarget=!0;class _{constructor(e=0,t=0,i=0,r=1){this._x=e,this._y=t,this._z=i,this._w=r}static slerp(e,t,i,r){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),i.slerpQuaternions(e,t,r)}static slerpFlat(e,t,i,r,n,a,s){let o=i[r+0],l=i[r+1],h=i[r+2],c=i[r+3];var i=n[a+0],r=n[a+1],u=n[a+2],n=n[a+3];if(0===s)e[t+0]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c;else if(1===s)e[t+0]=i,e[t+1]=r,e[t+2]=u,e[t+3]=n;else{if(c!==n||o!==i||l!==r||h!==u){let e=1-s;var a=o*i+l*r+h*u+c*n,d=0<=a?1:-1,p=1-a*a,a=(p>Number.EPSILON&&(p=Math.sqrt(p),a=Math.atan2(p,a*d),e=Math.sin(e*a)/p,s=Math.sin(s*a)/p),s*d);o=o*e+i*a,l=l*e+r*a,h=h*e+u*a,c=c*e+n*a,e===1-s&&(p=1/Math.sqrt(o*o+l*l+h*h+c*c),o*=p,l*=p,h*=p,c*=p)}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}}static multiplyQuaternionsFlat(e,t,i,r,n,a){var s=i[r],o=i[r+1],l=i[r+2],i=i[r+3],r=n[a],h=n[a+1],c=n[a+2],n=n[a+3];return e[t]=s*n+i*r+o*c-l*h,e[t+1]=o*n+i*h+l*r-s*c,e[t+2]=l*n+i*c+s*h-o*r,e[t+3]=i*n-s*r-o*h-l*c,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=e._x,r=e._y,n=e._z,a=e._order,e=Math.cos,s=Math.sin,o=e(i/2),l=e(r/2),h=e(n/2),c=s(i/2),u=s(r/2),d=s(n/2);switch(a){case"XYZ":this._x=c*l*h+o*u*d,this._y=o*u*h-c*l*d,this._z=o*l*d+c*u*h,this._w=o*l*h-c*u*d;break;case"YXZ":this._x=c*l*h+o*u*d,this._y=o*u*h-c*l*d,this._z=o*l*d-c*u*h,this._w=o*l*h+c*u*d;break;case"ZXY":this._x=c*l*h-o*u*d,this._y=o*u*h+c*l*d,this._z=o*l*d+c*u*h,this._w=o*l*h-c*u*d;break;case"ZYX":this._x=c*l*h-o*u*d,this._y=o*u*h+c*l*d,this._z=o*l*d-c*u*h,this._w=o*l*h+c*u*d;break;case"YZX":this._x=c*l*h+o*u*d,this._y=o*u*h+c*l*d,this._z=o*l*d-c*u*h,this._w=o*l*h-c*u*d;break;case"XZY":this._x=c*l*h-o*u*d,this._y=o*u*h-c*l*d,this._z=o*l*d+c*u*h,this._w=o*l*h+c*u*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){var t=t/2,i=Math.sin(t);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(e){var e=e.elements,t=e[0],i=e[4],r=e[8],n=e[1],a=e[5],s=e[9],o=e[2],l=e[6],e=e[10],h=t+a+e;return 0<h?(h=.5/Math.sqrt(h+1),this._w=.25/h,this._x=(l-s)*h,this._y=(r-o)*h,this._z=(n-i)*h):a<t&&e<t?(h=2*Math.sqrt(1+t-a-e),this._w=(l-s)/h,this._x=.25*h,this._y=(i+n)/h,this._z=(r+o)/h):e<a?(h=2*Math.sqrt(1+a-t-e),this._w=(r-o)/h,this._x=(i+n)/h,this._y=.25*h,this._z=(s+l)/h):(h=2*Math.sqrt(1+e-t-a),this._w=(n-i)/h,this._x=(r+o)/h,this._y=(s+l)/h,this._z=.25*h),this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x),this._w=i,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(hi(this.dot(e),-1,1)))}rotateTowards(e,t){var i=this.angleTo(e);return 0!==i&&(t=Math.min(1,t/i),this.slerp(e,t)),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(this._x=this._x*(e=1/e),this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){var i=e._x,r=e._y,n=e._z,e=e._w,a=t._x,s=t._y,o=t._z,t=t._w;return this._x=i*t+e*a+r*o-n*s,this._y=r*t+e*s+n*a-i*o,this._z=n*t+e*o+i*s-r*a,this._w=e*t-i*a-r*s-n*o,this._onChangeCallback(),this}slerp(t,i){if(0!==i){if(1===i)return this.copy(t);var r,n,a=this._x,s=this._y,o=this._z,l=this._w;let e=l*t._w+a*t._x+s*t._y+o*t._z;e<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,e=-e):this.copy(t),1<=e?(this._w=l,this._x=a,this._y=s,this._z=o):((t=1-e*e)<=Number.EPSILON?(this._w=(r=1-i)*l+i*this._w,this._x=r*a+i*this._x,this._y=r*s+i*this._y,this._z=r*o+i*this._z,this.normalize()):(r=Math.sqrt(t),t=Math.atan2(r,e),n=Math.sin((1-i)*t)/r,i=Math.sin(i*t)/r,this._w=l*n+this._w*i,this._x=a*n+this._x*i,this._y=s*n+this._y*i,this._z=o*n+this._z*i),this._onChangeCallback())}return this}slerpQuaternions(e,t,i){this.copy(e).slerp(t,i)}random(){var e=Math.random(),t=Math.sqrt(1-e),e=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),e*Math.sin(r),e*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}_.prototype.isQuaternion=!0;class Oe{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Li.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Li.setFromAxisAngle(e,t))}applyMatrix3(e){var t=this.x,i=this.y,r=this.z,e=e.elements;return this.x=e[0]*t+e[3]*i+e[6]*r,this.y=e[1]*t+e[4]*i+e[7]*r,this.z=e[2]*t+e[5]*i+e[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){var t=this.x,i=this.y,r=this.z,e=e.elements,n=1/(e[3]*t+e[7]*i+e[11]*r+e[15]);return this.x=(e[0]*t+e[4]*i+e[8]*r+e[12])*n,this.y=(e[1]*t+e[5]*i+e[9]*r+e[13])*n,this.z=(e[2]*t+e[6]*i+e[10]*r+e[14])*n,this}applyQuaternion(e){var t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,s=e.z,e=e.w,o=e*t+a*r-s*i,l=e*i+s*t-n*r,h=e*r+n*i-a*t,t=-n*t-a*i-s*r;return this.x=o*e+t*-n+l*-s-h*-a,this.y=l*e+t*-a+h*-n-o*-s,this.z=h*e+t*-s+o*-a-l*-n,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){var t=this.x,i=this.y,r=this.z,e=e.elements;return this.x=e[0]*t+e[4]*i+e[8]*r,this.y=e[1]*t+e[5]*i+e[9]*r,this.z=e[2]*t+e[6]*i+e[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){var i=e.x,r=e.y,e=e.z,n=t.x,a=t.y,t=t.z;return this.x=r*t-e*a,this.y=e*n-i*t,this.z=i*a-r*n,this}projectOnVector(e){var t=e.lengthSq();return 0===t?this.set(0,0,0):(t=e.dot(this)/t,this.copy(e).multiplyScalar(t))}projectOnPlane(e){return Ai.copy(this).projectOnVector(e),this.sub(Ai)}reflect(e){return this.sub(Ai.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:(e=this.dot(e)/t,Math.acos(hi(e,-1,1)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x,i=this.y-e.y,e=this.z-e.z;return t*t+i*i+e*e}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){var r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){e=e.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),e=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=e,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){var e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Oe.prototype.isVector3=!0;const Ai=new Oe,Li=new _;class Ri{constructor(e=new Oe(1/0,1/0,1/0),t=new Oe(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(i){let r=1/0,n=1/0,a=1/0,s=-1/0,o=-1/0,l=-1/0;for(let e=0,t=i.length;e<t;e+=3){var h=i[e],c=i[e+1],u=i[e+2];h<r&&(r=h),c<n&&(n=c),u<a&&(a=u),h>s&&(s=h),c>o&&(o=c),u>l&&(l=u)}return this.min.set(r,n,a),this.max.set(s,o,l),this}setFromBufferAttribute(i){let r=1/0,n=1/0,a=1/0,s=-1/0,o=-1/0,l=-1/0;for(let e=0,t=i.count;e<t;e++){var h=i.getX(e),c=i.getY(e),u=i.getZ(e);h<r&&(r=h),c<n&&(n=c),u<a&&(a=u),h>s&&(s=h),c>o&&(o=c),u>l&&(l=u)}return this.min.set(r,n,a),this.max.set(s,o,l),this}setFromPoints(i){this.makeEmpty();for(let e=0,t=i.length;e<t;e++)this.expandByPoint(i[e]);return this}setFromCenterAndSize(e,t){t=Pi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(t),this.max.copy(e).add(t),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){e.updateWorldMatrix(!1,!1);var t=e.geometry,i=(void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),Ii.copy(t.boundingBox),Ii.applyMatrix4(e.matrixWorld),this.union(Ii)),e.children);for(let e=0,t=i.length;e<t;e++)this.expandByObject(i[e]);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Pi),Pi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return i=0<e.normal.x?(t=e.normal.x*this.min.x,e.normal.x*this.max.x):(t=e.normal.x*this.max.x,e.normal.x*this.min.x),0<e.normal.y?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),0<e.normal.z?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){return!this.isEmpty()&&(this.getCenter(Bi),Hi.subVectors(this.max,Bi),Oi.subVectors(e.a,Bi),Di.subVectors(e.b,Bi),Ni.subVectors(e.c,Bi),Fi.subVectors(Di,Oi),Ui.subVectors(Ni,Di),zi.subVectors(Oi,Ni),!!Vi([0,-Fi.z,Fi.y,0,-Ui.z,Ui.y,0,-zi.z,zi.y,Fi.z,0,-Fi.x,Ui.z,0,-Ui.x,zi.z,0,-zi.x,-Fi.y,Fi.x,0,-Ui.y,Ui.x,0,-zi.y,zi.x,0],Oi,Di,Ni,Hi))&&!!Vi([1,0,0,0,1,0,0,0,1],Oi,Di,Ni,Hi)&&(ki.crossVectors(Fi,Ui),Vi([ki.x,ki.y,ki.z],Oi,Di,Ni,Hi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Pi.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(Pi).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Ci[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ci[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ci[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ci[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ci[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ci[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ci[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ci[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ci)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}Ri.prototype.isBox3=!0;const Ci=[new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe],Pi=new Oe,Ii=new Ri,Oi=new Oe,Di=new Oe,Ni=new Oe,Fi=new Oe,Ui=new Oe,zi=new Oe,Bi=new Oe,Hi=new Oe,ki=new Oe,Gi=new Oe;function Vi(i,r,n,a,s){for(let e=0,t=i.length-3;e<=t;e+=3){Gi.fromArray(i,e);var o=s.x*Math.abs(Gi.x)+s.y*Math.abs(Gi.y)+s.z*Math.abs(Gi.z),l=r.dot(Gi),h=n.dot(Gi),c=a.dot(Gi);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}const Wi=new Ri,ji=new Oe,Xi=new Oe,qi=new Oe;class Yi{constructor(e=new Oe,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(i,e){var r=this.center;void 0!==e?r.copy(e):Wi.setFromPoints(i).getCenter(r);let n=0;for(let e=0,t=i.length;e<t;e++)n=Math.max(n,r.distanceToSquared(i[e]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){var i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?e.makeEmpty():(e.set(this.center,this.center),e.expandByScalar(this.radius)),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){qi.subVectors(e,this.center);var t,e=qi.lengthSq();return e>this.radius*this.radius&&(t=.5*((e=Math.sqrt(e))-this.radius),this.center.add(qi.multiplyScalar(t/e)),this.radius+=t),this}union(e){return Xi.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(ji.copy(e.center).add(Xi)),this.expandByPoint(ji.copy(e.center).sub(Xi)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Zi=new Oe,Ji=new Oe,Ki=new Oe,Qi=new Oe,$i=new Oe,er=new Oe,tr=new Oe;class ir{constructor(e=new Oe,t=new Oe(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Zi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);e=t.dot(this.direction);return e<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(e).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){var t=Zi.subVectors(e,this.origin).dot(this.direction);return(t<0?this.origin:(Zi.copy(this.direction).multiplyScalar(t).add(this.origin),Zi)).distanceToSquared(e)}distanceSqToSegment(e,t,i,r){Ji.copy(e).add(t).multiplyScalar(.5),Ki.copy(t).sub(e).normalize(),Qi.copy(this.origin).sub(Ji);var e=.5*e.distanceTo(t),t=-this.direction.dot(Ki),n=Qi.dot(this.direction),a=-Qi.dot(Ki),s=Qi.lengthSq(),o=Math.abs(1-t*t);let l,h,c,u;return c=0<o?(l=t*a-n,h=t*n-a,u=e*o,0<=l?h>=-u?h<=u?(o=1/o,l*=o,h*=o,l*(l+t*h+2*n)+h*(t*l+h+2*a)+s):(h=e,-(l=Math.max(0,-(t*h+n)))*l+h*(h+2*a)+s):(h=-e,-(l=Math.max(0,-(t*h+n)))*l+h*(h+2*a)+s):h<=-u?(l=Math.max(0,-(-t*e+n)),h=0<l?-e:Math.min(Math.max(-e,-a),e),-l*l+h*(h+2*a)+s):h<=u?(l=0,(h=Math.min(Math.max(-e,-a),e))*(h+2*a)+s):(l=Math.max(0,-(t*e+n)),h=0<l?e:Math.min(Math.max(-e,-a),e),-l*l+h*(h+2*a)+s)):(h=0<t?-e:e,-(l=Math.max(0,-(t*h+n)))*l+h*(h+2*a)+s),i&&i.copy(this.direction).multiplyScalar(l).add(this.origin),r&&r.copy(Ki).multiplyScalar(h).add(Ji),c}intersectSphere(e,t){Zi.subVectors(e.center,this.origin);var i=Zi.dot(this.direction),r=Zi.dot(Zi)-i*i,e=e.radius*e.radius;return e<r||(r=i+(e=Math.sqrt(e-r)),(i=i-e)<0&&r<0)?null:i<0?this.at(r,t):this.at(i,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){var t=e.normal.dot(this.direction);return 0===t?0===e.distanceToPoint(this.origin)?0:null:0<=(e=-(this.origin.dot(e.normal)+e.constant)/t)?e:null}intersectPlane(e,t){e=this.distanceToPlane(e);return null===e?null:this.at(e,t)}intersectsPlane(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,n,a,s,o;var l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return r=0<=l?(i=(e.min.x-u.x)*l,(e.max.x-u.x)*l):(i=(e.max.x-u.x)*l,(e.min.x-u.x)*l),a=0<=h?(n=(e.min.y-u.y)*h,(e.max.y-u.y)*h):(n=(e.max.y-u.y)*h,(e.min.y-u.y)*h),i>a||n>r||((n>i||i!=i)&&(i=n),(a<r||r!=r)&&(r=a),o=0<=c?(s=(e.min.z-u.z)*c,(e.max.z-u.z)*c):(s=(e.max.z-u.z)*c,(e.min.z-u.z)*c),i>o)||s>r||((s>i||i!=i)&&(i=s),(r=o<r||r!=r?o:r)<0)?null:this.at(0<=i?i:r,t)}intersectsBox(e){return null!==this.intersectBox(e,Zi)}intersectTriangle(e,t,i,r,n){$i.subVectors(t,e),er.subVectors(i,e),tr.crossVectors($i,er);let a=this.direction.dot(tr),s;if(0<a){if(r)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Qi.subVectors(this.origin,e);t=s*this.direction.dot(er.crossVectors(Qi,er));return t<0||(i=s*this.direction.dot($i.cross(Qi)))<0||t+i>a||(r=-s*Qi.dot(tr))<0?null:this.at(r/a,n)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class De{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,i,r,n,a,s,o,l,h,c,u,d,p,m,f){var g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=n,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 De).fromArray(this.elements)}copy(e){var t=this.elements,e=e.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],this}copyPosition(e){var t=this.elements,e=e.elements;return t[12]=e[12],t[13]=e[13],t[14]=e[14],this}setFromMatrix3(e){e=e.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(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){var t=this.elements,i=e.elements,r=1/rr.setFromMatrixColumn(e,0).length(),n=1/rr.setFromMatrixColumn(e,1).length(),e=1/rr.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*e,t[9]=i[9]*e,t[10]=i[10]*e,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t,i,r,n,a=this.elements,s=e.x,o=e.y,l=e.z,h=Math.cos(s),s=Math.sin(s),c=Math.cos(o),o=Math.sin(o),u=Math.cos(l),l=Math.sin(l);return"XYZ"===e.order?(i=h*u,r=h*l,n=s*u,t=s*l,a[0]=c*u,a[4]=-c*l,a[8]=o,a[1]=r+n*o,a[5]=i-t*o,a[9]=-s*c,a[2]=t-i*o,a[6]=n+r*o,a[10]=h*c):"YXZ"===e.order?(t=c*l,i=o*u,a[0]=(n=c*u)+(r=o*l)*s,a[4]=i*s-t,a[8]=h*o,a[1]=h*l,a[5]=h*u,a[9]=-s,a[2]=t*s-i,a[6]=r+n*s,a[10]=h*c):"ZXY"===e.order?(t=c*l,i=o*u,a[0]=(r=c*u)-(n=o*l)*s,a[4]=-h*l,a[8]=i+t*s,a[1]=t+i*s,a[5]=h*u,a[9]=n-r*s,a[2]=-h*o,a[6]=s,a[10]=h*c):"ZYX"===e.order?(t=h*u,i=h*l,n=s*u,r=s*l,a[0]=c*u,a[4]=n*o-i,a[8]=t*o+r,a[1]=c*l,a[5]=r*o+t,a[9]=i*o-n,a[2]=-o,a[6]=s*c,a[10]=h*c):"YZX"===e.order?(r=h*c,t=h*o,i=s*c,n=s*o,a[0]=c*u,a[4]=n-r*l,a[8]=i*l+t,a[1]=l,a[5]=h*u,a[9]=-s*u,a[2]=-o*u,a[6]=t*l+i,a[10]=r-n*l):"XZY"===e.order&&(t=h*c,i=h*o,r=s*c,n=s*o,a[0]=c*u,a[4]=-l,a[8]=o*u,a[1]=t*l+n,a[5]=h*u,a[9]=i*l-r,a[2]=r*l-i,a[6]=s*u,a[10]=n*l+t),a[3]=0,a[7]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,this}makeRotationFromQuaternion(e){return this.compose(ar,e,sr)}lookAt(e,t,i){var r=this.elements;return hr.subVectors(e,t),0===hr.lengthSq()&&(hr.z=1),hr.normalize(),or.crossVectors(i,hr),0===or.lengthSq()&&(1===Math.abs(i.z)?hr.x+=1e-4:hr.z+=1e-4,hr.normalize(),or.crossVectors(i,hr)),or.normalize(),lr.crossVectors(hr,or),r[0]=or.x,r[4]=lr.x,r[8]=hr.x,r[1]=or.y,r[5]=lr.y,r[9]=hr.y,r[2]=or.z,r[6]=lr.z,r[10]=hr.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)