1import{u as Ql,r as Tt,j as Pe,F as jl,L as ec}from"./index-j7I9Tmll.js";/** 2 * @license 3 * Copyright 2010-2026 Three.js Authors 4 * SPDX-License-Identifier: MIT 5 */const fa="185",tc=0,qa=1,nc=2,xr=1,ic=2,Ni=3,Dn=0,Pt=1,nn=2,mn=0,mi=1,Ya=2,Ka=3,Za=4,rc=5,zn=100,sc=101,ac=102,oc=103,lc=104,cc=200,uc=201,hc=202,fc=203,Es=204,ys=205,dc=206,pc=207,mc=208,gc=209,_c=210,xc=211,vc=212,Mc=213,Sc=214,Ts=0,bs=1,As=2,xi=3,ws=4,Rs=5,Cs=6,Ps=7,ol=0,Ec=1,yc=2,an=0,ll=1,cl=2,ul=3,da=4,hl=5,fl=6,dl=7,pl=300,Yn=301,vi=302,Gr=303,Vr=304,Ur=306,Ds=1e3,pn=1001,Ls=1002,Et=1003,Tc=1004,Zi=1005,wt=1006,Hr=1007,Hn=1008,Ft=1009,ml=1010,gl=1011,zi=1012,pa=1013,ln=1014,qt=1015,xn=1016,ma=1017,ga=1018,Gi=1020,_l=35902,xl=35899,vl=1021,Ml=1022,Yt=1023,vn=1026,kn=1027,_a=1028,xa=1029,Kn=1030,va=1031,Ma=1033,vr=33776,Mr=33777,Sr=33778,Er=33779,Is=35840,Us=35841,Ns=35842,Fs=35843,Os=36196,Bs=37492,zs=37496,Gs=37488,Vs=37489,br=37490,Hs=37491,ks=37808,Ws=37809,Xs=37810,qs=37811,Ys=37812,Ks=37813,Zs=37814,$s=37815,Js=37816,Qs=37817,js=37818,ea=37819,ta=37820,na=37821,ia=36492,ra=36494,sa=36495,aa=36283,oa=36284,Ar=36285,la=36286,bc=3200,ca=0,Ac=1,Cn="",zt="srgb",wr="srgb-linear",Rr="linear",Ke="srgb",jn=7680,$a=519,wc=512,Rc=513,Cc=514,Sa=515,Pc=516,Dc=517,Ea=518,Lc=519,Ja=35044,Qa="300 es",rn=2e3,Vi=2001;function Ic(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Cr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Uc(){const i=Cr("canvas");return i.style.display="block",i}const ja={};function eo(...i){const e="THREE."+i.shift();console.log(e,...i)}function Sl(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function we(...i){i=Sl(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function We(...i){i=Sl(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function gi(...i){const e=i.join(" ");e in ja||(ja[e]=!0,we(...i))}function Nc(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const Fc={[Ts]:bs,[As]:Cs,[ws]:Ps,[xi]:Rs,[bs]:Ts,[Cs]:As,[Ps]:ws,[Rs]:xi};class Zn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const bt=["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 to=1234567;const Oi=Math.PI/180,Hi=180/Math.PI;function yi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(bt[i&255]+bt[i>>8&255]+bt[i>>16&255]+bt[i>>24&255]+"-"+bt[e&255]+bt[e>>8&255]+"-"+bt[e>>16&15|64]+bt[e>>24&255]+"-"+bt[t&63|128]+bt[t>>8&255]+"-"+bt[t>>16&255]+bt[t>>24&255]+bt[n&255]+bt[n>>8&255]+bt[n>>16&255]+bt[n>>24&255]).toLowerCase()}function Be(i,e,t){return Math.max(e,Math.min(t,i))}function ya(i,e){return(i%e+e)%e}function Oc(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}
vendor: 4,329 bytes, line 5
5function Bc(i,e,t){return i!==e?(t-i)/(e-i):0}function Bi(i,e,t){return(1-t)*i+t*e}function zc(i,e,t,n){return Bi(i,e,1-Math.exp(-t*n))}function Gc(i,e=1){return e-Math.abs(ya(i,e*2)-e)}function Vc(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Hc(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function kc(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Wc(i,e){return i+Math.random()*(e-i)}function Xc(i){return i*(.5-Math.random())}function qc(i){i!==void 0&&(to=i);let e=to+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Yc(i){return i*Oi}function Kc(i){return i*Hi}function Zc(i){return(i&i-1)===0&&i!==0}function $c(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Jc(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Qc(i,e,t,n,r){const s=Math.cos,a=Math.sin,o=s(t/2),c=a(t/2),l=s((e+n)/2),f=a((e+n)/2),m=s((e-n)/2),u=a((e-n)/2),_=s((n-e)/2),v=a((n-e)/2);switch(r){case"XYX":i.set(o*f,c*m,c*u,o*l);break;case"YZY":i.set(c*u,o*f,c*m,o*l);break;case"ZXZ":i.set(c*m,c*u,o*f,o*l);break;case"XZX":i.set(o*f,c*v,c*_,o*l);break;case"YXY":i.set(c*_,o*f,c*v,o*l);break;case"ZYZ":i.set(c*v,c*_,o*f,o*l);break;default:we("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function pi(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Rt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const no={DEG2RAD:Oi,RAD2DEG:Hi,generateUUID:yi,clamp:Be,euclideanModulo:ya,mapLinear:Oc,inverseLerp:Bc,lerp:Bi,damp:zc,pingpong:Gc,smoothstep:Vc,smootherstep:Hc,randInt:kc,randFloat:Wc,randFloatSpread:Xc,seededRandom:qc,degToRad:Yc,radToDeg:Kc,isPowerOfTwo:Zc,ceilPowerOfTwo:$c,floorPowerOfTwo:Jc,setQuaternionFromProperEuler:Qc,normalize:Rt,denormalize:pi},La=class La{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: 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("THREE.Vector2: 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){return 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){return 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){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[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=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}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}
vendor: 38,691 bytes, line 5
5round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Be(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};La.prototype.isVector2=!0;let Fe=La;class Ti{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let c=n[r+0],l=n[r+1],f=n[r+2],m=n[r+3],u=s[a+0],_=s[a+1],v=s[a+2],y=s[a+3];if(m!==y||c!==u||l!==_||f!==v){let g=c*u+l*_+f*v+m*y;g<0&&(u=-u,_=-_,v=-v,y=-y,g=-g);let h=1-o;if(g<.9995){const b=Math.acos(g),R=Math.sin(b);h=Math.sin(h*b)/R,o=Math.sin(o*b)/R,c=c*h+u*o,l=l*h+_*o,f=f*h+v*o,m=m*h+y*o}else{c=c*h+u*o,l=l*h+_*o,f=f*h+v*o,m=m*h+y*o;const b=1/Math.sqrt(c*c+l*l+f*f+m*m);c*=b,l*=b,f*=b,m*=b}}e[t]=c,e[t+1]=l,e[t+2]=f,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],c=n[r+1],l=n[r+2],f=n[r+3],m=s[a],u=s[a+1],_=s[a+2],v=s[a+3];return e[t]=o*v+f*m+c*_-l*u,e[t+1]=c*v+f*u+l*m-o*_,e[t+2]=l*v+f*_+o*u-c*m,e[t+3]=f*v-o*m-c*u-l*_,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,n,r){return this._x=e,this._y=t,this._z=n,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=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),f=o(r/2),m=o(s/2),u=c(n/2),_=c(r/2),v=c(s/2);switch(a){case"XYZ":this._x=u*f*m+l*_*v,this._y=l*_*m-u*f*v,this._z=l*f*v+u*_*m,this._w=l*f*m-u*_*v;break;case"YXZ":this._x=u*f*m+l*_*v,this._y=l*_*m-u*f*v,this._z=l*f*v-u*_*m,this._w=l*f*m+u*_*v;break;case"ZXY":this._x=u*f*m-l*_*v,this._y=l*_*m+u*f*v,this._z=l*f*v+u*_*m,this._w=l*f*m-u*_*v;break;case"ZYX":this._x=u*f*m-l*_*v,this._y=l*_*m+u*f*v,this._z=l*f*v-u*_*m,this._w=l*f*m+u*_*v;break;case"YZX":this._x=u*f*m+l*_*v,this._y=l*_*m+u*f*v,this._z=l*f*v-u*_*m,this._w=l*f*m-u*_*v;break;case"XZY":this._x=u*f*m-l*_*v,this._y=l*_*m-u*f*v,this._z=l*f*v+u*_*m,this._w=l*f*m+u*_*v;break;default:we("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],f=t[6],m=t[10],u=n+o+m;if(u>0){const _=.5/Math.sqrt(u+1);this._w=.25/_,this._x=(f-c)*_,this._y=(s-l)*_,this._z=(a-r)*_}else if(n>o&&n>m){const _=2*Math.sqrt(1+n-o-m);this._w=(f-c)/_,this._x=.25*_,this._y=(r+a)/_,this._z=(s+l)/_}else if(o>m){const _=2*Math.sqrt(1+o-n-m);this._w=(s-l)/_,this._x=(r+a)/_,this._y=.25*_,this._z=(c+f)/_}else{const _=2*Math.sqrt(1+m-n-o);this._w=(a-r)/_,this._x=(s+l)/_,this._y=(c+f)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(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=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Be(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),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(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,f=t._w;return this._x=n*f+a*o+r*l-s*c,this._y=r*f+a*c+s*o-n*l,this._z=s*f+a*l+n*c-r*o,this._w=a*f-n*o-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,s=-s,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),f=Math.sin(l);c=Math.sin(c*l)/f,t=Math.sin(t*l)/f,this._x=this._x*c+n*t,this._y=this._y*c+r*t,this._z=this._z*c+s*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+r*t,this._z=this._z*c+s*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Ia=class Ia{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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("THREE.Vector3: 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("THREE.Vector3: 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){return 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){return 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){return 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 this.applyQuaternion(io.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(io.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*r-o*n),f=2*(o*t-s*r),m=2*(s*n-a*t);return this.x=t+c*l+a*m-o*f,this.y=n+c*f+o*l-s*m,this.z=r+c*m+s*f-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[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=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=r*c-s*o,this.y=s*a-n*c,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return kr.copy(this).projectOnVector(e),this.sub(kr)}reflect(e){return this.sub(kr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Be(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return 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(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Ia.prototype.isVector3=!0;let N=Ia;const kr=new N,io=new Ti,Ua=class Ua{constructor(e,t,n,r,s,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,c,l)}set(e,t,n,r,s,a,o,c,l){const f=this.elements;return f[0]=e,f[1]=r,f[2]=o,f[3]=t,f[4]=s,f[5]=c,f[6]=n,f[7]=a,f[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],f=n[4],m=n[7],u=n[2],_=n[5],v=n[8],y=r[0],g=r[3],h=r[6],b=r[1],R=r[4],M=r[7],A=r[2],S=r[5],C=r[8];return s[0]=a*y+o*b+c*A,s[3]=a*g+o*R+c*S,s[6]=a*h+o*M+c*C,s[1]=l*y+f*b+m*A,s[4]=l*g+f*R+m*S,s[7]=l*h+f*M+m*C,s[2]=u*y+_*b+v*A,s[5]=u*g+_*R+v*S,s[8]=u*h+_*M+v*C,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8];return t*a*f-t*o*l-n*s*f+n*o*c+r*s*l-r*a*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8],m=f*a-o*l,u=o*c-f*s,_=l*s-a*c,v=t*m+n*u+r*_;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/v;return e[0]=m*y,e[1]=(r*l-f*n)*y,e[2]=(o*n-r*a)*y,e[3]=u*y,e[4]=(f*t-r*c)*y,e[5]=(r*s-o*t)*y,e[6]=_*y,e[7]=(n*c-l*t)*y,e[8]=(a*t-n*s)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const 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,n,r,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-r*l,r*c,-r*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return gi("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Wr.makeScale(e,t)),this}rotate(e){return gi("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Wr.makeRotation(-e)),this}translate(e,t){return gi("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Wr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Ua.prototype.isMatrix3=!0;let Ce=Ua;const Wr=new Ce,ro=new Ce().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),so=new Ce().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function jc(){const i={enabled:!0,workingColorSpace:wr,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Ke&&(r.r=gn(r.r),r.g=gn(r.g),r.b=gn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ke&&(r.r=_i(r.r),r.g=_i(r.g),r.b=_i(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Cn?Rr:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return gi("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return gi("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[wr]:{primaries:e,whitePoint:n,transfer:Rr,toXYZ:ro,fromXYZ:so,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:zt},outputColorSpaceConfig:{drawingBufferColorSpace:zt}},[zt]:{primaries:e,whitePoint:n,transfer:Ke,toXYZ:ro,fromXYZ:so,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:zt}}}),i}const ze=jc();function gn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function _i(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ei;class eu{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ei===void 0&&(ei=Cr("canvas")),ei.width=e.width,ei.height=e.height;const r=ei.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=ei}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Cr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=gn(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(gn(t[n]/255)*255):t[n]=gn(t[n]);return{data:t,width:e.width,height:e.height}}else return we("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let tu=0;class Ta{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:tu++}),this.uuid=yi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Xr(r[a].image)):s.push(Xr(r[a]))}else s=Xr(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function Xr(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?eu.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(we("Texture: Unable to serialize Texture."),{})}let nu=0;const qr=new N;class Dt extends Zn{constructor(e=Dt.DEFAULT_IMAGE,t=Dt.DEFAULT_MAPPING,n=pn,r=pn,s=wt,a=Hn,o=Yt,c=Ft,l=Dt.DEFAULT_ANISOTROPY,f=Cn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:nu++}),this.uuid=yi(),this.name="",this.source=new Ta(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Fe(0,0),this.repeat=new Fe(1,1),this.center=new Fe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ce,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(qr).x}get height(){return this.source.getSize(qr).y}get depth(){return this.source.getSize(qr).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,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.normalized=e.normalized,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.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){we(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){we(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==pl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ds:e.x=e.x-Math.floor(e.x);break;case pn:e.x=e.x<0?0:1;break;case Ls:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ds:e.y=e.y-Math.floor(e.y);break;case pn:e.y=e.y<0?0:1;break;case Ls:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Dt.DEFAULT_IMAGE=null;Dt.DEFAULT_MAPPING=pl;Dt.DEFAULT_ANISOTROPY=1;const Na=class Na{constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,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,n,r){return this.x=e,this.y=t,this.z=n,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("THREE.Vector4: 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("THREE.Vector4: 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=e.w!==void 0?e.w:1,this}add(e){return 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){return 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){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const 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){let t,n,r,s;const c=e.elements,l=c[0],f=c[4],m=c[8],u=c[1],_=c[5],v=c[9],y=c[2],g=c[6],h=c[10];if(Math.abs(f-u)<.01&&Math.abs(m-y)<.01&&Math.abs(v-g)<.01){if(Math.abs(f+u)<.1&&Math.abs(m+y)<.1&&Math.abs(v+g)<.1&&Math.abs(l+_+h-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const R=(l+1)/2,M=(_+1)/2,A=(h+1)/2,S=(f+u)/4,C=(m+y)/4,p=(v+g)/4;return R>M&&R>A?R<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(R),r=S/n,s=C/n):M>A?M<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(M),n=S/r,s=p/r):A<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(A),n=C/s,r=p/s),this.set(n,r,s,t),this}let b=Math.sqrt((g-v)*(g-v)+(m-y)*(m-y)+(u-f)*(u-f));return Math.abs(b)<.001&&(b=1),this.x=(g-v)/b,this.y=(m-y)/b,this.z=(u-f)/b,this.w=Math.acos((l+_+h-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],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=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this.w=Be(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this.w=Be(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return 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}};Na.prototype.isVector4=!0;let it=Na;class iu extends Zn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new it(0,0,e,t),this.scissorTest=!1,this.viewport=new it(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:n.depth},s=new Dt(r),a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:wt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);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){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new Ta(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class on extends iu{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class El extends Dt{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Et,this.minFilter=Et,this.wrapR=pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class ru extends Dt{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=Et,this.minFilter=Et,this.wrapR=pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ir=class Ir{constructor(e,t,n,r,s,a,o,c,l,f,m,u,_,v,y,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,c,l,f,m,u,_,v,y,g)}set(e,t,n,r,s,a,o,c,l,f,m,u,_,v,y,g){const h=this.elements;return h[0]=e,h[4]=t,h[8]=n,h[12]=r,h[1]=s,h[5]=a,h[9]=o,h[13]=c,h[2]=l,h[6]=f,h[10]=m,h[14]=u,h[3]=_,h[7]=v,h[11]=y,h[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ir().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,r=1/ti.setFromMatrixColumn(e,0).length(),s=1/ti.setFromMatrixColumn(e,1).length(),a=1/ti.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(r),l=Math.sin(r),f=Math.cos(s),m=Math.sin(s);if(e.order==="XYZ"){const u=a*f,_=a*m,v=o*f,y=o*m;t[0]=c*f,t[4]=-c*m,t[8]=l,t[1]=_+v*l,t[5]=u-y*l,t[9]=-o*c,t[2]=y-u*l,t[6]=v+_*l,t[10]=a*c}else if(e.order==="YXZ"){const u=c*f,_=c*m,v=l*f,y=l*m;t[0]=u+y*o,t[4]=v*o-_,t[8]=a*l,t[1]=a*m,t[5]=a*f,t[9]=-o,t[2]=_*o-v,t[6]=y+u*o,t[10]=a*c}else if(e.order==="ZXY"){const u=c*f,_=c*m,v=l*f,y=l*m;t[0]=u-y*o,t[4]=-a*m,t[8]=v+_*o,t[1]=_+v*o,t[5]=a*f,t[9]=y-u*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const u=a*f,_=a*m,v=o*f,y=o*m;t[0]=c*f,t[4]=v*l-_,t[8]=u*l+y,t[1]=c*m,t[5]=y*l+u,t[9]=_*l-v,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const u=a*c,_=a*l,v=o*c,y=o*l;t[0]=c*f,t[4]=y-u*m,t[8]=v*m+_,t[1]=m,t[5]=a*f,t[9]=-o*f,t[2]=-l*f,t[6]=_*m+v,t[10]=u-y*m}else if(e.order==="XZY"){const u=a*c,_=a*l,v=o*c,y=o*l;t[0]=c*f,t[4]=-m,t[8]=l*f,t[1]=u*m+y,t[5]=a*f,t[9]=_*m-v,t[2]=v*m-_,t[6]=o*f,t[10]=y*m+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(su,e,au)}lookAt(e,t,n){const r=this.elements;return Ut.subVectors(e,t),Ut.lengthSq()===0&&(Ut.z=1),Ut.normalize(),yn.crossVectors(n,Ut),yn.lengthSq()===0&&(Math.abs(n.z)===1?Ut.x+=1e-4:Ut.z+=1e-4,Ut.normalize(),yn.crossVectors(n,Ut)),yn.normalize(),$i.crossVectors(Ut,yn),r[0]=yn.x,r[4]=$i.x,r[8]=Ut.x,r[1]=yn.y,r[5]=$i.y,r[9]=Ut.y,r[2]=yn.z,r[6]=$i.z,r[10]=Ut.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],f=n[1],m=n[5],u=n[9],_=n[13],v=n[2],y=n[6],g=n[10],h=n[14],b=n[3],R=n[7],M=n[11],A=n[15],S=r[0],C=r[4],p=r[8],E=r[12],w=r[1],P=r[5],I=r[9],X=r[13],H=r[2],O=r[6],W=r[10],k=r[14],J=r[3],j=r[7],le=r[11],he=r[15];
vendor: 4,452 bytes, line 5
5return s[0]=a*S+o*w+c*H+l*J,s[4]=a*C+o*P+c*O+l*j,s[8]=a*p+o*I+c*W+l*le,s[12]=a*E+o*X+c*k+l*he,s[1]=f*S+m*w+u*H+_*J,s[5]=f*C+m*P+u*O+_*j,s[9]=f*p+m*I+u*W+_*le,s[13]=f*E+m*X+u*k+_*he,s[2]=v*S+y*w+g*H+h*J,s[6]=v*C+y*P+g*O+h*j,s[10]=v*p+y*I+g*W+h*le,s[14]=v*E+y*X+g*k+h*he,s[3]=b*S+R*w+M*H+A*J,s[7]=b*C+R*P+M*O+A*j,s[11]=b*p+R*I+M*W+A*le,s[15]=b*E+R*X+M*k+A*he,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],f=e[2],m=e[6],u=e[10],_=e[14],v=e[3],y=e[7],g=e[11],h=e[15],b=c*_-l*u,R=o*_-l*m,M=o*u-c*m,A=a*_-l*f,S=a*u-c*f,C=a*m-o*f;return t*(y*b-g*R+h*M)-n*(v*b-g*A+h*S)+r*(v*R-y*A+h*C)-s*(v*M-y*S+g*C)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],c=e[2],l=e[6],f=e[10];return t*(a*f-o*l)-n*(s*f-o*c)+r*(s*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8],m=e[9],u=e[10],_=e[11],v=e[12],y=e[13],g=e[14],h=e[15],b=t*o-n*a,R=t*c-r*a,M=t*l-s*a,A=n*c-r*o,S=n*l-s*o,C=r*l-s*c,p=f*y-m*v,E=f*g-u*v,w=f*h-_*v,P=m*g-u*y,I=m*h-_*y,X=u*h-_*g,H=b*X-R*I+M*P+A*w-S*E+C*p;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/H;return e[0]=(o*X-c*I+l*P)*O,e[1]=(r*I-n*X-s*P)*O,e[2]=(y*C-g*S+h*A)*O,e[3]=(u*S-m*C-_*A)*O,e[4]=(c*w-a*X-l*E)*O,e[5]=(t*X-r*w+s*E)*O,e[6]=(g*M-v*C-h*R)*O,e[7]=(f*C-u*M+_*R)*O,e[8]=(a*I-o*w+l*p)*O,e[9]=(n*w-t*I-s*p)*O,e[10]=(v*S-y*M+h*b)*O,e[11]=(m*M-f*S-_*b)*O,e[12]=(o*E-a*P-c*p)*O,e[13]=(t*P-n*E+r*p)*O,e[14]=(y*R-v*A-g*b)*O,e[15]=(f*A-m*R+u*b)*O,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,f=s*o;return this.set(l*a+n,l*o-r*c,l*c+r*o,0,l*o+r*c,f*o+n,f*c-r*a,0,l*c-r*o,f*c+r*a,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,f=a+a,m=o+o,u=s*l,_=s*f,v=s*m,y=a*f,g=a*m,h=o*m,b=c*l,R=c*f,M=c*m,A=n.x,S=n.y,C=n.z;return r[0]=(1-(y+h))*A,r[1]=(_+M)*A,r[2]=(v-R)*A,r[3]=0,r[4]=(_-M)*S,r[5]=(1-(u+h))*S,r[6]=(g+b)*S,r[7]=0,r[8]=(v+R)*C,r[9]=(g-b)*C,r[10]=(1-(u+y))*C,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinantAffine();if(s===0)return n.set(1,1,1),t.identity(),this;let a=ti.set(r[0],r[1],r[2]).length();const o=ti.set(r[4],r[5],r[6]).length(),c=ti.set(r[8],r[9],r[10]).length();s<0&&(a=-a),Ht.copy(this);const l=1/a,f=1/o,m=1/c;return Ht.elements[0]*=l,Ht.elements[1]*=l,Ht.elements[2]*=l,Ht.elements[4]*=f,Ht.elements[5]*=f,Ht.elements[6]*=f,Ht.elements[8]*=m,Ht.elements[9]*=m,Ht.elements[10]*=m,t.setFromRotationMatrix(Ht),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,r,s,a,o=rn,c=!1){const l=this.elements,f=2*s/(t-e),m=2*s/(n-r),u=(t+e)/(t-e),_=(n+r)/(n-r);let v,y;if(c)v=s/(a-s),y=a*s/(a-s);else if(o===rn)v=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===Vi)v=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=f,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=m,l[9]=_,l[13]=0,l[2]=0,l[6]=0,l[10
vendor: 25,840 bytes, line 5
5]=v,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=rn,c=!1){const l=this.elements,f=2/(t-e),m=2/(n-r),u=-(t+e)/(t-e),_=-(n+r)/(n-r);let v,y;if(c)v=1/(a-s),y=a/(a-s);else if(o===rn)v=-2/(a-s),y=-(a+s)/(a-s);else if(o===Vi)v=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=f,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=m,l[9]=0,l[13]=_,l[2]=0,l[6]=0,l[10]=v,l[14]=y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};Ir.prototype.isMatrix4=!0;let tt=Ir;const ti=new N,Ht=new tt,su=new N(0,0,0),au=new N(1,1,1),yn=new N,$i=new N,Ut=new N,ao=new tt,oo=new Ti;class Ln{constructor(e=0,t=0,n=0,r=Ln.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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 order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],f=r[9],m=r[2],u=r[6],_=r[10];switch(t){case"XYZ":this._y=Math.asin(Be(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,_),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Be(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,_),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-m,s),this._z=0);break;case"ZXY":this._x=Math.asin(Be(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-m,_),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Be(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(u,_),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Be(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,l),this._y=Math.atan2(-m,s)):(this._x=0,this._y=Math.atan2(o,_));break;case"XZY":this._z=Math.asin(-Be(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-f,_),this._y=0);break;default:we("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ao.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ao,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return oo.setFromEuler(this),this.setFromQuaternion(oo,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ln.DEFAULT_ORDER="XYZ";class yl{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let ou=0;const lo=new N,ni=new Ti,cn=new tt,Ji=new N,wi=new N,lu=new N,cu=new Ti,co=new N(1,0,0),uo=new N(0,1,0),ho=new N(0,0,1),fo={type:"added"},uu={type:"removed"},ii={type:"childadded",child:null},Yr={type:"childremoved",child:null};class vt extends Zn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ou++}),this.uuid=yi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=vt.DEFAULT_UP.clone();const e=new N,t=new Ln,n=new Ti,r=new N(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new tt},normalMatrix:{value:new Ce}}),this.matrix=new tt,this.matrixWorld=new tt,this.matrixAutoUpdate=vt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=vt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ni.setFromAxisAngle(e,t),this.quaternion.multiply(ni),this}rotateOnWorldAxis(e,t){return ni.setFromAxisAngle(e,t),this.quaternion.premultiply(ni),this}rotateX(e){return this.rotateOnAxis(co,e)}rotateY(e){return this.rotateOnAxis(uo,e)}rotateZ(e){return this.rotateOnAxis(ho,e)}translateOnAxis(e,t){return lo.copy(e).applyQuaternion(this.quaternion),this.position.add(lo.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(co,e)}translateY(e){return this.translateOnAxis(uo,e)}translateZ(e){return this.translateOnAxis(ho,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(cn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ji.copy(e):Ji.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),wi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?cn.lookAt(wi,Ji,this.up):cn.lookAt(Ji,wi,this.up),this.quaternion.setFromRotationMatrix(cn),r&&(cn.extractRotation(r.matrixWorld),ni.setFromRotationMatrix(cn),this.quaternion.premultiply(ni.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(We("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(fo),ii.child=e,this.dispatchEvent(ii),ii.child=null):We("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(uu),Yr.child=e,this.dispatchEvent(Yr),Yr.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),cn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),cn.multiply(e.parent.matrixWorld)),e.applyMatrix4(cn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(fo),ii.child=e,this.dispatchEvent(ii),ii.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wi,e,lu),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wi,cu,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*r,s[13]+=n-s[1]*t-s[5]*n-s[9]*r,s[14]+=r-s[2]*t-s[6]*n-s[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const s=this.children;for(let a=0,o=s.length;a<o;a++)s[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,f=c.length;l<f;l++){const m=c[l];s(e.shapes,m)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(e.materials,this.material[c]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];r.animations.push(s(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),f=a(e.images),m=a(e.shapes),u=a(e.skeletons),_=a(e.animations),v=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),f.length>0&&(n.images=f),m.length>0&&(n.shapes=m),u.length>0&&(n.skeletons=u),_.length>0&&(n.animations=_),v.length>0&&(n.nodes=v)}return n.object=r,n;function a(o){const c=[];for(const l in o){const f=o[l];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}vt.DEFAULT_UP=new N(0,1,0);vt.DEFAULT_MATRIX_AUTO_UPDATE=!0;vt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Wn extends vt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const hu={type:"move"};class Kr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Wn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Wn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const y of e.hand.values()){const g=t.getJointPose(y,n),h=this._getHandJoint(l,y);g!==null&&(h.matrix.fromArray(g.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,h.jointRadius=g.radius),h.visible=g!==null}const f=l.joints["index-finger-tip"],m=l.joints["thumb-tip"],u=f.position.distanceTo(m.position),_=.02,v=.005;l.inputState.pinching&&u>_+v?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=_-v&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(hu)))}return o!==null&&(o.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Wn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Tl={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},Tn={h:0,s:0,l:0},Qi={h:0,s:0,l:0};function Zr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Ge{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=zt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ze.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=ze.workingColorSpace){return this.r=e,this.g=t,this.b=n,ze.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=ze.workingColorSpace){if(e=ya(e,1),t=Be(t,0,1),n=Be(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Zr(a,s,e+1/3),this.g=Zr(a,s,e),this.b=Zr(a,s,e-1/3)}return ze.colorSpaceToWorking(this,r),this}setStyle(e,t=zt){function n(s){s!==void 0&&parseFloat(s)<1&&we("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:we("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);we("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=zt){const n=Tl[e.toLowerCase()];return n!==void 0?this.setHex(n,t):we("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=gn(e.r),this.g=gn(e.g),this.b=gn(e.b),this}copyLinearToSRGB(e){return this.r=_i(e.r),this.g=_i(e.g),this.b=_i(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=zt){return ze.workingToColorSpace(At.copy(this),e),Math.round(Be(At.r*255,0,255))*65536+Math.round(Be(At.g*255,0,255))*256+Math.round(Be(At.b*255,0,255))}getHexString(e=zt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ze.workingColorSpace){ze.workingToColorSpace(At.copy(this),t);const n=At.r,r=At.g,s=At.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let c,l;const f=(o+a)/2;if(o===a)c=0,l=0;else{const m=a-o;switch(l=f<=.5?m/(a+o):m/(2-a-o),a){case n:c=(r-s)/m+(r<s?6:0);break;case r:c=(s-n)/m+2;break;case s:c=(n-r)/m+4;break}c/=6}return e.h=c,e.s=l,e.l=f,e}getRGB(e,t=ze.workingColorSpace){return ze.workingToColorSpace(At.copy(this),t),e.r=At.r,e.g=At.g,e.b=At.b,e}getStyle(e=zt){ze.workingToColorSpace(At.copy(this),e);const t=At.r,n=At.g,r=At.b;return e!==zt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Tn),this.setHSL(Tn.h+e,Tn.s+t,Tn.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}
vendor: 4,712 bytes, line 5
5lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Tn),e.getHSL(Qi);const n=Bi(Tn.h,Qi.h,t),r=Bi(Tn.s,Qi.s,t),s=Bi(Tn.l,Qi.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const At=new Ge;Ge.NAMES=Tl;class ba{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ge(e),this.near=t,this.far=n}clone(){return new ba(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class fu extends vt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ln,this.environmentIntensity=1,this.environmentRotation=new Ln,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const kt=new N,un=new N,$r=new N,hn=new N,ri=new N,si=new N,po=new N,Jr=new N,Qr=new N,jr=new N,es=new it,ts=new it,ns=new it;class Xt{constructor(e=new N,t=new N,n=new N){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),kt.subVectors(e,t),r.cross(kt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){kt.subVectors(r,t),un.subVectors(n,t),$r.subVectors(e,t);const a=kt.dot(kt),o=kt.dot(un),c=kt.dot($r),l=un.dot(un),f=un.dot($r),m=a*l-o*o;if(m===0)return s.set(0,0,0),null;const u=1/m,_=(l*c-o*f)*u,v=(a*f-o*c)*u;return s.set(1-_-v,v,_)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,hn)===null?!1:hn.x>=0&&hn.y>=0&&hn.x+hn.y<=1}static getInterpolation(e,t,n,r,s,a,o,c){return this.getBarycoord(e,t,n,r,hn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,hn.x),c.addScaledVector(a,hn.y),c.addScaledVector(o,hn.z),c)}static getInterpolatedAttribute(e,t,n,r,s,a){return es.setScalar(0),ts.setScalar(0),ns.setScalar(0),es.fromBufferAttribute(e,t),ts.fromBufferAttribute(e,n),ns.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(es,s.x),a.addScaledVector(ts,s.y),a.addScaledVector(ns,s.z),a}static isFrontFacing(e,t,n,r){return kt.subVectors(n,t),un.subVectors(e,t),kt.cross(un).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return kt.subVectors(this.c,this.b),un.subVectors(this.a,this.b),kt.cross(un).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Xt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Xt.getBarycoord(e,this.a,this.b,this.c,t)}
vendor: 6,209 bytes, line 5
5getInterpolation(e,t,n,r,s){return Xt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Xt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Xt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;ri.subVectors(r,n),si.subVectors(s,n),Jr.subVectors(e,n);const c=ri.dot(Jr),l=si.dot(Jr);if(c<=0&&l<=0)return t.copy(n);Qr.subVectors(e,r);const f=ri.dot(Qr),m=si.dot(Qr);if(f>=0&&m<=f)return t.copy(r);const u=c*m-f*l;if(u<=0&&c>=0&&f<=0)return a=c/(c-f),t.copy(n).addScaledVector(ri,a);jr.subVectors(e,s);const _=ri.dot(jr),v=si.dot(jr);if(v>=0&&_<=v)return t.copy(s);const y=_*l-c*v;if(y<=0&&l>=0&&v<=0)return o=l/(l-v),t.copy(n).addScaledVector(si,o);const g=f*v-_*m;if(g<=0&&m-f>=0&&_-v>=0)return po.subVectors(s,r),o=(m-f)/(m-f+(_-v)),t.copy(r).addScaledVector(po,o);const h=1/(g+y+u);return a=y*h,o=u*h,t.copy(n).addScaledVector(ri,a).addScaledVector(si,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class $n{constructor(e=new N(1/0,1/0,1/0),t=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Wt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Wt.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Wt.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}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,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Wt):Wt.fromBufferAttribute(s,a),Wt.applyMatrix4(e.matrixWorld),this.expandByPoint(Wt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ji.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ji.copy(n.boundingBox)),ji.applyMatrix4(e.matrixWorld),this.union(ji)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);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,Wt),Wt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ri),er.subVectors(this.max,Ri),ai.subVectors(e.a,Ri),oi.subVectors(e.b,Ri),li.subVectors(e.c,Ri),bn.subVectors(oi,ai),An.subVectors(li,oi),Un.subVectors(ai,li);let t=[0,-bn.z,bn.y,0,-An.z,An.y,0,-Un.z,Un.y,bn.z,0,-bn.x,An.z,0,-An.x,Un.z,0,-Un.x,-bn.y,bn.x,0,-An.y,An.x,0,-Un.y,Un.x,0];return!is(t,ai,oi,li,er)||(t=[1,0,0,0,1,0,0,0,1],!is(t,ai,oi,li,er))?!1:(tr.crossVectors(bn,An),t=[tr.x,tr.y,tr.z],is(t,ai,oi,li,er))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Wt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Wt).length()*.5),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()?this:(fn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fn),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const fn=[new N,new N,new N,new N,new N,new N,new N,new N],Wt=new N,ji=new $n,ai=new N,oi=new N,li=new N,bn=new N,An=new N,Un=new N,Ri=new N,er=new N,tr=new N,Nn=new N;function is(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Nn.fromArray(i,s);const o=r.x*Math.abs(Nn.x)+r.y*Math.abs(Nn.y)+r.z*Math.abs(Nn.z),c=e.dot(Nn),l=t.dot(Nn),f=n.dot(Nn);
vendor: 5,102 bytes, line 5
5if(Math.max(-Math.max(c,l,f),Math.min(c,l,f))>o)return!1}return!0}const dt=new N,nr=new Fe;let du=0;class Kt extends Zn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:du++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ja,this.updateRanges=[],this.gpuType=qt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)nr.fromBufferAttribute(this,t),nr.applyMatrix3(e),this.setXY(t,nr.x,nr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)dt.fromBufferAttribute(this,t),dt.applyMatrix3(e),this.setXYZ(t,dt.x,dt.y,dt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)dt.fromBufferAttribute(this,t),dt.applyMatrix4(e),this.setXYZ(t,dt.x,dt.y,dt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)dt.fromBufferAttribute(this,t),dt.applyNormalMatrix(e),this.setXYZ(t,dt.x,dt.y,dt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)dt.fromBufferAttribute(this,t),dt.transformDirection(e),this.setXYZ(t,dt.x,dt.y,dt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=pi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Rt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=pi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Rt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=pi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Rt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=pi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Rt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=pi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Rt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Rt(t,this.array),n=Rt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Rt(t,this.array),n=Rt(n,this.array),r=Rt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Rt(t,this.array),n=Rt(n,this.array),r=Rt(r,this.array),s=Rt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ja&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class bl extends Kt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Al extends Kt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Mt extends Kt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const pu=new $n,Ci=new N,rs=new N;class ki{constructor(e=new N,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):pu.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));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){const 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){const n=this.center.distanceToSquared(e);return t.copy(e),n>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):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}
vendor: 13,275 bytes, line 5
5applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ci.subVectors(e,this.center);const t=Ci.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Ci,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(rs.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ci.copy(e.center).add(rs)),this.expandByPoint(Ci.copy(e.center).sub(rs))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let mu=0;const Bt=new tt,ss=new vt,ci=new N,Nt=new $n,Pi=new $n,xt=new N;class Vt extends Zn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:mu++}),this.uuid=yi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Ic(e)?Al:bl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Ce().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Bt.makeRotationFromQuaternion(e),this.applyMatrix4(Bt),this}rotateX(e){return Bt.makeRotationX(e),this.applyMatrix4(Bt),this}rotateY(e){return Bt.makeRotationY(e),this.applyMatrix4(Bt),this}rotateZ(e){return Bt.makeRotationZ(e),this.applyMatrix4(Bt),this}translate(e,t,n){return Bt.makeTranslation(e,t,n),this.applyMatrix4(Bt),this}scale(e,t,n){return Bt.makeScale(e,t,n),this.applyMatrix4(Bt),this}lookAt(e){return ss.lookAt(e),ss.updateMatrix(),this.applyMatrix4(ss.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ci).negate(),this.translate(ci.x,ci.y,ci.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Mt(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&we("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new $n);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Nt.setFromBufferAttribute(s),this.morphTargetsRelative?(xt.addVectors(this.boundingBox.min,Nt.min),this.boundingBox.expandByPoint(xt),xt.addVectors(this.boundingBox.max,Nt.max),this.boundingBox.expandByPoint(xt)):(this.boundingBox.expandByPoint(Nt.min),this.boundingBox.expandByPoint(Nt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&We('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){const n=this.boundingSphere.center;if(Nt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Pi.setFromBufferAttribute(o),this.morphTargetsRelative?(xt.addVectors(Nt.min,Pi.min),Nt.expandByPoint(xt),xt.addVectors(Nt.max,Pi.max),Nt.expandByPoint(xt)):(Nt.expandByPoint(Pi.min),Nt.expandByPoint(Pi.max))}Nt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)xt.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(xt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,f=o.count;l<f;l++)xt.fromBufferAttribute(o,l),c&&(ci.fromBufferAttribute(e,l),xt.add(ci)),r=Math.max(r,n.distanceToSquared(xt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&We('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){We("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Kt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let p=0;p<n.count;p++)o[p]=new N,c[p]=new N;const l=new N,f=new N,m=new N,u=new Fe,_=new Fe,v=new Fe,y=new N,g=new N;function h(p,E,w){l.fromBufferAttribute(n,p),f.fromBufferAttribute(n,E),m.fromBufferAttribute(n,w),u.fromBufferAttribute(s,p),_.fromBufferAttribute(s,E),v.fromBufferAttribute(s,w),f.sub(l),m.sub(l),_.sub(u),v.sub(u);const P=1/(_.x*v.y-v.x*_.y);isFinite(P)&&(y.copy(f).multiplyScalar(v.y).addScaledVector(m,-_.y).multiplyScalar(P),g.copy(m).multiplyScalar(_.x).addScaledVector(f,-v.x).multiplyScalar(P),o[p].add(y),o[E].add(y),o[w].add(y),c[p].add(g),c[E].add(g),c[w].add(g))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let p=0,E=b.length;p<E;++p){const w=b[p],P=w.start,I=w.count;for(let X=P,H=P+I;X<H;X+=3)h(e.getX(X+0),e.getX(X+1),e.getX(X+2))}const R=new N,M=new N,A=new N,S=new N;function C(p){A.fromBufferAttribute(r,p),S.copy(A);const E=o[p];R.copy(E),R.sub(A.multiplyScalar(A.dot(E))).normalize(),M.crossVectors(S,E);const P=M.dot(c[p])<0?-1:1;a.setXYZW(p,R.x,R.y,R.z,P)}for(let p=0,E=b.length;p<E;++p){const w=b[p],P=w.start,I=w.count;for(let X=P,H=P+I;X<H;X+=3)C(e.getX(X+0)),C(e.getX(X+1)),C(e.getX(X+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Kt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,_=n.count;u<_;u++)n.setXYZ(u,0,0,0);const r=new N,s=new N,a=new N,o=new N,c=new N,l=new N,f=new N,m=new N;if(e)for(let u=0,_=e.count;u<_;u+=3){const v=e.getX(u+0),y=e.getX(u+1),g=e.getX(u+2);r.fromBufferAttribute(t,v),s.fromBufferAttribute(t,y),a.fromBufferAttribute(t,g),f.subVectors(a,s),m.subVectors(r,s),f.cross(m),o.fromBufferAttribute(n,v),c.fromBufferAttribute(n,y),l.fromBufferAttribute(n,g),o.add(f),c.add(f),l.add(f),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(y,c.x,c.y,c.z),n.setXYZ(g,l.x,l.y,l.z)}else for(let u=0,_=t.count;u<_;u+=3)r.fromBufferAttribute(t,u+0),s.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),f.subVectors(a,s),m.subVectors(r,s),f.cross(m),n.setXYZ(u+0,f.x,f.y,f.z),n.setXYZ(u+1,f.x,f.y,f.z),n.setXYZ(u+2,f.x,f.y,f.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)xt.fromBufferAttribute(e,t),xt.normalize(),e.setXYZ(t,xt.x,xt.y,xt.z)}toNonIndexed(){function e(o,c){const l=o.array,f=o.itemSize,m=o.normalized,u=new l.constructor(c.length*f);let _=0,v=0;for(let y=0,g=c.length;y<g;y++){o.isInterleavedBufferAttribute?_=c[y]*o.data.stride+o.offset:_=c[y]*f;for(let h=0;h<f;h++)u[v++]=l[_++]}return new Kt(u,f,m)}if(this.index===null)return we("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Vt,n=this.index.array,r=this.attributes;for(const o in r){const c=r[o],l=e(c,n);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let f=0,m=l.length;f<m;f++){const u=l[f],_=e(u,n);c.push(_)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],f=[];for(let m=0,u=l.length;m<u;m++){const _=l[m];f.push(_.toJSON(e.data))}f.length>0&&(r[c]=f,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const l in r){const f=r[l];this.setAttribute(l,f.clone(t))}const s=e.morphAttributes;for(const l in s){const f=[],m=s[l];for(let u=0,_=m.length;u<_;u++)f.push(m[u].clone(t));this.morphAttributes[l]=f}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,f=a.length;l<f;l++){const m=a[l];this.addGroup(m.start,m.count,m.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}let gu=0;class Wi extends Zn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:gu++}),this.uuid=yi(),this.name="",this.type="Material",this.blending=mi,this.side=Dn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Es,this.blendDst=ys,this.blendEquation=zn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ge(0,0,0),this.blendAlpha=0,this.depthFunc=xi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=$a,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=jn,this.stencilZFail=jn,this.stencilZPass=jn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){we(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){we(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};
vendor: 16,661 bytes, line 5
5n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==mi&&(n.blending=this.blending),this.side!==Dn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Es&&(n.blendSrc=this.blendSrc),this.blendDst!==ys&&(n.blendDst=this.blendDst),this.blendEquation!==zn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==xi&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==$a&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==jn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==jn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==jn&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ge().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Fe().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Fe().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipSh
vendor: 5,530 bytes, line 5
5adows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const dn=new N,as=new N,ir=new N,wn=new N,os=new N,rr=new N,ls=new N;class _u{constructor(e=new N,t=new N(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.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,dn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=dn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(dn.copy(this.origin).addScaledVector(this.direction,t),dn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){as.copy(e).add(t).multiplyScalar(.5),ir.copy(t).sub(e).normalize(),wn.copy(this.origin).sub(as);const s=e.distanceTo(t)*.5,a=-this.direction.dot(ir),o=wn.dot(this.direction),c=-wn.dot(ir),l=wn.lengthSq(),f=Math.abs(1-a*a);let m,u,_,v;if(f>0)if(m=a*c-o,u=a*o-c,v=s*f,m>=0)if(u>=-v)if(u<=v){const y=1/f;m*=y,u*=y,_=m*(m+a*u+2*o)+u*(a*m+u+2*c)+l}else u=s,m=Math.max(0,-(a*u+o)),_=-m*m+u*(u+2*c)+l;else u=-s,m=Math.max(0,-(a*u+o)),_=-m*m+u*(u+2*c)+l;else u<=-v?(m=Math.max(0,-(-a*s+o)),u=m>0?-s:Math.min(Math.max(-s,-c),s),_=-m*m+u*(u+2*c)+l):u<=v?(m=0,u=Math.min(Math.max(-s,-c),s),_=u*(u+2*c)+l):(m=Math.max(0,-(a*s+o)),u=m>0?s:Math.min(Math.max(-s,-c),s),_=-m*m+u*(u+2*c)+l);else u=a>0?-s:s,m=Math.max(0,-(a*u+o)),_=-m*m+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,m),r&&r.copy(as).addScaledVector(ir,u),_}intersectSphere(e,t){dn.subVectors(e.center,this.origin);const n=dn.dot(this.direction),r=dn.dot(dn)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,c;const l=1/this.direction.x,f=1/this.direction.y,m=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,r=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,r=(e.min.x-u.x)*l),f>=0?(s=(e.min.y-u.y)*f,a=(e.max.y-u.y)*f):(s=(e.max.y-u.y)*f,a=(e.min.y-u.y)*f),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),m>=0?(o=(e.min.z-u.z)*m,c=(e.max.z-u.z)*m):(o=(e.max.z-u.z)*m,c=(e.min.z-u.z)*m),n>c||o>r)||((o>n||n!==n)&&(n=o),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,dn)!==null}intersectTriangle(e,t,n,r,s){os.subVectors(t,e),rr.subVectors(n,e),ls.crossVectors(os,rr);let a=this.direction.dot(ls),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;wn.subVectors(this.origin,e);const c=o*this.direction.dot(rr.crossVectors(wn,rr));if(c<0)return null;const l=o*this.direction.dot(os.cross(wn));if(l<0||c+l>a)return null;const f=-o*wn.dot(ls);return f<0?null:this.at(f/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class wl extends Wi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ge(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ln,this.combine=ol,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const mo=new tt,Fn=new _u,sr=new ki,go=new N,ar=new N,or=new N,lr=new N,cs=new N,cr=new N,_o=new N,ur=new N;
vendor: 7,626 bytes, line 5
5class nt extends vt{constructor(e=new Vt,t=new wl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){cr.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const f=o[c],m=s[c];f!==0&&(cs.fromBufferAttribute(m,e),a?cr.addScaledVector(cs,f):cr.addScaledVector(cs.sub(t),f))}t.add(cr)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),sr.copy(n.boundingSphere),sr.applyMatrix4(s),Fn.copy(e.ray).recast(e.near),!(sr.containsPoint(Fn.origin)===!1&&(Fn.intersectSphere(sr,go)===null||Fn.origin.distanceToSquared(go)>(e.far-e.near)**2))&&(mo.copy(s).invert(),Fn.copy(e.ray).applyMatrix4(mo),!(n.boundingBox!==null&&Fn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Fn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,f=s.attributes.uv1,m=s.attributes.normal,u=s.groups,_=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,y=u.length;v<y;v++){const g=u[v],h=a[g.materialIndex],b=Math.max(g.start,_.start),R=Math.min(o.count,Math.min(g.start+g.count,_.start+_.count));for(let M=b,A=R;M<A;M+=3){const S=o.getX(M),C=o.getX(M+1),p=o.getX(M+2);r=hr(this,h,e,n,l,f,m,S,C,p),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{const v=Math.max(0,_.start),y=Math.min(o.count,_.start+_.count);for(let g=v,h=y;g<h;g+=3){const b=o.getX(g),R=o.getX(g+1),M=o.getX(g+2);r=hr(this,a,e,n,l,f,m,b,R,M),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(a))for(let v=0,y=u.length;v<y;v++){const g=u[v],h=a[g.materialIndex],b=Math.max(g.start,_.start),R=Math.min(c.count,Math.min(g.start+g.count,_.start+_.count));for(let M=b,A=R;M<A;M+=3){const S=M,C=M+1,p=M+2;r=hr(this,h,e,n,l,f,m,S,C,p),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{const v=Math.max(0,_.start),y=Math.min(c.count,_.start+_.count);for(let g=v,h=y;g<h;g+=3){const b=g,R=g+1,M=g+2;r=hr(this,a,e,n,l,f,m,b,R,M),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}}function xu(i,e,t,n,r,s,a,o){let c;if(e.side===Pt?c=n.intersectTriangle(a,s,r,!0,o):c=n.intersectTriangle(r,s,a,e.side===Dn,o),c===null)return null;ur.copy(o),ur.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(ur);return l<t.near||l>t.far?null:{distance:l,point:ur.clone(),object:i}}function hr(i,e,t,n,r,s,a,o,c,l){i.getVertexPosition(o,ar),i.getVertexPosition(c,or),i.getVertexPosition(l,lr);const f=xu(i,e,t,n,ar,or,lr,_o);if(f){const m=new N;Xt.getBarycoord(_o,ar,or,lr,m),r&&(f.uv=Xt.getInterpolatedAttribute(r,o,c,l,m,new Fe)),s&&(f.uv1=Xt.getInterpolatedAttribute(s,o,c,l,m,new Fe)),a&&(f.normal=Xt.getInterpolatedAttribute(a,o,c,l,m,new N),f.normal.dot(n.direction)>0&&f.normal.multiplyScalar(-1));const u={a:o,b:c,c:l,normal:new N,materialIndex:0};Xt.getNormal(ar,or,lr,u.normal),f.face=u,f.barycoord=m}return f}class Rl extends Dt{constructor(e=null,t=1,n=1,r,s,a,o,c,l=Et,f=Et,m,u){super(null,a,o,c,l,f,r,s,m,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class xo extends Kt{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const ui=new tt,vo=new tt,fr=[],Mo=new $n,vu=new tt,Di=new nt,Li=new ki;class So extends nt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new xo(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,vu)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new $n),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ui),Mo.copy(e.boundingBox).applyMatrix4(ui),this.boundingBox.union(Mo)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ki),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ui),Li.copy(e.boundingSphere).applyMatrix4(ui),this.boundingSphere.union(Li)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=e*s+1;for(let o=0;o<n.length;o++)n[o]=r[a+o]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(Di.geometry=this.geometry,Di.material=this.material,Di.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Li.copy(this.boundingSphere),Li.applyMatrix4(n),e.ray.intersectsSphere(Li)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,ui),vo.multiplyMatrices(n,ui),Di.matrixWorld=vo,Di.raycast(e,fr);for(let a=0,o=fr.length;a<o;a++){const c=fr[a];c.instanceId=s,c.object=this,t.push(c)}fr.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new xo(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Rl(new Float32Array(r*this.count),r,this.count,_a,qt));const s=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=r*e;return s[c]=o,s.set(n,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const us=new N,Mu=new N,Su=new Ce;class Bn{constructor(e=new N(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}
vendor: 7,857 bytes, line 5
5setFromCoplanarPoints(e,t,n){const r=us.subVectors(n,t).cross(Mu.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const r=e.delta(us),s=this.normal.dot(r);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/s;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Su.getNormalMatrix(e),r=this.coplanarPoint(us).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const On=new ki,Eu=new Fe(.5,.5),dr=new N;class Aa{constructor(e=new Bn,t=new Bn,n=new Bn,r=new Bn,s=new Bn,a=new Bn){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=rn,n=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],c=s[2],l=s[3],f=s[4],m=s[5],u=s[6],_=s[7],v=s[8],y=s[9],g=s[10],h=s[11],b=s[12],R=s[13],M=s[14],A=s[15];if(r[0].setComponents(l-a,_-f,h-v,A-b).normalize(),r[1].setComponents(l+a,_+f,h+v,A+b).normalize(),r[2].setComponents(l+o,_+m,h+y,A+R).normalize(),r[3].setComponents(l-o,_-m,h-y,A-R).normalize(),n)r[4].setComponents(c,u,g,M).normalize(),r[5].setComponents(l-c,_-u,h-g,A-M).normalize();else if(r[4].setComponents(l-c,_-u,h-g,A-M).normalize(),t===rn)r[5].setComponents(l+c,_+u,h+g,A+M).normalize();else if(t===Vi)r[5].setComponents(c,u,g,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),On.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),On.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(On)}intersectsSprite(e){On.center.set(0,0,0);const t=Eu.distanceTo(e.center);return On.radius=.7071067811865476+t,On.applyMatrix4(e.matrixWorld),this.intersectsSphere(On)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(dr.x=r.normal.x>0?e.max.x:e.min.x,dr.y=r.normal.y>0?e.max.y:e.min.y,dr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(dr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Cl extends Dt{constructor(e=[],t=Yn,n,r,s,a,o,c,l,f){super(e,t,n,r,s,a,o,c,l,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Mi extends Dt{constructor(e,t,n=ln,r,s,a,o=Et,c=Et,l,f=vn,m=1){if(f!==vn&&f!==kn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:m};super(u,r,s,a,o,c,f,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ta(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class yu extends Mi{constructor(e,t=ln,n=Yn,r,s,a=Et,o=Et,c,l=vn){const f={width:e,height:e,depth:1},m=[f,f,f,f,f,f];super(e,e,t,n,r,s,a,o,c,l),this.image=m,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Pl extends Dt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class sn extends Vt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],f=[],m=[];let u=0,_=0;v("z","y","x",-1,-1,n,t,e,a,s,0),v("z","y","x",1,-1,n,t,-e,a,s,1),v("x","z","y",1,1,e,n,t,r,a,2),v("x","z","y",1,-1,e,n,-t,r,a,3),v("x","y","z",1,-1,e,t,n,r,s,4),v("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new Mt(l,3)),this.setAttribute("normal",new Mt(f,3)),this.setAttribute("uv",new Mt(m,2));function v(y,g,h,b,R,M,A,S,C,p,E){const w=M/C,P=A/p,I=M/2,X=A/2,H=S/2,O=C+1,W=p+1;let k=0,J=0;const j=new N;for(let le=0;le<W;le++){const he=le*P-X;for(let _e=0;_e<O;_e++){const Ve=_e*w-I;j[y]=Ve*b,j[g]=he*R,j[h]=H,l.push(j.x,j.y,j.z),j[y]=0,j[g]=0,j[h]=S>0?1:-1,f.push(j.x,j.y,j.z),m.push(_e/C),m.push(1-le/p),k+=1}}for(let le=0;le<p;le++)for(let he=0;he<C;he++){const _e=u+he+O*le,Ve=u+he+O*(le+1),rt=u+(he+1)+O*(le+1),Xe=u+(he+1)+O*le;c.push(_e,Ve,Xe),c.push(Ve,rt,Xe),J+=6}o.addGroup(_,J,E),_+=J,u+=k}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Xi extends Vt{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:c};const l=this;r=Math.floor(r),s=Math.floor(s);const f=[],m=[],u=[],_=[];let v=0;const y=[],g=n/2;let h=0;b(),a===!1&&(e>0&&R(!0),t>0&&R(!1)),this.setIndex(f),this.setAttribute("position",new Mt(m,3)),this.setAttribute("normal",new Mt(u,3)),this.setAttribute("uv",new Mt(_,2));function b(){const M=new N,A=new N;let S=0;const C=(t-e)/n;for(let p=0;p<=s;p++){const E=[],w=p/s,P=w*(t-e)+e;for(let I=0;I<=r;I++){const X=I/r,H=X*c+o,O=Math.sin(H),W=Math.cos(H);A.x=P*O,A.y=-w*n+g,A.z=P*W,m.push(A.x,A.y,A.z),M.set(O,C,W).normalize(),u.push(M.x,M.y,M.z),_.push(X,1-w),E.push(v++)}y.push(E)}for(let p=0;p<r;p++)for(let E=0;E<s;E++){const w=y[E][p],P=y[E+1][p],I=y[E+1][p+1],X=y[E][p+1];(e>0||E!==0)&&(f.push(w,P,X),S+=3),(t>0||E!==s-1)&&(f.push(P,I,X),S+=3)}l.addGroup(h,S,0),h+=S}function R(M){const A=v,S=new Fe,C=new N;let p=0;const E=M===!0?e:t,w=M===!0?1:-1;for(let I=1;I<=r;I++)m.push(0,g*w,0),u.push(0,w,0),_.push(.5,.5),v++;const P=v;for(let I=0;I<=r;I++){const H=I/r*c+o,O=Math.cos(H),W=Math.sin(H);C.x=E*W,C.y=g*w,C.z=E*O,m.push(C.x,C.y,C.z),u.push(0,w,0),S.x=O*.5+.5,S.y=W*.5*w+.5,_.push(S.x,S.y),v++}for(let I=0;I<r;I++){const X=A+I,H=P+I;M===!0?f.push(H,H+1,X):f.push(H+1,H,X),p+=3}l.addGroup(h,p,M===!0?1:2),h+=p}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xi(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class qi extends Xi{constructor(e=1,t=1,n=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,s,a,o),this.type="C
5oneGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new qi(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class wa extends Vt{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const s=[],a=[];o(r),l(n),f(),this.setAttribute("position",new Mt(s,3)),this.setAttribute("normal",new Mt(s.slice(),3)),this.setAttribute("uv",new Mt(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(b){const R=new N,M=new N,A=new N;for(let S=0;S<t.length;S+=3)_(t[S+0],R),_(t[S+1],M),_(t[S+2],A),c(R,M,A,b)}function c(b,R,M,A){const S=A+1,C=[];for(let p=0;p<=S;p++){C[p]=[];const E=b.clone().lerp(M,p/S),w=R.clone().lerp(M,p/S),P=S-p;for(let I=0;I<=P;I++)I===0&&p===S?C[p][I]=E:C[p][I]=E.clone().lerp(w,I/P)}for(let p=0;p<S;p++)for(let E=0;E<2*(S-p)-1;E++){const w=Math.floor(E/2);E%2===0?(u(C[p][w+1]),u(C[p+1][w]),u(C[p][w])):(u(C[p][w+1]),u(C[p+1][w+1]),u(C[p+1][w])
vendor: 7,159 bytes, lines 5-9
5)}}function l(b){const R=new N;for(let M=0;M<s.length;M+=3)R.x=s[M+0],R.y=s[M+1],R.z=s[M+2],R.normalize().multiplyScalar(b),s[M+0]=R.x,s[M+1]=R.y,s[M+2]=R.z}function f(){const b=new N;for(let R=0;R<s.length;R+=3){b.x=s[R+0],b.y=s[R+1],b.z=s[R+2];const M=g(b)/2/Math.PI+.5,A=h(b)/Math.PI+.5;a.push(M,1-A)}v(),m()}function m(){for(let b=0;b<a.length;b+=6){const R=a[b+0],M=a[b+2],A=a[b+4],S=Math.max(R,M,A),C=Math.min(R,M,A);S>.9&&C<.1&&(R<.2&&(a[b+0]+=1),M<.2&&(a[b+2]+=1),A<.2&&(a[b+4]+=1))}}function u(b){s.push(b.x,b.y,b.z)}function _(b,R){const M=b*3;R.x=e[M+0],R.y=e[M+1],R.z=e[M+2]}function v(){const b=new N,R=new N,M=new N,A=new N,S=new Fe,C=new Fe,p=new Fe;for(let E=0,w=0;E<s.length;E+=9,w+=6){b.set(s[E+0],s[E+1],s[E+2]),R.set(s[E+3],s[E+4],s[E+5]),M.set(s[E+6],s[E+7],s[E+8]),S.set(a[w+0],a[w+1]),C.set(a[w+2],a[w+3]),p.set(a[w+4],a[w+5]),A.copy(b).add(R).add(M).divideScalar(3);const P=g(A);y(S,w+0,b,P),y(C,w+2,R,P),y(p,w+4,M,P)}}function y(b,R,M,A){A<0&&b.x===1&&(a[R]=b.x-1),M.x===0&&M.z===0&&(a[R]=A/2/Math.PI+.5)}function g(b){return Math.atan2(b.z,-b.x)}function h(b){return Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wa(e.vertices,e.indices,e.radius,e.detail)}}class Ra extends wa{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ra(e.radius,e.detail)}}class bi extends Vt{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),c=Math.floor(r),l=o+1,f=c+1,m=e/o,u=t/c,_=[],v=[],y=[],g=[];for(let h=0;h<f;h++){const b=h*u-a;for(let R=0;R<l;R++){const M=R*m-s;v.push(M,-b,0),y.push(0,0,1),g.push(R/o),g.push(1-h/c)}}for(let h=0;h<c;h++)for(let b=0;b<o;b++){const R=b+l*h,M=b+l*(h+1),A=b+1+l*(h+1),S=b+1+l*h;_.push(R,M,S),_.push(M,A,S)}this.setIndex(_),this.setAttribute("position",new Mt(v,3)),this.setAttribute("normal",new Mt(y,3)),this.setAttribute("uv",new Mt(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bi(e.width,e.height,e.widthSegments,e.heightSegments)}}class Ca extends Vt{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2,a=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s,thetaStart:a,thetaLength:o},n=Math.floor(n),r=Math.floor(r);const c=[],l=[],f=[],m=[],u=new N,_=new N,v=new N;for(let y=0;y<=n;y++){const g=a+y/n*o;for(let h=0;h<=r;h++){const b=h/r*s;_.x=(e+t*Math.cos(g))*Math.cos(b),_.y=(e+t*Math.cos(g))*Math.sin(b),_.z=t*Math.sin(g),l.push(_.x,_.y,_.z),u.x=e*Math.cos(b),u.y=e*Math.sin(b),v.subVectors(_,u).normalize(),f.push(v.x,v.y,v.z),m.push(h/r),m.push(y/n)}}for(let y=1;y<=n;y++)for(let g=1;g<=r;g++){const h=(r+1)*y+g-1,b=(r+1)*(y-1)+g-1,R=(r+1)*(y-1)+g,M=(r+1)*y+g;c.push(h,b,M),c.push(b,R,M)}this.setIndex(c),this.setAttribute("position",new Mt(l,3)),this.setAttribute("normal",new Mt(f,3)),this.setAttribute("uv",new Mt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ca(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}function Si(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];if(Eo(r))r.isRenderTargetTexture?(we("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone();else if(Array.isArray(r))if(Eo(r[0])){const s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();e[t][n]=s}else e[t][n]=r.slice();else e[t][n]=r}}return e}function Ct(i){const e={};for(let t=0;t<i.length;t++){const n=Si(i[t]);for(const r in n)e[r]=n[r]}return e}function Eo(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Tu(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Dl(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ze.workingColorSpace}const Ll={clone:Si,merge:Ct};var bu=`void main() { 6 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 7}`,Au=`void main() { 8 gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); 9}`;class Zt extends Wi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=bu,this.fragmentShader=Au,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Si(e.uniforms),this.uniformsGroups=Tu(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case"t":this.uniforms[n].value=t[r.value]||null;break;case"c":this.uniforms[n].value=new Ge().setHex(r.value);break;case"v2":this.uniforms[n].value=new Fe().fromArray(r.value);break;case"v3":this.uniforms[n].value=new N().fromArray(r.value);break;case"v4":this.uniforms[n].value=new it().fromArray(r.value);break;case"m3":this.uniforms[n].value=new Ce().fromArray(r.value);break;
9case"m4":this.uniforms[n].value=new tt().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class wu extends Zt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class _n extends Wi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ge(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ge(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ca,this.normalScale=new Fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ln,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ru extends Wi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Cu extends Wi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Il extends vt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ge(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Pu extends Il{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(vt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const hs=new tt,yo=new N,To=new N;class Du{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Fe(512,512),this.mapType=Ft,this.map=null,this.mapPass=null,this.matrix=new tt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Aa,this._frameExtents=new Fe(1,1),this._viewportCount=1,this._viewports=[new it(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;yo.setFromMatrixPosition(e.matrixWorld),t.position.copy(yo),To.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(To),t.updateMatrixWorld(),hs.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hs,t.co
9ordinateSystem,t.reversedDepth),t.coordinateSystem===Vi||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(hs)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const pr=new N,mr=new Ti,jt=new N;class Ul extends vt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new tt,this.projectionMatrix=new tt,this.projectionMatrixInverse=new tt,this.coordinateSystem=rn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(pr,mr,jt),jt.x===1&&jt.y===1&&jt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pr,mr,jt.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(pr,mr,jt),jt.x===1&&jt.y===1&&jt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pr,mr,jt.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Rn=new N,bo=new Fe,Ao=new Fe;class Gt extends Ul{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Hi*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Oi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Hi*2*Math.atan(Math.tan(Oi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Rn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Rn.x,Rn.y).multiplyScalar(-e/Rn.z),Rn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Rn.x,Rn.y).multiplyScalar(-e/Rn.z)}getViewSize(e,t){return this.getViewBounds(e,bo,Ao),t.subVectors(Ao,bo)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Oi*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*r/c,t-=a.offsetY*n/l,r*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Pa extends Ul{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="Orthogra
9phicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,c=r-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=f*this.view.offsetY,c=o-f*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Lu extends Du{constructor(){super(new Pa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Iu extends Il{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(vt.DEFAULT_UP),this.updateMatrix(),this.target=new vt,this.shadow=new Lu}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}const hi=-90,fi=1;class Uu extends vt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Gt(hi,fi,e,t);r.layers=this.layers,this.add(r);const s=new Gt(hi,fi,e,t);s.layers=this.layers,this.add(s);const a=new Gt(hi,fi,e,t);a.layers=this.layers,this.add(a);const o=new Gt(hi,fi,e,t);o.layers=this.layers,this.add(o);const c=new Gt(hi,fi,e,t);c.layers=this.layers,this.add(c);const l=new Gt(hi,fi,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,c]=t;for(const l of t)this.remove(l);if(e===rn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Vi)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,f]=this.children,m=e.getRenderTarget(),u=e.getActiveCubeFace(),_=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(n,0,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,1,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,f),e.setRenderTarget(m,u,_),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class Nu extends Gt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Fa=class Fa{constructor(e,t,n,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}};Fa.prototype.isMatrix2=!0;let wo=Fa;function Ro(i,e,t,n){const r=Fu(n);switch(t){case vl:return i*e;case _a:return i*e/r.components*r.byteLength;case xa:return i*e/r.components*r.byteLength;case Kn:return i*e*2/r.components*r.byteLength;case va:return i*e*2/r.components*r.byteLength;case Ml:return i*e*3/r.components*r.byteLength;case Yt:return i*e*4/r.components*r.byteLength;case Ma:return i*e*4/r.components*r.byteLength;case vr:case Mr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Sr:case Er:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Us:case Fs:return Math.max(i,16)*Math.max(e,8)/4;case Is:case Ns:return Math.max(i,8)*Math.max(e,8)/2;case Os:case Bs:case Gs:case Vs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case zs:case br:case Hs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ks:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ws:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Xs:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case qs:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ys:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Ks:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Zs:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case $s:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Js:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Qs:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case js:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case ea:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case ta:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case na:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case ia:case ra:case sa:return Math.ceil(i/4)*Math.ceil(e/4)*16;case aa:case oa:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Ar:case la:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Fu(i){switch(i){case Ft:case ml:return{byteLength:1,components:1};case zi:case gl:case xn:return{byteLength:2,components:1};case ma:case ga:return{byteLength:2,components:4};case ln:case pa:case qt:return{byteLength:4,components:1};case _l:case xl:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:fa}}));typeof window<"u"&&(window.__THREE__?we("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=fa);/** 10 * @license 11 * Copyright 2010-2026 Three.js Authors 12 * SPDX-License-Identifier: MIT 13 */function Nl(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function Ou(i){const e=new WeakMap;function t(o,c){const l=o.array,f=o.usage,m=l.byteLength,u=i.createBuffer();i.bindBuffer(c,u),i.bufferData(c,l,f),o.onUploadCallback();let _;if(l instanceof Float32Array)_=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)_=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?_=i.HALF_FLOAT:_=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)_=i.SHORT;else if(l instanceof Uint32Array)_=i.UNSIGNED_INT;else if(l instanceof Int32Array)_=i.INT;else if(l instanceof Int8Array)_=i.BYTE;else if(l instanceof Uint8Array)_=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)_=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:u,type:_,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:m}}function n(o,c,l){const f=c.array,m=c.updateRanges;if(i.bindBuffer(l,o),m.length===0)i.bufferSubData(l,0,f);else{m.sort((_,v)=>_.start-v.start);let u=0;for(let _=1;_<m.length;_++){const v=m[u],y=m[_];y.start<=v.start+v.count+1?v.count=Math.max(v.count,y.start+y.count-v.start):(++u,m[u]=y)}m.length=u+1;for(let _=0,v=m.length;_<v;_++){const y=m[_];i.bufferSubData(l,y.start*f.BYTES_PER_ELEMENT,f,y.start,y.count)}
vendor: 4,945 bytes, lines 13-126
13c.clearUpdateRanges()}c.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const f=e.get(o);(!f||f.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}var Bu=`#ifdef USE_ALPHAHASH 14 if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; 15#endif`,zu=`#ifdef USE_ALPHAHASH 16 const float ALPHA_HASH_SCALE = 0.05; 17 float hash2D( vec2 value ) { 18 return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) ); 19 } 20 float hash3D( vec3 value ) { 21 return hash2D( vec2( hash2D( value.xy ), value.z ) ); 22 } 23 float getAlphaHashThreshold( vec3 position ) { 24 float maxDeriv = max( 25 length( dFdx( position.xyz ) ), 26 length( dFdy( position.xyz ) ) 27 ); 28 float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv ); 29 vec2 pixScales = vec2( 30 exp2( floor( log2( pixScale ) ) ), 31 exp2( ceil( log2( pixScale ) ) ) 32 ); 33 vec2 alpha = vec2( 34 hash3D( floor( pixScales.x * position.xyz ) ), 35 hash3D( floor( pixScales.y * position.xyz ) ) 36 ); 37 float lerpFactor = fract( log2( pixScale ) ); 38 float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y; 39 float a = min( lerpFactor, 1.0 - lerpFactor ); 40 vec3 cases = vec3( 41 x * x / ( 2.0 * a * ( 1.0 - a ) ), 42 ( x - 0.5 * a ) / ( 1.0 - a ), 43 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) ) 44 ); 45 float threshold = ( x < ( 1.0 - a ) ) 46 ? ( ( x < a ) ? cases.x : cases.y ) 47 : cases.z; 48 return clamp( threshold , 1.0e-6, 1.0 ); 49 } 50#endif`,Gu=`#ifdef USE_ALPHAMAP 51 diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; 52#endif`,Vu=`#ifdef USE_ALPHAMAP 53 uniform sampler2D alphaMap; 54#endif`,Hu=`#ifdef USE_ALPHATEST 55 #ifdef ALPHA_TO_COVERAGE 56 diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); 57 if ( diffuseColor.a == 0.0 ) discard; 58 #else 59 if ( diffuseColor.a < alphaTest ) discard; 60 #endif 61#endif`,ku=`#ifdef USE_ALPHATEST 62 uniform float alphaTest; 63#endif`,Wu=`#ifdef USE_AOMAP 64 float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; 65 reflectedLight.indirectDiffuse *= ambientOcclusion; 66 #if defined( USE_CLEARCOAT ) 67 clearcoatSpecularIndirect *= ambientOcclusion; 68 #endif 69 #if defined( USE_SHEEN ) 70 sheenSpecularIndirect *= ambientOcclusion; 71 #endif 72 #if defined( USE_ENVMAP ) && defined( STANDARD ) 73 float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); 74 reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); 75 #endif 76#endif`,Xu=`#ifdef USE_AOMAP 77 uniform sampler2D aoMap; 78 uniform float aoMapIntensity; 79#endif`,qu=`#ifdef USE_BATCHING 80 #if ! defined( GL_ANGLE_multi_draw ) 81 #define gl_DrawID _gl_DrawID 82 uniform int _gl_DrawID; 83 #endif 84 uniform highp sampler2D batchingTexture; 85 uniform highp usampler2D batchingIdTexture; 86 mat4 getBatchingMatrix( const in float i ) { 87 int size = textureSize( batchingTexture, 0 ).x; 88 int j = int( i ) * 4; 89 int x = j % size; 90 int y = j / size; 91 vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 ); 92 vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 ); 93 vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 ); 94 vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 ); 95 return mat4( v1, v2, v3, v4 ); 96 } 97 float getIndirectIndex( const in int i ) { 98 int size = textureSize( batchingIdTexture, 0 ).x; 99 int x = i % size; 100 int y = i / size; 101 return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r ); 102 } 103#endif 104#ifdef USE_BATCHING_COLOR 105 uniform sampler2D batchingColorTexture; 106 vec4 getBatchingColor( const in float i ) { 107 int size = textureSize( batchingColorTexture, 0 ).x; 108 int j = int( i ); 109 int x = j % size; 110 int y = j / size; 111 return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ); 112 } 113#endif`,Yu=`#ifdef USE_BATCHING 114 mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); 115#endif`,Ku=`vec3 transformed = vec3( position ); 116#ifdef USE_ALPHAHASH 117 vPosition = vec3( position ); 118#endif`,Zu=`vec3 objectNormal = vec3( normal ); 119#ifdef USE_TANGENT 120 vec3 objectTangent = vec3( tangent.xyz ); 121#endif`,$u=`float G_BlinnPhong_Implicit( ) { 122 return 0.25; 123} 124float D_BlinnPhong( const in float shininess, const in float dotNH ) { 125 return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); 126}
127vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { 128 vec3 halfDir = normalize( lightDir + viewDir ); 129 float dotNH = saturate( dot( normal, halfDir ) ); 130 float dotVH = saturate( dot( viewDir, halfDir ) ); 131 vec3 F = F_Schlick( specularColor, 1.0, dotVH ); 132 float G = G_BlinnPhong_Implicit( ); 133 float D = D_BlinnPhong( shininess, dotNH ); 134 return F * ( G * D ); 135} // validated`,Ju=`#ifdef USE_IRIDESCENCE 136 const mat3 XYZ_TO_REC709 = mat3( 137 3.2404542, -0.9692660, 0.0556434, 138 -1.5371385, 1.8760108, -0.2040259, 139 -0.4985314, 0.0415560, 1.0572252 140 ); 141 vec3 Fresnel0ToIor( vec3 fresnel0 ) { 142 vec3 sqrtF0 = sqrt( fresnel0 ); 143 return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); 144 } 145 vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { 146 return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); 147 } 148 float IorToFresnel0( float transmittedIor, float incidentIor ) { 149 return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); 150 } 151 vec3 evalSensitivity( float OPD, vec3 shift ) { 152 float phase = 2.0 * PI * OPD * 1.0e-9; 153 vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); 154 vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); 155 vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); 156 vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); 157 xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); 158 xyz /= 1.0685e-7; 159 vec3 rgb = XYZ_TO_REC709 * xyz; 160 return rgb; 161 } 162 vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { 163 vec3 I; 164 float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); 165 float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); 166 float cosTheta2Sq = 1.0 - sinTheta2Sq; 167 if ( cosTheta2Sq < 0.0 ) { 168 return vec3( 1.0 ); 169 } 170 float cosTheta2 = sqrt( cosTheta2Sq ); 171 float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); 172 float R12 = F_Schlick( R0, 1.0, cosTheta1 );
173 float T121 = 1.0 - R12; 174 float phi12 = 0.0; 175 if ( iridescenceIOR < outsideIOR ) phi12 = PI; 176 float phi21 = PI - phi12; 177 vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); 178 vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); 179 vec3 phi23 = vec3( 0.0 ); 180 if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; 181 if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; 182 if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; 183 float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; 184 vec3 phi = vec3( phi21 ) + phi23; 185 vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); 186 vec3 r123 = sqrt( R123 ); 187 vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); 188 vec3 C0 = R12 + Rs; 189 I = C0; 190 vec3 Cm = Rs - T121; 191 for ( int m = 1; m <= 2; ++ m ) { 192 Cm *= r123; 193 vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); 194 I += Cm * Sm; 195 } 196 return max( I, vec3( 0.0 ) ); 197 } 198#endif`,Qu=`#ifdef USE_BUMPMAP 199 uniform sampler2D bumpMap; 200 uniform float bumpScale; 201 vec2 dHdxy_fwd() { 202 vec2 dSTdx = dFdx( vBumpMapUv ); 203 vec2 dSTdy = dFdy( vBumpMapUv ); 204 float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; 205 float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; 206 float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; 207 return vec2( dBx, dBy ); 208 } 209 vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { 210 vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) ); 211 vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) ); 212 vec3 vN = surf_norm; 213 vec3 R1 = cross( vSigmaY, vN ); 214 vec3 R2 = cross( vN, vSigmaX ); 215 float fDet = dot( vSigmaX, R1 ) * faceDirection; 216 vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); 217 return normalize( abs( fDet ) * surf_norm - vGrad ); 218 } 219#endif`,ju=`#if NUM_CLIPPING_PLANES > 0 220 vec4 plane; 221 #ifdef ALPHA_TO_COVERAGE 222 float distanceToPlane, distanceGradient; 223 float clipOpacity = 1.0; 224 #pragma unroll_loop_start 225 for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 226 plane = clippingPlanes[ i ]; 227 distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; 228 distanceGradient = fwidth( distanceToPlane ) / 2.0; 229 clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); 230 if ( clipOpacity == 0.0 ) discard; 231 } 232 #pragma unroll_loop_end 233 #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 234 float unionClipOpacity = 1.0; 235 #pragma unroll_loop_start 236 for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 237 plane = clippingPlanes[ i ]; 238 distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; 239 distanceGradient = fwidth( distanceToPlane ) / 2.0; 240 unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); 241 } 242 #pragma unroll_loop_end 243 clipOpacity *= 1.0 - unionClipOpacity; 244 #endif 245 diffuseColor.a *= clipOpacity; 246 if ( diffuseColor.a == 0.0 ) discard; 247 #else 248 #pragma unroll_loop_start 249 for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 250 plane = clippingPlanes[ i ]; 251 if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; 252 } 253 #pragma unroll_loop_end 254 #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 255 bool clipped = true; 256 #pragma unroll_loop_start 257 for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 258 plane = clippingPlanes[ i ]; 259 clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; 260 } 261 #pragma unroll_loop_end 262 if ( clipped ) discard; 263 #endif 264 #endif 265#endif`,eh=`#if NUM_CLIPPING_PLANES > 0 266 varying vec3 vClipPosition; 267 uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; 268#endif`,th=`#if NUM_CLIPPING_PLANES > 0 269 varying vec3 vClipPosition; 270#endif`,nh=`#if NUM_CLIPPING_PLANES > 0 271 vClipPosition = - mvPosition.xyz; 272#endif`,ih=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) 273 diffuseColor *= vColor; 274#endif`,rh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) 275 varying vec4 vColor; 276#endif`,sh=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) 277 varying vec4 vColor; 278#endif`,ah=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) 279 vColor = vec4( 1.0 ); 280#endif 281#ifdef USE_COLOR_ALPHA 282 vColor *= color; 283#elif defined( USE_COLOR ) 284 vColor.rgb *= color; 285#endif 286#ifdef USE_INSTANCING_COLOR 287 vColor.rgb *= instanceColor.rgb; 288#endif 289#ifdef USE_BATCHING_COLOR 290 vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); 291#endif`,oh=`#define PI 3.141592653589793 292#define PI2 6.283185307179586 293#define PI_HALF 1.5707963267948966 294#define RECIPROCAL_PI 0.3183098861837907 295#define RECIPROCAL_PI2 0.15915494309189535 296#define EPSILON 1e-6 297#ifndef saturate 298#define saturate( a ) clamp( a, 0.0, 1.0 ) 299#endif 300#define whiteComplement( a ) ( 1.0 - saturate( a ) ) 301float pow2( const in float x ) { return x*x; } 302vec3 pow2( const in vec3 x ) { return x*x; } 303float pow3( const in float x ) { return x*x*x; } 304float pow4( const in float x ) { float x2 = x*x; return x2*x2; } 305float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } 306float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } 307highp float rand( const in vec2 uv ) { 308 const highp float a = 12.9898, b = 78.233, c = 43758.5453; 309 highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); 310 return fract( sin( sn ) * c ); 311} 312#ifdef HIGH_PRECISION 313 float precisionSafeLength( vec3 v ) { return length( v ); } 314#else 315 float precisionSafeLength( vec3 v ) { 316 float maxComponent = max3( abs( v ) ); 317 return length( v / maxComponent ) * maxComponent; 318 } 319#endif 320struct IncidentLight { 321 vec3 color; 322 vec3 direction; 323 bool visible; 324}; 325struct ReflectedLight { 326 vec3 directDiffuse; 327 vec3 directSpecular; 328 vec3 indirectDiffuse; 329 vec3 indirectSpecular; 330}; 331#ifdef USE_ALPHAHASH 332 varying vec3 vPosition; 333#endif 334vec3 transformDirection( in vec3 dir, in mat4 matrix ) { 335 return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); 336} 337#define inverseTransformDirection transformDirectionByInverseViewMatrix 338vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { 339 return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); 340} 341vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { 342 return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); 343} 344bool isPerspectiveMatrix( mat4 m ) { 345 return m[ 2 ][ 3 ] == - 1.0; 346} 347vec2 equirectUv( in vec3 dir ) { 348 float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; 349 float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; 350 return vec2( u, v ); 351}
352vec3 BRDF_Lambert( const in vec3 diffuseColor ) { 353 return RECIPROCAL_PI * diffuseColor; 354} 355vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { 356 float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); 357 return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); 358} 359float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { 360 float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); 361 return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); 362} // validated`,lh=`#ifdef ENVMAP_TYPE_CUBE_UV 363 #define cubeUV_minMipLevel 4.0 364 #define cubeUV_minTileSize 16.0 365 float getFace( vec3 direction ) { 366 vec3 absDirection = abs( direction ); 367 float face = - 1.0; 368 if ( absDirection.x > absDirection.z ) { 369 if ( absDirection.x > absDirection.y ) 370 face = direction.x > 0.0 ? 0.0 : 3.0; 371 else 372 face = direction.y > 0.0 ? 1.0 : 4.0; 373 } else { 374 if ( absDirection.z > absDirection.y ) 375 face = direction.z > 0.0 ? 2.0 : 5.0; 376 else 377 face = direction.y > 0.0 ? 1.0 : 4.0; 378 } 379 return face; 380 } 381 vec2 getUV( vec3 direction, float face ) { 382 vec2 uv; 383 if ( face == 0.0 ) { 384 uv = vec2( direction.z, direction.y ) / abs( direction.x ); 385 } else if ( face == 1.0 ) { 386 uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); 387 } else if ( face == 2.0 ) { 388 uv = vec2( - direction.x, direction.y ) / abs( direction.z ); 389 } else if ( face == 3.0 ) { 390 uv = vec2( - direction.z, direction.y ) / abs( direction.x ); 391 } else if ( face == 4.0 ) { 392 uv = vec2( - direction.x, direction.z ) / abs( direction.y ); 393 } else { 394 uv = vec2( direction.x, direction.y ) / abs( direction.z ); 395 } 396 return 0.5 * ( uv + 1.0 ); 397 } 398 vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { 399 float face = getFace( direction ); 400 float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); 401 mipInt = max( mipInt, cubeUV_minMipLevel ); 402 float faceSize = exp2( mipInt ); 403 highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; 404 if ( face > 2.0 ) { 405 uv.y += faceSize; 406 face -= 3.0; 407 } 408 uv.x += face * faceSize; 409 uv.x += filterInt * 3.0 * cubeUV_minTileSize; 410 uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); 411 uv.x *= CUBEUV_TEXEL_WIDTH; 412 uv.y *= CUBEUV_TEXEL_HEIGHT; 413 #ifdef texture2DGradEXT 414 return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; 415 #else 416 return texture2D( envMap, uv ).rgb; 417 #endif 418 } 419 #define cubeUV_r0 1.0 420 #define cubeUV_m0 - 2.0 421 #define cubeUV_r1 0.8 422 #define cubeUV_m1 - 1.0 423 #define cubeUV_r4 0.4 424 #define cubeUV_m4 2.0 425 #define cubeUV_r5 0.305 426 #define cubeUV_m5 3.0 427 #define cubeUV_r6 0.21 428 #define cubeUV_m6 4.0 429 float roughnessToMip( float roughness ) { 430 float mip = 0.0; 431 if ( roughness >= cubeUV_r1 ) { 432 mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; 433 } else if ( roughness >= cubeUV_r4 ) { 434 mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; 435 } else if ( roughness >= cubeUV_r5 ) { 436 mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; 437 } else if ( roughness >= cubeUV_r6 ) { 438 mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; 439 } else { 440 mip = - 2.0 * log2( 1.16 * roughness ); } 441 return mip; 442 } 443 vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { 444 float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); 445 float mipF = fract( mip ); 446 float mipInt = floor( mip ); 447 vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); 448 if ( mipF == 0.0 ) { 449 return vec4( color0, 1.0 ); 450 } else { 451 vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); 452 return vec4( mix( color0, color1, mipF ), 1.0 ); 453 } 454 } 455#endif`,ch=`vec3 transformedNormal = objectNormal; 456#ifdef USE_TANGENT 457 vec3 transformedTangent = objectTangent; 458#endif 459#ifdef USE_BATCHING 460 mat3 bm = mat3( batchingMatrix ); 461 transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); 462 transformedNormal = bm * transformedNormal; 463 #ifdef USE_TANGENT 464 transformedTangent = bm * transformedTangent; 465 #endif 466#endif 467#ifdef USE_INSTANCING 468 mat3 im = mat3( instanceMatrix ); 469 transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); 470 transformedNormal = im * transformedNormal; 471 #ifdef USE_TANGENT 472 transformedTangent = im * transformedTangent; 473 #endif 474#endif 475transformedNormal = normalMatrix * transformedNormal; 476#ifdef FLIP_SIDED 477 transformedNormal = - transformedNormal; 478#endif 479#ifdef USE_TANGENT 480 transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; 481#endif`,uh=`#ifdef USE_DISPLACEMENTMAP 482 uniform sampler2D displacementMap; 483 uniform float displacementScale; 484 uniform float displacementBias; 485#endif`,hh=`#ifdef USE_DISPLACEMENTMAP 486 transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + dis
486placementBias ); 487#endif`,fh=`#ifdef USE_EMISSIVEMAP 488 vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); 489 #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE 490 emissiveColor = sRGBTransferEOTF( emissiveColor ); 491 #endif 492 totalEmissiveRadiance *= emissiveColor.rgb; 493#endif`,dh=`#ifdef USE_EMISSIVEMAP 494 uniform sampler2D emissiveMap; 495#endif`,ph="gl_FragColor = linearToOutputTexel( gl_FragColor );",mh=`vec4 LinearTransferOETF( in vec4 value ) { 496 return value; 497} 498vec4 sRGBTransferEOTF( in vec4 value ) { 499 return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); 500} 501vec4 sRGBTransferOETF( in vec4 value ) { 502 return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); 503}`,gh=`#ifdef USE_ENVMAP 504 #ifdef ENV_WORLDPOS 505 vec3 cameraToFrag; 506 if ( isOrthographic ) { 507 cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 508 } else { 509 cameraToFrag = normalize( vWorldPosition - cameraPosition ); 510 } 511 vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); 512 #ifdef ENVMAP_MODE_REFLECTION 513 vec3 reflectVec = reflect( cameraToFrag, worldNormal ); 514 #else 515 vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); 516 #endif 517 #else 518 vec3 reflectVec = vReflect; 519 #endif 520 #ifdef ENVMAP_TYPE_CUBE 521 vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); 522 #ifdef ENVMAP_BLENDING_MULTIPLY 523 outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); 524 #elif defined( ENVMAP_BLENDING_MIX ) 525 outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); 526 #elif defined( ENVMAP_BLENDING_ADD ) 527 outgoingLight += envColor.xyz * specularStrength * reflectivity; 528 #endif 529 #endif 530#endif`,_h=`#ifdef USE_ENVMAP 531 uniform float envMapIntensity; 532 uniform mat3 envMapRotation; 533 #ifdef ENVMAP_TYPE_CUBE 534 uniform samplerCube envMap; 535 #else 536 uniform sampler2D envMap; 537 #endif 538#endif`,xh=`#ifdef USE_ENVMAP 539 uniform float reflectivity; 540 #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 541 #define ENV_WORLDPOS 542 #endif 543 #ifdef ENV_WORLDPOS 544 varying vec3 vWorldPosition; 545 uniform float refractionRatio; 546 #else 547 varying vec3 vReflect; 548 #endif 549#endif`,vh=`#ifdef USE_ENVMAP 550 #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 551 #define ENV_WORLDPOS 552 #endif 553 #ifdef ENV_WORLDPOS 554 555 varying vec3 vWorldPosition; 556 #else 557 varying vec3 vReflect; 558 uniform float refractionRatio; 559 #endif 560#endif`,Mh=`#ifdef USE_ENVMAP 561 #ifdef ENV_WORLDPOS 562 vWorldPosition = worldPosition.xyz; 563 #else 564 vec3 cameraToVertex; 565 if ( isOrthographic ) { 566 cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 567 } else {
568 cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); 569 } 570 vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); 571 #ifdef ENVMAP_MODE_REFLECTION 572 vReflect = reflect( cameraToVertex, worldNormal ); 573 #else 574 vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); 575 #endif 576 #endif 577#endif`,Sh=`#ifdef USE_FOG 578 vFogDepth = - mvPosition.z; 579#endif`,Eh=`#ifdef USE_FOG 580 varying float vFogDepth; 581#endif`,yh=`#ifdef USE_FOG 582 #ifdef FOG_EXP2 583 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); 584 #else 585 float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); 586 #endif 587 gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); 588#endif`,Th=`#ifdef USE_FOG 589 uniform vec3 fogColor; 590 varying float vFogDepth; 591 #ifdef FOG_EXP2 592 uniform float fogDensity; 593 #else 594 uniform float fogNear; 595 uniform float fogFar; 596 #endif 597#endif`,bh=`#ifdef USE_GRADIENTMAP 598 uniform sampler2D gradientMap; 599#endif 600vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { 601 float dotNL = dot( normal, lightDirection ); 602 vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); 603 #ifdef USE_GRADIENTMAP 604 return vec3( texture2D( gradientMap, coord ).r ); 605 #else 606 vec2 fw = fwidth( coord ) * 0.5; 607 return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); 608 #endif 609}`,Ah=`#ifdef USE_LIGHTMAP 610 uniform sampler2D lightMap; 611 uniform float lightMapIntensity; 612#endif`,wh=`LambertMaterial material; 613material.diffuseColor = diffuseColor.rgb; 614material.specularStrength = specularStrength;`,Rh=`varying vec3 vViewPosition; 615struct LambertMaterial { 616 vec3 diffuseColor; 617 float specularStrength; 618}; 619void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { 620 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 621 vec3 irradiance = dotNL * directLight.color; 622 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 623} 624void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { 625 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 626} 627#define RE_Direct RE_Direct_Lambert 628#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Ch=`uniform bool receiveShadow; 629uniform vec3 ambientLightColor; 630#if defined( USE_LIGHT_PROBES ) 631 uniform vec3 lightProbe[ 9 ]; 632#endif 633vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { 634 float x = normal.x, y = normal.y, z = normal.z; 635 vec3 result = shCoefficients[ 0 ] * 0.886227; 636 result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; 637 result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; 638 result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; 639 result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; 640 result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; 641 result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); 642 result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; 643 result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); 644 return result; 645} 646vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { 647 vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); 648 vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); 649 return irradiance; 650} 651vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { 652 vec3 irradiance = ambientLightColor; 653 return irradiance; 654} 655float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { 656 float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); 657 if ( cutoffDistance > 0.0 ) { 658 distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); 659 } 660 return distanceFalloff; 661} 662float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { 663 return smoothstep( coneCosine, penumbraCosine, angleCosine ); 664} 665#if NUM_DIR_LIGHTS > 0 666 struct DirectionalLight { 667 vec3 direction; 668 vec3 color; 669 }; 670 uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; 671 void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { 672 light.color = directionalLight.color; 673 light.direction = directionalLight.direction; 674 light.visible = true; 675 } 676#endif 677#if NUM_POINT_LIGHTS > 0 678 struct PointLight { 679 vec3 position; 680 vec3 color; 681 float distance; 682 float decay; 683 }; 684 uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; 685 void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { 686 vec3 lVector = pointLight.position - geometryPosition; 687 light.direction = normalize( lVector ); 688 float lightDistance = length( lVector ); 689 light.color = pointLight.color; 690 light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); 691 light.visible = ( light.color != vec3( 0.0 ) ); 692 } 693#endif
694#if NUM_SPOT_LIGHTS > 0 695 struct SpotLight { 696 vec3 position; 697 vec3 direction; 698 vec3 color; 699 float distance; 700 float decay; 701 float coneCos; 702 float penumbraCos; 703 }; 704 uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; 705 void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { 706 vec3 lVector = spotLight.position - geometryPosition; 707 light.direction = normalize( lVector ); 708 float angleCos = dot( light.direction, spotLight.direction ); 709 float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); 710 if ( spotAttenuation > 0.0 ) { 711 float lightDistance = length( lVector ); 712 light.color = spotLight.color * spotAttenuation; 713 light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); 714 light.visible = ( light.color != vec3( 0.0 ) ); 715 } else { 716 light.color = vec3( 0.0 ); 717 light.visible = false; 718 } 719 } 720#endif 721#if NUM_RECT_AREA_LIGHTS > 0 722 struct RectAreaLight { 723 vec3 color; 724 vec3 position; 725 vec3 halfWidth; 726 vec3 halfHeight; 727 }; 728 uniform sampler2D ltc_1; uniform sampler2D ltc_2; 729 uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; 730#endif 731#if NUM_HEMI_LIGHTS > 0 732 struct HemisphereLight { 733 vec3 direction; 734 vec3 skyColor; 735 vec3 groundColor; 736 }; 737 uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; 738 vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { 739 float dotNL = dot( normal, hemiLight.direction ); 740 float hemiDiffuseWeight = 0.5 * dotNL + 0.5; 741 vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); 742 return irradiance; 743 } 744#endif 745#include <lightprobes_pars_fragment>`,Ph=`#ifdef USE_ENVMAP 746 vec3 getIBLIrradiance( const in vec3 normal ) { 747 #ifdef ENVMAP_TYPE_CUBE_UV 748 vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); 749 vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); 750 return PI * envMapColor.rgb * envMapIntensity; 751 #else 752 return vec3( 0.0 ); 753 #endif 754 } 755 vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { 756 #ifdef ENVMAP_TYPE_CUBE_UV 757 vec3 reflectVec = reflect( - viewDir, normal ); 758 reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); 759 reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); 760 vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); 761 return envMapColor.rgb * envMapIntensity; 762 #else 763 return vec3( 0.0 ); 764 #endif 765 } 766 #ifdef USE_ANISOTROPY 767 vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { 768 #ifdef ENVMAP_TYPE_CUBE_UV 769 vec3 bentNormal = cross( bitangent, viewDir ); 770 bentNormal = normalize( cross( bentNormal, bitangent ) ); 771 bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); 772 return getIBLRadiance( viewDir, bentNormal, roughness ); 773 #else 774 return vec3( 0.0 ); 775 #endif 776 } 777 #endif 778#endif`,Dh=`ToonMaterial material; 779material.diffuseColor = diffuseColor.rgb;`,Lh=`varying vec3 vViewPosition; 780struct ToonMaterial { 781 vec3 diffuseColor; 782}; 783void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { 784 vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; 785 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 786} 787void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { 788 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 789} 790#define RE_Direct RE_Direct_Toon 791#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ih=`BlinnPhongMaterial material; 792material.diffuseColor = diffuseColor.rgb; 793material.specularColor = specular; 794material.specularShininess = shininess; 795material.specularStrength = specularStrength;`,Uh=`varying vec3 vViewPosition; 796struct BlinnPhongMaterial { 797 vec3 diffuseColor; 798 vec3 specularColor; 799 float specularShininess; 800 float specularStrength; 801}; 802void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
803 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 804 vec3 irradiance = dotNL * directLight.color; 805 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 806 reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; 807} 808void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { 809 reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 810} 811#define RE_Direct RE_Direct_BlinnPhong 812#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Nh=`PhysicalMaterial material; 813material.diffuseColor = diffuseColor.rgb; 814material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); 815material.metalness = metalnessFactor; 816vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); 817float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); 818material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; 819material.roughness = min( material.roughness, 1.0 ); 820#ifdef IOR 821 material.ior = ior; 822 #ifdef USE_SPECULAR 823 float specularIntensityFactor = specularIntensity; 824 vec3 specularColorFactor = specularColor; 825 #ifdef USE_SPECULAR_COLORMAP 826 specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; 827 #endif 828 #ifdef USE_SPECULAR_INTENSITYMAP 829 specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; 830 #endif 831 material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); 832 #else 833 float specularIntensityFactor = 1.0; 834 vec3 specularColorFactor = vec3( 1.0 ); 835 material.specularF90 = 1.0; 836 #endif 837 material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; 838 material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); 839#else 840 material.specularColor = vec3( 0.04 ); 841 material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); 842 material.specularF90 = 1.0; 843#endif 844#ifdef USE_CLEARCOAT 845 material.clearcoat = clearcoat; 846 material.clearcoatRoughness = clearcoatRoughness; 847 material.clearcoatF0 = vec3( 0.04 ); 848 material.clearcoatF90 = 1.0; 849 #ifdef USE_CLEARCOATMAP 850 material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; 851 #endif 852 #ifdef USE_CLEARCOAT_ROUGHNESSMAP 853 material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; 854 #endif 855 material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); 856 material.clearcoatRoughness += geometryRoughness; 857 material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); 858#endif 859#ifdef USE_DISPERSION 860 material.dispersion = dispersion; 861#endif 862#ifdef USE_IRIDESCENCE 863 material.iridescence = iridescence; 864 material.iridescenceIOR = iridescenceIOR; 865 #ifdef USE_IRIDESCENCEMAP 866 material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; 867 #endif 868 #ifdef USE_IRIDESCENCE_THICKNESSMAP 869 material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; 870 #else 871 material.iridescenceThickness = iridescenceThicknessMaximum; 872 #endif 873#endif 874#ifdef USE_SHEEN 875 material.sheenColor = sheenColor; 876 #ifdef USE_SHEEN_COLORMAP 877 material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; 878 #endif 879 material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); 880 #ifdef USE_SHEEN_ROUGHNESSMAP 881 material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; 882 #endif 883#endif 884#ifdef USE_ANISOTROPY 885 #ifdef USE_ANISOTROPYMAP 886 mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); 887 vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; 888 vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; 889 #else 890 vec2 anisotropyV = anisotropyVector; 891 #endif 892 material.anisotropy = length( anisotropyV ); 893 if( material.anisotropy == 0.0 ) { 894 anisotropyV = vec2( 1.0, 0.0 ); 895 } else { 896 anisotropyV /= material.anisotropy; 897 material.anisotropy = saturate( material.anisotropy ); 898 } 899 material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
900 material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; 901 material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; 902#endif`,Fh=`uniform sampler2D dfgLUT; 903struct PhysicalMaterial { 904 vec3 diffuseColor; 905 vec3 diffuseContribution; 906 vec3 specularColor; 907 vec3 specularColorBlended; 908 float roughness; 909 float metalness; 910 float specularF90; 911 float dispersion; 912 #ifdef USE_CLEARCOAT 913 float clearcoat; 914 float clearcoatRoughness; 915 vec3 clearcoatF0; 916 float clearcoatF90; 917 #endif 918 #ifdef USE_IRIDESCENCE 919 float iridescence; 920 float iridescenceIOR; 921 float iridescenceThickness; 922 vec3 iridescenceFresnel; 923 vec3 iridescenceF0; 924 vec3 iridescenceFresnelDielectric; 925 vec3 iridescenceFresnelMetallic; 926 #endif 927 #ifdef USE_SHEEN 928 vec3 sheenColor; 929 float sheenRoughness; 930 #endif 931 #ifdef IOR 932 float ior; 933 #endif 934 #ifdef USE_TRANSMISSION 935 float transmission; 936 float transmissionAlpha; 937 float thickness; 938 float attenuationDistance; 939 vec3 attenuationColor; 940 #endif 941 #ifdef USE_ANISOTROPY 942 float anisotropy; 943 float alphaT; 944 vec3 anisotropyT; 945 vec3 anisotropyB; 946 #endif 947}; 948vec3 clearcoatSpecularDirect = vec3( 0.0 ); 949vec3 clearcoatSpecularIndirect = vec3( 0.0 ); 950vec3 sheenSpecularDirect = vec3( 0.0 ); 951vec3 sheenSpecularIndirect = vec3(0.0 ); 952vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { 953 float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); 954 float x2 = x * x; 955 float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); 956 return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); 957} 958float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { 959 float a2 = pow2( alpha ); 960 float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); 961 float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); 962 return 0.5 / max( gv + gl, EPSILON ); 963} 964float D_GGX( const in float alpha, const in float dotNH ) { 965 float a2 = pow2( alpha ); 966 float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; 967 return RECIPROCAL_PI * a2 / pow2( denom ); 968} 969#ifdef USE_ANISOTROPY 970 float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { 971 float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); 972 float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); 973 return 0.5 / max( gv + gl, EPSILON )
vendor: 7,372 bytes, lines 973-1132
973; 974 } 975 float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { 976 float a2 = alphaT * alphaB; 977 highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); 978 highp float v2 = dot( v, v ); 979 float w2 = a2 / v2; 980 return RECIPROCAL_PI * a2 * pow2 ( w2 ); 981 } 982#endif 983#ifdef USE_CLEARCOAT 984 vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { 985 vec3 f0 = material.clearcoatF0; 986 float f90 = material.clearcoatF90; 987 float roughness = material.clearcoatRoughness; 988 float alpha = pow2( roughness ); 989 vec3 halfDir = normalize( lightDir + viewDir ); 990 float dotNL = saturate( dot( normal, lightDir ) ); 991 float dotNV = saturate( dot( normal, viewDir ) ); 992 float dotNH = saturate( dot( normal, halfDir ) ); 993 float dotVH = saturate( dot( viewDir, halfDir ) ); 994 vec3 F = F_Schlick( f0, f90, dotVH ); 995 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); 996 float D = D_GGX( alpha, dotNH ); 997 return F * ( V * D ); 998 } 999#endif 1000vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { 1001 vec3 f0 = material.specularColorBlended; 1002 float f90 = material.specularF90; 1003 float roughness = material.roughness; 1004 float alpha = pow2( roughness ); 1005 vec3 halfDir = normalize( lightDir + viewDir ); 1006 float dotNL = saturate( dot( normal, lightDir ) ); 1007 float dotNV = saturate( dot( normal, viewDir ) ); 1008 float dotNH = saturate( dot( normal, halfDir ) ); 1009 float dotVH = saturate( dot( viewDir, halfDir ) ); 1010 vec3 F = F_Schlick( f0, f90, dotVH ); 1011 #ifdef USE_IRIDESCENCE 1012 F = mix( F, material.iridescenceFresnel, material.iridescence ); 1013 #endif 1014 #ifdef USE_ANISOTROPY 1015 float dotTL = dot( material.anisotropyT, lightDir ); 1016 float dotTV = dot( material.anisotropyT, viewDir ); 1017 float dotTH = dot( material.anisotropyT, halfDir ); 1018 float dotBL = dot( material.anisotropyB, lightDir ); 1019 float dotBV = dot( material.anisotropyB, viewDir ); 1020 float dotBH = dot( material.anisotropyB, halfDir ); 1021 float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); 1022 float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); 1023 #else 1024 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); 1025 float D = D_GGX( alpha, dotNH ); 1026 #endif 1027 return F * ( V * D ); 1028} 1029vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { 1030 const float LUT_SIZE = 64.0; 1031 const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; 1032 const float LUT_BIAS = 0.5 / LUT_SIZE; 1033 float dotNV = saturate( dot( N, V ) ); 1034 vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); 1035 uv = uv * LUT_SCALE + LUT_BIAS; 1036 return uv; 1037} 1038float LTC_ClippedSphereFormFactor( const in vec3 f ) { 1039 float l = length( f ); 1040 return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); 1041} 1042vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { 1043 float x = dot( v1, v2 ); 1044 float y = abs( x ); 1045 float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; 1046 float b = 3.4175940 + ( 4.1616724 + y ) * y; 1047 float v = a / b; 1048 float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; 1049 return cross( v1, v2 ) * theta_sintheta; 1050} 1051vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { 1052 vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; 1053 vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; 1054 vec3 lightNormal = cross( v1, v2 ); 1055 if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); 1056 vec3 T1, T2; 1057 T1 = normalize( V - N * dot( V, N ) ); 1058 T2 = - cross( N, T1 ); 1059 mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); 1060 vec3 coords[ 4 ]; 1061 coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); 1062 coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); 1063 coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); 1064 coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); 1065 coords[ 0 ] = normalize( coords[ 0 ] ); 1066 coords[ 1 ] = normalize( coords[ 1 ] ); 1067 coords[ 2 ] = normalize( coords[ 2 ] ); 1068 coords[ 3 ] = normalize( coords[ 3 ] ); 1069 vec3 vectorFormFactor = vec3( 0.0 ); 1070 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); 1071 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); 1072 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); 1073 vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); 1074 float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); 1075 return vec3( result ); 1076} 1077#if defined( USE_SHEEN ) 1078float D_Charlie( float roughness, float dotNH ) { 1079 float alpha = pow2( roughness ); 1080 float invAlpha = 1.0 / alpha; 1081 float cos2h = dotNH * dotNH; 1082 float sin2h = max( 1.0 - cos2h, 0.0078125 ); 1083 return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); 1084} 1085float V_Neubelt( float dotNV, float dotNL ) { 1086 return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); 1087} 1088vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { 1089 vec3 halfDir = normalize( lightDir + viewDir ); 1090 float dotNL = saturate( dot( normal, lightDir ) ); 1091 float dotNV = saturate( dot( normal, viewDir ) ); 1092 float dotNH = saturate( dot( normal, halfDir ) ); 1093 float D = D_Charlie( sheenRoughness, dotNH ); 1094 float V = V_Neubelt( dotNV, dotNL ); 1095 return sheenColor * ( D * V ); 1096} 1097#endif 1098float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { 1099 float dotNV = saturate( dot( normal, viewDir ) ); 1100 float r2 = roughness * roughness; 1101 float rInv = 1.0 / ( roughness + 0.1 ); 1102 float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; 1103 float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; 1104 float DG = exp( a * dotNV + b ); 1105 return saturate( DG ); 1106} 1107vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { 1108 float dotNV = saturate( dot( normal, viewDir ) ); 1109 vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; 1110 return specularColor * fab.x + specularF90 * fab.y; 1111} 1112#ifdef USE_IRIDESCENCE 1113void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { 1114#else 1115void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { 1116#endif 1117 float dotNV = saturate( dot( normal, viewDir ) ); 1118 vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; 1119 #ifdef USE_IRIDESCENCE 1120 vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); 1121 #else 1122 vec3 Fr = specularColor; 1123 #endif 1124 vec3 FssEss = Fr * fab.x + specularF90 * fab.y; 1125 float Ess = fab.x + fab.y; 1126 float Ems = 1.0 - Ess; 1127 vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); 1128 singleScatter += FssEss; 1129 multiScatter += Fms * Ems; 1130} 1131vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { 1132 vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
vendor: 8,354 bytes, lines 1133-1262
1133 float dotNL = saturate( dot( normal, lightDir ) ); 1134 float dotNV = saturate( dot( normal, viewDir ) ); 1135 vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; 1136 vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; 1137 vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; 1138 vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; 1139 float Ess_V = dfgV.x + dfgV.y; 1140 float Ess_L = dfgL.x + dfgL.y; 1141 float Ems_V = 1.0 - Ess_V; 1142 float Ems_L = 1.0 - Ess_L; 1143 vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; 1144 vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); 1145 float compensationFactor = Ems_V * Ems_L; 1146 vec3 multiScatter = Fms * compensationFactor; 1147 return singleScatter + multiScatter; 1148} 1149#if NUM_RECT_AREA_LIGHTS > 0 1150 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1151 vec3 normal = geometryNormal; 1152 vec3 viewDir = geometryViewDir; 1153 vec3 position = geometryPosition; 1154 vec3 lightPos = rectAreaLight.position; 1155 vec3 halfWidth = rectAreaLight.halfWidth; 1156 vec3 halfHeight = rectAreaLight.halfHeight; 1157 vec3 lightColor = rectAreaLight.color; 1158 float roughness = material.roughness; 1159 vec3 rectCoords[ 4 ]; 1160 rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; 1161 rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; 1162 rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; 1163 vec2 uv = LTC_Uv( normal, viewDir, roughness ); 1164 vec4 t1 = texture2D( ltc_1, uv ); 1165 vec4 t2 = texture2D( ltc_2, uv ); 1166 mat3 mInv = mat3( 1167 vec3( t1.x, 0, t1.y ), 1168 vec3( 0, 1, 0 ), 1169 vec3( t1.z, 0, t1.w ) 1170 ); 1171 vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); 1172 reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); 1173 reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); 1174 #ifdef USE_CLEARCOAT 1175 vec3 Ncc = geometryClearcoatNormal; 1176 vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); 1177 vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); 1178 vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); 1179 mat3 mInvClearcoat = mat3( 1180 vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), 1181 vec3( 0, 1, 0 ), 1182 vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) 1183 ); 1184 vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; 1185 clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); 1186 #endif 1187 } 1188#endif 1189void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1190 float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); 1191 vec3 irradiance = dotNL * directLight.color; 1192 #ifdef USE_CLEARCOAT 1193 float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); 1194 vec3 ccIrradiance = dotNLcc * directLight.color; 1195 clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); 1196 #endif 1197 #ifdef USE_SHEEN 1198 1199 sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); 1200 1201 float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1202 float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); 1203 1204 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); 1205 1206 irradiance *= sheenEnergyComp; 1207 1208 #endif 1209 reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); 1210 reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); 1211} 1212void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { 1213 vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); 1214 #ifdef USE_SHEEN 1215 float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1216 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; 1217 diffuse *= sheenEnergyComp; 1218 #endif 1219 reflectedLight.indirectDiffuse += diffuse; 1220} 1221void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { 1222 #ifdef USE_CLEARCOAT 1223 clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); 1224 #endif 1225 #ifdef USE_SHEEN 1226 sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; 1227 #endif 1228 vec3 singleScatteringDielectric = vec3( 0.0 ); 1229 vec3 multiScatteringDielectric = vec3( 0.0 ); 1230 vec3 singleScatteringMetallic = vec3( 0.0 ); 1231 vec3 multiScatteringMetallic = vec3( 0.0 ); 1232 #ifdef USE_IRIDESCENCE 1233 computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); 1234 computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); 1235 #else 1236 computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); 1237 computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); 1238 #endif 1239 vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); 1240 vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); 1241 vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; 1242 vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); 1243 vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; 1244 vec3 indirectSpecular = radiance * singleScattering; 1245 indirectSpecular += multiScattering * cosineWeightedIrradiance; 1246 vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; 1247 #ifdef USE_SHEEN 1248 float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); 1249 float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; 1250 indirectSpecular *= sheenEnergyComp; 1251 indirectDiffuse *= sheenEnergyComp; 1252 #endif 1253 reflectedLight.indirectSpecular += indirectSpecular; 1254 reflectedLight.indirectDiffuse += indirectDiffuse; 1255} 1256#define RE_Direct RE_Direct_Physical 1257#define RE_Direct_RectArea RE_Direct_RectArea_Physical 1258#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical 1259#define RE_IndirectSpecular RE_IndirectSpecular_Physical 1260float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { 1261 return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); 1262}`,
1262Oh=` 1263vec3 geometryPosition = - vViewPosition; 1264vec3 geometryNormal = normal; 1265vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); 1266vec3 geometryClearcoatNormal = vec3( 0.0 ); 1267#ifdef USE_CLEARCOAT 1268 geometryClearcoatNormal = clearcoatNormal; 1269#endif 1270#ifdef USE_IRIDESCENCE 1271 float dotNVi = saturate( dot( normal, geometryViewDir ) ); 1272 if ( material.iridescenceThickness == 0.0 ) { 1273 material.iridescence = 0.0; 1274 } else { 1275 material.iridescence = saturate( material.iridescence ); 1276 } 1277 if ( material.iridescence > 0.0 ) { 1278 material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); 1279 material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); 1280 material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); 1281 material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); 1282 } 1283#endif 1284IncidentLight directLight; 1285#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) 1286 PointLight pointLight; 1287 #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 1288 PointLightShadow pointLightShadow; 1289 #endif 1290 #pragma unroll_loop_start 1291 for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { 1292 pointLight = pointLights[ i ]; 1293 getPointLightInfo( pointLight, geometryPosition, directLight ); 1294 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) 1295 pointLightShadow = pointLightShadows[ i ]; 1296 directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; 1297 #endif 1298 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1299 } 1300 #pragma unroll_loop_end 1301#endif 1302#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) 1303 SpotLight spotLight; 1304 vec4 spotColor; 1305 vec3 spotLightCoord; 1306 bool inSpotLightMap; 1307 #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 1308 SpotLightShadow spotLightShadow; 1309 #endif 1310 #pragma unroll_loop_start 1311 for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { 1312 spotLight = spotLights[ i ]; 1313 getSpotLightInfo( spotLight, geometryPosition, directLight ); 1314 #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) 1315 #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX 1316 #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1317 #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS 1318 #else 1319 #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) 1320 #endif 1321 #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) 1322 spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; 1323 inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); 1324 spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); 1325 directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; 1326 #endif 1327 #undef SPOT_LIGHT_MAP_INDEX 1328 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 1329 spotLightShadow = spotLightShadows[ i ]; 1330 directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 1331 #endif 1332 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1333 } 1334 #pragma unroll_loop_end 1335#endif 1336#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) 1337 DirectionalLight directionalLight; 1338 #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 1339 DirectionalLightShadow directionalLightShadow; 1340 #endif 1341 #pragma unroll_loop_start 1342 for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { 1343 directionalLight = directionalLights[ i ]; 1344 getDirectionalLightInfo( directionalLight, directLight ); 1345 #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) 1346 directionalLightShadow = directionalLightShadows[ i ]; 1347 directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 1348 #endif 1349 RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1350 } 1351 #pragma unroll_loop_end 1352#endif 1353#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) 1354 RectAreaLight rectAreaLight; 1355 #pragma unroll_loop_start 1356 for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { 1357 rectAreaLight = rectAreaLights[ i ]; 1358 RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1359 } 1360 #pragma unroll_loop_end 1361#endif 1362#if defined( RE_IndirectDiffuse ) 1363 vec3 iblIrradiance = vec3( 0.0 ); 1364 vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); 1365 #if defined( USE_LIGHT_PROBES ) 1366 irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); 1367 #endif 1368 #if ( NUM_HEMI_LIGHTS > 0 ) 1369 #pragma unroll_loop_start 1370 for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { 1371 irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); 1372 } 1373 #pragma unroll_loop_end 1374 #endif 1375 #ifdef USE_LIGHT_PROBES_GRID 1376 vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; 1377 vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); 1378 irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); 1379 #endif 1380#endif 1381#if defined( RE_IndirectSpecular ) 1382 vec3 radiance = vec3( 0.0 ); 1383 vec3 clearcoatRadiance = vec3( 0.0 ); 1384#endif`,Bh=`#if defined( RE_IndirectDiffuse ) 1385 #ifdef USE_LIGHTMAP 1386 vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 1387 vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; 1388 irradiance += lightMapIrradiance; 1389 #endif 1390 #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) 1391 #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) 1392 iblIrradiance += getIBLIrradiance( geometryNormal ); 1393 #endif 1394 #endif 1395#endif 1396#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) 1397 #ifdef USE_ANISOTROPY 1398 radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); 1399 #else 1400 radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); 1401 #endif 1402 #ifdef USE_CLEARCOAT 1403 clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); 1404 #endif 1405#endif`,zh=`#if defined( RE_IndirectDiffuse ) 1406 #if defined( LAMBERT ) || defined( PHONG ) 1407 irradiance += iblIrradiance; 1408 #endif 1409 RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1410#endif 1411#if defined( RE_IndirectSpecular ) 1412 RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); 1413#endif`,Gh=`#ifdef USE_LIGHT_PROBES_GRID 1414uniform highp sampler3D probesSH; 1415uniform vec3 probesMin; 1416uniform vec3 probesMax; 1417uniform vec3 probesResolution; 1418vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { 1419 vec3 res = probesResolution; 1420 vec3 gridRange = probesMax - probesMin; 1421 vec3 resMinusOne = res - 1.0; 1422 vec3 probeSpacing = gridRange / resMinusOne; 1423 vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; 1424 vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); 1425 uvw = uvw * resMinusOne / res + 0.5 / res; 1426 float nz = res.z; 1427 float paddedSlices = nz + 2.0; 1428 float atlasDepth = 7.0 * paddedSlices; 1429 float uvZBase = uvw.z * nz + 1.0; 1430 vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); 1431 vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); 1432 vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); 1433 vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); 1434 vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); 1435 vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); 1436 vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); 1437 vec3 c0 = s0.xyz; 1438 vec3 c1 = vec3( s0.w, s1.xy ); 1439 vec3 c2 = vec3( s1.zw, s2.x ); 1440 vec3 c3 = s2.yzw; 1441 vec3 c4 = s3.xyz; 1442 vec3 c5 = vec3( s3.w, s4.xy ); 1443 vec3 c6 = vec3( s4.zw, s5.x ); 1444 vec3 c7 = s5.yzw; 1445 vec3 c8 = s6.xyz; 1446 float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; 1447 vec3 result = c0 * 0.886227; 1448 result += c1 * 2.0 * 0.511664 * y; 1449 result += c2 * 2.0 * 0.511664 * z; 1450 result += c3 * 2.0 * 0.511664 * x; 1451 result += c4 * 2.0 * 0.429043 * x * y; 1452 result += c5 * 2.0 * 0.429043 * y * z; 1453 result += c6 * ( 0.743125 * z * z - 0.247708 ); 1454 result += c7 * 2.0 * 0.429043 * x * z; 1455 result += c8 * 0.429043 * ( x * x - y * y ); 1456 return max( result, vec3( 0.0 ) ); 1457} 1458#endif`,Vh=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) 1459 gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; 1460#endif`,Hh=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) 1461 uniform float logDepthBufFC; 1462 varying float vFragDepth; 1463 varying float vIsPerspective; 1464#endif`,kh=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER 1465 varying float vFragDepth; 1466 varying float vIsPerspective; 1467#endif`,Wh=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER 1468 vFragDepth = 1.0 + gl_Position.w; 1469 vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); 1470#endif`,Xh=`#ifdef USE_MAP 1471 vec4 sampledDiffuseColor = texture2D( map, vMapUv ); 1472 #ifdef DECODE_VIDEO_TEXTURE 1473 sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); 1474 #endif 1475 diffuseColor *= sampledDiffuseColor; 1476#endif`,qh=`#ifdef USE_MAP 1477 uniform sampler2D map; 1478#endif`,Yh=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 1479 #if defined( USE_POINTS_UV ) 1480 vec2 uv = vUv; 1481 #else 1482 vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; 1483 #endif 1484#endif 1485#ifdef USE_MAP 1486 diffuseColor *= texture2D( map, uv ); 1487#endif 1488#ifdef USE_ALPHAMAP 1489 diffuseColor.a *= texture2D( alphaMap, uv ).g; 1490#endif`,Kh=`#if defined( USE_POINTS_UV ) 1491 varying vec2 vUv; 1492#else 1493 #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 1494 uniform mat3 uvTransform; 1495 #endif 1496#endif 1497#ifdef USE_MAP 1498 uniform sampler2D map; 1499#endif 1500#ifdef USE_ALPHAMAP 1501 uniform sampler2D alphaMap; 1502#endif`,Zh=`float metalnessFactor = metalness; 1503#ifdef USE_METALNESSMAP 1504 vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); 1505 metalnessFactor *= texelMetalness.b; 1506#endif`,$h=`#ifdef USE_METALNESSMAP 1507 uniform sampler2D metalnessMap; 1508#endif`,Jh=`#ifdef USE_INSTANCING_MORPH 1509 float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 1510 float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; 1511 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1512 morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; 1513 } 1514#endif`,Qh=`#if defined( USE_MORPHCOLORS ) 1515 vColor *= morphTargetBaseInfluence; 1516 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1517 #if defined( USE_COLOR_ALPHA ) 1518 if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; 1519 #elif defined( USE_COLOR ) 1520 if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; 1521 #endif 1522 } 1523#endif`,jh=`#ifdef USE_MORPHNORMALS 1524 objectNormal *= morphTargetBaseInfluence; 1525 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1526 if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; 1527 } 1528#endif`,ef=`#ifdef USE_MORPHTARGETS 1529 #ifndef USE_INSTANCING_MORPH 1530 uniform float morphTargetBaseInfluence; 1531 uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 1532 #endif 1533 uniform sampler2DArray morphTargetsTexture; 1534 uniform ivec2 morphTargetsTextureSize; 1535 vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { 1536 int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; 1537 int y = texelIndex / morphTargetsTextureSize.x; 1538 int x = texelIndex - y * morphTargetsTextureSize.x; 1539 ivec3 morphUV = ivec3( x, y, morphTargetIndex ); 1540 return texelFetch( morphTargetsTexture, morphUV, 0 ); 1541 } 1542#endif`,tf=`#ifdef USE_MORPHTARGETS 1543 transformed *= morphTargetBaseInfluence; 1544 for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 1545 if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; 1546 } 1547#endif`,nf=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; 1548#ifdef FLAT_SHADED 1549 vec3 fdx = dFdx( vViewPosition ); 1550 vec3 fdy = dFdy( vViewPosition ); 1551 vec3 normal = normalize( cross( fdx, fdy ) ); 1552#else 1553 vec3 normal = normalize( vNormal ); 1554 #ifdef DOUBLE_SIDED 1555 normal *= faceDirection; 1556 #endif 1557#endif 1558#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) 1559 #ifdef USE_TANGENT 1560 mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 1561 #else 1562 mat3 tbn = getTangentFrame( - vViewPosition, normal, 1563 #if defined( USE_NORMALMAP ) 1564 vNormalMapUv 1565 #elif defined( USE_CLEARCOAT_NORMALMAP ) 1566 vClearcoatNormalMapUv 1567 #else 1568 vUv 1569 #endif 1570 ); 1571 #endif 1572 #ifdef DOUBLE_SIDED 1573 tbn[0] *= faceDirection; 1574 tbn[1] *= faceDirection; 1575 #endif 1576#endif 1577#ifdef USE_CLEARCOAT_NORMALMAP 1578 #ifdef USE_TANGENT 1579 mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 1580 #else 1581 mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); 1582 #endif 1583 #ifdef DOUBLE_SIDED 1584 tbn2[0] *= faceDirection; 1585 tbn2[1] *= faceDirection; 1586 #endif 1587#endif 1588vec3 nonPerturbedNormal = normal;`,rf=`#ifdef USE_NORMALMAP_OBJECTSPACE 1589 normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 1590 #ifdef FLIP_SIDED 1591 normal = - normal; 1592 #endif 1593 #ifdef DOUBLE_SIDED 1594 normal = normal * faceDirection; 1595 #endif 1596 normal = normalize( normalMatrix * normal ); 1597#elif defined( USE_NORMALMAP_TANGENTSPACE ) 1598 vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 1599 #if defined( USE_PACKED_NORMALMAP ) 1600 mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); 1601 #endif 1602 mapN.xy *= normalScale; 1603 normal = normalize( tbn * mapN ); 1604#elif defined( USE_BUMPMAP )
1605 normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); 1606#endif`,sf=`#ifndef FLAT_SHADED 1607 varying vec3 vNormal; 1608 #ifdef USE_TANGENT 1609 varying vec3 vTangent; 1610 varying vec3 vBitangent; 1611 #endif 1612#endif`,af=`#ifndef FLAT_SHADED 1613 varying vec3 vNormal; 1614 #ifdef USE_TANGENT 1615 varying vec3 vTangent; 1616 varying vec3 vBitangent; 1617 #endif 1618#endif`,of=`#ifndef FLAT_SHADED 1619 vNormal = normalize( transformedNormal ); 1620 #ifdef USE_TANGENT 1621 vTangent = normalize( transformedTangent ); 1622 vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); 1623 #ifdef FLIP_SIDED 1624 vBitangent = - vBitangent; 1625 #endif 1626 #endif 1627#endif`,lf=`#ifdef USE_NORMALMAP 1628 uniform sampler2D normalMap; 1629 uniform vec2 normalScale; 1630#endif 1631#ifdef USE_NORMALMAP_OBJECTSPACE 1632 uniform mat3 normalMatrix; 1633#endif 1634#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) 1635 mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { 1636 vec3 q0 = dFdx( eye_pos.xyz ); 1637 vec3 q1 = dFdy( eye_pos.xyz ); 1638 vec2 st0 = dFdx( uv.st ); 1639 vec2 st1 = dFdy( uv.st ); 1640 vec3 N = surf_norm; 1641 vec3 q1perp = cross( q1, N ); 1642 vec3 q0perp = cross( N, q0 ); 1643 vec3 T = q1perp * st0.x + q0perp * st1.x; 1644 vec3 B = q1perp * st0.y + q0perp * st1.y; 1645 float det = max( dot( T, T ), dot( B, B ) ); 1646 float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); 1647 return mat3( T * scale, B * scale, N ); 1648 } 1649#endif`,cf=`#ifdef USE_CLEARCOAT 1650 vec3 clearcoatNormal = nonPerturbedNormal; 1651#endif`,uf=`#ifdef USE_CLEARCOAT_NORMALMAP 1652 vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; 1653 clearcoatMapN.xy *= clearcoatNormalScale; 1654 clearcoatNormal = normalize( tbn2 * clearcoatMapN ); 1655#endif`,hf=`#ifdef USE_CLEARCOATMAP 1656 uniform sampler2D clearcoatMap; 1657#endif 1658#ifdef USE_CLEARCOAT_NORMALMAP 1659 uniform sampler2D clearcoatNormalMap; 1660 uniform vec2 clearcoatNormalScale; 1661#endif 1662#ifdef USE_CLEARCOAT_ROUGHNESSMAP 1663 uniform sampler2D clearcoatRoughnessMap; 1664#endif`,ff=`#ifdef USE_IRIDESCENCEMAP 1665 uniform sampler2D iridescenceMap; 1666#endif 1667#ifdef USE_IRIDESCENCE_THICKNESSMAP 1668 uniform sampler2D iridescenceThicknessMap; 1669#endif`,df=`#ifdef OPAQUE 1670diffuseColor.a = 1.0; 1671#endif 1672#ifdef USE_TRANSMISSION 1673diffuseColor.a *= material.transmissionAlpha; 1674#endif 1675gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,pf=`vec3 packNormalToRGB( const in vec3 normal ) { 1676 return normalize( normal ) * 0.5 + 0.5; 1677} 1678vec3 unpackRGBToNormal( const in vec3 rgb ) { 1679 return 2.0 * rgb.xyz - 1.0; 1680} 1681const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; 1682const float Inv255 = 1. / 255.; 1683const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); 1684const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); 1685const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); 1686const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); 1687vec4 packDepthToRGBA( const in float v ) { 1688 if( v <= 0.0 ) 1689 return vec4( 0., 0., 0., 0. ); 1690 if( v >= 1.0 ) 1691 return vec4( 1., 1., 1., 1. ); 1692 float vuf; 1693 float af = modf( v * PackFactors.a, vuf ); 1694 float bf = modf( vuf * ShiftRight8, vuf ); 1695 float gf = modf( vuf * ShiftRight8, vuf ); 1696 return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); 1697} 1698vec3 packDepthToRGB( const in float v ) { 1699 if( v <= 0.0 ) 1700 return vec3( 0., 0., 0. ); 1701 if( v >= 1.0 ) 1702 return vec3( 1., 1., 1. ); 1703 float vuf; 1704 float bf = modf( v * PackFactors.b, vuf ); 1705 float gf = modf( vuf * ShiftRight8, vuf ); 1706 return vec3( vuf * Inv255, gf * PackUpscale, bf ); 1707} 1708vec2 packDepthToRG( const in float v ) { 1709 if( v <= 0.0 ) 1710 return vec2( 0., 0. ); 1711 if( v >= 1.0 ) 1712 return vec2( 1., 1. ); 1713 float vuf; 1714 float gf = modf( v * 256., vuf ); 1715 return vec2( vuf * Inv255, gf ); 1716} 1717float unpackRGBAToDepth( const in vec4 v ) { 1718 return dot( v, UnpackFactors4 ); 1719} 1720float unpackRGBToDepth( const in vec3 v ) { 1721 return dot( v, UnpackFactors3 ); 1722} 1723float unpackRGToDepth( const in vec2 v ) { 1724 return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; 1725} 1726vec4 pack2HalfToRGBA( const in vec2 v ) {
1727 vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); 1728 return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); 1729} 1730vec2 unpackRGBATo2Half( const in vec4 v ) { 1731 return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); 1732} 1733float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { 1734 return ( viewZ + near ) / ( near - far ); 1735} 1736float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { 1737 #ifdef USE_REVERSED_DEPTH_BUFFER 1738 1739 return depth * ( far - near ) - far; 1740 #else 1741 return depth * ( near - far ) - near; 1742 #endif 1743} 1744float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { 1745 return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); 1746} 1747float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { 1748 1749 #ifdef USE_REVERSED_DEPTH_BUFFER 1750 return ( near * far ) / ( ( near - far ) * depth - near ); 1751 #else 1752 return ( near * far ) / ( ( far - near ) * depth - far ); 1753 #endif 1754}`,mf=`#ifdef PREMULTIPLIED_ALPHA 1755 gl_FragColor.rgb *= gl_FragColor.a; 1756#endif`,gf=`vec4 mvPosition = vec4( transformed, 1.0 ); 1757#ifdef USE_BATCHING 1758 mvPosition = batchingMatrix * mvPosition; 1759#endif 1760#ifdef USE_INSTANCING 1761 mvPosition = instanceMatrix * mvPosition; 1762#endif 1763mvPosition = modelViewMatrix * mvPosition; 1764gl_Position = projectionMatrix * mvPosition;`,_f=`#ifdef DITHERING 1765 gl_FragColor.rgb = dithering( gl_FragColor.rgb ); 1766#endif`,xf=`#ifdef DITHERING 1767 vec3 dithering( vec3 color ) { 1768 float grid_position = rand( gl_FragCoord.xy ); 1769 vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); 1770 dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); 1771 return color + dither_shift_RGB; 1772 } 1773#endif`,vf=`float roughnessFactor = roughness; 1774#ifdef USE_ROUGHNESSMAP 1775 vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); 1776 roughnessFactor *= texelRoughness.g; 1777#endif`,Mf=`#ifdef USE_ROUGHNESSMAP 1778 uniform sampler2D roughnessMap; 1779#endif`,Sf=`#if NUM_SPOT_LIGHT_COORDS > 0 1780 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 1781#endif 1782#if NUM_SPOT_LIGHT_MAPS > 0 1783 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; 1784#endif 1785#ifdef USE_SHADOWMAP 1786 #if NUM_DIR_LIGHT_SHADOWS > 0 1787 #if defined( SHADOWMAP_TYPE_PCF ) 1788 uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; 1789 #else 1790 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; 1791 #endif 1792 varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 1793 struct DirectionalLightShadow { 1794 float shadowIntensity; 1795 float shadowBias; 1796 float shadowNormalBias; 1797 float shadowRadius; 1798 vec2 shadowMapSize; 1799 }; 1800 uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 1801 #endif 1802 #if NUM_SPOT_LIGHT_SHADOWS > 0 1803 #if defined( SHADOWMAP_TYPE_PCF ) 1804 uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; 1805 #else 1806 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; 1807 #endif 1808 struct SpotLightShadow { 1809 float shadowIntensity; 1810 float shadowBias; 1811 float shadowNormalBias; 1812 float shadowRadius; 1813 vec2 shadowMapSize; 1814 }; 1815 uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 1816 #endif 1817 #if NUM_POINT_LIGHT_SHADOWS > 0 1818 #if defined( SHADOWMAP_TYPE_PCF ) 1819 uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; 1820 #elif defined( SHADOWMAP_TYPE_BASIC ) 1821 uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; 1822 #endif 1823 varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 1824 struct PointLightShadow { 1825 float shadowIntensity; 1826 float shadowBias; 1827 float shadowNormalBias; 1828 float shadowRadius; 1829 vec2 shadowMapSize; 1830 float shadowCameraNear; 1831 float shadowCameraFar; 1832 }; 1833 uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 1834 #endif 1835 #if defined( SHADOWMAP_TYPE_PCF ) 1836 float interleavedGradientNoise( vec2 position ) { 1837 return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); 1838 } 1839 vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { 1840 const float goldenAngle = 2.399963229728653; 1841 float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); 1842 float theta = float( sampleIndex ) * goldenAngle + phi; 1843 return vec2( cos( theta ), sin( theta ) ) * r; 1844 } 1845 #endif 1846 #if defined( SHADOWMAP_TYPE_PCF ) 1847 float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 1848 float shadow = 1.0; 1849 shadowCoord.xyz /= shadowCoord.w; 1850 shadowCoord.z += shadowBias; 1851 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 1852 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 1853 if ( frustumTest ) { 1854 vec2 texelSize = vec2( 1.0 ) / shadowMapSize; 1855 float radius = shadowRadius * texelSize.x; 1856 float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; 1857 shadow = ( 1858 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + 1859 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + 1860 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + 1861 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + 1862 texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) 1863 ) * 0.2; 1864 } 1865 return mix( 1.0, shadow, shadowIntensity ); 1866 } 1867 #elif defined( SHADOWMAP_TYPE_VSM ) 1868 float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 1869 float shadow = 1.0; 1870 shadowCoord.xyz /= shadowCoord.w; 1871 #ifdef USE_REVERSED_DEPTH_BUFFER 1872 shadowCoord.z -= shadowBias; 1873 #else 1874 shadowCoord.z += shadowBias; 1875 #endif 1876 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 1877 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 1878 if ( frustumTest ) { 1879 vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; 1880 float mean = distribution.x; 1881 float variance = distribution.y * distribution.y; 1882 #ifdef USE_REVERSED_DEPTH_BUFFER 1883 float hard_shadow = step( mean, shadowCoord.z ); 1884 #else 1885 float hard_shadow = step( shadowCoord.z, mean ); 1886 #endif 1887 1888 if ( hard_shadow == 1.0 ) { 1889 shadow = 1.0; 1890 } else { 1891 variance = max( variance, 0.0000001 ); 1892 float d = shadowCoord.z - mean; 1893 float p_max = variance / ( variance + d * d ); 1894 p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); 1895 shadow = max( hard_shadow, p_max ); 1896 } 1897 } 1898 return mix( 1.0, shadow, shadowIntensity ); 1899 } 1900 #else 1901 float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { 1902 float shadow = 1.0; 1903 shadowCoord.xyz /= shadowCoord.w; 1904 #ifdef USE_REVERSED_DEPTH_BUFFER 1905 shadowCoord.z -= shadowBias; 1906 #else 1907 shadowCoord.z += shadowBias; 1908 #endif 1909 bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; 1910 bool frustumTest = inFrustum && shadowCoord.z <= 1.0; 1911 if ( frustumTest ) { 1912 float depth = texture2D( shadowMap, shadowCoord.xy ).r; 1913 #ifdef USE_REVERSED_DEPTH_BUFFER 1914 shadow = step( depth, shadowCoord.z ); 1915 #else 1916 shadow = step( shadowCoord.z, depth ); 1917 #endif 1918 } 1919 return mix( 1.0, shadow, shadowIntensity ); 1920 } 1921 #endif 1922 #if NUM_POINT_LIGHT_SHADOWS > 0 1923 #if defined( SHADOWMAP_TYPE_PCF ) 1924 float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { 1925 float shadow = 1.0; 1926 vec3 lightToPosition = shadowCoord.xyz; 1927 vec3 bd3D = normalize( lightToPosition ); 1928 vec3 absVec = abs( lightToPosition ); 1929 float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); 1930 if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { 1931 #ifdef USE_REVERSED_DEPTH_BUFFER 1932 float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
1933 dp -= shadowBias; 1934 #else 1935 float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); 1936 dp += shadowBias; 1937 #endif 1938 float texelSize = shadowRadius / shadowMapSize.x; 1939 vec3 absDir = abs( bd3D ); 1940 vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); 1941 tangent = normalize( cross( bd3D, tangent ) ); 1942 vec3 bitangent = cross( bd3D, tangent ); 1943 float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; 1944 vec2 sample0 = vogelDiskSample( 0, 5, phi ); 1945 vec2 sample1 = vogelDiskSample( 1, 5, phi ); 1946 vec2 sample2 = vogelDiskSample( 2, 5, phi ); 1947 vec2 sample3 = vogelDiskSample( 3, 5, phi ); 1948 vec2 sample4 = vogelDiskSample( 4, 5, phi ); 1949 shadow = ( 1950 texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + 1951 texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + 1952 texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + 1953 texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + 1954 texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) 1955 ) * 0.2; 1956 } 1957 return mix( 1.0, shadow, shadowIntensity ); 1958 } 1959 #elif defined( SHADOWMAP_TYPE_BASIC ) 1960 float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { 1961 float shadow = 1.0; 1962 vec3 lightToPosition = shadowCoord.xyz; 1963 vec3 absVec = abs( lightToPosition ); 1964 float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); 1965 if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { 1966 float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); 1967 dp += shadowBias; 1968 vec3 bd3D = normalize( lightToPosition ); 1969 float depth = textureCube( shadowMap, bd3D ).r; 1970 #ifdef USE_REVERSED_DEPTH_BUFFER 1971 depth = 1.0 - depth; 1972 #endif 1973 shadow = step( dp, depth ); 1974 } 1975 return mix( 1.0, shadow, shadowIntensity ); 1976 } 1977 #endif 1978 #endif 1979#endif`,Ef=`#if NUM_SPOT_LIGHT_COORDS > 0 1980 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; 1981 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 1982#endif 1983#ifdef USE_SHADOWMAP 1984 #if NUM_DIR_LIGHT_SHADOWS > 0 1985 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; 1986 varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 1987 struct DirectionalLightShadow { 1988 float shadowIntensity; 1989 float shadowBias; 1990 float shadowNormalBias; 1991 float shadowRadius; 1992 vec2 shadowMapSize; 1993 }; 1994 uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 1995 #endif 1996 #if NUM_SPOT_LIGHT_SHADOWS > 0 1997 struct SpotLightShadow { 1998 float shadowIntensity; 1999 float shadowBias; 2000 float shadowNormalBias; 2001 float shadowRadius; 2002 vec2 shadowMapSize; 2003 }; 2004 uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 2005 #endif 2006 #if NUM_POINT_LIGHT_SHADOWS > 0 2007 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; 2008 varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 2009 struct PointLightShadow { 2010 float shadowIntensity; 2011 float shadowBias; 2012 float shadowNormalBias; 2013 float shadowRadius; 2014 vec2 shadowMapSize; 2015 float shadowCameraNear; 2016 float shadowCameraFar; 2017 }; 2018 uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 2019 #endif 2020#endif`,yf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) 2021 #ifdef HAS_NORMAL 2022 vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); 2023 #else 2024 vec3 shadowWorldNormal = vec3( 0.0 ); 2025 #endif 2026 vec4 shadowWorldPosition; 2027#endif 2028#if defined( USE_SHADOWMAP ) 2029 #if NUM_DIR_LIGHT_SHADOWS > 0 2030 #pragma unroll_loop_start 2031 for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 2032 shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); 2033 vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; 2034 } 2035 #pragma unroll_loop_end 2036 #endif 2037 #if NUM_POINT_LIGHT_SHADOWS > 0 2038 #pragma unroll_loop_start 2039 for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 2040 shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); 2041 vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; 2042 } 2043 #pragma unroll_loop_end 2044 #endif 2045#endif
2046#if NUM_SPOT_LIGHT_COORDS > 0 2047 #pragma unroll_loop_start 2048 for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { 2049 shadowWorldPosition = worldPosition; 2050 #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) 2051 shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; 2052 #endif 2053 vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; 2054 } 2055 #pragma unroll_loop_end 2056#endif`,Tf=`float getShadowMask() { 2057 float shadow = 1.0; 2058 #ifdef USE_SHADOWMAP 2059 #if NUM_DIR_LIGHT_SHADOWS > 0 2060 DirectionalLightShadow directionalLight; 2061 #pragma unroll_loop_start 2062 for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 2063 directionalLight = directionalLightShadows[ i ]; 2064 shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 2065 } 2066 #pragma unroll_loop_end 2067 #endif 2068 #if NUM_SPOT_LIGHT_SHADOWS > 0 2069 SpotLightShadow spotLight; 2070 #pragma unroll_loop_start 2071 for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { 2072 spotLight = spotLightShadows[ i ]; 2073 shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 2074 } 2075 #pragma unroll_loop_end 2076 #endif 2077 #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) 2078 PointLightShadow pointLight; 2079 #pragma unroll_loop_start 2080 for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 2081 pointLight = pointLightShadows[ i ]; 2082 shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; 2083 } 2084 #pragma unroll_loop_end 2085 #endif 2086 #endif 2087 return shadow; 2088}`,bf=`#ifdef USE_SKINNING 2089 mat4 boneMatX = getBoneMatrix( skinIndex.x ); 2090 mat4 boneMatY = getBoneMatrix( skinIndex.y ); 2091 mat4 boneMatZ = getBoneMatrix( skinIndex.z ); 2092 mat4 boneMatW = getBoneMatrix( skinIndex.w ); 2093#endif`,Af=`#ifdef USE_SKINNING 2094 uniform mat4 bindMatrix; 2095 uniform mat4 bindMatrixInverse; 2096 uniform highp sampler2D boneTexture; 2097 mat4 getBoneMatrix( const in float i ) { 2098 int size = textureSize( boneTexture, 0 ).x; 2099 int j = int( i ) * 4; 2100 int x = j % size; 2101 int y = j / size; 2102 vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); 2103 vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); 2104 vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); 2105 vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); 2106 return mat4( v1, v2, v3, v4 ); 2107 } 2108#endif`,wf=`#ifdef USE_SKINNING 2109 vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); 2110 vec4 skinned = vec4( 0.0 ); 2111 skinned += boneMatX * skinVertex * skinWeight.x; 2112 skinned += boneMatY * skinVertex * skinWeight.y; 2113 skinned += boneMatZ * skinVertex * skinWeight.z; 2114 skinned += boneMatW * skinVertex * skinWeight.w; 2115 transformed = ( bindMatrixInverse * skinned ).xyz; 2116#endif`,Rf=`#ifdef USE_SKINNING 2117 mat4 skinMatrix = mat4( 0.0 ); 2118 skinMatrix += skinWeight.x * boneMatX; 2119 skinMatrix += skinWeight.y * boneMatY; 2120 skinMatrix += skinWeight.z * boneMatZ; 2121 skinMatrix += skinWeight.w * boneMatW; 2122 skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; 2123 objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; 2124 #ifdef USE_TANGENT 2125 objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; 2126 #endif 2127#endif`,Cf=`float specularStrength; 2128#ifdef USE_SPECULARMAP 2129 vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); 2130 specularStrength = texelSpecular.r; 2131#else 2132 specularStrength = 1.0; 2133#endif`,Pf=`#ifdef USE_SPECULARMAP 2134 uniform sampler2D specularMap; 2135#endif`,Df=`#if defined( TONE_MAPPING ) 2136 gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); 2137#endif`,Lf=`#ifndef saturate 2138#define saturate( a ) clamp( a, 0.0, 1.0 ) 2139#endif 2140uniform float toneMappingExposure; 2141vec3 LinearToneMapping( vec3 color ) { 2142 return saturate( toneMappingExposure * color ); 2143} 2144vec3 ReinhardToneMapping( vec3 color ) { 2145 color *= toneMappingExposure; 2146 return saturate( color / ( vec3( 1.0 ) + color ) ); 2147} 2148vec3 CineonToneMapping( vec3 color ) { 2149 color *= toneMappingExposure; 2150 color = max( vec3( 0.0 ), color - 0.004 ); 2151 return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); 2152} 2153vec3 RRTAndODTFit( vec3 v ) { 2154 vec3 a = v * ( v + 0.0245786 ) - 0.000090537; 2155 vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; 2156 return a / b; 2157} 2158vec3 ACESFilmicToneMapping( vec3 color ) { 2159 const mat3 ACESInputMat = mat3( 2160 vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), 2161 vec3( 0.04823, 0.01566, 0.83777 ) 2162 ); 2163 const mat3 ACESOutputMat = mat3( 2164 vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), 2165 vec3( -0.07367, -0.00605, 1.07602 ) 2166 ); 2167 color *= toneMappingExposure / 0.6; 2168 color = ACESInputMat * color; 2169 color = RRTAndODTFit( color ); 2170 color = ACESOutputMat * color; 2171 return saturate( color ); 2172} 2173const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( 2174 vec3( 1.6605, - 0.1246, - 0.0182 ), 2175 vec3( - 0.5876, 1.1329, - 0.1006 ), 2176 vec3( - 0.0728, - 0.0083, 1.1187 ) 2177); 2178const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( 2179 vec3( 0.6274, 0.0691, 0.0164 ), 2180 vec3( 0.3293, 0.9195, 0.0880 ), 2181 vec3( 0.0433, 0.0113, 0.8956 ) 2182); 2183vec3 agxDefaultContrastApprox( vec3 x ) { 2184 vec3 x2 = x * x; 2185 vec3 x4 = x2 * x2; 2186 return + 15.5 * x4 * x2 2187 - 40.14 * x4 * x 2188 + 31.96 * x4 2189 - 6.868 * x2 * x 2190 + 0.4298 * x2 2191 + 0.1191 * x 2192 - 0.00232; 2193} 2194vec3 AgXToneMapping( vec3 color ) { 2195 const mat3 AgXInsetMatrix = mat3( 2196 vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), 2197 vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), 2198 vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) 2199 );
2200 const mat3 AgXOutsetMatrix = mat3( 2201 vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), 2202 vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), 2203 vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) 2204 ); 2205 const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; 2206 color *= toneMappingExposure; 2207 color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; 2208 color = AgXInsetMatrix * color; 2209 color = max( color, 1e-10 ); color = log2( color ); 2210 color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); 2211 color = clamp( color, 0.0, 1.0 ); 2212 color = agxDefaultContrastApprox( color ); 2213 color = AgXOutsetMatrix * color; 2214 color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); 2215 color = LINEAR_REC2020_TO_LINEAR_SRGB * color; 2216 color = clamp( color, 0.0, 1.0 ); 2217 return color; 2218} 2219vec3 NeutralToneMapping( vec3 color ) { 2220 const float StartCompression = 0.8 - 0.04; 2221 const float Desaturation = 0.15; 2222 color *= toneMappingExposure; 2223 float x = min( color.r, min( color.g, color.b ) ); 2224 float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; 2225 color -= offset; 2226 float peak = max( color.r, max( color.g, color.b ) ); 2227 if ( peak < StartCompression ) return color; 2228 float d = 1. - StartCompression; 2229 float newPeak = 1. - d * d / ( peak + d - StartCompression ); 2230 color *= newPeak / peak; 2231 float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); 2232 return mix( color, vec3( newPeak ), g ); 2233} 2234vec3 CustomToneMapping( vec3 color ) { return color; }`,If=`#ifdef USE_TRANSMISSION 2235 material.transmission = transmission; 2236 material.transmissionAlpha = 1.0; 2237 material.thickness = thickness; 2238 material.attenuationDistance = attenuationDistance; 2239 material.attenuationColor = attenuationColor; 2240 #ifdef USE_TRANSMISSIONMAP 2241 material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; 2242 #endif 2243 #ifdef USE_THICKNESSMAP 2244 material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; 2245 #endif 2246 vec3 pos = vWorldPosition; 2247 vec3 v = normalize( cameraPosition - pos ); 2248 vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); 2249 vec4 transmitted = getIBLVolumeRefraction( 2250 n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, 2251 pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, 2252 material.attenuationColor, material.attenuationDistance ); 2253 material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); 2254 totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); 2255#endif`,Uf=`#ifdef USE_TRANSMISSION 2256 uniform float transmission; 2257 uniform float thickness; 2258 uniform float attenuationDistance; 2259 uniform vec3 attenuationColor; 2260 #ifdef USE_TRANSMISSIONMAP 2261 uniform sampler2D transmissionMap; 2262 #endif 2263 #ifdef USE_THICKNESSMAP 2264 uniform sampler2D thicknessMap; 2265 #endif 2266 uniform vec2 transmissionSamplerSize; 2267 uniform sampler2D transmissionSamplerMap; 2268 uniform mat4 modelMatrix; 2269 uniform mat4 projectionMatrix; 2270 varying vec3 vWorldPosition; 2271 float w0( float a ) { 2272 return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); 2273 } 2274 float w1( float a ) { 2275 return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); 2276 } 2277 float w2( float a ){ 2278 return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); 2279 } 2280 float w3( float a ) { 2281 return ( 1.0 / 6.0 ) * ( a * a * a ); 2282 } 2283 float g0( float a ) { 2284 return w0( a ) + w1( a ); 2285 } 2286 float g1( float a ) { 2287 return w2( a ) + w3( a ); 2288 } 2289 float h0( float a ) { 2290 return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); 2291 } 2292 float h1( float a ) { 2293 return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); 2294 } 2295 vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { 2296 uv = uv * texelSize.zw + 0.5; 2297 vec2 iuv = floor( uv ); 2298 vec2 fuv = fract( uv ); 2299 float g0x = g0( fuv.x ); 2300 float g1x = g1( fuv.x ); 2301 float h0x = h0( fuv.x ); 2302 float h1x = h1( fuv.x ); 2303 float h0y = h0( fuv.y ); 2304 float h1y = h1( fuv.y ); 2305 vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; 2306 vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; 2307 vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; 2308 vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; 2309 return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + 2310 g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); 2311 } 2312 vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { 2313 vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); 2314 vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); 2315 vec2 fLodSizeInv = 1.0 / fLodSize; 2316 vec2 cLodSizeInv = 1.0 / cLodSize; 2317 vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); 2318 vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); 2319 return mix( fSample, cSample, fract( lod ) ); 2320 } 2321 vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { 2322 vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); 2323 vec3 modelScale; 2324 modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); 2325 modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); 2326 modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); 2327 return normalize( refractionVector ) * thickness * modelScale; 2328 } 2329 float applyIorToRoughness( const in float roughness, const in float ior ) { 2330 return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); 2331 } 2332 vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { 2333 float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); 2334 return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); 2335 } 2336 vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { 2337 if ( isinf( attenuationDistance ) ) { 2338 return vec3( 1.0 ); 2339 } else { 2340 vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; 2341 vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; 2342 } 2343 } 2344 vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, 2345 const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, 2346 const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, 2347 const in vec3 attenuationColor, const in float attenuationDistance ) { 2348 vec4 transmittedLight; 2349 vec3 transmittance; 2350 #ifdef USE_DISPERSION 2351 float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; 2352 vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); 2353 for ( int i = 0; i < 3; i ++ ) { 2354 vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); 2355 vec3 refractedRayExit = position + transmissionRay; 2356 vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); 2357 vec2 refractionCoords = ndcPos.xy / ndcPos.w; 2358 refractionCoords += 1.0; 2359 refractionCoords /= 2.0; 2360 vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); 2361 transmittedLight[ i ] = transmissionSample[ i ]; 2362 transmittedLight.a += transmissionSample.a; 2363 transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; 2364 } 2365 transmittedLight.a /= 3.0; 2366 #else 2367 vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); 2368 vec3 refractedRayExit = position + transmissionRay; 2369 vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); 2370 vec2 refractionCoords = ndcPos.xy / ndcPos.w; 2371 refractionCoords += 1.0; 2372 refractionCoords /= 2.0; 2373 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); 2374 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); 2375 #endif 2376 vec3 attenuatedColor = transmittance * transmittedLight.rgb; 2377 vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); 2378 float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; 2379 return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); 2380 } 2381#endif`,Nf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2382 varying vec2 vUv; 2383#endif 2384#ifdef USE_MAP 2385 varying vec2 vMapUv; 2386#endif 2387#ifdef USE_ALPHAMAP
2388 varying vec2 vAlphaMapUv; 2389#endif 2390#ifdef USE_LIGHTMAP 2391 varying vec2 vLightMapUv; 2392#endif 2393#ifdef USE_AOMAP 2394 varying vec2 vAoMapUv; 2395#endif 2396#ifdef USE_BUMPMAP 2397 varying vec2 vBumpMapUv; 2398#endif 2399#ifdef USE_NORMALMAP 2400 varying vec2 vNormalMapUv; 2401#endif 2402#ifdef USE_EMISSIVEMAP 2403 varying vec2 vEmissiveMapUv; 2404#endif 2405#ifdef USE_METALNESSMAP 2406 varying vec2 vMetalnessMapUv; 2407#endif 2408#ifdef USE_ROUGHNESSMAP 2409 varying vec2 vRoughnessMapUv; 2410#endif 2411#ifdef USE_ANISOTROPYMAP 2412 varying vec2 vAnisotropyMapUv; 2413#endif 2414#ifdef USE_CLEARCOATMAP 2415 varying vec2 vClearcoatMapUv; 2416#endif 2417#ifdef USE_CLEARCOAT_NORMALMAP 2418 varying vec2 vClearcoatNormalMapUv; 2419#endif 2420#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2421 varying vec2 vClearcoatRoughnessMapUv; 2422#endif 2423#ifdef USE_IRIDESCENCEMAP 2424 varying vec2 vIridescenceMapUv; 2425#endif 2426#ifdef USE_IRIDESCENCE_THICKNESSMAP 2427 varying vec2 vIridescenceThicknessMapUv; 2428#endif 2429#ifdef USE_SHEEN_COLORMAP 2430 varying vec2 vSheenColorMapUv; 2431#endif 2432#ifdef USE_SHEEN_ROUGHNESSMAP 2433 varying vec2 vSheenRoughnessMapUv; 2434#endif 2435#ifdef USE_SPECULARMAP 2436 varying vec2 vSpecularMapUv; 2437#endif 2438#ifdef USE_SPECULAR_COLORMAP 2439 varying vec2 vSpecularColorMapUv; 2440#endif 2441#ifdef USE_SPECULAR_INTENSITYMAP 2442 varying vec2 vSpecularIntensityMapUv; 2443#endif 2444#ifdef USE_TRANSMISSIONMAP 2445 uniform mat3 transmissionMapTransform; 2446 varying vec2 vTransmissionMapUv; 2447#endif 2448#ifdef USE_THICKNESSMAP 2449 uniform mat3 thicknessMapTransform; 2450 varying vec2 vThicknessMapUv; 2451#endif`,Ff=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2452 varying vec2 vUv; 2453#endif 2454#ifdef USE_MAP 2455 uniform mat3 mapTransform; 2456 varying vec2 vMapUv; 2457#endif 2458#ifdef USE_ALPHAMAP 2459 uniform mat3 alphaMapTransform; 2460 varying vec2 vAlphaMapUv; 2461#endif 2462#ifdef USE_LIGHTMAP 2463 uniform mat3 lightMapTransform; 2464 varying vec2 vLightMapUv; 2465#endif 2466#ifdef USE_AOMAP 2467 uniform mat3 aoMapTransform; 2468 varying vec2 vAoMapUv; 2469#endif 2470#ifdef USE_BUMPMAP 2471 uniform mat3 bumpMapTransform; 2472 varying vec2 vBumpMapUv; 2473#endif 2474#ifdef USE_NORMALMAP 2475 uniform mat3 normalMapTransform; 2476 varying vec2 vNormalMapUv; 2477#endif 2478#ifdef USE_DISPLACEMENTMAP 2479 uniform mat3 displacementMapTransform; 2480 varying vec2 vDisplacementMapUv; 2481#endif 2482#ifdef USE_EMISSIVEMAP 2483 uniform mat3 emissiveMapTransform; 2484 varying vec2 vEmissiveMapUv; 2485#endif 2486#ifdef USE_METALNESSMAP 2487 uniform mat3 metalnessMapTransform; 2488 varying vec2 vMetalnessMapUv; 2489#endif 2490#ifdef USE_ROUGHNESSMAP 2491 uniform mat3 roughnessMapTransform; 2492 varying vec2 vRoughnessMapUv; 2493#endif 2494#ifdef USE_ANISOTROPYMAP 2495 uniform mat3 anisotropyMapTransform; 2496 varying vec2 vAnisotropyMapUv; 2497#endif 2498#ifdef USE_CLEARCOATMAP 2499 uniform mat3 clearcoatMapTransform; 2500 varying vec2 vClearcoatMapUv; 2501#endif 2502#ifdef USE_CLEARCOAT_NORMALMAP 2503 uniform mat3 clearcoatNormalMapTransform; 2504 varying vec2 vClearcoatNormalMapUv; 2505#endif 2506#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2507 uniform mat3 clearcoatRoughnessMapTransform; 2508 varying vec2 vClearcoatRoughnessMapUv; 2509#endif 2510#ifdef USE_SHEEN_COLORMAP 2511 uniform mat3 sheenColorMapTransform; 2512 varying vec2 vSheenColorMapUv; 2513#endif 2514#ifdef USE_SHEEN_ROUGHNESSMAP 2515 uniform mat3 sheenRoughnessMapTransform; 2516 varying vec2 vSheenRoughnessMapUv; 2517#endif 2518#ifdef USE_IRIDESCENCEMAP 2519 uniform mat3 iridescenceMapTransform; 2520 varying vec2 vIridescenceMapUv; 2521#endif 2522#ifdef USE_IRIDESCENCE_THICKNESSMAP 2523 uniform mat3 iridescenceThicknessMapTransform; 2524 varying vec2 vIridescenceThicknessMapUv; 2525#endif 2526#ifdef USE_SPECULARMAP 2527 uniform mat3 specularMapTransform; 2528 varying vec2 vSpecularMapUv; 2529#endif 2530#ifdef USE_SPECULAR_COLORMAP 2531 uniform mat3 specularColorMapTransform; 2532 varying vec2 vSpecularColorMapUv; 2533#endif 2534#ifdef USE_SPECULAR_INTENSITYMAP 2535 uniform mat3 specularIntensityMapTransform; 2536 varying vec2 vSpecularIntensityMapUv; 2537#endif 2538#ifdef USE_TRANSMISSIONMAP 2539 uniform mat3 transmissionMapTransform; 2540 varying vec2 vTransmissionMapUv; 2541#endif 2542#ifdef USE_THICKNESSMAP 2543 uniform mat3 thicknessMapTransform; 2544 varying vec2 vThicknessMapUv; 2545#endif`,Of=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) 2546 vUv = vec3( uv, 1 ).xy; 2547#endif 2548#ifdef USE_MAP 2549 vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; 2550#endif 2551#ifdef USE_ALPHAMAP 2552 vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; 2553#endif 2554#ifdef USE_LIGHTMAP 2555 vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; 2556#endif 2557#ifdef USE_AOMAP 2558 vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; 2559#endif 2560#ifdef USE_BUMPMAP 2561 vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; 2562#endif 2563#ifdef USE_NORMALMAP 2564 vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; 2565#endif 2566#ifdef USE_DISPLACEMENTMAP 2567 vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; 2568#endif 2569#ifdef USE_EMISSIVEMAP 2570 vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; 2571#endif 2572#ifdef USE_METALNESSMAP 2573 vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; 2574#endif 2575#ifdef USE_ROUGHNESSMAP 2576 vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; 2577#endif 2578#ifdef USE_ANISOTROPYMAP 2579 vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; 2580#endif 2581#ifdef USE_CLEARCOATMAP 2582 vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; 2583#endif 2584#ifdef USE_CLEARCOAT_NORMALMAP 2585 vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; 2586#endif 2587#ifdef USE_CLEARCOAT_ROUGHNESSMAP 2588 vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; 2589#endif
2590#ifdef USE_IRIDESCENCEMAP 2591 vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; 2592#endif 2593#ifdef USE_IRIDESCENCE_THICKNESSMAP 2594 vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; 2595#endif 2596#ifdef USE_SHEEN_COLORMAP 2597 vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; 2598#endif 2599#ifdef USE_SHEEN_ROUGHNESSMAP 2600 vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; 2601#endif 2602#ifdef USE_SPECULARMAP 2603 vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; 2604#endif 2605#ifdef USE_SPECULAR_COLORMAP 2606 vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; 2607#endif 2608#ifdef USE_SPECULAR_INTENSITYMAP 2609 vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; 2610#endif 2611#ifdef USE_TRANSMISSIONMAP 2612 vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; 2613#endif 2614#ifdef USE_THICKNESSMAP 2615 vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; 2616#endif`,Bf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 2617 vec4 worldPosition = vec4( transformed, 1.0 ); 2618 #ifdef USE_BATCHING 2619 worldPosition = batchingMatrix * worldPosition; 2620 #endif 2621 #ifdef USE_INSTANCING 2622 worldPosition = instanceMatrix * worldPosition; 2623 #endif 2624 worldPosition = modelMatrix * worldPosition; 2625#endif`;const zf=`varying vec2 vUv; 2626uniform mat3 uvTransform; 2627void main() { 2628 vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 2629 gl_Position = vec4( position.xy, 1.0, 1.0 ); 2630}`,Gf=`uniform sampler2D t2D; 2631uniform float backgroundIntensity; 2632varying vec2 vUv; 2633void main() { 2634 vec4 texColor = texture2D( t2D, vUv ); 2635 #ifdef DECODE_VIDEO_TEXTURE 2636 texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); 2637 #endif 2638 texColor.rgb *= backgroundIntensity; 2639 gl_FragColor = texColor; 2640 #include <tonemapping_fragment> 2641 #include <colorspace_fragment> 2642}`,Vf=`varying vec3 vWorldDirection; 2643#include <common> 2644void main() { 2645 vWorldDirection = transformDirection( position, modelMatrix ); 2646 #include <begin_vertex> 2647 #include <project_vertex> 2648 gl_Position.z = gl_Position.w; 2649}`,Hf=`#ifdef ENVMAP_TYPE_CUBE 2650 uniform samplerCube envMap; 2651#elif defined( ENVMAP_TYPE_CUBE_UV ) 2652 uniform sampler2D envMap; 2653#endif 2654uniform float backgroundBlurriness; 2655uniform float backgroundIntensity; 2656uniform mat3 backgroundRotation; 2657varying vec3 vWorldDirection; 2658#include <cube_uv_reflection_fragment> 2659void main() { 2660 #ifdef ENVMAP_TYPE_CUBE 2661 vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); 2662 #elif defined( ENVMAP_TYPE_CUBE_UV ) 2663 vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); 2664 #else 2665 vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); 2666 #endif 2667 texColor.rgb *= backgroundIntensity; 2668 gl_FragColor = texColor; 2669 #include <tonemapping_fragment> 2670 #include <colorspace_fragment> 2671}`,kf=`varying vec3 vWorldDirection; 2672#include <common> 2673void main() { 2674 vWorldDirection = transformDirection( position, modelMatrix ); 2675 #include <begin_vertex> 2676 #include <project_vertex> 2677 gl_Position.z = gl_Position.w; 2678}`,Wf=`uniform samplerCube tCube; 2679uniform float tFlip; 2680uniform float opacity; 2681varying vec3 vWorldDirection; 2682void main() { 2683 vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); 2684 gl_FragColor = texColor; 2685 gl_FragColor.a *= opacity; 2686 #include <tonemapping_fragment> 2687 #include <colorspace_fragment> 2688}`,Xf=`#include <common> 2689#include <batching_pars_vertex> 2690#include <uv_pars_vertex> 2691#include <displacementmap_pars_vertex> 2692#include <morphtarget_pars_vertex> 2693#include <skinning_pars_vertex> 2694#include <logdepthbuf_pars_vertex> 2695#include <clipping_planes_pars_vertex> 2696varying vec2 vHighPrecisionZW; 2697void main() { 2698 #include <uv_vertex> 2699 #include <batching_vertex> 2700 #include <skinbase_vertex> 2701 #include <morphinstance_vertex> 2702 #ifdef USE_DISPLACEMENTMAP 2703 #include <beginnormal_vertex> 2704 #include <morphnormal_vertex> 2705 #include <skinnormal_vertex> 2706 #endif 2707 #include <begin_vertex> 2708 #include <morphtarget_vertex> 2709 #include <skinning_vertex> 2710 #include <displacementmap_vertex> 2711 #include <project_vertex> 2712 #include <logdepthbuf_vertex> 2713 #include <clipping_planes_vertex> 2714 vHighPrecisionZW = gl_Position.zw; 2715}`,qf=`#if DEPTH_PACKING == 3200 2716 uniform float opacity; 2717#endif 2718#include <common> 2719#include <packing> 2720#include <uv_pars_fragment> 2721#include <map_pars_fragment> 2722#include <alphamap_pars_fragment> 2723#include <alphatest_pars_fragment> 2724#include <alphahash_pars_fragment> 2725#include <logdepthbuf_pars_fragment> 2726#include <clipping_planes_pars_fragment> 2727varying vec2 vHighPrecisionZW; 2728void main() { 2729 vec4 diffuseColor = vec4( 1.0 ); 2730 #include <clipping_planes_fragment> 2731 #if DEPTH_PACKING == 3200 2732 diffuseColor.a = opacity; 2733 #endif 2734 #include <map_fragment> 2735 #include <alphamap_fragment> 2736 #include <alphatest_fragment> 2737 #include <alphahash_fragment> 2738 #include <logdepthbuf_fragment> 2739 #ifdef USE_REVERSED_DEPTH_BUFFER 2740 float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; 2741 #else 2742 float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; 2743 #endif 2744 #if DEPTH_PACKING == 3200 2745 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); 2746 #elif DEPTH_PACKING == 3201 2747 gl_FragColor = packDepthToRGBA( fragCoordZ ); 2748 #elif DEPTH_PACKING == 3202 2749 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); 2750 #elif DEPTH_PACKING == 3203 2751 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); 2752 #endif 2753}`,Yf=`#define DISTANCE 2754varying vec3 vWorldPosition; 2755#include <common> 2756#include <batching_pars_vertex> 2757#include <uv_pars_vertex> 2758#include <displacementmap_pars_vertex> 2759#include <morphtarget_pars_vertex> 2760#include <skinning_pars_vertex> 2761#include <clipping_planes_pars_vertex> 2762void main() { 2763 #include <uv_vertex> 2764 #include <batching_vertex> 2765 #include <skinbase_vertex> 2766 #include <morphinstance_vertex> 2767 #ifdef USE_DISPLACEMENTMAP 2768 #include <beginnormal_vertex> 2769 #include <morphnormal_vertex> 2770 #include <skinnormal_vertex> 2771 #endif 2772 #include <begin_vertex> 2773 #include <morphtarget_vertex> 2774 #include <skinning_vertex> 2775 #include <displacementmap_vertex> 2776 #include <project_vertex> 2777 #include <worldpos_vertex> 2778 #include <clipping_planes_vertex> 2779 vWorldPosition = worldPosition.xyz; 2780}`,Kf=`#define DISTANCE 2781uniform vec3 referencePosition; 2782uniform float nearDistance; 2783uniform float farDistance; 2784varying vec3 vWorldPosition; 2785#include <common> 2786#include <uv_pars_fragment> 2787#include <map_pars_fragment> 2788#include <alphamap_pars_fragment> 2789#include <alphatest_pars_fragment> 2790#include <alphahash_pars_fragment> 2791#include <clipping_planes_pars_fragment> 2792void main() { 2793 vec4 diffuseColor = vec4( 1.0 ); 2794 #include <clipping_planes_fragment> 2795 #include <map_fragment> 2796 #include <alphamap_fragment> 2797 #include <alphatest_fragment> 2798 #include <alphahash_fragment> 2799 float dist = length( vWorldPosition - referencePosition ); 2800 dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); 2801 dist = saturate( dist ); 2802 gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); 2803}`,Zf=`varying vec3 vWorldDirection; 2804#include <common> 2805void main() { 2806 vWorldDirection = transformDirection( position, modelMatrix ); 2807 #include <begin_vertex> 2808 #include <project_vertex> 2809}`,$f=`uniform sampler2D tEquirect; 2810varying vec3 vWorldDirection; 2811#include <common> 2812void main() { 2813 vec3 direction = normalize( vWorldDirection ); 2814 vec2 sampleUV = equirectUv( direction ); 2815 gl_FragColor = texture2D( tEquirect, sampleUV ); 2816 #include <tonemapping_fragment> 2817 #include <colorspace_fragment> 2818}`,Jf=`uniform float scale; 2819attribute float lineDistance; 2820varying float vLineDistance; 2821#include <common> 2822#include <uv_pars_vertex> 2823#include <color_pars_vertex> 2824#include <fog_pars_vertex> 2825#include <morphtarget_pars_vertex> 2826#include <logdepthbuf_pars_vertex> 2827#include <clipping_planes_pars_vertex> 2828void main() { 2829 vLineDistance = scale * lineDistance; 2830 #include <uv_vertex> 2831 #include <color_vertex> 2832 #include <morphinstance_vertex> 2833 #include <morphcolor_vertex> 2834 #include <begin_vertex> 2835 #include <morphtarget_vertex> 2836 #include <project_vertex> 2837 #include <logdepthbuf_vertex> 2838 #include <clipping_planes_vertex> 2839 #include <fog_vertex> 2840}`,Qf=`uniform vec3 diffuse; 2841uniform float opacity; 2842uniform float dashSize; 2843uniform float totalSize; 2844varying float vLineDistance; 2845#include <common> 2846#include <color_pars_fragment> 2847#include <uv_pars_fragment> 2848#include <map_pars_fragment> 2849#include <fog_pars_fragment> 2850#include <logdepthbuf_pars_fragment> 2851#include <clipping_planes_pars_fragment> 2852void main() { 2853 vec4 diffuseColor = vec4( diffuse, opacity ); 2854 #include <clipping_planes_fragment> 2855 if ( mod( vLineDistance, totalSize ) > dashSize ) { 2856 discard; 2857 } 2858 vec3 outgoingLight = vec3( 0.0 ); 2859 #include <logdepthbuf_fragment> 2860 #include <map_fragment> 2861 #include <color_fragment> 2862 outgoingLight = diffuseColor.rgb; 2863 #include <opaque_fragment> 2864 #include <tonemapping_fragment> 2865 #include <colorspace_fragment> 2866 #include <fog_fragment> 2867 #include <premultiplied_alpha_fragment> 2868}`,jf=`#include <common> 2869#include <batching_pars_vertex> 2870#include <uv_pars_vertex> 2871#include <envmap_pars_vertex> 2872#include <color_pars_vertex> 2873#include <fog_pars_vertex> 2874#include <morphtarget_pars_vertex> 2875#include <skinning_pars_vertex> 2876#include <logdepthbuf_pars_vertex> 2877#include <clipping_planes_pars_vertex> 2878void main() { 2879 #include <uv_vertex> 2880 #include <color_vertex> 2881 #include <morphinstance_vertex> 2882 #include <morphcolor_vertex> 2883 #include <batching_vertex> 2884 #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) 2885 #include <beginnormal_vertex> 2886 #include <morphnormal_vertex> 2887 #include <skinbase_vertex> 2888 #include <skinnormal_vertex> 2889 #include <defaultnormal_vertex> 2890 #endif 2891 #include <begin_vertex> 2892 #include <morphtarget_vertex> 2893 #include <skinning_vertex> 2894 #include <project_vertex> 2895 #include <logdepthbuf_vertex> 2896 #include <clipping_planes_vertex> 2897 #include <worldpos_vertex> 2898 #include <envmap_vertex> 2899 #include <fog_vertex> 2900}`,ed=`uniform vec3 diffuse; 2901uniform float opacity; 2902#ifndef FLAT_SHADED 2903 varying vec3 vNormal; 2904#endif 2905#include <common> 2906#include <dithering_pars_fragment> 2907#include <color_pars_fragment> 2908#include <uv_pars_fragment> 2909#include <map_pars_fragment> 2910#include <alphamap_pars_fragment> 2911#include <alphatest_pars_fragment> 2912#include <alphahash_pars_fragment> 2913#include <aomap_pars_fragment> 2914#include <lightmap_pars_fragment> 2915#include <envmap_common_pars_fragment> 2916#include <envmap_pars_fragment> 2917#include <fog_pars_fragment> 2918#include <specularmap_pars_fragment> 2919#include <logdepthbuf_pars_fragment> 2920#include <clipping_planes_pars_fragment> 2921void main() { 2922 vec4 diffuseColor = vec4( diffuse, opacity ); 2923 #include <clipping_planes_fragment> 2924 #include <logdepthbuf_fragment> 2925 #include <map_fragment> 2926 #include <color_fragment> 2927 #include <alphamap_fragment> 2928 #include <alphatest_fragment> 2929 #include <alphahash_fragment> 2930 #include <specularmap_fragment> 2931 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 2932 #ifdef USE_LIGHTMAP 2933 vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 2934 reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; 2935 #else 2936 reflectedLight.indirectDiffuse += vec3( 1.0 ); 2937 #endif 2938 #include <aomap_fragment> 2939 reflectedLight.indirectDiffuse *= diffuseColor.rgb; 2940 vec3 outgoingLight = reflectedLight.indirectDiffuse; 2941 #include <envmap_fragment> 2942 #include <opaque_fragment> 2943 #include <tonemapping_fragment> 2944 #include <colorspace_fragment> 2945 #include <fog_fragment> 2946 #include <premultiplied_alpha_fragment> 2947 #include <dithering_fragment> 2948}`,td=`#define LAMBERT 2949varying vec3 vViewPosition; 2950#include <common> 2951#include <batching_pars_vertex> 2952#include <uv_pars_vertex> 2953#include <displacementmap_pars_vertex> 2954#include <envmap_pars_vertex> 2955#include <color_pars_vertex> 2956#include <fog_pars_vertex> 2957#include <normal_pars_vertex> 2958#include <morphtarget_pars_vertex> 2959#include <skinning_pars_vertex> 2960#include <shadowmap_pars_vertex> 2961#include <logdepthbuf_pars_vertex> 2962#include <clipping_planes_pars_vertex> 2963void main() { 2964 #include <uv_vertex> 2965 #include <color_vertex> 2966 #include <morphinstance_vertex> 2967 #include <morphcolor_vertex> 2968 #include <batching_vertex> 2969 #include <beginnormal_vertex> 2970 #include <morphnormal_vertex> 2971 #include <skinbase_vertex> 2972 #include <skinnormal_vertex> 2973 #include <defaultnormal_vertex> 2974 #include <normal_vertex> 2975 #include <begin_vertex> 2976 #include <morphtarget_vertex> 2977 #include <skinning_vertex> 2978 #include <displacementmap_vertex> 2979 #include <project_vertex> 2980 #include <logdepthbuf_vertex> 2981 #include <clipping_planes_vertex> 2982 vViewPosition = - mvPosition.xyz; 2983 #include <worldpos_vertex> 2984 #include <envmap_vertex> 2985 #include <shadowmap_vertex> 2986 #include <fog_vertex> 2987}`,nd=`#define LAMBERT 2988uniform vec3 diffuse; 2989uniform vec3 emissive; 2990uniform float opacity; 2991#include <common> 2992#include <dithering_pars_fragment> 2993#include <color_pars_fragment> 2994#include <uv_pars_fragment> 2995#include <map_pars_fragment> 2996#include <alphamap_pars_fragment> 2997#include <alphatest_pars_fragment> 2998#include <alphahash_pars_fragment> 2999#include <aomap_pars_fragment> 3000#include <lightmap_pars_fragment> 3001#include <emissivemap_pars_fragment> 3002#include <cube_uv_reflection_fragment> 3003#include <envmap_common_pars_fragment> 3004#include <envmap_pars_fragment> 3005#include <envmap_physical_pars_fragment> 3006#include <fog_pars_fragment> 3007#include <bsdfs> 3008#include <lights_pars_begin> 3009#include <normal_pars_fragment> 3010#include <lights_lambert_pars_fragment> 3011#include <shadowmap_pars_fragment> 3012#include <bumpmap_pars_fragment> 3013#include <normalmap_pars_fragment> 3014#include <specularmap_pars_fragment> 3015#include <logdepthbuf_pars_fragment> 3016#include <clipping_planes_pars_fragment> 3017void main() { 3018 vec4 diffuseColor = vec4( diffuse, opacity ); 3019 #include <clipping_planes_fragment> 3020 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3021 vec3 totalEmissiveRadiance = emissive; 3022 #include <logdepthbuf_fragment> 3023 #include <map_fragment> 3024 #include <color_fragment> 3025 #include <alphamap_fragment> 3026 #include <alphatest_fragment> 3027 #include <alphahash_fragment> 3028 #include <specularmap_fragment> 3029 #include <normal_fragment_begin> 3030 #include <normal_fragment_maps> 3031 #include <emissivemap_fragment> 3032 #include <lights_lambert_fragment> 3033 #include <lights_fragment_begin> 3034 #include <lights_fragment_maps> 3035 #include <lights_fragment_end> 3036 #include <aomap_fragment> 3037 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; 3038 #include <envmap_fragment> 3039 #include <opaque_fragment> 3040 #include <tonemapping_fragment> 3041 #include <colorspace_fragment> 3042 #include <fog_fragment> 3043 #include <premultiplied_alpha_fragment> 3044 #include <dithering_fragment> 3045}`,id=`#define MATCAP 3046varying vec3 vViewPosition; 3047#include <common> 3048#include <batching_pars_vertex> 3049#include <uv_pars_vertex> 3050#include <color_pars_vertex> 3051#include <displacementmap_pars_vertex> 3052#include <fog_pars_vertex> 3053#include <normal_pars_vertex> 3054#include <morphtarget_pars_vertex> 3055#include <skinning_pars_vertex> 3056#include <logdepthbuf_pars_vertex> 3057#include <clipping_planes_pars_vertex> 3058void main() { 3059 #include <uv_vertex> 3060 #include <color_vertex> 3061 #include <morphinstance_vertex> 3062 #include <morphcolor_vertex> 3063 #include <batching_vertex> 3064 #include <beginnormal_vertex> 3065 #include <morphnormal_vertex> 3066 #include <skinbase_vertex> 3067 #include <skinnormal_vertex> 3068 #include <defaultnormal_vertex> 3069 #include <normal_vertex> 3070 #include <begin_vertex> 3071 #include <morphtarget_vertex> 3072 #include <skinning_vertex> 3073 #include <displacementmap_vertex> 3074 #include <project_vertex> 3075 #include <logdepthbuf_vertex> 3076 #include <clipping_planes_vertex> 3077 #include <fog_vertex> 3078 vViewPosition = - mvPosition.xyz; 3079}`,rd=`#define MATCAP 3080uniform vec3 diffuse; 3081uniform float opacity; 3082uniform sampler2D matcap; 3083varying vec3 vViewPosition; 3084#include <common> 3085#include <dithering_pars_fragment> 3086#include <color_pars_fragment> 3087#include <uv_pars_fragment> 3088#include <map_pars_fragment> 3089#include <alphamap_pars_fragment> 3090#include <alphatest_pars_fragment> 3091#include <alphahash_pars_fragment> 3092#include <fog_pars_fragment> 3093#include <normal_pars_fragment> 3094#include <bumpmap_pars_fragment> 3095#include <normalmap_pars_fragmen
3095t> 3096#include <logdepthbuf_pars_fragment> 3097#include <clipping_planes_pars_fragment> 3098void main() { 3099 vec4 diffuseColor = vec4( diffuse, opacity ); 3100 #include <clipping_planes_fragment> 3101 #include <logdepthbuf_fragment> 3102 #include <map_fragment> 3103 #include <color_fragment> 3104 #include <alphamap_fragment> 3105 #include <alphatest_fragment> 3106 #include <alphahash_fragment> 3107 #include <normal_fragment_begin> 3108 #include <normal_fragment_maps> 3109 vec3 viewDir = normalize( vViewPosition ); 3110 vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); 3111 vec3 y = cross( viewDir, x ); 3112 vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; 3113 #ifdef USE_MATCAP 3114 vec4 matcapColor = texture2D( matcap, uv ); 3115 #else 3116 vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); 3117 #endif 3118 vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; 3119 #include <opaque_fragment> 3120 #include <tonemapping_fragment> 3121 #include <colorspace_fragment> 3122 #include <fog_fragment> 3123 #include <premultiplied_alpha_fragment> 3124 #include <dithering_fragment> 3125}`,sd=`#define NORMAL 3126#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3127 varying vec3 vViewPosition; 3128#endif 3129#include <common> 3130#include <batching_pars_vertex> 3131#include <uv_pars_vertex> 3132#include <displacementmap_pars_vertex> 3133#include <normal_pars_vertex> 3134#include <morphtarget_pars_vertex> 3135#include <skinning_pars_vertex> 3136#include <logdepthbuf_pars_vertex> 3137#include <clipping_planes_pars_vertex> 3138void main() { 3139 #include <uv_vertex> 3140 #include <batching_vertex> 3141 #include <beginnormal_vertex> 3142 #include <morphinstance_vertex> 3143 #include <morphnormal_vertex> 3144 #include <skinbase_vertex> 3145 #include <skinnormal_vertex> 3146 #include <defaultnormal_vertex> 3147 #include <normal_vertex> 3148 #include <begin_vertex> 3149 #include <morphtarget_vertex> 3150 #include <skinning_vertex> 3151 #include <displacementmap_vertex> 3152 #include <project_vertex> 3153 #include <logdepthbuf_vertex> 3154 #include <clipping_planes_vertex> 3155#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3156 vViewPosition = - mvPosition.xyz; 3157#endif 3158}`,ad=`#define NORMAL 3159uniform float opacity; 3160#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 3161 varying vec3 vViewPosition; 3162#endif 3163#include <uv_pars_fragment> 3164#include <normal_pars_fragment> 3165#include <bumpmap_pars_fragment> 3166#include <normalmap_pars_fragment> 3167#include <logdepthbuf_pars_fragment> 3168#include <clipping_planes_pars_fragment> 3169void main() { 3170 vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); 3171 #include <clipping_planes_fragment> 3172 #include <logdepthbuf_fragment> 3173 #include <normal_fragment_begin> 3174 #include <normal_fragment_maps> 3175 gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); 3176 #ifdef OPAQUE 3177 gl_FragColor.a = 1.0; 3178 #endif 3179}`,od=`#define PHONG 3180varying vec3 vViewPosition; 3181#include <common> 3182#include <batching_pars_vertex> 3183#include <uv_pars_vertex> 3184#include <displacementmap_pars_vertex> 3185#include <envmap_pars_vertex> 3186#include <color_pars_vertex> 3187#include <fog_pars_vertex> 3188#include <normal_pars_vertex> 3189#include <morphtarget_pars_vertex> 3190#include <skinning_pars_vertex> 3191#include <shadowmap_pars_vertex> 3192#include <logdepthbuf_pars_vertex> 3193#include <clipping_planes_pars_vertex> 3194void main() { 3195 #include <uv_vertex> 3196 #include <color_vertex> 3197 #include <morphcolor_vertex> 3198 #include <batching_vertex> 3199 #include <beginnormal_vertex> 3200 #include <morphinstance_vertex> 3201 #include <morphnormal_vertex> 3202 #include <skinbase_vertex> 3203 #include <skinnormal_vertex> 3204 #include <defaultnormal_vertex> 3205 #include <normal_vertex> 3206 #include <begin_vertex> 3207 #include <morphtarget_vertex> 3208 #include <skinning_vertex> 3209 #include <displacementmap_vertex> 3210 #include <project_vertex> 3211 #include <logdepthbuf_vertex> 3212 #include <clipping_planes_vertex> 3213 vViewPosition = - mvPosition.xyz; 3214 #include <worldpos_vertex> 3215 #include <envmap_vertex> 3216 #include <shadowmap_vertex> 3217 #include <fog_vertex> 3218}`,ld=`#define PHONG 3219uniform vec3 diffuse; 3220uniform vec3 emissive; 3221uniform vec3 specular; 3222uniform float shininess; 3223uniform float opacity; 3224#include <common> 3225#include <dithering_pars_fragment> 3226#include <color_pars_fragment> 3227#include <uv_pars_fragment> 3228#include <map_pars_fragment> 3229#include <alphamap_pars_fragment> 3230#include <alphatest_pars_fragment> 3231#include <alphahash_pars_fragment> 3232#include <aomap_pars_fragment> 3233#include <lightmap_pars_fragment> 3234#include <emissivemap_pars_fragment> 3235#include <cube_uv_reflection_fragment> 3236#include <envmap_common_pars_fragment> 3237#include <envmap_pars_fragment> 3238#include <envmap_physical_pars_fragment> 3239#include <fog_pars_fragment> 3240#include <bsdfs> 3241#include <lights_pars_begin> 3242#include <normal_pars_fragment> 3243#include <lights_phong_pars_fragment> 3244#include <shadowmap_pars_fragment> 3245#include <bumpmap_pars_fragment> 3246#include <normalmap_pars_fragment> 3247#include <specularmap_pars_fragment> 3248#include <logdepthbuf_pars_fragment> 3249#include <clipping_planes_pars_fragment> 3250void main() { 3251 vec4 diffuseColor = vec4( diffuse, opacity ); 3252 #include <clipping_planes_fragment> 3253 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3254 vec3 totalEmissiveRadiance = emissive; 3255 #include <logdepthbuf_fragment> 3256 #include <map_fragment> 3257 #include <color_fragment> 3258 #include <alphamap_fragment> 3259 #include <alphatest_fragment> 3260 #include <alphahash_fragment> 3261 #include <specularmap_fragment> 3262 #include <normal_fragment_begin> 3263 #include <normal_fragment_maps> 3264 #include <emissivemap_fragment> 3265 #include <lights_phong_fragment> 3266 #include <lights_fragment_begin> 3267 #include <lights_fragment_maps> 3268 #include <lights_fragment_end> 3269 #include <aomap_fragment> 3270 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; 3271 #include <envmap_fragment> 3272 #include <opaque_fragment> 3273 #include <tonemapping_fragment> 3274 #include <colorspace_fragment> 3275 #include <fog_fragment> 3276 #include <premultiplied_alpha_fragment> 3277 #include <dithering_fragment> 3278}`,cd=`#define STANDARD 3279varying vec3 vViewPosition; 3280#ifdef USE_TRANSMISSION 3281 varying vec3 vWorldPosition; 3282#endif 3283#include <common> 3284#include <batching_pars_vertex> 3285#include <uv_pars_vertex> 3286#include <displacementmap_pars_vertex> 3287#include <color_pars_vertex> 3288#include <fog_pars_vertex> 3289#include <normal_pars_vertex> 3290#include <morphtarget_pars_vertex> 3291#include <skinning_pars_vertex> 3292#include <shadowmap_pars_vertex> 3293#include <logdepthbuf_pars_vertex> 3294#include <clipping_planes_pars_vertex> 3295void main() { 3296 #include <uv_vertex> 3297 #include <color_vertex> 3298 #include <morphinstance_vertex> 3299 #include <morphcolor_vertex> 3300 #include <batching_vertex> 3301 #include <beginnormal_vertex> 3302 #include <morphnormal_vertex> 3303 #include <skinbase_vertex> 3304 #include <skinnormal_vertex> 3305 #include <defaultnormal_vertex> 3306 #include <normal_vertex> 3307 #include <begin_vertex> 3308 #include <morphtarget_vertex> 3309 #include <skinning_vertex> 3310 #include <displacementmap_vertex> 3311 #include <project_vertex> 3312 #include <logdepthbuf_vertex> 3313 #include <clipping_planes_vertex> 3314 vViewPosition = - mvPosition.xyz; 3315 #include <worldpos_vertex> 3316 #include <shadowmap_vertex> 3317 #include <fog_vertex> 3318#ifdef USE_TRANSMISSION 3319 vWorldPosition = worldPosition.xyz; 3320#endif 3321}`,ud=`#define STANDARD 3322#ifdef PHYSICAL 3323 #define IOR 3324 #define USE_SPECULAR 3325#endif 3326uniform vec3 diffuse; 3327uniform vec3 emissive; 3328uniform float roughness; 3329uniform float metalness; 3330uniform float opacity; 3331#ifdef IOR 3332 uniform float ior; 3333#endif 3334#ifdef USE_SPECULAR 3335 uniform float specularIntensity; 3336 uniform vec3 specularColor; 3337 #ifdef USE_SPECULAR_COLORMAP 3338 uniform sampler2D specularColorMap; 3339 #endif 3340 #ifdef USE_SPECULAR_INTENSITYMAP 3341 uniform sampler2D specularIntensityMap; 3342 #endif 3343#endif 3344#ifdef USE_CLEARCOAT 3345 uniform float clearcoat; 3346 uniform float clearcoatRoughness; 3347#endif 3348#ifdef USE_DISPERSION 3349 uniform float dispersion; 3350#endif
3351#ifdef USE_IRIDESCENCE 3352 uniform float iridescence; 3353 uniform float iridescenceIOR; 3354 uniform float iridescenceThicknessMinimum; 3355 uniform float iridescenceThicknessMaximum; 3356#endif 3357#ifdef USE_SHEEN 3358 uniform vec3 sheenColor; 3359 uniform float sheenRoughness; 3360 #ifdef USE_SHEEN_COLORMAP 3361 uniform sampler2D sheenColorMap; 3362 #endif 3363 #ifdef USE_SHEEN_ROUGHNESSMAP 3364 uniform sampler2D sheenRoughnessMap; 3365 #endif 3366#endif 3367#ifdef USE_ANISOTROPY 3368 uniform vec2 anisotropyVector; 3369 #ifdef USE_ANISOTROPYMAP 3370 uniform sampler2D anisotropyMap; 3371 #endif 3372#endif 3373varying vec3 vViewPosition; 3374#include <common> 3375#include <dithering_pars_fragment> 3376#include <color_pars_fragment> 3377#include <uv_pars_fragment> 3378#include <map_pars_fragment> 3379#include <alphamap_pars_fragment> 3380#include <alphatest_pars_fragment> 3381#include <alphahash_pars_fragment> 3382#include <aomap_pars_fragment> 3383#include <lightmap_pars_fragment> 3384#include <emissivemap_pars_fragment> 3385#include <iridescence_fragment> 3386#include <cube_uv_reflection_fragment> 3387#include <envmap_common_pars_fragment> 3388#include <envmap_physical_pars_fragment> 3389#include <fog_pars_fragment> 3390#include <lights_pars_begin> 3391#include <normal_pars_fragment> 3392#include <lights_physical_pars_fragment> 3393#include <transmission_pars_fragment> 3394#include <shadowmap_pars_fragment> 3395#include <bumpmap_pars_fragment> 3396#include <normalmap_pars_fragment> 3397#include <clearcoat_pars_fragment> 3398#include <iridescence_pars_fragment> 3399#include <roughnessmap_pars_fragment> 3400#include <metalnessmap_pars_fragment> 3401#include <logdepthbuf_pars_fragment> 3402#include <clipping_planes_pars_fragment> 3403void main() { 3404 vec4 diffuseColor = vec4( diffuse, opacity ); 3405 #include <clipping_planes_fragment> 3406 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3407 vec3 totalEmissiveRadiance = emissive; 3408 #include <logdepthbuf_fragment> 3409 #include <map_fragment> 3410 #include <color_fragment> 3411 #include <alphamap_fragment> 3412 #include <alphatest_fragment> 3413 #include <alphahash_fragment> 3414 #include <roughnessmap_fragment> 3415 #include <metalnessmap_fragment> 3416 #include <normal_fragment_begin> 3417 #include <normal_fragment_maps> 3418 #include <clearcoat_normal_fragment_begin> 3419 #include <clearcoat_normal_fragment_maps> 3420 #include <emissivemap_fragment> 3421 #include <lights_physical_fragment> 3422 #include <lights_fragment_begin> 3423 #include <lights_fragment_maps> 3424 #include <lights_fragment_end> 3425 #include <aomap_fragment> 3426 vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; 3427 vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; 3428 #include <transmission_fragment> 3429 vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; 3430 #ifdef USE_SHEEN 3431 3432 outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; 3433 3434 #endif 3435 #ifdef USE_CLEARCOAT 3436 float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); 3437 vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); 3438 outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; 3439 #endif 3440 #include <opaque_fragment> 3441 #include <tonemapping_fragment> 3442 #include <colorspace_fragment> 3443 #include <fog_fragment> 3444 #include <premultiplied_alpha_fragment> 3445 #include <dithering_fragment> 3446}`,hd=`#define TOON 3447varying vec3 vViewPosition; 3448#include <common> 3449#include <batching_pars_vertex> 3450#include <uv_pars_vertex> 3451#include <displacementmap_pars_vertex> 3452#include <color_pars_vertex> 3453#include <fog_pars_vertex> 3454#include <normal_pars_vertex> 3455#include <morphtarget_pars_vertex> 3456#include <skinning_pars_vertex> 3457#include <shadowmap_pars_vertex> 3458#include <logdepthbuf_pars_vertex> 3459#include <clipping_planes_pars_vertex> 3460void main() { 3461 #include <uv_vertex> 3462 #include <color_vertex> 3463 #include <morphinstance_vertex> 3464 #include <morphcolor_vertex> 3465 #include <batching_vertex> 3466 #include <beginnormal_vertex> 3467 #include <morphnormal_vertex> 3468 #include <skinbase_vertex> 3469 #include <skinnormal_vertex> 3470 #include <defaultnormal_vertex> 3471 #include <normal_vertex> 3472 #include <begin_vertex> 3473 #include <morphtarget_vertex> 3474 #include <skinning_vertex> 3475 #include <displacementmap_vertex> 3476 #include <project_vertex> 3477 #include <logdepthbuf_vertex> 3478 #include <clipping_planes_vertex> 3479 vViewPosition = - mvPosition.xyz; 3480 #include <worldpos_vertex> 3481 #include <shadowmap_vertex> 3482 #include <fog_vertex> 3483}`,fd=`#define TOON 3484uniform vec3 diffuse; 3485uniform vec3 emissive; 3486uniform float opacity; 3487#include <common> 3488#include <dithering_pars_fragment> 3489#include <color_pars_fragment> 3490#include <uv_pars_fragment> 3491#include <map_pars_fragment> 3492#include <alphamap_pars_fragment> 3493#include <alphatest_pars_fragment> 3494#include <alphahash_pars_fragment> 3495#include <aomap_pars_fragment> 3496#include <lightmap_pars_fragment> 3497#include <emissivemap_pars_fragment> 3498#include <gradientmap_pars_fragment> 3499#include <fog_pars_fragment> 3500#include <bsdfs> 3501#include <lights_pars_begin> 3502#include <normal_pars_fragment> 3503#include <lights_toon_pars_fragment> 3504#include <shadowmap_pars_fragment> 3505#include <bumpmap_pars_fragment> 3506#include <normalmap_pars_fragment> 3507#include <logdepthbuf_pars_fragment> 3508#include <clipping_planes_pars_fragment> 3509void main() { 3510 vec4 diffuseColor = vec4( diffuse, opacity ); 3511 #include <clipping_planes_fragment> 3512 ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 3513 vec3 totalEmissiveRadiance = emissive; 3514 #include <logdepthbuf_fragment> 3515 #include <map_fragment> 3516 #include <color_fragment> 3517 #include <alphamap_fragment> 3518 #include <alphatest_fragment> 3519 #include <alphahash_fragment> 3520 #include <normal_fragment_begin> 3521 #include <normal_fragment_maps> 3522 #include <emissivemap_fragment> 3523 #include <lights_toon_fragment> 3524 #include <lights_fragment_begin> 3525 #include <lights_fragment_maps> 3526 #include <lights_fragment_end> 3527 #include <aomap_fragment> 3528 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; 3529 #include <opaque_fragment> 3530 #include <tonemapping_fragment> 3531 #include <colorspace_fragment> 3532 #include <fog_fragment> 3533 #include <premultiplied_alpha_fragment> 3534 #include <dithering_fragment> 3535}`,dd=`uniform float size; 3536uniform float scale; 3537#include <common> 3538#include <color_pars_vertex> 3539#include <fog_pars_vertex> 3540#include <morphtarget_pars_vertex> 3541#include <logdepthbuf_pars_vertex> 3542#include <clipping_planes_pars_vertex> 3543#ifdef USE_POINTS_UV 3544 varying vec2 vUv; 3545 uniform mat3 uvTransform; 3546#endif 3547void main() { 3548 #ifdef USE_POINTS_UV 3549 vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 3550 #endif 3551 #include <color_vertex> 3552 #include <morphinstance_vertex> 3553 #include <morphcolor_vertex> 3554 #include <begin_vertex> 3555 #include <morphtarget_vertex> 3556 #include <project_vertex> 3557 gl_PointSize = size; 3558 #ifdef USE_SIZEATTENUATION 3559 bool isPerspective = isPerspectiveMatrix( projectionMatrix ); 3560 if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); 3561 #endif 3562 #include <logdepthbuf_vertex> 3563 #include <clipping_planes_vertex> 3564 #include <worldpos_vertex> 3565 #include <fog_vertex> 3566}`,pd=`uniform vec3 diffuse; 3567uniform float opacity; 3568#include <common> 3569#include <color_pars_fragment> 3570#include <map_particle_pars_fragment> 3571#include <alphatest_pars_fragment> 3572#include <alphahash_pars_fragment> 3573#include <fog_pars_fragment> 3574#include <logdepthbuf_pars_fragment> 3575#include <clipping_planes_pars_fragment> 3576void main() { 3577 vec4 diffuseColor = vec4( diffuse, opacity ); 3578 #include <clipping_planes_fragment> 3579 vec3 outgoingLight = vec3( 0.0 ); 3580 #include <logdepthbuf_fragment> 3581 #include <map_particle_fragment> 3582 #include <color_fragment> 3583 #include <alphatest_fragment> 3584 #include <alphahash_fragment> 3585 outgoingLight = diffuseColor.rgb; 3586 #include <opaque_fragment> 3587 #include <tonemapping_fragment> 3588 #include <colorspace_fragment> 3589 #include <fog_fragment> 3590 #include <premultiplied_alpha_fragment> 3591}`,md=`#include <common> 3592#include <batching_pars_vertex> 3593#include <fog_pars_vertex> 3594#include <morphtarget_pars_vertex> 3595#include <skinning_pars_vertex> 3596#include <logdepthbuf_pars_vertex> 3597#include <shadowmap_pars_vertex> 3598void main() { 3599 #include <batching_vertex> 3600 #include <beginnormal_vertex> 3601 #include <morphinstance_vertex> 3602 #include <morphnormal_vertex> 3603 #include <skinbase_vertex> 3604 #include <skinnormal_vertex> 3605 #include <defaultnormal_vertex> 3606 #include <begin_vertex> 3607 #include <morphtarget_vertex> 3608 #include <skinning_vertex> 3609 #include <project_vertex> 3610 #include <logdepthbuf_vertex> 3611 #include <worldpos_vertex> 3612 #include <shadowmap_vertex> 3613 #include <fog_vertex> 3614}`,gd=`uniform vec3 color; 3615uniform float opacity; 3616#include <common> 3617#include <fog_pars_fragment> 3618#include <bsdfs> 3619#include <lights_pars_begin> 3620#include <logdepthbuf_pars_fragment> 3621#include <shadowmap_pars_fragment> 3622#include <shadowmask_pars_fragment> 3623void main() { 3624 #include <logdepthbuf_fragment> 3625 gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); 3626 #include <tonemapping_fragment> 3627 #include <colorspace_fragment> 3628 #include <fog_fragment> 3629 #include <premultiplied_alpha_fragment> 3630}`,_d=`uniform float rotation; 3631uniform vec2 center; 3632#include <common> 3633#include <uv_pars_vertex> 3634#include <fog_pars_vertex> 3635#include <logdepthbuf_pars_vertex> 3636#include <clipping_planes_pars_vertex> 3637void main() { 3638 #include <uv_vertex> 3639 vec4 mvPosition = modelViewMatrix[ 3 ]; 3640 vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); 3641 #ifndef USE_SIZEATTENUATION 3642 bool isPerspective = isPerspectiveMatrix( projectionMatrix ); 3643 if ( isPerspective ) scale *= - mvPosition.z; 3644 #endif 3645 vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; 3646 vec2 rotatedPosition; 3647 rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; 3648 rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; 3649 mvPosition.xy += rotatedPosition; 3650 gl_Position = projectionMatrix * mvPosition; 3651 #include <logdepthbuf_vertex> 3652 #include <clipping_planes_vertex> 3653 #include <fog_vertex> 3654}`,xd=`uniform vec3 diffuse; 3655uniform float opacity; 3656#include <common> 3657#include <uv_pars_fragment> 3658#include <map_pars_fragment> 3659#include <alphamap_pars_fragment> 3660#include <alphatest_pars_fragment> 3661#include <alphahash_pars_fragment> 3662#include <fog_pars_fragment> 3663#include <logdepthbuf_pars_fragment> 3664#include <clipping_planes_pars_fragment> 3665void main() { 3666 vec4 diffuseColor = vec4( diffuse, opacity ); 3667 #include <clipping_planes_fragment> 3668 vec3 outgoingLight = vec3( 0.0 ); 3669 #include <logdepthbuf_fragment> 3670 #include <map_fragment> 3671 #include <alphamap_fragment> 3672 #include <alphatest_fragment> 3673 #include <alphahash_fragment> 3674 outgoingLight = diffuseColor.rgb; 3675 #include <opaque_fragment> 3676 #include <tonemapping_fragment> 3677 #include <colorspace_fragment> 3678 #include <fog_fragment> 3679}`,Ue={alphahash_fragment:Bu,alphahash_pars_fragment:zu,alphamap_fragment:Gu,alphamap_pars_fragment:Vu,alphatest_fragment:Hu,alphatest_pars_fragment:ku,aomap_fragment:Wu,aomap_pars_fragment:Xu,batching_pars_vertex:qu,batching_vertex:Yu,begin_vertex:Ku,beginnormal_vertex:Zu,bsdfs:$u,iridescence_fragment:Ju,bumpmap_pars_fragment:Qu,clipping_planes_fragment:ju,clipping_planes_pars_fragment:eh,clipping_planes_pars_vertex:th,clipping_planes_vertex:nh,color_fragment:ih,color_pars_fragment:rh,color_pars_vertex:sh,color_vertex:ah,common:oh,cube_uv_reflection_fragment:lh,defaultnormal_vertex:ch,displacementmap_pars_vertex:uh,displacementmap_vertex:hh,emissivemap_fragment:fh,emissivemap_pars_fragment:dh,colorspace_fragment:ph,colorspace_pars_fragment:mh,envmap_fragment:gh,envmap_common_pars_fragment:_h,envmap_pars_fragment:xh,envmap_pars_vertex:vh,envmap_physical_pars_fragment:Ph,envmap_vertex:Mh,fog_vertex:Sh,fog_pars_vertex:Eh,fog_fragment:yh,fog_pars_fragment:Th,gradientmap_pars_fragment:bh,lightmap_pars_fragment:Ah,lights_lambert_fragment:wh,lights_lambert_pars_fragment:Rh,lights_pars_begin:Ch,lights_toon_fragment:Dh,lights_toon_pars_fragment:Lh,lights_phong_fragment:Ih,lights_phong_pars_fragment:Uh,lights_physical_fragment:Nh,lights_physical_pars_fragment:Fh,lights_fragment_begin:Oh,lights_fragment_maps:Bh,lights_fragment_end:zh,lightprobes_pars_fragment:Gh,logdepthbuf_fragment:Vh,logdepthbuf_pars_fragment:Hh,logdepthbuf_pars_vertex:kh,logdepthbuf_vertex:Wh,map_fragment:Xh,map_pars_fragment:qh,map_particle_fragment:Yh,map_particle_pars_fragment:Kh,metalnessmap_fragment:Zh,metalnessmap_pars_fragment:$h,morphinstance_vertex:Jh,morphcolor_vertex:Qh,morphnormal_vertex:jh,morphtarget_pars_vertex:ef,morphtarget_vertex:tf,normal_fragment_begin:nf,normal_fragment_maps:rf,normal_pars_fragment:sf,normal_pars_vertex:af,normal_vertex:of,normalmap_pars_fragment:lf,clearcoat_normal_fragment_begin:cf,clearcoat_normal_fragment_maps:uf,clearcoat_pars_fragment:hf,iridescence_pars_fragment:ff,opaque_fragment:df,packing:pf,premultiplied_alpha_fragment:mf,project_vertex:gf,dithering_fragment:_f,dithering_pars_fragment:xf,roughnessmap_fragment:vf,roughnessmap_pars_fragment:Mf,shadowmap_pars_fragment:Sf,shadowmap_pars_vertex:Ef,shadowmap_vertex:yf,shadowmask_pars_fragment:Tf,skinbase_vertex:bf,skinning_pars_vertex:Af,skinning_vertex:wf,skinnormal_vertex:Rf,specularmap_fragment:Cf,specularmap_pars_fragment:Pf,tonemapping_fragment:Df,tonemapping_pars_fragment:Lf,transmission_fragment:If,transmission_pars_fragment:Uf,uv_pars_fragment:Nf,uv_pars_vertex:Ff,uv_vertex:Of,worldpos_vertex:Bf,background_vert:zf,background_frag:Gf,backgroundCube_vert:Vf,backgroundCube_frag:Hf,cube_vert:kf,cube_frag:Wf,depth_vert:Xf,depth_frag:qf,distance_vert:Yf,distance_frag:Kf,equirect_vert:Zf,equirect_frag:$f,linedashed_vert:Jf,linedashed_frag:Qf,meshbasic_vert:jf,meshbasic_frag:ed,meshlambert_vert:td,meshlambert_frag:nd,meshmatcap_vert:id,meshmatcap_frag:rd,meshnormal_vert:sd,meshnormal_frag:ad,meshphong_vert:od,meshphong_frag:ld,meshphysical_vert:cd,meshphysical_frag:ud,meshtoon_vert:hd,meshtoon_frag:fd,points_vert:dd,points_frag:pd,shadow_vert:md,shadow_frag:gd,sprite_vert:_d,sprite_frag:xd},ue={common:{diffuse:{value:new Ge(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ce},alphaMap:{value:null},alphaMapTransform:{value:new Ce},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ce}},envmap:{envMap:{value:null},envMapRotation:{value:new Ce},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ce}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ce}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ce},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ce},normalScale:{value:new Fe(1,1)}}
vendor: 6,842 bytes, line 3679
3679,displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ce},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ce}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ce}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ce}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ge(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new N},probesMax:{value:new N},probesResolution:{value:new N}},points:{diffuse:{value:new Ge(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ce},alphaTest:{value:0},uvTransform:{value:new Ce}},sprite:{diffuse:{value:new Ge(16777215)},opacity:{value:1},center:{value:new Fe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ce},alphaMap:{value:null},alphaMapTransform:{value:new Ce},alphaTest:{value:0}}},tn={basic:{uniforms:Ct([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.fog]),vertexShader:Ue.meshbasic_vert,fragmentShader:Ue.meshbasic_frag},lambert:{uniforms:Ct([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,ue.lights,{emissive:{value:new Ge(0)},envMapIntensity:{value:1}}]),vertexShader:Ue.meshlambert_vert,fragmentShader:Ue.meshlambert_frag},phong:{uniforms:Ct([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,ue.lights,{emissive:{value:new Ge(0)},specular:{value:new Ge(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ue.meshphong_vert,fragmentShader:Ue.meshphong_frag},standard:{uniforms:Ct([ue.common,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.roughnessmap,ue.metalnessmap,ue.fog,ue.lights,{emissive:{value:new Ge(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ue.meshphysical_vert,fragmentShader:Ue.meshphysical_frag},toon:{uniforms:Ct([ue.common,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.gradientmap,ue.fog,ue.lights,{emissive:{value:new Ge(0)}}]),vertexShader:Ue.meshtoon_vert,fragmentShader:Ue.meshtoon_frag},matcap:{uniforms:Ct([ue.common,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,{matcap:{value:null}}]),vertexShader:Ue.meshmatcap_vert,fragmentShader:Ue.meshmatcap_frag},points:{uniforms:Ct([ue.points,ue.fog]),vertexShader:Ue.points_vert,fragmentShader:Ue.points_frag},dashed:{uniforms:Ct([ue.common,ue.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ue.linedashed_vert,fragmentShader:Ue.linedashed_frag},depth:{uniforms:Ct([ue.common,ue.displacementmap]),vertexShader:Ue.depth_vert,fragmentShader:Ue.depth_frag},normal:{uniforms:Ct([ue.common,ue.bumpmap,ue.normalmap,ue.displacementmap,{opacity:{value:1}}]),vertexShader:Ue.meshnormal_vert,fragmentShader:Ue.meshnormal_frag},sprite:{uniforms:Ct([ue.sprite,ue.fog]),vertexShader:Ue.sprite_vert,fragmentShader:Ue.sprite_frag},background:{uniforms:{uvTransform:{value:new Ce},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ue.background_vert,fragmentShader:Ue.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ce}},vertexShader:Ue.backgroundCube_vert,fragmentShader:Ue.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ue.cube_vert,fragmentShader:Ue.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ue.equirect_vert,fragmentShader:Ue.equirect_frag},distance:{uniforms:Ct([ue.common,ue.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ue.distance_vert,fragmentShader:Ue.distance_frag},shadow:{uniforms:Ct([ue.lights,ue.fog,{color:{value:new Ge(0)},opacity:{value:1}}]),vertexShader:Ue.shadow_vert,fragmentShader:Ue.shadow_frag}};tn.physical={uniforms:Ct([tn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ce},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ce},clearcoatNormalScale:{value:new Fe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ce},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ce},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ce},sheen:{value:0},sheenColor:{value:new Ge(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ce},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ce},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ce},transmissionSamplerSize:{value:new Fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ce},attenuationDistance:{value:0},attenuationColor:{value:new Ge(0)},specularColor:{value:new Ge(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ce},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ce},anisotropyVector:{value:new Fe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ce}}]),vertexShader:Ue.meshphysical_vert,fragmentShader:Ue.meshphysical_frag};const gr={r:0,b:0,g:0},vd=new tt,Fl=new Ce;Fl.set(-1,0,0,0,1,0,0,0,1);
vendor: 15,037 bytes, line 3679
3679function Md(i,e,t,n,r,s){const a=new Ge(0);let o=r===!0?0:1,c,l,f=null,m=0,u=null;function _(b){let R=b.isScene===!0?b.background:null;if(R&&R.isTexture){const M=b.backgroundBlurriness>0;R=e.get(R,M)}return R}function v(b){let R=!1;const M=_(b);M===null?g(a,o):M&&M.isColor&&(g(M,1),R=!0);const A=i.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,s):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(i.autoClear||R)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function y(b,R){const M=_(R);M&&(M.isCubeTexture||M.mapping===Ur)?(l===void 0&&(l=new nt(new sn(1,1,1),new Zt({name:"BackgroundCubeMaterial",uniforms:Si(tn.backgroundCube.uniforms),vertexShader:tn.backgroundCube.vertexShader,fragmentShader:tn.backgroundCube.fragmentShader,side:Pt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(A,S,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(vd.makeRotationFromEuler(R.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Fl),l.material.toneMapped=ze.getTransfer(M.colorSpace)!==Ke,(f!==M||m!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,f=M,m=M.version,u=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new nt(new bi(2,2),new Zt({name:"BackgroundMaterial",uniforms:Si(tn.background.uniforms),vertexShader:tn.background.vertexShader,fragmentShader:tn.background.fragmentShader,side:Dn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=ze.getTransfer(M.colorSpace)!==Ke,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(f!==M||m!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,f=M,m=M.version,u=i.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function g(b,R){b.getRGB(gr,Dl(i)),t.buffers.color.setClear(gr.r,gr.g,gr.b,R,s)}function h(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(b,R=1){a.set(b),o=R,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,g(a,o)},render:v,addToRenderList:y,dispose:h}}function Sd(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=u(null);let s=r,a=!1;function o(P,I,X,H,O){let W=!1;const k=m(P,H,X,I);s!==k&&(s=k,l(s.object)),W=_(P,H,X,O),W&&v(P,H,X,O),O!==null&&e.update(O,i.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,M(P,I,X,H),O!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function c(){return i.createVertexArray()}function l(P){return i.bindVertexArray(P)}function f(P){return i.deleteVertexArray(P)}function m(P,I,X,H){const O=H.wireframe===!0;let W=n[I.id];W===void 0&&(W={},n[I.id]=W);const k=P.isInstancedMesh===!0?P.id:0;let J=W[k];J===void 0&&(J={},W[k]=J);let j=J[X.id];j===void 0&&(j={},J[X.id]=j);let le=j[O];return le===void 0&&(le=u(c()),j[O]=le),le}function u(P){const I=[],X=[],H=[];for(let O=0;O<t;O++)I[O]=0,X[O]=0,H[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:X,attributeDivisors:H,object:P,attributes:{},index:null}}function _(P,I,X,H){const O=s.attributes,W=I.attributes;let k=0;const J=X.getAttributes();for(const j in J)if(J[j].location>=0){const he=O[j];let _e=W[j];if(_e===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(_e=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(_e=P.instanceColor)),he===void 0||he.attribute!==_e||_e&&he.data!==_e.data)return!0;k++}return s.attributesNum!==k||s.index!==H}function v(P,I,X,H){const O={},W=I.attributes;let k=0;const J=X.getAttributes();for(const j in J)if(J[j].location>=0){let he=W[j];he===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(he=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(he=P.instanceColor));const _e={};_e.attribute=he,he&&he.data&&(_e.data=he.data),O[j]=_e,k++}s.attributes=O,s.attributesNum=k,s.index=H}function y(){const P=s.newAttributes;for(let I=0,X=P.length;I<X;I++)P[I]=0}function g(P){h(P,0)}function h(P,I){const X=s.newAttributes,H=s.enabledAttributes,O=s.attributeDivisors;X[P]=1,H[P]===0&&(i.enableVertexAttribArray(P),H[P]=1),O[P]!==I&&(i.vertexAttribDivisor(P,I),O[P]=I)}function b(){const P=s.newAttributes,I=s.enabledAttributes;for(let X=0,H=I.length;X<H;X++)I[X]!==P[X]&&(i.disableVertexAttribArray(X),I[X]=0)}function R(P,I,X,H,O,W,k){k===!0?i.vertexAttribIPointer(P,I,X,O,W):i.vertexAttribPointer(P,I,X,H,O,W)}function M(P,I,X,H){y();const O=H.attributes,W=X.getAttributes(),k=I.defaultAttributeValues;for(const J in W){const j=W[J];if(j.location>=0){let le=O[J];if(le===void 0&&(J==="instanceMatrix"&&P.instanceMatrix&&(le=P.instanceMatrix),J==="instanceColor"&&P.instanceColor&&(le=P.instanceColor)),le!==void 0){const he=le.normalized,_e=le.itemSize,Ve=e.get(le);if(Ve===void 0)continue;const rt=Ve.buffer,Xe=Ve.type,$=Ve.bytesPerElement,ie=Xe===i.INT||Xe===i.UNSIGNED_INT||le.gpuType===pa;if(le.isInterleavedBufferAttribute){const ee=le.data,Re=ee.stride,De=le.offset;if(ee.isInstancedInterleavedBuffer){for(let be=0;be<j.locationSize;be++)h(j.location+be,ee.meshPerAttribute);P.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let be=0;be<j.locationSize;be++)g(j.location+be);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let be=0;be<j.locationSize;be++)R(j.location+be,_e/j.locationSize,Xe,he,Re*$,(De+_e/j.locationSize*be)*$,ie)}else{if(le.isInstancedBufferAttribute){for(let ee=0;ee<j.locationSize;ee++)h(j.location+ee,le.meshPerAttribute);P.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let ee=0;ee<j.locationSize;ee++)g(j.location+ee);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let ee=0;ee<j.locationSize;ee++)R(j.location+ee,_e/j.locationSize,Xe,he,_e*$,_e/j.locationSize*ee*$,ie)}}else if(k!==void 0){const he=k[J];if(he!==void 0)switch(he.length){case 2:i.vertexAttrib2fv(j.location,he);break;case 3:i.vertexAttrib3fv(j.location,he);break;case 4:i.vertexAttrib4fv(j.location,he);break;default:i.vertexAttrib1fv(j.location,he)}}}}b()}function A(){E();for(const P in n){const I=n[P];for(const X in I){const H=I[X];for(const O in H){const W=H[O];for(const k in W)f(W[k].object),delete W[k];delete H[O]}}delete n[P]}}function S(P){if(n[P.id]===void 0)return;const I=n[P.id];for(const X in I){const H=I[X];for(const O in H){const W=H[O];for(const k in W)f(W[k].object),delete W[k];delete H[O]}}delete n[P.id]}function C(P){for(const I in n){const X=n[I];for(const H in X){const O=X[H];if(O[P.id]===void 0)continue;const W=O[P.id];for(const k in W)f(W[k].object),delete W[k];delete O[P.id]}}}function p(P){for(const I in n){const X=n[I],H=P.isInstancedMesh===!0?P.id:0,O=X[H];if(O!==void 0){for(const W in O){const k=O[W];for(const J in k)f(k[J].object),delete k[J];delete O[W]}delete X[H],Object.keys(X).length===0&&delete n[I]}}}function E(){w(),a=!0,s!==r&&(s=r,l(s.object))}function w(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:E,resetDefaultState:w,dispose:A,releaseStatesOfGeometry:S,releaseStatesOfObject:p,releaseStatesOfProgram:C,initAttributes:y,enableAttribute:g,disableUnusedAttributes:b}}function Ed(i,e,t){let n;function r(c){n=c}function s(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,f){f!==0&&(i.drawArraysInstanced(n,c,l,f),t.update(l,n,f))}function o(c,l,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,f);let u=0;for(let _=0;_<f;_++)u+=l[_];t.update(u,n,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function yd(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){return!(C!==Yt&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const p=C===xn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==Ft&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==qt&&!p)}function c(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const f=c(l);f!==l&&(we("WebGLRenderer:",l,"not supported, using",f,"instead."),l=f);const m=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&we("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const _=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),h=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),R=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),A=i.getParameter(i.MAX_SAMPLES),S=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:m,reversedDepthBuffer:u,maxTextures:_,maxVertexTextures:v,maxTextureSize:y,maxCubemapSize:g,maxAttributes:h,maxVertexUniforms:b,maxVaryings:R,maxFragmentUniforms:M,maxSamples:A,samples:S}}function Td(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new Bn,o=new Ce,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(m,u){const _=m.length!==0||u||n!==0||r;return r=u,n=m.length,_},this.beginShadows=function(){s=!0,f(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(m,u){t=f(m,u,0)},this.setState=function(m,u,_){const v=m.clippingPlanes,y=m.clipIntersection,g=m.clipShadows,h=i.get(m);if(!r||v===null||v.length===0||s&&!g)s?f(null):l();else{const b=s?0:n,R=b*4;let M=h.clippingState||null;c.value=M,M=f(v,u,R,_);for(let A=0;A!==R;++A)M[A]=t[A];h.clippingState=M,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=b}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function f(m,u,_,v){const y=m!==null?m.length:0;let g=null;if(y!==0){if(g=c.value,v!==!0||g===null){const h=_+y*4,b=u.matrixWorldInverse;o.getNormalMatrix(b),(g===null||g.length<h)&&(g=new Float32Array(h));for(let R=0,M=_;R!==y;++R,M+=4)a.copy(m[R]).applyMatrix4(b,o),a.normal.toArray(g,M),g[M+3]=a.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,g}}const Pn=4,Co=[.125,.215,.35,.446,.526,.582],Gn=20,bd=256,Ii=new Pa,Po=new Ge;let fs=null,ds=0,ps=0,ms=!1;const Ad=new N;class Do{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,s={}){const{size:a=256,position:o=Ad}=s;fs=this._renderer.getRenderTarget(),ds=this._renderer.getActiveCubeFace(),ps=this._renderer.getActiveMipmapLevel(),ms=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Uo(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Io(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(fs,ds,ps),this._renderer.xr.enabled=ms,e.scissorTest=!1,di(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Yn||e.mapping===vi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),fs=this._renderer.getRenderTarget(),ds=this._renderer.getActiveCubeFace(),ps=this._renderer.getActiveMipmapLevel(),ms=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:wt,minFilter:wt,generateMipmaps:!1,type:xn,format:Yt,colorSpace:wr,depthBuffer:!1},r=Lo(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Lo(e,t,n);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=wd(s)),this._blurMaterial=Cd(s,e,t),this._ggxMaterial=Rd(s,e,t)}return r}_compileMaterial(e){const t=new nt(new Vt,e);this._renderer.compile(t,Ii)}_sceneToCubeUV(e,t,n,r,s){const c=new Gt(90,1,t,n),l=[1,-1,1,1,1,1],f=[1,1,1,-1,-1,-1],m=this._renderer,u=m.autoClear,_=m.toneMapping;m.getClearColor(Po),m.toneMapping=an,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(r),m.clearDepth(),m.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new nt(new sn,new wl({name:"PMREM.Backgroun
3679d",side:Pt,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,g=y.material;let h=!1;const b=e.background;b?b.isColor&&(g.color.copy(b),e.background=null,h=!0):(g.color.copy(Po),h=!0);for(let R=0;R<6;R++){const M=R%3;M===0?(c.up.set(0,l[R],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+f[R],s.y,s.z)):M===1?(c.up.set(0,0,l[R]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+f[R],s.z)):(c.up.set(0,l[R],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+f[R]));const A=this._cubeSize;di(r,M*A,R>2?A:0,A,A),m.setRenderTarget(r),h&&m.render(y,c),m.render(e,c)}m.toneMapping=_,m.autoClear=u,e.background=b}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Yn||e.mapping===vi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Uo()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Io());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;di(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Ii)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),f=t/(this._lodMeshes.length-1),m=Math.sqrt(l*l-f*f),u=0+l*1.25,_=m*u,{_lodMax:v}=this,y=this._sizeLods[n],g=3*y*(n>v-Pn?n-v+Pn:0),h=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=_,c.mipInt.value=v-t,di(s,g,h,3*y,2*y),r.setRenderTarget(s),r.render(o,Ii),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=v-n,di(e,g,h,3*y,2*y),r.setRenderTarget(e),r.render(o,Ii)}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&We("blur direction must be either latitudinal or longitudinal!");const f=3,m=this._lodMeshes[r];m.material=l;const u=l.uniforms,_=this._sizeLods[n]-1,v=isFinite(s)?Math.PI/(2*_):2*Math.PI/(2*Gn-1),y=s/v,g=isFinite(s)?1+Math.floor(f*y):Gn;g>Gn&&we(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Gn}`);const h=[];let b=0;for(let C=0;C<Gn;++C){const p=C/y,E=Math.exp(-p*p/2);h.push(E),C===0?b+=E:C<g&&(b+=2*E)}for(let C=0;C<h.length;C++)h[C]=h[C]/b;u.envMap.value=e.texture,u.samples.value=g,u.weights.value=h,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:R}=this;u.dTheta.value=v,u.mipInt.value=R-n;const M=this._sizeLods[r],A=3*M*(r>R-Pn?r-R+Pn:0),S=4*(this._cubeSize-M);di(t,A,S,3*M,2*M),c.setRenderTarget(t),c.render(m,Ii)}}function wd(i){const e=[],t=[],n=[];let r=i;const s=i-Pn+1+Co.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let c=1/o;a>i-Pn?c=Co[a-i+Pn-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),f=-l,m=1+l,u=[f,f,m,f,m,m,f,f,m,m,f,m],_=6,v=6,y=3,g=2,h=1,b=new Float32Array(y*v*_),R=new Float32Array(g*v*_),M=new Float32Array(h*v*_);for(let S=0;S<_;S++){const C=S%3*2/3-1,p=S>2?0:-1,E=[C,p,0,C+2/3,p,0,C+2/3,p+1,0,C,p,0,C+2/3,p+1,0,C,p+1,0];b.set(E,y*v*S),R.set(u,g*v*S);const w=[S,S,S,S,S,S];M.set(w,h*v*S)}const A=new Vt;A.setAttribute("position",new Kt(b,y)),A.setAttribute("uv",new Kt(R,g)),A.setAttribute("faceIndex",new Kt(M,h)),n.push(new nt(A,null)),r>Pn&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Lo(i,e,t){const n=new on(i,e,t);return n.texture.mapping=Ur,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function di(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Rd(i,e,t){return new Zt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:bd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Nr(),fragmentShader:` 3680 3681 precision highp float; 3682 precision highp int; 3683 3684 varying vec3 vOutputDirection; 3685 3686 uniform sampler2D envMap; 3687 uniform float roughness; 3688 uniform float mipInt; 3689 3690 #define ENVMAP_TYPE_CUBE_UV 3691 #include <cube_uv_reflection_fragment> 3692 3693 #define PI 3.14159265359 3694 3695 // Van der Corput radical inverse 3696 float radicalInverse_VdC(uint bits) { 3697 bits = (bits << 16u) | (bits >> 16u); 3698 bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); 3699 bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); 3700 bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); 3701 bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); 3702 return float(bits) * 2.3283064365386963e-10; // / 0x100000000 3703 } 3704 3705 // Hammersley sequence 3706 vec2 hammersley(uint i, uint N) { 3707 return vec2(float(i) / float(N), radicalInverse_VdC(i)); 3708 } 3709 3710 // GGX VNDF importance sampling (Eric Heitz 2018) 3711 // "Sampling the GGX Distribution of Visible Normals" 3712 // https://jcgt.org/published/0007/04/01/ 3713 vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { 3714 float alpha = roughness * roughness; 3715 3716 // Section 4.1: Orthonormal basis 3717 vec3 T1 = vec3(1.0, 0.0, 0.0); 3718 vec3 T2 = cross(V, T1); 3719 3720 // Section 4.2: Parameterization of projected area 3721 float r = sqrt(Xi.x); 3722 float phi = 2.0 * PI * Xi.y; 3723 float t1 = r * cos(phi); 3724 float t2 = r * sin(phi); 3725 float s = 0.5 * (1.0 + V.z); 3726 t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; 3727 3728 // Section 4.3: Reprojection onto hemisphere 3729 vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; 3730 3731 // Section 3.4: Transform back to ellipsoid configuration 3732 return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); 3733 } 3734 3735 void main() { 3736 vec3 N = normalize(vOutputDirection); 3737 vec3 V = N; // Assume view direction equals normal for pre-filtering 3738 3739 vec3 prefilteredColor = vec3(0.0); 3740 float totalWeight = 0.0; 3741 3742 // For very low roughness, just sample the environment directly 3743 if (roughness < 0.001) { 3744 gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); 3745 return; 3746 } 3747 3748 // Tangent space basis for VNDF sampling 3749 vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); 3750 vec3 tangent = normalize(cross(up, N)); 3751 vec3 bitangent = cross(N, tangent); 3752
3753 for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { 3754 vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); 3755 3756 // For PMREM, V = N, so in tangent space V is always (0, 0, 1) 3757 vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); 3758 3759 // Transform H back to world space 3760 vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); 3761 vec3 L = normalize(2.0 * dot(V, H) * H - V); 3762 3763 float NdotL = max(dot(N, L), 0.0); 3764 3765 if(NdotL > 0.0) { 3766 // Sample environment at fixed mip level 3767 // VNDF importance sampling handles the distribution filtering 3768 vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); 3769 3770 // Weight by NdotL for the split-sum approximation 3771 // VNDF PDF naturally accounts for the visible microfacet distribution 3772 prefilteredColor += sampleColor * NdotL; 3773 totalWeight += NdotL; 3774 } 3775 } 3776 3777 if (totalWeight > 0.0) { 3778 prefilteredColor = prefilteredColor / totalWeight; 3779 } 3780 3781 gl_FragColor = vec4(prefilteredColor, 1.0); 3782 } 3783 `,blending:mn,depthTest:!1,depthWrite:!1})}function Cd(i,e,t){const n=new Float32Array(Gn),r=new N(0,1,0);return new Zt({name:"SphericalGaussianBlur",defines:{n:Gn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Nr(),fragmentShader:` 3784 3785 precision mediump float; 3786 precision mediump int; 3787 3788 varying vec3 vOutputDirection; 3789 3790 uniform sampler2D envMap; 3791 uniform int samples; 3792 uniform float weights[ n ]; 3793 uniform bool latitudinal; 3794 uniform float dTheta; 3795 uniform float mipInt; 3796 uniform vec3 poleAxis; 3797 3798 #define ENVMAP_TYPE_CUBE_UV 3799 #include <cube_uv_reflection_fragment> 3800 3801 vec3 getSample( float theta, vec3 axis ) { 3802 3803 float cosTheta = cos( theta ); 3804 // Rodrigues' axis-angle rotation 3805 vec3 sampleDirection = vOutputDirection * cosTheta 3806 + cross( axis, vOutputDirection ) * sin( theta ) 3807 + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); 3808 3809 return bilinearCubeUV( envMap, sampleDirection, mipInt ); 3810 3811 } 3812 3813 void main() { 3814 3815 vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); 3816 3817 if ( all( equal( axis, vec3( 0.0 ) ) ) ) { 3818 3819 axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); 3820 3821 } 3822 3823 axis = normalize( axis ); 3824 3825 gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); 3826 gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); 3827 3828 for ( int i = 1; i < n; i++ ) { 3829 3830 if ( i >= samples ) { 3831 3832 break; 3833 3834 } 3835 3836 float theta = dTheta * float( i ); 3837 gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); 3838 gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); 3839 3840 } 3841 3842 } 3843 `,blending:mn,depthTest:!1,depthWrite:!1})}function Io(){return new Zt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Nr(),fragmentShader:` 3844 3845 precision mediump float; 3846 precision mediump int; 3847 3848 varying vec3 vOutputDirection; 3849 3850 uniform sampler2D envMap; 3851 3852 #include <common> 3853 3854 void main() { 3855 3856 vec3 outputDirection = normalize( vOutputDirection ); 3857 vec2 uv = equirectUv( outputDirection ); 3858 3859 gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); 3860 3861 } 3862 `,blending:mn,depthTest:!1,depthWrite:!1})}function Uo(){return new Zt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Nr(),fragmentShader:` 3863 3864 precision mediump float; 3865 precision mediump int; 3866 3867 uniform float flipEnvMap; 3868 3869 varying vec3 vOutputDirection; 3870 3871 uniform samplerCube envMap; 3872 3873 void main() { 3874 3875 gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); 3876 3877 } 3878 `,blending:mn,depthTest:!1,depthWrite:!1})}function Nr(){return` 3879 3880 precision mediump float; 3881 precision mediump int; 3882 3883 attribute float faceIndex; 3884 3885 varying vec3 vOutputDirection; 3886 3887 // RH coordinate system; PMREM face-indexing convention 3888 vec3 getDirection( vec2 uv, float face ) { 3889 3890 uv = 2.0 * uv - 1.0; 3891 3892 vec3 direction = vec3( uv, 1.0 ); 3893 3894 if ( face == 0.0 ) { 3895 3896 direction = direction.zyx; // ( 1, v, u ) pos x 3897 3898 } else if ( face == 1.0 ) { 3899 3900 direction = direction.xzy; 3901 direction.xz *= -1.0; // ( -u, 1, -v ) pos y 3902 3903 } else if ( face == 2.0 ) { 3904 3905 direction.x *= -1.0; // ( -u, v, 1 ) pos z 3906 3907 } else if ( face == 3.0 ) { 3908 3909 direction = direction.zyx; 3910 direction.xz *= -1.0; // ( -1, v, -u ) neg x 3911 3912 } else if ( face == 4.0 ) { 3913 3914 direction = direction.xzy; 3915 direction.xy *= -1.0; // ( -u, -1, v ) neg y 3916 3917 } else if ( face == 5.0 ) { 3918 3919 direction.z *= -1.0; // ( u, v, -1 ) neg z 3920 3921 } 3922 3923 return direction; 3924 3925 } 3926 3927 void main() { 3928 3929 vOutputDirection = getDirection( uv, faceIndex ); 3930 gl_Position = vec4( position, 1.0 ); 3931 3932 } 3933 `}class Ol extends on{constructor(e=1,t={}
vendor: 25,290 bytes, lines 3933-4044
3933){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Cl(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` 3934 3935 varying vec3 vWorldDirection; 3936 3937 vec3 transformDirection( in vec3 dir, in mat4 matrix ) { 3938 3939 return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); 3940 3941 } 3942 3943 void main() { 3944 3945 vWorldDirection = transformDirection( position, modelMatrix ); 3946 3947 #include <begin_vertex> 3948 #include <project_vertex> 3949 3950 } 3951 `,fragmentShader:` 3952 3953 uniform sampler2D tEquirect; 3954 3955 varying vec3 vWorldDirection; 3956 3957 #include <common> 3958 3959 void main() { 3960 3961 vec3 direction = normalize( vWorldDirection ); 3962 3963 vec2 sampleUV = equirectUv( direction ); 3964 3965 gl_FragColor = texture2D( tEquirect, sampleUV ); 3966 3967 } 3968 `},r=new sn(5,5,5),s=new Zt({name:"CubemapFromEquirect",uniforms:Si(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Pt,blending:mn});s.uniforms.tEquirect.value=t;const a=new nt(r,s),o=t.minFilter;return t.minFilter===Hn&&(t.minFilter=wt),new Uu(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}function Pd(i){let e=new WeakMap,t=new WeakMap,n=null;function r(u,_=!1){return u==null?null:_?a(u):s(u)}function s(u){if(u&&u.isTexture){const _=u.mapping;if(_===Gr||_===Vr)if(e.has(u)){const v=e.get(u).texture;return o(v,u.mapping)}else{const v=u.image;if(v&&v.height>0){const y=new Ol(v.height);return y.fromEquirectangularTexture(i,u),e.set(u,y),u.addEventListener("dispose",l),o(y.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture){const _=u.mapping,v=_===Gr||_===Vr,y=_===Yn||_===vi;if(v||y){let g=t.get(u);const h=g!==void 0?g.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==h)return n===null&&(n=new Do(i)),g=v?n.fromEquirectangular(u,g):n.fromCubemap(u,g),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),g.texture;if(g!==void 0)return g.texture;{const b=u.image;return v&&b&&b.height>0||y&&b&&c(b)?(n===null&&(n=new Do(i)),g=v?n.fromEquirectangular(u):n.fromCubemap(u),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),u.addEventListener("dispose",f),g.texture):null}}}return u}function o(u,_){return _===Gr?u.mapping=Yn:_===Vr&&(u.mapping=vi),u}function c(u){let _=0;const v=6;for(let y=0;y<v;y++)u[y]!==void 0&&_++;return _===v}function l(u){const _=u.target;_.removeEventListener("dispose",l);const v=e.get(_);v!==void 0&&(e.delete(_),v.dispose())}function f(u){const _=u.target;_.removeEventListener("dispose",f);const v=t.get(_);v!==void 0&&(t.delete(_),v.dispose())}function m(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:m}}function Dd(i){const e={};function t(n){if(e[n]!==void 0)return e[n];const r=i.getExtension(n);return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&gi("WebGLRenderer: "+n+" extension not supported."),r}}}function Ld(i,e,t,n){const r={},s=new WeakMap;function a(m){const u=m.target;u.index!==null&&e.remove(u.index);for(const v in u.attributes)e.remove(u.attributes[v]);u.removeEventListener("dispose",a),delete r[u.id];const _=s.get(u);_&&(e.remove(_),s.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function o(m,u){return r[u.id]===!0||(u.addEventListener("dispose",a),r[u.id]=!0,t.memory.geometries++),u}function c(m){const u=m.attributes;for(const _ in u)e.update(u[_],i.ARRAY_BUFFER)}function l(m){const u=[],_=m.index,v=m.attributes.position;let y=0;if(v===void 0)return;if(_!==null){const b=_.array;y=_.version;for(let R=0,M=b.length;R<M;R+=3){const A=b[R+0],S=b[R+1],C=b[R+2];u.push(A,S,S,C,C,A)}}else{const b=v.array;y=v.version;for(let R=0,M=b.length/3-1;R<M;R+=3){const A=R+0,S=R+1,C=R+2;u.push(A,S,S,C,C,A)}}const g=new(v.count>=65535?Al:bl)(u,1);g.version=y;const h=s.get(m);h&&e.remove(h),s.set(m,g)}function f(m){const u=s.get(m);if(u){const _=m.index;_!==null&&u.version<_.version&&l(m)}else l(m);return s.get(m)}return{get:o,update:c,getWireframeAttribute:f}}function Id(i,e,t){let n;function r(m){n=m}let s,a;function o(m){s=m.type,a=m.bytesPerElement}function c(m,u){i.drawElements(n,u,s,m*a),t.update(u,n,1)}function l(m,u,_){_!==0&&(i.drawElementsInstanced(n,u,s,m*a,_),t.update(u,n,_))}function f(m,u,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,s,m,0,_);let y=0;for(let g=0;g<_;g++)y+=u[g];t.update(y,n,1)}this.setMode=r,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=f}function Ud(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(s/3);break;case i.LINES:t.lines+=o*(s/2);break;case i.LINE_STRIP:t.lines+=o*(s-1);break;case i.LINE_LOOP:t.lines+=o*s;break;case i.POINTS:t.points+=o*s;break;default:We("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function Nd(i,e,t){const n=new WeakMap,r=new it;function s(a,o,c){const l=a.morphTargetInfluences,f=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,m=f!==void 0?f.length:0;let u=n.get(o);if(u===void 0||u.count!==m){let E=function(){C.dispose(),n.delete(o),o.removeEventListener("dispose",E)};u!==void 0&&u.texture.dispose();const _=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],h=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let R=0;_===!0&&(R=1),v===!0&&(R=2),y===!0&&(R=3);let M=o.attributes.position.count*R,A=1;M>e.maxTextureSize&&(A=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const S=new Float32Array(M*A*4*m),C=new El(S,M,A,m);C.type=qt,C.needsUpdate=!0;const p=R*4;for(let w=0;w<m;w++){const P=g[w],I=h[w],X=b[w],H=M*A*4*w;for(let O=0;O<P.count;O++){const W=O*p;_===!0&&(r.fromBufferAttribute(P,O),S[H+W+0]=r.x,S[H+W+1]=r.y,S[H+W+2]=r.z,S[H+W+3]=0),v===!0&&(r.fromBufferAttribute(I,O),S[H+W+4]=r.x,S[H+W+5]=r.y,S[H+W+6]=r.z,S[H+W+7]=0),y===!0&&(r.fromBufferAttribute(X,O),S[H+W+8]=r.x,S[H+W+9]=r.y,S[H+W+10]=r.z,S[H+W+11]=X.itemSize===4?r.w:1)}}u={count:m,texture:C,size:new Fe(M,A)},n.set(o,u),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let _=0;for(let y=0;y<l.length;y++)_+=l[y];const v=o.morphTargetsRelative?1:1-_;c.getUniforms().setValue(i,"morphTargetBaseInfluence",v),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:s}}function Fd(i,e,t,n,r){let s=new WeakMap;function a(l){const f=r.render.frame,m=l.geometry,u=e.get(l,m);if(s.get(u)!==f&&(e.update(u),s.set(u,f)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),s.get(l)!==f&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,f))),l.isSkinnedMesh){const _=l.skeleton;s.get(_)!==f&&(_.update(),s.set(_,f))}return u}function o(){s=new WeakMap}function c(l){const f=l.target;f.removeEventListener("dispose",c),n.releaseStatesOfObject(f),t.remove(f.instanceMatrix),f.instanceColor!==null&&t.remove(f.instanceColor)}return{update:a,dispose:o}}const Od={[ll]:"LINEAR_TONE_MAPPING",[cl]:"REINHARD_TONE_MAPPING",[ul]:"CINEON_TONE_MAPPING",[da]:"ACES_FILMIC_TONE_MAPPING",[fl]:"AGX_TONE_MAPPING",[dl]:"NEUTRAL_TONE_MAPPING",[hl]:"CUSTOM_TONE_MAPPING"};function Bd(i,e,t,n,r,s){const a=new on(e,t,{type:i,depthBuffer:r,stencilBuffer:s,samples:n?4:0,depthTexture:r?new Mi(e,t):void 0}),o=new on(e,t,{type:xn,depthBuffer:!1,stencilBuffer:!1}),c=new Vt;c.setAttribute("position",new Mt([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Mt([0,2,0,0,2,0],2));const l=new wu({uniforms:{tDiffuse:{value:null}},vertexShader:` 3969 precision highp float; 3970 3971 uniform mat4 modelViewMatrix; 3972 uniform mat4 projectionMatrix; 3973 3974 attribute vec3 position; 3975 attribute vec2 uv; 3976 3977 varying vec2 vUv; 3978 3979 void main() { 3980 vUv = uv; 3981 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 3982 }`,fragmentShader:` 3983 precision highp float; 3984 3985 uniform sampler2D tDiffuse; 3986 3987 varying vec2 vUv; 3988 3989 #include <tonemapping_pars_fragment> 3990 #include <colorspace_pars_fragment> 3991 3992 void main() { 3993 gl_FragColor = texture2D( tDiffuse, vUv ); 3994 3995 #ifdef LINEAR_TONE_MAPPING 3996 gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); 3997 #elif defined( REINHARD_TONE_MAPPING ) 3998 gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); 3999 #elif defined( CINEON_TONE_MAPPING ) 4000 gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); 4001 #elif defined( ACES_FILMIC_TONE_MAPPING ) 4002 gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); 4003 #elif defined( AGX_TONE_MAPPING ) 4004 gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); 4005 #elif defined( NEUTRAL_TONE_MAPPING ) 4006 gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); 4007 #elif defined( CUSTOM_TONE_MAPPING ) 4008 gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); 4009 #endif 4010 4011 #ifdef SRGB_TRANSFER 4012 gl_FragColor = sRGBTransferOETF( gl_FragColor ); 4013 #endif 4014 }`,depthTest:!1,depthWrite:!1}),f=new nt(c,l),m=new Pa(-1,1,1,-1,0,1);let u=null,_=null,v=!1,y,g=null,h=[],b=!1;this.setSize=function(R,M){a.setSize(R,M),o.setSize(R,M);for(let A=0;A<h.length;A++){const S=h[A];S.setSize&&S.setSize(R,M)}},this.setEffects=function(R){h=R,b=h.length>0&&h[0].isRenderPass===!0;const M=a.width,A=a.height;for(let S=0;S<h.length;S++){const C=h[S];C.setSize&&C.setSize(M,A)}},this.begin=function(R,M){if(v||R.toneMapping===an&&h.length===0)return!1;if(g=M,M!==null){const A=M.width,S=M.height;(a.width!==A||a.height!==S)&&this.setSize(A,S)}return b===!1&&R.setRenderTarget(a),y=R.toneMapping,R.toneMapping=an,!0},this.hasRenderPass=function(){return b},this.end=function(R,M){R.toneMapping=y,v=!0;let A=a,S=o;for(let C=0;C<h.length;C++){const p=h[C];if(p.enabled!==!1&&(p.render(R,S,A,M),p.needsSwap!==!1)){const E=A;A=S,S=E}}if(u!==R.outputColorSpace||_!==R.toneMapping){u=R.outputColorSpace,_=R.toneMapping,l.defines={},ze.getTransfer(u)===Ke&&(l.defines.SRGB_TRANSFER="");const C=Od[_];C&&(l.defines[C]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=A.texture,R.setRenderTarget(g),R.render(f,m),g=null,v=!1},this.isCompositing=function(){return v},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),c.dispose(),l.dispose()}}const Bl=new Dt,ua=new Mi(1,1),zl=new El,Gl=new ru,Vl=new Cl,No=[],Fo=[],Oo=new Float32Array(16),Bo=new Float32Array(9),zo=new Float32Array(4);function Ai(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=No[r];if(s===void 0&&(s=new Float32Array(r),No[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function mt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function gt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Fr(i,e){let t=Fo[e];t===void 0&&(t=new Int32Array(e),Fo[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function zd(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Gd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(mt(t,e))return;i.uniform2fv(this.addr,e),gt(t,e)}}function Vd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(mt(t,e))return;i.uniform3fv(this.addr,e),gt(t,e)}}function Hd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(mt(t,e))return;i.uniform4fv(this.addr,e),gt(t,e)}}function kd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(mt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),gt(t,e)}else{if(mt(t,n))return;zo.set(n),i.uniformMatrix2fv(this.addr,!1,zo),gt(t,n)}}function Wd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(mt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),gt(t,e)}else{if(mt(t,n))return;Bo.set(n),i.uniformMatrix3fv(this.addr,!1,Bo),gt(t,n)}}function Xd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(mt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),gt(t,e)}else{if(mt(t,n))return;Oo.set(n),i.uniformMatrix4fv(this.addr,!1,Oo),gt(t,n)}}function qd(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Yd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(mt(t,e))return;i.uniform2iv(this.addr,e),gt(t,e)}}function Kd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(mt(t,e))return;i.uniform3iv(this.addr,e),gt(t,e)}}function Zd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(mt(t,e))return;i.uniform4iv(this.addr,e),gt(t,e)}}function $d(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Jd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(mt(t,e))return;i.uniform2uiv(this.addr,e),gt(t,e)}}function Qd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(mt(t,e))return;i.uniform3uiv(this.addr,e),gt(t,e)}}function jd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(mt(t,e))return;i.uniform4uiv(this.addr,e),gt(t,e)}}function ep(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(ua.compareFunction=t.isReversedDepthBuffer()?Ea:Sa,s=ua):s=Bl,t.setTexture2D(e||s,r)}function tp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Gl,r)}function np(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||Vl,r)}function ip(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||zl,r)}function rp(i){switch(i){case 5126:return zd;case 35664:return Gd;case 35665:return Vd;case 35666:return Hd;case 35674:return kd;case 35675:return Wd;case 35676:return Xd;case 5124:case 35670:return qd;case 35667:case 35671:return Yd;case 35668:case 35672:return Kd;case 35669:case 35673:return Zd;case 5125:return $d;case 36294:return Jd;case 36295:return Qd;case 36296:return jd;case 35678:case 36198:case 36298:case 36306:case 35682:return ep;case 35679:case 36299:case 36307:return tp;case 35680:case 36300:case 36308:case 36293:return np;case 36289:case 36303:case 36311:case 36292:return ip}}function sp(i,e){i.uniform1fv(this.addr,e)}function ap(i,e){const t=Ai(e,this.size,2);i.uniform2fv(this.addr,t)}function op(i,e){const t=Ai(e,this.size,3);i.uniform3fv(this.addr,t)}function lp(i,e){const t=Ai(e,this.size,4);i.uniform4fv(this.addr,t)}function cp(i,e){const t=Ai(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function up(i,e){const t=Ai(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function hp(i,e){const t=Ai(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function fp(i,e){i.uniform1iv(this.addr,e)}function dp(i,e){i.uniform2iv(this.addr,e)}function pp(i,e){i.uniform3iv(this.addr,e)}function mp(i,e){i.uniform4iv(this.addr,e)}function gp(i,e){i.uniform1uiv(this.addr,e)}function _p(i,e){i.uniform2uiv(this.addr,e)}function xp(i,e){i.uniform3uiv(this.addr,e)}function vp(i,e){i.uniform4uiv(this.addr,e)}function Mp(i,e,t){const n=this.cache,r=e.length,s=Fr(t,r);mt(n,s)||(i.uniform1iv(this.addr,s),gt(n,s));let a;this.type===i.SAMPLER_2D_SHADOW?a=ua:a=Bl;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||a,s[o])}function Sp(i,e,t){const n=this.cache,r=e.length,s=Fr(t,r);mt(n,s)||(i.uniform1iv(this.addr,s),gt(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Gl,s[a])}function Ep(i,e,t){const n=this.cache,r=e.length,s=Fr(t,r);mt(n,s)||(i.uniform1iv(this.addr,s),gt(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Vl,s[a])}function yp(i,e,t){const n=this.cache,r=e.length,s=Fr(t,r);mt(n,s)||(i.uniform1iv(this.addr,s),gt(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||zl,s[a])}function Tp(i){switch(i){case 5126:return sp;case 35664:return ap;case 35665:return op;case 35666:return lp;case 35674:return cp;case 35675:return up;case 35676:return hp;case 5124:case 35670:return fp;case 35667:case 35671:return dp;case 35668:case 35672:return pp;case 35669:case 35673:return mp;case 5125:return gp;case 36294:return _p;case 36295:return xp;case 36296:return vp;case 35678:case 36198:case 36298:case 36306:case 35682:return Mp;case 35679:case 36299:case 36307:return Sp;case 35680:case 36300:case 36308:case 36293:return Ep;case 36289:case 36303:case 36311:case 36292:return yp}}class bp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=rp(t.type)}}class Ap{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Tp(t.type)}}class wp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const gs=/(\w+)(\])?(\[|\.)?/g;function Go(i,e){i.seq.push(e),i.map[e.id]=e}function Rp(i,e,t){const n=i.name,r=n.length;for(gs.lastIndex=0;;){const s=gs.exec(n),a=gs.lastIndex;let o=s[1];const c=s[2]==="]",l=s[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===r){Go(t,l===void 0?new bp(o,i,e):new Ap(o,i,e));break}else{let m=t.map[o];m===void 0&&(m=new wp(o),Go(t,m)),t=m}}}class yr{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);Rp(o,c,this)}const r=[],s=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):s.push(a);r.length>0&&(this.seq=r.concat(s))}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function Vo(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Cp=37297;let Pp=0;function Dp(i,e){const t=i.split(` 4015`),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(` 4016`)}const Ho=new Ce;function Lp(i){ze._getMatrix(Ho,ze.workingColorSpace,i);const e=`mat3( ${Ho.elements.map(t=>t.toFixed(4))} )`;switch(ze.getTransfer(i)){case Rr:return[e,"LinearTransferOETF"];case Ke:return[e,"sRGBTransferOETF"];default:return we("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function ko(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` 4017 4018`+s+` 4019 4020`+Dp(i.getShaderSource(e),o)}else return s}function Ip(i,e){const t=Lp(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` 4021`)}const Up={[ll]:"Linear",[cl]:"Reinhard",[ul]:"Cineon",[da]:"ACESFilmic",[fl]:"AgX",[dl]:"Neutral",[hl]:"Custom"};function Np(i,e){const t=Up[e];return t===void 0?(we("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const _r=new N;function Fp(){ze.getLuminanceCoefficients(_r);const i=_r.x.toFixed(4),e=_r.y.toFixed(4),t=_r.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` 4022`)}function Op(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fi).join(` 4023`)}function Bp(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` 4024`)}function zp(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Fi(i){return i!==""}function Wo(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Xo(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Gp=/^[ \t]*#include +<([\w\d./]+)>/gm;function ha(i){return i.replace(Gp,Hp)}const Vp=new Map;function Hp(i,e){let t=Ue[e];if(t===void 0){const n=Vp.get(e);if(n!==void 0)t=Ue[n],we('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return ha(t)}const kp=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function qo(i){return i.replace(kp,Wp)}function Wp(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Yo(i){let e=`precision ${i.precision} float; 4025 precision ${i.precision} int; 4026 precision ${i.precision} sampler2D; 4027 precision ${i.precision} samplerCube; 4028 precision ${i.precision} sampler3D; 4029 precision ${i.precision} sampler2DArray; 4030 precision ${i.precision} sampler2DShadow; 4031 precision ${i.precision} samplerCubeShadow; 4032 precision ${i.precision} sampler2DArrayShadow; 4033 precision ${i.precision} isampler2D; 4034 precision ${i.precision} isampler3D; 4035 precision ${i.precision} isamplerCube; 4036 precision ${i.precision} isampler2DArray; 4037 precision ${i.precision} usampler2D; 4038 precision ${i.precision} usampler3D; 4039 precision ${i.precision} usamplerCube; 4040 precision ${i.precision} usampler2DArray; 4041 `;return i.precision==="highp"?e+=` 4042#define HIGH_PRECISION`:i.precision==="mediump"?e+=` 4043#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=` 4044#define LOW_PRECISION`),e}const Xp={[xr]:"SHADOWMAP_TYPE_PCF",[Ni]:"SHADOWMAP_TYPE_VSM"};function qp(i){return Xp[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const Yp={[Yn]:"ENVMAP_TYPE_CUBE",[vi]:"ENVMAP_TYPE_CUBE",[Ur]:"ENVMAP_TYPE_CUBE_UV"};function Kp(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":Yp[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const Zp={[vi]:"ENVMAP_MODE_REFRACTION"};function $p(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":Zp[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const Jp={[ol]:"ENVMAP_BLENDING_MULTIPLY",[Ec]:"ENVMAP_BLENDING_MIX",[yc]:"ENVMAP_BLENDING_ADD"};function Qp(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":Jp[i.combine]||"ENVMAP_BLENDING_NONE"}function jp(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function em(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;
vendor: 7,066 bytes, lines 4044-4051
4044const c=qp(t),l=Kp(t),f=$p(t),m=Qp(t),u=jp(t),_=Op(t),v=Bp(s),y=r.createProgram();let g,h,b=t.glslVersion?"#version "+t.glslVersion+` 4045`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Fi).join(` 4046`),g.length>0&&(g+=` 4047`),h=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Fi).join(` 4048`),h.length>0&&(h+=` 4049`)):(g=[Yo(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` 4050`].filter(Fi).join(` 4051`),h=[Yo(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+f:"",t.envMap?"#define "+m:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IR
4051IDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==an?"#define TONE_MAPPING":"",t.toneMapping!==an?Ue.tonemapping_pars_fragment:"",t.toneMapping!==an?Np("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ue.colorspace_pars_fragment,Ip("linearToOutputTexel",t.outputColorSpace),Fp(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` 4052`].filter(Fi).join(` 4053`)),a=ha(a),a=Wo(a,t),a=Xo(a,t),o=ha(o),o=Wo(o,t),o=Xo(o,t),a=qo(a),o=qo(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es 4054`,g=[_,"#define attribute in","#define varying out","#define texture2D texture"].join(` 4055`)+` 4056`+g,h=["#define varying in",t.glslVersion===Qa?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Qa?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` 4057`)+` 4058`+h);const R=b+g+a,M=b+h+o,A=Vo(r,r.VERTEX_SHADER,R),S=Vo(r,r.FRAGMENT_SHADER,M);r.attachShader(y,A),r.attachShader(y,S),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.hasPositionAttribute===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function C(P){if(i.debug.checkShaderErrors){const I=r.getProgramInfoLog(y)||"",X=r.getShaderInfoLog(A)||"",H=r.getShaderInfoLog(S)||"",O=I.trim(),W=X.trim(),k=H.trim();let J=!0,j=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(J=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,y,A,S);else{const le=ko(r,A,"vertex"),he=ko(r,S,"fragment");We("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+` 4059 4060Material Name: `+P.name+` 4061Material Type: `+P.type+` 4062 4063Program Info Log: `+O+` 4064`+le+` 4065`+he)}else O!==""?we("WebGLProgram: Program Info Log:",O):(W===""||k==="")&&(j=!1);j&&(P.diagnostics={runnable:J,programLog:O,vertexShader:{log:W,prefix:g},fragmentShader:{log:k,prefix:h}})}r.deleteShader(A),r.deleteShader(S),p=new yr(r,y),E=zp(r,y)}let p;this.getUniforms=function(){return p===void 0&&C(this),p};let E;this.getAttributes=function(){return E===void 0&&C(this),E};let w=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return w===!1&&(w=r.getProgramParameter(y,Cp)),w},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Pp++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=S,this}let tm=0;class nm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new im(e),t.set(e,n)),n}}class im{constructor(e){this.id=tm++,this.code=e,this.usedTimes=0}}function rm(i){return i===Kn||i===br||i===Ar}
4065function sm(i,e,t,n,r,s){const a=new yl,o=new nm,c=new Set,l=[],f=new Map,m=n.logarithmicDepthBuffer;let u=n.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(p){return c.add(p),p===0?"uv":`uv${p}`}function y(p,E,w,P,I,X){const H=P.fog,O=I.geometry,W=p.isMeshStandardMaterial||p.isMeshLambertMaterial||p.isMeshPhongMaterial?P.environment:null,k=p.isMeshStandardMaterial||p.isMeshLambertMaterial&&!p.envMap||p.isMeshPhongMaterial&&!p.envMap,J=e.get(p.envMap||W,k),j=J&&J.mapping===Ur?J.image.height:null,le=_[p.type];p.precision!==null&&(u=n.getMaxPrecision(p.precision),u!==p.precision&&we("WebGLProgram.getParameters:",p.precision,"not supported, using",u,"instead."));const he=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,_e=he!==void 0?he.length:0;let Ve=0;O.morphAttributes.position!==void 0&&(Ve=1),O.morphAttributes.normal!==void 0&&(Ve=2),O.morphAttributes.color!==void 0&&(Ve=3);let rt,Xe,$,ie;if(le){const xe=tn[le];rt=xe.vertexShader,Xe=xe.fragmentShader}else{rt=p.vertexShader,Xe=p.fragmentShader;const xe=o.getVertexShaderStage(p),at=o.getFragmentShaderStage(p);o.update(p,xe,at),$=xe.id,ie=at.id}const ee=i.getRenderTarget(),Re=i.state.buffers.depth.getReversed(),De=I.isInstancedMesh===!0,be=I.isBatchedMesh===!0,lt=!!p.map,Oe=!!p.matcap,$e=!!J,qe=!!p.aoMap,He=!!p.lightMap,ht=!!p.bumpMap&&p.wireframe===!1,pt=!!p.normalMap,_t=!!p.displacementMap,St=!!p.emissiveMap,st=!!p.metalnessMap,ft=!!p.roughnessMap,L=p.anisotropy>0,Lt=p.clearcoat>0,Ye=p.dispersion>0,T=p.iridescence>0,d=p.sheen>0,F=p.transmission>0,G=L&&!!p.anisotropyMap,q=Lt&&!!p.clearcoatMap,te=Lt&&!!p.clearcoatNormalMap,re=Lt&&!!p.clearcoatRoughnessMap,Y=T&&!!p.iridescenceMap,Z=T&&!!p.iridescenceThicknessMap,se=d&&!!p.sheenColorMap,Se=d&&!!p.sheenRoughnessMap,ce=!!p.specularMap,ae=!!p.specularColorMap,Te=!!p.specularIntensityMap,Ae=F&&!!p.transmissionMap,Le=F&&!!p.thicknessMap,D=!!p.gradientMap,ne=!!p.alph
vendor: 4,448 bytes, line 4065
4065aMap,K=p.alphaTest>0,oe=!!p.alphaHash,pe=!!p.extensions;let Q=an;p.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(Q=i.toneMapping);const Me={shaderID:le,shaderType:p.type,shaderName:p.name,vertexShader:rt,fragmentShader:Xe,defines:p.defines,customVertexShaderID:$,customFragmentShaderID:ie,isRawShaderMaterial:p.isRawShaderMaterial===!0,glslVersion:p.glslVersion,precision:u,batching:be,batchingColor:be&&I._colorsTexture!==null,instancing:De,instancingColor:De&&I.instanceColor!==null,instancingMorph:De&&I.morphTexture!==null,outputColorSpace:ee===null?i.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:ze.workingColorSpace,alphaToCoverage:!!p.alphaToCoverage,map:lt,matcap:Oe,envMap:$e,envMapMode:$e&&J.mapping,envMapCubeUVHeight:j,aoMap:qe,lightMap:He,bumpMap:ht,normalMap:pt,displacementMap:_t,emissiveMap:St,normalMapObjectSpace:pt&&p.normalMapType===Ac,normalMapTangentSpace:pt&&p.normalMapType===ca,packedNormalMap:pt&&p.normalMapType===ca&&rm(p.normalMap.format),metalnessMap:st,roughnessMap:ft,anisotropy:L,anisotropyMap:G,clearcoat:Lt,clearcoatMap:q,clearcoatNormalMap:te,clearcoatRoughnessMap:re,dispersion:Ye,iridescence:T,iridescenceMap:Y,iridescenceThicknessMap:Z,sheen:d,sheenColorMap:se,sheenRoughnessMap:Se,specularMap:ce,specularColorMap:ae,specularIntensityMap:Te,transmission:F,transmissionMap:Ae,thicknessMap:Le,gradientMap:D,opaque:p.transparent===!1&&p.blending===mi&&p.alphaToCoverage===!1,alphaMap:ne,alphaTest:K,alphaHash:oe,combine:p.combine,mapUv:lt&&v(p.map.channel),aoMapUv:qe&&v(p.aoMap.channel),lightMapUv:He&&v(p.lightMap.channel),bumpMapUv:ht&&v(p.bumpMap.channel),normalMapUv:pt&&v(p.normalMap.channel),displacementMapUv:_t&&v(p.displacementMap.channel),emissiveMapUv:St&&v(p.emissiveMap.channel),metalnessMapUv:st&&v(p.metalnessMap.channel),roughnessMapUv:ft&&v(p.roughnessMap.channel),anisotropyMapUv:G&&v(p.anisotropyMap.channel),clearcoatMapUv:q&&v(p.clearcoatMap.channel),clearcoatNormalMapUv:te&&v(p.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&v(p.clearcoatRoughnessMap.channel),iridescenceMapUv:Y&&v(p.iridescenceMap.channel),iridescenceThicknessMapUv:Z&&v(p.iridescenceThicknessMap.channel),sheenColorMapUv:se&&v(p.sheenColorMap.channel),sheenRoughnessMapUv:Se&&v(p.sheenRoughnessMap.channel),specularMapUv:ce&&v(p.specularMap.channel),specularColorMapUv:ae&&v(p.specularColorMap.channel),specularIntensityMapUv:Te&&v(p.specularIntensityMap.channel),transmissionMapUv:Ae&&v(p.transmissionMap.channel),thicknessMapUv:Le&&v(p.thicknessMap.channel),alphaMapUv:ne&&v(p.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(pt||L),vertexNormals:!!O.attributes.normal,vertexColors:p.vertexColors,vertexAlphas:p.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(lt||ne),fog:!!H,useFog:p.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:p.wireframe===!1&&(p.flatShading===!0||O.attributes.normal===void 0&&pt===!1&&(p.isMeshLambertMaterial||p.isMeshPhongMaterial||p.isMeshStandardMaterial||p.isMeshPhysicalMaterial)),sizeAttenuation:p.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:Re,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:_e,morphTextureStride:Ve,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numLightProbeGrids:X.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:p.dithering,shadowMapEnabled:i.shadowMap.enabled&&w.length>0,shadowMapType:i.shadowMap.type,toneMapping:Q,decodeVideoTexture:lt&&p.map.isVideoTexture===!0&&ze.getTransfer(p.map.colorSpace)===Ke,decodeVideoTextureEmissive:St&&p.emissiveMap.isVideoTexture===!0&&ze.getTransfer(p.emissiveMap.colorSpace)===Ke,premultipliedAlpha:p.premultipliedAlpha,doubleSided:p.side===nn,flipSided:p.side===Pt,useDepthPacking:p.depthPacking>=0,depthPacking:p.depthPacking||0,index0AttributeName:p.index0AttributeName,extensionCl
vendor: 12,951 bytes, line 4065
4065ipCullDistance:pe&&p.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pe&&p.extensions.multiDraw===!0||be)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:p.customProgramCacheKey()};return Me.vertexUv1s=c.has(1),Me.vertexUv2s=c.has(2),Me.vertexUv3s=c.has(3),c.clear(),Me}function g(p){const E=[];if(p.shaderID?E.push(p.shaderID):(E.push(p.customVertexShaderID),E.push(p.customFragmentShaderID)),p.defines!==void 0)for(const w in p.defines)E.push(w),E.push(p.defines[w]);return p.isRawShaderMaterial===!1&&(h(E,p),b(E,p),E.push(i.outputColorSpace)),E.push(p.customProgramCacheKey),E.join()}function h(p,E){p.push(E.precision),p.push(E.outputColorSpace),p.push(E.envMapMode),p.push(E.envMapCubeUVHeight),p.push(E.mapUv),p.push(E.alphaMapUv),p.push(E.lightMapUv),p.push(E.aoMapUv),p.push(E.bumpMapUv),p.push(E.normalMapUv),p.push(E.displacementMapUv),p.push(E.emissiveMapUv),p.push(E.metalnessMapUv),p.push(E.roughnessMapUv),p.push(E.anisotropyMapUv),p.push(E.clearcoatMapUv),p.push(E.clearcoatNormalMapUv),p.push(E.clearcoatRoughnessMapUv),p.push(E.iridescenceMapUv),p.push(E.iridescenceThicknessMapUv),p.push(E.sheenColorMapUv),p.push(E.sheenRoughnessMapUv),p.push(E.specularMapUv),p.push(E.specularColorMapUv),p.push(E.specularIntensityMapUv),p.push(E.transmissionMapUv),p.push(E.thicknessMapUv),p.push(E.combine),p.push(E.fogExp2),p.push(E.sizeAttenuation),p.push(E.morphTargetsCount),p.push(E.morphAttributeCount),p.push(E.numDirLights),p.push(E.numPointLights),p.push(E.numSpotLights),p.push(E.numSpotLightMaps),p.push(E.numHemiLights),p.push(E.numRectAreaLights),p.push(E.numDirLightShadows),p.push(E.numPointLightShadows),p.push(E.numSpotLightShadows),p.push(E.numSpotLightShadowsWithMaps),p.push(E.numLightProbes),p.push(E.shadowMapType),p.push(E.toneMapping),p.push(E.numClippingPlanes),p.push(E.numClipIntersection),p.push(E.depthPacking)}function b(p,E){a.disableAll(),E.instancing&&a.enable(0),E.instancingColor&&a.enable(1),E.instancingMorph&&a.enable(2),E.matcap&&a.enable(3),E.envMap&&a.enable(4),E.normalMapObjectSpace&&a.enable(5),E.normalMapTangentSpace&&a.enable(6),E.clearcoat&&a.enable(7),E.iridescence&&a.enable(8),E.alphaTest&&a.enable(9),E.vertexColors&&a.enable(10),E.vertexAlphas&&a.enable(11),E.vertexUv1s&&a.enable(12),E.vertexUv2s&&a.enable(13),E.vertexUv3s&&a.enable(14),E.vertexTangents&&a.enable(15),E.anisotropy&&a.enable(16),E.alphaHash&&a.enable(17),E.batching&&a.enable(18),E.dispersion&&a.enable(19),E.batchingColor&&a.enable(20),E.gradientMap&&a.enable(21),E.packedNormalMap&&a.enable(22),E.vertexNormals&&a.enable(23),p.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.reversedDepthBuffer&&a.enable(4),E.skinning&&a.enable(5),E.morphTargets&&a.enable(6),E.morphNormals&&a.enable(7),E.morphColors&&a.enable(8),E.premultipliedAlpha&&a.enable(9),E.shadowMapEnabled&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),E.decodeVideoTexture&&a.enable(19),E.decodeVideoTextureEmissive&&a.enable(20),E.alphaToCoverage&&a.enable(21),E.numLightProbeGrids>0&&a.enable(22),E.hasPositionAttribute&&a.enable(23),p.push(a.mask)}function R(p){const E=_[p.type];let w;if(E){const P=tn[E];w=Ll.clone(P.uniforms)}else w=p.uniforms;return w}function M(p,E){let w=f.get(E);return w!==void 0?++w.usedTimes:(w=new em(i,E,p,r),l.push(w),f.set(E,w)),w}function A(p){if(--p.usedTimes===0){const E=l.indexOf(p);l[E]=l[l.length-1],l.pop(),f.delete(p.cacheKey),p.destroy()}}function S(p){o.remove(p)}function C(){o.dispose()}return{getParameters:y,getProgramCacheKey:g,getUniforms:R,acquireProgram:M,releaseProgram:A,releaseShaderCache:S,programs:l,dispose:C}}function am(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,c){i.get(a)[o]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function om(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function Ko(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Zo(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(u){let _=0;return u.isInstancedMesh&&(_+=2),u.isSkinnedMesh&&(_+=1),_}function o(u,_,v,y,g,h){let b=i[e];return b===void 0?(b={id:u.id,object:u,geometry:_,material:v,materialVariant:a(u),groupOrder:y,renderOrder:u.renderOrder,z:g,group:h},i[e]=b):(b.id=u.id,b.object=u,b.geometry=_,b.material=v,b.materialVariant=a(u),b.groupOrder=y,b.renderOrder=u.renderOrder,b.z=g,b.group=h),e++,b}function c(u,_,v,y,g,h){const b=o(u,_,v,y,g,h);v.transmission>0?n.push(b):v.transparent===!0?r.push(b):t.push(b)}function l(u,_,v,y,g,h){const b=o(u,_,v,y,g,h);v.transmission>0?n.unshift(b):v.transparent===!0?r.unshift(b):t.unshift(b)}function f(u,_,v){t.length>1&&t.sort(u||om),n.length>1&&n.sort(_||Ko),r.length>1&&r.sort(_||Ko),v&&(t.reverse(),n.reverse(),r.reverse())}function m(){for(let u=e,_=i.length;u<_;u++){const v=i[u];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:c,unshift:l,finish:m,sort:f}}function lm(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new Zo,i.set(n,[a])):r>=s.length?(a=new Zo,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function cm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new Ge};break;case"SpotLight":t={position:new N,direction:new N,color:new Ge,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new Ge,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new Ge,groundColor:new Ge};break;case"RectAreaLight":t={color:new Ge,position:new N,halfWidth:new N,halfHeight:new N};break}return i[e.id]=t,t}}}function um(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let hm=0;function fm(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function dm(i){const e=new cm,t=um(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new N);const r=new N,s=new tt,a=new tt;function o(l){let f=0,m=0,u=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let _=0,v=0,y=0,g=0,h=0,b=0,R=0,M=0,A=0,S=0,C=0;l.sort(fm);for(let E=0,w=l.length;E<w;E++){const P=l[E],I=P.color,X=P.intensity,H=P.distance;let O=null;if(P.shadow&&P.shadow.map&&(P.shadow.map.texture.format===Kn?O=P.shadow.map.texture:O=P.shadow.map.depthTexture||P.shadow.map.texture),P.isAmbientLight)f+=I.r*X,m+=I.g*X,u+=I.b*X;else if(P.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(P.sh.coefficients[W],X);C++}else if(P.isDirectionalLight){const W=e.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){const k=P.shadow,J=t.get(P);J.shadowIntensity=k.intensity,J.shadowBias=k.bias,J.shadowNormalBias=k.normalBias,J.shadowRadius=k.radius,J.shadowMapSize=k.mapSize,n.directionalShadow[_]=J,n.directionalShadowMap[_]=O,n.directionalShadowMatrix[_]=P.shadow.matrix,b++}n.directional[_]=W,_++}else if(P.isSpotLight){const W=e.get(P);W.position.setFromMatrixPosition(P.matrixWorld),W.color.copy(I).multiplyScalar(X),W.distance=H,W.coneCos=Math.cos(P.angle),W.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),W.decay=P.decay,n.spot[y]=W;const k=P.shadow;if(P.map&&(n.spotLightMap[A]=P.map,A++,k.updateMatrices(P),P.castShadow&&S++),n.spotLightMatrix[y]=k.matrix,P.castShadow){const J=t.get(P);J.shadowIntensity=k.intensity,J.shadowBias=k.bias,J.shadowNormalBias=k.normalBias,J.shadowRadius=k.radius,J.shadowMapSize=k.mapSize,n.spotShadow[y]=J,n.spotShadowMap[y]=O,M++}y++}else if(P.isRectAreaLight){const W=e.get(P);W.color.copy(I).multiplyScalar(X),W.halfWidth.set(P.width*.5,0,0),W.halfHeight.set(0,P.height*.5,0),n.rectArea[g]=W,g++}else if(P.isPointLight){const W=e.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),W.distance=P.distance,W.decay=P.decay,P.castShadow){const k=P.shadow,J=t.get(P);J.shadowIntensity=k.intensity,J.shadowBias=k.bias,J.shadowNormalBias=k.normalBias,J.shadowRadius=k.radius,J.shadowMapSize=k.mapSize,J.shadowCameraNear=k.camera.near,J.shadowCameraFar=k.camera.far,n.pointShadow[v]=J,n.pointShadowMap[v]=O,n.pointShadowMatrix[v]=P.shadow.matrix,R++}n.point[v]=W,v++}else if(P.isHemisphereLight){const W=e.get(P);W.skyColor.copy(P.color).multiplyScalar(X),W.groundColor.copy(P.groundColor).multiplyScalar(X),n.hemi[h]=W,h++}}g>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ue.LTC_FLOAT_1,n.rectAreaLTC2=ue.LTC_FLOAT_2):(n.rectAreaLTC1=ue.LTC_HALF_1,n.rectAreaLTC2=ue.LTC_HALF_2)),n.ambient[0]=f,n.ambient[1]=m,n.ambient[2]=u;const p=n.hash;(p.directionalLength!==_||p.pointLength!==v||p.spotLength!==y||p.rectAreaLength!==g||p.hemiLength!==h||p.numDirectionalShadows!==b||p.numPointShadows!==R||p.numSpotShadows!==M||p.numSpotMaps!==A||p.numLightProbes!==C)&&(n.directional.length=_,n.spot.length=y,n.rectArea.length=g,n.point.length=v,n.hemi.length=h,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=R,n.pointShadowMap.length=R,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=R,n.spotLightMatrix.length=M+A-S,n.spotLightMap.length=A,n.numSpotLightShadowsWithMaps=S,n.numLightProbes=C,p.directionalLength=_,p.pointLength=v,p.spotLength=y,p.rectAreaLength=g,p.hemiLength=h,p.numDirectionalShadows=b,p.numPointShadows=R,p.numSpotShadows=M,p.numSpotMaps=A,p.numLightProbes=C,n.version=hm++)}function c(l,f){let m=0,u=0,_=0,v=0,y=0;const g=f.matrixWorldInverse;for(let h=0,b=l.length;h<b;h++){const R=l[h];if(R.isDirectionalLight){const M=n.directional[m];M.direction.setFromMatrixPosition(R.matrixWorld),r.setFromMatrixPosition(R.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),m++}else if(R.isSpotLight){const M=n.spot[_];M.position.setFromMatrixPosition(R.matrixWorld),M.position.applyMatrix4(g),M.direction.setFromMatrixPosition(R.matrixWorld),r.setFromMatrixPosition(R.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),_++}else if(R.isRectAreaLight){const M=n.rectArea[v];M.position.setFromMatrixPosition(R.matrixWorld),M.position.applyMatrix4(g),a.identity(),s.copy(R.matrixWorld),s.premultiply(g),a.extractRotation(s),M.halfWidth.set(R.width*.5,0,0),M.halfHeight.set(0,R.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),v++}else if(R.isPointLight){const M=n.point[u];M.position.setFromMatrixPosition(R.matrixWorld),M.position.applyMatrix4(g),u++}else if(R.isHemisphereLight){const M=n.hemi[y];M.direction.setFromMatrixPosition(R.matrixWorld),M.direction.transformDirection(g),y++}}}return{setup:o,setupView:c,state:n}}function $o(i){const e=new dm(i),t=[],n=[],r=[];function s(u){m.camera=u,t.length=0,n.length=0,r.length=0}function a(u){t.push(u)}function o(u){n.push(u)}function c(u){r.push(u)}function l(){e.setup(t)}function f(u){e.setupView(t,u)}const m={lightsArray:t,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:m,setupLights:l,setupLightsView:f,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function pm(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new $o(i),e.set(r,[o])):s>=a.length?(o=new $o(i),a.push(o)):o=a[s],o}
vendor: 4,067 bytes, lines 4065-4092
4065function n(){e=new WeakMap}return{get:t,dispose:n}}const mm=`void main() { 4066 gl_Position = vec4( position, 1.0 ); 4067}`,gm=`uniform sampler2D shadow_pass; 4068uniform vec2 resolution; 4069uniform float radius; 4070void main() { 4071 const float samples = float( VSM_SAMPLES ); 4072 float mean = 0.0; 4073 float squared_mean = 0.0; 4074 float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); 4075 float uvStart = samples <= 1.0 ? 0.0 : - 1.0; 4076 for ( float i = 0.0; i < samples; i ++ ) { 4077 float uvOffset = uvStart + i * uvStride; 4078 #ifdef HORIZONTAL_PASS 4079 vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; 4080 mean += distribution.x; 4081 squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; 4082 #else 4083 float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; 4084 mean += depth; 4085 squared_mean += depth * depth; 4086 #endif 4087 } 4088 mean = mean / samples; 4089 squared_mean = squared_mean / samples; 4090 float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); 4091 gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); 4092}`,_m=[new N(1,0,0),new N(-1,0,0),new N(0,1,0),new N(0,-1,0),new N(0,0,1),new N(0,0,-1)],xm=[new N(0,-1,0),new N(0,-1,0),new N(0,0,1),new N(0,0,-1),new N(0,-1,0),new N(0,-1,0)],Jo=new tt,Ui=new N,_s=new N;function vm(i,e,t){let n=new Aa;const r=new Fe,s=new Fe,a=new it,o=new Ru,c=new Cu,l={},f=t.maxTextureSize,m={[Dn]:Pt,[Pt]:Dn,[nn]:nn},u=new Zt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Fe},radius:{value:4}},vertexShader:mm,fragmentShader:gm}),_=u.clone();_.defines.HORIZONTAL_PASS=1;const v=new Vt;v.setAttribute("position",new Kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new nt(v,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xr;let h=this.type;this.render=function(S,C,p){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;this.type===ic&&(we("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=xr);const E=i.getRenderTarget(),w=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),I=i.state;I.setBlending(mn),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const X=h!==this.type;X&&C.traverse(function(H){H.material&&(Array.isArray(H.material)?H.material.forEach(O=>O.needsUpdate=!0):H.material.needsUpdate=!0)});for(let H=0,O=S.length;H<O;H++){const W=S[H],k=W.shadow;if(k===void 0){we("WebGLShadowMap:",W,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);const J=k.getFrameExtents();r.multiply(J),s.copy(k.mapSize),(r.x>f||r.y>f)&&(r.x>f&&(s.x=Math.floor(f/J.x),r.x=s.x*J.x,k.mapSize.x=s.x),r.y>f&&(s.y=Math.floor(f/J.y),r.y=s.y*J.y,k.mapSize.y=s.y));const j=i.state.buffers.depth.getReversed();if(k.camera._reversedDepth=j,k.map===null||X===!0){if(k.map!==null&&(k.map.depthTexture!==null&&(k.map.depthTexture.dispose(),k.map.depthTexture=null),k.map.dispose()),this.type===Ni){if(W.isPointLight){we("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new on(r.x,r.y,{format:Kn,type:xn,minFilter:wt,magFilter:wt,generateMipmaps:!1}),k.map.texture.name=W.name+".shadowMap",k.map.depthTexture=new Mi(r.x,r.y,qt),k.map.depthTexture.name=W.name+".shadowMapDepth",k.map.depthTexture.format=vn,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Et,k.map.depthTexture.magFilter=Et}else W.isPointLight?(k.map=new Ol(r.x),k.map.depthTexture=new yu(r.x,ln)):(k.map=new on(r.x,r.y),k.map.depthTexture=new Mi(r.x,r.y,ln)),k.map.depthTexture.name=W.name+".shadowMap",k.map.depthTexture.format=vn,this.type===xr?(k.map.depthTexture.compareFunction=j?Ea:Sa,k.map.depthTexture.minFilter=wt,k.map.depthTexture.magFilter=wt):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=Et,k.map.depthTexture.magFilter=Et);k.camera.updateProjectionMatrix()}
vendor: 6,144 bytes, line 4092
4092const le=k.map.isWebGLCubeRenderTarget?6:1;for(let he=0;he<le;he++){if(k.map.isWebGLCubeRenderTarget)i.setRenderTarget(k.map,he),i.clear();else{he===0&&(i.setRenderTarget(k.map),i.clear());const _e=k.getViewport(he);a.set(s.x*_e.x,s.y*_e.y,s.x*_e.z,s.y*_e.w),I.viewport(a)}if(W.isPointLight){const _e=k.camera,Ve=k.matrix,rt=W.distance||_e.far;rt!==_e.far&&(_e.far=rt,_e.updateProjectionMatrix()),Ui.setFromMatrixPosition(W.matrixWorld),_e.position.copy(Ui),_s.copy(_e.position),_s.add(_m[he]),_e.up.copy(xm[he]),_e.lookAt(_s),_e.updateMatrixWorld(),Ve.makeTranslation(-Ui.x,-Ui.y,-Ui.z),Jo.multiplyMatrices(_e.projectionMatrix,_e.matrixWorldInverse),k._frustum.setFromProjectionMatrix(Jo,_e.coordinateSystem,_e.reversedDepth)}else k.updateMatrices(W);n=k.getFrustum(),M(C,p,k.camera,W,this.type)}k.isPointLightShadow!==!0&&this.type===Ni&&b(k,p),k.needsUpdate=!1}h=this.type,g.needsUpdate=!1,i.setRenderTarget(E,w,P)};function b(S,C){const p=e.update(y);u.defines.VSM_SAMPLES!==S.blurSamples&&(u.defines.VSM_SAMPLES=S.blurSamples,_.defines.VSM_SAMPLES=S.blurSamples,u.needsUpdate=!0,_.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new on(r.x,r.y,{format:Kn,type:xn})),u.uniforms.shadow_pass.value=S.map.depthTexture,u.uniforms.resolution.value=S.mapSize,u.uniforms.radius.value=S.radius,i.setRenderTarget(S.mapPass),i.clear(),i.renderBufferDirect(C,null,p,u,y,null),_.uniforms.shadow_pass.value=S.mapPass.texture,_.uniforms.resolution.value=S.mapSize,_.uniforms.radius.value=S.radius,i.setRenderTarget(S.map),i.clear(),i.renderBufferDirect(C,null,p,_,y,null)}function R(S,C,p,E){let w=null;const P=p.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(P!==void 0)w=P;else if(w=p.isPointLight===!0?c:o,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const I=w.uuid,X=C.uuid;let H=l[I];H===void 0&&(H={},l[I]=H);let O=H[X];O===void 0&&(O=w.clone(),H[X]=O,C.addEventListener("dispose",A)),w=O}if(w.visible=C.visible,w.wireframe=C.wireframe,E===Ni?w.side=C.shadowSide!==null?C.shadowSide:C.side:w.side=C.shadowSide!==null?C.shadowSide:m[C.side],w.alphaMap=C.alphaMap,w.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,w.map=C.map,w.clipShadows=C.clipShadows,w.clippingPlanes=C.clippingPlanes,w.clipIntersection=C.clipIntersection,w.displacementMap=C.displacementMap,w.displacementScale=C.displacementScale,w.displacementBias=C.displacementBias,w.wireframeLinewidth=C.wireframeLinewidth,w.linewidth=C.linewidth,p.isPointLight===!0&&w.isMeshDistanceMaterial===!0){const I=i.properties.get(w);I.light=p}return w}function M(S,C,p,E,w){if(S.visible===!1)return;if(S.layers.test(C.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&w===Ni)&&(!S.frustumCulled||n.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(p.matrixWorldInverse,S.matrixWorld);const X=e.update(S),H=S.material;if(Array.isArray(H)){const O=X.groups;for(let W=0,k=O.length;W<k;W++){const J=O[W],j=H[J.materialIndex];if(j&&j.visible){const le=R(S,j,E,w);S.onBeforeShadow(i,S,C,p,X,le,J),i.renderBufferDirect(p,null,X,le,S,J),S.onAfterShadow(i,S,C,p,X,le,J)}}}else if(H.visible){const O=R(S,H,E,w);S.onBeforeShadow(i,S,C,p,X,O,null),i.renderBufferDirect(p,null,X,O,S,null),S.onAfterShadow(i,S,C,p,X,O,null)}}const I=S.children;for(let X=0,H=I.length;X<H;X++)M(I[X],C,p,E,w)}function A(S){S.target.removeEventListener("dispose",A);for(const p in l){const E=l[p],w=S.target.uuid;w in E&&(E[w].dispose(),delete E[w])}}}function Mm(i,e){function t(){let D=!1;const ne=new it;let K=null;const oe=new it(0,0,0,0);return{setMask:function(pe){K!==pe&&!D&&(i.colorMask(pe,pe,pe,pe),K=pe)},setLocked:function(pe){D=pe},setClear:function(pe,Q,Me,xe,at){at===!0&&(pe*=xe,Q*=xe,Me*=xe),ne.set(pe,Q,Me,xe),oe.equals(ne)===!1&&(i.clearColor(pe,Q,Me,xe),oe.copy(ne))},reset:function(){D=!1,K=null,oe.set(-1,0,0,0)}}}function n(){let D=!1,ne=!1,K=null,oe=null,pe=null;return{setReversed:function(Q){if(ne!==Q){const Me=e.get("EXT_clip_control");Q?Me.clipControlEXT(Me.LOWER_LEFT_EXT,Me.ZERO_TO_ONE_EXT):Me.clipControlEXT(Me.LOWER_LEFT_EXT,Me.NEGATIVE_ONE_TO_ONE_EXT),ne=Q;const xe=pe;pe=null,this.setClear(xe)}},getReversed:function(){return ne},setTest:function(Q){Q?ee(i.DEPTH_TEST):Re(i.DEPTH_TEST)},setMask:function(Q){K!==Q&&!D&&(i.depthMask(Q),K=Q)},setFunc:function(Q){if(ne&&(Q=Fc[Q]),oe!==Q){switch(Q){case Ts:i.depthFunc(i.NEVER);break;case bs:i.depthFunc(i.ALWAYS);break;case As:i.depthFunc(i.LESS);break;case xi:i.depthFunc(i.LEQUAL);break;case ws:i.depthFunc(i.EQUAL);break;case Rs:i.depthFunc(i.GEQUAL);break;case Cs:i.depthFunc(i.GREATER);break;case Ps:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}oe=Q}},setLocked:function(Q){D=Q},setClear:function(Q){pe!==Q&&(pe=Q,ne&&(Q=1-Q),i.clearDepth(Q))},reset:function(){D=!1,K=null,oe=null,pe=null,ne=!1}}}function r(){let D=!1,ne=null,K=null,oe=null,pe=null,Q=null,Me=null,xe=null,at=null;return{setTest:function(je){D||(je?ee(i.STENCIL_TEST):Re(i.STENCIL_TEST))},setMask:function(je){ne!==je&&!D&&(i.stencilMask(je),ne=je)},setFunc:function(je,$t,Jt){(K!==je||oe!==$t||pe!==Jt)&&(i.stencilFunc(je,$t,Jt),K=je,oe=$t,pe=Jt)},setOp:function(je,$t,Jt){(Q!==je||Me!==$t||xe!==Jt)&&(i.stencilOp(je,$t,Jt),Q=je,Me=$t,xe=Jt)},setLocked:function(je){D=je},setClear:function(je){at!==je&&(i.clearStencil(je),at=je)},reset:function(){D=!1,ne=null,K=null,oe=null,pe=null,Q=null,Me=null,xe=null,at=null}}}const s=new t,a=new n,o=new r,c=new WeakMap,l=new WeakMap;let f={},m={},u={},_=new WeakMap,v=[],y=null,g=!1,h=null,b=null,R=null,M=null,A=null,S=null,C=null,p=new Ge(0,0,0),E=0,w=!1,P=null,I=null,X=null,H=null,O=null;const W=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,J=0;const j=i.getParameter(i.VERSION);j.indexOf("WebGL")!==-1?(J=parseFloat(/^WebGL (\d)/.exec(j)[1]),k=J>=1):j.indexOf("OpenGL ES")!==-1&&(J=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),k=J>=2);let le=null,he={};const _e=i.getParameter(i.SCISSOR_BOX),Ve=i.getParameter(i.VIEWPORT),rt=new it().fromArray(_e),Xe=new it().fromArray(Ve);
vendor: 11,923 bytes, line 4092
4092function $(D,ne,K,oe){const pe=new Uint8Array(4),Q=i.createTexture();i.bindTexture(D,Q),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Me=0;Me<K;Me++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(ne,0,i.RGBA,1,1,oe,0,i.RGBA,i.UNSIGNED_BYTE,pe):i.texImage2D(ne+Me,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,pe);return Q}const ie={};ie[i.TEXTURE_2D]=$(i.TEXTURE_2D,i.TEXTURE_2D,1),ie[i.TEXTURE_CUBE_MAP]=$(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),ie[i.TEXTURE_2D_ARRAY]=$(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),ie[i.TEXTURE_3D]=$(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ee(i.DEPTH_TEST),a.setFunc(xi),ht(!1),pt(qa),ee(i.CULL_FACE),qe(mn);function ee(D){f[D]!==!0&&(i.enable(D),f[D]=!0)}function Re(D){f[D]!==!1&&(i.disable(D),f[D]=!1)}function De(D,ne){return u[D]!==ne?(i.bindFramebuffer(D,ne),u[D]=ne,D===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ne),D===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ne),!0):!1}function be(D,ne){let K=v,oe=!1;if(D){K=_.get(ne),K===void 0&&(K=[],_.set(ne,K));const pe=D.textures;if(K.length!==pe.length||K[0]!==i.COLOR_ATTACHMENT0){for(let Q=0,Me=pe.length;Q<Me;Q++)K[Q]=i.COLOR_ATTACHMENT0+Q;K.length=pe.length,oe=!0}}else K[0]!==i.BACK&&(K[0]=i.BACK,oe=!0);oe&&i.drawBuffers(K)}function lt(D){return y!==D?(i.useProgram(D),y=D,!0):!1}const Oe={[zn]:i.FUNC_ADD,[sc]:i.FUNC_SUBTRACT,[ac]:i.FUNC_REVERSE_SUBTRACT};Oe[oc]=i.MIN,Oe[lc]=i.MAX;const $e={[cc]:i.ZERO,[uc]:i.ONE,[hc]:i.SRC_COLOR,[Es]:i.SRC_ALPHA,[_c]:i.SRC_ALPHA_SATURATE,[mc]:i.DST_COLOR,[dc]:i.DST_ALPHA,[fc]:i.ONE_MINUS_SRC_COLOR,[ys]:i.ONE_MINUS_SRC_ALPHA,[gc]:i.ONE_MINUS_DST_COLOR,[pc]:i.ONE_MINUS_DST_ALPHA,[xc]:i.CONSTANT_COLOR,[vc]:i.ONE_MINUS_CONSTANT_COLOR,[Mc]:i.CONSTANT_ALPHA,[Sc]:i.ONE_MINUS_CONSTANT_ALPHA};function qe(D,ne,K,oe,pe,Q,Me,xe,at,je){if(D===mn){g===!0&&(Re(i.BLEND),g=!1);return}if(g===!1&&(ee(i.BLEND),g=!0),D!==rc){if(D!==h||je!==w){if((b!==zn||A!==zn)&&(i.blendEquation(i.FUNC_ADD),b=zn,A=zn),je)switch(D){case mi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ya:i.blendFunc(i.ONE,i.ONE);break;case Ka:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Za:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:We("WebGLState: Invalid blending: ",D);break}else switch(D){case mi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ya:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Ka:We("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Za:We("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:We("WebGLState: Invalid blending: ",D);break}R=null,M=null,S=null,C=null,p.set(0,0,0),E=0,h=D,w=je}return}pe=pe||ne,Q=Q||K,Me=Me||oe,(ne!==b||pe!==A)&&(i.blendEquationSeparate(Oe[ne],Oe[pe]),b=ne,A=pe),(K!==R||oe!==M||Q!==S||Me!==C)&&(i.blendFuncSeparate($e[K],$e[oe],$e[Q],$e[Me]),R=K,M=oe,S=Q,C=Me),(xe.equals(p)===!1||at!==E)&&(i.blendColor(xe.r,xe.g,xe.b,at),p.copy(xe),E=at),h=D,w=!1}function He(D,ne){D.side===nn?Re(i.CULL_FACE):ee(i.CULL_FACE);let K=D.side===Pt;ne&&(K=!K),ht(K),D.blending===mi&&D.transparent===!1?qe(mn):qe(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),s.setMask(D.colorWrite);const oe=D.stencilWrite;o.setTest(oe),oe&&(o.setMask(D.stencilWriteMask),o.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),o.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),St(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?ee(i.SAMPLE_ALPHA_TO_COVERAGE):Re(i.SAMPLE_ALPHA_TO_COVERAGE)}function ht(D){P!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),P=D)}function pt(D){D!==tc?(ee(i.CULL_FACE),D!==I&&(D===qa?i.cullFace(i.BACK):D===nc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Re(i.CULL_FACE),I=D}function _t(D){D!==X&&(k&&i.lineWidth(D),X=D)}function St(D,ne,K){D?(ee(i.POLYGON_OFFSET_FILL),(H!==ne||O!==K)&&(H=ne,O=K,a.getReversed()&&(ne=-ne),i.polygonOffset(ne,K))):Re(i.POLYGON_OFFSET_FILL)}function st(D){D?ee(i.SCISSOR_TEST):Re(i.SCISSOR_TEST)}function ft(D){D===void 0&&(D=i.TEXTURE0+W-1),le!==D&&(i.activeTexture(D),le=D)}function L(D,ne,K){K===void 0&&(le===null?K=i.TEXTURE0+W-1:K=le);let oe=he[K];oe===void 0&&(oe={type:void 0,texture:void 0},he[K]=oe),(oe.type!==D||oe.texture!==ne)&&(le!==K&&(i.activeTexture(K),le=K),i.bindTexture(D,ne||ie[D]),oe.type=D,oe.texture=ne)}function Lt(){const D=he[le];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function Ye(){try{i.compressedTexImage2D(...arguments)}catch(D){We("WebGLState:",D)}}function T(){try{i.compressedTexImage3D(...arguments)}catch(D){We("WebGLState:",D)}}function d(){try{i.texSubImage2D(...arguments)}catch(D){We("WebGLState:",D)}}function F(){try{i.texSubImage3D(...arguments)}catch(D){We("WebGLState:",D)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(D){We("WebGLState:",D)}}function q(){try{i.compressedTexSubImage3D(...arguments)}catch(D){We("WebGLState:",D)}}function te(){try{i.texStorage2D(...arguments)}catch(D){We("WebGLState:",D)}}function re(){try{i.texStorage3D(...arguments)}catch(D){We("WebGLState:",D)}}function Y(){try{i.texImage2D(...arguments)}catch(D){We("WebGLState:",D)}}function Z(){try{i.texImage3D(...arguments)}catch(D){We("WebGLState:",D)}}function se(D){return m[D]!==void 0?m[D]:i.getParameter(D)}function Se(D,ne){m[D]!==ne&&(i.pixelStorei(D,ne),m[D]=ne)}function ce(D){rt.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),rt.copy(D))}function ae(D){Xe.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),Xe.copy(D))}function Te(D,ne){let K=l.get(ne);K===void 0&&(K=new WeakMap,l.set(ne,K));let oe=K.get(D);oe===void 0&&(oe=i.getUniformBlockIndex(ne,D.name),K.set(D,oe))}function Ae(D,ne){const oe=l.get(ne).get(D);c.get(ne)!==oe&&(i.uniformBlockBinding(ne,oe,D.__bindingPointIndex),c.set(ne,oe))}function Le(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),f={},m={},le=null,he={},u={},_=new WeakMap,v=[],y=null,g=!1,h=null,b=null,R=null,M=null,A=null,S=null,C=null,p=new Ge(0,0,0),E=0,w=!1,P=null,I=null,X=null,H=null,O=null,rt.set(0,0,i.canvas.width,i.canvas.height),Xe.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:ee,disable:Re,bindFramebuffer:De,drawBuffers:be,useProgram:lt,setBlending:qe,setMaterial:He,setFlipSided:ht,setCullFace:pt,setLineWidth:_t,setPolygonOffset:St,setScissorTest:st,activeTexture:ft,bindTexture:L,unbindTexture:Lt,compressedTexImage2D:Ye,compressedTexImage3D:T,texImage2D:Y,texImage3D:Z,pixelStorei:Se,getParameter:se,updateUBOMapping:Te,uniformBlockBinding:Ae,texStorage2D:te,texStorage3D:re,texSubImage2D:d,texSubImage3D:F,compressedTexSubImage2D:G,compressedTexSubImage3D:q,scissor:ce,viewport:ae,reset:Le}}function Sm(i,e,t,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Fe,f=new WeakMap,m=new Set;let u;const _=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(T,d){return v?new OffscreenCanvas(T,d):Cr("canvas")}function g(T,d,F){let G=1;const q=Ye(T);if((q.width>F||q.height>F)&&(G=F/Math.max(q.width,q.height)),G<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const te=Math.floor(G*q.width),re=Math.floor(G*q.height);u===void 0&&(u=y(te,re));const Y=d?y(te,re):u;return Y.width=te,Y.height=re,Y.getContext("2d").drawImage(T,0,0,te,re),we("WebGLRenderer: Texture has been resized from ("+q.width+"x"+q.height+") to ("+te+"x"+re+")."),Y}else return"data"in T&&we("WebGLRenderer: Image in DataTexture is too big ("+q.width+"x"+q.height+")."),T;return T}function h(T){return T.generateMipmaps}function b(T){i.generateMipmap(T)}function R(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(T,d,F,G,q,te=!1){if(T!==null){if(i[T]!==void 0)return i[T];we("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let re;G&&(re=e.get("EXT_texture_norm16"),re||we("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Y=d;if(d===i.RED&&(F===i.FLOAT&&(Y=i.R32F),F===i.HALF_FLOAT&&(Y=i.R16F),F===i.UNSIGNED_BYTE&&(Y=i.R8),F===i.UNSIGNED_SHORT&&re&&(Y=re.R16_EXT),F===i.SHORT&&re&&(Y=re.R16_SNORM_EXT)),d===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(Y=i.R8UI),F===i.UNSIGNED_SHORT&&(Y=i.R16UI),F===i.UNSIGNED_INT&&(Y=i.R32UI),F===i.BYTE&&(Y=i.R8I),F===i.SHORT&&(Y=i.R16I),F===i.INT&&(Y=i.R32I)),d===i.RG&&(F===i.FLOAT&&(Y=i.RG32F),F===i.HALF_FLOAT&&(Y=i.RG16F),F===i.UNSIGNED_BYTE&&(Y=i.RG8),F===i.UNSIGNED_SHORT&&re&&(Y=re.RG16_EXT),F===i.SHORT&&re&&(Y=re.RG16_SNORM_EXT)),d===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(Y=i.RG8UI),F===i.UNSIGNED_SHORT&&(Y=i.RG16UI),F===i.UNSIGNED_INT&&(Y=i.RG32UI),F===i.BYTE&&(Y=i.RG8I),F===i.SHORT&&(Y=i.RG16I),F===i.INT&&(Y=i.RG32I)),d===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(Y=i.RGB8UI),F===i.UNSIGNED_SHORT&&(Y=i.RGB16UI),F===i.UNSIGNED_INT&&(Y=i.RGB32UI),F===i.BYTE&&(Y=i.RGB8I),F===i.SHORT&&(Y=i.RGB16I),F===i.INT&&(Y=i.RGB32I)),d===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(Y=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(Y=i.RGBA16UI),F===i.UNSIGNED_INT&&(Y=i.RGBA32UI),F===i.BYTE&&(Y=i.RGBA8I),F===i.SHORT&&(Y=i.RGBA16I),F===i.INT&&(Y=i.RGBA32I)),d===i.RGB&&(F===i.UNSIGNED_SHORT&&re&&(Y=re.RGB16_EXT),F===i.SHORT&&re&&(Y=re.RGB16_SNORM_EXT),F===i.UNSIGNED_INT_5_9_9_9_REV&&(Y=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&(Y=i.R11F_G11F_B10F)),d===i.RGBA){const Z=te?Rr:ze.getTransfer(q);F===i.FLOAT&&(Y=i.RGBA32F),F===i.HALF_FLOAT&&(Y=i.RGBA16F),F===i.UNSIGNED_BYTE&&(Y=Z===Ke?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT&&re&&(Y=re.RGBA16_EXT),F===i.SHORT&&re&&(Y=re.RGBA16_SNORM_EXT),F===i.UNSIGNED_SHORT_4_4_4_4&&(Y=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(Y=i.RGB5_A1)}return(Y===i.R16F||Y===i.R32F||Y===i.RG16F||Y===i.RG32F||Y===i.RGBA16F||Y===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Y}function A(T,d){let F;
vendor: 7,480 bytes, line 4092
4092return T?d===null||d===ln||d===Gi?F=i.DEPTH24_STENCIL8:d===qt?F=i.DEPTH32F_STENCIL8:d===zi&&(F=i.DEPTH24_STENCIL8,we("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):d===null||d===ln||d===Gi?F=i.DEPTH_COMPONENT24:d===qt?F=i.DEPTH_COMPONENT32F:d===zi&&(F=i.DEPTH_COMPONENT16),F}function S(T,d){return h(T)===!0||T.isFramebufferTexture&&T.minFilter!==Et&&T.minFilter!==wt?Math.log2(Math.max(d.width,d.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?d.mipmaps.length:1}function C(T){const d=T.target;d.removeEventListener("dispose",C),E(d),d.isVideoTexture&&f.delete(d),d.isHTMLTexture&&m.delete(d)}function p(T){const d=T.target;d.removeEventListener("dispose",p),P(d)}function E(T){const d=n.get(T);if(d.__webglInit===void 0)return;const F=T.source,G=_.get(F);if(G){const q=G[d.__cacheKey];q.usedTimes--,q.usedTimes===0&&w(T),Object.keys(G).length===0&&_.delete(F)}n.remove(T)}function w(T){const d=n.get(T);i.deleteTexture(d.__webglTexture);const F=T.source,G=_.get(F);delete G[d.__cacheKey],a.memory.textures--}function P(T){const d=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(d.__webglFramebuffer[G]))for(let q=0;q<d.__webglFramebuffer[G].length;q++)i.deleteFramebuffer(d.__webglFramebuffer[G][q]);else i.deleteFramebuffer(d.__webglFramebuffer[G]);d.__webglDepthbuffer&&i.deleteRenderbuffer(d.__webglDepthbuffer[G])}else{if(Array.isArray(d.__webglFramebuffer))for(let G=0;G<d.__webglFramebuffer.length;G++)i.deleteFramebuffer(d.__webglFramebuffer[G]);else i.deleteFramebuffer(d.__webglFramebuffer);if(d.__webglDepthbuffer&&i.deleteRenderbuffer(d.__webglDepthbuffer),d.__webglMultisampledFramebuffer&&i.deleteFramebuffer(d.__webglMultisampledFramebuffer),d.__webglColorRenderbuffer)for(let G=0;G<d.__webglColorRenderbuffer.length;G++)d.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(d.__webglColorRenderbuffer[G]);d.__webglDepthRenderbuffer&&i.deleteRenderbuffer(d.__webglDepthRenderbuffer)}const F=T.textures;for(let G=0,q=F.length;G<q;G++){const te=n.get(F[G]);te.__webglTexture&&(i.deleteTexture(te.__webglTexture),a.memory.textures--),n.remove(F[G])}n.remove(T)}let I=0;function X(){I=0}function H(){return I}function O(T){I=T}function W(){const T=I;return T>=r.maxTextures&&we("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+r.maxTextures),I+=1,T}function k(T){const d=[];return d.push(T.wrapS),d.push(T.wrapT),d.push(T.wrapR||0),d.push(T.magFilter),d.push(T.minFilter),d.push(T.anisotropy),d.push(T.internalFormat),d.push(T.format),d.push(T.type),d.push(T.generateMipmaps),d.push(T.premultiplyAlpha),d.push(T.flipY),d.push(T.unpackAlignment),d.push(T.colorSpace),d.join()}function J(T,d){const F=n.get(T);if(T.isVideoTexture&&L(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&F.__version!==T.version){const G=T.image;if(G===null)we("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)we("WebGLRenderer: Texture marked for update but image is incomplete");else{Re(F,T,d);return}}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+d)}function j(T,d){const F=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){Re(F,T,d);return}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+d)}function le(T,d){const F=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){Re(F,T,d);return}t.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+d)}function he(T,d){const F=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&F.__version!==T.version){De(F,T,d);return}t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+d)}const _e={[Ds]:i.REPEAT,[pn]:i.CLAMP_TO_EDGE,[Ls]:i.MIRRORED_REPEAT},Ve={[Et]:i.NEAREST,[Tc]:i.NEAREST_MIPMAP_NEAREST,[Zi]:i.NEAREST_MIPMAP_LINEAR,[wt]:i.LINEAR,[Hr]:i.LINEAR_MIPMAP_NEAREST,[Hn]:i.LINEAR_MIPMAP_LINEAR},rt={[wc]:i.NEVER,[Lc]:i.ALWAYS,[Rc]:i.LESS,[Sa]:i.LEQUAL,[Cc]:i.EQUAL,[Ea]:i.GEQUAL,[Pc]:i.GREATER,[Dc]:i.NOTEQUAL};function Xe(T,d){if(d.type===qt&&e.has("OES_texture_float_linear")===!1&&(d.magFilter===wt||d.magFilter===Hr||d.magFilter===Zi||d.magFilter===Hn||d.minFilter===wt||d.minFilter===Hr||d.minFilter===Zi||d.minFilter===Hn)&&we("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,_e[d.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,_e[d.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,_e[d.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,Ve[d.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,Ve[d.minFilter]),d.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,rt[d.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(d.magFilter===Et||d.minFilter!==Zi&&d.minFilter!==Hn||d.type===qt&&e.has("OES_texture_float_linear")===!1)return;if(d.anisotropy>1||n.get(d).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(d.anisotropy,r.getMaxAnisotropy())),n.get(d).__currentAnisotropy=d.anisotropy}}}function $(T,d){let F=!1;T.__webglInit===void 0&&(T.__webglInit=!0,d.addEventListener("dispose",C));const G=d.source;let q=_.get(G);q===void 0&&(q={},_.set(G,q));const te=k(d);if(te!==T.__cacheKey){q[te]===void 0&&(q[te]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),q[te].usedTimes++;const re=q[T.__cacheKey];re!==void 0&&(q[T.__cacheKey].usedTimes--,re.usedTimes===0&&w(d)),T.__cacheKey=te,T.__webglTexture=q[te].texture}return F}function ie(T,d,F){return Math.floor(Math.floor(T/F)/d)}function ee(T,d,F,G){const te=T.updateRanges;if(te.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,d.width,d.height,F,G,d.data);else{te.sort((Se,ce)=>Se.start-ce.start);let re=0;for(let Se=1;Se<te.length;Se++){const ce=te[re],ae=te[Se],Te=ce.start+ce.count,Ae=ie(ae.start,d.width,4),Le=ie(ce.start,d.width,4);ae.start<=Te+1&&Ae===Le&&ie(ae.start+ae.count-1,d.width,4)===Ae?ce.count=Math.max(ce.count,ae.start+ae.count-ce.start):(++re,te[re]=ae)}te.length=re+1;const Y=t.getParameter(i.UNPACK_ROW_LENGTH),Z=t.getParameter(i.UNPACK_SKIP_PIXELS),se=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,d.width);for(let Se=0,ce=te.length;Se<ce;Se++){const ae=te[Se],Te=Math.floor(ae.start/4),Ae=Math.ceil(ae.count/4),Le=Te%d.width,D=Math.floor(Te/d.width),ne=Ae,K=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Le),t.pixelStorei(i.UNPACK_SKIP_ROWS,D),t.texSubImage2D(i.TEXTURE_2D,0,Le,D,ne,K,F,G,d.data)}T.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,Y),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Z),t.pixelStorei(i.UNPACK_SKIP_ROWS,se)}}function Re(T,d,F){let G=i.TEXTURE_2D;(d.isDataArrayTexture||d.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),d.isData3DTexture&&(G=i.TEXTURE_3D);const q=$(T,d),te=d.source;t.bindTexture(G,T.__webglTexture,i.TEXTURE0+F);const re=n.get(te);if(te.version!==re.__version||q===!0){if(t.activeTexture(i.TEXTURE0+F),(typeof ImageBitmap<"u"&&d.image instanceof ImageBitmap)===!1){const K=ze.getPrimaries(ze.workingColorSpace),oe=
vendor: 5,016 bytes, line 4092
4092d.colorSpace===Cn?null:ze.getPrimaries(d.colorSpace),pe=d.colorSpace===Cn||K===oe?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,d.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,d.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,pe)}t.pixelStorei(i.UNPACK_ALIGNMENT,d.unpackAlignment);let Z=g(d.image,!1,r.maxTextureSize);Z=Lt(d,Z);const se=s.convert(d.format,d.colorSpace),Se=s.convert(d.type);let ce=M(d.internalFormat,se,Se,d.normalized,d.colorSpace,d.isVideoTexture);Xe(G,d);let ae;const Te=d.mipmaps,Ae=d.isVideoTexture!==!0,Le=re.__version===void 0||q===!0,D=te.dataReady,ne=S(d,Z);if(d.isDepthTexture)ce=A(d.format===kn,d.type),Le&&(Ae?t.texStorage2D(i.TEXTURE_2D,1,ce,Z.width,Z.height):t.texImage2D(i.TEXTURE_2D,0,ce,Z.width,Z.height,0,se,Se,null));else if(d.isDataTexture)if(Te.length>0){Ae&&Le&&t.texStorage2D(i.TEXTURE_2D,ne,ce,Te[0].width,Te[0].height);for(let K=0,oe=Te.length;K<oe;K++)ae=Te[K],Ae?D&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,ae.width,ae.height,se,Se,ae.data):t.texImage2D(i.TEXTURE_2D,K,ce,ae.width,ae.height,0,se,Se,ae.data);d.generateMipmaps=!1}else Ae?(Le&&t.texStorage2D(i.TEXTURE_2D,ne,ce,Z.width,Z.height),D&&ee(d,Z,se,Se)):t.texImage2D(i.TEXTURE_2D,0,ce,Z.width,Z.height,0,se,Se,Z.data);else if(d.isCompressedTexture)if(d.isCompressedArrayTexture){Ae&&Le&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ne,ce,Te[0].width,Te[0].height,Z.depth);for(let K=0,oe=Te.length;K<oe;K++)if(ae=Te[K],d.format!==Yt)if(se!==null)if(Ae){if(D)if(d.layerUpdates.size>0){const pe=Ro(ae.width,ae.height,d.format,d.type);for(const Q of d.layerUpdates){const Me=ae.data.subarray(Q*pe/ae.data.BYTES_PER_ELEMENT,(Q+1)*pe/ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,Q,ae.width,ae.height,1,se,Me)}d.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,ae.width,ae.height,Z.depth,se,ae.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,K,ce,ae.width,ae.height,Z.depth,0,ae.data,0,0);else we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ae?D&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,ae.width,ae.height,Z.depth,se,Se,ae.data):t.texImage3D(i.TEXTURE_2D_ARRAY,K,ce,ae.width,ae.height,Z.depth,0,se,Se,ae.data)}else{Ae&&Le&&t.texStorage2D(i.TEXTURE_2D,ne,ce,Te[0].width,Te[0].height);for(let K=0,oe=Te.length;K<oe;K++)ae=Te[K],d.format!==Yt?se!==null?Ae?D&&t.compressedTexSubImage2D(i.TEXTURE_2D,K,0,0,ae.width,ae.height,se,ae.data):t.compressedTexImage2D(i.TEXTURE_2D,K,ce,ae.width,ae.height,0,ae.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ae?D&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,ae.width,ae.height,se,Se,ae.data):t.texImage2D(i.TEXTURE_2D,K,ce,ae.width,ae.height,0,se,Se,ae.data)}else if(d.isDataArrayTexture)if(Ae){if(Le&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ne,ce,Z.width,Z.height,Z.depth),D)if(d.layerUpdates.size>0){const K=Ro(Z.width,Z.height,d.format,d.type);for(const oe of d.layerUpdates){const pe=Z.data.subarray(oe*K/Z.data.BYTES_PER_ELEMENT,(oe+1)*K/Z.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,oe,Z.width,Z.height,1,se,Se,pe)}d.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Z.width,Z.height,Z.depth,se,Se,Z.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ce,Z.width,Z.height,Z.depth,0,se,Se,Z.data);else if(d.isData3DTexture)Ae?(Le&&t.texStorage3D(i.TEXTURE_3D,ne,ce,Z.width,Z.height,Z.depth),D&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Z.width,Z.height,Z.depth,se,Se,Z.data)):t.texImage3D(i.TEXTURE_3D,0,ce,Z.width,Z.height,Z.depth,0,se,Se,Z.data);else if(d.isFramebufferTexture){if(Le)if(Ae)t.texStorage2D(i.TEXTURE_2D,ne,ce,Z.width,Z.height);else{let K=Z.width,oe=Z.height;for(let pe=0;pe<ne;pe++)t.texImage2D(i.TEXTURE_2D,pe,ce,K,oe,0,se,Se,null),K>>=1,oe>>=1}}else if(d.isHTMLTexture){if("texElementImage2D"in i){const K=i.canvas;if(K.hasAttribute("layoutsubtree")||K.setAttribute("layoutsubtree","true"),Z.parentNode!==K){K.appendChild(Z),m.add(d),K.onpaint=oe=>{const pe=oe.changedElements;for(const Q of m)pe.includes(Q.image)&&(Q.needsUpdate=!0)},K.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Z);else{const pe=i.RGBA,Q=i.RGBA,Me=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,pe,Q,Me,Z)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Te.length>0){if(Ae&&Le){const K=Ye(Te[0]);t.texStorage2D(i.TEXTURE_2D,ne,ce,K.width,K.height)}for(let K=0,oe=Te.length;K<oe;K++)ae=Te[K],Ae?D&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,se,Se,ae):t.texImage2D(i.TEXTURE_2D,K,ce,se,Se,ae);d.generateMipmaps=!1}else if(Ae){if(Le){const K=Ye(Z);t.texStorage2D(i.TEXTURE_2D,ne,ce,K.width,K.height)}D&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,se,Se,Z)}else t.texImage2D(i.TEXTURE_2D,0,ce,se,Se,Z);h(d)&&b(G),re.__version=te.version,d.onUpdate&&d.onUpdate(d)}T.__version=d.version}
vendor: 35,859 bytes, lines 4092-4116
4092function De(T,d,F){if(d.image.length!==6)return;const G=$(T,d),q=d.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+F);const te=n.get(q);if(q.version!==te.__version||G===!0){t.activeTexture(i.TEXTURE0+F);const re=ze.getPrimaries(ze.workingColorSpace),Y=d.colorSpace===Cn?null:ze.getPrimaries(d.colorSpace),Z=d.colorSpace===Cn||re===Y?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,d.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,d.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,d.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Z);const se=d.isCompressedTexture||d.image[0].isCompressedTexture,Se=d.image[0]&&d.image[0].isDataTexture,ce=[];for(let Q=0;Q<6;Q++)!se&&!Se?ce[Q]=g(d.image[Q],!0,r.maxCubemapSize):ce[Q]=Se?d.image[Q].image:d.image[Q],ce[Q]=Lt(d,ce[Q]);const ae=ce[0],Te=s.convert(d.format,d.colorSpace),Ae=s.convert(d.type),Le=M(d.internalFormat,Te,Ae,d.normalized,d.colorSpace),D=d.isVideoTexture!==!0,ne=te.__version===void 0||G===!0,K=q.dataReady;let oe=S(d,ae);Xe(i.TEXTURE_CUBE_MAP,d);let pe;if(se){D&&ne&&t.texStorage2D(i.TEXTURE_CUBE_MAP,oe,Le,ae.width,ae.height);for(let Q=0;Q<6;Q++){pe=ce[Q].mipmaps;for(let Me=0;Me<pe.length;Me++){const xe=pe[Me];d.format!==Yt?Te!==null?D?K&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Me,0,0,xe.width,xe.height,Te,xe.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Me,Le,xe.width,xe.height,0,xe.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Me,0,0,xe.width,xe.height,Te,Ae,xe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Me,Le,xe.width,xe.height,0,Te,Ae,xe.data)}}}else{if(pe=d.mipmaps,D&&ne){pe.length>0&&oe++;const Q=Ye(ce[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,oe,Le,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(Se){D?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,ce[Q].width,ce[Q].height,Te,Ae,ce[Q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,Le,ce[Q].width,ce[Q].height,0,Te,Ae,ce[Q].data);for(let Me=0;Me<pe.length;Me++){const at=pe[Me].image[Q].image;D?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Me+1,0,0,at.width,at.height,Te,Ae,at.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Me+1,Le,at.width,at.height,0,Te,Ae,at.data)}}else{D?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,Te,Ae,ce[Q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,Le,Te,Ae,ce[Q]);for(let Me=0;Me<pe.length;Me++){const xe=pe[Me];D?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Me+1,0,0,Te,Ae,xe.image[Q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Me+1,Le,Te,Ae,xe.image[Q])}}}h(d)&&b(i.TEXTURE_CUBE_MAP),te.__version=q.version,d.onUpdate&&d.onUpdate(d)}T.__version=d.version}function be(T,d,F,G,q,te){const re=s.convert(F.format,F.colorSpace),Y=s.convert(F.type),Z=M(F.internalFormat,re,Y,F.normalized,F.colorSpace),se=n.get(d),Se=n.get(F);if(Se.__renderTarget=d,!se.__hasExternalTextures){const ce=Math.max(1,d.width>>te),ae=Math.max(1,d.height>>te);q===i.TEXTURE_3D||q===i.TEXTURE_2D_ARRAY?t.texImage3D(q,te,Z,ce,ae,d.depth,0,re,Y,null):t.texImage2D(q,te,Z,ce,ae,0,re,Y,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),ft(d)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,q,Se.__webglTexture,0,st(d)):(q===i.TEXTURE_2D||q>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&q<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,q,Se.__webglTexture,te),t.bindFramebuffer(i.FRAMEBUFFER,null)}function lt(T,d,F){if(i.bindRenderbuffer(i.RENDERBUFFER,T),d.depthBuffer){const G=d.depthTexture,q=G&&G.isDepthTexture?G.type:null,te=A(d.stencilBuffer,q),re=d.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ft(d)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(d),te,d.width,d.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(d),te,d.width,d.height):i.renderbufferStorage(i.RENDERBUFFER,te,d.width,d.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,re,i.RENDERBUFFER,T)}else{const G=d.textures;for(let q=0;q<G.length;q++){const te=G[q],re=s.convert(te.format,te.colorSpace),Y=s.convert(te.type),Z=M(te.internalFormat,re,Y,te.normalized,te.colorSpace);ft(d)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(d),Z,d.width,d.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(d),Z,d.width,d.height):i.renderbufferStorage(i.RENDERBUFFER,Z,d.width,d.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Oe(T,d,F){const G=d.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,T),!(d.depthTexture&&d.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const q=n.get(d.depthTexture);if(q.__renderTarget=d,(!q.__webglTexture||d.depthTexture.image.width!==d.width||d.depthTexture.image.height!==d.height)&&(d.depthTexture.image.width=d.width,d.depthTexture.image.height=d.height,d.depthTexture.needsUpdate=!0),G){if(q.__webglInit===void 0&&(q.__webglInit=!0,d.depthTexture.addEventListener("dispose",C)),q.__webglTexture===void 0){q.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,q.__webglTexture),Xe(i.TEXTURE_CUBE_MAP,d.depthTexture);const se=s.convert(d.depthTexture.format),Se=s.convert(d.depthTexture.type);let ce;d.depthTexture.format===vn?ce=i.DEPTH_COMPONENT24:d.depthTexture.format===kn&&(ce=i.DEPTH24_STENCIL8);for(let ae=0;ae<6;ae++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ae,0,ce,d.width,d.height,0,se,Se,null)}}else J(d.depthTexture,0);const te=q.__webglTexture,re=st(d),Y=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+F:i.TEXTURE_2D,Z=d.depthTexture.format===kn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(d.depthTexture.format===vn)ft(d)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Z,Y,te,0,re):i.framebufferTexture2D(i.FRAMEBUFFER,Z,Y,te,0);else if(d.depthTexture.format===kn)ft(d)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Z,Y,te,0,re):i.framebufferTexture2D(i.FRAMEBUFFER,Z,Y,te,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function $e(T){const d=n.get(T),F=T.isWebGLCubeRenderTarget===!0;if(d.__boundDepthTexture!==T.depthTexture){const G=T.depthTexture;if(d.__depthDisposeCallback&&d.__depthDisposeCallback(),G){const q=()=>{delete d.__boundDepthTexture,delete d.__depthDisposeCallback,G.removeEventListener("dispose",q)};G.addEventListener("dispose",q),d.__depthDisposeCallback=q}d.__boundDepthTexture=G}if(T.depthTexture&&!d.__autoAllocateDepthBuffer)if(F)for(let G=0;G<6;G++)Oe(d.__webglFramebuffer[G],T,G);else{const G=T.texture.mipmaps;G&&G.length>0?Oe(d.__webglFramebuffer[0],T,0):Oe(d.__webglFramebuffer,T,0)}else if(F){d.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer[G]),d.__webglDepthbuffer[G]===void 0)d.__webglDepthbuffer[G]=i.createRenderbuffer(),lt(d.__webglDepthbuffer[G],T,!1);else{const q=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=d.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,q,i.RENDERBUFFER,te)}}else{const G=T.texture.mipmaps;if(G&&G.length>0?t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer),d.__webglDepthbuffer===void 0)d.__webglDepthbuffer=i.createRenderbuffer(),lt(d.__webglDepthbuffer,T,!1);else{const q=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=d.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,q,i.RENDERBUFFER,te)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function qe(T,d,F){const G=n.get(T);d!==void 0&&be(G.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&$e(T)}function He(T){const d=T.texture,F=n.get(T),G=n.get(d);T.addEventListener("dispose",p);const q=T.textures,te=T.isWebGLCubeRenderTarget===!0,re=q.length>1;if(re||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=d.version,a.memory.textures++),te){F.__webglFramebuffer=[];for(let Y=0;Y<6;Y++)if(d.mipmaps&&d.mipmaps.length>0){F.__webglFramebuffer[Y]=[];for(let Z=0;Z<d.mipmaps.length;Z++)F.__webglFramebuffer[Y][Z]=i.createFramebuffer()}else F.__webglFramebuffer[Y]=i.createFramebuffer()}else{if(d.mipmaps&&d.mipmaps.length>0){F.__webglFramebuffer=[];for(let Y=0;Y<d.mipmaps.length;Y++)F.__webglFramebuffer[Y]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(re)for(let Y=0,Z=q.length;Y<Z;Y++){const se=n.get(q[Y]);se.__webglTexture===void 0&&(se.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&ft(T)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Y=0;Y<q.length;Y++){const Z=q[Y];F.__webglColorRenderbuffer[Y]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[Y]);const se=s.convert(Z.format,Z.colorSpace),Se=s.convert(Z.type),ce=M(Z.internalFormat,se,Se,Z.normalized,Z.colorSpace,T.isXRRenderTarget===!0),ae=st(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,ae,ce,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Y,i.RENDERBUFFER,F.__webglColorRenderbuffer[Y])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),lt(F.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(te){t.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),Xe(i.TEXTURE_CUBE_MAP,d);for(let Y=0;Y<6;Y++)if(d.mipmaps&&d.mipmaps.length>0)for(let Z=0;Z<d.mipmaps.length;Z++)be(F.__webglFramebuffer[Y][Z],T,d,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,Z);else be(F.__webglFramebuffer[Y],T,d,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0);h(d)&&b(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(re){for(let Y=0,Z=q.length;Y<Z;Y++){const se=q[Y],Se=n.get(se);let ce=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ce=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ce,Se.__webglTexture),Xe(ce,se),be(F.__webglFramebuffer,T,se,i.COLOR_ATTACHMENT0+Y,ce,0),h(se)&&b(ce)}t.unbindTexture()}else{let Y=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(Y=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Y,G.__webglTexture),Xe(Y,d),d.mipmaps&&d.mipmaps.length>0)for(let Z=0;Z<d.mipmaps.length;Z++)be(F.__webglFramebuffer[Z],T,d,i.COLOR_ATTACHMENT0,Y,Z);else be(F.__webglFramebuffer,T,d,i.COLOR_ATTACHMENT0,Y,0);h(d)&&b(Y),t.unbindTexture()}T.depthBuffer&&$e(T)}function ht(T){const d=T.textures;for(let F=0,G=d.length;F<G;F++){const q=d[F];if(h(q)){const te=R(T),re=n.get(q).__webglTexture;t.bindTexture(te,re),b(te),t.unbindTexture()}}}const pt=[],_t=[];function St(T){if(T.samples>0){if(ft(T)===!1){const d=T.textures,F=T.width,G=T.height;let q=i.COLOR_BUFFER_BIT;const te=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,re=n.get(T),Y=d.length>1;if(Y)for(let se=0;se<d.length;se++)t.bindFramebuffer(i.FRAMEBUFFER,re.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+se,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,re.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+se,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,re.__webglMultisampledFramebuffer);const Z=T.texture.mipmaps;Z&&Z.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,re.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,re.__webglFramebuffer);for(let se=0;se<d.length;se++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(q|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(q|=i.STENCIL_BUFFER_BIT)),Y){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,re.__webglColorRenderbuffer[se]);const Se=n.get(d[se]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Se,0)}i.blitFramebuffer(0,0,F,G,0,0,F,G,q,i.NEAREST),c===!0&&(pt.length=0,_t.length=0,pt.push(i.COLOR_ATTACHMENT0+se),T.depthBuffer&&T.resolveDepthBuffer===!1&&(pt.push(te),_t.push(te),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,_t)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,pt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Y)for(let se=0;se<d.length;se++){t.bindFramebuffer(i.FRAMEBUFFER,re.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+se,i.RENDERBUFFER,re.__webglColorRenderbuffer[se]);const Se=n.get(d[se]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,re.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+se,i.TEXTURE_2D,Se,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,re.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const d=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[d])}}}function st(T){return Math.min(r.maxSamples,T.samples)}function ft(T){const d=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&d.__useRenderToTexture!==!1}function L(T){const d=a.render.frame;f.get(T)!==d&&(f.set(T,d),T.update())}function Lt(T,d){const F=T.colorSpace,G=T.format,q=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||F!==wr&&F!==Cn&&(ze.getTransfer(F)===Ke?(G!==Yt||q!==Ft)&&we("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):We("WebGLTextures: Unsupported texture color space:",F)),d}function Ye(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=W,this.resetTextureUnits=X,this.getTextureUnits=H,this.setTextureUnits=O,this.setTexture2D=J,this.setTexture2DArray=j,this.setTexture3D=le,this.setTextureCube=he,this.rebindTextures=qe,this.setupRenderTarget=He,this.updateRenderTargetMipmap=ht,this.updateMultisampleRenderTarget=St,this.setupDepthRenderbuffer=$e,this.setupFrameBufferTexture=be,this.useMultisampledRTT=ft,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Em(i,e){function t(n,r=Cn){let s;const a=ze.getTransfer(r);if(n===Ft)return i.UNSIGNED_BYTE;if(n===ma)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ga)return i.UNSIGNED_SHORT_5_5_5_1;if(n===_l)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===xl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===ml)return i.BYTE;if(n===gl)return i.SHORT;if(n===zi)return i.UNSIGNED_SHORT;if(n===pa)return i.INT;if(n===ln)return i.UNSIGNED_INT;if(n===qt)return i.FLOAT;if(n===xn)return i.HALF_FLOAT;if(n===vl)return i.ALPHA;if(n===Ml)return i.RGB;if(n===Yt)return i.RGBA;if(n===vn)return i.DEPTH_COMPONENT;if(n===kn)return i.DEPTH_STENCIL;if(n===_a)return i.RED;if(n===xa)return i.RED_INTEGER;if(n===Kn)return i.RG;if(n===va)return i.RG_INTEGER;if(n===Ma)return i.RGBA_INTEGER;if(n===vr||n===Mr||n===Sr||n===Er)if(a===Ke)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===vr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Mr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Sr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Er)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===vr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Mr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Sr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Er)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Is||n===Us||n===Ns||n===Fs)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Is)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Us)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ns)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Fs)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Os||n===Bs||n===zs||n===Gs||n===Vs||n===br||n===Hs)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Os||n===Bs)return a===Ke?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===zs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===Gs)return s.COMPRESSED_R11_EAC;if(n===Vs)return s.COMPRESSED_SIGNED_R11_EAC;if(n===br)return s.COMPRESSED_RG11_EAC;if(n===Hs)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===ks||n===Ws||n===Xs||n===qs||n===Ys||n===Ks||n===Zs||n===$s||n===Js||n===Qs||n===js||n===ea||n===ta||n===na)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===ks)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ws)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Xs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===qs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ys)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ks)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Zs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===$s)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Js)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Qs)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===js)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ea)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ta)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===na)return a===Ke?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ia||n===ra||n===sa)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===ia)return a===Ke?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ra)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===sa)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===aa||n===oa||n===Ar||n===la)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===aa)return s.COMPRESSED_RED_RGTC1_EXT;if(n===oa)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ar)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===la)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Gi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const ym=` 4093void main() { 4094 4095 gl_Position = vec4( position, 1.0 ); 4096 4097}`,Tm=` 4098uniform sampler2DArray depthColor; 4099uniform float depthWidth; 4100uniform float depthHeight; 4101 4102void main() { 4103 4104 vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); 4105 4106 if ( coord.x >= 1.0 ) { 4107 4108 gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; 4109 4110 } else { 4111 4112 gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; 4113 4114 } 4115 4116}`;class bm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Pl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Zt({vertexShader:ym,fragmentShader:Tm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new nt(new bi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Am extends Zn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",c=1,l=null,f=null,m=null,u=null,_=null,v=null;const y=typeof XRWebGLBinding<"u",g=new bm,h={},b=t.getContextAttributes();let R=null,M=null;const A=[],S=[],C=new Fe;let p=null;const E=new Gt;E.viewport=new it;const w=new Gt;w.viewport=new it;const P=[E,w],I=new Nu;let X=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let ie=A[$];return ie===void 0&&(ie=new Kr,A[$]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function($){let ie=A[$];return ie===void 0&&(ie=new Kr,A[$]=ie),ie.getGripSpace()},this.getHand=function($){let ie=A[$];return ie===void 0&&(ie=new Kr,A[$]=ie),ie.getHandSpace()};function O($){const ie=S.indexOf($.inputSource);if(ie===-1)return;const ee=A[ie];ee!==void 0&&(ee.update($.inputSource,$.frame,l||a),ee.dispatchEvent({type:$.type,data:$.inputSource}))}function W(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",k);for(let $=0;$<A.length;$++){const ie=S[$];ie!==null&&(S[$]=null,A[$].disconnect(ie))}X=null,H=null,g.reset();for(const $ in h)delete h[$];e.setRenderTarget(R),_=null,u=null,m=null,r=null,M=null,Xe.stop(),n.isPresenting=!1,e.setPixelRatio(p),e.setSize(C.width,C.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){s=$,n.isPresenting===!0&&we("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){o=$,n.isPresenting===!0&&we("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function($){l=$},this.getBaseLayer=function(){return u!==null?u:_},this.getBinding=function(){return m===null&&y&&(m=new XRWebGLBinding(r,t)),m},this.getFrame=function(){return v},this.getSession=function(){return r},this.setSession=async function($){if(r=$,r!==null){if(R=e.getRenderTarget(),r.addEventListener("select",O),r.addEventListener("selectstart",O),r.addEventListener("selectend",O),r.addEventListener("squeeze",O),r.addEventListener("squeezestart",O),r.addEventListener("squeezeend",O),r.addEventListener("end",W),r.addEventListener("inputsourceschange",k),b.xrCompatible!==!0&&await t.makeXRCompatible(),p=e.getPixelRatio(),e.getSize(C),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let ee=null,Re=null,De=null;b.depth&&(De=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ee=b.stencil?kn:vn,Re=b.stencil?Gi:ln);const be={colorFormat:t.RGBA8,depthFormat:De,scaleFactor:s};m=this.getBinding(),u=m.createProjectionLayer(be),r.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),M=new on(u.textureWidth,u.textureHeight,{format:Yt,type:Ft,depthTexture:new Mi(u.textureWidth,u.textureHeight,Re,void 0,void 0,void 0,void 0,void 0,void 0,ee),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ee={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:s};_=new XRWebGLLayer(r,t,ee),r.updateRenderState({baseLayer:_}),e.setPixelRatio(1),e.setSize(_.framebufferWidth,_.framebufferHeight,!1),M=new on(_.framebufferWidth,_.framebufferHeight,{format:Yt,type:Ft,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:_.ignoreDepthValues===!1,resolveStencilBuffer:_.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await r.requestReferenceSpace(o),Xe.setContext(r),Xe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function k($){for(let ie=0;ie<$.removed.length;ie++){const ee=$.removed[ie],Re=S.indexOf(ee);Re>=0&&(S[Re]=null,A[Re].disconnect(ee))}for(let ie=0;ie<$.added.length;ie++){const ee=$.added[ie];let Re=S.indexOf(ee);if(Re===-1){for(let be=0;be<A.length;be++)if(be>=S.length){S.push(ee),Re=be;break}else if(S[be]===null){S[be]=ee,Re=be;break}if(Re===-1)break}const De=A[Re];De&&De.connect(ee)}}const J=new N,j=new N;function le($,ie,ee){J.setFromMatrixPosition(ie.matrixWorld),j.setFromMatrixPosition(ee.matrixWorld);const Re=J.distanceTo(j),De=ie.projectionMatrix.elements,be=ee.projectionMatrix.elements,lt=De[14]/(De[10]-1),Oe=De[14]/(De[10]+1),$e=(De[9]+1)/De[5],qe=(De[9]-1)/De[5],He=(De[8]-1)/De[0],ht=(be[8]+1)/be[0],pt=lt*He,_t=lt*ht,St=Re/(-He+ht),st=St*-He;if(ie.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(st),$.translateZ(St),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),De[10]===-1)$.projectionMatrix.copy(ie.projectionMatrix),$.projectionMatrixInverse.copy(ie.projectionMatrixInverse);else{const ft=lt+St,L=Oe+St,Lt=pt-st,Ye=_t+(Re-st),T=$e*Oe/L*ft,d=qe*Oe/L*ft;$.projectionMatrix.makePerspective(Lt,Ye,T,d,ft,L),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function he($,ie){ie===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(ie.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(r===null)return;let ie=$.near,ee=$.far;g.texture!==null&&(g.depthNear>0&&(ie=g.depthNear),g.depthFar>0&&(ee=g.depthFar)),I.near=w.near=E.near=ie,I.far=w.far=E.far=ee,(X!==I.near||H!==I.far)&&(r.updateRenderState({depthNear:I.near,depthFar:I.far}),X=I.near,H=I.far),I.layers.mask=$.layers.mask|6,E.layers.mask=I.layers.mask&-5,w.layers.mask=I.layers.mask&-3;const Re=$.parent,De=I.cameras;he(I,Re);for(let be=0;be<De.length;be++)he(De[be],Re);De.length===2?le(I,E,w):I.projectionMatrix.copy(E.projectionMatrix),_e($,I,Re)};function _e($,ie,ee){ee===null?$.matrix.copy(ie.matrixWorld):($.matrix.copy(ee.matrixWorld),$.matrix.invert(),$.matrix.multiply(ie.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(ie.projectionMatrix),$.projectionMatrixInverse.copy(ie.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Hi*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(u===null&&_===null))return c},this.setFoveation=function($){c=$,u!==null&&(u.fixedFoveation=$),_!==null&&_.fixedFoveation!==void 0&&(_.fixedFoveation=$)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(I)},this.getCameraTexture=function($){return h[$]};let Ve=null;function rt($,ie){if(f=ie.getViewerPose(l||a),v=ie,f!==null){const ee=f.views;_!==null&&(e.setRenderTargetFramebuffer(M,_.framebuffer),e.setRenderTarget(M));let Re=!1;ee.length!==I.cameras.length&&(I.cameras.length=0,Re=!0);for(let Oe=0;Oe<ee.length;Oe++){const $e=ee[Oe];let qe=null;if(_!==null)qe=_.getViewport($e);else{const ht=m.getViewSubImage(u,$e);qe=ht.viewport,Oe===0&&(e.setRenderTargetTextures(M,ht.colorTexture,ht.depthStencilTexture),e.setRenderTarget(M))}let He=P[Oe];He===void 0&&(He=new Gt,He.layers.enable(Oe),He.viewport=new it,P[Oe]=He),He.matrix.fromArray($e.transform.matrix),He.matrix.decompose(He.position,He.quaternion,He.scale),He.projectionMatrix.fromArray($e.projectionMatrix),He.projectionMatrixInverse.copy(He.projectionMatrix).invert(),He.viewport.set(qe.x,qe.y,qe.width,qe.height),Oe===0&&(I.matrix.copy(He.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),Re===!0&&I.cameras.push(He)}const De=r.enabledFeatures;if(De&&De.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){m=n.getBinding();const Oe=m.getDepthInformation(ee[0]);Oe&&Oe.isValid&&Oe.texture&&g.init(Oe,r.renderState)}if(De&&De.includes("camera-access")&&y){e.state.unbindTexture(),m=n.getBinding();for(let Oe=0;Oe<ee.length;Oe++){const $e=ee[Oe].camera;if($e){let qe=h[$e];qe||(qe=new Pl,h[$e]=qe);const He=m.getCameraImage($e);qe.sourceTexture=He}}}}for(let ee=0;ee<A.length;ee++){const Re=S[ee],De=A[ee];Re!==null&&De!==void 0&&De.update(Re,ie,l||a)}Ve&&Ve($,ie),ie.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ie}),v=null}const Xe=new Nl;Xe.setAnimationLoop(rt),this.setAnimationLoop=function($){Ve=$},this.dispose=function(){}}}const wm=new tt,Hl=new Ce;Hl.set(-1,0,0,0,1,0,0,0,1);function Rm(i,e){function t(g,h){g.matrixAutoUpdate===!0&&g.updateMatrix(),h.value.copy(g.matrix)}function n(g,h){h.color.getRGB(g.fogColor.value,Dl(i)),h.isFog?(g.fogNear.value=h.near,g.fogFar.value=h.far):h.isFogExp2&&(g.fogDensity.value=h.density)}function r(g,h,b,R,M){h.isNodeMaterial?h.uniformsNeedUpdate=!1:h.isMeshBasicMaterial?s(g,h):h.isMeshLambertMaterial?(s(g,h),h.envMap&&(g.envMapIntensity.value=h.envMapIntensity)):h.isMeshToonMaterial?(s(g,h),m(g,h)):h.isMeshPhongMaterial?(s(g,h),f(g,h),h.envMap&&(g.envMapIntensity.value=h.envMapIntensity)):h.isMeshStandardMaterial?(s(g,h),u(g,h),h.isMeshPhysicalMaterial&&_(g,h,M)):h.isMeshMatcapMaterial?(s(g,h),v(g,h)):h.isMeshDepthMaterial?s(g,h):h.isMeshDistanceMaterial?(s(g,h),y(g,h)):h.isMeshNormalMaterial?s(g,h):h.isLineBasicMaterial?(a(g,h),h.isLineDashedMaterial&&o(g,h)):h.isPointsMaterial?c(g,h,b,R):h.isSpriteMaterial?l(g,h):h.isShadowMaterial?(g.color.value.copy(h.color),g.opacity.value=h.opacity):h.isShaderMaterial&&(h.uniformsNeedUpdate=!1)}function s(g,h){g.opacity.value=h.opacity,h.color&&g.diffuse.value.copy(h.color),h.emissive&&g.emissive.value.copy(h.emissive).multiplyScalar(h.emissiveIntensity),h.map&&(g.map.value=h.map,t(h.map,g.mapTransform)),h.alphaMap&&(g.alphaMap.value=h.alphaMap,t(h.alphaMap,g.alphaMapTransform)),h.bumpMap&&(g.bumpMap.value=h.bumpMap,t(h.bumpMap,g.bumpMapTransform),g.bumpScale.value=h.bumpScale,h.side===Pt&&(g.bumpScale.value*=-1)),h.normalMap&&(g.normalMap.value=h.normalMap,t(h.normalMap,g.normalMapTransform),g.normalScale.value.copy(h.normalScale),h.side===Pt&&g.normalScale.value.negate()),h.displacementMap&&(g.displacementMap.value=h.displacementMap,t(h.displacementMap,g.displacementMapTransform),g.displacementScale.value=h.displacementScale,g.displacementBias.value=h.displacementBias),h.emissiveMap&&(g.emissiveMap.value=h.emissiveMap,t(h.emissiveMap,g.emissiveMapTransform)),h.specularMap&&(g.specularMap.value=h.specularMap,t(h.specularMap,g.specularMapTransform)),h.alphaTest>0&&(g.alphaTest.value=h.alphaTest);const b=e.get(h),R=b.envMap,M=b.envMapRotation;R&&(g.envMap.value=R,g.envMapRotation.value.setFromMatrix4(wm.makeRotationFromEuler(M)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(Hl),g.reflectivity.value=h.reflectivity,g.ior.value=h.ior,g.refractionRatio.value=h.refractionRatio),h.lightMap&&(g.lightMap.value=h.lightMap,g.lightMapIntensity.value=h.lightMapIntensity,t(h.lightMap,g.lightMapTransform)),h.aoMap&&(g.aoMap.value=h.aoMap,g.aoMapIntensity.value=h.aoMapIntensity,t(h.aoMap,g.aoMapTransform))}function a(g,h){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,h.map&&(g.map.value=h.map,t(h.map,g.mapTransform))}function o(g,h){g.dashSize.value=h.dashSize,g.totalSize.value=h.dashSize+h.gapSize,g.scale.value=h.scale}function c(g,h,b,R){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,g.size.value=h.size*b,g.scale.value=R*.5,h.map&&(g.map.value=h.map,t(h.map,g.uvTransform)),h.alphaMap&&(g.alphaMap.value=h.alphaMap,t(h.alphaMap,g.alphaMapTransform)),h.alphaTest>0&&(g.alphaTest.value=h.alphaTest)}function l(g,h){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,g.rotation.value=h.rotation,h.map&&(g.map.value=h.map,t(h.map,g.mapTransform)),h.alphaMap&&(g.alphaMap.value=h.alphaMap,t(h.alphaMap,g.alphaMapTransform)),h.alphaTest>0&&(g.alphaTest.value=h.alphaTest)}function f(g,h){g.specular.value.copy(h.specular),g.shininess.value=Math.max(h.shininess,1e-4)}function m(g,h){h.gradientMap&&(g.gradientMap.value=h.gradientMap)}function u(g,h){g.metalness.value=h.metalness,h.metalnessMap&&(g.metalnessMap.value=h.metalnessMap,t(h.metalnessMap,g.metalnessMapTransform)),g.roughness.value=h.roughness,h.roughnessMap&&(g.roughnessMap.value=h.roughnessMap,t(h.roughnessMap,g.roughnessMapTransform)),h.envMap&&(g.envMapIntensity.value=h.envMapIntensity)}function _(g,h,b){g.ior.value=h.ior,h.sheen>0&&(g.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),g.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(g.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,g.sheenColorMapTransform)),h.sheenRoughnessMap&&(g.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,g.sheenRoughnessMapTransform))),h.clearcoat>0&&(g.clearcoat.value=h.clearcoat,g.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(g.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,g.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(g.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===Pt&&g.clearcoatNormalScale.value.negate())),h.dispersion>0&&(g.dispersion.value=h.dispersion),h.iridescence>0&&(g.iridescence.value=h.iridescence,g.iridescenceIOR.value=h.iridescenceIOR,g.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(g.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,g.iridescenceMapTransform)),h.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),h.transmission>0&&(g.transmission.value=h.transmission,g.transmissionSamplerMap.value=b.texture,g.transmissionSamplerSize.value.set(b.width,b.height),h.transmissionMap&&(g.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,g.transmissionMapTransform)),g.thickness.value=h.thickness,h.thicknessMap&&(g.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=h.attenuationDistance,g.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(g.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(g.anisotropyMap.value=h.anisotropyMap,t(h.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=h.specularIntensity,g.specularColor.value.copy(h.specularColor),h.specularColorMap&&(g.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,g.specularColorMapTransform)),h.specularIntensityMap&&(g.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,g.specularIntensityMapTransform))}function v(g,h){h.matcap&&(g.matcap.value=h.matcap)}function y(g,h){const b=e.get(h).light;g.referencePosition.value.setFromMatrixPosition(b.matrixWorld),g.nearDistance.value=b.shadow.camera.near,g.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Cm(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,A){const S=A.program;n.uniformBlockBinding(M,S)}function l(M,A){let S=r[M.id];S===void 0&&(g(M),S=f(M),r[M.id]=S,M.addEventListener("dispose",b));const C=A.program;n.updateUBOMapping(M,C);const p=e.render.frame;s[M.id]!==p&&(u(M),s[M.id]=p)}function f(M){const A=m();M.__bindingPointIndex=A;const S=i.createBuffer(),C=M.__size,p=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,C,p),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,A,S),S}function m(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return We("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(M){const A=r[M.id],S=M.uniforms,C=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,A);for(let p=0,E=S.length;p<E;p++){const w=S[p];if(Array.isArray(w))for(let P=0,I=w.length;P<I;P++)_(w[P],p,P,C);
4116else _(w,p,0,C)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function _(M,A,S,C){if(y(M,A,S,C)===!0){const p=M.__offset,E=M.value;if(Array.isArray(E)){let w=0;for(let P=0;P<E.length;P++){const I=E[P],X=h(I);v(I,M.__data,w),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(w+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else v(E,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,p,M.__data)}}function v(M,A,S){typeof M=="number"||typeof M=="boolean"?A[0]=M:M.isMatrix3?(A[0]=M.elements[0],A[1]=M.elements[1],A[2]=M.elements[2],A[3]=0,A[4]=M.elements[3],A[5]=M.elements[4],A[6]=M.elements[5],A[7]=0,A[8]=M.elements[6],A[9]=M.elements[7],A[10]=M.elements[8],A[11]=0):ArrayBuffer.isView(M)?A.set(new M.constructor(M.buffer,M.byteOffset,A.length)):M.toArray(A,S)}function y(M,A,S,C){const p=M.value,E=A+"_"+S;if(C[E]===void 0)return typeof p=="number"||typeof p=="boolean"?C[E]=p:ArrayBuffer.isView(p)?C[E]=p.slice():C[E]=p.clone(),!0;{const w=C[E];if(typeof p=="number"||typeof p=="boolean"){if(w!==p)return C[E]=p,!0}else{if(ArrayBuffer.isView(p))return!0;if(w.equals(p)===!1)return w.copy(p),!0}}return!1}function g(M){const A=M.uniforms;let S=0;const C=16;for(let E=0,w=A.length;E<w;E++){const P=Array.isArray(A[E])?A[E]:[A[E]];for(let I=0,X=P.length;I<X;I++){const H=P[I],O=Array.isArray(H.value)?H.value:[H.value];for(let W=0,k=O.length;W<k;W++){const J=O[W],j=h(J),le=S%C,he=le%j.boundary,_e=le+he;S+=he,_e!==0&&C-_e<j.storage&&(S+=C-_e),H.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=S,S+=j.storage}}}const p=S%C;return p>0&&(S+=C-p),M.__size=S,M.__cache={},this}function h(M){const A={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(A.boundary=4,A.storage=4):M.isVector2?(A.boundary=8,A.storage=8):M.isVector3||M.isColor?(A.boundary=16,A.storage=12):M.isVector4?(A.boundary=16,A.storage=16):M.isMatrix3?(A.boundary=48,A.storage=48):M.isMatrix4?(A.boundary=64,A.storage=64):M.isTexture?we("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(A.boundary=16,A.storage=M.byteLength):we("WebGLRenderer: Unsupported uniform value type.",M),A}function b(M){const A=M.target;A.removeEventListener("dispose",b);const S=a.indexOf(A.__bindingPointIndex);a.splice(S,1),i.deleteBuffer(r[A.id]),delete r[A.id],delete s[A.id]}function R(){for(const M in r)i.deleteBuffer(r[M]);a=[],r={},s={}}return{bind:c,update:l,dispose:R}}const Pm=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,
vendor: 4,246 bytes, line 4116
411614942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let en=null;function Dm(){return en===null&&(en=new Rl(Pm,16,16,Kn,xn),en.name="DFG_LUT",en.minFilter=wt,en.magFilter=wt,en.wrapS=pn,en.wrapT=pn,en.generateMipmaps=!1,en.needsUpdate=!0),en}class Lm{constructor(e={}){const{canvas:t=Uc(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:u=!1,outputBufferType:_=Ft}=e;this.isWebGLRenderer=!0;let v;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");v=n.getContextAttributes().alpha}else v=a;const y=_,g=new Set([Ma,va,xa]),h=new Set([Ft,ln,zi,Gi,ma,ga]),b=new Uint32Array(4),R=new Int32Array(4),M=new N;let A=null,S=null;const C=[],p=[];let E=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=an,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const w=this;let P=!1,I=null,X=null,H=null,O=null;this._outputColorSpace=zt;let W=0,k=0,J=null,j=-1,le=null;const he=new it,_e=new it;let Ve=null;const rt=new Ge(0);let Xe=0,$=t.width,ie=t.height,ee=1,Re=null,De=null;const be=new it(0,0,$,ie),lt=new it(0,0,$,ie);let Oe=!1;const $e=new Aa;let qe=!1,He=!1;const ht=new tt,pt=new N,_t=new it,St={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let st=!1;function ft(){return J===null?ee:1}let L=n;function Lt(x,U){return t.getContext(x,U)}try{const x={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:f,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${fa}`),t.addEventListener("webglcontextlost",at,!1),t.addEventListener("webglcontextrestored",je,!1),t.addEventListener("webglcontextcreationerror",$t,!1),L===null){const U="webgl2";if(L=Lt(U,x),L===null)throw Lt(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(x){throw We("WebGLRenderer: "+x.message),x}let Ye,T,d,F,G,q,te,re,Y,Z,se,Se,ce,ae,Te,Ae,Le,D,ne,K,oe,pe,Q;
vendor: 5,386 bytes, line 4116
4116function Me(){Ye=new Dd(L),Ye.init(),oe=new Em(L,Ye),T=new yd(L,Ye,e,oe),d=new Mm(L,Ye),T.reversedDepthBuffer&&u&&d.buffers.depth.setReversed(!0),X=L.createFramebuffer(),H=L.createFramebuffer(),O=L.createFramebuffer(),F=new Ud(L),G=new am,q=new Sm(L,Ye,d,G,T,oe,F),te=new Pd(w),re=new Ou(L),pe=new Sd(L,re),Y=new Ld(L,re,F,pe),Z=new Fd(L,Y,re,pe,F),D=new Nd(L,T,q),Te=new Td(G),se=new sm(w,te,Ye,T,pe,Te),Se=new Rm(w,G),ce=new lm,ae=new pm(Ye),Le=new Md(w,te,d,Z,v,c),Ae=new vm(w,Z,T),Q=new Cm(L,F,T,d),ne=new Ed(L,Ye,F),K=new Id(L,Ye,F),F.programs=se.programs,w.capabilities=T,w.extensions=Ye,w.properties=G,w.renderLists=ce,w.shadowMap=Ae,w.state=d,w.info=F}Me(),y!==Ft&&(E=new Bd(y,t.width,t.height,o,r,s));const xe=new Am(w,L);this.xr=xe,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const x=Ye.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Ye.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(x){x!==void 0&&(ee=x,this.setSize($,ie,!1))},this.getSize=function(x){return x.set($,ie)},this.setSize=function(x,U,V=!0){if(xe.isPresenting){we("WebGLRenderer: Can't change size while VR device is presenting.");return}$=x,ie=U,t.width=Math.floor(x*ee),t.height=Math.floor(U*ee),V===!0&&(t.style.width=x+"px",t.style.height=U+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,x,U)},this.getDrawingBufferSize=function(x){return x.set($*ee,ie*ee).floor()},this.setDrawingBufferSize=function(x,U,V){$=x,ie=U,ee=V,t.width=Math.floor(x*V),t.height=Math.floor(U*V),this.setViewport(0,0,x,U)},this.setEffects=function(x){if(y===Ft){We("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let U=0;U<x.length;U++)if(x[U].isOutputPass===!0){we("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(x||[])},this.getCurrentViewport=function(x){return x.copy(he)},this.getViewport=function(x){return x.copy(be)},this.setViewport=function(x,U,V,B){x.isVector4?be.set(x.x,x.y,x.z,x.w):be.set(x,U,V,B),d.viewport(he.copy(be).multiplyScalar(ee).round())},this.getScissor=function(x){return x.copy(lt)},this.setScissor=function(x,U,V,B){x.isVector4?lt.set(x.x,x.y,x.z,x.w):lt.set(x,U,V,B),d.scissor(_e.copy(lt).multiplyScalar(ee).round())},this.getScissorTest=function(){return Oe},this.setScissorTest=function(x){d.setScissorTest(Oe=x)},this.setOpaqueSort=function(x){Re=x},this.setTransparentSort=function(x){De=x},this.getClearColor=function(x){return x.copy(Le.getClearColor())},this.setClearColor=function(){Le.setClearColor(...arguments)},this.getClearAlpha=function(){return Le.getClearAlpha()},this.setClearAlpha=function(){Le.setClearAlpha(...arguments)},this.clear=function(x=!0,U=!0,V=!0){let B=0;if(x){let z=!1;if(J!==null){const de=J.texture.format;z=g.has(de)}if(z){const de=J.texture.type,ge=h.has(de),fe=Le.getClearColor(),ve=Le.getClearAlpha(),Ee=fe.r,Ie=fe.g,Ne=fe.b;ge?(b[0]=Ee,b[1]=Ie,b[2]=Ne,b[3]=ve,L.clearBufferuiv(L.COLOR,0,b)):(R[0]=Ee,R[1]=Ie,R[2]=Ne,R[3]=ve,L.clearBufferiv(L.COLOR,0,R))}else B|=L.COLOR_BUFFER_BIT}U&&(B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&L.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(x){x.setRenderer(this),I=x},this.dispose=function(){t.removeEventListener("webglcontextlost",at,!1),t.removeEventListener("webglcontextrestored",je,!1),t.removeEventListener("webglcontextcreationerror",$t,!1),Le.dispose(),ce.dispose(),ae.dispose(),G.dispose(),te.dispose(),Z.dispose(),pe.dispose(),Q.dispose(),se.dispose(),xe.dispose(),xe.removeEventListener("sessionstart",Ba),xe.removeEventListener("sessionend",za),In.stop()};function at(x){x.preventDefault(),eo("WebGLRenderer: Context Lost."),P=!0}function je(){eo("WebGLRenderer: Context Restored."),P=!1;const x=F.autoReset,U=Ae.enabled,V=Ae.autoUpdate,B=Ae.needsUpdate,z=Ae.type;Me(),F.autoReset=x,Ae.enabled=U,Ae.autoUpdate=V,Ae.needsUpdate=B,Ae.type=z}function $t(x){We("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function Jt(x){const U=x.target;U.removeEventListener("dispose",Jt),Xl(U)}function Xl(x){ql(x),G.remove(x)}function ql(x){const U=G.get(x).programs;U!==void 0&&(U.forEach(function(V){se.releaseProgram(V)}),x.isShaderMaterial&&se.releaseShaderCache(x))}this.renderBufferDirect=function(x,U,V,B,z,de){U===null&&(U=St);const ge=z.isMesh&&z.matrixWorld.determinantAffine()<0,fe=Zl(x,U,V,B,z);d.setMaterial(B,ge);let ve=V.index,Ee=1;if(B.wireframe===!0){if(ve=Y.getWireframeAttribute(V),ve===void 0)return;Ee=2}const Ie=V.drawRange,Ne=V.attributes.position;let ye=Ie.start*Ee,Ze=(Ie.start+Ie.count)*Ee;de!==null&&(ye=Math.max(ye,de.start*Ee),Ze=Math.min(Ze,(de.start+de.count)*Ee)),ve!==null?(ye=Math.max(ye,0),Ze=Math.min(Ze,ve.count)):Ne!=null&&(ye=Math.max(ye,0),Ze=Math.min(Ze,Ne.count));const ct=Ze-ye;if(ct<0||ct===1/0)return;pe.setup(z,B,fe,V,ve);let ot,Je=ne;if(ve!==null&&(ot=re.get(ve),Je=K,Je.setIndex(ot)),z.isMesh)B.wireframe===!0?(d.set
vendor: 10,227 bytes, line 4116
4116LineWidth(B.wireframeLinewidth*ft()),Je.setMode(L.LINES)):Je.setMode(L.TRIANGLES);else if(z.isLine){let yt=B.linewidth;yt===void 0&&(yt=1),d.setLineWidth(yt*ft()),z.isLineSegments?Je.setMode(L.LINES):z.isLineLoop?Je.setMode(L.LINE_LOOP):Je.setMode(L.LINE_STRIP)}else z.isPoints?Je.setMode(L.POINTS):z.isSprite&&Je.setMode(L.TRIANGLES);if(z.isBatchedMesh)if(Ye.get("WEBGL_multi_draw"))Je.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{const yt=z._multiDrawStarts,me=z._multiDrawCounts,It=z._multiDrawCount,ke=ve?re.get(ve).bytesPerElement:1,Ot=G.get(B).currentProgram.getUniforms();for(let Qt=0;Qt<It;Qt++)Ot.setValue(L,"_gl_DrawID",Qt),Je.render(yt[Qt]/ke,me[Qt])}else if(z.isInstancedMesh)Je.renderInstances(ye,ct,z.count);else if(V.isInstancedBufferGeometry){const yt=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,me=Math.min(V.instanceCount,yt);Je.renderInstances(ye,ct,me)}else Je.render(ye,ct)};function Oa(x,U,V){x.transparent===!0&&x.side===nn&&x.forceSinglePass===!1?(x.side=Pt,x.needsUpdate=!0,Ki(x,U,V),x.side=Dn,x.needsUpdate=!0,Ki(x,U,V),x.side=nn):Ki(x,U,V)}this.compile=function(x,U,V=null){V===null&&(V=x),S=ae.get(V),S.init(U),p.push(S),V.traverseVisible(function(z){z.isLight&&z.layers.test(U.layers)&&(S.pushLight(z),z.castShadow&&S.pushShadow(z))}),x!==V&&x.traverseVisible(function(z){z.isLight&&z.layers.test(U.layers)&&(S.pushLight(z),z.castShadow&&S.pushShadow(z))}),S.setupLights();const B=new Set;return x.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;const de=z.material;if(de)if(Array.isArray(de))for(let ge=0;ge<de.length;ge++){const fe=de[ge];Oa(fe,V,z),B.add(fe)}else Oa(de,V,z),B.add(de)}),S=p.pop(),B},this.compileAsync=function(x,U,V=null){const B=this.compile(x,U,V);return new Promise(z=>{function de(){if(B.forEach(function(ge){G.get(ge).currentProgram.isReady()&&B.delete(ge)}),B.size===0){z(x);return}setTimeout(de,10)}Ye.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let Br=null;function Yl(x){Br&&Br(x)}function Ba(){In.stop()}function za(){In.start()}const In=new Nl;In.setAnimationLoop(Yl),typeof self<"u"&&In.setContext(self),this.setAnimationLoop=function(x){Br=x,xe.setAnimationLoop(x),x===null?In.stop():In.start()},xe.addEventListener("sessionstart",Ba),xe.addEventListener("sessionend",za),this.render=function(x,U){if(U!==void 0&&U.isCamera!==!0){We("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;I!==null&&I.renderStart(x,U);const V=xe.enabled===!0&&xe.isPresenting===!0,B=E!==null&&(J===null||V)&&E.begin(w,J);if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),xe.enabled===!0&&xe.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(xe.cameraAutoUpdate===!0&&xe.updateCamera(U),U=xe.getCamera()),x.isScene===!0&&x.onBeforeRender(w,x,U,J),S=ae.get(x,p.length),S.init(U),S.state.textureUnits=q.getTextureUnits(),p.push(S),ht.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),$e.setFromProjectionMatrix(ht,rn,U.reversedDepth),He=this.localClippingEnabled,qe=Te.init(this.clippingPlanes,He),A=ce.get(x,C.length),A.init(),C.push(A),xe.enabled===!0&&xe.isPresenting===!0){const ge=w.xr.getDepthSensingMesh();ge!==null&&zr(ge,U,-1/0,w.sortObjects)}zr(x,U,0,w.sortObjects),A.finish(),w.sortObjects===!0&&A.sort(Re,De,U.reversedDepth),st=xe.enabled===!1||xe.isPresenting===!1||xe.hasDepthSensing()===!1,st&&Le.addToRenderList(A,x),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),qe===!0&&Te.beginShadows();const z=S.state.shadowsArray;if(Ae.render(z,x,U),qe===!0&&Te.endShadows(),(B&&E.hasRenderPass())===!1){const ge=A.opaque,fe=A.transmissive;if(S.setupLights(),U.isArrayCamera){const ve=U.cameras;if(fe.length>0)for(let Ee=0,Ie=ve.length;Ee<Ie;Ee++){const Ne=ve[Ee];Va(ge,fe,x,Ne)}st&&Le.render(x);for(let Ee=0,Ie=ve.length;Ee<Ie;Ee++){const Ne=ve[Ee];Ga(A,x,Ne,Ne.viewport)}}else fe.length>0&&Va(ge,fe,x,U),st&&Le.render(x),Ga(A,x,U)}J!==null&&k===0&&(q.updateMultisampleRenderTarget(J),q.updateRenderTargetMipmap(J)),B&&E.end(w),x.isScene===!0&&x.onAfterRender(w,x,U),pe.resetDefaultState(),j=-1,le=null,p.pop(),p.length>0?(S=p[p.length-1],q.setTextureUnits(S.state.textureUnits),qe===!0&&Te.setGlobalState(w.clippingPlanes,S.state.camera)):S=null,C.pop(),C.length>0?A=C[C.length-1]:A=null,I!==null&&I.renderEnd()};function zr(x,U,V,B){if(x.visible===!1)return;if(x.layers.test(U.layers)){if(x.isGroup)V=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(U);else if(x.isLightProbeGrid)S.pushLightProbeGrid(x);else if(x.isLight)S.pushLight(x),x.castShadow&&S.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||$e.intersectsSprite(x)){B&&_t.setFromMatrixPosition(x.matrixWorld).applyMatrix4(ht);const ge=Z.update(x),fe=x.material;fe.visible&&A.push(x,ge,fe,V,_t.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||$e.intersectsObject(x))){const ge=Z.update(x),fe=x.material;if(B&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),_t.copy(x.boundingSphere.center)):(ge.boundingSphere===null&&ge.computeBoundingSphere(),_t.copy(ge.boundingSphere.center)),_t.applyMatrix4(x.matrixWorld).applyMatrix4(ht)),Array.isArray(fe)){const ve=ge.groups;for(let Ee=0,Ie=ve.length;Ee<Ie;Ee++){const Ne=ve[Ee],ye=fe[Ne.materialIndex];ye&&ye.visible&&A.push(x,ge,ye,V,_t.z,Ne)}}else fe.visible&&A.push(x,ge,fe,V,_t.z,null)}}const de=x.children;for(let ge=0,fe=de.length;ge<fe;ge++)zr(de[ge],U,V,B)}function Ga(x,U,V,B){const{opaque:z,transmissive:de,transparent:ge}=x;S.setupLightsView(V),qe===!0&&Te.setGlobalState(w.clippingPlanes,V),B&&d.viewport(he.copy(B)),z.length>0&&Yi(z,U,V),de.length>0&&Yi(de,U,V),ge.length>0&&Yi(ge,U,V),d.buffers.depth.setTest(!0),d.buffers.depth.setMask(!0),d.buffers.color.setMask(!0),d.setPolygonOffset(!1)}function Va(x,U,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[B.id]===void 0){const ye=Ye.has("EXT_color_buffer_half_float")||Ye.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[B.id]=new on(1,1,{generateMipmaps:!0,type:ye?xn:Ft,minFilter:Hn,samples:Math.max(4,T.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ze.workingColorSpace})}const de=S.state.transmissionRenderTarget[B.id],ge=B.viewport||he;de.setSize(ge.z*w.transmissionResolutionScale,ge.w*w.transmissionResolutionScale);const fe=w.getRenderTarget(),ve=w.getActiveCubeFace(),Ee=w.getActiveMipmapLevel();w.setRenderTarget(de),w.getClearColor(rt),Xe=w.getClearAlpha(),Xe<1&&w.setClearColor(16777215,.5),w.clear(),st&&Le.render(V);const Ie=w.toneMapping;w.toneMapping=an;const Ne=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),S.setupLightsView(B),qe===!0&&Te.setGlobalState(w.clippingPlanes,B),Yi(x,V,B),q.updateMultisampleRenderTarget(de),q.updateRenderTargetMipmap(de),Ye.has("WEBGL_multisampled_render_to_texture")===!1){let ye=!1;for(let Ze=0,ct=U.length;Ze<ct;Ze++){const ot=U[Ze],{object:Je,geometry:yt,material:me,group:It}=ot;if(me.side===nn&&Je.layers.test(B.layers)){const ke=me.side;me.side=Pt,me.needsUpdate=!0,Ha(Je,V,B,yt,me,It),me.side=ke,me.needsUpdate=!0,ye=!0}}ye===!0&&(q.updateMultisampleRenderTarget(de),q.updateRenderTargetMipmap(de))}w.setRenderTarget(fe,ve,Ee),w.setClearColor(rt,Xe),Ne!==void 0&&(B.viewport=Ne),w.toneMapping=Ie}function Yi(x,U,V){const B=U.isScene===!0?U.overrideMaterial:null;for(let z=0,de=x.length;z<de;z++){const ge=x[z],{object:fe,geometry:ve,group:Ee}=ge;let Ie=ge.material;Ie.allowOverride===!0&&B!==null&&(Ie=B),fe.layers.test(V.layers)&&Ha(fe,U,V,ve,Ie,Ee)}}function Ha(x,U,V,B,z,de){x.onBeforeRender(w,U,V,B,z,de),x.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),z.onBeforeRender(w,U,V,B,x,de),z.transparent===!0&&z.side===nn&&z.forceSinglePass===!1?(z.side=Pt,z.needsUpdate=!0,w.renderBufferDirect(V,U,B,z,x,de),z.side=Dn,z.needsUpdate=!0,w.renderBufferDirect(V,U,B,z,x,de),z.side=nn):w.renderBufferDirect(V,U,B,z,x,de),x.onAfterRender(w,U,V,B,z,de)}function Ki(x,U,V){U.isScene!==!0&&(U=St);const B=G.get(x),z=S.state.lights,de=S.state.shadowsArray,ge=z.state.version,fe=se.getParameters(x,z.state,de,U,V,S.state.lightProbeGridArray),ve=se.getProgramCacheKey(fe);let Ee=B.programs;B.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?U.environment:null,B.fog=U.fog;const Ie=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;B.envMap=te.get(x.envMap||B.environment,Ie),B.envMapRotation=B.environment!==null&&x.envMap===null?U.environmentRotation:x.envMapRotation,Ee===void 0&&(x.addEventListener("dispose",Jt),Ee=new Map,B.programs=Ee);let Ne=Ee.get(ve);if(Ne!==void 0){if(B.currentProgram===Ne&&B.lightsStateVersion===ge)return Wa(x,fe),Ne}else fe.uniforms=se.getUniforms(x),I!==null&&x.isNodeMaterial&&I.build(x,V,fe),x.onBeforeCompile(fe,w),Ne=se.acquireProgram(fe,ve),Ee.set(ve,Ne),B.uniforms=fe.uniforms;const ye=B.uniforms;return(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)&&(ye.clippingPlanes=Te.uniform),Wa(x,fe),B.needsLights=Jl(x),B.lightsStateVersion=ge,B.needsLights&&(ye.ambientLightColor.value=z.state.ambient,ye.lightProbe.value=z.state.probe,ye.directionalLights.value=z.state.directional,ye.directionalLightShadows.value=z.state.directionalShadow,ye.spotLights.value=z.state.spot,ye.spotLightShadows.value=z.state.spotShadow,ye.rectAreaLights.value=z.state.rectArea,ye.ltc_1.value=z.state.rectAreaLTC1,ye.ltc_2.value=z.state.rectAreaLTC2,ye.pointLights.value=z.state.point,ye.pointLightShadows.value=z.state.pointShadow,ye.hemisphereLights.value=z.state.hemi,ye.directionalShadowMatrix.value=z.state.directionalShadowMatrix,ye.spotLightMatrix.value=z.state.spotLightMatrix,ye.spotLightMap.value=z.state.spotLightMap,ye.pointShadowMatrix.value=z.state.pointShadowMatrix),B.lightProbeGrid=S.state.lightProbeGridArray.length>0,B.currentProgram=Ne,B.uniformsList=null,Ne}function ka(x){if(x.uniformsList===null){const U=x.currentProgram.getUniforms();x.uniformsList=yr.seqWithValue(U.seq,x.uniforms)}return x.uniformsList}function Wa(x,U){const V=G.get(x);
vendor: 8,027 bytes, line 4116
4116V.outputColorSpace=U.outputColorSpace,V.batching=U.batching,V.batchingColor=U.batchingColor,V.instancing=U.instancing,V.instancingColor=U.instancingColor,V.instancingMorph=U.instancingMorph,V.skinning=U.skinning,V.morphTargets=U.morphTargets,V.morphNormals=U.morphNormals,V.morphColors=U.morphColors,V.morphTargetsCount=U.morphTargetsCount,V.numClippingPlanes=U.numClippingPlanes,V.numIntersection=U.numClipIntersection,V.vertexAlphas=U.vertexAlphas,V.vertexTangents=U.vertexTangents,V.toneMapping=U.toneMapping}function Kl(x,U){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let V=0,B=x.length;V<B;V++){const z=x[V];if(z.texture!==null&&z.boundingBox.containsPoint(M))return z}return null}function Zl(x,U,V,B,z){U.isScene!==!0&&(U=St),q.resetTextureUnits();const de=U.fog,ge=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?U.environment:null,fe=J===null?w.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:ze.workingColorSpace,ve=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Ee=te.get(B.envMap||ge,ve),Ie=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Ne=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),ye=!!V.morphAttributes.position,Ze=!!V.morphAttributes.normal,ct=!!V.morphAttributes.color;let ot=an;B.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(ot=w.toneMapping);const Je=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,yt=Je!==void 0?Je.length:0,me=G.get(B),It=S.state.lights;if(qe===!0&&(He===!0||x!==le)){const et=x===le&&B.id===j;Te.setState(B,x,et)}let ke=!1;B.version===me.__version?(me.needsLights&&me.lightsStateVersion!==It.state.version||me.outputColorSpace!==fe||z.isBatchedMesh&&me.batching===!1||!z.isBatchedMesh&&me.batching===!0||z.isBatchedMesh&&me.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&me.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&me.instancing===!1||!z.isInstancedMesh&&me.instancing===!0||z.isSkinnedMesh&&me.skinning===!1||!z.isSkinnedMesh&&me.skinning===!0||z.isInstancedMesh&&me.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&me.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&me.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&me.instancingMorph===!1&&z.morphTexture!==null||me.envMap!==Ee||B.fog===!0&&me.fog!==de||me.numClippingPlanes!==void 0&&(me.numClippingPlanes!==Te.numPlanes||me.numIntersection!==Te.numIntersection)||me.vertexAlphas!==Ie||me.vertexTangents!==Ne||me.morphTargets!==ye||me.morphNormals!==Ze||me.morphColors!==ct||me.toneMapping!==ot||me.morphTargetsCount!==yt||!!me.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ke=!0):(ke=!0,me.__version=B.version);let Ot=me.currentProgram;ke===!0&&(Ot=Ki(B,U,z),I&&B.isNodeMaterial&&I.onUpdateProgram(B,Ot,me));let Qt=!1,Mn=!1,Jn=!1;const Qe=Ot.getUniforms(),ut=me.uniforms;if(d.useProgram(Ot.program)&&(Qt=!0,Mn=!0,Jn=!0),B.id!==j&&(j=B.id,Mn=!0),me.needsLights){const et=Kl(S.state.lightProbeGridArray,z);me.lightProbeGrid!==et&&(me.lightProbeGrid=et,Mn=!0)}if(Qt||le!==x){d.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),Qe.setValue(L,"projectionMatrix",x.projectionMatrix),Qe.setValue(L,"viewMatrix",x.matrixWorldInverse);const En=Qe.map.cameraPosition;En!==void 0&&En.setValue(L,pt.setFromMatrixPosition(x.matrixWorld)),T.logarithmicDepthBuffer&&Qe.setValue(L,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&Qe.setValue(L,"isOrthographic",x.isOrthographicCamera===!0),le!==x&&(le=x,Mn=!0,Jn=!0)}if(me.needsLights&&(It.state.directionalShadowMap.length>0&&Qe.setValue(L,"directionalShadowMap",It.state.directionalShadowMap,q),It.state.spotShadowMap.length>0&&Qe.setValue(L,"spotShadowMap",It.state.spotShadowMap,q),It.state.pointShadowMap.length>0&&Qe.setValue(L,"pointShadowMap",It.state.pointShadowMap,q)),z.isSkinnedMesh){Qe.setOptional(L,z,"bindMatrix"),Qe.setOptional(L,z,"bindMatrixInverse");const et=z.skeleton;et&&(et.boneTexture===null&&et.computeBoneTexture(),Qe.setValue(L,"boneTexture",et.boneTexture,q))}z.isBatchedMesh&&(Qe.setOptional(L,z,"batchingTexture"),Qe.setValue(L,"batchingTexture",z._matricesTexture,q),Qe.setOptional(L,z,"batchingIdTexture"),Qe.setValue(L,"batchingIdTexture",z._indirectTexture,q),Qe.setOptional(L,z,"batchingColorTexture"),z._colorsTexture!==null&&Qe.setValue(L,"batchingColorTexture",z._colorsTexture,q));const Sn=V.morphAttributes;if((Sn.position!==void 0||Sn.normal!==void 0||Sn.color!==void 0)&&D.update(z,V,Ot),(Mn||me.receiveShadow!==z.receiveShadow)&&(me.receiveShadow=z.receiveShadow,Qe.setValue(L,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&U.environment!==null&&(ut.envMapIntensity.value=U.environmentIntensity),ut.dfgLUT!==void 0&&(ut.dfgLUT.value=Dm()),Mn){if(Qe.setValue(L,"toneMappingExposure",w.toneMappingExposure),me.needsLights&&$l(ut,Jn),de&&B.fog===!0&&Se.refreshFogUniforms(ut,de),Se.refreshMaterialUniforms(ut,B,ee,ie,S.state.transmissionRenderTarget[x.id]),me.needsLights&&me.lightProbeGrid){const et=me.lightProbeGrid;ut.probesSH.value=et.texture,ut.probesMin.value.copy(et.boundingBox.min),ut.probesMax.value.copy(et.boundingBox.max),ut.probesResolution.value.copy(et.resolution)}yr.upload(L,ka(me),ut,q)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(yr.upload(L,ka(me),ut,q),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&Qe.setValue(L,"center",z.center),Qe.setValue(L,"modelViewMatrix",z.modelViewMatrix),Qe.setValue(L,"normalMatrix",z.normalMatrix),Qe.setValue(L,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){const et=B.uniformsGroups;for(let En=0,Qn=et.length;En<Qn;En++){const Xa=et[En];Q.update(Xa,Ot),Q.bind(Xa,Ot)}}return Ot}function $l(x,U){x.ambientLightColor.needsUpdate=U,x.lightProbe.needsUpdate=U,x.directionalLights.needsUpdate=U,x.directionalLightShadows.needsUpdate=U,x.pointLights.needsUpdate=U,x.pointLightShadows.needsUpdate=U,x.spotLights.needsUpdate=U,x.spotLightShadows.needsUpdate=U,x.rectAreaLights.needsUpdate=U,x.hemisphereLights.needsUpdate=U}function Jl(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return J},this.setRenderTargetTextures=function(x,U,V){const B=G.get(x);B.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),G.get(x.texture).__webglTexture=U,G.get(x.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,U){const V=G.get(x);V.__webglFramebuffer=U,V.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(x,U=0,V=0){J=x,W=U,k=V;let B=null,z=!1,de=!1;if(x){const fe=G.get(x);if(fe.__useDefaultFramebuffer!==void 0){d.bindFramebuffer(L.FRAMEBUFFER,fe.__webglFramebuffer),he.copy(x.viewport),_e.copy(x.scissor),Ve=x.scissorTest,d.viewport(he),d.scissor(_e),d.setScissorTest(Ve),j=-1;return}else if(fe.__webglFramebuffer===void 0)q.setupRenderTarget(x);else if(fe.__hasExternalTextures)q.rebindTextures(x,G.get(x.texture).__webglTexture,G.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){const Ie=x.depthTexture;if(fe.__boundDepthTexture!==Ie){if(Ie!==null&&G.has(Ie)&&(x.width!==Ie.image.width||x.height!==Ie.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");q.setupDepthRenderbuffer(x)}}const ve=x.texture;(ve.isData3DTexture||ve.isDataArrayTexture||ve.isCompressedArrayTexture)&&(de=!0);const Ee=G.get(x).__webglFramebuffer;
vendor: 6,227 bytes, line 4116
4116x.isWebGLCubeRenderTarget?(Array.isArray(Ee[U])?B=Ee[U][V]:B=Ee[U],z=!0):x.samples>0&&q.useMultisampledRTT(x)===!1?B=G.get(x).__webglMultisampledFramebuffer:Array.isArray(Ee)?B=Ee[V]:B=Ee,he.copy(x.viewport),_e.copy(x.scissor),Ve=x.scissorTest}else he.copy(be).multiplyScalar(ee).floor(),_e.copy(lt).multiplyScalar(ee).floor(),Ve=Oe;if(V!==0&&(B=X),d.bindFramebuffer(L.FRAMEBUFFER,B)&&d.drawBuffers(x,B),d.viewport(he),d.scissor(_e),d.setScissorTest(Ve),z){const fe=G.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+U,fe.__webglTexture,V)}else if(de){const fe=U;for(let ve=0;ve<x.textures.length;ve++){const Ee=G.get(x.textures[ve]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+ve,Ee.__webglTexture,V,fe)}}else if(x!==null&&V!==0){const fe=G.get(x.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,fe.__webglTexture,V)}j=-1},this.readRenderTargetPixels=function(x,U,V,B,z,de,ge,fe=0){if(!(x&&x.isWebGLRenderTarget)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ve=G.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ge!==void 0&&(ve=ve[ge]),ve){d.bindFramebuffer(L.FRAMEBUFFER,ve);try{const Ee=x.textures[fe],Ie=Ee.format,Ne=Ee.type;if(x.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+fe),!T.textureFormatReadable(Ie)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(Ne)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=x.width-B&&V>=0&&V<=x.height-z&&L.readPixels(U,V,B,z,oe.convert(Ie),oe.convert(Ne),de)}finally{const Ee=J!==null?G.get(J).__webglFramebuffer:null;d.bindFramebuffer(L.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(x,U,V,B,z,de,ge,fe=0){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ve=G.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ge!==void 0&&(ve=ve[ge]),ve)if(U>=0&&U<=x.width-B&&V>=0&&V<=x.height-z){d.bindFramebuffer(L.FRAMEBUFFER,ve);const Ee=x.textures[fe],Ie=Ee.format,Ne=Ee.type;if(x.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+fe),!T.textureFormatReadable(Ie))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(Ne))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const ye=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,ye),L.bufferData(L.PIXEL_PACK_BUFFER,de.byteLength,L.STREAM_READ),L.readPixels(U,V,B,z,oe.convert(Ie),oe.convert(Ne),0);const Ze=J!==null?G.get(J).__webglFramebuffer:null;d.bindFramebuffer(L.FRAMEBUFFER,Ze);const ct=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Nc(L,ct,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,ye),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,de),L.deleteBuffer(ye),L.deleteSync(ct),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,U=null,V=0){const B=Math.pow(2,-V),z=Math.floor(x.image.width*B),de=Math.floor(x.image.height*B),ge=U!==null?U.x:0,fe=U!==null?U.y:0;q.setTexture2D(x,0),L.copyTexSubImage2D(L.TEXTURE_2D,V,0,0,ge,fe,z,de),d.unbindTexture()},this.copyTextureToTexture=function(x,U,V=null,B=null,z=0,de=0){let ge,fe,ve,Ee,Ie,Ne,ye,Ze,ct;const ot=x.isCompressedTexture?x.mipmaps[de]:x.image;if(V!==null)ge=V.max.x-V.min.x,fe=V.max.y-V.min.y,ve=V.isBox3?V.max.z-V.min.z:1,Ee=V.min.x,Ie=V.min.y,Ne=V.isBox3?V.min.z:0;else{const ut=Math.pow(2,-z);ge=Math.floor(ot.width*ut),fe=Math.floor(ot.height*ut),x.isDataArrayTexture?ve=ot.depth:x.isData3DTexture?ve=Math.floor(ot.depth*ut):ve=1,Ee=0,Ie=0,Ne=0}B!==null?(ye=B.x,Ze=B.y,ct=B.z):(ye=0,Ze=0,ct=0);const Je=oe.convert(U.format),yt=oe.convert(U.type);let me;U.isData3DTexture?(q.setTexture3D(U,0),me=L.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(q.setTexture2DArray(U,0),me=L.TEXTURE_2D_ARRAY):(q.setTexture2D(U,0),me=L.TEXTURE_2D),d.activeTexture(L.TEXTURE0),d.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,U.flipY),d.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),d.pixelStorei(L.UNPACK_ALIGNMENT,U.unpackAlignment);const It=d.getParameter(L.UNPACK_ROW_LENGTH),ke=d.getParameter(L.UNPACK_IMAGE_HEIGHT),Ot=d.getParameter(L.UNPACK_SKIP_PIXELS),Qt=d.getParameter(L.UNPACK_SKIP_ROWS),Mn=d.getParameter(L.UNPACK_SKIP_IMAGES);d.pixelStorei(L.UNPACK_ROW_LENGTH,ot.width),d.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ot.height),d.pixelStorei(L.UNPACK_SKIP_PIXELS,Ee),d.pixelStorei(L.UNPACK_SKIP_ROWS,Ie),d.pixelStorei(L.UNPACK_SKIP_IMAGES,Ne);const Jn=x.isDataArrayTexture||x.isData3DTexture,Qe=U.isDataArrayTexture||U.isData3DTexture;if(x.isDepthTexture){const ut=G.get(x),Sn=G.get(U),et=G.get(ut.__renderTarget),En=G.get(Sn.__renderTarget);d.bindFramebuffer(L.READ_FRAMEBUFFER,et.__webglFramebuffer),d.bindFramebuffer(L.DRAW_FRAMEBUFFER,En.__webglFramebuffer);for(let Qn=0;Qn<ve;Qn++)Jn&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,G.get(x).__webglTexture,z,Ne+Qn),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,G.get(U).__webglTexture,de,ct+Qn)),L.blitFramebuffer(Ee,Ie,ge,fe,ye,Ze,ge,fe,L.DEPTH_BUFFER_BIT,L.NEAREST);d.bindFramebuffer(L.READ_FRAMEBUFFER,null),d.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(z!==0||x.isRenderTargetTexture||G.has(x)){const ut=G.get(x),Sn=G.get(U);d.bindFramebuffer(L.READ_FRAMEBUFFER,H),d.bindFramebuffer(L.DRAW_FRAMEBUFFER,O);for(let et=0;et<ve;et++)Jn?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,ut.__webglTexture,z,Ne+et):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ut.__webglTexture,z),Qe?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Sn.__webglTexture,de,ct+et):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Sn.__webglTexture,de),z!==0?L.blitFramebuffer(Ee,Ie,ge,fe,ye,Ze,ge,fe,L.COLOR_BUFFER_BIT,L.NEAREST):Qe?L.c
4116opyTexSubImage3D(me,de,ye,Ze,ct+et,Ee,Ie,ge,fe):L.copyTexSubImage2D(me,de,ye,Ze,Ee,Ie,ge,fe);d.bindFramebuffer(L.READ_FRAMEBUFFER,null),d.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else Qe?x.isDataTexture||x.isData3DTexture?L.texSubImage3D(me,de,ye,Ze,ct,ge,fe,ve,Je,yt,ot.data):U.isCompressedArrayTexture?L.compressedTexSubImage3D(me,de,ye,Ze,ct,ge,fe,ve,Je,ot.data):L.texSubImage3D(me,de,ye,Ze,ct,ge,fe,ve,Je,yt,ot):x.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,de,ye,Ze,ge,fe,Je,yt,ot.data):x.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,de,ye,Ze,ot.width,ot.height,Je,ot.data):L.texSubImage2D(L.TEXTURE_2D,de,ye,Ze,ge,fe,Je,yt,ot);d.pixelStorei(L.UNPACK_ROW_LENGTH,It),d.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ke),d.pixelStorei(L.UNPACK_SKIP_PIXELS,Ot),d.pixelStorei(L.UNPACK_SKIP_ROWS,Qt),d.pixelStorei(L.UNPACK_SKIP_IMAGES,Mn),de===0&&U.generateMipmaps&&L.generateMipmap(me),d.unbindTexture()},this.initRenderTarget=function(x){G.get(x).__webglFramebuffer===void 0&&q.setupRenderTarget(x)},this.initTexture=function(x){x.isCubeTexture?q.setTextureCube(x,0):x.isData3DTexture?q.setTexture3D(x,0):x.isDataArrayTexture||x.isCompressedArrayTexture?q.setTexture2DArray(x,0):q.setTexture2D(x,0),d.unbindTexture()},this.resetState=function(){W=0,k=0,J=null,d.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ze._getDrawingBufferColorSpace(e),t.unpackColorSpace=ze._getUnpackColorSpace()}}class Or extends nt{constructor(){const e=Or.SkyShader,t=new Zt({name:e.name,uniforms:Ll.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:Pt,depthWrite:!1});super(new sn(1,1,1),t),this.isSky=!0}}Or.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new N},up:{value:new N(0,1,0)},cloudScale:{value:2e-4},cloudSpeed:{value:1e-4},cloudCoverage:{value:.4},cloudDensity:{value:.4},cloudElevation:{value:.5},showSunDisc:{value:1},time:{value:0}},vertexShader:` 4117 uniform vec3 sunPosition; 4118 uniform float rayleigh; 4119 uniform float turbidity; 4120 uniform float mieCoefficient; 4121 uniform vec3 up; 4122 4123 varying vec3 vWorldPosition; 4124 varying vec3 vSunDirection; 4125 varying float vSunfade; 4126 varying vec3 vBetaR; 4127 varying vec3 vBetaM; 4128 varying float vSunE; 4129 4130 // constants for atmospheric scattering 4131 const float e = 2.71828182845904523536028747135266249775724709369995957; 4132 const float pi = 3.141592653589793238462643383279502884197169; 4133 4134 // wavelength of used primaries, according to preetham 4135 const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 ); 4136 // this pre-calculation replaces older TotalRayleigh(vec3 lambda) function: 4137 // (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn)) 4138 const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 ); 4139 4140 // mie stuff 4141 // K coefficient for the primaries 4142 const float v = 4.0; 4143 const vec3 K = vec3( 0.686, 0.678, 0.666 ); 4144 // MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K 4145 const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 ); 4146 4147 // earth shadow hack 4148 // cutoffAngle = pi / 1.95; 4149 const float cutoffAngle = 1.6110731556870734; 4150 const float steepness = 1.5; 4151 const float EE = 1000.0; 4152 4153 float sunIntensity( float zenithAngleCos ) { 4154 zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 ); 4155 return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) ); 4156 } 4157 4158 vec3 totalMie( float T ) { 4159 float c = ( 0.2 * T ) * 10E-18; 4160 return 0.434 * c * MieConst; 4161 } 4162 4163 void main() { 4164 4165 vec4 worldPosition = modelMatrix * vec4( position, 1.0 ); 4166 vWorldPosition = worldPosition.xyz; 4167 4168 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 4169 gl_Position.z = gl_Position.w; // set z to camera.far 4170 4171 vSunDirection = normalize( sunPosition ); 4172 4173 vSunE = sunIntensity( dot( vSunDirection, up ) ); 4174 4175 vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 ); 4176 4177 float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) ); 4178 4179 // extinction (absorption + out scattering) 4180 // rayleigh coefficients 4181 vBetaR = totalRayleigh * rayleighCoefficient; 4182 4183 // mie coefficients 4184 vBetaM = totalMie( turbidity ) * mieCoefficient; 4185 4186 }`,fragmentShader:` 4187 varying vec3 vWorldPosition; 4188 varying vec3 vSunDirection; 4189 varying vec3 vBetaR; 4190 varying vec3 vBetaM; 4191 varying float vSunE; 4192 4193 uniform float mieDirectionalG; 4194 uniform vec3 up; 4195 uniform float cloudScale; 4196 uniform float cloudSpeed; 4197 uniform float cloudCoverage; 4198 uniform float cloudDensity; 4199 uniform float cloudElevation; 4200 uniform float showSunDisc; 4201 uniform float time; 4202 4203 // Cloud noise functions 4204 float hash( vec2 p ) { 4205 return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ) * 43758.5453123 ); 4206 } 4207 4208 float noise( vec2 p ) { 4209 vec2 i = floor( p ); 4210 vec2 f = fract( p ); 4211 f = f * f * ( 3.0 - 2.0 * f ); 4212 float a = hash( i ); 4213 float b = hash( i + vec2( 1.0, 0.0 ) ); 4214 float c = hash( i + vec2( 0.0, 1.0 ) ); 4215 float d = hash( i + vec2( 1.0, 1.0 ) ); 4216 return mix( mix( a, b, f.x ), mix( c, d, f.x ), f.y ); 4217 } 4218 4219 float fbm( vec2 p ) { 4220 float value = 0.0; 4221 float amplitude = 0.5; 4222 for ( int i = 0; i < 5; i ++ ) { 4223 value += amplitude * noise( p ); 4224 p *= 2.0; 4225 amplitude *= 0.5; 4226 } 4227 return value; 4228 } 4229 4230 // constants for atmospheric scattering 4231 const float pi = 3.141592653589793238462643383279502884197169; 4232 4233 const float n = 1.0003; // refractive index of air 4234 const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius) 4235 4236 // optical length at zenith for molecules 4237 const float rayleighZenithLength = 8.4E3; 4238 const float mieZenithLength = 1.25E3; 4239 // 66 arc seconds -> degrees, and the cosine of that 4240 const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324; 4241 4242 // 3.0 / ( 16.0 * pi ) 4243 const float THREE_OVER_SIXTEENPI = 0.05968310365946075; 4244 // 1.0 / ( 4.0 * pi ) 4245 const float ONE_OVER_FOURPI = 0.07957747154594767; 4246 4247 float rayleighPhase( float cosTheta ) { 4248 return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) ); 4249 } 4250 4251 float hgPhase( float cosTheta, float g ) { 4252 float g2 = pow( g, 2.0 ); 4253 float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 ); 4254 return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse ); 4255 } 4256 4257 void main() { 4258 4259 vec3 direction = normalize( vWorldPosition - cameraPosition ); 4260 4261 // optical length 4262 // cutoff angle at 90 to avoid singularity in next formula. 4263 float zenithAngle = acos( max( 0.0, dot( up, direction ) ) ); 4264 float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) ); 4265 float sR = rayleighZenithLength * inverse; 4266 float sM = mieZenithLength * inverse; 4267
4268 // combined extinction factor 4269 vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) ); 4270 4271 // in scattering 4272 float cosTheta = dot( direction, vSunDirection ); 4273 4274 float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 ); 4275 vec3 betaRTheta = vBetaR * rPhase; 4276 4277 float mPhase = hgPhase( cosTheta, mieDirectionalG ); 4278 vec3 betaMTheta = vBetaM * mPhase; 4279 4280 vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) ); 4281 Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) ); 4282 4283 // nightsky 4284 float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2] 4285 float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2] 4286 vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 ); 4287 vec3 L0 = vec3( 0.1 ) * Fex; 4288 4289 // composition + solar disc 4290 float sundisc = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta ) * showSunDisc; 4291 L0 += ( vSunE * 19000.0 * Fex ) * sundisc; 4292 4293 vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 ); 4294 4295 // Clouds 4296 if ( direction.y > 0.0 && cloudCoverage > 0.0 ) { 4297 4298 // Project to cloud plane (higher elevation = clouds appear lower/closer) 4299 float elevation = mix( 1.0, 0.1, cloudElevation ); 4300 vec2 cloudUV = direction.xz / ( direction.y * elevation ); 4301 cloudUV *= cloudScale; 4302 cloudUV += time * cloudSpeed; 4303 4304 // Multi-octave noise for fluffy clouds 4305 float cloudNoise = fbm( cloudUV * 1000.0 ); 4306 cloudNoise += 0.5 * fbm( cloudUV * 2000.0 + 3.7 ); 4307 cloudNoise = cloudNoise * 0.5 + 0.5; 4308 4309 // Apply coverage threshold 4310 float cloudMask = smoothstep( 1.0 - cloudCoverage, 1.0 - cloudCoverage + 0.3, cloudNoise ); 4311 4312 // Fade clouds near horizon (adjusted by elevation) 4313 float horizonFade = smoothstep( 0.0, 0.1 + 0.2 * cloudElevation, direction.y ); 4314 cloudMask *= horizonFade; 4315 4316 // Cloud lighting based on sun position 4317 float sunInfluence = dot( direction, vSunDirection ) * 0.5 + 0.5; 4318 float daylight = max( 0.0, vSunDirection.y * 2.0 ); 4319 4320 // Base cloud color affected by atmosphere 4321 vec3 atmosphereColor = Lin * 0.04; 4322 vec3 cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight ); 4323 cloudColor = mix( cloudColor, atmosphereColor + vec3( 1.0 ), sunInfluence * 0.5 ); 4324 cloudColor *= vSunE * 0.00002; 4325 4326 // Blend clouds with sky 4327 texColor = mix( texColor, cloudColor, cloudMask * cloudDensity ); 4328 4329 } 4330 4331 gl_FragColor = vec4( texColor, 1.0 ); 4332 4333 #include <tonemapping_fragment> 4334 #include <colorspace_fragment> 4335 4336 }`};const xs=640,vs=400,Xn=60,Pr=8,Dr=65,Vn=32,Im=4,Um=55,Qo=.16,jo=.6,el=.32,Nm=.11,Fm=.15,kl=4,Om=13,Bm=.0015,zm=420,tl=40,Gm=10,Vm=8,Hm=10,km=340,Lr=6e4,Wm=26,Xm=600,Ms=450,nl=170,Ss=3.4,il=4.2,qm=[{dx:45,dy:18,dz:75,radius:8,speed:.6,count:5},{dx:-55,dy:10,dz:95,radius:6,speed:.8,count:4},{dx:8,dy:26,dz:135,radius:10,speed:.5,count:6}],Wl="kernel_framerate_flyer_best";function qn(i,e){return i+Math.random()*(e-i)}function Ei(i,e,t){return Math.max(e,Math.min(t,i))}function Da(i,e){return 6+8*Math.sin(e*.006)*Math.cos(i*.01)+5*Math.sin(i*.02+e*.003)+3*Math.sin(e*.015)}function Ym(){const i=new bi(km,Lr,Wm,Xm);i.rotateX(-Math.PI/2);const e=i.attributes.position;for(let t=0;t<e.count;t++){const n=e.getX(t),r=e.getZ(t)+Lr/2;e.setY(t,Da(n,r))}return i.computeVertexNormals(),i}function Km(){const i=new Xi(.35,.5,Ss,6),e=new _n({color:7031343,roughness:1}),t=new qi(2.2,il,7),n=new _n({color:3038242,roughness:1}),r=new So(i,e,Ms),s=new So(t,n,Ms);r.castShadow=!0,s.castShadow=!0;const a=new vt;for(let o=0;o<Ms;o++){const c=qn(40,Lr-40),l=qn(-nl,nl),f=Da(l,c),m=qn(.75,1.35),u=Math.random()*Math.PI*2;a.position.set(l,f+Ss/2*m,c),a.rotation.set(0,u,0),a.scale.setScalar(m),a.updateMatrix(),r.setMatrixAt(o,a.matrix
4336),a.position.set(l,f+(Ss+il/2-.5)*m,c),a.updateMatrix(),s.setMatrixAt(o,a.matrix)}return r.instanceMatrix.needsUpdate=!0,s.instanceMatrix.needsUpdate=!0,{trunkMesh:r,foliageMesh:s}}const Tr=new _n({color:3816772,roughness:.9,side:nn});function Zm(){const i=new Wn,e=new nt(new qi(.22,.9,6),Tr);e.rotation.x=Math.PI/2,i.add(e);const t=new bi(1.3,.35),n=new nt(t,Tr);n.position.set(-.6,0,0),i.add(n);const r=new nt(t,Tr);return r.position.set(.6,0,0),i.add(r),{group:i,leftWing:n,rightWing:r}}function $m(i){const e=[];for(const t of qm)for(let n=0;n<t.count;n++){const r=Zm();i.add(r.group),e.push({...r,flock:t,phase:n/t.count*Math.PI*2+Math.random()*.5,radiusJitter:qn(.7,1.3),flapPhase:Math.random()*Math.PI*2})}return e}function rl(i,e,t){for(const n of i){const r=t*n.flock.speed+n.phase,s=n.flock.radius*n.radiusJitter,a=e.x+n.flock.dx,o=e.y+n.flock.dy,c=e.z+n.flock.dz,l=a+Math.cos(r)*s,f=c+Math.sin(r)*s,m=o+Math.sin(r*1.7)*1.5;n.group.position.set(l,m,f);const u=r+.05;n.group.lookAt(a+Math.cos(u)*s,o+Math.sin(u*1.7)*1.5,c+Math.sin(u)*s);const _=Math.sin(t*10+n.flapPhase)*.6;n.leftWing.rotation.z=_,n.rightWing.rotation.z=-_}}function Jm(){const i=new Wn,e=new _n({color:15856628,metalness:.4,roughness:.4}),t=new _n({color:3108272,metalness:.3,roughness:.5}),n=new _n({color:2830136,metalness:.6,roughness:.3}),r=new nt(new Xi(1.1,.6,7,10),e);r.rotation.x=Math.PI/2,r.castShadow=!0,i.add(r);const s=new nt(new qi(1.1,1.6,10),e);s.rotation.x=Math.PI/2,s.position.z=4.3,s.castShadow=!0,i.add(s);const a=new nt(new sn(11,.18,1.6),t);a.position.set(0,-.1,.3),a.castShadow=!0,i.add(a);const o=new nt(new sn(4,.14,.9),t);o.position.set(0,.2,-3.1),o.castShadow=!0,i.add(o);const c=new nt(new sn(.14,1.4,1.1),t);c.position.set(0,.9,-3.2),c.castShadow=!0,i.add(c);const l=new nt(new sn(.12,2.3,.25),n);return l.position.set(0,0,5.1),l.castShadow=!0,i.add(l),{group:i,propeller:l}}function Qm(){return new nt(new Ca(9,1.1,10,24),new _n({color:13214720,emissive:3812864,metalness:.5,roughness:.3}))}function jm(){return new nt(new Ra(6,0),new _n({color:13191214,metalness:.2,roughness:.7,flatShading:!0}))}function sl(){return{x:0,y:Vn,z:0,targetX:0,targetY:Vn,roll:0,pitch:0,propAngle:0,speed:kl,spawnTimer:400,nextId:1,rings:[],hazards:[],bonus:0,rawScore:0,gameOver:!1,overReason:null}}function eg(i){const e=i.z+zm,t=qn(-Xn*.8,Xn*.8),n=qn(Pr+4,Dr-2),r=i.nextId++;Math.random()<.32?i.hazards.push({id:r,x:t,y:n,z:e,checked:!1}):i.rings.push({id:r,x:t,y:n,z:e,checked:!1,collected:!1})}function tg(i,e,t){const n=Um*t*.016667;e.has("left")&&(i.targetX-=n),e.has("right")&&(i.targetX+=n),e.has("up")&&(i.targetY+=n),e.has("down")&&(i.targetY-=n),i.targetX=Ei(i.targetX,-Xn,Xn),i.targetY=Ei(i.targetY,Pr,Dr)}function ng(i,e){const t=i.x,n=i.y;i.x+=(i.targetX-i.x)*Math.min(1,Qo*e),i.y+=(i.targetY-i.y)*Math.min(1,Qo*e);const r=e>0?(i.x-t)/e:0,s=e>0?(i.y-n)/e:0;i.roll=Ei(-r*Nm,-jo,jo),i.pitch=Ei(s*Fm,-el,el),i.propAngle+=e*1.4,i.z+=i.speed*e,i.speed=Math.min(Om,kl+i.z*Bm);const a=Da(i.x,i.z)+Im;if(i.y<a){i.gameOver=!0,i.overReason="terrain";return}i.spawnTimer-=e*16.6667,i.spawnTimer<=0&&(eg(i),i.spawnTimer=qn(650,1050)-Math.min(350,i.z*.02));const o=[];for(const l of i.rings){if(!l.checked&&i.z>=l.z){l.checked=!0;const f=i.x-l.x,m=i.y-l.y;Math.sqrt(f*f+m*m)<Gm&&(l.collected=!0,i.bonus+=Hm)}i.z-l.z<tl&&o.push(l)}i.rings=o;const c=[];for(const l of i.hazards){if(!l.checked&&i.z>=l.z){l.checked=!0;const f=i.x-l.x,m=i.y-l.y;if(Math.sqrt(f*f+m*m)<Vm){i.gameOver=!0,i.overReason="hazard";return}}i.z-l.z<tl&&c.push(l)}i.hazards=c,i.rawScore=Math.floor(i.z/12)+i.bonus}function ig(i,e){const t=new Set;for(const r of e.rings){t.add(r.id);let s=i.ringMeshes.get(r.id);s||(s=Qm(),i.dynamicGroup.add(s),i.ringMeshes.set(r.id,s)),s.position.set(r.x,r.y,r.z),s.visible=!r.collected}for(const[r,s]of i.ringMeshes)t.has(r)||(i.dynamicGroup.remove(s),s.geometry.dispose(),s.material.dispose(),i.ringMeshes.delete(r));const n=new Set;for(const r of e.hazards){n.add(r.id);let s=i.hazardMeshes.get(r.id);s||(s=jm(),i.dynamicGroup.add(s),i.hazardMeshes.set(r.id,s)),s.position.set(r.x,r.y,r.z)}for(const[r,s]of i.hazardMeshes)n.has(r)||(i.dynamicGroup.remove(s),s.geometry.dispose(),s.material.dispose(),i.hazardMeshes.delete(r))}function rg(i){for(const e of i.ringMeshes.values())i.dynamicGroup.remove(e),e.geometry.dispose(),e.material.dispose();for(const e of i.hazardMeshes.values())i.dynamicGroup.remove(e),e.geometry.dispose(),e.material.dispose();i.ringMeshes.clear(),i.hazardMeshes.clear()}function sg(){try{const i=localStorage.getItem(Wl);return i?Number(JSON.parse(i)):null}catch{return null}}const al={ArrowLeft:"left",KeyA:"left",ArrowRight:"right",KeyD:"right",ArrowUp:"up",KeyW:"up",ArrowDown:"down",KeyS:"down"};function og(){Ql({title:"Framerate Flyer â Kernel Tools",description:"A real-time 3D flight game built with Three.js â bank through gold rings, dodge red hazards, and stay above the terrain. Just for fun.",noindex:!0,structuredData:{"@context":"https://schema.org","@type":"VideoGame",name:"Framerate Flyer",url:"https://kerneltools.dev/framerate-flyer",description:"A real-time 3D flight game rendered with Three.js/WebGL â pitch and bank through gold rings, dodge red hazards, and stay above the procedurally generated terrain for as long as you can.",genre:"Simulation",gamePlatform:"Web Browser",applicationCategory:"Game",operatingSystem:"Any",offers:{"@type":"Offer",price:"0",priceCurrency:"USD"},author:{"@type":"Organization",name:"Kernel DevTools",url:"https://kerneltools.dev"}}});const i=Tt.useRef(null),e=Tt.useRef(null),t=Tt.useRef(sl()),n=Tt.useRef(null),r=Tt.useRef(null),s=Tt.useRef(0),a=Tt.useRef(0),o=Tt.useRef(new Set),c=Tt.useRef(!1),[l,f]=Tt.useState("ready"),[m,u]=Tt.useState(0),[_,v]=Tt.useState(()=>sg()),[y,g]=Tt.useState(!1);Tt.useEffect(()=>{const S=i.current,C=new Lm({canvas:S,antialias:!0});C.setSize(xs,vs,!1),C.setPixelRatio(Math.min(1.5,window.devicePixelRatio||1)),C.shadowMap.enabled=!0,C.toneMapping=da,C.toneMappingExposure=.6;const p=new fu,E=new Gt(62,xs/vs,.5,4e3),w=new Or;w.scale.setScalar(9e3),p.add(w);const P=new N,I=no.degToRad(52),X=no.degToRad(160);P.setFromSphericalCoords(1,I,X),w.material.uniforms.sunPosition.value.copy(P),w.material.uniforms.turbidity.value=3.5,w.material.uniforms.rayleigh.value=1.8,w.material.uniforms.mieCoefficient.value=.006,w.material.uniforms.mieDirectionalG.value=.8;const H=new Iu(16777215,2.2);H.position.copy(P).multiplyScalar(500),H.castShadow=!0,H.shadow.mapSize.set(1024,1024),H.shadow.camera.left=-120,H.shadow.camera.right=120,H.shadow.camera.top=120,H.shadow.camera.bottom=-120,H.shadow.camera.near=10,H.shadow.camera.far=1200,p.add(H),p.add(H.target),p.add(new Pu(12572927,3955242,.7)),p.fog=new ba(12376558,260,1500);const O=new nt(Ym(),new _n({color:5012536,roughness:1,metalness:0}));O.position.z=Lr/2,O.receiveShadow=!0,p.add(O);const{trunkMesh:W,foliageMesh:k}=Km();p.add(W),p.add(k);const J=$m(p),{group:j,propeller:le}=Jm();p.add(j);const he=new Wn;return p.add(he),n.current={renderer:C,scene:p,camera:E,planeGroup:j,propeller:le,dynamicGroup:he,sun:H,sunDir:P.clone(),birds:J,birdTime:0,ringMeshes:new Map,hazardMeshes:new Map},j.position.set(0,Vn,0),E.position.set(0,Vn+6,-22),E.lookAt(0,Vn-8,22),rl(J,{x:0,y:Vn,z:0},0),C.render(p,E),()=>{C.dispose(),O.geometry.dispose(),O.material.dispose(),W.geometry.dispose(),W.material.dispose(),k.geometry.dispose(),k.material.dispose(),Tr.dispose();for(const _e of J)_e.group.traverse(Ve=>{Ve.geometry&&Ve.geometry.dispose()})}},[]);function h(){const S=n.current;S&&rg(S),t.current=sl(),s.current=performance.now(),a.current=0,u(0),g(!1),f("playing")}function b(S,C){const p=i.current;
4336if(!p)return;const E=p.getBoundingClientRect(),w=(S-E.left)/E.width-.5,P=(C-E.top)/E.height-.5,I=t.current;I.targetX=Ei(w*2*Xn,-Xn,Xn),I.targetY=Ei(Vn-P*(Dr-Pr),Pr,Dr)}function R(S){if(l!=="playing"){h();return}c.current=!0,b(S.clientX,S.clientY)}function M(S){c.current&&b(S.clientX,S.clientY)}function A(){c.current=!1}return Tt.useEffect(()=>{function S(p){const E=al[p.code];E?(p.preventDefault(),o.current.add(E)):p.code==="Space"&&l!=="playing"&&(p.preventDefault(),h())}function C(p){const E=al[p.code];E&&o.current.delete(E)}return window.addEventListener("keydown",S),window.addEventListener("keyup",C),()=>{window.removeEventListener("keydown",S),window.removeEventListener("keyup",C)}}),Tt.useEffect(()=>{if(l!=="playing")return;const S=n.current;s.current=performance.now();function C(p){const E=Math.min((p-s.current)/16.6667,3);s.current=p;const w=t.current;if(tg(w,o.current,E),ng(w,E),S.planeGroup.position.set(w.x,w.y,w.z),S.planeGroup.rotation.z=w.roll,S.planeGroup.rotation.x=w.pitch,S.propeller.rotation.z=w.propAngle,S.camera.position.z=w.z-22,S.camera.position.x+=(w.x*.4-S.camera.position.x)*.14,S.camera.position.y+=(w.y+6-S.camera.position.y)*.14,S.camera.lookAt(w.x,w.y-8,w.z+22),S.sun.target.position.set(w.x,w.y,w.z),S.sun.position.set(w.x,w.y,w.z).addScaledVector(S.sunDir,500),S.birdTime+=E*.016667,rl(S.birds,w,S.birdTime),ig(S,w),S.renderer.render(S.scene,S.camera),w.rawScore!==a.current&&(a.current=w.rawScore,u(w.rawScore)),w.gameOver){f("over"),v(P=>{if(P===null||w.rawScore>P){g(!0);try{localStorage.setItem(Wl,JSON.stringify(w.rawScore))}catch{}return w.rawScore}return P});return}r.current=requestAnimationFrame(C)}return r.current=requestAnimationFrame(C),()=>cancelAnimationFrame(r.current)},[l]),Pe.jsxs(Pe.Fragment,{children:[Pe.jsx("div",{className:"page-hero",children:Pe.jsxs("div",{className:"page-hero-inner",children:[Pe.jsx("div",{className:"section-eyebrow",children:"Just for fun"}),Pe.jsx("h1",{children:"Framerate Flyer"}),Pe.jsx("p",{children:"A real-time 3D flight scene built with Three.js â bank through gold rings, dodge red hazards, stay above the terrain."})]})}),Pe.jsxs("div",{className:"prose",style:{maxWidth:680},children:[Pe.jsxs("div",{className:"match-hud",children:[Pe.jsxs("span",{className:"stat",children:[Pe.jsx("span",{className:"stat-l",children:"score"}),Pe.jsx("span",{className:"stat-n",children:m})]}),Pe.jsxs("span",{className:"stat",children:[Pe.jsx("span",{className:"stat-l",children:"best"}),Pe.jsx("span",{className:"stat-n",children:_!==null?_:"â"})]}
4336),Pe.jsx(jl,{targetRef:e})]}),Pe.jsxs("div",{className:"dash-wrap",ref:e,children:[Pe.jsx("canvas",{ref:i,width:xs,height:vs,className:"dash-canvas",onPointerDown:R,onPointerMove:M,onPointerUp:A,onPointerLeave:A}),l!=="playing"&&Pe.jsx("div",{className:"dash-overlay",children:l==="ready"?Pe.jsxs(Pe.Fragment,{children:[Pe.jsx("div",{className:"section-eyebrow",style:{justifyContent:"center"},children:"Ready"}),Pe.jsx("p",{children:"Arrow keys/WASD, or drag, to climb/dive and bank. Fly through gold rings, dodge red hazards, stay above the hills."}),Pe.jsx("button",{type:"button",className:"btn btn-primary",onClick:h,children:"Start"})]}):Pe.jsxs(Pe.Fragment,{children:[Pe.jsx("div",{className:"section-eyebrow",style:{justifyContent:"center"},children:t.current.overReason==="terrain"?"Terrain! Pull Up!":"Collision!"}),Pe.jsxs("p",{children:[m," points",y?" â new best!":"."]}),Pe.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"center",flexWrap:"wrap"},children:[Pe.jsx("button",{type:"button",className:"btn btn-primary",onClick:h,children:"Try again"}),Pe.jsx(ec,{to:"/8-ball-pool",className:"btn btn-ghost",children:"Try Eight Ball Pool â"})]})]})})]})]}),Pe.jsxs("div",{className:"prose",style:{maxWidth:680},children:[Pe.jsx("h2",{children:"How to play"}),Pe.jsxs("div",{className:"props-panel",children:[Pe.jsxs("div",{className:"props-row",children:[Pe.jsx("span",{className:"props-key",children:"Controls"}),Pe.jsx("span",{className:"props-val",children:"Arrow keys or WASD to pitch and bank the plane."})]}),Pe.jsxs("div",{className:"props-row",children:[Pe.jsx("span",{className:"props-key",children:"Objective"}),Pe.jsx("span",{className:"props-val",children:"Fly through gold rings for score, dodge red hazards, and stay above the terrain â clipping the ground ends the run."})]}),Pe.jsxs("div",{className:"props-row",children:[Pe.jsx("span",{className:"props-key",children:"Under the hood"}),Pe.jsx("span",{className:"props-val",children:"A real 3D scene rendered with Three.js/WebGL â the one game on this site that isn't hand-drawn Canvas 2D."})]})]})]})]})}export{og as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.