verge3d
Version:
Toolkit for creating 3D web interactives
1 lines • 1.5 MB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).v3d={})}(this,(function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null;const n="4.10.0",o={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},i=100,r=101,s=102,a=200,l=201,c=202,u=203,h=204,f=205,d=206,A=207,v=208,m=209,p=210,g=300,_=301,C=302,E=303,w=304,x=306,I=1e3,M=1001,S=1002,b=1003,y=1004,R=1005,T=1006,B=1007,L=1008,N=1009,D=1012,P=1013,O=1014,F=1015,U=1016,V=1017,G=1018,Q=1020,z=1023,k=1026,H=1027,W=1028,Y=1029,X=1030,K=1031,j=1033,Z=33776,q=33777,J=33778,$=33779,tt=35840,et=35841,nt=35842,ot=35843,it=36196,rt=37492,st=37496,at=37808,lt=37809,ct=37810,ut=37811,ht=37812,ft=37813,dt=37814,At=37815,vt=37816,mt=37817,pt=37818,gt=37819,_t=37820,Ct=37821,Et=36492,wt=2200,xt=2201,It=2202,Mt=2300,St=2301,bt=2302,yt=2400,Rt=2401,Tt=2402,Bt=2500,Lt=2501,Nt=3e3,Dt=3001,Pt=3201,Ot=3202,Ft=3301,Ut="srgb",Vt="srgb-linear",Gt=7680,Qt=7681,zt=34055,kt=34056,Ht=35044,Wt="300 es",Yt=1035,Xt="__V3DL__0000000000";class Kt{addEventListener(t,e){void 0===this.t&&(this.t={});const n=this.t;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this.t)return!1;const n=this.t;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this.t)return;const n=this.t[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this.t)return;const e=this.t[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,o=n.length;e<o;e++)n[e].call(this,t);t.target=null}}}const jt=new RegExp("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"),Zt=Math.PI/180,qt=180/Math.PI,Jt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let $t=1234567;function te(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,o=4294967295*Math.random()|0;return(Jt[255&t]+Jt[t>>8&255]+Jt[t>>16&255]+Jt[t>>24&255]+"-"+Jt[255&e]+Jt[e>>8&255]+"-"+Jt[e>>16&15|64]+Jt[e>>24&255]+"-"+Jt[63&n|128]+Jt[n>>8&255]+"-"+Jt[n>>16&255]+Jt[n>>24&255]+Jt[255&o]+Jt[o>>8&255]+Jt[o>>16&255]+Jt[o>>24&255]).toLowerCase()}function ee(t){return jt.test(t)}function ne(t,e=0,n=1){return Math.max(e,Math.min(n,t))}function oe(t,e){return(t%e+e)%e}function ie(t,e,n){return(1-n)*t+n*e}function re(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)}function se(t){return t*Zt}function ae(t){return t*qt}function le(t){return!(t&t-1)&&0!==t}function ce(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ue(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function he(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function fe(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}function de(t){let e=5381,n=t.length;for(;n;)e=33*e^t.charCodeAt(--n);return e>>>0}function Ae(t,e,n,o){let i=Math.exp(-n/o);return t*i+(1-i)*e}function ve(t,e,n,o,i){let r=Ae(t,e,n,o);return Math.abs(t-e)<i&&(r=e),r}function me(t){return ne(t-2*Math.PI*Math.floor(t/(2*Math.PI)),0,2*Math.PI)}function pe(t){let e=t+Math.PI;return e%=2*Math.PI,e+=2*Math.PI,e%=2*Math.PI,e-=Math.PI,e}function ge(t,e,n){let o=me(t-e),i=me(n-e);return o>i&&(o=o<i/2+Math.PI?i:0),o+e}var _e=Object.freeze({__proto__:null,DEG2RAD:Zt,RAD2DEG:qt,angleToRange_0_2Pi:me,angleToRange_mPi_Pi:pe,ceilPowerOfTwo:ce,checkUUID:ee,clamp:ne,clampAngle:ge,damp:function(t,e,n,o){return ie(t,e,1-Math.exp(-n*o))},degToRad:se,denormalize:he,euclideanModulo:oe,expAverage:Ae,expAverageClamp:ve,floorPowerOfTwo:ue,generateUUID:te,hashString:de,inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},isPowerOfTwo:le,lerp:ie,mapLinear:function(t,e,n,o,i){return o+(t-e)*(i-o)/(n-e)},normalize:fe,pingpong:function(t,e=1){return e-Math.abs(oe(t,2*e)-e)},radToDeg:ae,randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},seededRandom:function(t){void 0!==t&&($t=t);let e=$t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},setQuaternionFromProperEuler:function(t,e,n,o,i){const r=Math.cos,s=Math.sin,a=r(n/2),l=s(n/2),c=r((e+o)/2),u=s((e+o)/2),h=r((e-o)/2),f=s((e-o)/2),d=r((o-e)/2),A=s((o-e)/2);switch(i){case"XYX":t.set(a*u,l*h,l*f,a*c);break;case"YZY":t.set(l*f,a*u,l*h,a*c);break;case"ZXZ":t.set(l*h,l*f,a*u,a*c);break;case"XZX":t.set(a*u,l*A,l*d,a*c);break;case"YXY":t.set(l*d,a*u,l*A,a*c);break;case"ZYZ":t.set(l*A,l*d,a*u,a*c);break;default:console.warn("v3d.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},smootherstep:re,smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)}});class Ce{constructor(t=0,e=0){Ce.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,o=t.elements;return this.x=o[0]*e+o[3]*n+o[6],this.y=o[1]*e+o[4]*n+o[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),o=Math.sin(e),i=this.x-t.x,r=this.y-t.y;return this.x=i*n-r*o+t.x,this.y=i*o+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ee{constructor(){Ee.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,n,o,i,r,s,a,l){const c=this.elements;return c[0]=t,c[1]=o,c[2]=s,c[3]=e,c[4]=i,c[5]=a,c[6]=n,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,o=e.elements,i=this.elements,r=n[0],s=n[3],a=n[6],l=n[1],c=n[4],u=n[7],h=n[2],f=n[5],d=n[8],A=o[0],v=o[3],m=o[6],p=o[1],g=o[4],_=o[7],C=o[2],E=o[5],w=o[8];return i[0]=r*A+s*p+a*C,i[3]=r*v+s*g+a*E,i[6]=r*m+s*_+a*w,i[1]=l*A+c*p+u*C,i[4]=l*v+c*g+u*E,i[7]=l*m+c*_+u*w,i[2]=h*A+f*p+d*C,i[5]=h*v+f*g+d*E,i[8]=h*m+f*_+d*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],o=t[2],i=t[3],r=t[4],s=t[5],a=t[6],l=t[7],c=t[8];return e*r*c-e*s*l-n*i*c+n*s*a+o*i*l-o*r*a}invert(){const t=this.elements,e=t[0],n=t[1],o=t[2],i=t[3],r=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=c*r-s*l,h=s*a-c*i,f=l*i-r*a,d=e*u+n*h+o*f;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const A=1/d;return t[0]=u*A,t[1]=(o*l-c*n)*A,t[2]=(s*n-o*r)*A,t[3]=h*A,t[4]=(c*e-o*a)*A,t[5]=(o*i-s*e)*A,t[6]=f*A,t[7]=(n*a-l*e)*A,t[8]=(r*e-n*i)*A,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,o,i,r,s){const a=Math.cos(i),l=Math.sin(i);return this.set(n*a,n*l,-n*(a*r+l*s)+r+t,-o*l,o*a,-o*(-l*r+a*s)+s+e,0,0,1),this}scale(t,e){return this.premultiply(we.makeScale(t,e)),this}rotate(t){return this.premultiply(we.makeRotation(-t)),this}translate(t,e){return this.premultiply(we.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const we=new Ee;function xe(t){if(0===t.length)return-1/0;let e=t[0];for(let n=1,o=t.length;n<o;++n)t[n]>e&&(e=t[n]);return e}function Ie(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Me(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Se(t){return void 0!==t}function be(t,e,n){for(let o=0;o<t.length;o++)t[o]=ne(t[o],e,n);return t}function ye(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function Re(t){return t.toLowerCase().replace(/_([a-zA-Z])/g,(function(t){return t[1].toUpperCase()}))}function Te(t){var e,n;const o=null!=(e=t.match(/^[a-zA-Z38 ]*(\d+).(\d+).(\d+)(?: (.*))?$/))?e:[];let i=Number(o[1]),r=Number(o[2]),s=Number(o[3]);i=Number.isNaN(i)?0:i,r=Number.isNaN(r)?0:r,s=Number.isNaN(s)?0:s;return{major:i,minor:r,patch:s,pre:null!=(n=o[4])?n:""}}function Be(t){var e;if(""===t)return 1/0;const n=null!=(e=t.match(/^pre(\d+)$/))?e:[];let o=Number(n[1]);return o=Number.isNaN(o)?0:o,o}function Le(t,e,n=3){const o=Te(t),i=Te(e);let r=i.major-o.major;return 0===r&&n>1&&(r=i.minor-o.minor,0===r&&n>2&&(r=i.patch-o.patch,0===r&&n>3&&(r=Be(i.pre)-Be(o.pre),isNaN(r)&&(r=0)))),Math.sign(r)}function Ne(t){return`${t%1?t:`${t}.0`}`}function De(){return"undefined"!=typeof window?window:"undefined"!=typeof self?self:global}const Pe={};function Oe(t=""){const e=document.getElementsByTagName("script");let n=t;for(let o=e.length-1;o>=0;--o){const i=e[o].src,r=i.search(/\/v3d[\w.]+js/);r>-1&&(n=i.substr(0,r)+"/"+t)}return n}function Fe(t,e=function(t){},n=function(t){}){Pe[t]=Pe[t]||{status:0,loadCallbacks:[],errorCallbacks:[]};const o=Pe[t];if(4==o.status)return void e(t);if(o.loadCallbacks.push(e),o.errorCallbacks.push(n),o.status>0)return;let i=Oe(t);const r=document.createElement("script");r.type="text/javascript",r.src=i,function(t){r.onload=function(){Pe[t].loadCallbacks.forEach((function(e){e(t)})),Pe[t].status=4},r.onerror=function(){Pe[t].errorCallbacks.forEach((function(e){e(t)})),Pe[t].status=0}}(t),document.getElementsByTagName("head")[0].appendChild(r),o.status=3}function Ue(t,e,n=0){const o=function(t,o,i,r){const s=performance.now();return e(t,o,i),s-r>n?(r=s,new Promise((function(t){setTimeout((function(){t(r)}),1)}))):r};let i=Promise.resolve(performance.now());return t.forEach((function(t,e,n){i=i.then(o.bind(null,t,e,n))})),i}function Ve(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Ge(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const Qe={[Ut]:{[Vt]:Ve},[Vt]:{[Ut]:Ge}},ze={legacyMode:!0,get workingColorSpace(){return Vt},set workingColorSpace(t){console.warn("v3d.ColorManagement: .workingColorSpace is readonly.")},convert:function(t,e,n){if(this.legacyMode||e===n||!e||!n)return t;if(Qe[e]&&void 0!==Qe[e][n]){const o=Qe[e][n];return t.r=o(t.r),t.g=o(t.g),t.b=o(t.b),t}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)}},ke={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},He={r:0,g:0,b:0},We={h:0,s:0,l:0},Ye={h:0,s:0,l:0};function Xe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function Ke(t,e){return e.r=t.r,e.g=t.g,e.b=t.b,e}class je{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ut){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,ze.toWorkingColorSpace(this,e),this}setRGB(t,e,n,o=ze.workingColorSpace){return this.r=t,this.g=e,this.b=n,ze.toWorkingColorSpace(this,o),this}setHSL(t,e,n,o=ze.workingColorSpace){if(t=oe(t,1),e=ne(e,0,1),n=ne(n,0,1),0===e)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+e):n+e-n*e,i=2*n-o;this.r=Xe(i,o,t+1/3),this.g=Xe(i,o,t),this.b=Xe(i,o,t-1/3)}return ze.toWorkingColorSpace(this,o),this}setStyle(t,e=Ut){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("v3d.Color: Alpha component of "+t+" will be ignored.")}let o;if(o=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const i=o[1],r=o[2];switch(i){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,ze.toWorkingColorSpace(this,e),n(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,ze.toWorkingColorSpace(this,e),n(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const o=parseFloat(t[1])/360,i=parseFloat(t[2])/100,r=parseFloat(t[3])/100;return n(t[4]),this.setHSL(o,i,r,e)}}}else if(o=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=o[1],n=t.length;if(3===n)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,ze.toWorkingColorSpace(this,e),this;if(6===n)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,ze.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e=Ut){const n=ke[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("v3d.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ve(t.r),this.g=Ve(t.g),this.b=Ve(t.b),this}copyLinearToSRGB(t){return this.r=Ge(t.r),this.g=Ge(t.g),this.b=Ge(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ut){return ze.fromWorkingColorSpace(Ke(this,He),t),ne(255*He.r,0,255)<<16^ne(255*He.g,0,255)<<8^ne(255*He.b,0,255)}getHexString(t=Ut){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ze.workingColorSpace){ze.fromWorkingColorSpace(Ke(this,He),e);const n=He.r,o=He.g,i=He.b,r=Math.max(n,o,i),s=Math.min(n,o,i);let a,l;const c=(s+r)/2;if(s===r)a=0,l=0;else{const t=r-s;switch(l=c<=.5?t/(r+s):t/(2-r-s),r){case n:a=(o-i)/t+(o<i?6:0);break;case o:a=(i-n)/t+2;break;case i:a=(n-o)/t+4}a/=6}return t.h=a,t.s=l,t.l=c,t}getRGB(t,e=ze.workingColorSpace){return ze.fromWorkingColorSpace(Ke(this,He),e),t.r=He.r,t.g=He.g,t.b=He.b,t}getStyle(t=Ut){return ze.fromWorkingColorSpace(Ke(this,He),t),t!==Ut?`color(${t} ${He.r} ${He.g} ${He.b})`:`rgb(${255*He.r|0},${255*He.g|0},${255*He.b|0})`}offsetHSL(t,e,n){return this.getHSL(We),We.h+=t,We.s+=e,We.l+=n,this.setHSL(We.h,We.s,We.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(We),t.getHSL(Ye);const n=ie(We.h,Ye.h,e),o=ie(We.s,Ye.s,e),i=ie(We.l,Ye.l,e);return this.setHSL(n,o,i),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}let Ze;je.NAMES=ke;class qe{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Ze&&(Ze=Me("canvas")),Ze.width=t.width,Ze.height=t.height;const n=Ze.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Ze}return e.width>2048||e.height>2048?(console.warn("v3d.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=Me("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const o=n.getImageData(0,0,t.width,t.height),i=o.data;for(let t=0;t<i.length;t++)i[t]=255*Ve(i[t]/255);return n.putImageData(o,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*Ve(e[t]/255)):e[t]=Ve(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("v3d.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Je=0;class $e{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Je++}),this.uuid=te(),this.data=t,this.version=0}set needsUpdate(t){!0===t&&this.version++}}let tn=0;class en extends Kt{constructor(t=en.DEFAULT_IMAGE,e=en.DEFAULT_MAPPING,n=1001,o=1001,i=1006,r=1008,s=1023,a=1009,l=en.DEFAULT_ANISOTROPY,c=3e3){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:tn++}),this.uuid=te(),this.name="",this.source=new $e(t),this.mipmaps=[],this.mapping=e,this.wrapS=n,this.wrapT=o,this.magFilter=i,this.minFilter=r,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new Ce(0,0),this.repeat=new Ce(1,1),this.center=new Ce(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ee,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==g)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case I:t.x=t.x-Math.floor(t.x);break;case M:t.x=t.x<0?0:1;break;case S:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case I:t.y=t.y-Math.floor(t.y);break;case M:t.y=t.y<0?0:1;break;case S:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}}en.DEFAULT_IMAGE=null,en.DEFAULT_MAPPING=g,en.DEFAULT_ANISOTROPY=1;class nn{constructor(t=0,e=0,n=0,o=1){nn.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=o}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,o){return this.x=t,this.y=e,this.z=n,this.w=o,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,o=this.z,i=this.w,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*o+r[12]*i,this.y=r[1]*e+r[5]*n+r[9]*o+r[13]*i,this.z=r[2]*e+r[6]*n+r[10]*o+r[14]*i,this.w=r[3]*e+r[7]*n+r[11]*o+r[15]*i,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,o,i;const r=.01,s=.1,a=t.elements,l=a[0],c=a[4],u=a[8],h=a[1],f=a[5],d=a[9],A=a[2],v=a[6],m=a[10];if(Math.abs(c-h)<r&&Math.abs(u-A)<r&&Math.abs(d-v)<r){if(Math.abs(c+h)<s&&Math.abs(u+A)<s&&Math.abs(d+v)<s&&Math.abs(l+f+m-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,a=(f+1)/2,p=(m+1)/2,g=(c+h)/4,_=(u+A)/4,C=(d+v)/4;return t>a&&t>p?t<r?(n=0,o=.707106781,i=.707106781):(n=Math.sqrt(t),o=g/n,i=_/n):a>p?a<r?(n=.707106781,o=0,i=.707106781):(o=Math.sqrt(a),n=g/o,i=C/o):p<r?(n=.707106781,o=.707106781,i=0):(i=Math.sqrt(p),n=_/i,o=C/i),this.set(n,o,i,e),this}let p=Math.sqrt((v-d)*(v-d)+(u-A)*(u-A)+(h-c)*(h-c));return Math.abs(p)<.001&&(p=1),this.x=(v-d)/p,this.y=(u-A)/p,this.z=(h-c)/p,this.w=Math.acos((l+f+m-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}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}}class on extends Kt{constructor(t=1,e=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new nn(0,0,t,e),this.scissorTest=!1,this.viewport=new nn(0,0,t,e);const o={width:t,height:e,depth:1};this.texture=new en(o,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:T,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(t,e,n=1){this.width===t&&this.height===e&&this.depth===n||(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new $e(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class rn extends en{constructor(t=null,e=1,n=1,o=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:o},this.magFilter=b,this.minFilter=b,this.wrapR=M,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class sn extends en{constructor(t=null,e=1,n=1,o=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:o},this.magFilter=b,this.minFilter=b,this.wrapR=M,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class an extends on{constructor(t=1,e=1,n=1,o={}){super(t,e,o),this.isWebGLMultipleRenderTargets=!0;const i=this.texture;this.texture=[];for(let t=0;t<n;t++)this.texture[t]=i.clone(),this.texture[t].isRenderTargetTexture=!0}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let o=0,i=this.texture.length;o<i;o++)this.texture[o].image.width=t,this.texture[o].image.height=e,this.texture[o].image.depth=n;this.dispose()}return this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e),this}copy(t){this.dispose(),this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.texture.length=0;for(let e=0,n=t.texture.length;e<n;e++)this.texture[e]=t.texture[e].clone(),this.texture[e].isRenderTargetTexture=!0;return this}}class ln{constructor(t=0,e=0,n=0,o=1){this.isQuaternion=!0,this._=t,this.$=e,this.tt=n,this.et=o}static slerpFlat(t,e,n,o,i,r,s){let a=n[o+0],l=n[o+1],c=n[o+2],u=n[o+3];const h=i[r+0],f=i[r+1],d=i[r+2],A=i[r+3];if(0===s)return t[e+0]=a,t[e+1]=l,t[e+2]=c,void(t[e+3]=u);if(1===s)return t[e+0]=h,t[e+1]=f,t[e+2]=d,void(t[e+3]=A);if(u!==A||a!==h||l!==f||c!==d){let t=1-s;const e=a*h+l*f+c*d+u*A,n=e>=0?1:-1,o=1-e*e;if(o>Number.EPSILON){const i=Math.sqrt(o),r=Math.atan2(i,e*n);t=Math.sin(t*r)/i,s=Math.sin(s*r)/i}const i=s*n;if(a=a*t+h*i,l=l*t+f*i,c=c*t+d*i,u=u*t+A*i,t===1-s){const t=1/Math.sqrt(a*a+l*l+c*c+u*u);a*=t,l*=t,c*=t,u*=t}}t[e]=a,t[e+1]=l,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,o,i,r){const s=n[o],a=n[o+1],l=n[o+2],c=n[o+3],u=i[r],h=i[r+1],f=i[r+2],d=i[r+3];return t[e]=s*d+c*u+a*f-l*h,t[e+1]=a*d+c*h+l*u-s*f,t[e+2]=l*d+c*f+s*h-a*u,t[e+3]=c*d-s*u-a*h-l*f,t}get x(){return this._}set x(t){this._=t,this.nt()}get y(){return this.$}set y(t){this.$=t,this.nt()}get z(){return this.tt}set z(t){this.tt=t,this.nt()}get w(){return this.et}set w(t){this.et=t,this.nt()}set(t,e,n,o){return this._=t,this.$=e,this.tt=n,this.et=o,this.nt(),this}clone(){return new this.constructor(this._,this.$,this.tt,this.et)}copy(t){return this._=t.x,this.$=t.y,this.tt=t.z,this.et=t.w,this.nt(),this}setFromEuler(t,e){const n=t._,o=t.$,i=t.tt,r=t.ot,s=Math.cos,a=Math.sin,l=s(n/2),c=s(o/2),u=s(i/2),h=a(n/2),f=a(o/2),d=a(i/2);switch(r){case"XYZ":this._=h*c*u+l*f*d,this.$=l*f*u-h*c*d,this.tt=l*c*d+h*f*u,this.et=l*c*u-h*f*d;break;case"YXZ":this._=h*c*u+l*f*d,this.$=l*f*u-h*c*d,this.tt=l*c*d-h*f*u,this.et=l*c*u+h*f*d;break;case"ZXY":this._=h*c*u-l*f*d,this.$=l*f*u+h*c*d,this.tt=l*c*d+h*f*u,this.et=l*c*u-h*f*d;break;case"ZYX":this._=h*c*u-l*f*d,this.$=l*f*u+h*c*d,this.tt=l*c*d-h*f*u,this.et=l*c*u+h*f*d;break;case"YZX":this._=h*c*u+l*f*d,this.$=l*f*u+h*c*d,this.tt=l*c*d-h*f*u,this.et=l*c*u-h*f*d;break;case"XZY":this._=h*c*u-l*f*d,this.$=l*f*u-h*c*d,this.tt=l*c*d+h*f*u,this.et=l*c*u+h*f*d;break;default:console.warn("v3d.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return!1!==e&&this.nt(),this}setFromAxisAngle(t,e){const n=e/2,o=Math.sin(n);return this._=t.x*o,this.$=t.y*o,this.tt=t.z*o,this.et=Math.cos(n),this.nt(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],o=e[4],i=e[8],r=e[1],s=e[5],a=e[9],l=e[2],c=e[6],u=e[10],h=n+s+u;if(h>0){const t=.5/Math.sqrt(h+1);this.et=.25/t,this._=(c-a)*t,this.$=(i-l)*t,this.tt=(r-o)*t}else if(n>s&&n>u){const t=2*Math.sqrt(1+n-s-u);this.et=(c-a)/t,this._=.25*t,this.$=(o+r)/t,this.tt=(i+l)/t}else if(s>u){const t=2*Math.sqrt(1+s-n-u);this.et=(i-l)/t,this._=(o+r)/t,this.$=.25*t,this.tt=(a+c)/t}else{const t=2*Math.sqrt(1+u-n-s);this.et=(r-o)/t,this._=(i+l)/t,this.$=(a+c)/t,this.tt=.25*t}return this.nt(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._=-t.y,this.$=t.x,this.tt=0,this.et=n):(this._=0,this.$=-t.z,this.tt=t.y,this.et=n)):(this._=t.y*e.z-t.z*e.y,this.$=t.z*e.x-t.x*e.z,this.tt=t.x*e.y-t.y*e.x,this.et=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ne(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const o=Math.min(1,e/n);return this.slerp(t,o),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._*=-1,this.$*=-1,this.tt*=-1,this.nt(),this}dot(t){return this._*t._+this.$*t.$+this.tt*t.tt+this.et*t.et}lengthSq(){return this._*this._+this.$*this.$+this.tt*this.tt+this.et*this.et}length(){return Math.sqrt(this._*this._+this.$*this.$+this.tt*this.tt+this.et*this.et)}normalize(){let t=this.length();return 0===t?(this._=0,this.$=0,this.tt=0,this.et=1):(t=1/t,this._=this._*t,this.$=this.$*t,this.tt=this.tt*t,this.et=this.et*t),this.nt(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._,o=t.$,i=t.tt,r=t.et,s=e._,a=e.$,l=e.tt,c=e.et;return this._=n*c+r*s+o*l-i*a,this.$=o*c+r*a+i*s-n*l,this.tt=i*c+r*l+n*a-o*s,this.et=r*c-n*s-o*a-i*l,this.nt(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._,o=this.$,i=this.tt,r=this.et;let s=r*t.et+n*t._+o*t.$+i*t.tt;if(s<0?(this.et=-t.et,this._=-t._,this.$=-t.$,this.tt=-t.tt,s=-s):this.copy(t),s>=1)return this.et=r,this._=n,this.$=o,this.tt=i,this;const a=1-s*s;if(a<=Number.EPSILON){const t=1-e;return this.et=t*r+e*this.et,this._=t*n+e*this._,this.$=t*o+e*this.$,this.tt=t*i+e*this.tt,this.normalize(),this.nt(),this}const l=Math.sqrt(a),c=Math.atan2(l,s),u=Math.sin((1-e)*c)/l,h=Math.sin(e*c)/l;return this.et=r*u+this.et*h,this._=n*u+this._*h,this.$=o*u+this.$*h,this.tt=i*u+this.tt*h,this.nt(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=Math.random(),e=Math.sqrt(1-t),n=Math.sqrt(t),o=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(e*Math.cos(o),n*Math.sin(i),n*Math.cos(i),e*Math.sin(o))}equals(t){return t._===this._&&t.$===this.$&&t.tt===this.tt&&t.et===this.et}fromArray(t,e=0){return this._=t[e],this.$=t[e+1],this.tt=t[e+2],this.et=t[e+3],this.nt(),this}toArray(t=[],e=0){return t[e]=this._,t[e+1]=this.$,t[e+2]=this.tt,t[e+3]=this.et,t}fromBufferAttribute(t,e){return this._=t.getX(e),this.$=t.getY(e),this.tt=t.getZ(e),this.et=t.getW(e),this}it(t){return this.nt=t,this}nt(){}*[Symbol.iterator](){yield this._,yield this.$,yield this.tt,yield this.et}}class cn{constructor(t=0,e=0,n=0){cn.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(hn.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(hn.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,o=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*o,this.y=i[1]*e+i[4]*n+i[7]*o,this.z=i[2]*e+i[5]*n+i[8]*o,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,o=this.z,i=t.elements,r=1/(i[3]*e+i[7]*n+i[11]*o+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*o+i[12])*r,this.y=(i[1]*e+i[5]*n+i[9]*o+i[13])*r,this.z=(i[2]*e+i[6]*n+i[10]*o+i[14])*r,this}applyQuaternion(t){const e=this.x,n=this.y,o=this.z,i=t.x,r=t.y,s=t.z,a=t.w,l=a*e+r*o-s*n,c=a*n+s*e-i*o,u=a*o+i*n-r*e,h=-i*e-r*n-s*o;return this.x=l*a+h*-i+c*-s-u*-r,this.y=c*a+h*-r+u*-i-l*-s,this.z=u*a+h*-s+l*-r-c*-i,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,o=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*o,this.y=i[1]*e+i[5]*n+i[9]*o,this.z=i[2]*e+i[6]*n+i[10]*o,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,o=t.y,i=t.z,r=e.x,s=e.y,a=e.z;return this.x=o*a-i*s,this.y=i*r-n*a,this.z=n*s-o*r,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return un.copy(this).projectOnVector(t),this.sub(un)}reflect(t){return this.sub(un.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ne(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,o=this.z-t.z;return e*e+n*n+o*o}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const o=Math.sin(e)*t;return this.x=o*Math.sin(n),this.y=Math.cos(e)*t,this.z=o*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),o=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=o,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._,this.y=t.$,this.z=t.tt,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,n=Math.sqrt(1-t**2);return this.x=n*Math.cos(e),this.y=n*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const un=new cn,hn=new ln;class fn{constructor(t=new cn(1/0,1/0,1/0),e=new cn(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,n=1/0,o=1/0,i=-1/0,r=-1/0,s=-1/0;for(let a=0,l=t.length;a<l;a+=3){const l=t[a],c=t[a+1],u=t[a+2];l<e&&(e=l),c<n&&(n=c),u<o&&(o=u),l>i&&(i=l),c>r&&(r=c),u>s&&(s=u)}return this.min.set(e,n,o),this.max.set(i,r,s),this}setFromBufferAttribute(t){let e=1/0,n=1/0,o=1/0,i=-1/0,r=-1/0,s=-1/0;for(let a=0,l=t.count;a<l;a++){const l=t.getX(a),c=t.getY(a),u=t.getZ(a);l<e&&(e=l),c<n&&(n=c),u<o&&(o=u),l>i&&(i=l),c>r&&(r=c),u>s&&(s=u)}return this.min.set(e,n,o),this.max.set(i,r,s),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=An.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n)if(e&&null!=n.attributes&&void 0!==n.attributes.position){const e=n.attributes.position;for(let n=0,o=e.count;n<o;n++)An.fromBufferAttribute(e,n).applyMatrix4(t.matrixWorld),this.ex