UNPKG

@olearis/view3d

Version:

Fast & Customizable glTF 3D model viewer, packed with full of features!

9 lines 746 kB
/* Copyright (c) NAVER Corp. name: @olearis/view3d license: MIT author: NAVER Corp. repository: https://github.com/naver/egjs-view3d version: 2.10.2 */ !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";function i(t,e){var i,r=Object.keys(t);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(t),e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)),r}function s(r){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach(function(e){var t,i;t=r,i=n[e=e],e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}return r}function z(e,t,i,r,n,a,s){try{var o=e[a](s),l=o.value}catch(e){return void i(e)}o.done?t(l):Promise.resolve(l).then(r,n)}var V=0,W=1,j=2,P=1,D=3,De=0,Le=1,Fe=2,X=0,q=1,Y=2,Z=3,$=4,ee=5,te=100,ie=101,re=102,ne=103,ae=104,se=200,oe=201,le=202,he=203,ce=204,ue=205,de=206,pe=207,me=208,fe=209,ve=210,ge=0,_e=1,xe=2,ye=3,we=4,be=5,Me=6,Ee=7,Ue=0,M=301,E=302,l=303,A=304,L=306,I=307,Te=1e3,ze=1001,Se=1002,Re=1003,Ae=1004,Be=1005,k=1006,He=1007,ke=1008,Ge=1009,o=1010,N=1011,Ve=1012,F=1013,We=1014,je=1015,Xe=1016,U=1017,B=1018,H=1019,qe=1020,Ye=1021,Ze=1022,Ce=1023,Je=1024,Ke=1025,Qe=Ce,$e=1026,et=1027,tt=1028,it=1029,rt=1030,nt=1031,at=1032,st=1033,ot=33776,lt=33777,ht=33778,ct=33779,ut=35840,dt=35841,pt=35842,mt=35843,ft=36196,vt=37492,gt=37496,_t=37808,xt=37809,yt=37810,wt=37811,bt=37812,Mt=37813,Et=37814,Tt=37815,St=37816,At=37817,Lt=37818,Rt=37819,Ct=37820,Pt=37821,Ot=36492,Dt=37840,It=37841,Nt=37842,Ft=37843,Ut=37844,zt=37845,Bt=37846,Ht=37847,kt=37848,Gt=37849,Vt=37850,Wt=37851,jt=37852,Xt=37853,qt=2300,Yt=2301,Zt=2400,Jt=2401,Kt=3e3,Qt=3001,$t=3201,ei=0,ti=1,ii=35044,ri=35048,ni="300 es";class ai{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(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var i=t.slice(0),r=0,n=i.length;r<n;r++)i[r].call(this,e);e.target=null}}}}for(var si=1234567,oi=Math.PI/180,li=180/Math.PI,hi=[],ci=0;ci<256;ci++)hi[ci]=(ci<16?"0":"")+ci.toString(16);var ui="undefined"!=typeof crypto&&"randomUUID"in crypto;function di(){var e,t,i,r;return(ui?crypto.randomUUID():(e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0,hi[255&e]+hi[e>>8&255]+hi[e>>16&255]+hi[e>>24&255]+"-"+hi[255&t]+hi[t>>8&255]+"-"+hi[t>>16&15|64]+hi[t>>24&255]+"-"+hi[63&i|128]+hi[i>>8&255]+"-"+hi[i>>16&255]+hi[i>>24&255]+hi[255&r]+hi[r>>8&255]+hi[r>>16&255]+hi[r>>24&255])).toUpperCase()}function pi(e,t,i){return Math.max(t,Math.min(i,e))}function mi(e,t){return(e%t+t)%t}function fi(e,t,i){return(1-i)*e+i*t}function vi(e){return 0==(e&e-1)&&0!==e}function gi(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function _i(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var xi,yi=Object.freeze({__proto__:null,DEG2RAD:oi,RAD2DEG:li,generateUUID:di,clamp:pi,euclideanModulo:mi,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:fi,damp:function(e,t,i,r){return fi(e,t,1-Math.exp(-i*r))},pingpong:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;return t-Math.abs(mi(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((si=16807*(si=void 0!==e?e%2147483647:si)%2147483647)-1)/2147483646},degToRad:function(e){return e*oi},radToDeg:function(e){return e*li},isPowerOfTwo:vi,ceilPowerOfTwo:gi,floorPowerOfTwo:_i,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(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]: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){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this}toArray(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]: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 wi{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],v=t[7],g=t[2],_=t[5],t=t[8];return i[0]=r*u+n*m+a*g,i[3]=r*d+n*f+a*_,i[6]=r*p+n*v+a*t,i[1]=s*u+o*m+l*g,i[4]=s*d+o*f+l*_,i[7]=s*p+o*v+l*t,i[2]=h*u+c*m+e*g,i[5]=h*d+c*f+e*_,i[8]=h*p+c*v+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){for(var t=this.elements,i=e.elements,r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e){for(var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,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 bi(e){if(0===e.length)return-1/0;for(var t=e[0],i=1,r=e.length;i<r;++i)e[i]>t&&(t=e[i]);return t}function Mi(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Ei(e,t){for(var i,t=1<arguments.length&&void 0!==t?t:0,r=3735928559^t,n=1103547991^t,a=0;a<e.length;a++)i=e.charCodeAt(a),r=Math.imul(r^i,2654435761),n=Math.imul(n^i,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)}wi.prototype.isMatrix3=!0;class Ti{static getDataURL(e){var t;return/^data:/i.test(e.src)||"undefined"==typeof HTMLCanvasElement?e.src:2048<(t=e instanceof HTMLCanvasElement?e:((xi=void 0===xi?Mi("canvas"):xi).width=e.width,xi.height=e.height,t=xi.getContext("2d"),e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),xi)).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")}}var Si=0;class Ai extends ai{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:Ai.DEFAULT_IMAGE,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:Ai.DEFAULT_MAPPING,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:ze,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:ze,n=4<arguments.length&&void 0!==arguments[4]?arguments[4]:k,a=5<arguments.length&&void 0!==arguments[5]?arguments[5]:ke,s=6<arguments.length&&void 0!==arguments[6]?arguments[6]:Ce,o=7<arguments.length&&void 0!==arguments[7]?arguments[7]:Ge,l=8<arguments.length&&void 0!==arguments[8]?arguments[8]:1,h=9<arguments.length&&void 0!==arguments[9]?arguments[9]:Kt;super(),Object.defineProperty(this,"id",{value:Si++}),this.uuid=di(),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 wi,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=di()),!t&&void 0===e.images[r.uuid]){if(Array.isArray(r))for(var n=[],a=0,s=r.length;a<s;a++)r[a].isDataTexture?n.push(Li(r[a].image)):n.push(Li(r[a]));else n=Li(r);e.images[r.uuid]={uuid:r.uuid,url:n}}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 Te:e.x=e.x-Math.floor(e.x);break;case ze:e.x=e.x<0?0:1;break;case Se: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 Te:e.y=e.y-Math.floor(e.y);break;case ze:e.y=e.y<0?0:1;break;case Se: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 Li(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Ti.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."),{})}Ai.DEFAULT_IMAGE=void 0,Ai.DEFAULT_MAPPING=300,Ai.prototype.isTexture=!0;class Pe{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]: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(e){var t,i,r,n,a,s,o,l,h,c,e=e.elements,u=e[0],d=e[4],p=e[8],m=e[1],f=e[5],v=e[9],g=e[2],_=e[6],e=e[10];return Math.abs(d-m)<.01&&Math.abs(p-g)<.01&&Math.abs(v-_)<.01?Math.abs(d+m)<.1&&Math.abs(p+g)<.1&&Math.abs(v+_)<.1&&Math.abs(u+f+e-3)<.1?this.set(1,0,0,0):(n=Math.PI,s=(e+1)/2,o=(d+m)/4,l=(p+g)/4,h=(v+_)/4,(a=(f+1)/2)<(c=(u+1)/2)&&s<c?r=c<.01?(t=0,i=.707106781):(i=o/(t=Math.sqrt(c)),l/t):s<a?r=a<.01?(i=0,t=.707106781):(t=o/(i=Math.sqrt(a)),h/i):s<.01?(i=t=.707106781,r=0):(t=l/(r=Math.sqrt(s)),i=h/r),this.set(t,i,r,n)):(c=Math.sqrt((_-v)*(_-v)+(p-g)*(p-g)+(m-d)*(m-d)),Math.abs(c)<.001&&(c=1),this.x=(_-v)/c,this.y=(p-g)/c,this.z=(m-d)/c,this.w=Math.acos((u+f+e-1)/2)),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){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]: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}}Pe.prototype.isVector4=!0;class Ri extends ai{constructor(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};super(),this.width=e,this.height=t,this.depth=1,this.scissor=new Pe(0,0,e,t),this.scissorTest=!1,this.viewport=new Pe(0,0,e,t),this.texture=new Ai(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:k,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){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]: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=s({},this.texture.image),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Ri.prototype.isWebGLRenderTarget=!0;(class extends Ri{});class Ci extends Ri{constructor(e,t,i){super(e,t,i),this.samples=4}copy(e){return super.copy.call(this,e),this.samples=e.samples,this}}Ci.prototype.isWebGLMultisampleRenderTarget=!0;class _{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]: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){var o,l,h,c=i[r+0],u=i[r+1],d=i[r+2],i=i[r+3],r=n[a+0],p=n[a+1],m=n[a+2],n=n[a+3];0===s?(e[t+0]=c,e[t+1]=u,e[t+2]=d,e[t+3]=i):1===s?(e[t+0]=r,e[t+1]=p,e[t+2]=m,e[t+3]=n):(i===n&&c===r&&u===p&&d===m||(a=1-s,o=0<=(l=c*r+u*p+d*m+i*n)?1:-1,(h=1-l*l)>Number.EPSILON&&(h=Math.sqrt(h),l=Math.atan2(h,l*o),a=Math.sin(a*l)/h,s=Math.sin(s*l)/h),c=c*a+r*(l=s*o),u=u*a+p*l,d=d*a+m*l,i=i*a+n*l,a===1-s&&(c*=h=1/Math.sqrt(c*c+u*u+d*d+i*i),u*=h,d*=h,i*=h)),e[t]=c,e[t+1]=u,e[t+2]=d,e[t+3]=i)}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){var 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(pi(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(e,t){if(0!==t){if(1===t)return this.copy(e);var i,r=this._x,n=this._y,a=this._z,s=this._w,o=s*e._w+r*e._x+n*e._y+a*e._z;o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),1<=o?(this._w=s,this._x=r,this._y=n,this._z=a):((e=1-o*o)<=Number.EPSILON?(this._w=(i=1-t)*s+t*this._w,this._x=i*r+t*this._x,this._y=i*n+t*this._y,this._z=i*a+t*this._z,this.normalize()):(i=Math.sqrt(e),e=Math.atan2(i,o),o=Math.sin((1-t)*e)/i,t=Math.sin(t*e)/i,this._w=s*o+this._w*t,this._x=r*o+this._x*t,this._y=n*o+this._y*t,this._z=a*o+this._z*t),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){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]: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(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]: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 Ne{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]: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(Oi.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Oi.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 Pi.copy(this).projectOnVector(e),this.sub(Pi)}reflect(e){return this.sub(Pi.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(pi(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){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],t=1<arguments.length&&void 0!==arguments[1]?arguments[1]: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-Math.pow(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}}Ne.prototype.isVector3=!0;var Pi=new Ne,Oi=new _;class Di{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ne(1/0,1/0,1/0),t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Ne(-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(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,a=-1/0,s=-1/0,o=0,l=e.length;o<l;o+=3){var h=e[o],c=e[o+1],u=e[o+2];h<t&&(t=h),c<i&&(i=c),u<r&&(r=u),n<h&&(n=h),a<c&&(a=c),s<u&&(s=u)}return this.min.set(t,i,r),this.max.set(n,a,s),this}setFromBufferAttribute(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,a=-1/0,s=-1/0,o=0,l=e.count;o<l;o++){var h=e.getX(o),c=e.getY(o),u=e.getZ(o);h<t&&(t=h),c<i&&(i=c),u<r&&(r=u),n<h&&(n=h),a<c&&(a=c),s<u&&(s=u)}return this.min.set(t,i,r),this.max.set(n,a,s),this}setFromPoints(e){this.makeEmpty();for(var t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){t=Ni.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);for(var t=e.geometry,i=(void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),Fi.copy(t.boundingBox),Fi.applyMatrix4(e.matrixWorld),this.union(Fi)),e.children),r=0,n=i.length;r<n;r++)this.expandByObject(i[r]);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,Ni),Ni.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){var t,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);return 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(Vi),Wi.subVectors(this.max,Vi),Ui.subVectors(e.a,Vi),zi.subVectors(e.b,Vi),Bi.subVectors(e.c,Vi),Hi.subVectors(zi,Ui),ki.subVectors(Bi,zi),Gi.subVectors(Ui,Bi),!!qi([0,-Hi.z,Hi.y,0,-ki.z,ki.y,0,-Gi.z,Gi.y,Hi.z,0,-Hi.x,ki.z,0,-ki.x,Gi.z,0,-Gi.x,-Hi.y,Hi.x,0,-ki.y,ki.x,0,-Gi.y,Gi.x,0],Ui,zi,Bi,Wi))&&!!qi([1,0,0,0,1,0,0,0,1],Ui,zi,Bi,Wi)&&(ji.crossVectors(Hi,ki),qi([ji.x,ji.y,ji.z],Ui,zi,Bi,Wi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Ni.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(Ni).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()||(Ii[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ii[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ii[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ii[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ii[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ii[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ii[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ii[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ii)),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)}}Di.prototype.isBox3=!0;var Ii=[new Ne,new Ne,new Ne,new Ne,new Ne,new Ne,new Ne,new Ne],Ni=new Ne,Fi=new Di,Ui=new Ne,zi=new Ne,Bi=new Ne,Hi=new Ne,ki=new Ne,Gi=new Ne,Vi=new Ne,Wi=new Ne,ji=new Ne,Xi=new Ne;function qi(e,t,i,r,n){for(var a=0,s=e.length-3;a<=s;a+=3){Xi.fromArray(e,a);var o=n.x*Math.abs(Xi.x)+n.y*Math.abs(Xi.y)+n.z*Math.abs(Xi.z),l=t.dot(Xi),h=i.dot(Xi),c=r.dot(Xi);if(Math.max(-Math.max(l,h,c),Math.min(l,h,c))>o)return!1}return!0}var Yi=new Di,Zi=new Ne,Ji=new Ne,Ki=new Ne;class Qi{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ne,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1;this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){for(var i=this.center,r=(void 0!==t?i.copy(t):Yi.setFromPoints(e).getCenter(i),0),n=0,a=e.length;n<a;n++)r=Math.max(r,i.distanceToSquared(e[n]));return this.radius=Math.sqrt(r),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){Ki.subVectors(e,this.center);var t,e=Ki.lengthSq();return e>this.radius*this.radius&&(t=.5*((e=Math.sqrt(e))-this.radius),this.center.add(Ki.multiplyScalar(t/e)),this.radius+=t),this}union(e){return Ji.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Zi.copy(e.center).add(Ji)),this.expandByPoint(Zi.copy(e.center).sub(Ji)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}var $i=new Ne,er=new Ne,tr=new Ne,ir=new Ne,rr=new Ne,nr=new Ne,ar=new Ne;class sr{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ne,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new Ne(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,$i)),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=$i.subVectors(e,this.origin).dot(this.direction);return(t<0?this.origin:($i.copy(this.direction).multiplyScalar(t).add(this.origin),$i)).distanceToSquared(e)}distanceSqToSegment(e,t,i,r){er.copy(e).add(t).multiplyScalar(.5),tr.copy(t).sub(e).normalize(),ir.copy(this.origin).sub(er);var n,a,s,e=.5*e.distanceTo(t),t=-this.direction.dot(tr),o=ir.dot(this.direction),l=-ir.dot(tr),h=ir.lengthSq(),c=Math.abs(1-t*t);return c=0<c?(a=t*o-l,s=e*c,0<=(n=t*l-o)?-s<=a?a<=s?(n*=c=1/c)*(n+t*(a*=c)+2*o)+a*(t*n+a+2*l)+h:(a=e,-(n=Math.max(0,-(t*a+o)))*n+a*(a+2*l)+h):(a=-e,-(n=Math.max(0,-(t*a+o)))*n+a*(a+2*l)+h):a<=-s?-(n=Math.max(0,-(-t*e+o)))*n+(a=0<n?-e:Math.min(Math.max(-e,-l),e))*(a+2*l)+h:a<=s?(n=0,(a=Math.min(Math.max(-e,-l),e))*(a+2*l)+h):-(n=Math.max(0,-(t*e+o)))*n+(a=0<n?e:Math.min(Math.max(-e,-l),e))*(a+2*l)+h):(a=0<t?-e:e,-(n=Math.max(0,-(t*a+o)))*n+a*(a+2*l)+h),i&&i.copy(this.direction).multiplyScalar(n).add(this.origin),r&&r.copy(tr).multiplyScalar(a).add(er),c}intersectSphere(e,t){$i.subVectors(e.center,this.origin);var i=$i.dot(this.direction),r=$i.dot($i)-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){var i,r,n,a=1/this.direction.x,s=1/this.direction.y,o=1/this.direction.z,l=this.origin,a=0<=a?(i=(e.min.x-l.x)*a,(e.max.x-l.x)*a):(i=(e.max.x-l.x)*a,(e.min.x-l.x)*a),s=0<=s?(n=(e.min.y-l.y)*s,(e.max.y-l.y)*s):(n=(e.max.y-l.y)*s,(e.min.y-l.y)*s);return s<i||a<n||((i<n||i!=i)&&(i=n),(s<a||a!=a)&&(a=s),(n=0<=o?(r=(e.min.z-l.z)*o,(e.max.z-l.z)*o):(r=(e.max.z-l.z)*o,(e.min.z-l.z)*o))<i)||a<r||((i<r||i!=i)&&(i=r),(a=n<a||a!=a?n:a)<0)?null:this.at(0<=i?i:a,t)}intersectsBox(e){return null!==this.intersectBox(e,$i)}intersectTriangle(e,t,i,r,n){rr.subVectors(t,e),nr.subVectors(i,e),ar.crossVectors(rr,nr);var a,t=this.direction.dot(ar);if(0<t){if(r)return null;a=1}else{if(!(t<0))return null;a=-1,t=-t}ir.subVectors(this.origin,e);i=a*this.direction.dot(nr.crossVectors(ir,nr));return i<0||(r=a*this.direction.dot(rr.cross(ir)))<0||t<i+r||(e=-a*ir.dot(ar))<0?null:this.at(e/t,n)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.or