stack3js 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +141 -2
- package/THIRD-PARTY-LICENSES.md +100 -0
- package/bin/stack3.mjs +4237 -0
- package/examples/future-tank.stack3.json +1 -0
- package/examples/traffic-cone-4view.png +0 -0
- package/package.json +25 -4
- package/viewer/dist/THIRD-PARTY-LICENSES.md +174 -0
- package/viewer/dist/assets/GLTFExporter--hziUXc8.js +1 -0
- package/viewer/dist/assets/ant-mech-angled-leg-4view-BO2qt1_k.png +0 -0
- package/viewer/dist/assets/ant-mech-body-4view-D9xVPpbc.png +0 -0
- package/viewer/dist/assets/ant-mech-center-leg-4view-BcphjF_G.png +0 -0
- package/viewer/dist/assets/compare-B6DWTZS9.css +1 -0
- package/viewer/dist/assets/compare-DJ8rV3Rn.js +6 -0
- package/viewer/dist/assets/compare.worker-DK2lJl0n.js +21 -0
- package/viewer/dist/assets/concrete-barrier-4view-7PsO3Ftq.png +0 -0
- package/viewer/dist/assets/emscripten-module-uFzwHH0Y.wasm +0 -0
- package/viewer/dist/assets/emscripten-module.browser-BcR5qphc.js +1 -0
- package/viewer/dist/assets/ffi-Boa1QuFa.js +1 -0
- package/viewer/dist/assets/fillet-rover-body-4-view-Chk8Mx4R.png +0 -0
- package/viewer/dist/assets/fillet-rover-wheel-4-view-B-F8flOC.png +0 -0
- package/viewer/dist/assets/hull-4view-BPPqJYUz.png +0 -0
- package/viewer/dist/assets/hull-base-color-4view-DrQmdT3h.png +0 -0
- package/viewer/dist/assets/hull-clay-4view-3Cu-4Hvr.png +0 -0
- package/viewer/dist/assets/hull-depth-4view-DCOdT5ev.png +0 -0
- package/viewer/dist/assets/hull-normal-4view-CvLaFITy.png +0 -0
- package/viewer/dist/assets/inspection-robot-body-4-view-CLMaHFYm.png +0 -0
- package/viewer/dist/assets/inspection-robot-wheel-4-view-27wRsxcs.png +0 -0
- package/viewer/dist/assets/plastic-barrier-4view-DQkTBW_i.png +0 -0
- package/viewer/dist/assets/presets-DwdZVYhs.js +1 -0
- package/viewer/dist/assets/preview-cache-DRF_H5pq.js +58 -0
- package/viewer/dist/assets/project-BzR9Ensg.css +1 -0
- package/viewer/dist/assets/project-D8tR6U-_.js +17 -0
- package/viewer/dist/assets/reconstruct.worker-Cf8iZwT3.js +21 -0
- package/viewer/dist/assets/script-engine-CLj7QMLe.js +6 -0
- package/viewer/dist/assets/style-CMUT8CmM.css +1 -0
- package/viewer/dist/assets/style-CWGgpweN.js +3947 -0
- package/viewer/dist/assets/tank-hull-4view-B4sMMkP5.png +0 -0
- package/viewer/dist/assets/tank-track-4view-DAIiMTy3.png +0 -0
- package/viewer/dist/assets/tank-turret-4view-Cx0FuNFu.png +0 -0
- package/viewer/dist/assets/traffic-cone-4view-DG-TkITx.png +0 -0
- package/viewer/dist/assets/viewer-CyGodHLY.js +2 -0
- package/viewer/dist/assets/wet-floor-sign-4view-CWJDyeTX.png +0 -0
- package/viewer/dist/compare.html +47 -0
- package/viewer/dist/examples/traffic-cone-4view.png +0 -0
- package/viewer/dist/index.html +147 -0
- package/viewer/dist/playground/index.html +3342 -0
- package/viewer/dist/project.html +83 -0
|
@@ -0,0 +1,3947 @@
|
|
|
1
|
+
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();const xa="181",Jm={ROTATE:0,DOLLY:1,PAN:2},Qm={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Yc=0,ka=1,Kc=2,sc=1,$c=2,un=3,wn=0,Ct=1,en=2,pn=0,li=1,Ga=2,Ha=3,Wa=4,Zc=5,zn=100,jc=101,Jc=102,Qc=103,el=104,tl=200,nl=201,il=202,rl=203,Es=204,Ts=205,sl=206,al=207,ol=208,cl=209,ll=210,hl=211,ul=212,dl=213,fl=214,As=0,ws=1,Rs=2,ui=3,Cs=4,Ps=5,Ds=6,Ls=7,ga=0,pl=1,ml=2,An=0,xl=1,gl=2,_l=3,vl=4,Ml=5,bl=6,Sl=7,Xa="attached",yl="detached",ac=300,di=301,fi=302,Is=303,Us=304,Ir=306,Ns=1e3,dn=1001,Fs=1002,Pt=1003,El=1004,Yi=1005,At=1006,Hr=1007,kn=1008,nn=1009,oc=1010,cc=1011,Fi=1012,_a=1013,Gn=1014,Yt=1015,gi=1016,va=1017,Ma=1018,Oi=1020,lc=35902,hc=35899,uc=1021,dc=1022,zt=1023,Bi=1026,zi=1027,ba=1028,Sa=1029,ya=1030,Ea=1031,Ta=1033,Mr=33776,br=33777,Sr=33778,yr=33779,Os=35840,Bs=35841,zs=35842,Vs=35843,ks=36196,Gs=37492,Hs=37496,Ws=37808,Xs=37809,qs=37810,Ys=37811,Ks=37812,$s=37813,Zs=37814,js=37815,Js=37816,Qs=37817,ea=37818,ta=37819,na=37820,ia=37821,ra=36492,sa=36494,aa=36495,oa=36283,ca=36284,la=36285,ha=36286,Tr=2300,ua=2301,Wr=2302,qa=2400,Ya=2401,Ka=2402,Tl=2500,e0=0,t0=1,n0=2,Al=3200,wl=3201,Aa=0,Rl=1,En="",Nt="srgb",pi="srgb-linear",Ar="linear",Qe="srgb",Yn=7680,$a=519,Cl=512,Pl=513,Dl=514,fc=515,Ll=516,Il=517,Ul=518,Nl=519,da=35044,Za="300 es",tn=2e3,wr=2001;function pc(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Vi(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Fl(){const i=Vi("canvas");return i.style.display="block",i}const ja={};function Rr(...i){const e="THREE."+i.shift();console.log(e,...i)}function _e(...i){const e="THREE."+i.shift();console.warn(e,...i)}function Be(...i){const e="THREE."+i.shift();console.error(e,...i)}function ki(...i){const e=i.join(" ");e in ja||(ja[e]=!0,_e(...i))}function Ol(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)})}class Xn{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 vt=["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 Ja=1234567;const Ui=Math.PI/180,mi=180/Math.PI;function Kt(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(vt[i&255]+vt[i>>8&255]+vt[i>>16&255]+vt[i>>24&255]+"-"+vt[e&255]+vt[e>>8&255]+"-"+vt[e>>16&15|64]+vt[e>>24&255]+"-"+vt[t&63|128]+vt[t>>8&255]+"-"+vt[t>>16&255]+vt[t>>24&255]+vt[n&255]+vt[n>>8&255]+vt[n>>16&255]+vt[n>>24&255]).toLowerCase()}function Fe(i,e,t){return Math.max(e,Math.min(t,i))}function wa(i,e){return(i%e+e)%e}function Bl(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function zl(i,e,t){return i!==e?(t-i)/(e-i):0}function Ni(i,e,t){return(1-t)*i+t*e}function Vl(i,e,t,n){return Ni(i,e,1-Math.exp(-t*n))}function kl(i,e=1){return e-Math.abs(wa(i,e*2)-e)}function Gl(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Hl(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Wl(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Xl(i,e){return i+Math.random()*(e-i)}function ql(i){return i*(.5-Math.random())}function Yl(i){i!==void 0&&(Ja=i);let e=Ja+=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 Kl(i){return i*Ui}function $l(i){return i*mi}function Zl(i){return(i&i-1)===0&&i!==0}function jl(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Jl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ql(i,e,t,n,r){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+n)/2),h=a((e+n)/2),u=s((e-n)/2),d=a((e-n)/2),p=s((n-e)/2),x=a((n-e)/2);switch(r){case"XYX":i.set(o*h,l*u,l*d,o*c);break;case"YZY":i.set(l*d,o*h,l*u,o*c);break;case"ZXZ":i.set(l*u,l*d,o*h,o*c);break;case"XZX":i.set(o*h,l*x,l*p,o*c);break;case"YXY":i.set(l*p,o*h,l*x,o*c);break;case"ZYZ":i.set(l*x,l*p,o*h,o*c);break;default:_e("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Xt(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("Invalid component type.")}}function $e(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("Invalid component type.")}}const i0={DEG2RAD:Ui,RAD2DEG:mi,generateUUID:Kt,clamp:Fe,euclideanModulo:wa,mapLinear:Bl,inverseLerp:zl,lerp:Ni,damp:Vl,pingpong:kl,smoothstep:Gl,smootherstep:Hl,randInt:Wl,randFloat:Xl,randFloatSpread:ql,seededRandom:Yl,degToRad:Kl,radToDeg:$l,isPowerOfTwo:Zl,ceilPowerOfTwo:jl,floorPowerOfTwo:Jl,setQuaternionFromProperEuler:Ql,normalize:$e,denormalize:Xt};class Xe{constructor(e=0,t=0){Xe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){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=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Fe(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}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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(Fe(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}}class _i{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 l=n[r+0],c=n[r+1],h=n[r+2],u=n[r+3],d=s[a+0],p=s[a+1],x=s[a+2],_=s[a+3];if(o<=0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(o>=1){e[t+0]=d,e[t+1]=p,e[t+2]=x,e[t+3]=_;return}if(u!==_||l!==d||c!==p||h!==x){let m=l*d+c*p+h*x+u*_;m<0&&(d=-d,p=-p,x=-x,_=-_,m=-m);let f=1-o;if(m<.9995){const T=Math.acos(m),y=Math.sin(T);f=Math.sin(f*T)/y,o=Math.sin(o*T)/y,l=l*f+d*o,c=c*f+p*o,h=h*f+x*o,u=u*f+_*o}else{l=l*f+d*o,c=c*f+p*o,h=h*f+x*o,u=u*f+_*o;const T=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=T,c*=T,h*=T,u*=T}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],u=s[a],d=s[a+1],p=s[a+2],x=s[a+3];return e[t]=o*x+h*u+l*p-c*d,e[t+1]=l*x+h*d+c*u-o*p,e[t+2]=c*x+h*p+o*d-l*u,e[t+3]=h*x-o*u-l*d-c*p,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,l=Math.sin,c=o(n/2),h=o(r/2),u=o(s/2),d=l(n/2),p=l(r/2),x=l(s/2);switch(a){case"XYZ":this._x=d*h*u+c*p*x,this._y=c*p*u-d*h*x,this._z=c*h*x+d*p*u,this._w=c*h*u-d*p*x;break;case"YXZ":this._x=d*h*u+c*p*x,this._y=c*p*u-d*h*x,this._z=c*h*x-d*p*u,this._w=c*h*u+d*p*x;break;case"ZXY":this._x=d*h*u-c*p*x,this._y=c*p*u+d*h*x,this._z=c*h*x+d*p*u,this._w=c*h*u-d*p*x;break;case"ZYX":this._x=d*h*u-c*p*x,this._y=c*p*u+d*h*x,this._z=c*h*x-d*p*u,this._w=c*h*u+d*p*x;break;case"YZX":this._x=d*h*u+c*p*x,this._y=c*p*u+d*h*x,this._z=c*h*x-d*p*u,this._w=c*h*u-d*p*x;break;case"XZY":this._x=d*h*u-c*p*x,this._y=c*p*u-d*h*x,this._z=c*h*x+d*p*u,this._w=c*h*u+d*p*x;break;default:_e("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],l=t[9],c=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(n>o&&n>u){const p=2*Math.sqrt(1+n-o-u);this._w=(h-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>u){const p=2*Math.sqrt(1+o-n-u);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+u-n-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+h)/p,this._z=.25*p}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(Fe(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,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);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 l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+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}}class U{constructor(e=0,t=0,n=0){U.prototype.isVector3=!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("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){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(Qa.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Qa.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,l=e.w,c=2*(a*r-o*n),h=2*(o*t-s*r),u=2*(s*n-a*t);return this.x=t+l*c+a*u-o*h,this.y=n+l*h+o*c-s*u,this.z=r+l*u+s*h-a*c,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=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this.z=Fe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this.z=Fe(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Fe(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,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,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 Xr.copy(this).projectOnVector(e),this.sub(Xr)}reflect(e){return this.sub(Xr.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(Fe(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}}const Xr=new U,Qa=new _i;class Ie{constructor(e,t,n,r,s,a,o,l,c){Ie.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,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],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],p=n[5],x=n[8],_=r[0],m=r[3],f=r[6],T=r[1],y=r[4],w=r[7],C=r[2],E=r[5],P=r[8];return s[0]=a*_+o*T+l*C,s[3]=a*m+o*y+l*E,s[6]=a*f+o*w+l*P,s[1]=c*_+h*T+u*C,s[4]=c*m+h*y+u*E,s[7]=c*f+h*w+u*P,s[2]=d*_+p*T+x*C,s[5]=d*m+p*y+x*E,s[8]=d*f+p*w+x*P,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],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*s,p=c*s-a*l,x=t*u+n*d+r*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/x;return e[0]=u*_,e[1]=(r*c-h*n)*_,e[2]=(o*n-r*a)*_,e[3]=d*_,e[4]=(h*t-r*l)*_,e[5]=(r*s-o*t)*_,e[6]=p*_,e[7]=(n*l-c*t)*_,e[8]=(a*t-n*s)*_,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 l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(qr.makeScale(e,t)),this}rotate(e){return this.premultiply(qr.makeRotation(-e)),this}translate(e,t){return this.premultiply(qr.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)}}const qr=new Ie,eo=new Ie().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),to=new Ie().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function eh(){const i={enabled:!0,workingColorSpace:pi,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Qe&&(r.r=mn(r.r),r.g=mn(r.g),r.b=mn(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===Qe&&(r.r=hi(r.r),r.g=hi(r.g),r.b=hi(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===En?Ar: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 ki("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return ki("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({[pi]:{primaries:e,whitePoint:n,transfer:Ar,toXYZ:eo,fromXYZ:to,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Nt},outputColorSpaceConfig:{drawingBufferColorSpace:Nt}},[Nt]:{primaries:e,whitePoint:n,transfer:Qe,toXYZ:eo,fromXYZ:to,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Nt}}}),i}const Ye=eh();function mn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function hi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Kn;class th{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{Kn===void 0&&(Kn=Vi("canvas")),Kn.width=e.width,Kn.height=e.height;const r=Kn.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Kn}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=Vi("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]=mn(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(mn(t[n]/255)*255):t[n]=mn(t[n]);return{data:t,width:e.width,height:e.height}}else return _e("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let nh=0;class Ra{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:nh++}),this.uuid=Kt(),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):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,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(Yr(r[a].image)):s.push(Yr(r[a]))}else s=Yr(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function Yr(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?th.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(_e("Texture: Unable to serialize Texture."),{})}let ih=0;const Kr=new U;class gt extends Xn{constructor(e=gt.DEFAULT_IMAGE,t=gt.DEFAULT_MAPPING,n=dn,r=dn,s=At,a=kn,o=zt,l=nn,c=gt.DEFAULT_ANISOTROPY,h=En){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ih++}),this.uuid=Kt(),this.name="",this.source=new Ra(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Xe(0,0),this.repeat=new Xe(1,1),this.center=new Xe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ie,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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}get width(){return this.source.getSize(Kr).x}get height(){return this.source.getSize(Kr).y}get depth(){return this.source.getSize(Kr).z}get image(){return this.source.data}set image(e=null){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.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){_e(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){_e(`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,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!==ac)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ns:e.x=e.x-Math.floor(e.x);break;case dn:e.x=e.x<0?0:1;break;case Fs: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 Ns:e.y=e.y-Math.floor(e.y);break;case dn:e.y=e.y<0?0:1;break;case Fs: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++}}gt.DEFAULT_IMAGE=null;gt.DEFAULT_MAPPING=ac;gt.DEFAULT_ANISOTROPY=1;class Ke{constructor(e=0,t=0,n=0,r=1){Ke.prototype.isVector4=!0,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("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=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 l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],p=l[5],x=l[9],_=l[2],m=l[6],f=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(x-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(x+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const y=(c+1)/2,w=(p+1)/2,C=(f+1)/2,E=(h+d)/4,P=(u+_)/4,z=(x+m)/4;return y>w&&y>C?y<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(y),r=E/n,s=P/n):w>C?w<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(w),n=E/r,s=z/r):C<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(C),n=P/s,r=z/s),this.set(n,r,s,t),this}let T=Math.sqrt((m-x)*(m-x)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(T)<.001&&(T=1),this.x=(m-x)/T,this.y=(u-_)/T,this.z=(d-h)/T,this.w=Math.acos((c+p+f-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=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this.z=Fe(this.z,e.z,t.z),this.w=Fe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this.z=Fe(this.z,e,t),this.w=Fe(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Fe(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}}class rh extends Xn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:At,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Ke(0,0,e,t),this.scissorTest=!1,this.viewport=new Ke(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new gt(r);this.textures=[];const 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}_setTextureOptions(e={}){const t={minFilter:At,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 Ra(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}dispose(){this.dispatchEvent({type:"dispose"})}}class Hn extends rh{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class mc extends gt{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=Pt,this.minFilter=Pt,this.wrapR=dn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class sh extends gt{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=Pt,this.minFilter=Pt,this.wrapR=dn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Rn{constructor(e=new U(1/0,1/0,1/0),t=new U(-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(Gt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Gt.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=Gt.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,Gt):Gt.fromBufferAttribute(s,a),Gt.applyMatrix4(e.matrixWorld),this.expandByPoint(Gt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ki.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Ki.copy(n.boundingBox)),Ki.applyMatrix4(e.matrixWorld),this.union(Ki)}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,Gt),Gt.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(yi),$i.subVectors(this.max,yi),$n.subVectors(e.a,yi),Zn.subVectors(e.b,yi),jn.subVectors(e.c,yi),_n.subVectors(Zn,$n),vn.subVectors(jn,Zn),Ln.subVectors($n,jn);let t=[0,-_n.z,_n.y,0,-vn.z,vn.y,0,-Ln.z,Ln.y,_n.z,0,-_n.x,vn.z,0,-vn.x,Ln.z,0,-Ln.x,-_n.y,_n.x,0,-vn.y,vn.x,0,-Ln.y,Ln.x,0];return!$r(t,$n,Zn,jn,$i)||(t=[1,0,0,0,1,0,0,0,1],!$r(t,$n,Zn,jn,$i))?!1:(Zi.crossVectors(_n,vn),t=[Zi.x,Zi.y,Zi.z],$r(t,$n,Zn,jn,$i))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Gt).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:(rn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),rn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),rn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),rn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),rn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),rn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),rn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),rn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(rn),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 rn=[new U,new U,new U,new U,new U,new U,new U,new U],Gt=new U,Ki=new Rn,$n=new U,Zn=new U,jn=new U,_n=new U,vn=new U,Ln=new U,yi=new U,$i=new U,Zi=new U,In=new U;function $r(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){In.fromArray(i,s);const o=r.x*Math.abs(In.x)+r.y*Math.abs(In.y)+r.z*Math.abs(In.z),l=e.dot(In),c=t.dot(In),h=n.dot(In);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const ah=new Rn,Ei=new U,Zr=new U;class gn{constructor(e=new U,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):ah.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)}applyMatrix4(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;Ei.subVectors(e,this.center);const t=Ei.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Ei,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):(Zr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ei.copy(e.center).add(Zr)),this.expandByPoint(Ei.copy(e.center).sub(Zr))),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}}const sn=new U,jr=new U,ji=new U,Mn=new U,Jr=new U,Ji=new U,Qr=new U;class Ur{constructor(e=new U,t=new U(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,sn)),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=sn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(sn.copy(this.origin).addScaledVector(this.direction,t),sn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){jr.copy(e).add(t).multiplyScalar(.5),ji.copy(t).sub(e).normalize(),Mn.copy(this.origin).sub(jr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(ji),o=Mn.dot(this.direction),l=-Mn.dot(ji),c=Mn.lengthSq(),h=Math.abs(1-a*a);let u,d,p,x;if(h>0)if(u=a*l-o,d=a*o-l,x=s*h,u>=0)if(d>=-x)if(d<=x){const _=1/h;u*=_,d*=_,p=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d<=-x?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-l),s),p=-u*u+d*(d+2*l)+c):d<=x?(u=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-l),s),p=-u*u+d*(d+2*l)+c);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(jr).addScaledVector(ji,d),p}intersectSphere(e,t){sn.subVectors(e.center,this.origin);const n=sn.dot(this.direction),r=sn.dot(sn)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,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,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,sn)!==null}intersectTriangle(e,t,n,r,s){Jr.subVectors(t,e),Ji.subVectors(n,e),Qr.crossVectors(Jr,Ji);let a=this.direction.dot(Qr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Mn.subVectors(this.origin,e);const l=o*this.direction.dot(Ji.crossVectors(Mn,Ji));if(l<0)return null;const c=o*this.direction.dot(Jr.cross(Mn));if(c<0||l+c>a)return null;const h=-o*Mn.dot(Qr);return h<0?null:this.at(h/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 He{constructor(e,t,n,r,s,a,o,l,c,h,u,d,p,x,_,m){He.prototype.isMatrix4=!0,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,l,c,h,u,d,p,x,_,m)}set(e,t,n,r,s,a,o,l,c,h,u,d,p,x,_,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=r,f[1]=s,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=u,f[14]=d,f[3]=p,f[7]=x,f[11]=_,f[15]=m,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 He().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 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){const t=this.elements,n=e.elements,r=1/Jn.setFromMatrixColumn(e,0).length(),s=1/Jn.setFromMatrixColumn(e,1).length(),a=1/Jn.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),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){const d=a*h,p=a*u,x=o*h,_=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=p+x*c,t[5]=d-_*c,t[9]=-o*l,t[2]=_-d*c,t[6]=x+p*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,p=l*u,x=c*h,_=c*u;t[0]=d+_*o,t[4]=x*o-p,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=p*o-x,t[6]=_+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,p=l*u,x=c*h,_=c*u;t[0]=d-_*o,t[4]=-a*u,t[8]=x+p*o,t[1]=p+x*o,t[5]=a*h,t[9]=_-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,p=a*u,x=o*h,_=o*u;t[0]=l*h,t[4]=x*c-p,t[8]=d*c+_,t[1]=l*u,t[5]=_*c+d,t[9]=p*c-x,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,p=a*c,x=o*l,_=o*c;t[0]=l*h,t[4]=_-d*u,t[8]=x*u+p,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=p*u+x,t[10]=d-_*u}else if(e.order==="XZY"){const d=a*l,p=a*c,x=o*l,_=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+_,t[5]=a*h,t[9]=p*u-x,t[2]=x*u-p,t[6]=o*h,t[10]=_*u+d}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(oh,e,ch)}lookAt(e,t,n){const r=this.elements;return It.subVectors(e,t),It.lengthSq()===0&&(It.z=1),It.normalize(),bn.crossVectors(n,It),bn.lengthSq()===0&&(Math.abs(n.z)===1?It.x+=1e-4:It.z+=1e-4,It.normalize(),bn.crossVectors(n,It)),bn.normalize(),Qi.crossVectors(It,bn),r[0]=bn.x,r[4]=Qi.x,r[8]=It.x,r[1]=bn.y,r[5]=Qi.y,r[9]=It.y,r[2]=bn.z,r[6]=Qi.z,r[10]=It.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],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],p=n[13],x=n[2],_=n[6],m=n[10],f=n[14],T=n[3],y=n[7],w=n[11],C=n[15],E=r[0],P=r[4],z=r[8],b=r[12],M=r[1],D=r[5],B=r[9],k=r[13],H=r[2],K=r[6],q=r[10],ne=r[14],G=r[3],te=r[7],se=r[11],Se=r[15];return s[0]=a*E+o*M+l*H+c*G,s[4]=a*P+o*D+l*K+c*te,s[8]=a*z+o*B+l*q+c*se,s[12]=a*b+o*k+l*ne+c*Se,s[1]=h*E+u*M+d*H+p*G,s[5]=h*P+u*D+d*K+p*te,s[9]=h*z+u*B+d*q+p*se,s[13]=h*b+u*k+d*ne+p*Se,s[2]=x*E+_*M+m*H+f*G,s[6]=x*P+_*D+m*K+f*te,s[10]=x*z+_*B+m*q+f*se,s[14]=x*b+_*k+m*ne+f*Se,s[3]=T*E+y*M+w*H+C*G,s[7]=T*P+y*D+w*K+C*te,s[11]=T*z+y*B+w*q+C*se,s[15]=T*b+y*k+w*ne+C*Se,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],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],p=e[14],x=e[3],_=e[7],m=e[11],f=e[15];return x*(+s*l*u-r*c*u-s*o*d+n*c*d+r*o*p-n*l*p)+_*(+t*l*p-t*c*d+s*a*d-r*a*p+r*c*h-s*l*h)+m*(+t*c*u-t*o*p-s*a*u+n*a*p+s*o*h-n*c*h)+f*(-r*o*h-t*l*u+t*o*d+r*a*u-n*a*d+n*l*h)}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],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],x=e[12],_=e[13],m=e[14],f=e[15],T=u*m*c-_*d*c+_*l*p-o*m*p-u*l*f+o*d*f,y=x*d*c-h*m*c-x*l*p+a*m*p+h*l*f-a*d*f,w=h*_*c-x*u*c+x*o*p-a*_*p-h*o*f+a*u*f,C=x*u*l-h*_*l-x*o*d+a*_*d+h*o*m-a*u*m,E=t*T+n*y+r*w+s*C;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/E;return e[0]=T*P,e[1]=(_*d*s-u*m*s-_*r*p+n*m*p+u*r*f-n*d*f)*P,e[2]=(o*m*s-_*l*s+_*r*c-n*m*c-o*r*f+n*l*f)*P,e[3]=(u*l*s-o*d*s-u*r*c+n*d*c+o*r*p-n*l*p)*P,e[4]=y*P,e[5]=(h*m*s-x*d*s+x*r*p-t*m*p-h*r*f+t*d*f)*P,e[6]=(x*l*s-a*m*s-x*r*c+t*m*c+a*r*f-t*l*f)*P,e[7]=(a*d*s-h*l*s+h*r*c-t*d*c-a*r*p+t*l*p)*P,e[8]=w*P,e[9]=(x*u*s-h*_*s-x*n*p+t*_*p+h*n*f-t*u*f)*P,e[10]=(a*_*s-x*o*s+x*n*c-t*_*c-a*n*f+t*o*f)*P,e[11]=(h*o*s-a*u*s-h*n*c+t*u*c+a*n*p-t*o*p)*P,e[12]=C*P,e[13]=(h*_*r-x*u*r+x*n*d-t*_*d-h*n*m+t*u*m)*P,e[14]=(x*o*r-a*_*r-x*n*l+t*_*l+a*n*m-t*o*m)*P,e[15]=(a*u*r-h*o*r+h*n*l-t*u*l-a*n*d+t*o*d)*P,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,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+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,l=t._w,c=s+s,h=a+a,u=o+o,d=s*c,p=s*h,x=s*u,_=a*h,m=a*u,f=o*u,T=l*c,y=l*h,w=l*u,C=n.x,E=n.y,P=n.z;return r[0]=(1-(_+f))*C,r[1]=(p+w)*C,r[2]=(x-y)*C,r[3]=0,r[4]=(p-w)*E,r[5]=(1-(d+f))*E,r[6]=(m+T)*E,r[7]=0,r[8]=(x+y)*P,r[9]=(m-T)*P,r[10]=(1-(d+_))*P,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;let s=Jn.set(r[0],r[1],r[2]).length();const a=Jn.set(r[4],r[5],r[6]).length(),o=Jn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Ht.copy(this);const c=1/s,h=1/a,u=1/o;return Ht.elements[0]*=c,Ht.elements[1]*=c,Ht.elements[2]*=c,Ht.elements[4]*=h,Ht.elements[5]*=h,Ht.elements[6]*=h,Ht.elements[8]*=u,Ht.elements[9]*=u,Ht.elements[10]*=u,t.setFromRotationMatrix(Ht),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=tn,l=!1){const c=this.elements,h=2*s/(t-e),u=2*s/(n-r),d=(t+e)/(t-e),p=(n+r)/(n-r);let x,_;if(l)x=s/(a-s),_=a*s/(a-s);else if(o===tn)x=-(a+s)/(a-s),_=-2*a*s/(a-s);else if(o===wr)x=-a/(a-s),_=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=x,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=tn,l=!1){const c=this.elements,h=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),p=-(n+r)/(n-r);let x,_;if(l)x=1/(a-s),_=a/(a-s);else if(o===tn)x=-2/(a-s),_=-(a+s)/(a-s);else if(o===wr)x=-1/(a-s),_=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=x,c[14]=_,c[3]=0,c[7]=0,c[11]=0,c[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}}const Jn=new U,Ht=new He,oh=new U(0,0,0),ch=new U(1,1,1),bn=new U,Qi=new U,It=new U,no=new He,io=new _i;class Zt{constructor(e=0,t=0,n=0,r=Zt.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],l=r[1],c=r[5],h=r[9],u=r[2],d=r[6],p=r[10];switch(t){case"XYZ":this._y=Math.asin(Fe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Fe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Fe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Fe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Fe(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Fe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,p),this._y=0);break;default:_e("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return no.makeRotationFromQuaternion(e),this.setFromRotationMatrix(no,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return io.setFromEuler(this),this.setFromQuaternion(io,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}}Zt.DEFAULT_ORDER="XYZ";class xc{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 lh=0;const ro=new U,Qn=new _i,an=new He,er=new U,Ti=new U,hh=new U,uh=new _i,so=new U(1,0,0),ao=new U(0,1,0),oo=new U(0,0,1),co={type:"added"},dh={type:"removed"},ei={type:"childadded",child:null},es={type:"childremoved",child:null};class dt extends Xn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:lh++}),this.uuid=Kt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=dt.DEFAULT_UP.clone();const e=new U,t=new Zt,n=new _i,r=new U(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 He},normalMatrix:{value:new Ie}}),this.matrix=new He,this.matrixWorld=new He,this.matrixAutoUpdate=dt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new xc,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.userData={}}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 Qn.setFromAxisAngle(e,t),this.quaternion.multiply(Qn),this}rotateOnWorldAxis(e,t){return Qn.setFromAxisAngle(e,t),this.quaternion.premultiply(Qn),this}rotateX(e){return this.rotateOnAxis(so,e)}rotateY(e){return this.rotateOnAxis(ao,e)}rotateZ(e){return this.rotateOnAxis(oo,e)}translateOnAxis(e,t){return ro.copy(e).applyQuaternion(this.quaternion),this.position.add(ro.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(so,e)}translateY(e){return this.translateOnAxis(ao,e)}translateZ(e){return this.translateOnAxis(oo,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(an.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?er.copy(e):er.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Ti.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?an.lookAt(Ti,er,this.up):an.lookAt(er,Ti,this.up),this.quaternion.setFromRotationMatrix(an),r&&(an.extractRotation(r.matrixWorld),Qn.setFromRotationMatrix(an),this.quaternion.premultiply(Qn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Be("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(co),ei.child=e,this.dispatchEvent(ei),ei.child=null):Be("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(dh),es.child=e,this.dispatchEvent(es),es.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),an.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),an.multiply(e.parent.matrixWorld)),e.applyMatrix4(an),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(co),ei.child=e,this.dispatchEvent(ei),ei.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(Ti,e,hh),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ti,uh,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),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){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}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),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.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),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,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.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 l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}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 l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));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 l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),p=a(e.animations),x=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),x.length>0&&(n.nodes=x)}return n.object=r,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}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.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.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}}dt.DEFAULT_UP=new U(0,1,0);dt.DEFAULT_MATRIX_AUTO_UPDATE=!0;dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Wt=new U,on=new U,ts=new U,cn=new U,ti=new U,ni=new U,lo=new U,ns=new U,is=new U,rs=new U,ss=new Ke,as=new Ke,os=new Ke;class qt{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Wt.subVectors(e,t),r.cross(Wt);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){Wt.subVectors(r,t),on.subVectors(n,t),ts.subVectors(e,t);const a=Wt.dot(Wt),o=Wt.dot(on),l=Wt.dot(ts),c=on.dot(on),h=on.dot(ts),u=a*c-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,p=(c*l-o*h)*d,x=(a*h-o*l)*d;return s.set(1-p-x,x,p)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,cn)===null?!1:cn.x>=0&&cn.y>=0&&cn.x+cn.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,cn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,cn.x),l.addScaledVector(a,cn.y),l.addScaledVector(o,cn.z),l)}static getInterpolatedAttribute(e,t,n,r,s,a){return ss.setScalar(0),as.setScalar(0),os.setScalar(0),ss.fromBufferAttribute(e,t),as.fromBufferAttribute(e,n),os.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(ss,s.x),a.addScaledVector(as,s.y),a.addScaledVector(os,s.z),a}static isFrontFacing(e,t,n,r){return Wt.subVectors(n,t),on.subVectors(e,t),Wt.cross(on).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 Wt.subVectors(this.c,this.b),on.subVectors(this.a,this.b),Wt.cross(on).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return qt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return qt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return qt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return qt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return qt.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;ti.subVectors(r,n),ni.subVectors(s,n),ns.subVectors(e,n);const l=ti.dot(ns),c=ni.dot(ns);if(l<=0&&c<=0)return t.copy(n);is.subVectors(e,r);const h=ti.dot(is),u=ni.dot(is);if(h>=0&&u<=h)return t.copy(r);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(ti,a);rs.subVectors(e,s);const p=ti.dot(rs),x=ni.dot(rs);if(x>=0&&p<=x)return t.copy(s);const _=p*c-l*x;if(_<=0&&c>=0&&x<=0)return o=c/(c-x),t.copy(n).addScaledVector(ni,o);const m=h*x-p*u;if(m<=0&&u-h>=0&&p-x>=0)return lo.subVectors(s,r),o=(u-h)/(u-h+(p-x)),t.copy(r).addScaledVector(lo,o);const f=1/(m+_+d);return a=_*f,o=d*f,t.copy(n).addScaledVector(ti,a).addScaledVector(ni,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const gc={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},Sn={h:0,s:0,l:0},tr={h:0,s:0,l:0};function cs(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 Ne{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=Nt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ye.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Ye.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ye.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Ye.workingColorSpace){if(e=wa(e,1),t=Fe(t,0,1),n=Fe(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=cs(a,s,e+1/3),this.g=cs(a,s,e),this.b=cs(a,s,e-1/3)}return Ye.colorSpaceToWorking(this,r),this}setStyle(e,t=Nt){function n(s){s!==void 0&&parseFloat(s)<1&&_e("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:_e("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);_e("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Nt){const n=gc[e.toLowerCase()];return n!==void 0?this.setHex(n,t):_e("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=mn(e.r),this.g=mn(e.g),this.b=mn(e.b),this}copyLinearToSRGB(e){return this.r=hi(e.r),this.g=hi(e.g),this.b=hi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nt){return Ye.workingToColorSpace(Mt.copy(this),e),Math.round(Fe(Mt.r*255,0,255))*65536+Math.round(Fe(Mt.g*255,0,255))*256+Math.round(Fe(Mt.b*255,0,255))}getHexString(e=Nt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ye.workingColorSpace){Ye.workingToColorSpace(Mt.copy(this),t);const n=Mt.r,r=Mt.g,s=Mt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(r-s)/u+(r<s?6:0);break;case r:l=(s-n)/u+2;break;case s:l=(n-r)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ye.workingColorSpace){return Ye.workingToColorSpace(Mt.copy(this),t),e.r=Mt.r,e.g=Mt.g,e.b=Mt.b,e}getStyle(e=Nt){Ye.workingToColorSpace(Mt.copy(this),e);const t=Mt.r,n=Mt.g,r=Mt.b;return e!==Nt?`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(Sn),this.setHSL(Sn.h+e,Sn.s+t,Sn.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}lerpColors(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(Sn),e.getHSL(tr);const n=Ni(Sn.h,tr.h,t),r=Ni(Sn.s,tr.s,t),s=Ni(Sn.l,tr.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 Mt=new Ne;Ne.NAMES=gc;let fh=0;class Cn extends Xn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:fh++}),this.uuid=Kt(),this.name="",this.type="Material",this.blending=li,this.side=wn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Es,this.blendDst=Ts,this.blendEquation=zn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ne(0,0,0),this.blendAlpha=0,this.depthFunc=ui,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=$a,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yn,this.stencilZFail=Yn,this.stencilZPass=Yn,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){_e(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){_e(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):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"}};n.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!==li&&(n.blending=this.blending),this.side!==wn&&(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!==Ts&&(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!==ui&&(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!==Yn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Yn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Yn&&(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.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 l=s[o];delete l.metadata,a.push(l)}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}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.clipShadows,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.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++}}class Wn extends Cn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ne(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 Zt,this.combine=ga,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 ft=new U,nr=new Xe;let ph=0;class bt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ph++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=da,this.updateRanges=[],this.gpuType=Yt,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++)ft.fromBufferAttribute(this,t),ft.applyMatrix3(e),this.setXYZ(t,ft.x,ft.y,ft.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ft.fromBufferAttribute(this,t),ft.applyMatrix4(e),this.setXYZ(t,ft.x,ft.y,ft.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ft.fromBufferAttribute(this,t),ft.applyNormalMatrix(e),this.setXYZ(t,ft.x,ft.y,ft.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ft.fromBufferAttribute(this,t),ft.transformDirection(e),this.setXYZ(t,ft.x,ft.y,ft.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=Xt(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=$e(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Xt(t,this.array)),t}setX(e,t){return this.normalized&&(t=$e(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Xt(t,this.array)),t}setY(e,t){return this.normalized&&(t=$e(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=Xt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=$e(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=Xt(t,this.array)),t}setW(e,t){return this.normalized&&(t=$e(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=$e(t,this.array),n=$e(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=$e(t,this.array),n=$e(n,this.array),r=$e(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=$e(t,this.array),n=$e(n,this.array),r=$e(r,this.array),s=$e(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!==da&&(e.usage=this.usage),e}}class _c extends bt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class vc extends bt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class $t extends bt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let mh=0;const Bt=new He,ls=new dt,ii=new U,Ut=new Rn,Ai=new Rn,xt=new U;class Vt extends Xn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:mh++}),this.uuid=Kt(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(pc(e)?vc:_c)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,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 Ie().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}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 ls.lookAt(e),ls.updateMatrix(),this.applyMatrix4(ls.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ii).negate(),this.translate(ii.x,ii.y,ii.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 $t(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&&_e("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 Rn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(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];Ut.setFromBufferAttribute(s),this.morphTargetsRelative?(xt.addVectors(this.boundingBox.min,Ut.min),this.boundingBox.expandByPoint(xt),xt.addVectors(this.boundingBox.max,Ut.max),this.boundingBox.expandByPoint(xt)):(this.boundingBox.expandByPoint(Ut.min),this.boundingBox.expandByPoint(Ut.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Be('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 gn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){const n=this.boundingSphere.center;if(Ut.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Ai.setFromBufferAttribute(o),this.morphTargetsRelative?(xt.addVectors(Ut.min,Ai.min),Ut.expandByPoint(xt),xt.addVectors(Ut.max,Ai.max),Ut.expandByPoint(xt)):(Ut.expandByPoint(Ai.min),Ut.expandByPoint(Ai.max))}Ut.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],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)xt.fromBufferAttribute(o,c),l&&(ii.fromBufferAttribute(e,c),xt.add(ii)),r=Math.max(r,n.distanceToSquared(xt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Be('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){Be("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new bt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let z=0;z<n.count;z++)o[z]=new U,l[z]=new U;const c=new U,h=new U,u=new U,d=new Xe,p=new Xe,x=new Xe,_=new U,m=new U;function f(z,b,M){c.fromBufferAttribute(n,z),h.fromBufferAttribute(n,b),u.fromBufferAttribute(n,M),d.fromBufferAttribute(s,z),p.fromBufferAttribute(s,b),x.fromBufferAttribute(s,M),h.sub(c),u.sub(c),p.sub(d),x.sub(d);const D=1/(p.x*x.y-x.x*p.y);isFinite(D)&&(_.copy(h).multiplyScalar(x.y).addScaledVector(u,-p.y).multiplyScalar(D),m.copy(u).multiplyScalar(p.x).addScaledVector(h,-x.x).multiplyScalar(D),o[z].add(_),o[b].add(_),o[M].add(_),l[z].add(m),l[b].add(m),l[M].add(m))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let z=0,b=T.length;z<b;++z){const M=T[z],D=M.start,B=M.count;for(let k=D,H=D+B;k<H;k+=3)f(e.getX(k+0),e.getX(k+1),e.getX(k+2))}const y=new U,w=new U,C=new U,E=new U;function P(z){C.fromBufferAttribute(r,z),E.copy(C);const b=o[z];y.copy(b),y.sub(C.multiplyScalar(C.dot(b))).normalize(),w.crossVectors(E,b);const D=w.dot(l[z])<0?-1:1;a.setXYZW(z,y.x,y.y,y.z,D)}for(let z=0,b=T.length;z<b;++z){const M=T[z],D=M.start,B=M.count;for(let k=D,H=D+B;k<H;k+=3)P(e.getX(k+0)),P(e.getX(k+1)),P(e.getX(k+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new bt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const r=new U,s=new U,a=new U,o=new U,l=new U,c=new U,h=new U,u=new U;if(e)for(let d=0,p=e.count;d<p;d+=3){const x=e.getX(d+0),_=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,x),s.fromBufferAttribute(t,_),a.fromBufferAttribute(t,m),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),o.fromBufferAttribute(n,x),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(x,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.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,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let p=0,x=0;for(let _=0,m=l.length;_<m;_++){o.isInterleavedBufferAttribute?p=l[_]*o.data.stride+o.offset:p=l[_]*h;for(let f=0;f<h;f++)d[x++]=c[p++]}return new bt(d,h,u)}if(this.index===null)return _e("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 l=r[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],p=e(d,n);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const p=c[u];h.push(p.toJSON(e.data))}h.length>0&&(r[l]=h,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 c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ho=new He,Un=new Ur,ir=new gn,uo=new U,rr=new U,sr=new U,ar=new U,hs=new U,or=new U,fo=new U,cr=new U;class St extends dt{constructor(e=new Vt,t=new Wn){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){or.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],u=s[l];h!==0&&(hs.fromBufferAttribute(u,e),a?or.addScaledVector(hs,h):or.addScaledVector(hs.sub(t),h))}t.add(or)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ir.copy(n.boundingSphere),ir.applyMatrix4(s),Un.copy(e.ray).recast(e.near),!(ir.containsPoint(Un.origin)===!1&&(Un.intersectSphere(ir,uo)===null||Un.origin.distanceToSquared(uo)>(e.far-e.near)**2))&&(ho.copy(s).invert(),Un.copy(e.ray).applyMatrix4(ho),!(n.boundingBox!==null&&Un.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Un)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,_=d.length;x<_;x++){const m=d[x],f=a[m.materialIndex],T=Math.max(m.start,p.start),y=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let w=T,C=y;w<C;w+=3){const E=o.getX(w),P=o.getX(w+1),z=o.getX(w+2);r=lr(this,f,e,n,c,h,u,E,P,z),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const x=Math.max(0,p.start),_=Math.min(o.count,p.start+p.count);for(let m=x,f=_;m<f;m+=3){const T=o.getX(m),y=o.getX(m+1),w=o.getX(m+2);r=lr(this,a,e,n,c,h,u,T,y,w),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let x=0,_=d.length;x<_;x++){const m=d[x],f=a[m.materialIndex],T=Math.max(m.start,p.start),y=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let w=T,C=y;w<C;w+=3){const E=w,P=w+1,z=w+2;r=lr(this,f,e,n,c,h,u,E,P,z),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const x=Math.max(0,p.start),_=Math.min(l.count,p.start+p.count);for(let m=x,f=_;m<f;m+=3){const T=m,y=m+1,w=m+2;r=lr(this,a,e,n,c,h,u,T,y,w),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}}function xh(i,e,t,n,r,s,a,o){let l;if(e.side===Ct?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===wn,o),l===null)return null;cr.copy(o),cr.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(cr);return c<t.near||c>t.far?null:{distance:c,point:cr.clone(),object:i}}function lr(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,rr),i.getVertexPosition(l,sr),i.getVertexPosition(c,ar);const h=xh(i,e,t,n,rr,sr,ar,fo);if(h){const u=new U;qt.getBarycoord(fo,rr,sr,ar,u),r&&(h.uv=qt.getInterpolatedAttribute(r,o,l,c,u,new Xe)),s&&(h.uv1=qt.getInterpolatedAttribute(s,o,l,c,u,new Xe)),a&&(h.normal=qt.getInterpolatedAttribute(a,o,l,c,u,new U),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new U,materialIndex:0};qt.getNormal(rr,sr,ar,d.normal),h.face=d,h.barycoord=u}return h}class Gi 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 l=[],c=[],h=[],u=[];let d=0,p=0;x("z","y","x",-1,-1,n,t,e,a,s,0),x("z","y","x",1,-1,n,t,-e,a,s,1),x("x","z","y",1,1,e,n,t,r,a,2),x("x","z","y",1,-1,e,n,-t,r,a,3),x("x","y","z",1,-1,e,t,n,r,s,4),x("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new $t(c,3)),this.setAttribute("normal",new $t(h,3)),this.setAttribute("uv",new $t(u,2));function x(_,m,f,T,y,w,C,E,P,z,b){const M=w/P,D=C/z,B=w/2,k=C/2,H=E/2,K=P+1,q=z+1;let ne=0,G=0;const te=new U;for(let se=0;se<q;se++){const Se=se*D-k;for(let We=0;We<K;We++){const Ze=We*M-B;te[_]=Ze*T,te[m]=Se*y,te[f]=H,c.push(te.x,te.y,te.z),te[_]=0,te[m]=0,te[f]=E>0?1:-1,h.push(te.x,te.y,te.z),u.push(We/P),u.push(1-se/z),ne+=1}}for(let se=0;se<z;se++)for(let Se=0;Se<P;Se++){const We=d+Se+K*se,Ze=d+Se+K*(se+1),nt=d+(Se+1)+K*(se+1),it=d+(Se+1)+K*se;l.push(We,Ze,it),l.push(Ze,nt,it),G+=6}o.addGroup(p,G,b),p+=G,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gi(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function xi(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(_e("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Tt(i){const e={};for(let t=0;t<i.length;t++){const n=xi(i[t]);for(const r in n)e[r]=n[r]}return e}function gh(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Mc(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ye.workingColorSpace}const _h={clone:xi,merge:Tt};var vh=`void main() {
|
|
2
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
|
+
}`,Mh=`void main() {
|
|
4
|
+
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
+
}`;class xn extends Cn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=vh,this.fragmentShader=Mh,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=xi(e.uniforms),this.uniformsGroups=gh(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}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}}class bc extends dt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new He,this.projectionMatrix=new He,this.projectionMatrixInverse=new He,this.coordinateSystem=tn,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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const yn=new U,po=new Xe,mo=new Xe;class Ft extends bc{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=mi*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ui*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return mi*2*Math.atan(Math.tan(Ui*.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){yn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(yn.x,yn.y).multiplyScalar(-e/yn.z),yn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(yn.x,yn.y).multiplyScalar(-e/yn.z)}getViewSize(e,t){return this.getViewBounds(e,po,mo),t.subVectors(mo,po)}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(Ui*.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 l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}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}}const ri=-90,si=1;class bh extends dt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ft(ri,si,e,t);r.layers=this.layers,this.add(r);const s=new Ft(ri,si,e,t);s.layers=this.layers,this.add(s);const a=new Ft(ri,si,e,t);a.layers=this.layers,this.add(a);const o=new Ft(ri,si,e,t);o.layers=this.layers,this.add(o);const l=new Ft(ri,si,e,t);l.layers=this.layers,this.add(l);const c=new Ft(ri,si,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===tn)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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===wr)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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.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,l,c,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,l),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,r),e.render(t,h),e.setRenderTarget(u,d,p),e.xr.enabled=x,n.texture.needsPMREMUpdate=!0}}class Sc extends gt{constructor(e=[],t=di,n,r,s,a,o,l,c,h){super(e,t,n,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Sh extends Hn{constructor(e=1,t={}){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 Sc(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:`
|
|
6
|
+
|
|
7
|
+
varying vec3 vWorldDirection;
|
|
8
|
+
|
|
9
|
+
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
10
|
+
|
|
11
|
+
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void main() {
|
|
16
|
+
|
|
17
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
18
|
+
|
|
19
|
+
#include <begin_vertex>
|
|
20
|
+
#include <project_vertex>
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
`,fragmentShader:`
|
|
24
|
+
|
|
25
|
+
uniform sampler2D tEquirect;
|
|
26
|
+
|
|
27
|
+
varying vec3 vWorldDirection;
|
|
28
|
+
|
|
29
|
+
#include <common>
|
|
30
|
+
|
|
31
|
+
void main() {
|
|
32
|
+
|
|
33
|
+
vec3 direction = normalize( vWorldDirection );
|
|
34
|
+
|
|
35
|
+
vec2 sampleUV = equirectUv( direction );
|
|
36
|
+
|
|
37
|
+
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
`},r=new Gi(5,5,5),s=new xn({name:"CubemapFromEquirect",uniforms:xi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ct,blending:pn});s.uniforms.tEquirect.value=t;const a=new St(r,s),o=t.minFilter;return t.minFilter===kn&&(t.minFilter=At),new bh(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)}}class Li extends dt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const yh={type:"move"};class us{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Li,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 Li,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Li,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U),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,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const _ of e.hand.values()){const m=t.getJointPose(_,n),f=this._getHandJoint(c,_);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,x=.005;c.inputState.pinching&&d>p+x?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-x&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));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(yh)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Li;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class r0 extends dt{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 Zt,this.environmentIntensity=1,this.environmentRotation=new Zt,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}}class s0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=da,this.updateRanges=[],this.version=0,this.uuid=Kt()}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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Kt()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Kt()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Et=new U;class yc{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix4(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyNormalMatrix(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.transformDirection(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Xt(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=$e(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=$e(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=$e(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=$e(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=$e(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Xt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xt(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array),r=$e(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=$e(t,this.array),n=$e(n,this.array),r=$e(r,this.array),s=$e(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){Rr("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new bt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new yc(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Rr("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const xo=new U,go=new Ke,_o=new Ke,Eh=new U,vo=new He,hr=new U,ds=new gn,Mo=new He,fs=new Ur;class a0 extends St{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Xa,this.bindMatrix=new He,this.bindMatrixInverse=new He,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Rn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,hr),this.boundingBox.expandByPoint(hr)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new gn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,hr),this.boundingSphere.expandByPoint(hr)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ds.copy(this.boundingSphere),ds.applyMatrix4(r),e.ray.intersectsSphere(ds)!==!1&&(Mo.copy(r).invert(),fs.copy(e.ray).applyMatrix4(Mo),!(this.boundingBox!==null&&fs.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,fs)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Ke,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Xa?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===yl?this.bindMatrixInverse.copy(this.bindMatrix).invert():_e("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;go.fromBufferAttribute(r.attributes.skinIndex,e),_o.fromBufferAttribute(r.attributes.skinWeight,e),xo.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=_o.getComponent(s);if(a!==0){const o=go.getComponent(s);vo.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Eh.copy(xo).applyMatrix4(vo),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Th extends dt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Nr extends gt{constructor(e=null,t=1,n=1,r,s,a,o,l,c=Pt,h=Pt,u,d){super(null,a,o,l,c,h,r,s,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const bo=new He,Ah=new He;class Ec{constructor(e=[],t=[]){this.uuid=Kt(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){_e("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new He)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new He;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:Ah;bo.multiplyMatrices(o,t[s]),bo.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Ec(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Nr(t,e,e,zt,Yt);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const s=e.bones[n];let a=t[s];a===void 0&&(_e("Skeleton: No bone found with UUID:",s),a=new Th),this.bones.push(a),this.boneInverses.push(new He().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=n[r];e.boneInverses.push(o.toArray())}return e}}class So extends bt{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 ai=new He,yo=new He,ur=[],Eo=new Rn,wh=new He,wi=new St,Ri=new gn;class o0 extends St{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new So(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,wh)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Rn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ai),Eo.copy(e.boundingBox).applyMatrix4(ai),this.boundingBox.union(Eo)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new gn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ai),Ri.copy(e.boundingSphere).applyMatrix4(ai),this.boundingSphere.union(Ri)}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){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){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(wi.geometry=this.geometry,wi.material=this.material,wi.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ri.copy(this.boundingSphere),Ri.applyMatrix4(n),e.ray.intersectsSphere(Ri)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,ai),yo.multiplyMatrices(n,ai),wi.matrixWorld=yo,wi.raycast(e,ur);for(let a=0,o=ur.length;a<o;a++){const l=ur[a];l.instanceId=s,l.object=this,t.push(l)}ur.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new So(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Nr(new Float32Array(r*this.count),r,this.count,ba,Yt));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const ps=new U,Rh=new U,Ch=new Ie;class Bn{constructor(e=new U(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}setFromCoplanarPoints(e,t,n){const r=ps.subVectors(n,t).cross(Rh.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){const n=e.delta(ps),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}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||Ch.getNormalMatrix(e),r=this.coplanarPoint(ps).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 Nn=new gn,Ph=new Xe(.5,.5),dr=new U;class Ca{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=tn,n=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],u=s[5],d=s[6],p=s[7],x=s[8],_=s[9],m=s[10],f=s[11],T=s[12],y=s[13],w=s[14],C=s[15];if(r[0].setComponents(c-a,p-h,f-x,C-T).normalize(),r[1].setComponents(c+a,p+h,f+x,C+T).normalize(),r[2].setComponents(c+o,p+u,f+_,C+y).normalize(),r[3].setComponents(c-o,p-u,f-_,C-y).normalize(),n)r[4].setComponents(l,d,m,w).normalize(),r[5].setComponents(c-l,p-d,f-m,C-w).normalize();else if(r[4].setComponents(c-l,p-d,f-m,C-w).normalize(),t===tn)r[5].setComponents(c+l,p+d,f+m,C+w).normalize();else if(t===wr)r[5].setComponents(l,d,m,w).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(),Nn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Nn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Nn)}intersectsSprite(e){Nn.center.set(0,0,0);const t=Ph.distanceTo(e.center);return Nn.radius=.7071067811865476+t,Nn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Nn)}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 Tc extends Cn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ne(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Cr=new U,Pr=new U,To=new He,Ci=new Ur,fr=new gn,ms=new U,Ao=new U;class Ac extends dt{constructor(e=new Vt,t=new Tc){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)Cr.fromBufferAttribute(t,r-1),Pr.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Cr.distanceTo(Pr);e.setAttribute("lineDistance",new $t(n,1))}else _e("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),fr.copy(n.boundingSphere),fr.applyMatrix4(r),fr.radius+=s,e.ray.intersectsSphere(fr)===!1)return;To.copy(r).invert(),Ci.copy(e.ray).applyMatrix4(To);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const p=Math.max(0,a.start),x=Math.min(h.count,a.start+a.count);for(let _=p,m=x-1;_<m;_+=c){const f=h.getX(_),T=h.getX(_+1),y=pr(this,e,Ci,l,f,T,_);y&&t.push(y)}if(this.isLineLoop){const _=h.getX(x-1),m=h.getX(p),f=pr(this,e,Ci,l,_,m,x-1);f&&t.push(f)}}else{const p=Math.max(0,a.start),x=Math.min(d.count,a.start+a.count);for(let _=p,m=x-1;_<m;_+=c){const f=pr(this,e,Ci,l,_,_+1,_);f&&t.push(f)}if(this.isLineLoop){const _=pr(this,e,Ci,l,x-1,p,x-1);_&&t.push(_)}}}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}}}}}function pr(i,e,t,n,r,s,a){const o=i.geometry.attributes.position;if(Cr.fromBufferAttribute(o,r),Pr.fromBufferAttribute(o,s),t.distanceSqToSegment(Cr,Pr,ms,Ao)>n)return;ms.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(ms);if(!(c<e.near||c>e.far))return{distance:c,point:Ao.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const wo=new U,Ro=new U;class Dh extends Ac{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)wo.fromBufferAttribute(t,r),Ro.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+wo.distanceTo(Ro);e.setAttribute("lineDistance",new $t(n,1))}else _e("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class c0 extends Ac{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Lh extends Cn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ne(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Co=new He,fa=new Ur,mr=new gn,xr=new U;class l0 extends dt{constructor(e=new Vt,t=new Lh){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),mr.copy(n.boundingSphere),mr.applyMatrix4(r),mr.radius+=s,e.ray.intersectsSphere(mr)===!1)return;Co.copy(r).invert(),fa.copy(e.ray).applyMatrix4(Co);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let x=d,_=p;x<_;x++){const m=c.getX(x);xr.fromBufferAttribute(u,m),Po(xr,m,l,r,e,t,this)}}else{const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let x=d,_=p;x<_;x++)xr.fromBufferAttribute(u,x),Po(xr,x,l,r,e,t,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}}}}}function Po(i,e,t,n,r,s,a){const o=fa.distanceSqToPoint(i);if(o<t){const l=new U;fa.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class h0 extends gt{constructor(e,t,n,r,s,a,o,l,c,h,u,d){super(null,a,o,l,c,h,r,s,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class wc extends gt{constructor(e,t,n=Gn,r,s,a,o=Pt,l=Pt,c,h=Bi,u=1){if(h!==Bi&&h!==zi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,r,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ra(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 Rc extends gt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Hi 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),l=Math.floor(r),c=o+1,h=l+1,u=e/o,d=t/l,p=[],x=[],_=[],m=[];for(let f=0;f<h;f++){const T=f*d-a;for(let y=0;y<c;y++){const w=y*u-s;x.push(w,-T,0),_.push(0,0,1),m.push(y/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let T=0;T<o;T++){const y=T+c*f,w=T+c*(f+1),C=T+1+c*(f+1),E=T+1+c*f;p.push(y,w,E),p.push(w,C,E)}this.setIndex(p),this.setAttribute("position",new $t(x,3)),this.setAttribute("normal",new $t(_,3)),this.setAttribute("uv",new $t(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hi(e.width,e.height,e.widthSegments,e.heightSegments)}}class Ih extends Cn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ne(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 Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Aa,this.normalScale=new Xe(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 Zt,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 u0 extends Ih{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Xe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Fe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ne(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ne(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ne(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class pa extends Cn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ne(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Aa,this.normalScale=new Xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zt,this.combine=ga,this.reflectivity=1,this.refractionRatio=.98,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.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.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.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.flatShading=e.flatShading,this.fog=e.fog,this}}class Uh extends Cn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Al,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 Nh extends Cn{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}}function gr(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Fh(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Oh(i){function e(r,s){return i[r]-i[s]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Do(i,e,t){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=i[o+l]}return r}function Cc(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(e.push(s.time),t.push(...a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(e.push(s.time),t.push(a)),s=i[r++];while(s!==void 0)}class Fr{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],s=t[n-1];n:{e:{let a;t:{i:if(!(e<r)){for(let o=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=r,r=t[++n],e<r)break e}a=t.length;break t}if(!(e>=s)){const o=t[1];e<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=t[--n-1],e>=s)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=n[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Bh extends Fr{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:qa,endingEnd:qa}}intervalChanged_(e,t,n){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ya:s=e,o=2*t-n;break;case Ka:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Ya:a=e,l=2*n-t;break;case Ka:a=1,l=n+r[1]-r[0];break;default:a=e-1,l=t}const c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,p=this._weightNext,x=(n-t)/(r-t),_=x*x,m=_*x,f=-d*m+2*d*_-d*x,T=(1+d)*m+(-1.5-2*d)*_+(-.5+d)*x+1,y=(-1-p)*m+(1.5+p)*_+.5*x,w=p*m-p*_;for(let C=0;C!==o;++C)s[C]=f*a[h+C]+T*a[c+C]+y*a[l+C]+w*a[u+C];return s}}class zh extends Fr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(n-t)/(r-t),u=1-h;for(let d=0;d!==o;++d)s[d]=a[c+d]*u+a[l+d]*h;return s}}class Vh extends Fr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class jt{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=gr(t,this.TimeBufferType),this.values=gr(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:gr(e.times,Array),values:gr(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Vh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new zh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Bh(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Tr:t=this.InterpolantFactoryMethodDiscrete;break;case ua:t=this.InterpolantFactoryMethodLinear;break;case Wr:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return _e("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Tr;case this.InterpolantFactoryMethodLinear:return ua;case this.InterpolantFactoryMethodSmooth:return Wr}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let s=0,a=r-1;for(;s!==r&&n[s]<e;)++s;for(;a!==-1&&n[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Be("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,s=n.length;s===0&&(Be("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){Be("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){Be("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Fh(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){Be("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Wr,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],h=e[o+1];if(c!==h&&(o!==1||c!==e[0]))if(r)l=!0;else{const u=o*n,d=u-n,p=u+n;for(let x=0;x!==n;++x){const _=t[u+x];if(_!==t[d+x]||_!==t[p+x]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const u=o*n,d=a*n;for(let p=0;p!==n;++p)t[d+p]=t[u+p]}++a}}if(s>0){e[a]=e[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}jt.prototype.ValueTypeName="";jt.prototype.TimeBufferType=Float32Array;jt.prototype.ValueBufferType=Float32Array;jt.prototype.DefaultInterpolation=ua;class vi extends jt{constructor(e,t,n){super(e,t,n)}}vi.prototype.ValueTypeName="bool";vi.prototype.ValueBufferType=Array;vi.prototype.DefaultInterpolation=Tr;vi.prototype.InterpolantFactoryMethodLinear=void 0;vi.prototype.InterpolantFactoryMethodSmooth=void 0;class Pc extends jt{constructor(e,t,n,r){super(e,t,n,r)}}Pc.prototype.ValueTypeName="color";class Dr extends jt{constructor(e,t,n,r){super(e,t,n,r)}}Dr.prototype.ValueTypeName="number";class kh extends Fr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(r-t);let c=e*o;for(let h=c+o;c!==h;c+=4)_i.slerpFlat(s,0,a,c-o,a,c,l);return s}}class Or extends jt{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new kh(this.times,this.values,this.getValueSize(),e)}}Or.prototype.ValueTypeName="quaternion";Or.prototype.InterpolantFactoryMethodSmooth=void 0;class Mi extends jt{constructor(e,t,n){super(e,t,n)}}Mi.prototype.ValueTypeName="string";Mi.prototype.ValueBufferType=Array;Mi.prototype.DefaultInterpolation=Tr;Mi.prototype.InterpolantFactoryMethodLinear=void 0;Mi.prototype.InterpolantFactoryMethodSmooth=void 0;class Lr extends jt{constructor(e,t,n,r){super(e,t,n,r)}}Lr.prototype.ValueTypeName="vector";class d0{constructor(e="",t=-1,n=[],r=Tl){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Kt(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Hh(n[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,a=n.length;s!==a;++s)t.push(jt.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=Oh(l);l=Do(l,1,h),c=Do(c,1,h),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Dr(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let d=r[u];d||(r[u]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,n));return a}static parseAnimation(e,t){if(_e("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Be("AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,p,x,_){if(p.length!==0){const m=[],f=[];Cc(p,m,f,x),m.length!==0&&_.push(new u(d,m,f))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const d=c[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const p={};let x;for(x=0;x<d.length;x++)if(d[x].morphTargets)for(let _=0;_<d[x].morphTargets.length;_++)p[d[x].morphTargets[_]]=-1;for(const _ in p){const m=[],f=[];for(let T=0;T!==d[x].morphTargets.length;++T){const y=d[x];m.push(y.time),f.push(y.morphTarget===_?1:0)}r.push(new Dr(".morphTargetInfluence["+_+"]",m,f))}l=p.length*a}else{const p=".bones["+t[u].name+"]";n(Lr,p+".position",d,"pos",r),n(Or,p+".quaternion",d,"rot",r),n(Lr,p+".scale",d,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function Gh(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Dr;case"vector":case"vector2":case"vector3":case"vector4":return Lr;case"color":return Pc;case"quaternion":return Or;case"bool":case"boolean":return vi;case"string":return Mi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Hh(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Gh(i.type);if(i.times===void 0){const t=[],n=[];Cc(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const fn={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class Wh{constructor(e,t,n){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){const p=c[u],x=c[u+1];if(p.global&&(p.lastIndex=0),p.test(h))return x}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const Xh=new Wh;class Wi{constructor(e){this.manager=e!==void 0?e:Xh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Wi.DEFAULT_MATERIAL_NAME="__DEFAULT";const ln={};class qh extends Error{constructor(e,t){super(e),this.response=t}}class f0 extends Wi{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=fn.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(ln[e]!==void 0){ln[e].push({onLoad:t,onProgress:n,onError:r});return}ln[e]=[],ln[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&_e("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=ln[e],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,x=p!==0;let _=0;const m=new ReadableStream({start(f){T();function T(){u.read().then(({done:y,value:w})=>{if(y)f.close();else{_+=w.byteLength;const C=new ProgressEvent("progress",{lengthComputable:x,loaded:_,total:p});for(let E=0,P=h.length;E<P;E++){const z=h[E];z.onProgress&&z.onProgress(C)}f.enqueue(w),T()}},y=>{f.error(y)})}}});return new Response(m)}else throw new qh(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o==="")return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(x=>p.decode(x))}}}).then(c=>{fn.add(`file:${e}`,c);const h=ln[e];delete ln[e];for(let u=0,d=h.length;u<d;u++){const p=h[u];p.onLoad&&p.onLoad(c)}}).catch(c=>{const h=ln[e];if(h===void 0)throw this.manager.itemError(e),c;delete ln[e];for(let u=0,d=h.length;u<d;u++){const p=h[u];p.onError&&p.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const oi=new WeakMap;class Yh extends Wi{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=fn.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);else{let u=oi.get(a);u===void 0&&(u=[],oi.set(a,u)),u.push({onLoad:t,onError:r})}return a}const o=Vi("img");function l(){h(),t&&t(this);const u=oi.get(this)||[];for(let d=0;d<u.length;d++){const p=u[d];p.onLoad&&p.onLoad(this)}oi.delete(this),s.manager.itemEnd(e)}function c(u){h(),r&&r(u),fn.remove(`image:${e}`);const d=oi.get(this)||[];for(let p=0;p<d.length;p++){const x=d[p];x.onError&&x.onError(u)}oi.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),fn.add(`image:${e}`,o),s.manager.itemStart(e),o.src=e,o}}class p0 extends Wi{constructor(e){super(e)}load(e,t,n,r){const s=new gt,a=new Yh(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}class Br extends dt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ne(e),this.intensity=t}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,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}const xs=new He,Lo=new U,Io=new U;class Pa{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Xe(512,512),this.mapType=nn,this.map=null,this.mapPass=null,this.matrix=new He,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ca,this._frameExtents=new Xe(1,1),this._viewportCount=1,this._viewports=[new Ke(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Lo.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lo),Io.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Io),t.updateMatrixWorld(),xs.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xs,t.coordinateSystem,t.reversedDepth),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(xs)}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}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}}class Kh extends Pa{constructor(){super(new Ft(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=mi*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class m0 extends Br{constructor(e,t,n=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(dt.DEFAULT_UP),this.updateMatrix(),this.target=new dt,this.distance=n,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new Kh}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Uo=new He,Pi=new U,gs=new U;class $h extends Pa{constructor(){super(new Ft(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Xe(4,2),this._viewportCount=6,this._viewports=[new Ke(2,1,1,1),new Ke(0,1,1,1),new Ke(3,1,1,1),new Ke(1,1,1,1),new Ke(3,0,1,1),new Ke(1,0,1,1)],this._cubeDirections=[new U(1,0,0),new U(-1,0,0),new U(0,0,1),new U(0,0,-1),new U(0,1,0),new U(0,-1,0)],this._cubeUps=[new U(0,1,0),new U(0,1,0),new U(0,1,0),new U(0,1,0),new U(0,0,1),new U(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Pi.setFromMatrixPosition(e.matrixWorld),n.position.copy(Pi),gs.copy(n.position),gs.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(gs),n.updateMatrixWorld(),r.makeTranslation(-Pi.x,-Pi.y,-Pi.z),Uo.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Uo,n.coordinateSystem,n.reversedDepth)}}class x0 extends Br{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new $h}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Dc extends bc{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",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,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,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 Zh extends Pa{constructor(){super(new Dc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class g0 extends Br{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(dt.DEFAULT_UP),this.updateMatrix(),this.target=new dt,this.shadow=new Zh}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _0 extends Br{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class v0{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const _s=new WeakMap;class M0 extends Wi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&_e("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&_e("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=fn.get(`image-bitmap:${e}`);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{if(_s.has(a)===!0)r&&r(_s.get(a)),s.manager.itemError(e),s.manager.itemEnd(e);else return t&&t(c),s.manager.itemEnd(e),c});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return fn.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),_s.set(l,c),fn.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});fn.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class jh extends Ft{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Da="\\[\\]\\.:\\/",Jh=new RegExp("["+Da+"]","g"),La="[^"+Da+"]",Qh="[^"+Da.replace("\\.","")+"]",eu=/((?:WC+[\/:])*)/.source.replace("WC",La),tu=/(WCOD+)?/.source.replace("WCOD",Qh),nu=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",La),iu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",La),ru=new RegExp("^"+eu+tu+nu+iu+"$"),su=["material","materials","bones","map"];class au{constructor(e,t,n){const r=n||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class et{constructor(e,t,n){this.path=t,this.parsedPath=n||et.parseTrackName(t),this.node=et.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new et.Composite(e,t,n):new et(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Jh,"")}static parseTrackName(e){const t=ru.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);su.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=et.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){_e("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Be("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Be("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Be("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Be("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Be("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;Be("PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}et.Composite=au;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class b0{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Fe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Fe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class S0 extends Dh{constructor(e=10,t=10,n=4473924,r=8947848){n=new Ne(n),r=new Ne(r);const s=t/2,a=e/t,o=e/2,l=[],c=[];for(let d=0,p=0,x=-o;d<=t;d++,x+=a){l.push(-o,0,x,o,0,x),l.push(x,0,-o,x,0,o);const _=d===s?n:r;_.toArray(c,p),p+=3,_.toArray(c,p),p+=3,_.toArray(c,p),p+=3,_.toArray(c,p),p+=3}const h=new Vt;h.setAttribute("position",new $t(l,3)),h.setAttribute("color",new $t(c,3));const u=new Tc({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class y0 extends Xn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){_e("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function No(i,e,t,n){const r=ou(n);switch(t){case uc:return i*e;case ba:return i*e/r.components*r.byteLength;case Sa:return i*e/r.components*r.byteLength;case ya:return i*e*2/r.components*r.byteLength;case Ea:return i*e*2/r.components*r.byteLength;case dc:return i*e*3/r.components*r.byteLength;case zt:return i*e*4/r.components*r.byteLength;case Ta:return i*e*4/r.components*r.byteLength;case Mr:case br:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Sr:case yr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Bs:case Vs:return Math.max(i,16)*Math.max(e,8)/4;case Os:case zs:return Math.max(i,8)*Math.max(e,8)/2;case ks:case Gs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Hs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ws:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Xs:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case qs:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Ys:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ks:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case $s: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 js: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 ea:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case ta:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case na:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ia:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case ra:case sa:case aa:return Math.ceil(i/4)*Math.ceil(e/4)*16;case oa:case ca:return Math.ceil(i/4)*Math.ceil(e/4)*8;case la:case ha:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function ou(i){switch(i){case nn:case oc:return{byteLength:1,components:1};case Fi:case cc:case gi:return{byteLength:2,components:1};case va:case Ma:return{byteLength:2,components:4};case Gn:case _a:case Yt:return{byteLength:4,components:1};case lc:case hc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:xa}}));typeof window<"u"&&(window.__THREE__?_e("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=xa);function Lc(){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&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function cu(i){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=i.SHORT;else if(c instanceof Uint32Array)p=i.UNSIGNED_INT;else if(c instanceof Int32Array)p=i.INT;else if(c instanceof Int8Array)p=i.BYTE;else if(c instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,0,h);else{u.sort((p,x)=>p.start-x.start);let d=0;for(let p=1;p<u.length;p++){const x=u[d],_=u[p];_.start<=x.start+x.count+1?x.count=Math.max(x.count,_.start+_.count-x.start):(++d,u[d]=_)}u.length=d+1;for(let p=0,x=u.length;p<x;p++){const _=u[p];i.bufferSubData(c,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.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(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}var lu=`#ifdef USE_ALPHAHASH
|
|
41
|
+
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
42
|
+
#endif`,hu=`#ifdef USE_ALPHAHASH
|
|
43
|
+
const float ALPHA_HASH_SCALE = 0.05;
|
|
44
|
+
float hash2D( vec2 value ) {
|
|
45
|
+
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
46
|
+
}
|
|
47
|
+
float hash3D( vec3 value ) {
|
|
48
|
+
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
49
|
+
}
|
|
50
|
+
float getAlphaHashThreshold( vec3 position ) {
|
|
51
|
+
float maxDeriv = max(
|
|
52
|
+
length( dFdx( position.xyz ) ),
|
|
53
|
+
length( dFdy( position.xyz ) )
|
|
54
|
+
);
|
|
55
|
+
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
56
|
+
vec2 pixScales = vec2(
|
|
57
|
+
exp2( floor( log2( pixScale ) ) ),
|
|
58
|
+
exp2( ceil( log2( pixScale ) ) )
|
|
59
|
+
);
|
|
60
|
+
vec2 alpha = vec2(
|
|
61
|
+
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
62
|
+
hash3D( floor( pixScales.y * position.xyz ) )
|
|
63
|
+
);
|
|
64
|
+
float lerpFactor = fract( log2( pixScale ) );
|
|
65
|
+
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
66
|
+
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
67
|
+
vec3 cases = vec3(
|
|
68
|
+
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
69
|
+
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
70
|
+
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
71
|
+
);
|
|
72
|
+
float threshold = ( x < ( 1.0 - a ) )
|
|
73
|
+
? ( ( x < a ) ? cases.x : cases.y )
|
|
74
|
+
: cases.z;
|
|
75
|
+
return clamp( threshold , 1.0e-6, 1.0 );
|
|
76
|
+
}
|
|
77
|
+
#endif`,uu=`#ifdef USE_ALPHAMAP
|
|
78
|
+
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
79
|
+
#endif`,du=`#ifdef USE_ALPHAMAP
|
|
80
|
+
uniform sampler2D alphaMap;
|
|
81
|
+
#endif`,fu=`#ifdef USE_ALPHATEST
|
|
82
|
+
#ifdef ALPHA_TO_COVERAGE
|
|
83
|
+
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
84
|
+
if ( diffuseColor.a == 0.0 ) discard;
|
|
85
|
+
#else
|
|
86
|
+
if ( diffuseColor.a < alphaTest ) discard;
|
|
87
|
+
#endif
|
|
88
|
+
#endif`,pu=`#ifdef USE_ALPHATEST
|
|
89
|
+
uniform float alphaTest;
|
|
90
|
+
#endif`,mu=`#ifdef USE_AOMAP
|
|
91
|
+
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
92
|
+
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
93
|
+
#if defined( USE_CLEARCOAT )
|
|
94
|
+
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
95
|
+
#endif
|
|
96
|
+
#if defined( USE_SHEEN )
|
|
97
|
+
sheenSpecularIndirect *= ambientOcclusion;
|
|
98
|
+
#endif
|
|
99
|
+
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
100
|
+
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
101
|
+
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
102
|
+
#endif
|
|
103
|
+
#endif`,xu=`#ifdef USE_AOMAP
|
|
104
|
+
uniform sampler2D aoMap;
|
|
105
|
+
uniform float aoMapIntensity;
|
|
106
|
+
#endif`,gu=`#ifdef USE_BATCHING
|
|
107
|
+
#if ! defined( GL_ANGLE_multi_draw )
|
|
108
|
+
#define gl_DrawID _gl_DrawID
|
|
109
|
+
uniform int _gl_DrawID;
|
|
110
|
+
#endif
|
|
111
|
+
uniform highp sampler2D batchingTexture;
|
|
112
|
+
uniform highp usampler2D batchingIdTexture;
|
|
113
|
+
mat4 getBatchingMatrix( const in float i ) {
|
|
114
|
+
int size = textureSize( batchingTexture, 0 ).x;
|
|
115
|
+
int j = int( i ) * 4;
|
|
116
|
+
int x = j % size;
|
|
117
|
+
int y = j / size;
|
|
118
|
+
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
119
|
+
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
120
|
+
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
121
|
+
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
122
|
+
return mat4( v1, v2, v3, v4 );
|
|
123
|
+
}
|
|
124
|
+
float getIndirectIndex( const in int i ) {
|
|
125
|
+
int size = textureSize( batchingIdTexture, 0 ).x;
|
|
126
|
+
int x = i % size;
|
|
127
|
+
int y = i / size;
|
|
128
|
+
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
|
129
|
+
}
|
|
130
|
+
#endif
|
|
131
|
+
#ifdef USE_BATCHING_COLOR
|
|
132
|
+
uniform sampler2D batchingColorTexture;
|
|
133
|
+
vec3 getBatchingColor( const in float i ) {
|
|
134
|
+
int size = textureSize( batchingColorTexture, 0 ).x;
|
|
135
|
+
int j = int( i );
|
|
136
|
+
int x = j % size;
|
|
137
|
+
int y = j / size;
|
|
138
|
+
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|
139
|
+
}
|
|
140
|
+
#endif`,_u=`#ifdef USE_BATCHING
|
|
141
|
+
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
142
|
+
#endif`,vu=`vec3 transformed = vec3( position );
|
|
143
|
+
#ifdef USE_ALPHAHASH
|
|
144
|
+
vPosition = vec3( position );
|
|
145
|
+
#endif`,Mu=`vec3 objectNormal = vec3( normal );
|
|
146
|
+
#ifdef USE_TANGENT
|
|
147
|
+
vec3 objectTangent = vec3( tangent.xyz );
|
|
148
|
+
#endif`,bu=`float G_BlinnPhong_Implicit( ) {
|
|
149
|
+
return 0.25;
|
|
150
|
+
}
|
|
151
|
+
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
152
|
+
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
153
|
+
}
|
|
154
|
+
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
155
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
156
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
157
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
158
|
+
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
159
|
+
float G = G_BlinnPhong_Implicit( );
|
|
160
|
+
float D = D_BlinnPhong( shininess, dotNH );
|
|
161
|
+
return F * ( G * D );
|
|
162
|
+
} // validated`,Su=`#ifdef USE_IRIDESCENCE
|
|
163
|
+
const mat3 XYZ_TO_REC709 = mat3(
|
|
164
|
+
3.2404542, -0.9692660, 0.0556434,
|
|
165
|
+
-1.5371385, 1.8760108, -0.2040259,
|
|
166
|
+
-0.4985314, 0.0415560, 1.0572252
|
|
167
|
+
);
|
|
168
|
+
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
169
|
+
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
170
|
+
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
171
|
+
}
|
|
172
|
+
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
173
|
+
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
174
|
+
}
|
|
175
|
+
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
176
|
+
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
177
|
+
}
|
|
178
|
+
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
179
|
+
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
180
|
+
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
181
|
+
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
182
|
+
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
183
|
+
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
184
|
+
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 ) );
|
|
185
|
+
xyz /= 1.0685e-7;
|
|
186
|
+
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
187
|
+
return rgb;
|
|
188
|
+
}
|
|
189
|
+
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
190
|
+
vec3 I;
|
|
191
|
+
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
192
|
+
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
193
|
+
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
194
|
+
if ( cosTheta2Sq < 0.0 ) {
|
|
195
|
+
return vec3( 1.0 );
|
|
196
|
+
}
|
|
197
|
+
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
198
|
+
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
199
|
+
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
200
|
+
float T121 = 1.0 - R12;
|
|
201
|
+
float phi12 = 0.0;
|
|
202
|
+
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
203
|
+
float phi21 = PI - phi12;
|
|
204
|
+
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
205
|
+
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
206
|
+
vec3 phi23 = vec3( 0.0 );
|
|
207
|
+
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
208
|
+
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
209
|
+
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
210
|
+
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
211
|
+
vec3 phi = vec3( phi21 ) + phi23;
|
|
212
|
+
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
213
|
+
vec3 r123 = sqrt( R123 );
|
|
214
|
+
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
215
|
+
vec3 C0 = R12 + Rs;
|
|
216
|
+
I = C0;
|
|
217
|
+
vec3 Cm = Rs - T121;
|
|
218
|
+
for ( int m = 1; m <= 2; ++ m ) {
|
|
219
|
+
Cm *= r123;
|
|
220
|
+
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
221
|
+
I += Cm * Sm;
|
|
222
|
+
}
|
|
223
|
+
return max( I, vec3( 0.0 ) );
|
|
224
|
+
}
|
|
225
|
+
#endif`,yu=`#ifdef USE_BUMPMAP
|
|
226
|
+
uniform sampler2D bumpMap;
|
|
227
|
+
uniform float bumpScale;
|
|
228
|
+
vec2 dHdxy_fwd() {
|
|
229
|
+
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
230
|
+
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
231
|
+
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
232
|
+
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
233
|
+
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
234
|
+
return vec2( dBx, dBy );
|
|
235
|
+
}
|
|
236
|
+
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
237
|
+
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|
238
|
+
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
|
239
|
+
vec3 vN = surf_norm;
|
|
240
|
+
vec3 R1 = cross( vSigmaY, vN );
|
|
241
|
+
vec3 R2 = cross( vN, vSigmaX );
|
|
242
|
+
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
243
|
+
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
244
|
+
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
245
|
+
}
|
|
246
|
+
#endif`,Eu=`#if NUM_CLIPPING_PLANES > 0
|
|
247
|
+
vec4 plane;
|
|
248
|
+
#ifdef ALPHA_TO_COVERAGE
|
|
249
|
+
float distanceToPlane, distanceGradient;
|
|
250
|
+
float clipOpacity = 1.0;
|
|
251
|
+
#pragma unroll_loop_start
|
|
252
|
+
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
253
|
+
plane = clippingPlanes[ i ];
|
|
254
|
+
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
255
|
+
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
256
|
+
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
257
|
+
if ( clipOpacity == 0.0 ) discard;
|
|
258
|
+
}
|
|
259
|
+
#pragma unroll_loop_end
|
|
260
|
+
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
261
|
+
float unionClipOpacity = 1.0;
|
|
262
|
+
#pragma unroll_loop_start
|
|
263
|
+
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
264
|
+
plane = clippingPlanes[ i ];
|
|
265
|
+
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
266
|
+
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
267
|
+
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
268
|
+
}
|
|
269
|
+
#pragma unroll_loop_end
|
|
270
|
+
clipOpacity *= 1.0 - unionClipOpacity;
|
|
271
|
+
#endif
|
|
272
|
+
diffuseColor.a *= clipOpacity;
|
|
273
|
+
if ( diffuseColor.a == 0.0 ) discard;
|
|
274
|
+
#else
|
|
275
|
+
#pragma unroll_loop_start
|
|
276
|
+
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
277
|
+
plane = clippingPlanes[ i ];
|
|
278
|
+
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
279
|
+
}
|
|
280
|
+
#pragma unroll_loop_end
|
|
281
|
+
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
282
|
+
bool clipped = true;
|
|
283
|
+
#pragma unroll_loop_start
|
|
284
|
+
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
285
|
+
plane = clippingPlanes[ i ];
|
|
286
|
+
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
287
|
+
}
|
|
288
|
+
#pragma unroll_loop_end
|
|
289
|
+
if ( clipped ) discard;
|
|
290
|
+
#endif
|
|
291
|
+
#endif
|
|
292
|
+
#endif`,Tu=`#if NUM_CLIPPING_PLANES > 0
|
|
293
|
+
varying vec3 vClipPosition;
|
|
294
|
+
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
295
|
+
#endif`,Au=`#if NUM_CLIPPING_PLANES > 0
|
|
296
|
+
varying vec3 vClipPosition;
|
|
297
|
+
#endif`,wu=`#if NUM_CLIPPING_PLANES > 0
|
|
298
|
+
vClipPosition = - mvPosition.xyz;
|
|
299
|
+
#endif`,Ru=`#if defined( USE_COLOR_ALPHA )
|
|
300
|
+
diffuseColor *= vColor;
|
|
301
|
+
#elif defined( USE_COLOR )
|
|
302
|
+
diffuseColor.rgb *= vColor;
|
|
303
|
+
#endif`,Cu=`#if defined( USE_COLOR_ALPHA )
|
|
304
|
+
varying vec4 vColor;
|
|
305
|
+
#elif defined( USE_COLOR )
|
|
306
|
+
varying vec3 vColor;
|
|
307
|
+
#endif`,Pu=`#if defined( USE_COLOR_ALPHA )
|
|
308
|
+
varying vec4 vColor;
|
|
309
|
+
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
310
|
+
varying vec3 vColor;
|
|
311
|
+
#endif`,Du=`#if defined( USE_COLOR_ALPHA )
|
|
312
|
+
vColor = vec4( 1.0 );
|
|
313
|
+
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
314
|
+
vColor = vec3( 1.0 );
|
|
315
|
+
#endif
|
|
316
|
+
#ifdef USE_COLOR
|
|
317
|
+
vColor *= color;
|
|
318
|
+
#endif
|
|
319
|
+
#ifdef USE_INSTANCING_COLOR
|
|
320
|
+
vColor.xyz *= instanceColor.xyz;
|
|
321
|
+
#endif
|
|
322
|
+
#ifdef USE_BATCHING_COLOR
|
|
323
|
+
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
324
|
+
vColor.xyz *= batchingColor.xyz;
|
|
325
|
+
#endif`,Lu=`#define PI 3.141592653589793
|
|
326
|
+
#define PI2 6.283185307179586
|
|
327
|
+
#define PI_HALF 1.5707963267948966
|
|
328
|
+
#define RECIPROCAL_PI 0.3183098861837907
|
|
329
|
+
#define RECIPROCAL_PI2 0.15915494309189535
|
|
330
|
+
#define EPSILON 1e-6
|
|
331
|
+
#ifndef saturate
|
|
332
|
+
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
333
|
+
#endif
|
|
334
|
+
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|
335
|
+
float pow2( const in float x ) { return x*x; }
|
|
336
|
+
vec3 pow2( const in vec3 x ) { return x*x; }
|
|
337
|
+
float pow3( const in float x ) { return x*x*x; }
|
|
338
|
+
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
339
|
+
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
340
|
+
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|
341
|
+
highp float rand( const in vec2 uv ) {
|
|
342
|
+
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|
343
|
+
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|
344
|
+
return fract( sin( sn ) * c );
|
|
345
|
+
}
|
|
346
|
+
#ifdef HIGH_PRECISION
|
|
347
|
+
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|
348
|
+
#else
|
|
349
|
+
float precisionSafeLength( vec3 v ) {
|
|
350
|
+
float maxComponent = max3( abs( v ) );
|
|
351
|
+
return length( v / maxComponent ) * maxComponent;
|
|
352
|
+
}
|
|
353
|
+
#endif
|
|
354
|
+
struct IncidentLight {
|
|
355
|
+
vec3 color;
|
|
356
|
+
vec3 direction;
|
|
357
|
+
bool visible;
|
|
358
|
+
};
|
|
359
|
+
struct ReflectedLight {
|
|
360
|
+
vec3 directDiffuse;
|
|
361
|
+
vec3 directSpecular;
|
|
362
|
+
vec3 indirectDiffuse;
|
|
363
|
+
vec3 indirectSpecular;
|
|
364
|
+
};
|
|
365
|
+
#ifdef USE_ALPHAHASH
|
|
366
|
+
varying vec3 vPosition;
|
|
367
|
+
#endif
|
|
368
|
+
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
369
|
+
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
370
|
+
}
|
|
371
|
+
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
372
|
+
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
373
|
+
}
|
|
374
|
+
bool isPerspectiveMatrix( mat4 m ) {
|
|
375
|
+
return m[ 2 ][ 3 ] == - 1.0;
|
|
376
|
+
}
|
|
377
|
+
vec2 equirectUv( in vec3 dir ) {
|
|
378
|
+
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
|
379
|
+
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
|
380
|
+
return vec2( u, v );
|
|
381
|
+
}
|
|
382
|
+
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|
383
|
+
return RECIPROCAL_PI * diffuseColor;
|
|
384
|
+
}
|
|
385
|
+
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
386
|
+
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
387
|
+
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
388
|
+
}
|
|
389
|
+
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
390
|
+
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
391
|
+
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
392
|
+
} // validated`,Iu=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
393
|
+
#define cubeUV_minMipLevel 4.0
|
|
394
|
+
#define cubeUV_minTileSize 16.0
|
|
395
|
+
float getFace( vec3 direction ) {
|
|
396
|
+
vec3 absDirection = abs( direction );
|
|
397
|
+
float face = - 1.0;
|
|
398
|
+
if ( absDirection.x > absDirection.z ) {
|
|
399
|
+
if ( absDirection.x > absDirection.y )
|
|
400
|
+
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
401
|
+
else
|
|
402
|
+
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
403
|
+
} else {
|
|
404
|
+
if ( absDirection.z > absDirection.y )
|
|
405
|
+
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
406
|
+
else
|
|
407
|
+
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
408
|
+
}
|
|
409
|
+
return face;
|
|
410
|
+
}
|
|
411
|
+
vec2 getUV( vec3 direction, float face ) {
|
|
412
|
+
vec2 uv;
|
|
413
|
+
if ( face == 0.0 ) {
|
|
414
|
+
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
415
|
+
} else if ( face == 1.0 ) {
|
|
416
|
+
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
417
|
+
} else if ( face == 2.0 ) {
|
|
418
|
+
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
419
|
+
} else if ( face == 3.0 ) {
|
|
420
|
+
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
421
|
+
} else if ( face == 4.0 ) {
|
|
422
|
+
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
423
|
+
} else {
|
|
424
|
+
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
425
|
+
}
|
|
426
|
+
return 0.5 * ( uv + 1.0 );
|
|
427
|
+
}
|
|
428
|
+
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
429
|
+
float face = getFace( direction );
|
|
430
|
+
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
431
|
+
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
432
|
+
float faceSize = exp2( mipInt );
|
|
433
|
+
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|
434
|
+
if ( face > 2.0 ) {
|
|
435
|
+
uv.y += faceSize;
|
|
436
|
+
face -= 3.0;
|
|
437
|
+
}
|
|
438
|
+
uv.x += face * faceSize;
|
|
439
|
+
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|
440
|
+
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|
441
|
+
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|
442
|
+
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|
443
|
+
#ifdef texture2DGradEXT
|
|
444
|
+
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|
445
|
+
#else
|
|
446
|
+
return texture2D( envMap, uv ).rgb;
|
|
447
|
+
#endif
|
|
448
|
+
}
|
|
449
|
+
#define cubeUV_r0 1.0
|
|
450
|
+
#define cubeUV_m0 - 2.0
|
|
451
|
+
#define cubeUV_r1 0.8
|
|
452
|
+
#define cubeUV_m1 - 1.0
|
|
453
|
+
#define cubeUV_r4 0.4
|
|
454
|
+
#define cubeUV_m4 2.0
|
|
455
|
+
#define cubeUV_r5 0.305
|
|
456
|
+
#define cubeUV_m5 3.0
|
|
457
|
+
#define cubeUV_r6 0.21
|
|
458
|
+
#define cubeUV_m6 4.0
|
|
459
|
+
float roughnessToMip( float roughness ) {
|
|
460
|
+
float mip = 0.0;
|
|
461
|
+
if ( roughness >= cubeUV_r1 ) {
|
|
462
|
+
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
463
|
+
} else if ( roughness >= cubeUV_r4 ) {
|
|
464
|
+
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
465
|
+
} else if ( roughness >= cubeUV_r5 ) {
|
|
466
|
+
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
467
|
+
} else if ( roughness >= cubeUV_r6 ) {
|
|
468
|
+
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
469
|
+
} else {
|
|
470
|
+
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
471
|
+
return mip;
|
|
472
|
+
}
|
|
473
|
+
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
474
|
+
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
475
|
+
float mipF = fract( mip );
|
|
476
|
+
float mipInt = floor( mip );
|
|
477
|
+
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
478
|
+
if ( mipF == 0.0 ) {
|
|
479
|
+
return vec4( color0, 1.0 );
|
|
480
|
+
} else {
|
|
481
|
+
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
482
|
+
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
#endif`,Uu=`vec3 transformedNormal = objectNormal;
|
|
486
|
+
#ifdef USE_TANGENT
|
|
487
|
+
vec3 transformedTangent = objectTangent;
|
|
488
|
+
#endif
|
|
489
|
+
#ifdef USE_BATCHING
|
|
490
|
+
mat3 bm = mat3( batchingMatrix );
|
|
491
|
+
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
492
|
+
transformedNormal = bm * transformedNormal;
|
|
493
|
+
#ifdef USE_TANGENT
|
|
494
|
+
transformedTangent = bm * transformedTangent;
|
|
495
|
+
#endif
|
|
496
|
+
#endif
|
|
497
|
+
#ifdef USE_INSTANCING
|
|
498
|
+
mat3 im = mat3( instanceMatrix );
|
|
499
|
+
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
500
|
+
transformedNormal = im * transformedNormal;
|
|
501
|
+
#ifdef USE_TANGENT
|
|
502
|
+
transformedTangent = im * transformedTangent;
|
|
503
|
+
#endif
|
|
504
|
+
#endif
|
|
505
|
+
transformedNormal = normalMatrix * transformedNormal;
|
|
506
|
+
#ifdef FLIP_SIDED
|
|
507
|
+
transformedNormal = - transformedNormal;
|
|
508
|
+
#endif
|
|
509
|
+
#ifdef USE_TANGENT
|
|
510
|
+
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
511
|
+
#ifdef FLIP_SIDED
|
|
512
|
+
transformedTangent = - transformedTangent;
|
|
513
|
+
#endif
|
|
514
|
+
#endif`,Nu=`#ifdef USE_DISPLACEMENTMAP
|
|
515
|
+
uniform sampler2D displacementMap;
|
|
516
|
+
uniform float displacementScale;
|
|
517
|
+
uniform float displacementBias;
|
|
518
|
+
#endif`,Fu=`#ifdef USE_DISPLACEMENTMAP
|
|
519
|
+
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
520
|
+
#endif`,Ou=`#ifdef USE_EMISSIVEMAP
|
|
521
|
+
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
522
|
+
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
523
|
+
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
524
|
+
#endif
|
|
525
|
+
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
526
|
+
#endif`,Bu=`#ifdef USE_EMISSIVEMAP
|
|
527
|
+
uniform sampler2D emissiveMap;
|
|
528
|
+
#endif`,zu="gl_FragColor = linearToOutputTexel( gl_FragColor );",Vu=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
529
|
+
return value;
|
|
530
|
+
}
|
|
531
|
+
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
532
|
+
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 );
|
|
533
|
+
}
|
|
534
|
+
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
535
|
+
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 );
|
|
536
|
+
}`,ku=`#ifdef USE_ENVMAP
|
|
537
|
+
#ifdef ENV_WORLDPOS
|
|
538
|
+
vec3 cameraToFrag;
|
|
539
|
+
if ( isOrthographic ) {
|
|
540
|
+
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
541
|
+
} else {
|
|
542
|
+
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|
543
|
+
}
|
|
544
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
545
|
+
#ifdef ENVMAP_MODE_REFLECTION
|
|
546
|
+
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|
547
|
+
#else
|
|
548
|
+
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|
549
|
+
#endif
|
|
550
|
+
#else
|
|
551
|
+
vec3 reflectVec = vReflect;
|
|
552
|
+
#endif
|
|
553
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
554
|
+
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
555
|
+
#else
|
|
556
|
+
vec4 envColor = vec4( 0.0 );
|
|
557
|
+
#endif
|
|
558
|
+
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|
559
|
+
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|
560
|
+
#elif defined( ENVMAP_BLENDING_MIX )
|
|
561
|
+
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|
562
|
+
#elif defined( ENVMAP_BLENDING_ADD )
|
|
563
|
+
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
564
|
+
#endif
|
|
565
|
+
#endif`,Gu=`#ifdef USE_ENVMAP
|
|
566
|
+
uniform float envMapIntensity;
|
|
567
|
+
uniform float flipEnvMap;
|
|
568
|
+
uniform mat3 envMapRotation;
|
|
569
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
570
|
+
uniform samplerCube envMap;
|
|
571
|
+
#else
|
|
572
|
+
uniform sampler2D envMap;
|
|
573
|
+
#endif
|
|
574
|
+
#endif`,Hu=`#ifdef USE_ENVMAP
|
|
575
|
+
uniform float reflectivity;
|
|
576
|
+
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
577
|
+
#define ENV_WORLDPOS
|
|
578
|
+
#endif
|
|
579
|
+
#ifdef ENV_WORLDPOS
|
|
580
|
+
varying vec3 vWorldPosition;
|
|
581
|
+
uniform float refractionRatio;
|
|
582
|
+
#else
|
|
583
|
+
varying vec3 vReflect;
|
|
584
|
+
#endif
|
|
585
|
+
#endif`,Wu=`#ifdef USE_ENVMAP
|
|
586
|
+
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
587
|
+
#define ENV_WORLDPOS
|
|
588
|
+
#endif
|
|
589
|
+
#ifdef ENV_WORLDPOS
|
|
590
|
+
|
|
591
|
+
varying vec3 vWorldPosition;
|
|
592
|
+
#else
|
|
593
|
+
varying vec3 vReflect;
|
|
594
|
+
uniform float refractionRatio;
|
|
595
|
+
#endif
|
|
596
|
+
#endif`,Xu=`#ifdef USE_ENVMAP
|
|
597
|
+
#ifdef ENV_WORLDPOS
|
|
598
|
+
vWorldPosition = worldPosition.xyz;
|
|
599
|
+
#else
|
|
600
|
+
vec3 cameraToVertex;
|
|
601
|
+
if ( isOrthographic ) {
|
|
602
|
+
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
603
|
+
} else {
|
|
604
|
+
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
|
605
|
+
}
|
|
606
|
+
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
607
|
+
#ifdef ENVMAP_MODE_REFLECTION
|
|
608
|
+
vReflect = reflect( cameraToVertex, worldNormal );
|
|
609
|
+
#else
|
|
610
|
+
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
611
|
+
#endif
|
|
612
|
+
#endif
|
|
613
|
+
#endif`,qu=`#ifdef USE_FOG
|
|
614
|
+
vFogDepth = - mvPosition.z;
|
|
615
|
+
#endif`,Yu=`#ifdef USE_FOG
|
|
616
|
+
varying float vFogDepth;
|
|
617
|
+
#endif`,Ku=`#ifdef USE_FOG
|
|
618
|
+
#ifdef FOG_EXP2
|
|
619
|
+
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
620
|
+
#else
|
|
621
|
+
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
622
|
+
#endif
|
|
623
|
+
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
624
|
+
#endif`,$u=`#ifdef USE_FOG
|
|
625
|
+
uniform vec3 fogColor;
|
|
626
|
+
varying float vFogDepth;
|
|
627
|
+
#ifdef FOG_EXP2
|
|
628
|
+
uniform float fogDensity;
|
|
629
|
+
#else
|
|
630
|
+
uniform float fogNear;
|
|
631
|
+
uniform float fogFar;
|
|
632
|
+
#endif
|
|
633
|
+
#endif`,Zu=`#ifdef USE_GRADIENTMAP
|
|
634
|
+
uniform sampler2D gradientMap;
|
|
635
|
+
#endif
|
|
636
|
+
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
637
|
+
float dotNL = dot( normal, lightDirection );
|
|
638
|
+
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
|
639
|
+
#ifdef USE_GRADIENTMAP
|
|
640
|
+
return vec3( texture2D( gradientMap, coord ).r );
|
|
641
|
+
#else
|
|
642
|
+
vec2 fw = fwidth( coord ) * 0.5;
|
|
643
|
+
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
644
|
+
#endif
|
|
645
|
+
}`,ju=`#ifdef USE_LIGHTMAP
|
|
646
|
+
uniform sampler2D lightMap;
|
|
647
|
+
uniform float lightMapIntensity;
|
|
648
|
+
#endif`,Ju=`LambertMaterial material;
|
|
649
|
+
material.diffuseColor = diffuseColor.rgb;
|
|
650
|
+
material.specularStrength = specularStrength;`,Qu=`varying vec3 vViewPosition;
|
|
651
|
+
struct LambertMaterial {
|
|
652
|
+
vec3 diffuseColor;
|
|
653
|
+
float specularStrength;
|
|
654
|
+
};
|
|
655
|
+
void 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 ) {
|
|
656
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
657
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
658
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
659
|
+
}
|
|
660
|
+
void 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 ) {
|
|
661
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
662
|
+
}
|
|
663
|
+
#define RE_Direct RE_Direct_Lambert
|
|
664
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ed=`uniform bool receiveShadow;
|
|
665
|
+
uniform vec3 ambientLightColor;
|
|
666
|
+
#if defined( USE_LIGHT_PROBES )
|
|
667
|
+
uniform vec3 lightProbe[ 9 ];
|
|
668
|
+
#endif
|
|
669
|
+
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
670
|
+
float x = normal.x, y = normal.y, z = normal.z;
|
|
671
|
+
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
672
|
+
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
673
|
+
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
674
|
+
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
675
|
+
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
676
|
+
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
677
|
+
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
678
|
+
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
679
|
+
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
680
|
+
return result;
|
|
681
|
+
}
|
|
682
|
+
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
683
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
684
|
+
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
685
|
+
return irradiance;
|
|
686
|
+
}
|
|
687
|
+
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|
688
|
+
vec3 irradiance = ambientLightColor;
|
|
689
|
+
return irradiance;
|
|
690
|
+
}
|
|
691
|
+
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|
692
|
+
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
693
|
+
if ( cutoffDistance > 0.0 ) {
|
|
694
|
+
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
695
|
+
}
|
|
696
|
+
return distanceFalloff;
|
|
697
|
+
}
|
|
698
|
+
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
699
|
+
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|
700
|
+
}
|
|
701
|
+
#if NUM_DIR_LIGHTS > 0
|
|
702
|
+
struct DirectionalLight {
|
|
703
|
+
vec3 direction;
|
|
704
|
+
vec3 color;
|
|
705
|
+
};
|
|
706
|
+
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
707
|
+
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
|
708
|
+
light.color = directionalLight.color;
|
|
709
|
+
light.direction = directionalLight.direction;
|
|
710
|
+
light.visible = true;
|
|
711
|
+
}
|
|
712
|
+
#endif
|
|
713
|
+
#if NUM_POINT_LIGHTS > 0
|
|
714
|
+
struct PointLight {
|
|
715
|
+
vec3 position;
|
|
716
|
+
vec3 color;
|
|
717
|
+
float distance;
|
|
718
|
+
float decay;
|
|
719
|
+
};
|
|
720
|
+
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
721
|
+
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
722
|
+
vec3 lVector = pointLight.position - geometryPosition;
|
|
723
|
+
light.direction = normalize( lVector );
|
|
724
|
+
float lightDistance = length( lVector );
|
|
725
|
+
light.color = pointLight.color;
|
|
726
|
+
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
727
|
+
light.visible = ( light.color != vec3( 0.0 ) );
|
|
728
|
+
}
|
|
729
|
+
#endif
|
|
730
|
+
#if NUM_SPOT_LIGHTS > 0
|
|
731
|
+
struct SpotLight {
|
|
732
|
+
vec3 position;
|
|
733
|
+
vec3 direction;
|
|
734
|
+
vec3 color;
|
|
735
|
+
float distance;
|
|
736
|
+
float decay;
|
|
737
|
+
float coneCos;
|
|
738
|
+
float penumbraCos;
|
|
739
|
+
};
|
|
740
|
+
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
741
|
+
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
742
|
+
vec3 lVector = spotLight.position - geometryPosition;
|
|
743
|
+
light.direction = normalize( lVector );
|
|
744
|
+
float angleCos = dot( light.direction, spotLight.direction );
|
|
745
|
+
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|
746
|
+
if ( spotAttenuation > 0.0 ) {
|
|
747
|
+
float lightDistance = length( lVector );
|
|
748
|
+
light.color = spotLight.color * spotAttenuation;
|
|
749
|
+
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|
750
|
+
light.visible = ( light.color != vec3( 0.0 ) );
|
|
751
|
+
} else {
|
|
752
|
+
light.color = vec3( 0.0 );
|
|
753
|
+
light.visible = false;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
#endif
|
|
757
|
+
#if NUM_RECT_AREA_LIGHTS > 0
|
|
758
|
+
struct RectAreaLight {
|
|
759
|
+
vec3 color;
|
|
760
|
+
vec3 position;
|
|
761
|
+
vec3 halfWidth;
|
|
762
|
+
vec3 halfHeight;
|
|
763
|
+
};
|
|
764
|
+
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|
765
|
+
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|
766
|
+
#endif
|
|
767
|
+
#if NUM_HEMI_LIGHTS > 0
|
|
768
|
+
struct HemisphereLight {
|
|
769
|
+
vec3 direction;
|
|
770
|
+
vec3 skyColor;
|
|
771
|
+
vec3 groundColor;
|
|
772
|
+
};
|
|
773
|
+
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|
774
|
+
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|
775
|
+
float dotNL = dot( normal, hemiLight.direction );
|
|
776
|
+
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|
777
|
+
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
778
|
+
return irradiance;
|
|
779
|
+
}
|
|
780
|
+
#endif`,td=`#ifdef USE_ENVMAP
|
|
781
|
+
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
782
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
783
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
784
|
+
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
|
785
|
+
return PI * envMapColor.rgb * envMapIntensity;
|
|
786
|
+
#else
|
|
787
|
+
return vec3( 0.0 );
|
|
788
|
+
#endif
|
|
789
|
+
}
|
|
790
|
+
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
791
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
792
|
+
vec3 reflectVec = reflect( - viewDir, normal );
|
|
793
|
+
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
|
|
794
|
+
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
795
|
+
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
|
796
|
+
return envMapColor.rgb * envMapIntensity;
|
|
797
|
+
#else
|
|
798
|
+
return vec3( 0.0 );
|
|
799
|
+
#endif
|
|
800
|
+
}
|
|
801
|
+
#ifdef USE_ANISOTROPY
|
|
802
|
+
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
803
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
804
|
+
vec3 bentNormal = cross( bitangent, viewDir );
|
|
805
|
+
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
806
|
+
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
807
|
+
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|
808
|
+
#else
|
|
809
|
+
return vec3( 0.0 );
|
|
810
|
+
#endif
|
|
811
|
+
}
|
|
812
|
+
#endif
|
|
813
|
+
#endif`,nd=`ToonMaterial material;
|
|
814
|
+
material.diffuseColor = diffuseColor.rgb;`,id=`varying vec3 vViewPosition;
|
|
815
|
+
struct ToonMaterial {
|
|
816
|
+
vec3 diffuseColor;
|
|
817
|
+
};
|
|
818
|
+
void 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 ) {
|
|
819
|
+
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|
820
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
821
|
+
}
|
|
822
|
+
void 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 ) {
|
|
823
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
824
|
+
}
|
|
825
|
+
#define RE_Direct RE_Direct_Toon
|
|
826
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,rd=`BlinnPhongMaterial material;
|
|
827
|
+
material.diffuseColor = diffuseColor.rgb;
|
|
828
|
+
material.specularColor = specular;
|
|
829
|
+
material.specularShininess = shininess;
|
|
830
|
+
material.specularStrength = specularStrength;`,sd=`varying vec3 vViewPosition;
|
|
831
|
+
struct BlinnPhongMaterial {
|
|
832
|
+
vec3 diffuseColor;
|
|
833
|
+
vec3 specularColor;
|
|
834
|
+
float specularShininess;
|
|
835
|
+
float specularStrength;
|
|
836
|
+
};
|
|
837
|
+
void 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 ) {
|
|
838
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
839
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
840
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
841
|
+
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
842
|
+
}
|
|
843
|
+
void 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 ) {
|
|
844
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
845
|
+
}
|
|
846
|
+
#define RE_Direct RE_Direct_BlinnPhong
|
|
847
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ad=`PhysicalMaterial material;
|
|
848
|
+
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
849
|
+
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
850
|
+
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
851
|
+
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
852
|
+
material.roughness = min( material.roughness, 1.0 );
|
|
853
|
+
#ifdef IOR
|
|
854
|
+
material.ior = ior;
|
|
855
|
+
#ifdef USE_SPECULAR
|
|
856
|
+
float specularIntensityFactor = specularIntensity;
|
|
857
|
+
vec3 specularColorFactor = specularColor;
|
|
858
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
859
|
+
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|
860
|
+
#endif
|
|
861
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
862
|
+
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|
863
|
+
#endif
|
|
864
|
+
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
865
|
+
#else
|
|
866
|
+
float specularIntensityFactor = 1.0;
|
|
867
|
+
vec3 specularColorFactor = vec3( 1.0 );
|
|
868
|
+
material.specularF90 = 1.0;
|
|
869
|
+
#endif
|
|
870
|
+
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
871
|
+
#else
|
|
872
|
+
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|
873
|
+
material.specularF90 = 1.0;
|
|
874
|
+
#endif
|
|
875
|
+
#ifdef USE_CLEARCOAT
|
|
876
|
+
material.clearcoat = clearcoat;
|
|
877
|
+
material.clearcoatRoughness = clearcoatRoughness;
|
|
878
|
+
material.clearcoatF0 = vec3( 0.04 );
|
|
879
|
+
material.clearcoatF90 = 1.0;
|
|
880
|
+
#ifdef USE_CLEARCOATMAP
|
|
881
|
+
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
|
882
|
+
#endif
|
|
883
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
884
|
+
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
885
|
+
#endif
|
|
886
|
+
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
887
|
+
material.clearcoatRoughness += geometryRoughness;
|
|
888
|
+
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
889
|
+
#endif
|
|
890
|
+
#ifdef USE_DISPERSION
|
|
891
|
+
material.dispersion = dispersion;
|
|
892
|
+
#endif
|
|
893
|
+
#ifdef USE_IRIDESCENCE
|
|
894
|
+
material.iridescence = iridescence;
|
|
895
|
+
material.iridescenceIOR = iridescenceIOR;
|
|
896
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
897
|
+
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|
898
|
+
#endif
|
|
899
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
900
|
+
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|
901
|
+
#else
|
|
902
|
+
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|
903
|
+
#endif
|
|
904
|
+
#endif
|
|
905
|
+
#ifdef USE_SHEEN
|
|
906
|
+
material.sheenColor = sheenColor;
|
|
907
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
908
|
+
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|
909
|
+
#endif
|
|
910
|
+
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|
911
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
912
|
+
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|
913
|
+
#endif
|
|
914
|
+
#endif
|
|
915
|
+
#ifdef USE_ANISOTROPY
|
|
916
|
+
#ifdef USE_ANISOTROPYMAP
|
|
917
|
+
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
918
|
+
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
919
|
+
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
920
|
+
#else
|
|
921
|
+
vec2 anisotropyV = anisotropyVector;
|
|
922
|
+
#endif
|
|
923
|
+
material.anisotropy = length( anisotropyV );
|
|
924
|
+
if( material.anisotropy == 0.0 ) {
|
|
925
|
+
anisotropyV = vec2( 1.0, 0.0 );
|
|
926
|
+
} else {
|
|
927
|
+
anisotropyV /= material.anisotropy;
|
|
928
|
+
material.anisotropy = saturate( material.anisotropy );
|
|
929
|
+
}
|
|
930
|
+
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
931
|
+
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
932
|
+
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
933
|
+
#endif`,od=`uniform sampler2D dfgLUT;
|
|
934
|
+
struct PhysicalMaterial {
|
|
935
|
+
vec3 diffuseColor;
|
|
936
|
+
float roughness;
|
|
937
|
+
vec3 specularColor;
|
|
938
|
+
float specularF90;
|
|
939
|
+
float dispersion;
|
|
940
|
+
#ifdef USE_CLEARCOAT
|
|
941
|
+
float clearcoat;
|
|
942
|
+
float clearcoatRoughness;
|
|
943
|
+
vec3 clearcoatF0;
|
|
944
|
+
float clearcoatF90;
|
|
945
|
+
#endif
|
|
946
|
+
#ifdef USE_IRIDESCENCE
|
|
947
|
+
float iridescence;
|
|
948
|
+
float iridescenceIOR;
|
|
949
|
+
float iridescenceThickness;
|
|
950
|
+
vec3 iridescenceFresnel;
|
|
951
|
+
vec3 iridescenceF0;
|
|
952
|
+
#endif
|
|
953
|
+
#ifdef USE_SHEEN
|
|
954
|
+
vec3 sheenColor;
|
|
955
|
+
float sheenRoughness;
|
|
956
|
+
#endif
|
|
957
|
+
#ifdef IOR
|
|
958
|
+
float ior;
|
|
959
|
+
#endif
|
|
960
|
+
#ifdef USE_TRANSMISSION
|
|
961
|
+
float transmission;
|
|
962
|
+
float transmissionAlpha;
|
|
963
|
+
float thickness;
|
|
964
|
+
float attenuationDistance;
|
|
965
|
+
vec3 attenuationColor;
|
|
966
|
+
#endif
|
|
967
|
+
#ifdef USE_ANISOTROPY
|
|
968
|
+
float anisotropy;
|
|
969
|
+
float alphaT;
|
|
970
|
+
vec3 anisotropyT;
|
|
971
|
+
vec3 anisotropyB;
|
|
972
|
+
#endif
|
|
973
|
+
};
|
|
974
|
+
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
975
|
+
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
976
|
+
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
977
|
+
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
978
|
+
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
979
|
+
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
980
|
+
float x2 = x * x;
|
|
981
|
+
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
982
|
+
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
983
|
+
}
|
|
984
|
+
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
985
|
+
float a2 = pow2( alpha );
|
|
986
|
+
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
987
|
+
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
988
|
+
return 0.5 / max( gv + gl, EPSILON );
|
|
989
|
+
}
|
|
990
|
+
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
991
|
+
float a2 = pow2( alpha );
|
|
992
|
+
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
993
|
+
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
994
|
+
}
|
|
995
|
+
#ifdef USE_ANISOTROPY
|
|
996
|
+
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 ) {
|
|
997
|
+
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
998
|
+
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
999
|
+
float v = 0.5 / ( gv + gl );
|
|
1000
|
+
return saturate(v);
|
|
1001
|
+
}
|
|
1002
|
+
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
1003
|
+
float a2 = alphaT * alphaB;
|
|
1004
|
+
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
1005
|
+
highp float v2 = dot( v, v );
|
|
1006
|
+
float w2 = a2 / v2;
|
|
1007
|
+
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
1008
|
+
}
|
|
1009
|
+
#endif
|
|
1010
|
+
#ifdef USE_CLEARCOAT
|
|
1011
|
+
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
1012
|
+
vec3 f0 = material.clearcoatF0;
|
|
1013
|
+
float f90 = material.clearcoatF90;
|
|
1014
|
+
float roughness = material.clearcoatRoughness;
|
|
1015
|
+
float alpha = pow2( roughness );
|
|
1016
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1017
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1018
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1019
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1020
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
1021
|
+
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
1022
|
+
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
1023
|
+
float D = D_GGX( alpha, dotNH );
|
|
1024
|
+
return F * ( V * D );
|
|
1025
|
+
}
|
|
1026
|
+
#endif
|
|
1027
|
+
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
1028
|
+
vec3 f0 = material.specularColor;
|
|
1029
|
+
float f90 = material.specularF90;
|
|
1030
|
+
float roughness = material.roughness;
|
|
1031
|
+
float alpha = pow2( roughness );
|
|
1032
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1033
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1034
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1035
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1036
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
1037
|
+
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
1038
|
+
#ifdef USE_IRIDESCENCE
|
|
1039
|
+
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|
1040
|
+
#endif
|
|
1041
|
+
#ifdef USE_ANISOTROPY
|
|
1042
|
+
float dotTL = dot( material.anisotropyT, lightDir );
|
|
1043
|
+
float dotTV = dot( material.anisotropyT, viewDir );
|
|
1044
|
+
float dotTH = dot( material.anisotropyT, halfDir );
|
|
1045
|
+
float dotBL = dot( material.anisotropyB, lightDir );
|
|
1046
|
+
float dotBV = dot( material.anisotropyB, viewDir );
|
|
1047
|
+
float dotBH = dot( material.anisotropyB, halfDir );
|
|
1048
|
+
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
1049
|
+
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
1050
|
+
#else
|
|
1051
|
+
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
1052
|
+
float D = D_GGX( alpha, dotNH );
|
|
1053
|
+
#endif
|
|
1054
|
+
return F * ( V * D );
|
|
1055
|
+
}
|
|
1056
|
+
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
1057
|
+
const float LUT_SIZE = 64.0;
|
|
1058
|
+
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
1059
|
+
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
1060
|
+
float dotNV = saturate( dot( N, V ) );
|
|
1061
|
+
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
1062
|
+
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
1063
|
+
return uv;
|
|
1064
|
+
}
|
|
1065
|
+
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
1066
|
+
float l = length( f );
|
|
1067
|
+
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
1068
|
+
}
|
|
1069
|
+
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
1070
|
+
float x = dot( v1, v2 );
|
|
1071
|
+
float y = abs( x );
|
|
1072
|
+
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
1073
|
+
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
1074
|
+
float v = a / b;
|
|
1075
|
+
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
1076
|
+
return cross( v1, v2 ) * theta_sintheta;
|
|
1077
|
+
}
|
|
1078
|
+
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
1079
|
+
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
1080
|
+
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
1081
|
+
vec3 lightNormal = cross( v1, v2 );
|
|
1082
|
+
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
1083
|
+
vec3 T1, T2;
|
|
1084
|
+
T1 = normalize( V - N * dot( V, N ) );
|
|
1085
|
+
T2 = - cross( N, T1 );
|
|
1086
|
+
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
|
|
1087
|
+
vec3 coords[ 4 ];
|
|
1088
|
+
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|
1089
|
+
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|
1090
|
+
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|
1091
|
+
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|
1092
|
+
coords[ 0 ] = normalize( coords[ 0 ] );
|
|
1093
|
+
coords[ 1 ] = normalize( coords[ 1 ] );
|
|
1094
|
+
coords[ 2 ] = normalize( coords[ 2 ] );
|
|
1095
|
+
coords[ 3 ] = normalize( coords[ 3 ] );
|
|
1096
|
+
vec3 vectorFormFactor = vec3( 0.0 );
|
|
1097
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|
1098
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|
1099
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|
1100
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|
1101
|
+
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
1102
|
+
return vec3( result );
|
|
1103
|
+
}
|
|
1104
|
+
#if defined( USE_SHEEN )
|
|
1105
|
+
float D_Charlie( float roughness, float dotNH ) {
|
|
1106
|
+
float alpha = pow2( roughness );
|
|
1107
|
+
float invAlpha = 1.0 / alpha;
|
|
1108
|
+
float cos2h = dotNH * dotNH;
|
|
1109
|
+
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
1110
|
+
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
1111
|
+
}
|
|
1112
|
+
float V_Neubelt( float dotNV, float dotNL ) {
|
|
1113
|
+
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
1114
|
+
}
|
|
1115
|
+
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
1116
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1117
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1118
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1119
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1120
|
+
float D = D_Charlie( sheenRoughness, dotNH );
|
|
1121
|
+
float V = V_Neubelt( dotNV, dotNL );
|
|
1122
|
+
return sheenColor * ( D * V );
|
|
1123
|
+
}
|
|
1124
|
+
#endif
|
|
1125
|
+
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
1126
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1127
|
+
float r2 = roughness * roughness;
|
|
1128
|
+
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
1129
|
+
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
1130
|
+
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
1131
|
+
return saturate( DG * RECIPROCAL_PI );
|
|
1132
|
+
}
|
|
1133
|
+
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
1134
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1135
|
+
vec2 uv = vec2( roughness, dotNV );
|
|
1136
|
+
return texture2D( dfgLUT, uv ).rg;
|
|
1137
|
+
}
|
|
1138
|
+
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
1139
|
+
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
1140
|
+
return specularColor * fab.x + specularF90 * fab.y;
|
|
1141
|
+
}
|
|
1142
|
+
#ifdef USE_IRIDESCENCE
|
|
1143
|
+
void 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 ) {
|
|
1144
|
+
#else
|
|
1145
|
+
void 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 ) {
|
|
1146
|
+
#endif
|
|
1147
|
+
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
1148
|
+
#ifdef USE_IRIDESCENCE
|
|
1149
|
+
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
|
1150
|
+
#else
|
|
1151
|
+
vec3 Fr = specularColor;
|
|
1152
|
+
#endif
|
|
1153
|
+
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
|
1154
|
+
float Ess = fab.x + fab.y;
|
|
1155
|
+
float Ems = 1.0 - Ess;
|
|
1156
|
+
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|
1157
|
+
singleScatter += FssEss;
|
|
1158
|
+
multiScatter += Fms * Ems;
|
|
1159
|
+
}
|
|
1160
|
+
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
1161
|
+
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
|
|
1162
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1163
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1164
|
+
vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
|
|
1165
|
+
vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
|
|
1166
|
+
vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
|
|
1167
|
+
vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
|
|
1168
|
+
float Ess_V = dfgV.x + dfgV.y;
|
|
1169
|
+
float Ess_L = dfgL.x + dfgL.y;
|
|
1170
|
+
float Ems_V = 1.0 - Ess_V;
|
|
1171
|
+
float Ems_L = 1.0 - Ess_L;
|
|
1172
|
+
vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
|
|
1173
|
+
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
|
|
1174
|
+
float compensationFactor = Ems_V * Ems_L;
|
|
1175
|
+
vec3 multiScatter = Fms * compensationFactor;
|
|
1176
|
+
return singleScatter + multiScatter;
|
|
1177
|
+
}
|
|
1178
|
+
#if NUM_RECT_AREA_LIGHTS > 0
|
|
1179
|
+
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 ) {
|
|
1180
|
+
vec3 normal = geometryNormal;
|
|
1181
|
+
vec3 viewDir = geometryViewDir;
|
|
1182
|
+
vec3 position = geometryPosition;
|
|
1183
|
+
vec3 lightPos = rectAreaLight.position;
|
|
1184
|
+
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
1185
|
+
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
1186
|
+
vec3 lightColor = rectAreaLight.color;
|
|
1187
|
+
float roughness = material.roughness;
|
|
1188
|
+
vec3 rectCoords[ 4 ];
|
|
1189
|
+
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
1190
|
+
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
1191
|
+
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
1192
|
+
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
1193
|
+
vec4 t1 = texture2D( ltc_1, uv );
|
|
1194
|
+
vec4 t2 = texture2D( ltc_2, uv );
|
|
1195
|
+
mat3 mInv = mat3(
|
|
1196
|
+
vec3( t1.x, 0, t1.y ),
|
|
1197
|
+
vec3( 0, 1, 0 ),
|
|
1198
|
+
vec3( t1.z, 0, t1.w )
|
|
1199
|
+
);
|
|
1200
|
+
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|
1201
|
+
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
1202
|
+
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
1203
|
+
}
|
|
1204
|
+
#endif
|
|
1205
|
+
void 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 ) {
|
|
1206
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
1207
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
1208
|
+
#ifdef USE_CLEARCOAT
|
|
1209
|
+
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
1210
|
+
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
1211
|
+
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
1212
|
+
#endif
|
|
1213
|
+
#ifdef USE_SHEEN
|
|
1214
|
+
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
1215
|
+
#endif
|
|
1216
|
+
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
1217
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1218
|
+
}
|
|
1219
|
+
void 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 ) {
|
|
1220
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1221
|
+
}
|
|
1222
|
+
void 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) {
|
|
1223
|
+
#ifdef USE_CLEARCOAT
|
|
1224
|
+
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
1225
|
+
#endif
|
|
1226
|
+
#ifdef USE_SHEEN
|
|
1227
|
+
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
1228
|
+
#endif
|
|
1229
|
+
vec3 singleScattering = vec3( 0.0 );
|
|
1230
|
+
vec3 multiScattering = vec3( 0.0 );
|
|
1231
|
+
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
1232
|
+
#ifdef USE_IRIDESCENCE
|
|
1233
|
+
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
1234
|
+
#else
|
|
1235
|
+
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
1236
|
+
#endif
|
|
1237
|
+
vec3 totalScattering = singleScattering + multiScattering;
|
|
1238
|
+
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|
1239
|
+
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|
1240
|
+
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
1241
|
+
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|
1242
|
+
}
|
|
1243
|
+
#define RE_Direct RE_Direct_Physical
|
|
1244
|
+
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|
1245
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|
1246
|
+
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1247
|
+
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1248
|
+
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1249
|
+
}`,cd=`
|
|
1250
|
+
vec3 geometryPosition = - vViewPosition;
|
|
1251
|
+
vec3 geometryNormal = normal;
|
|
1252
|
+
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
1253
|
+
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
1254
|
+
#ifdef USE_CLEARCOAT
|
|
1255
|
+
geometryClearcoatNormal = clearcoatNormal;
|
|
1256
|
+
#endif
|
|
1257
|
+
#ifdef USE_IRIDESCENCE
|
|
1258
|
+
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
1259
|
+
if ( material.iridescenceThickness == 0.0 ) {
|
|
1260
|
+
material.iridescence = 0.0;
|
|
1261
|
+
} else {
|
|
1262
|
+
material.iridescence = saturate( material.iridescence );
|
|
1263
|
+
}
|
|
1264
|
+
if ( material.iridescence > 0.0 ) {
|
|
1265
|
+
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
1266
|
+
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
1267
|
+
}
|
|
1268
|
+
#endif
|
|
1269
|
+
IncidentLight directLight;
|
|
1270
|
+
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1271
|
+
PointLight pointLight;
|
|
1272
|
+
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|
1273
|
+
PointLightShadow pointLightShadow;
|
|
1274
|
+
#endif
|
|
1275
|
+
#pragma unroll_loop_start
|
|
1276
|
+
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
1277
|
+
pointLight = pointLights[ i ];
|
|
1278
|
+
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|
1279
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
1280
|
+
pointLightShadow = pointLightShadows[ i ];
|
|
1281
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
1282
|
+
#endif
|
|
1283
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1284
|
+
}
|
|
1285
|
+
#pragma unroll_loop_end
|
|
1286
|
+
#endif
|
|
1287
|
+
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1288
|
+
SpotLight spotLight;
|
|
1289
|
+
vec4 spotColor;
|
|
1290
|
+
vec3 spotLightCoord;
|
|
1291
|
+
bool inSpotLightMap;
|
|
1292
|
+
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1293
|
+
SpotLightShadow spotLightShadow;
|
|
1294
|
+
#endif
|
|
1295
|
+
#pragma unroll_loop_start
|
|
1296
|
+
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
1297
|
+
spotLight = spotLights[ i ];
|
|
1298
|
+
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
1299
|
+
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
1300
|
+
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
1301
|
+
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1302
|
+
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
1303
|
+
#else
|
|
1304
|
+
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
1305
|
+
#endif
|
|
1306
|
+
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
1307
|
+
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
1308
|
+
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
1309
|
+
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
1310
|
+
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
1311
|
+
#endif
|
|
1312
|
+
#undef SPOT_LIGHT_MAP_INDEX
|
|
1313
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1314
|
+
spotLightShadow = spotLightShadows[ i ];
|
|
1315
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
1316
|
+
#endif
|
|
1317
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1318
|
+
}
|
|
1319
|
+
#pragma unroll_loop_end
|
|
1320
|
+
#endif
|
|
1321
|
+
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1322
|
+
DirectionalLight directionalLight;
|
|
1323
|
+
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
1324
|
+
DirectionalLightShadow directionalLightShadow;
|
|
1325
|
+
#endif
|
|
1326
|
+
#pragma unroll_loop_start
|
|
1327
|
+
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
1328
|
+
directionalLight = directionalLights[ i ];
|
|
1329
|
+
getDirectionalLightInfo( directionalLight, directLight );
|
|
1330
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
1331
|
+
directionalLightShadow = directionalLightShadows[ i ];
|
|
1332
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
1333
|
+
#endif
|
|
1334
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1335
|
+
}
|
|
1336
|
+
#pragma unroll_loop_end
|
|
1337
|
+
#endif
|
|
1338
|
+
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
1339
|
+
RectAreaLight rectAreaLight;
|
|
1340
|
+
#pragma unroll_loop_start
|
|
1341
|
+
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
1342
|
+
rectAreaLight = rectAreaLights[ i ];
|
|
1343
|
+
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1344
|
+
}
|
|
1345
|
+
#pragma unroll_loop_end
|
|
1346
|
+
#endif
|
|
1347
|
+
#if defined( RE_IndirectDiffuse )
|
|
1348
|
+
vec3 iblIrradiance = vec3( 0.0 );
|
|
1349
|
+
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
1350
|
+
#if defined( USE_LIGHT_PROBES )
|
|
1351
|
+
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
1352
|
+
#endif
|
|
1353
|
+
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
1354
|
+
#pragma unroll_loop_start
|
|
1355
|
+
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
1356
|
+
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
1357
|
+
}
|
|
1358
|
+
#pragma unroll_loop_end
|
|
1359
|
+
#endif
|
|
1360
|
+
#endif
|
|
1361
|
+
#if defined( RE_IndirectSpecular )
|
|
1362
|
+
vec3 radiance = vec3( 0.0 );
|
|
1363
|
+
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1364
|
+
#endif`,ld=`#if defined( RE_IndirectDiffuse )
|
|
1365
|
+
#ifdef USE_LIGHTMAP
|
|
1366
|
+
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1367
|
+
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
1368
|
+
irradiance += lightMapIrradiance;
|
|
1369
|
+
#endif
|
|
1370
|
+
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
1371
|
+
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|
1372
|
+
#endif
|
|
1373
|
+
#endif
|
|
1374
|
+
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
1375
|
+
#ifdef USE_ANISOTROPY
|
|
1376
|
+
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
1377
|
+
#else
|
|
1378
|
+
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|
1379
|
+
#endif
|
|
1380
|
+
#ifdef USE_CLEARCOAT
|
|
1381
|
+
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1382
|
+
#endif
|
|
1383
|
+
#endif`,hd=`#if defined( RE_IndirectDiffuse )
|
|
1384
|
+
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1385
|
+
#endif
|
|
1386
|
+
#if defined( RE_IndirectSpecular )
|
|
1387
|
+
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1388
|
+
#endif`,ud=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1389
|
+
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1390
|
+
#endif`,dd=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1391
|
+
uniform float logDepthBufFC;
|
|
1392
|
+
varying float vFragDepth;
|
|
1393
|
+
varying float vIsPerspective;
|
|
1394
|
+
#endif`,fd=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1395
|
+
varying float vFragDepth;
|
|
1396
|
+
varying float vIsPerspective;
|
|
1397
|
+
#endif`,pd=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1398
|
+
vFragDepth = 1.0 + gl_Position.w;
|
|
1399
|
+
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1400
|
+
#endif`,md=`#ifdef USE_MAP
|
|
1401
|
+
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1402
|
+
#ifdef DECODE_VIDEO_TEXTURE
|
|
1403
|
+
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1404
|
+
#endif
|
|
1405
|
+
diffuseColor *= sampledDiffuseColor;
|
|
1406
|
+
#endif`,xd=`#ifdef USE_MAP
|
|
1407
|
+
uniform sampler2D map;
|
|
1408
|
+
#endif`,gd=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1409
|
+
#if defined( USE_POINTS_UV )
|
|
1410
|
+
vec2 uv = vUv;
|
|
1411
|
+
#else
|
|
1412
|
+
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|
1413
|
+
#endif
|
|
1414
|
+
#endif
|
|
1415
|
+
#ifdef USE_MAP
|
|
1416
|
+
diffuseColor *= texture2D( map, uv );
|
|
1417
|
+
#endif
|
|
1418
|
+
#ifdef USE_ALPHAMAP
|
|
1419
|
+
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1420
|
+
#endif`,_d=`#if defined( USE_POINTS_UV )
|
|
1421
|
+
varying vec2 vUv;
|
|
1422
|
+
#else
|
|
1423
|
+
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1424
|
+
uniform mat3 uvTransform;
|
|
1425
|
+
#endif
|
|
1426
|
+
#endif
|
|
1427
|
+
#ifdef USE_MAP
|
|
1428
|
+
uniform sampler2D map;
|
|
1429
|
+
#endif
|
|
1430
|
+
#ifdef USE_ALPHAMAP
|
|
1431
|
+
uniform sampler2D alphaMap;
|
|
1432
|
+
#endif`,vd=`float metalnessFactor = metalness;
|
|
1433
|
+
#ifdef USE_METALNESSMAP
|
|
1434
|
+
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1435
|
+
metalnessFactor *= texelMetalness.b;
|
|
1436
|
+
#endif`,Md=`#ifdef USE_METALNESSMAP
|
|
1437
|
+
uniform sampler2D metalnessMap;
|
|
1438
|
+
#endif`,bd=`#ifdef USE_INSTANCING_MORPH
|
|
1439
|
+
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1440
|
+
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1441
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1442
|
+
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1443
|
+
}
|
|
1444
|
+
#endif`,Sd=`#if defined( USE_MORPHCOLORS )
|
|
1445
|
+
vColor *= morphTargetBaseInfluence;
|
|
1446
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1447
|
+
#if defined( USE_COLOR_ALPHA )
|
|
1448
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|
1449
|
+
#elif defined( USE_COLOR )
|
|
1450
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1451
|
+
#endif
|
|
1452
|
+
}
|
|
1453
|
+
#endif`,yd=`#ifdef USE_MORPHNORMALS
|
|
1454
|
+
objectNormal *= morphTargetBaseInfluence;
|
|
1455
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1456
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1457
|
+
}
|
|
1458
|
+
#endif`,Ed=`#ifdef USE_MORPHTARGETS
|
|
1459
|
+
#ifndef USE_INSTANCING_MORPH
|
|
1460
|
+
uniform float morphTargetBaseInfluence;
|
|
1461
|
+
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1462
|
+
#endif
|
|
1463
|
+
uniform sampler2DArray morphTargetsTexture;
|
|
1464
|
+
uniform ivec2 morphTargetsTextureSize;
|
|
1465
|
+
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
1466
|
+
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
1467
|
+
int y = texelIndex / morphTargetsTextureSize.x;
|
|
1468
|
+
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
1469
|
+
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1470
|
+
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1471
|
+
}
|
|
1472
|
+
#endif`,Td=`#ifdef USE_MORPHTARGETS
|
|
1473
|
+
transformed *= morphTargetBaseInfluence;
|
|
1474
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1475
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1476
|
+
}
|
|
1477
|
+
#endif`,Ad=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1478
|
+
#ifdef FLAT_SHADED
|
|
1479
|
+
vec3 fdx = dFdx( vViewPosition );
|
|
1480
|
+
vec3 fdy = dFdy( vViewPosition );
|
|
1481
|
+
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
1482
|
+
#else
|
|
1483
|
+
vec3 normal = normalize( vNormal );
|
|
1484
|
+
#ifdef DOUBLE_SIDED
|
|
1485
|
+
normal *= faceDirection;
|
|
1486
|
+
#endif
|
|
1487
|
+
#endif
|
|
1488
|
+
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|
1489
|
+
#ifdef USE_TANGENT
|
|
1490
|
+
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
1491
|
+
#else
|
|
1492
|
+
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
1493
|
+
#if defined( USE_NORMALMAP )
|
|
1494
|
+
vNormalMapUv
|
|
1495
|
+
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|
1496
|
+
vClearcoatNormalMapUv
|
|
1497
|
+
#else
|
|
1498
|
+
vUv
|
|
1499
|
+
#endif
|
|
1500
|
+
);
|
|
1501
|
+
#endif
|
|
1502
|
+
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
1503
|
+
tbn[0] *= faceDirection;
|
|
1504
|
+
tbn[1] *= faceDirection;
|
|
1505
|
+
#endif
|
|
1506
|
+
#endif
|
|
1507
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1508
|
+
#ifdef USE_TANGENT
|
|
1509
|
+
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
1510
|
+
#else
|
|
1511
|
+
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
|
1512
|
+
#endif
|
|
1513
|
+
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
1514
|
+
tbn2[0] *= faceDirection;
|
|
1515
|
+
tbn2[1] *= faceDirection;
|
|
1516
|
+
#endif
|
|
1517
|
+
#endif
|
|
1518
|
+
vec3 nonPerturbedNormal = normal;`,wd=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1519
|
+
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1520
|
+
#ifdef FLIP_SIDED
|
|
1521
|
+
normal = - normal;
|
|
1522
|
+
#endif
|
|
1523
|
+
#ifdef DOUBLE_SIDED
|
|
1524
|
+
normal = normal * faceDirection;
|
|
1525
|
+
#endif
|
|
1526
|
+
normal = normalize( normalMatrix * normal );
|
|
1527
|
+
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|
1528
|
+
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1529
|
+
mapN.xy *= normalScale;
|
|
1530
|
+
normal = normalize( tbn * mapN );
|
|
1531
|
+
#elif defined( USE_BUMPMAP )
|
|
1532
|
+
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1533
|
+
#endif`,Rd=`#ifndef FLAT_SHADED
|
|
1534
|
+
varying vec3 vNormal;
|
|
1535
|
+
#ifdef USE_TANGENT
|
|
1536
|
+
varying vec3 vTangent;
|
|
1537
|
+
varying vec3 vBitangent;
|
|
1538
|
+
#endif
|
|
1539
|
+
#endif`,Cd=`#ifndef FLAT_SHADED
|
|
1540
|
+
varying vec3 vNormal;
|
|
1541
|
+
#ifdef USE_TANGENT
|
|
1542
|
+
varying vec3 vTangent;
|
|
1543
|
+
varying vec3 vBitangent;
|
|
1544
|
+
#endif
|
|
1545
|
+
#endif`,Pd=`#ifndef FLAT_SHADED
|
|
1546
|
+
vNormal = normalize( transformedNormal );
|
|
1547
|
+
#ifdef USE_TANGENT
|
|
1548
|
+
vTangent = normalize( transformedTangent );
|
|
1549
|
+
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
1550
|
+
#endif
|
|
1551
|
+
#endif`,Dd=`#ifdef USE_NORMALMAP
|
|
1552
|
+
uniform sampler2D normalMap;
|
|
1553
|
+
uniform vec2 normalScale;
|
|
1554
|
+
#endif
|
|
1555
|
+
#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1556
|
+
uniform mat3 normalMatrix;
|
|
1557
|
+
#endif
|
|
1558
|
+
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|
1559
|
+
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
|
1560
|
+
vec3 q0 = dFdx( eye_pos.xyz );
|
|
1561
|
+
vec3 q1 = dFdy( eye_pos.xyz );
|
|
1562
|
+
vec2 st0 = dFdx( uv.st );
|
|
1563
|
+
vec2 st1 = dFdy( uv.st );
|
|
1564
|
+
vec3 N = surf_norm;
|
|
1565
|
+
vec3 q1perp = cross( q1, N );
|
|
1566
|
+
vec3 q0perp = cross( N, q0 );
|
|
1567
|
+
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|
1568
|
+
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|
1569
|
+
float det = max( dot( T, T ), dot( B, B ) );
|
|
1570
|
+
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1571
|
+
return mat3( T * scale, B * scale, N );
|
|
1572
|
+
}
|
|
1573
|
+
#endif`,Ld=`#ifdef USE_CLEARCOAT
|
|
1574
|
+
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1575
|
+
#endif`,Id=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1576
|
+
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1577
|
+
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1578
|
+
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1579
|
+
#endif`,Ud=`#ifdef USE_CLEARCOATMAP
|
|
1580
|
+
uniform sampler2D clearcoatMap;
|
|
1581
|
+
#endif
|
|
1582
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1583
|
+
uniform sampler2D clearcoatNormalMap;
|
|
1584
|
+
uniform vec2 clearcoatNormalScale;
|
|
1585
|
+
#endif
|
|
1586
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1587
|
+
uniform sampler2D clearcoatRoughnessMap;
|
|
1588
|
+
#endif`,Nd=`#ifdef USE_IRIDESCENCEMAP
|
|
1589
|
+
uniform sampler2D iridescenceMap;
|
|
1590
|
+
#endif
|
|
1591
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1592
|
+
uniform sampler2D iridescenceThicknessMap;
|
|
1593
|
+
#endif`,Fd=`#ifdef OPAQUE
|
|
1594
|
+
diffuseColor.a = 1.0;
|
|
1595
|
+
#endif
|
|
1596
|
+
#ifdef USE_TRANSMISSION
|
|
1597
|
+
diffuseColor.a *= material.transmissionAlpha;
|
|
1598
|
+
#endif
|
|
1599
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Od=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1600
|
+
return normalize( normal ) * 0.5 + 0.5;
|
|
1601
|
+
}
|
|
1602
|
+
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
1603
|
+
return 2.0 * rgb.xyz - 1.0;
|
|
1604
|
+
}
|
|
1605
|
+
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
|
|
1606
|
+
const float Inv255 = 1. / 255.;
|
|
1607
|
+
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
|
|
1608
|
+
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
|
|
1609
|
+
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
|
|
1610
|
+
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
|
|
1611
|
+
vec4 packDepthToRGBA( const in float v ) {
|
|
1612
|
+
if( v <= 0.0 )
|
|
1613
|
+
return vec4( 0., 0., 0., 0. );
|
|
1614
|
+
if( v >= 1.0 )
|
|
1615
|
+
return vec4( 1., 1., 1., 1. );
|
|
1616
|
+
float vuf;
|
|
1617
|
+
float af = modf( v * PackFactors.a, vuf );
|
|
1618
|
+
float bf = modf( vuf * ShiftRight8, vuf );
|
|
1619
|
+
float gf = modf( vuf * ShiftRight8, vuf );
|
|
1620
|
+
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
|
|
1621
|
+
}
|
|
1622
|
+
vec3 packDepthToRGB( const in float v ) {
|
|
1623
|
+
if( v <= 0.0 )
|
|
1624
|
+
return vec3( 0., 0., 0. );
|
|
1625
|
+
if( v >= 1.0 )
|
|
1626
|
+
return vec3( 1., 1., 1. );
|
|
1627
|
+
float vuf;
|
|
1628
|
+
float bf = modf( v * PackFactors.b, vuf );
|
|
1629
|
+
float gf = modf( vuf * ShiftRight8, vuf );
|
|
1630
|
+
return vec3( vuf * Inv255, gf * PackUpscale, bf );
|
|
1631
|
+
}
|
|
1632
|
+
vec2 packDepthToRG( const in float v ) {
|
|
1633
|
+
if( v <= 0.0 )
|
|
1634
|
+
return vec2( 0., 0. );
|
|
1635
|
+
if( v >= 1.0 )
|
|
1636
|
+
return vec2( 1., 1. );
|
|
1637
|
+
float vuf;
|
|
1638
|
+
float gf = modf( v * 256., vuf );
|
|
1639
|
+
return vec2( vuf * Inv255, gf );
|
|
1640
|
+
}
|
|
1641
|
+
float unpackRGBAToDepth( const in vec4 v ) {
|
|
1642
|
+
return dot( v, UnpackFactors4 );
|
|
1643
|
+
}
|
|
1644
|
+
float unpackRGBToDepth( const in vec3 v ) {
|
|
1645
|
+
return dot( v, UnpackFactors3 );
|
|
1646
|
+
}
|
|
1647
|
+
float unpackRGToDepth( const in vec2 v ) {
|
|
1648
|
+
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
|
|
1649
|
+
}
|
|
1650
|
+
vec4 pack2HalfToRGBA( const in vec2 v ) {
|
|
1651
|
+
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
|
1652
|
+
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
|
1653
|
+
}
|
|
1654
|
+
vec2 unpackRGBATo2Half( const in vec4 v ) {
|
|
1655
|
+
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
|
1656
|
+
}
|
|
1657
|
+
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
|
1658
|
+
return ( viewZ + near ) / ( near - far );
|
|
1659
|
+
}
|
|
1660
|
+
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
1661
|
+
return depth * ( near - far ) - near;
|
|
1662
|
+
}
|
|
1663
|
+
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|
1664
|
+
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|
1665
|
+
}
|
|
1666
|
+
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
1667
|
+
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1668
|
+
}`,Bd=`#ifdef PREMULTIPLIED_ALPHA
|
|
1669
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1670
|
+
#endif`,zd=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1671
|
+
#ifdef USE_BATCHING
|
|
1672
|
+
mvPosition = batchingMatrix * mvPosition;
|
|
1673
|
+
#endif
|
|
1674
|
+
#ifdef USE_INSTANCING
|
|
1675
|
+
mvPosition = instanceMatrix * mvPosition;
|
|
1676
|
+
#endif
|
|
1677
|
+
mvPosition = modelViewMatrix * mvPosition;
|
|
1678
|
+
gl_Position = projectionMatrix * mvPosition;`,Vd=`#ifdef DITHERING
|
|
1679
|
+
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1680
|
+
#endif`,kd=`#ifdef DITHERING
|
|
1681
|
+
vec3 dithering( vec3 color ) {
|
|
1682
|
+
float grid_position = rand( gl_FragCoord.xy );
|
|
1683
|
+
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1684
|
+
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1685
|
+
return color + dither_shift_RGB;
|
|
1686
|
+
}
|
|
1687
|
+
#endif`,Gd=`float roughnessFactor = roughness;
|
|
1688
|
+
#ifdef USE_ROUGHNESSMAP
|
|
1689
|
+
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1690
|
+
roughnessFactor *= texelRoughness.g;
|
|
1691
|
+
#endif`,Hd=`#ifdef USE_ROUGHNESSMAP
|
|
1692
|
+
uniform sampler2D roughnessMap;
|
|
1693
|
+
#endif`,Wd=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1694
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1695
|
+
#endif
|
|
1696
|
+
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
1697
|
+
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|
1698
|
+
#endif
|
|
1699
|
+
#ifdef USE_SHADOWMAP
|
|
1700
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1701
|
+
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1702
|
+
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1703
|
+
struct DirectionalLightShadow {
|
|
1704
|
+
float shadowIntensity;
|
|
1705
|
+
float shadowBias;
|
|
1706
|
+
float shadowNormalBias;
|
|
1707
|
+
float shadowRadius;
|
|
1708
|
+
vec2 shadowMapSize;
|
|
1709
|
+
};
|
|
1710
|
+
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1711
|
+
#endif
|
|
1712
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1713
|
+
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1714
|
+
struct SpotLightShadow {
|
|
1715
|
+
float shadowIntensity;
|
|
1716
|
+
float shadowBias;
|
|
1717
|
+
float shadowNormalBias;
|
|
1718
|
+
float shadowRadius;
|
|
1719
|
+
vec2 shadowMapSize;
|
|
1720
|
+
};
|
|
1721
|
+
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1722
|
+
#endif
|
|
1723
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1724
|
+
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1725
|
+
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1726
|
+
struct PointLightShadow {
|
|
1727
|
+
float shadowIntensity;
|
|
1728
|
+
float shadowBias;
|
|
1729
|
+
float shadowNormalBias;
|
|
1730
|
+
float shadowRadius;
|
|
1731
|
+
vec2 shadowMapSize;
|
|
1732
|
+
float shadowCameraNear;
|
|
1733
|
+
float shadowCameraFar;
|
|
1734
|
+
};
|
|
1735
|
+
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1736
|
+
#endif
|
|
1737
|
+
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
1738
|
+
float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
|
|
1739
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
1740
|
+
return step( depth, compare );
|
|
1741
|
+
#else
|
|
1742
|
+
return step( compare, depth );
|
|
1743
|
+
#endif
|
|
1744
|
+
}
|
|
1745
|
+
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
1746
|
+
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
1747
|
+
}
|
|
1748
|
+
float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
|
|
1749
|
+
float occlusion = 1.0;
|
|
1750
|
+
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
1751
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
1752
|
+
float hard_shadow = step( distribution.x, compare );
|
|
1753
|
+
#else
|
|
1754
|
+
float hard_shadow = step( compare, distribution.x );
|
|
1755
|
+
#endif
|
|
1756
|
+
if ( hard_shadow != 1.0 ) {
|
|
1757
|
+
float distance = compare - distribution.x;
|
|
1758
|
+
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
1759
|
+
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
1760
|
+
}
|
|
1761
|
+
return occlusion;
|
|
1762
|
+
}
|
|
1763
|
+
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
1764
|
+
float shadow = 1.0;
|
|
1765
|
+
shadowCoord.xyz /= shadowCoord.w;
|
|
1766
|
+
shadowCoord.z += shadowBias;
|
|
1767
|
+
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
1768
|
+
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
1769
|
+
if ( frustumTest ) {
|
|
1770
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
1771
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
1772
|
+
float dx0 = - texelSize.x * shadowRadius;
|
|
1773
|
+
float dy0 = - texelSize.y * shadowRadius;
|
|
1774
|
+
float dx1 = + texelSize.x * shadowRadius;
|
|
1775
|
+
float dy1 = + texelSize.y * shadowRadius;
|
|
1776
|
+
float dx2 = dx0 / 2.0;
|
|
1777
|
+
float dy2 = dy0 / 2.0;
|
|
1778
|
+
float dx3 = dx1 / 2.0;
|
|
1779
|
+
float dy3 = dy1 / 2.0;
|
|
1780
|
+
shadow = (
|
|
1781
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
1782
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
1783
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
1784
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
1785
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
1786
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
1787
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
1788
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
1789
|
+
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
1790
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
1791
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
1792
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
1793
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
1794
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
1795
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
1796
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
1797
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
1798
|
+
) * ( 1.0 / 17.0 );
|
|
1799
|
+
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
1800
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
1801
|
+
float dx = texelSize.x;
|
|
1802
|
+
float dy = texelSize.y;
|
|
1803
|
+
vec2 uv = shadowCoord.xy;
|
|
1804
|
+
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
1805
|
+
uv -= f * texelSize;
|
|
1806
|
+
shadow = (
|
|
1807
|
+
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
1808
|
+
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
1809
|
+
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
1810
|
+
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
1811
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
1812
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
1813
|
+
f.x ) +
|
|
1814
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
1815
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
1816
|
+
f.x ) +
|
|
1817
|
+
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
1818
|
+
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
1819
|
+
f.y ) +
|
|
1820
|
+
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
1821
|
+
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
1822
|
+
f.y ) +
|
|
1823
|
+
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
1824
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
1825
|
+
f.x ),
|
|
1826
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
1827
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
1828
|
+
f.x ),
|
|
1829
|
+
f.y )
|
|
1830
|
+
) * ( 1.0 / 9.0 );
|
|
1831
|
+
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
1832
|
+
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
1833
|
+
#else
|
|
1834
|
+
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
1835
|
+
#endif
|
|
1836
|
+
}
|
|
1837
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
1838
|
+
}
|
|
1839
|
+
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
1840
|
+
vec3 absV = abs( v );
|
|
1841
|
+
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
1842
|
+
absV *= scaleToCube;
|
|
1843
|
+
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
1844
|
+
vec2 planar = v.xy;
|
|
1845
|
+
float almostATexel = 1.5 * texelSizeY;
|
|
1846
|
+
float almostOne = 1.0 - almostATexel;
|
|
1847
|
+
if ( absV.z >= almostOne ) {
|
|
1848
|
+
if ( v.z > 0.0 )
|
|
1849
|
+
planar.x = 4.0 - v.x;
|
|
1850
|
+
} else if ( absV.x >= almostOne ) {
|
|
1851
|
+
float signX = sign( v.x );
|
|
1852
|
+
planar.x = v.z * signX + 2.0 * signX;
|
|
1853
|
+
} else if ( absV.y >= almostOne ) {
|
|
1854
|
+
float signY = sign( v.y );
|
|
1855
|
+
planar.x = v.x + 2.0 * signY + 2.0;
|
|
1856
|
+
planar.y = v.z * signY - 2.0;
|
|
1857
|
+
}
|
|
1858
|
+
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
1859
|
+
}
|
|
1860
|
+
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
1861
|
+
float shadow = 1.0;
|
|
1862
|
+
vec3 lightToPosition = shadowCoord.xyz;
|
|
1863
|
+
|
|
1864
|
+
float lightToPositionLength = length( lightToPosition );
|
|
1865
|
+
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|
1866
|
+
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
1867
|
+
vec3 bd3D = normalize( lightToPosition );
|
|
1868
|
+
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
1869
|
+
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
1870
|
+
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
1871
|
+
shadow = (
|
|
1872
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
1873
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
1874
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
1875
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
1876
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
1877
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
1878
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
1879
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
1880
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
1881
|
+
) * ( 1.0 / 9.0 );
|
|
1882
|
+
#else
|
|
1883
|
+
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
1884
|
+
#endif
|
|
1885
|
+
}
|
|
1886
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
1887
|
+
}
|
|
1888
|
+
#endif`,Xd=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1889
|
+
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
1890
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1891
|
+
#endif
|
|
1892
|
+
#ifdef USE_SHADOWMAP
|
|
1893
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1894
|
+
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1895
|
+
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1896
|
+
struct DirectionalLightShadow {
|
|
1897
|
+
float shadowIntensity;
|
|
1898
|
+
float shadowBias;
|
|
1899
|
+
float shadowNormalBias;
|
|
1900
|
+
float shadowRadius;
|
|
1901
|
+
vec2 shadowMapSize;
|
|
1902
|
+
};
|
|
1903
|
+
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1904
|
+
#endif
|
|
1905
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1906
|
+
struct SpotLightShadow {
|
|
1907
|
+
float shadowIntensity;
|
|
1908
|
+
float shadowBias;
|
|
1909
|
+
float shadowNormalBias;
|
|
1910
|
+
float shadowRadius;
|
|
1911
|
+
vec2 shadowMapSize;
|
|
1912
|
+
};
|
|
1913
|
+
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1914
|
+
#endif
|
|
1915
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1916
|
+
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1917
|
+
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1918
|
+
struct PointLightShadow {
|
|
1919
|
+
float shadowIntensity;
|
|
1920
|
+
float shadowBias;
|
|
1921
|
+
float shadowNormalBias;
|
|
1922
|
+
float shadowRadius;
|
|
1923
|
+
vec2 shadowMapSize;
|
|
1924
|
+
float shadowCameraNear;
|
|
1925
|
+
float shadowCameraFar;
|
|
1926
|
+
};
|
|
1927
|
+
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1928
|
+
#endif
|
|
1929
|
+
#endif`,qd=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
1930
|
+
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
1931
|
+
vec4 shadowWorldPosition;
|
|
1932
|
+
#endif
|
|
1933
|
+
#if defined( USE_SHADOWMAP )
|
|
1934
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1935
|
+
#pragma unroll_loop_start
|
|
1936
|
+
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
1937
|
+
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
|
1938
|
+
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
|
1939
|
+
}
|
|
1940
|
+
#pragma unroll_loop_end
|
|
1941
|
+
#endif
|
|
1942
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1943
|
+
#pragma unroll_loop_start
|
|
1944
|
+
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
1945
|
+
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
|
1946
|
+
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
|
1947
|
+
}
|
|
1948
|
+
#pragma unroll_loop_end
|
|
1949
|
+
#endif
|
|
1950
|
+
#endif
|
|
1951
|
+
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1952
|
+
#pragma unroll_loop_start
|
|
1953
|
+
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
|
1954
|
+
shadowWorldPosition = worldPosition;
|
|
1955
|
+
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1956
|
+
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
|
1957
|
+
#endif
|
|
1958
|
+
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
1959
|
+
}
|
|
1960
|
+
#pragma unroll_loop_end
|
|
1961
|
+
#endif`,Yd=`float getShadowMask() {
|
|
1962
|
+
float shadow = 1.0;
|
|
1963
|
+
#ifdef USE_SHADOWMAP
|
|
1964
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1965
|
+
DirectionalLightShadow directionalLight;
|
|
1966
|
+
#pragma unroll_loop_start
|
|
1967
|
+
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
1968
|
+
directionalLight = directionalLightShadows[ i ];
|
|
1969
|
+
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
1970
|
+
}
|
|
1971
|
+
#pragma unroll_loop_end
|
|
1972
|
+
#endif
|
|
1973
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1974
|
+
SpotLightShadow spotLight;
|
|
1975
|
+
#pragma unroll_loop_start
|
|
1976
|
+
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
1977
|
+
spotLight = spotLightShadows[ i ];
|
|
1978
|
+
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
1979
|
+
}
|
|
1980
|
+
#pragma unroll_loop_end
|
|
1981
|
+
#endif
|
|
1982
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1983
|
+
PointLightShadow pointLight;
|
|
1984
|
+
#pragma unroll_loop_start
|
|
1985
|
+
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
1986
|
+
pointLight = pointLightShadows[ i ];
|
|
1987
|
+
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
1988
|
+
}
|
|
1989
|
+
#pragma unroll_loop_end
|
|
1990
|
+
#endif
|
|
1991
|
+
#endif
|
|
1992
|
+
return shadow;
|
|
1993
|
+
}`,Kd=`#ifdef USE_SKINNING
|
|
1994
|
+
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
1995
|
+
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
1996
|
+
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
1997
|
+
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
1998
|
+
#endif`,$d=`#ifdef USE_SKINNING
|
|
1999
|
+
uniform mat4 bindMatrix;
|
|
2000
|
+
uniform mat4 bindMatrixInverse;
|
|
2001
|
+
uniform highp sampler2D boneTexture;
|
|
2002
|
+
mat4 getBoneMatrix( const in float i ) {
|
|
2003
|
+
int size = textureSize( boneTexture, 0 ).x;
|
|
2004
|
+
int j = int( i ) * 4;
|
|
2005
|
+
int x = j % size;
|
|
2006
|
+
int y = j / size;
|
|
2007
|
+
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
2008
|
+
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
2009
|
+
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
2010
|
+
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2011
|
+
return mat4( v1, v2, v3, v4 );
|
|
2012
|
+
}
|
|
2013
|
+
#endif`,Zd=`#ifdef USE_SKINNING
|
|
2014
|
+
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2015
|
+
vec4 skinned = vec4( 0.0 );
|
|
2016
|
+
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
2017
|
+
skinned += boneMatY * skinVertex * skinWeight.y;
|
|
2018
|
+
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2019
|
+
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2020
|
+
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2021
|
+
#endif`,jd=`#ifdef USE_SKINNING
|
|
2022
|
+
mat4 skinMatrix = mat4( 0.0 );
|
|
2023
|
+
skinMatrix += skinWeight.x * boneMatX;
|
|
2024
|
+
skinMatrix += skinWeight.y * boneMatY;
|
|
2025
|
+
skinMatrix += skinWeight.z * boneMatZ;
|
|
2026
|
+
skinMatrix += skinWeight.w * boneMatW;
|
|
2027
|
+
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
|
2028
|
+
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
|
2029
|
+
#ifdef USE_TANGENT
|
|
2030
|
+
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2031
|
+
#endif
|
|
2032
|
+
#endif`,Jd=`float specularStrength;
|
|
2033
|
+
#ifdef USE_SPECULARMAP
|
|
2034
|
+
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2035
|
+
specularStrength = texelSpecular.r;
|
|
2036
|
+
#else
|
|
2037
|
+
specularStrength = 1.0;
|
|
2038
|
+
#endif`,Qd=`#ifdef USE_SPECULARMAP
|
|
2039
|
+
uniform sampler2D specularMap;
|
|
2040
|
+
#endif`,ef=`#if defined( TONE_MAPPING )
|
|
2041
|
+
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2042
|
+
#endif`,tf=`#ifndef saturate
|
|
2043
|
+
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2044
|
+
#endif
|
|
2045
|
+
uniform float toneMappingExposure;
|
|
2046
|
+
vec3 LinearToneMapping( vec3 color ) {
|
|
2047
|
+
return saturate( toneMappingExposure * color );
|
|
2048
|
+
}
|
|
2049
|
+
vec3 ReinhardToneMapping( vec3 color ) {
|
|
2050
|
+
color *= toneMappingExposure;
|
|
2051
|
+
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|
2052
|
+
}
|
|
2053
|
+
vec3 CineonToneMapping( vec3 color ) {
|
|
2054
|
+
color *= toneMappingExposure;
|
|
2055
|
+
color = max( vec3( 0.0 ), color - 0.004 );
|
|
2056
|
+
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
|
2057
|
+
}
|
|
2058
|
+
vec3 RRTAndODTFit( vec3 v ) {
|
|
2059
|
+
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
|
2060
|
+
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
|
2061
|
+
return a / b;
|
|
2062
|
+
}
|
|
2063
|
+
vec3 ACESFilmicToneMapping( vec3 color ) {
|
|
2064
|
+
const mat3 ACESInputMat = mat3(
|
|
2065
|
+
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
|
2066
|
+
vec3( 0.04823, 0.01566, 0.83777 )
|
|
2067
|
+
);
|
|
2068
|
+
const mat3 ACESOutputMat = mat3(
|
|
2069
|
+
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
|
2070
|
+
vec3( -0.07367, -0.00605, 1.07602 )
|
|
2071
|
+
);
|
|
2072
|
+
color *= toneMappingExposure / 0.6;
|
|
2073
|
+
color = ACESInputMat * color;
|
|
2074
|
+
color = RRTAndODTFit( color );
|
|
2075
|
+
color = ACESOutputMat * color;
|
|
2076
|
+
return saturate( color );
|
|
2077
|
+
}
|
|
2078
|
+
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|
2079
|
+
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|
2080
|
+
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|
2081
|
+
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|
2082
|
+
);
|
|
2083
|
+
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|
2084
|
+
vec3( 0.6274, 0.0691, 0.0164 ),
|
|
2085
|
+
vec3( 0.3293, 0.9195, 0.0880 ),
|
|
2086
|
+
vec3( 0.0433, 0.0113, 0.8956 )
|
|
2087
|
+
);
|
|
2088
|
+
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|
2089
|
+
vec3 x2 = x * x;
|
|
2090
|
+
vec3 x4 = x2 * x2;
|
|
2091
|
+
return + 15.5 * x4 * x2
|
|
2092
|
+
- 40.14 * x4 * x
|
|
2093
|
+
+ 31.96 * x4
|
|
2094
|
+
- 6.868 * x2 * x
|
|
2095
|
+
+ 0.4298 * x2
|
|
2096
|
+
+ 0.1191 * x
|
|
2097
|
+
- 0.00232;
|
|
2098
|
+
}
|
|
2099
|
+
vec3 AgXToneMapping( vec3 color ) {
|
|
2100
|
+
const mat3 AgXInsetMatrix = mat3(
|
|
2101
|
+
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|
2102
|
+
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|
2103
|
+
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|
2104
|
+
);
|
|
2105
|
+
const mat3 AgXOutsetMatrix = mat3(
|
|
2106
|
+
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|
2107
|
+
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|
2108
|
+
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|
2109
|
+
);
|
|
2110
|
+
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
|
2111
|
+
color *= toneMappingExposure;
|
|
2112
|
+
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|
2113
|
+
color = AgXInsetMatrix * color;
|
|
2114
|
+
color = max( color, 1e-10 ); color = log2( color );
|
|
2115
|
+
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|
2116
|
+
color = clamp( color, 0.0, 1.0 );
|
|
2117
|
+
color = agxDefaultContrastApprox( color );
|
|
2118
|
+
color = AgXOutsetMatrix * color;
|
|
2119
|
+
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|
2120
|
+
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|
2121
|
+
color = clamp( color, 0.0, 1.0 );
|
|
2122
|
+
return color;
|
|
2123
|
+
}
|
|
2124
|
+
vec3 NeutralToneMapping( vec3 color ) {
|
|
2125
|
+
const float StartCompression = 0.8 - 0.04;
|
|
2126
|
+
const float Desaturation = 0.15;
|
|
2127
|
+
color *= toneMappingExposure;
|
|
2128
|
+
float x = min( color.r, min( color.g, color.b ) );
|
|
2129
|
+
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
2130
|
+
color -= offset;
|
|
2131
|
+
float peak = max( color.r, max( color.g, color.b ) );
|
|
2132
|
+
if ( peak < StartCompression ) return color;
|
|
2133
|
+
float d = 1. - StartCompression;
|
|
2134
|
+
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
|
2135
|
+
color *= newPeak / peak;
|
|
2136
|
+
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2137
|
+
return mix( color, vec3( newPeak ), g );
|
|
2138
|
+
}
|
|
2139
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,nf=`#ifdef USE_TRANSMISSION
|
|
2140
|
+
material.transmission = transmission;
|
|
2141
|
+
material.transmissionAlpha = 1.0;
|
|
2142
|
+
material.thickness = thickness;
|
|
2143
|
+
material.attenuationDistance = attenuationDistance;
|
|
2144
|
+
material.attenuationColor = attenuationColor;
|
|
2145
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2146
|
+
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|
2147
|
+
#endif
|
|
2148
|
+
#ifdef USE_THICKNESSMAP
|
|
2149
|
+
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|
2150
|
+
#endif
|
|
2151
|
+
vec3 pos = vWorldPosition;
|
|
2152
|
+
vec3 v = normalize( cameraPosition - pos );
|
|
2153
|
+
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
2154
|
+
vec4 transmitted = getIBLVolumeRefraction(
|
|
2155
|
+
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
2156
|
+
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
|
2157
|
+
material.attenuationColor, material.attenuationDistance );
|
|
2158
|
+
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2159
|
+
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2160
|
+
#endif`,rf=`#ifdef USE_TRANSMISSION
|
|
2161
|
+
uniform float transmission;
|
|
2162
|
+
uniform float thickness;
|
|
2163
|
+
uniform float attenuationDistance;
|
|
2164
|
+
uniform vec3 attenuationColor;
|
|
2165
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2166
|
+
uniform sampler2D transmissionMap;
|
|
2167
|
+
#endif
|
|
2168
|
+
#ifdef USE_THICKNESSMAP
|
|
2169
|
+
uniform sampler2D thicknessMap;
|
|
2170
|
+
#endif
|
|
2171
|
+
uniform vec2 transmissionSamplerSize;
|
|
2172
|
+
uniform sampler2D transmissionSamplerMap;
|
|
2173
|
+
uniform mat4 modelMatrix;
|
|
2174
|
+
uniform mat4 projectionMatrix;
|
|
2175
|
+
varying vec3 vWorldPosition;
|
|
2176
|
+
float w0( float a ) {
|
|
2177
|
+
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
2178
|
+
}
|
|
2179
|
+
float w1( float a ) {
|
|
2180
|
+
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
|
2181
|
+
}
|
|
2182
|
+
float w2( float a ){
|
|
2183
|
+
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
|
2184
|
+
}
|
|
2185
|
+
float w3( float a ) {
|
|
2186
|
+
return ( 1.0 / 6.0 ) * ( a * a * a );
|
|
2187
|
+
}
|
|
2188
|
+
float g0( float a ) {
|
|
2189
|
+
return w0( a ) + w1( a );
|
|
2190
|
+
}
|
|
2191
|
+
float g1( float a ) {
|
|
2192
|
+
return w2( a ) + w3( a );
|
|
2193
|
+
}
|
|
2194
|
+
float h0( float a ) {
|
|
2195
|
+
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
|
2196
|
+
}
|
|
2197
|
+
float h1( float a ) {
|
|
2198
|
+
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
|
2199
|
+
}
|
|
2200
|
+
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
|
2201
|
+
uv = uv * texelSize.zw + 0.5;
|
|
2202
|
+
vec2 iuv = floor( uv );
|
|
2203
|
+
vec2 fuv = fract( uv );
|
|
2204
|
+
float g0x = g0( fuv.x );
|
|
2205
|
+
float g1x = g1( fuv.x );
|
|
2206
|
+
float h0x = h0( fuv.x );
|
|
2207
|
+
float h1x = h1( fuv.x );
|
|
2208
|
+
float h0y = h0( fuv.y );
|
|
2209
|
+
float h1y = h1( fuv.y );
|
|
2210
|
+
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
2211
|
+
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
2212
|
+
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
2213
|
+
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
2214
|
+
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
|
2215
|
+
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
|
2216
|
+
}
|
|
2217
|
+
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
|
2218
|
+
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
|
2219
|
+
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
|
2220
|
+
vec2 fLodSizeInv = 1.0 / fLodSize;
|
|
2221
|
+
vec2 cLodSizeInv = 1.0 / cLodSize;
|
|
2222
|
+
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
2223
|
+
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
2224
|
+
return mix( fSample, cSample, fract( lod ) );
|
|
2225
|
+
}
|
|
2226
|
+
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
2227
|
+
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
2228
|
+
vec3 modelScale;
|
|
2229
|
+
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
2230
|
+
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
2231
|
+
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
2232
|
+
return normalize( refractionVector ) * thickness * modelScale;
|
|
2233
|
+
}
|
|
2234
|
+
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
2235
|
+
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
2236
|
+
}
|
|
2237
|
+
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
2238
|
+
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
2239
|
+
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
|
2240
|
+
}
|
|
2241
|
+
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
2242
|
+
if ( isinf( attenuationDistance ) ) {
|
|
2243
|
+
return vec3( 1.0 );
|
|
2244
|
+
} else {
|
|
2245
|
+
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
2246
|
+
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
2250
|
+
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
2251
|
+
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
|
|
2252
|
+
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
2253
|
+
vec4 transmittedLight;
|
|
2254
|
+
vec3 transmittance;
|
|
2255
|
+
#ifdef USE_DISPERSION
|
|
2256
|
+
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
|
|
2257
|
+
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
|
|
2258
|
+
for ( int i = 0; i < 3; i ++ ) {
|
|
2259
|
+
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
|
|
2260
|
+
vec3 refractedRayExit = position + transmissionRay;
|
|
2261
|
+
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
2262
|
+
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
2263
|
+
refractionCoords += 1.0;
|
|
2264
|
+
refractionCoords /= 2.0;
|
|
2265
|
+
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
|
|
2266
|
+
transmittedLight[ i ] = transmissionSample[ i ];
|
|
2267
|
+
transmittedLight.a += transmissionSample.a;
|
|
2268
|
+
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
|
|
2269
|
+
}
|
|
2270
|
+
transmittedLight.a /= 3.0;
|
|
2271
|
+
#else
|
|
2272
|
+
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
2273
|
+
vec3 refractedRayExit = position + transmissionRay;
|
|
2274
|
+
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
2275
|
+
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
2276
|
+
refractionCoords += 1.0;
|
|
2277
|
+
refractionCoords /= 2.0;
|
|
2278
|
+
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
2279
|
+
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
2280
|
+
#endif
|
|
2281
|
+
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|
2282
|
+
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
2283
|
+
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2284
|
+
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2285
|
+
}
|
|
2286
|
+
#endif`,sf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2287
|
+
varying vec2 vUv;
|
|
2288
|
+
#endif
|
|
2289
|
+
#ifdef USE_MAP
|
|
2290
|
+
varying vec2 vMapUv;
|
|
2291
|
+
#endif
|
|
2292
|
+
#ifdef USE_ALPHAMAP
|
|
2293
|
+
varying vec2 vAlphaMapUv;
|
|
2294
|
+
#endif
|
|
2295
|
+
#ifdef USE_LIGHTMAP
|
|
2296
|
+
varying vec2 vLightMapUv;
|
|
2297
|
+
#endif
|
|
2298
|
+
#ifdef USE_AOMAP
|
|
2299
|
+
varying vec2 vAoMapUv;
|
|
2300
|
+
#endif
|
|
2301
|
+
#ifdef USE_BUMPMAP
|
|
2302
|
+
varying vec2 vBumpMapUv;
|
|
2303
|
+
#endif
|
|
2304
|
+
#ifdef USE_NORMALMAP
|
|
2305
|
+
varying vec2 vNormalMapUv;
|
|
2306
|
+
#endif
|
|
2307
|
+
#ifdef USE_EMISSIVEMAP
|
|
2308
|
+
varying vec2 vEmissiveMapUv;
|
|
2309
|
+
#endif
|
|
2310
|
+
#ifdef USE_METALNESSMAP
|
|
2311
|
+
varying vec2 vMetalnessMapUv;
|
|
2312
|
+
#endif
|
|
2313
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2314
|
+
varying vec2 vRoughnessMapUv;
|
|
2315
|
+
#endif
|
|
2316
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2317
|
+
varying vec2 vAnisotropyMapUv;
|
|
2318
|
+
#endif
|
|
2319
|
+
#ifdef USE_CLEARCOATMAP
|
|
2320
|
+
varying vec2 vClearcoatMapUv;
|
|
2321
|
+
#endif
|
|
2322
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2323
|
+
varying vec2 vClearcoatNormalMapUv;
|
|
2324
|
+
#endif
|
|
2325
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2326
|
+
varying vec2 vClearcoatRoughnessMapUv;
|
|
2327
|
+
#endif
|
|
2328
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2329
|
+
varying vec2 vIridescenceMapUv;
|
|
2330
|
+
#endif
|
|
2331
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2332
|
+
varying vec2 vIridescenceThicknessMapUv;
|
|
2333
|
+
#endif
|
|
2334
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2335
|
+
varying vec2 vSheenColorMapUv;
|
|
2336
|
+
#endif
|
|
2337
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2338
|
+
varying vec2 vSheenRoughnessMapUv;
|
|
2339
|
+
#endif
|
|
2340
|
+
#ifdef USE_SPECULARMAP
|
|
2341
|
+
varying vec2 vSpecularMapUv;
|
|
2342
|
+
#endif
|
|
2343
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2344
|
+
varying vec2 vSpecularColorMapUv;
|
|
2345
|
+
#endif
|
|
2346
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2347
|
+
varying vec2 vSpecularIntensityMapUv;
|
|
2348
|
+
#endif
|
|
2349
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2350
|
+
uniform mat3 transmissionMapTransform;
|
|
2351
|
+
varying vec2 vTransmissionMapUv;
|
|
2352
|
+
#endif
|
|
2353
|
+
#ifdef USE_THICKNESSMAP
|
|
2354
|
+
uniform mat3 thicknessMapTransform;
|
|
2355
|
+
varying vec2 vThicknessMapUv;
|
|
2356
|
+
#endif`,af=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2357
|
+
varying vec2 vUv;
|
|
2358
|
+
#endif
|
|
2359
|
+
#ifdef USE_MAP
|
|
2360
|
+
uniform mat3 mapTransform;
|
|
2361
|
+
varying vec2 vMapUv;
|
|
2362
|
+
#endif
|
|
2363
|
+
#ifdef USE_ALPHAMAP
|
|
2364
|
+
uniform mat3 alphaMapTransform;
|
|
2365
|
+
varying vec2 vAlphaMapUv;
|
|
2366
|
+
#endif
|
|
2367
|
+
#ifdef USE_LIGHTMAP
|
|
2368
|
+
uniform mat3 lightMapTransform;
|
|
2369
|
+
varying vec2 vLightMapUv;
|
|
2370
|
+
#endif
|
|
2371
|
+
#ifdef USE_AOMAP
|
|
2372
|
+
uniform mat3 aoMapTransform;
|
|
2373
|
+
varying vec2 vAoMapUv;
|
|
2374
|
+
#endif
|
|
2375
|
+
#ifdef USE_BUMPMAP
|
|
2376
|
+
uniform mat3 bumpMapTransform;
|
|
2377
|
+
varying vec2 vBumpMapUv;
|
|
2378
|
+
#endif
|
|
2379
|
+
#ifdef USE_NORMALMAP
|
|
2380
|
+
uniform mat3 normalMapTransform;
|
|
2381
|
+
varying vec2 vNormalMapUv;
|
|
2382
|
+
#endif
|
|
2383
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2384
|
+
uniform mat3 displacementMapTransform;
|
|
2385
|
+
varying vec2 vDisplacementMapUv;
|
|
2386
|
+
#endif
|
|
2387
|
+
#ifdef USE_EMISSIVEMAP
|
|
2388
|
+
uniform mat3 emissiveMapTransform;
|
|
2389
|
+
varying vec2 vEmissiveMapUv;
|
|
2390
|
+
#endif
|
|
2391
|
+
#ifdef USE_METALNESSMAP
|
|
2392
|
+
uniform mat3 metalnessMapTransform;
|
|
2393
|
+
varying vec2 vMetalnessMapUv;
|
|
2394
|
+
#endif
|
|
2395
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2396
|
+
uniform mat3 roughnessMapTransform;
|
|
2397
|
+
varying vec2 vRoughnessMapUv;
|
|
2398
|
+
#endif
|
|
2399
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2400
|
+
uniform mat3 anisotropyMapTransform;
|
|
2401
|
+
varying vec2 vAnisotropyMapUv;
|
|
2402
|
+
#endif
|
|
2403
|
+
#ifdef USE_CLEARCOATMAP
|
|
2404
|
+
uniform mat3 clearcoatMapTransform;
|
|
2405
|
+
varying vec2 vClearcoatMapUv;
|
|
2406
|
+
#endif
|
|
2407
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2408
|
+
uniform mat3 clearcoatNormalMapTransform;
|
|
2409
|
+
varying vec2 vClearcoatNormalMapUv;
|
|
2410
|
+
#endif
|
|
2411
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2412
|
+
uniform mat3 clearcoatRoughnessMapTransform;
|
|
2413
|
+
varying vec2 vClearcoatRoughnessMapUv;
|
|
2414
|
+
#endif
|
|
2415
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2416
|
+
uniform mat3 sheenColorMapTransform;
|
|
2417
|
+
varying vec2 vSheenColorMapUv;
|
|
2418
|
+
#endif
|
|
2419
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2420
|
+
uniform mat3 sheenRoughnessMapTransform;
|
|
2421
|
+
varying vec2 vSheenRoughnessMapUv;
|
|
2422
|
+
#endif
|
|
2423
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2424
|
+
uniform mat3 iridescenceMapTransform;
|
|
2425
|
+
varying vec2 vIridescenceMapUv;
|
|
2426
|
+
#endif
|
|
2427
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2428
|
+
uniform mat3 iridescenceThicknessMapTransform;
|
|
2429
|
+
varying vec2 vIridescenceThicknessMapUv;
|
|
2430
|
+
#endif
|
|
2431
|
+
#ifdef USE_SPECULARMAP
|
|
2432
|
+
uniform mat3 specularMapTransform;
|
|
2433
|
+
varying vec2 vSpecularMapUv;
|
|
2434
|
+
#endif
|
|
2435
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2436
|
+
uniform mat3 specularColorMapTransform;
|
|
2437
|
+
varying vec2 vSpecularColorMapUv;
|
|
2438
|
+
#endif
|
|
2439
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2440
|
+
uniform mat3 specularIntensityMapTransform;
|
|
2441
|
+
varying vec2 vSpecularIntensityMapUv;
|
|
2442
|
+
#endif
|
|
2443
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2444
|
+
uniform mat3 transmissionMapTransform;
|
|
2445
|
+
varying vec2 vTransmissionMapUv;
|
|
2446
|
+
#endif
|
|
2447
|
+
#ifdef USE_THICKNESSMAP
|
|
2448
|
+
uniform mat3 thicknessMapTransform;
|
|
2449
|
+
varying vec2 vThicknessMapUv;
|
|
2450
|
+
#endif`,of=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2451
|
+
vUv = vec3( uv, 1 ).xy;
|
|
2452
|
+
#endif
|
|
2453
|
+
#ifdef USE_MAP
|
|
2454
|
+
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
|
2455
|
+
#endif
|
|
2456
|
+
#ifdef USE_ALPHAMAP
|
|
2457
|
+
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
|
2458
|
+
#endif
|
|
2459
|
+
#ifdef USE_LIGHTMAP
|
|
2460
|
+
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
|
2461
|
+
#endif
|
|
2462
|
+
#ifdef USE_AOMAP
|
|
2463
|
+
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
|
2464
|
+
#endif
|
|
2465
|
+
#ifdef USE_BUMPMAP
|
|
2466
|
+
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
|
2467
|
+
#endif
|
|
2468
|
+
#ifdef USE_NORMALMAP
|
|
2469
|
+
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
|
2470
|
+
#endif
|
|
2471
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2472
|
+
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
|
2473
|
+
#endif
|
|
2474
|
+
#ifdef USE_EMISSIVEMAP
|
|
2475
|
+
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
|
2476
|
+
#endif
|
|
2477
|
+
#ifdef USE_METALNESSMAP
|
|
2478
|
+
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
|
2479
|
+
#endif
|
|
2480
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2481
|
+
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2482
|
+
#endif
|
|
2483
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2484
|
+
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|
2485
|
+
#endif
|
|
2486
|
+
#ifdef USE_CLEARCOATMAP
|
|
2487
|
+
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
|
2488
|
+
#endif
|
|
2489
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2490
|
+
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
|
2491
|
+
#endif
|
|
2492
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2493
|
+
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2494
|
+
#endif
|
|
2495
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2496
|
+
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
|
2497
|
+
#endif
|
|
2498
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2499
|
+
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
|
2500
|
+
#endif
|
|
2501
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2502
|
+
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
|
2503
|
+
#endif
|
|
2504
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2505
|
+
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2506
|
+
#endif
|
|
2507
|
+
#ifdef USE_SPECULARMAP
|
|
2508
|
+
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
|
2509
|
+
#endif
|
|
2510
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2511
|
+
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
|
2512
|
+
#endif
|
|
2513
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2514
|
+
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
|
2515
|
+
#endif
|
|
2516
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2517
|
+
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
|
2518
|
+
#endif
|
|
2519
|
+
#ifdef USE_THICKNESSMAP
|
|
2520
|
+
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2521
|
+
#endif`,cf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2522
|
+
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2523
|
+
#ifdef USE_BATCHING
|
|
2524
|
+
worldPosition = batchingMatrix * worldPosition;
|
|
2525
|
+
#endif
|
|
2526
|
+
#ifdef USE_INSTANCING
|
|
2527
|
+
worldPosition = instanceMatrix * worldPosition;
|
|
2528
|
+
#endif
|
|
2529
|
+
worldPosition = modelMatrix * worldPosition;
|
|
2530
|
+
#endif`;const lf=`varying vec2 vUv;
|
|
2531
|
+
uniform mat3 uvTransform;
|
|
2532
|
+
void main() {
|
|
2533
|
+
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2534
|
+
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2535
|
+
}`,hf=`uniform sampler2D t2D;
|
|
2536
|
+
uniform float backgroundIntensity;
|
|
2537
|
+
varying vec2 vUv;
|
|
2538
|
+
void main() {
|
|
2539
|
+
vec4 texColor = texture2D( t2D, vUv );
|
|
2540
|
+
#ifdef DECODE_VIDEO_TEXTURE
|
|
2541
|
+
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 );
|
|
2542
|
+
#endif
|
|
2543
|
+
texColor.rgb *= backgroundIntensity;
|
|
2544
|
+
gl_FragColor = texColor;
|
|
2545
|
+
#include <tonemapping_fragment>
|
|
2546
|
+
#include <colorspace_fragment>
|
|
2547
|
+
}`,uf=`varying vec3 vWorldDirection;
|
|
2548
|
+
#include <common>
|
|
2549
|
+
void main() {
|
|
2550
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2551
|
+
#include <begin_vertex>
|
|
2552
|
+
#include <project_vertex>
|
|
2553
|
+
gl_Position.z = gl_Position.w;
|
|
2554
|
+
}`,df=`#ifdef ENVMAP_TYPE_CUBE
|
|
2555
|
+
uniform samplerCube envMap;
|
|
2556
|
+
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2557
|
+
uniform sampler2D envMap;
|
|
2558
|
+
#endif
|
|
2559
|
+
uniform float flipEnvMap;
|
|
2560
|
+
uniform float backgroundBlurriness;
|
|
2561
|
+
uniform float backgroundIntensity;
|
|
2562
|
+
uniform mat3 backgroundRotation;
|
|
2563
|
+
varying vec3 vWorldDirection;
|
|
2564
|
+
#include <cube_uv_reflection_fragment>
|
|
2565
|
+
void main() {
|
|
2566
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
2567
|
+
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
2568
|
+
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2569
|
+
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
2570
|
+
#else
|
|
2571
|
+
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
2572
|
+
#endif
|
|
2573
|
+
texColor.rgb *= backgroundIntensity;
|
|
2574
|
+
gl_FragColor = texColor;
|
|
2575
|
+
#include <tonemapping_fragment>
|
|
2576
|
+
#include <colorspace_fragment>
|
|
2577
|
+
}`,ff=`varying vec3 vWorldDirection;
|
|
2578
|
+
#include <common>
|
|
2579
|
+
void main() {
|
|
2580
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2581
|
+
#include <begin_vertex>
|
|
2582
|
+
#include <project_vertex>
|
|
2583
|
+
gl_Position.z = gl_Position.w;
|
|
2584
|
+
}`,pf=`uniform samplerCube tCube;
|
|
2585
|
+
uniform float tFlip;
|
|
2586
|
+
uniform float opacity;
|
|
2587
|
+
varying vec3 vWorldDirection;
|
|
2588
|
+
void main() {
|
|
2589
|
+
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
|
2590
|
+
gl_FragColor = texColor;
|
|
2591
|
+
gl_FragColor.a *= opacity;
|
|
2592
|
+
#include <tonemapping_fragment>
|
|
2593
|
+
#include <colorspace_fragment>
|
|
2594
|
+
}`,mf=`#include <common>
|
|
2595
|
+
#include <batching_pars_vertex>
|
|
2596
|
+
#include <uv_pars_vertex>
|
|
2597
|
+
#include <displacementmap_pars_vertex>
|
|
2598
|
+
#include <morphtarget_pars_vertex>
|
|
2599
|
+
#include <skinning_pars_vertex>
|
|
2600
|
+
#include <logdepthbuf_pars_vertex>
|
|
2601
|
+
#include <clipping_planes_pars_vertex>
|
|
2602
|
+
varying vec2 vHighPrecisionZW;
|
|
2603
|
+
void main() {
|
|
2604
|
+
#include <uv_vertex>
|
|
2605
|
+
#include <batching_vertex>
|
|
2606
|
+
#include <skinbase_vertex>
|
|
2607
|
+
#include <morphinstance_vertex>
|
|
2608
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2609
|
+
#include <beginnormal_vertex>
|
|
2610
|
+
#include <morphnormal_vertex>
|
|
2611
|
+
#include <skinnormal_vertex>
|
|
2612
|
+
#endif
|
|
2613
|
+
#include <begin_vertex>
|
|
2614
|
+
#include <morphtarget_vertex>
|
|
2615
|
+
#include <skinning_vertex>
|
|
2616
|
+
#include <displacementmap_vertex>
|
|
2617
|
+
#include <project_vertex>
|
|
2618
|
+
#include <logdepthbuf_vertex>
|
|
2619
|
+
#include <clipping_planes_vertex>
|
|
2620
|
+
vHighPrecisionZW = gl_Position.zw;
|
|
2621
|
+
}`,xf=`#if DEPTH_PACKING == 3200
|
|
2622
|
+
uniform float opacity;
|
|
2623
|
+
#endif
|
|
2624
|
+
#include <common>
|
|
2625
|
+
#include <packing>
|
|
2626
|
+
#include <uv_pars_fragment>
|
|
2627
|
+
#include <map_pars_fragment>
|
|
2628
|
+
#include <alphamap_pars_fragment>
|
|
2629
|
+
#include <alphatest_pars_fragment>
|
|
2630
|
+
#include <alphahash_pars_fragment>
|
|
2631
|
+
#include <logdepthbuf_pars_fragment>
|
|
2632
|
+
#include <clipping_planes_pars_fragment>
|
|
2633
|
+
varying vec2 vHighPrecisionZW;
|
|
2634
|
+
void main() {
|
|
2635
|
+
vec4 diffuseColor = vec4( 1.0 );
|
|
2636
|
+
#include <clipping_planes_fragment>
|
|
2637
|
+
#if DEPTH_PACKING == 3200
|
|
2638
|
+
diffuseColor.a = opacity;
|
|
2639
|
+
#endif
|
|
2640
|
+
#include <map_fragment>
|
|
2641
|
+
#include <alphamap_fragment>
|
|
2642
|
+
#include <alphatest_fragment>
|
|
2643
|
+
#include <alphahash_fragment>
|
|
2644
|
+
#include <logdepthbuf_fragment>
|
|
2645
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
2646
|
+
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
|
2647
|
+
#else
|
|
2648
|
+
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
|
2649
|
+
#endif
|
|
2650
|
+
#if DEPTH_PACKING == 3200
|
|
2651
|
+
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
2652
|
+
#elif DEPTH_PACKING == 3201
|
|
2653
|
+
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
2654
|
+
#elif DEPTH_PACKING == 3202
|
|
2655
|
+
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|
2656
|
+
#elif DEPTH_PACKING == 3203
|
|
2657
|
+
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2658
|
+
#endif
|
|
2659
|
+
}`,gf=`#define DISTANCE
|
|
2660
|
+
varying vec3 vWorldPosition;
|
|
2661
|
+
#include <common>
|
|
2662
|
+
#include <batching_pars_vertex>
|
|
2663
|
+
#include <uv_pars_vertex>
|
|
2664
|
+
#include <displacementmap_pars_vertex>
|
|
2665
|
+
#include <morphtarget_pars_vertex>
|
|
2666
|
+
#include <skinning_pars_vertex>
|
|
2667
|
+
#include <clipping_planes_pars_vertex>
|
|
2668
|
+
void main() {
|
|
2669
|
+
#include <uv_vertex>
|
|
2670
|
+
#include <batching_vertex>
|
|
2671
|
+
#include <skinbase_vertex>
|
|
2672
|
+
#include <morphinstance_vertex>
|
|
2673
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2674
|
+
#include <beginnormal_vertex>
|
|
2675
|
+
#include <morphnormal_vertex>
|
|
2676
|
+
#include <skinnormal_vertex>
|
|
2677
|
+
#endif
|
|
2678
|
+
#include <begin_vertex>
|
|
2679
|
+
#include <morphtarget_vertex>
|
|
2680
|
+
#include <skinning_vertex>
|
|
2681
|
+
#include <displacementmap_vertex>
|
|
2682
|
+
#include <project_vertex>
|
|
2683
|
+
#include <worldpos_vertex>
|
|
2684
|
+
#include <clipping_planes_vertex>
|
|
2685
|
+
vWorldPosition = worldPosition.xyz;
|
|
2686
|
+
}`,_f=`#define DISTANCE
|
|
2687
|
+
uniform vec3 referencePosition;
|
|
2688
|
+
uniform float nearDistance;
|
|
2689
|
+
uniform float farDistance;
|
|
2690
|
+
varying vec3 vWorldPosition;
|
|
2691
|
+
#include <common>
|
|
2692
|
+
#include <packing>
|
|
2693
|
+
#include <uv_pars_fragment>
|
|
2694
|
+
#include <map_pars_fragment>
|
|
2695
|
+
#include <alphamap_pars_fragment>
|
|
2696
|
+
#include <alphatest_pars_fragment>
|
|
2697
|
+
#include <alphahash_pars_fragment>
|
|
2698
|
+
#include <clipping_planes_pars_fragment>
|
|
2699
|
+
void main () {
|
|
2700
|
+
vec4 diffuseColor = vec4( 1.0 );
|
|
2701
|
+
#include <clipping_planes_fragment>
|
|
2702
|
+
#include <map_fragment>
|
|
2703
|
+
#include <alphamap_fragment>
|
|
2704
|
+
#include <alphatest_fragment>
|
|
2705
|
+
#include <alphahash_fragment>
|
|
2706
|
+
float dist = length( vWorldPosition - referencePosition );
|
|
2707
|
+
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2708
|
+
dist = saturate( dist );
|
|
2709
|
+
gl_FragColor = packDepthToRGBA( dist );
|
|
2710
|
+
}`,vf=`varying vec3 vWorldDirection;
|
|
2711
|
+
#include <common>
|
|
2712
|
+
void main() {
|
|
2713
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2714
|
+
#include <begin_vertex>
|
|
2715
|
+
#include <project_vertex>
|
|
2716
|
+
}`,Mf=`uniform sampler2D tEquirect;
|
|
2717
|
+
varying vec3 vWorldDirection;
|
|
2718
|
+
#include <common>
|
|
2719
|
+
void main() {
|
|
2720
|
+
vec3 direction = normalize( vWorldDirection );
|
|
2721
|
+
vec2 sampleUV = equirectUv( direction );
|
|
2722
|
+
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2723
|
+
#include <tonemapping_fragment>
|
|
2724
|
+
#include <colorspace_fragment>
|
|
2725
|
+
}`,bf=`uniform float scale;
|
|
2726
|
+
attribute float lineDistance;
|
|
2727
|
+
varying float vLineDistance;
|
|
2728
|
+
#include <common>
|
|
2729
|
+
#include <uv_pars_vertex>
|
|
2730
|
+
#include <color_pars_vertex>
|
|
2731
|
+
#include <fog_pars_vertex>
|
|
2732
|
+
#include <morphtarget_pars_vertex>
|
|
2733
|
+
#include <logdepthbuf_pars_vertex>
|
|
2734
|
+
#include <clipping_planes_pars_vertex>
|
|
2735
|
+
void main() {
|
|
2736
|
+
vLineDistance = scale * lineDistance;
|
|
2737
|
+
#include <uv_vertex>
|
|
2738
|
+
#include <color_vertex>
|
|
2739
|
+
#include <morphinstance_vertex>
|
|
2740
|
+
#include <morphcolor_vertex>
|
|
2741
|
+
#include <begin_vertex>
|
|
2742
|
+
#include <morphtarget_vertex>
|
|
2743
|
+
#include <project_vertex>
|
|
2744
|
+
#include <logdepthbuf_vertex>
|
|
2745
|
+
#include <clipping_planes_vertex>
|
|
2746
|
+
#include <fog_vertex>
|
|
2747
|
+
}`,Sf=`uniform vec3 diffuse;
|
|
2748
|
+
uniform float opacity;
|
|
2749
|
+
uniform float dashSize;
|
|
2750
|
+
uniform float totalSize;
|
|
2751
|
+
varying float vLineDistance;
|
|
2752
|
+
#include <common>
|
|
2753
|
+
#include <color_pars_fragment>
|
|
2754
|
+
#include <uv_pars_fragment>
|
|
2755
|
+
#include <map_pars_fragment>
|
|
2756
|
+
#include <fog_pars_fragment>
|
|
2757
|
+
#include <logdepthbuf_pars_fragment>
|
|
2758
|
+
#include <clipping_planes_pars_fragment>
|
|
2759
|
+
void main() {
|
|
2760
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2761
|
+
#include <clipping_planes_fragment>
|
|
2762
|
+
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
2763
|
+
discard;
|
|
2764
|
+
}
|
|
2765
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
2766
|
+
#include <logdepthbuf_fragment>
|
|
2767
|
+
#include <map_fragment>
|
|
2768
|
+
#include <color_fragment>
|
|
2769
|
+
outgoingLight = diffuseColor.rgb;
|
|
2770
|
+
#include <opaque_fragment>
|
|
2771
|
+
#include <tonemapping_fragment>
|
|
2772
|
+
#include <colorspace_fragment>
|
|
2773
|
+
#include <fog_fragment>
|
|
2774
|
+
#include <premultiplied_alpha_fragment>
|
|
2775
|
+
}`,yf=`#include <common>
|
|
2776
|
+
#include <batching_pars_vertex>
|
|
2777
|
+
#include <uv_pars_vertex>
|
|
2778
|
+
#include <envmap_pars_vertex>
|
|
2779
|
+
#include <color_pars_vertex>
|
|
2780
|
+
#include <fog_pars_vertex>
|
|
2781
|
+
#include <morphtarget_pars_vertex>
|
|
2782
|
+
#include <skinning_pars_vertex>
|
|
2783
|
+
#include <logdepthbuf_pars_vertex>
|
|
2784
|
+
#include <clipping_planes_pars_vertex>
|
|
2785
|
+
void main() {
|
|
2786
|
+
#include <uv_vertex>
|
|
2787
|
+
#include <color_vertex>
|
|
2788
|
+
#include <morphinstance_vertex>
|
|
2789
|
+
#include <morphcolor_vertex>
|
|
2790
|
+
#include <batching_vertex>
|
|
2791
|
+
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
2792
|
+
#include <beginnormal_vertex>
|
|
2793
|
+
#include <morphnormal_vertex>
|
|
2794
|
+
#include <skinbase_vertex>
|
|
2795
|
+
#include <skinnormal_vertex>
|
|
2796
|
+
#include <defaultnormal_vertex>
|
|
2797
|
+
#endif
|
|
2798
|
+
#include <begin_vertex>
|
|
2799
|
+
#include <morphtarget_vertex>
|
|
2800
|
+
#include <skinning_vertex>
|
|
2801
|
+
#include <project_vertex>
|
|
2802
|
+
#include <logdepthbuf_vertex>
|
|
2803
|
+
#include <clipping_planes_vertex>
|
|
2804
|
+
#include <worldpos_vertex>
|
|
2805
|
+
#include <envmap_vertex>
|
|
2806
|
+
#include <fog_vertex>
|
|
2807
|
+
}`,Ef=`uniform vec3 diffuse;
|
|
2808
|
+
uniform float opacity;
|
|
2809
|
+
#ifndef FLAT_SHADED
|
|
2810
|
+
varying vec3 vNormal;
|
|
2811
|
+
#endif
|
|
2812
|
+
#include <common>
|
|
2813
|
+
#include <dithering_pars_fragment>
|
|
2814
|
+
#include <color_pars_fragment>
|
|
2815
|
+
#include <uv_pars_fragment>
|
|
2816
|
+
#include <map_pars_fragment>
|
|
2817
|
+
#include <alphamap_pars_fragment>
|
|
2818
|
+
#include <alphatest_pars_fragment>
|
|
2819
|
+
#include <alphahash_pars_fragment>
|
|
2820
|
+
#include <aomap_pars_fragment>
|
|
2821
|
+
#include <lightmap_pars_fragment>
|
|
2822
|
+
#include <envmap_common_pars_fragment>
|
|
2823
|
+
#include <envmap_pars_fragment>
|
|
2824
|
+
#include <fog_pars_fragment>
|
|
2825
|
+
#include <specularmap_pars_fragment>
|
|
2826
|
+
#include <logdepthbuf_pars_fragment>
|
|
2827
|
+
#include <clipping_planes_pars_fragment>
|
|
2828
|
+
void main() {
|
|
2829
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2830
|
+
#include <clipping_planes_fragment>
|
|
2831
|
+
#include <logdepthbuf_fragment>
|
|
2832
|
+
#include <map_fragment>
|
|
2833
|
+
#include <color_fragment>
|
|
2834
|
+
#include <alphamap_fragment>
|
|
2835
|
+
#include <alphatest_fragment>
|
|
2836
|
+
#include <alphahash_fragment>
|
|
2837
|
+
#include <specularmap_fragment>
|
|
2838
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
2839
|
+
#ifdef USE_LIGHTMAP
|
|
2840
|
+
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
2841
|
+
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
2842
|
+
#else
|
|
2843
|
+
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
2844
|
+
#endif
|
|
2845
|
+
#include <aomap_fragment>
|
|
2846
|
+
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
2847
|
+
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
2848
|
+
#include <envmap_fragment>
|
|
2849
|
+
#include <opaque_fragment>
|
|
2850
|
+
#include <tonemapping_fragment>
|
|
2851
|
+
#include <colorspace_fragment>
|
|
2852
|
+
#include <fog_fragment>
|
|
2853
|
+
#include <premultiplied_alpha_fragment>
|
|
2854
|
+
#include <dithering_fragment>
|
|
2855
|
+
}`,Tf=`#define LAMBERT
|
|
2856
|
+
varying vec3 vViewPosition;
|
|
2857
|
+
#include <common>
|
|
2858
|
+
#include <batching_pars_vertex>
|
|
2859
|
+
#include <uv_pars_vertex>
|
|
2860
|
+
#include <displacementmap_pars_vertex>
|
|
2861
|
+
#include <envmap_pars_vertex>
|
|
2862
|
+
#include <color_pars_vertex>
|
|
2863
|
+
#include <fog_pars_vertex>
|
|
2864
|
+
#include <normal_pars_vertex>
|
|
2865
|
+
#include <morphtarget_pars_vertex>
|
|
2866
|
+
#include <skinning_pars_vertex>
|
|
2867
|
+
#include <shadowmap_pars_vertex>
|
|
2868
|
+
#include <logdepthbuf_pars_vertex>
|
|
2869
|
+
#include <clipping_planes_pars_vertex>
|
|
2870
|
+
void main() {
|
|
2871
|
+
#include <uv_vertex>
|
|
2872
|
+
#include <color_vertex>
|
|
2873
|
+
#include <morphinstance_vertex>
|
|
2874
|
+
#include <morphcolor_vertex>
|
|
2875
|
+
#include <batching_vertex>
|
|
2876
|
+
#include <beginnormal_vertex>
|
|
2877
|
+
#include <morphnormal_vertex>
|
|
2878
|
+
#include <skinbase_vertex>
|
|
2879
|
+
#include <skinnormal_vertex>
|
|
2880
|
+
#include <defaultnormal_vertex>
|
|
2881
|
+
#include <normal_vertex>
|
|
2882
|
+
#include <begin_vertex>
|
|
2883
|
+
#include <morphtarget_vertex>
|
|
2884
|
+
#include <skinning_vertex>
|
|
2885
|
+
#include <displacementmap_vertex>
|
|
2886
|
+
#include <project_vertex>
|
|
2887
|
+
#include <logdepthbuf_vertex>
|
|
2888
|
+
#include <clipping_planes_vertex>
|
|
2889
|
+
vViewPosition = - mvPosition.xyz;
|
|
2890
|
+
#include <worldpos_vertex>
|
|
2891
|
+
#include <envmap_vertex>
|
|
2892
|
+
#include <shadowmap_vertex>
|
|
2893
|
+
#include <fog_vertex>
|
|
2894
|
+
}`,Af=`#define LAMBERT
|
|
2895
|
+
uniform vec3 diffuse;
|
|
2896
|
+
uniform vec3 emissive;
|
|
2897
|
+
uniform float opacity;
|
|
2898
|
+
#include <common>
|
|
2899
|
+
#include <packing>
|
|
2900
|
+
#include <dithering_pars_fragment>
|
|
2901
|
+
#include <color_pars_fragment>
|
|
2902
|
+
#include <uv_pars_fragment>
|
|
2903
|
+
#include <map_pars_fragment>
|
|
2904
|
+
#include <alphamap_pars_fragment>
|
|
2905
|
+
#include <alphatest_pars_fragment>
|
|
2906
|
+
#include <alphahash_pars_fragment>
|
|
2907
|
+
#include <aomap_pars_fragment>
|
|
2908
|
+
#include <lightmap_pars_fragment>
|
|
2909
|
+
#include <emissivemap_pars_fragment>
|
|
2910
|
+
#include <envmap_common_pars_fragment>
|
|
2911
|
+
#include <envmap_pars_fragment>
|
|
2912
|
+
#include <fog_pars_fragment>
|
|
2913
|
+
#include <bsdfs>
|
|
2914
|
+
#include <lights_pars_begin>
|
|
2915
|
+
#include <normal_pars_fragment>
|
|
2916
|
+
#include <lights_lambert_pars_fragment>
|
|
2917
|
+
#include <shadowmap_pars_fragment>
|
|
2918
|
+
#include <bumpmap_pars_fragment>
|
|
2919
|
+
#include <normalmap_pars_fragment>
|
|
2920
|
+
#include <specularmap_pars_fragment>
|
|
2921
|
+
#include <logdepthbuf_pars_fragment>
|
|
2922
|
+
#include <clipping_planes_pars_fragment>
|
|
2923
|
+
void main() {
|
|
2924
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2925
|
+
#include <clipping_planes_fragment>
|
|
2926
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
2927
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
2928
|
+
#include <logdepthbuf_fragment>
|
|
2929
|
+
#include <map_fragment>
|
|
2930
|
+
#include <color_fragment>
|
|
2931
|
+
#include <alphamap_fragment>
|
|
2932
|
+
#include <alphatest_fragment>
|
|
2933
|
+
#include <alphahash_fragment>
|
|
2934
|
+
#include <specularmap_fragment>
|
|
2935
|
+
#include <normal_fragment_begin>
|
|
2936
|
+
#include <normal_fragment_maps>
|
|
2937
|
+
#include <emissivemap_fragment>
|
|
2938
|
+
#include <lights_lambert_fragment>
|
|
2939
|
+
#include <lights_fragment_begin>
|
|
2940
|
+
#include <lights_fragment_maps>
|
|
2941
|
+
#include <lights_fragment_end>
|
|
2942
|
+
#include <aomap_fragment>
|
|
2943
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
2944
|
+
#include <envmap_fragment>
|
|
2945
|
+
#include <opaque_fragment>
|
|
2946
|
+
#include <tonemapping_fragment>
|
|
2947
|
+
#include <colorspace_fragment>
|
|
2948
|
+
#include <fog_fragment>
|
|
2949
|
+
#include <premultiplied_alpha_fragment>
|
|
2950
|
+
#include <dithering_fragment>
|
|
2951
|
+
}`,wf=`#define MATCAP
|
|
2952
|
+
varying vec3 vViewPosition;
|
|
2953
|
+
#include <common>
|
|
2954
|
+
#include <batching_pars_vertex>
|
|
2955
|
+
#include <uv_pars_vertex>
|
|
2956
|
+
#include <color_pars_vertex>
|
|
2957
|
+
#include <displacementmap_pars_vertex>
|
|
2958
|
+
#include <fog_pars_vertex>
|
|
2959
|
+
#include <normal_pars_vertex>
|
|
2960
|
+
#include <morphtarget_pars_vertex>
|
|
2961
|
+
#include <skinning_pars_vertex>
|
|
2962
|
+
#include <logdepthbuf_pars_vertex>
|
|
2963
|
+
#include <clipping_planes_pars_vertex>
|
|
2964
|
+
void main() {
|
|
2965
|
+
#include <uv_vertex>
|
|
2966
|
+
#include <color_vertex>
|
|
2967
|
+
#include <morphinstance_vertex>
|
|
2968
|
+
#include <morphcolor_vertex>
|
|
2969
|
+
#include <batching_vertex>
|
|
2970
|
+
#include <beginnormal_vertex>
|
|
2971
|
+
#include <morphnormal_vertex>
|
|
2972
|
+
#include <skinbase_vertex>
|
|
2973
|
+
#include <skinnormal_vertex>
|
|
2974
|
+
#include <defaultnormal_vertex>
|
|
2975
|
+
#include <normal_vertex>
|
|
2976
|
+
#include <begin_vertex>
|
|
2977
|
+
#include <morphtarget_vertex>
|
|
2978
|
+
#include <skinning_vertex>
|
|
2979
|
+
#include <displacementmap_vertex>
|
|
2980
|
+
#include <project_vertex>
|
|
2981
|
+
#include <logdepthbuf_vertex>
|
|
2982
|
+
#include <clipping_planes_vertex>
|
|
2983
|
+
#include <fog_vertex>
|
|
2984
|
+
vViewPosition = - mvPosition.xyz;
|
|
2985
|
+
}`,Rf=`#define MATCAP
|
|
2986
|
+
uniform vec3 diffuse;
|
|
2987
|
+
uniform float opacity;
|
|
2988
|
+
uniform sampler2D matcap;
|
|
2989
|
+
varying vec3 vViewPosition;
|
|
2990
|
+
#include <common>
|
|
2991
|
+
#include <dithering_pars_fragment>
|
|
2992
|
+
#include <color_pars_fragment>
|
|
2993
|
+
#include <uv_pars_fragment>
|
|
2994
|
+
#include <map_pars_fragment>
|
|
2995
|
+
#include <alphamap_pars_fragment>
|
|
2996
|
+
#include <alphatest_pars_fragment>
|
|
2997
|
+
#include <alphahash_pars_fragment>
|
|
2998
|
+
#include <fog_pars_fragment>
|
|
2999
|
+
#include <normal_pars_fragment>
|
|
3000
|
+
#include <bumpmap_pars_fragment>
|
|
3001
|
+
#include <normalmap_pars_fragment>
|
|
3002
|
+
#include <logdepthbuf_pars_fragment>
|
|
3003
|
+
#include <clipping_planes_pars_fragment>
|
|
3004
|
+
void main() {
|
|
3005
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3006
|
+
#include <clipping_planes_fragment>
|
|
3007
|
+
#include <logdepthbuf_fragment>
|
|
3008
|
+
#include <map_fragment>
|
|
3009
|
+
#include <color_fragment>
|
|
3010
|
+
#include <alphamap_fragment>
|
|
3011
|
+
#include <alphatest_fragment>
|
|
3012
|
+
#include <alphahash_fragment>
|
|
3013
|
+
#include <normal_fragment_begin>
|
|
3014
|
+
#include <normal_fragment_maps>
|
|
3015
|
+
vec3 viewDir = normalize( vViewPosition );
|
|
3016
|
+
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
3017
|
+
vec3 y = cross( viewDir, x );
|
|
3018
|
+
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
3019
|
+
#ifdef USE_MATCAP
|
|
3020
|
+
vec4 matcapColor = texture2D( matcap, uv );
|
|
3021
|
+
#else
|
|
3022
|
+
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
3023
|
+
#endif
|
|
3024
|
+
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
3025
|
+
#include <opaque_fragment>
|
|
3026
|
+
#include <tonemapping_fragment>
|
|
3027
|
+
#include <colorspace_fragment>
|
|
3028
|
+
#include <fog_fragment>
|
|
3029
|
+
#include <premultiplied_alpha_fragment>
|
|
3030
|
+
#include <dithering_fragment>
|
|
3031
|
+
}`,Cf=`#define NORMAL
|
|
3032
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3033
|
+
varying vec3 vViewPosition;
|
|
3034
|
+
#endif
|
|
3035
|
+
#include <common>
|
|
3036
|
+
#include <batching_pars_vertex>
|
|
3037
|
+
#include <uv_pars_vertex>
|
|
3038
|
+
#include <displacementmap_pars_vertex>
|
|
3039
|
+
#include <normal_pars_vertex>
|
|
3040
|
+
#include <morphtarget_pars_vertex>
|
|
3041
|
+
#include <skinning_pars_vertex>
|
|
3042
|
+
#include <logdepthbuf_pars_vertex>
|
|
3043
|
+
#include <clipping_planes_pars_vertex>
|
|
3044
|
+
void main() {
|
|
3045
|
+
#include <uv_vertex>
|
|
3046
|
+
#include <batching_vertex>
|
|
3047
|
+
#include <beginnormal_vertex>
|
|
3048
|
+
#include <morphinstance_vertex>
|
|
3049
|
+
#include <morphnormal_vertex>
|
|
3050
|
+
#include <skinbase_vertex>
|
|
3051
|
+
#include <skinnormal_vertex>
|
|
3052
|
+
#include <defaultnormal_vertex>
|
|
3053
|
+
#include <normal_vertex>
|
|
3054
|
+
#include <begin_vertex>
|
|
3055
|
+
#include <morphtarget_vertex>
|
|
3056
|
+
#include <skinning_vertex>
|
|
3057
|
+
#include <displacementmap_vertex>
|
|
3058
|
+
#include <project_vertex>
|
|
3059
|
+
#include <logdepthbuf_vertex>
|
|
3060
|
+
#include <clipping_planes_vertex>
|
|
3061
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3062
|
+
vViewPosition = - mvPosition.xyz;
|
|
3063
|
+
#endif
|
|
3064
|
+
}`,Pf=`#define NORMAL
|
|
3065
|
+
uniform float opacity;
|
|
3066
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3067
|
+
varying vec3 vViewPosition;
|
|
3068
|
+
#endif
|
|
3069
|
+
#include <packing>
|
|
3070
|
+
#include <uv_pars_fragment>
|
|
3071
|
+
#include <normal_pars_fragment>
|
|
3072
|
+
#include <bumpmap_pars_fragment>
|
|
3073
|
+
#include <normalmap_pars_fragment>
|
|
3074
|
+
#include <logdepthbuf_pars_fragment>
|
|
3075
|
+
#include <clipping_planes_pars_fragment>
|
|
3076
|
+
void main() {
|
|
3077
|
+
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|
3078
|
+
#include <clipping_planes_fragment>
|
|
3079
|
+
#include <logdepthbuf_fragment>
|
|
3080
|
+
#include <normal_fragment_begin>
|
|
3081
|
+
#include <normal_fragment_maps>
|
|
3082
|
+
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
|
|
3083
|
+
#ifdef OPAQUE
|
|
3084
|
+
gl_FragColor.a = 1.0;
|
|
3085
|
+
#endif
|
|
3086
|
+
}`,Df=`#define PHONG
|
|
3087
|
+
varying vec3 vViewPosition;
|
|
3088
|
+
#include <common>
|
|
3089
|
+
#include <batching_pars_vertex>
|
|
3090
|
+
#include <uv_pars_vertex>
|
|
3091
|
+
#include <displacementmap_pars_vertex>
|
|
3092
|
+
#include <envmap_pars_vertex>
|
|
3093
|
+
#include <color_pars_vertex>
|
|
3094
|
+
#include <fog_pars_vertex>
|
|
3095
|
+
#include <normal_pars_vertex>
|
|
3096
|
+
#include <morphtarget_pars_vertex>
|
|
3097
|
+
#include <skinning_pars_vertex>
|
|
3098
|
+
#include <shadowmap_pars_vertex>
|
|
3099
|
+
#include <logdepthbuf_pars_vertex>
|
|
3100
|
+
#include <clipping_planes_pars_vertex>
|
|
3101
|
+
void main() {
|
|
3102
|
+
#include <uv_vertex>
|
|
3103
|
+
#include <color_vertex>
|
|
3104
|
+
#include <morphcolor_vertex>
|
|
3105
|
+
#include <batching_vertex>
|
|
3106
|
+
#include <beginnormal_vertex>
|
|
3107
|
+
#include <morphinstance_vertex>
|
|
3108
|
+
#include <morphnormal_vertex>
|
|
3109
|
+
#include <skinbase_vertex>
|
|
3110
|
+
#include <skinnormal_vertex>
|
|
3111
|
+
#include <defaultnormal_vertex>
|
|
3112
|
+
#include <normal_vertex>
|
|
3113
|
+
#include <begin_vertex>
|
|
3114
|
+
#include <morphtarget_vertex>
|
|
3115
|
+
#include <skinning_vertex>
|
|
3116
|
+
#include <displacementmap_vertex>
|
|
3117
|
+
#include <project_vertex>
|
|
3118
|
+
#include <logdepthbuf_vertex>
|
|
3119
|
+
#include <clipping_planes_vertex>
|
|
3120
|
+
vViewPosition = - mvPosition.xyz;
|
|
3121
|
+
#include <worldpos_vertex>
|
|
3122
|
+
#include <envmap_vertex>
|
|
3123
|
+
#include <shadowmap_vertex>
|
|
3124
|
+
#include <fog_vertex>
|
|
3125
|
+
}`,Lf=`#define PHONG
|
|
3126
|
+
uniform vec3 diffuse;
|
|
3127
|
+
uniform vec3 emissive;
|
|
3128
|
+
uniform vec3 specular;
|
|
3129
|
+
uniform float shininess;
|
|
3130
|
+
uniform float opacity;
|
|
3131
|
+
#include <common>
|
|
3132
|
+
#include <packing>
|
|
3133
|
+
#include <dithering_pars_fragment>
|
|
3134
|
+
#include <color_pars_fragment>
|
|
3135
|
+
#include <uv_pars_fragment>
|
|
3136
|
+
#include <map_pars_fragment>
|
|
3137
|
+
#include <alphamap_pars_fragment>
|
|
3138
|
+
#include <alphatest_pars_fragment>
|
|
3139
|
+
#include <alphahash_pars_fragment>
|
|
3140
|
+
#include <aomap_pars_fragment>
|
|
3141
|
+
#include <lightmap_pars_fragment>
|
|
3142
|
+
#include <emissivemap_pars_fragment>
|
|
3143
|
+
#include <envmap_common_pars_fragment>
|
|
3144
|
+
#include <envmap_pars_fragment>
|
|
3145
|
+
#include <fog_pars_fragment>
|
|
3146
|
+
#include <bsdfs>
|
|
3147
|
+
#include <lights_pars_begin>
|
|
3148
|
+
#include <normal_pars_fragment>
|
|
3149
|
+
#include <lights_phong_pars_fragment>
|
|
3150
|
+
#include <shadowmap_pars_fragment>
|
|
3151
|
+
#include <bumpmap_pars_fragment>
|
|
3152
|
+
#include <normalmap_pars_fragment>
|
|
3153
|
+
#include <specularmap_pars_fragment>
|
|
3154
|
+
#include <logdepthbuf_pars_fragment>
|
|
3155
|
+
#include <clipping_planes_pars_fragment>
|
|
3156
|
+
void main() {
|
|
3157
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3158
|
+
#include <clipping_planes_fragment>
|
|
3159
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3160
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3161
|
+
#include <logdepthbuf_fragment>
|
|
3162
|
+
#include <map_fragment>
|
|
3163
|
+
#include <color_fragment>
|
|
3164
|
+
#include <alphamap_fragment>
|
|
3165
|
+
#include <alphatest_fragment>
|
|
3166
|
+
#include <alphahash_fragment>
|
|
3167
|
+
#include <specularmap_fragment>
|
|
3168
|
+
#include <normal_fragment_begin>
|
|
3169
|
+
#include <normal_fragment_maps>
|
|
3170
|
+
#include <emissivemap_fragment>
|
|
3171
|
+
#include <lights_phong_fragment>
|
|
3172
|
+
#include <lights_fragment_begin>
|
|
3173
|
+
#include <lights_fragment_maps>
|
|
3174
|
+
#include <lights_fragment_end>
|
|
3175
|
+
#include <aomap_fragment>
|
|
3176
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
3177
|
+
#include <envmap_fragment>
|
|
3178
|
+
#include <opaque_fragment>
|
|
3179
|
+
#include <tonemapping_fragment>
|
|
3180
|
+
#include <colorspace_fragment>
|
|
3181
|
+
#include <fog_fragment>
|
|
3182
|
+
#include <premultiplied_alpha_fragment>
|
|
3183
|
+
#include <dithering_fragment>
|
|
3184
|
+
}`,If=`#define STANDARD
|
|
3185
|
+
varying vec3 vViewPosition;
|
|
3186
|
+
#ifdef USE_TRANSMISSION
|
|
3187
|
+
varying vec3 vWorldPosition;
|
|
3188
|
+
#endif
|
|
3189
|
+
#include <common>
|
|
3190
|
+
#include <batching_pars_vertex>
|
|
3191
|
+
#include <uv_pars_vertex>
|
|
3192
|
+
#include <displacementmap_pars_vertex>
|
|
3193
|
+
#include <color_pars_vertex>
|
|
3194
|
+
#include <fog_pars_vertex>
|
|
3195
|
+
#include <normal_pars_vertex>
|
|
3196
|
+
#include <morphtarget_pars_vertex>
|
|
3197
|
+
#include <skinning_pars_vertex>
|
|
3198
|
+
#include <shadowmap_pars_vertex>
|
|
3199
|
+
#include <logdepthbuf_pars_vertex>
|
|
3200
|
+
#include <clipping_planes_pars_vertex>
|
|
3201
|
+
void main() {
|
|
3202
|
+
#include <uv_vertex>
|
|
3203
|
+
#include <color_vertex>
|
|
3204
|
+
#include <morphinstance_vertex>
|
|
3205
|
+
#include <morphcolor_vertex>
|
|
3206
|
+
#include <batching_vertex>
|
|
3207
|
+
#include <beginnormal_vertex>
|
|
3208
|
+
#include <morphnormal_vertex>
|
|
3209
|
+
#include <skinbase_vertex>
|
|
3210
|
+
#include <skinnormal_vertex>
|
|
3211
|
+
#include <defaultnormal_vertex>
|
|
3212
|
+
#include <normal_vertex>
|
|
3213
|
+
#include <begin_vertex>
|
|
3214
|
+
#include <morphtarget_vertex>
|
|
3215
|
+
#include <skinning_vertex>
|
|
3216
|
+
#include <displacementmap_vertex>
|
|
3217
|
+
#include <project_vertex>
|
|
3218
|
+
#include <logdepthbuf_vertex>
|
|
3219
|
+
#include <clipping_planes_vertex>
|
|
3220
|
+
vViewPosition = - mvPosition.xyz;
|
|
3221
|
+
#include <worldpos_vertex>
|
|
3222
|
+
#include <shadowmap_vertex>
|
|
3223
|
+
#include <fog_vertex>
|
|
3224
|
+
#ifdef USE_TRANSMISSION
|
|
3225
|
+
vWorldPosition = worldPosition.xyz;
|
|
3226
|
+
#endif
|
|
3227
|
+
}`,Uf=`#define STANDARD
|
|
3228
|
+
#ifdef PHYSICAL
|
|
3229
|
+
#define IOR
|
|
3230
|
+
#define USE_SPECULAR
|
|
3231
|
+
#endif
|
|
3232
|
+
uniform vec3 diffuse;
|
|
3233
|
+
uniform vec3 emissive;
|
|
3234
|
+
uniform float roughness;
|
|
3235
|
+
uniform float metalness;
|
|
3236
|
+
uniform float opacity;
|
|
3237
|
+
#ifdef IOR
|
|
3238
|
+
uniform float ior;
|
|
3239
|
+
#endif
|
|
3240
|
+
#ifdef USE_SPECULAR
|
|
3241
|
+
uniform float specularIntensity;
|
|
3242
|
+
uniform vec3 specularColor;
|
|
3243
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
3244
|
+
uniform sampler2D specularColorMap;
|
|
3245
|
+
#endif
|
|
3246
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
3247
|
+
uniform sampler2D specularIntensityMap;
|
|
3248
|
+
#endif
|
|
3249
|
+
#endif
|
|
3250
|
+
#ifdef USE_CLEARCOAT
|
|
3251
|
+
uniform float clearcoat;
|
|
3252
|
+
uniform float clearcoatRoughness;
|
|
3253
|
+
#endif
|
|
3254
|
+
#ifdef USE_DISPERSION
|
|
3255
|
+
uniform float dispersion;
|
|
3256
|
+
#endif
|
|
3257
|
+
#ifdef USE_IRIDESCENCE
|
|
3258
|
+
uniform float iridescence;
|
|
3259
|
+
uniform float iridescenceIOR;
|
|
3260
|
+
uniform float iridescenceThicknessMinimum;
|
|
3261
|
+
uniform float iridescenceThicknessMaximum;
|
|
3262
|
+
#endif
|
|
3263
|
+
#ifdef USE_SHEEN
|
|
3264
|
+
uniform vec3 sheenColor;
|
|
3265
|
+
uniform float sheenRoughness;
|
|
3266
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
3267
|
+
uniform sampler2D sheenColorMap;
|
|
3268
|
+
#endif
|
|
3269
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
3270
|
+
uniform sampler2D sheenRoughnessMap;
|
|
3271
|
+
#endif
|
|
3272
|
+
#endif
|
|
3273
|
+
#ifdef USE_ANISOTROPY
|
|
3274
|
+
uniform vec2 anisotropyVector;
|
|
3275
|
+
#ifdef USE_ANISOTROPYMAP
|
|
3276
|
+
uniform sampler2D anisotropyMap;
|
|
3277
|
+
#endif
|
|
3278
|
+
#endif
|
|
3279
|
+
varying vec3 vViewPosition;
|
|
3280
|
+
#include <common>
|
|
3281
|
+
#include <packing>
|
|
3282
|
+
#include <dithering_pars_fragment>
|
|
3283
|
+
#include <color_pars_fragment>
|
|
3284
|
+
#include <uv_pars_fragment>
|
|
3285
|
+
#include <map_pars_fragment>
|
|
3286
|
+
#include <alphamap_pars_fragment>
|
|
3287
|
+
#include <alphatest_pars_fragment>
|
|
3288
|
+
#include <alphahash_pars_fragment>
|
|
3289
|
+
#include <aomap_pars_fragment>
|
|
3290
|
+
#include <lightmap_pars_fragment>
|
|
3291
|
+
#include <emissivemap_pars_fragment>
|
|
3292
|
+
#include <iridescence_fragment>
|
|
3293
|
+
#include <cube_uv_reflection_fragment>
|
|
3294
|
+
#include <envmap_common_pars_fragment>
|
|
3295
|
+
#include <envmap_physical_pars_fragment>
|
|
3296
|
+
#include <fog_pars_fragment>
|
|
3297
|
+
#include <lights_pars_begin>
|
|
3298
|
+
#include <normal_pars_fragment>
|
|
3299
|
+
#include <lights_physical_pars_fragment>
|
|
3300
|
+
#include <transmission_pars_fragment>
|
|
3301
|
+
#include <shadowmap_pars_fragment>
|
|
3302
|
+
#include <bumpmap_pars_fragment>
|
|
3303
|
+
#include <normalmap_pars_fragment>
|
|
3304
|
+
#include <clearcoat_pars_fragment>
|
|
3305
|
+
#include <iridescence_pars_fragment>
|
|
3306
|
+
#include <roughnessmap_pars_fragment>
|
|
3307
|
+
#include <metalnessmap_pars_fragment>
|
|
3308
|
+
#include <logdepthbuf_pars_fragment>
|
|
3309
|
+
#include <clipping_planes_pars_fragment>
|
|
3310
|
+
void main() {
|
|
3311
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3312
|
+
#include <clipping_planes_fragment>
|
|
3313
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3314
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3315
|
+
#include <logdepthbuf_fragment>
|
|
3316
|
+
#include <map_fragment>
|
|
3317
|
+
#include <color_fragment>
|
|
3318
|
+
#include <alphamap_fragment>
|
|
3319
|
+
#include <alphatest_fragment>
|
|
3320
|
+
#include <alphahash_fragment>
|
|
3321
|
+
#include <roughnessmap_fragment>
|
|
3322
|
+
#include <metalnessmap_fragment>
|
|
3323
|
+
#include <normal_fragment_begin>
|
|
3324
|
+
#include <normal_fragment_maps>
|
|
3325
|
+
#include <clearcoat_normal_fragment_begin>
|
|
3326
|
+
#include <clearcoat_normal_fragment_maps>
|
|
3327
|
+
#include <emissivemap_fragment>
|
|
3328
|
+
#include <lights_physical_fragment>
|
|
3329
|
+
#include <lights_fragment_begin>
|
|
3330
|
+
#include <lights_fragment_maps>
|
|
3331
|
+
#include <lights_fragment_end>
|
|
3332
|
+
#include <aomap_fragment>
|
|
3333
|
+
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
3334
|
+
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
3335
|
+
#include <transmission_fragment>
|
|
3336
|
+
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
3337
|
+
#ifdef USE_SHEEN
|
|
3338
|
+
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
3339
|
+
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
3340
|
+
#endif
|
|
3341
|
+
#ifdef USE_CLEARCOAT
|
|
3342
|
+
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
3343
|
+
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
3344
|
+
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
3345
|
+
#endif
|
|
3346
|
+
#include <opaque_fragment>
|
|
3347
|
+
#include <tonemapping_fragment>
|
|
3348
|
+
#include <colorspace_fragment>
|
|
3349
|
+
#include <fog_fragment>
|
|
3350
|
+
#include <premultiplied_alpha_fragment>
|
|
3351
|
+
#include <dithering_fragment>
|
|
3352
|
+
}`,Nf=`#define TOON
|
|
3353
|
+
varying vec3 vViewPosition;
|
|
3354
|
+
#include <common>
|
|
3355
|
+
#include <batching_pars_vertex>
|
|
3356
|
+
#include <uv_pars_vertex>
|
|
3357
|
+
#include <displacementmap_pars_vertex>
|
|
3358
|
+
#include <color_pars_vertex>
|
|
3359
|
+
#include <fog_pars_vertex>
|
|
3360
|
+
#include <normal_pars_vertex>
|
|
3361
|
+
#include <morphtarget_pars_vertex>
|
|
3362
|
+
#include <skinning_pars_vertex>
|
|
3363
|
+
#include <shadowmap_pars_vertex>
|
|
3364
|
+
#include <logdepthbuf_pars_vertex>
|
|
3365
|
+
#include <clipping_planes_pars_vertex>
|
|
3366
|
+
void main() {
|
|
3367
|
+
#include <uv_vertex>
|
|
3368
|
+
#include <color_vertex>
|
|
3369
|
+
#include <morphinstance_vertex>
|
|
3370
|
+
#include <morphcolor_vertex>
|
|
3371
|
+
#include <batching_vertex>
|
|
3372
|
+
#include <beginnormal_vertex>
|
|
3373
|
+
#include <morphnormal_vertex>
|
|
3374
|
+
#include <skinbase_vertex>
|
|
3375
|
+
#include <skinnormal_vertex>
|
|
3376
|
+
#include <defaultnormal_vertex>
|
|
3377
|
+
#include <normal_vertex>
|
|
3378
|
+
#include <begin_vertex>
|
|
3379
|
+
#include <morphtarget_vertex>
|
|
3380
|
+
#include <skinning_vertex>
|
|
3381
|
+
#include <displacementmap_vertex>
|
|
3382
|
+
#include <project_vertex>
|
|
3383
|
+
#include <logdepthbuf_vertex>
|
|
3384
|
+
#include <clipping_planes_vertex>
|
|
3385
|
+
vViewPosition = - mvPosition.xyz;
|
|
3386
|
+
#include <worldpos_vertex>
|
|
3387
|
+
#include <shadowmap_vertex>
|
|
3388
|
+
#include <fog_vertex>
|
|
3389
|
+
}`,Ff=`#define TOON
|
|
3390
|
+
uniform vec3 diffuse;
|
|
3391
|
+
uniform vec3 emissive;
|
|
3392
|
+
uniform float opacity;
|
|
3393
|
+
#include <common>
|
|
3394
|
+
#include <packing>
|
|
3395
|
+
#include <dithering_pars_fragment>
|
|
3396
|
+
#include <color_pars_fragment>
|
|
3397
|
+
#include <uv_pars_fragment>
|
|
3398
|
+
#include <map_pars_fragment>
|
|
3399
|
+
#include <alphamap_pars_fragment>
|
|
3400
|
+
#include <alphatest_pars_fragment>
|
|
3401
|
+
#include <alphahash_pars_fragment>
|
|
3402
|
+
#include <aomap_pars_fragment>
|
|
3403
|
+
#include <lightmap_pars_fragment>
|
|
3404
|
+
#include <emissivemap_pars_fragment>
|
|
3405
|
+
#include <gradientmap_pars_fragment>
|
|
3406
|
+
#include <fog_pars_fragment>
|
|
3407
|
+
#include <bsdfs>
|
|
3408
|
+
#include <lights_pars_begin>
|
|
3409
|
+
#include <normal_pars_fragment>
|
|
3410
|
+
#include <lights_toon_pars_fragment>
|
|
3411
|
+
#include <shadowmap_pars_fragment>
|
|
3412
|
+
#include <bumpmap_pars_fragment>
|
|
3413
|
+
#include <normalmap_pars_fragment>
|
|
3414
|
+
#include <logdepthbuf_pars_fragment>
|
|
3415
|
+
#include <clipping_planes_pars_fragment>
|
|
3416
|
+
void main() {
|
|
3417
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3418
|
+
#include <clipping_planes_fragment>
|
|
3419
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3420
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3421
|
+
#include <logdepthbuf_fragment>
|
|
3422
|
+
#include <map_fragment>
|
|
3423
|
+
#include <color_fragment>
|
|
3424
|
+
#include <alphamap_fragment>
|
|
3425
|
+
#include <alphatest_fragment>
|
|
3426
|
+
#include <alphahash_fragment>
|
|
3427
|
+
#include <normal_fragment_begin>
|
|
3428
|
+
#include <normal_fragment_maps>
|
|
3429
|
+
#include <emissivemap_fragment>
|
|
3430
|
+
#include <lights_toon_fragment>
|
|
3431
|
+
#include <lights_fragment_begin>
|
|
3432
|
+
#include <lights_fragment_maps>
|
|
3433
|
+
#include <lights_fragment_end>
|
|
3434
|
+
#include <aomap_fragment>
|
|
3435
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
3436
|
+
#include <opaque_fragment>
|
|
3437
|
+
#include <tonemapping_fragment>
|
|
3438
|
+
#include <colorspace_fragment>
|
|
3439
|
+
#include <fog_fragment>
|
|
3440
|
+
#include <premultiplied_alpha_fragment>
|
|
3441
|
+
#include <dithering_fragment>
|
|
3442
|
+
}`,Of=`uniform float size;
|
|
3443
|
+
uniform float scale;
|
|
3444
|
+
#include <common>
|
|
3445
|
+
#include <color_pars_vertex>
|
|
3446
|
+
#include <fog_pars_vertex>
|
|
3447
|
+
#include <morphtarget_pars_vertex>
|
|
3448
|
+
#include <logdepthbuf_pars_vertex>
|
|
3449
|
+
#include <clipping_planes_pars_vertex>
|
|
3450
|
+
#ifdef USE_POINTS_UV
|
|
3451
|
+
varying vec2 vUv;
|
|
3452
|
+
uniform mat3 uvTransform;
|
|
3453
|
+
#endif
|
|
3454
|
+
void main() {
|
|
3455
|
+
#ifdef USE_POINTS_UV
|
|
3456
|
+
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
3457
|
+
#endif
|
|
3458
|
+
#include <color_vertex>
|
|
3459
|
+
#include <morphinstance_vertex>
|
|
3460
|
+
#include <morphcolor_vertex>
|
|
3461
|
+
#include <begin_vertex>
|
|
3462
|
+
#include <morphtarget_vertex>
|
|
3463
|
+
#include <project_vertex>
|
|
3464
|
+
gl_PointSize = size;
|
|
3465
|
+
#ifdef USE_SIZEATTENUATION
|
|
3466
|
+
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
3467
|
+
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
3468
|
+
#endif
|
|
3469
|
+
#include <logdepthbuf_vertex>
|
|
3470
|
+
#include <clipping_planes_vertex>
|
|
3471
|
+
#include <worldpos_vertex>
|
|
3472
|
+
#include <fog_vertex>
|
|
3473
|
+
}`,Bf=`uniform vec3 diffuse;
|
|
3474
|
+
uniform float opacity;
|
|
3475
|
+
#include <common>
|
|
3476
|
+
#include <color_pars_fragment>
|
|
3477
|
+
#include <map_particle_pars_fragment>
|
|
3478
|
+
#include <alphatest_pars_fragment>
|
|
3479
|
+
#include <alphahash_pars_fragment>
|
|
3480
|
+
#include <fog_pars_fragment>
|
|
3481
|
+
#include <logdepthbuf_pars_fragment>
|
|
3482
|
+
#include <clipping_planes_pars_fragment>
|
|
3483
|
+
void main() {
|
|
3484
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3485
|
+
#include <clipping_planes_fragment>
|
|
3486
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
3487
|
+
#include <logdepthbuf_fragment>
|
|
3488
|
+
#include <map_particle_fragment>
|
|
3489
|
+
#include <color_fragment>
|
|
3490
|
+
#include <alphatest_fragment>
|
|
3491
|
+
#include <alphahash_fragment>
|
|
3492
|
+
outgoingLight = diffuseColor.rgb;
|
|
3493
|
+
#include <opaque_fragment>
|
|
3494
|
+
#include <tonemapping_fragment>
|
|
3495
|
+
#include <colorspace_fragment>
|
|
3496
|
+
#include <fog_fragment>
|
|
3497
|
+
#include <premultiplied_alpha_fragment>
|
|
3498
|
+
}`,zf=`#include <common>
|
|
3499
|
+
#include <batching_pars_vertex>
|
|
3500
|
+
#include <fog_pars_vertex>
|
|
3501
|
+
#include <morphtarget_pars_vertex>
|
|
3502
|
+
#include <skinning_pars_vertex>
|
|
3503
|
+
#include <logdepthbuf_pars_vertex>
|
|
3504
|
+
#include <shadowmap_pars_vertex>
|
|
3505
|
+
void main() {
|
|
3506
|
+
#include <batching_vertex>
|
|
3507
|
+
#include <beginnormal_vertex>
|
|
3508
|
+
#include <morphinstance_vertex>
|
|
3509
|
+
#include <morphnormal_vertex>
|
|
3510
|
+
#include <skinbase_vertex>
|
|
3511
|
+
#include <skinnormal_vertex>
|
|
3512
|
+
#include <defaultnormal_vertex>
|
|
3513
|
+
#include <begin_vertex>
|
|
3514
|
+
#include <morphtarget_vertex>
|
|
3515
|
+
#include <skinning_vertex>
|
|
3516
|
+
#include <project_vertex>
|
|
3517
|
+
#include <logdepthbuf_vertex>
|
|
3518
|
+
#include <worldpos_vertex>
|
|
3519
|
+
#include <shadowmap_vertex>
|
|
3520
|
+
#include <fog_vertex>
|
|
3521
|
+
}`,Vf=`uniform vec3 color;
|
|
3522
|
+
uniform float opacity;
|
|
3523
|
+
#include <common>
|
|
3524
|
+
#include <packing>
|
|
3525
|
+
#include <fog_pars_fragment>
|
|
3526
|
+
#include <bsdfs>
|
|
3527
|
+
#include <lights_pars_begin>
|
|
3528
|
+
#include <logdepthbuf_pars_fragment>
|
|
3529
|
+
#include <shadowmap_pars_fragment>
|
|
3530
|
+
#include <shadowmask_pars_fragment>
|
|
3531
|
+
void main() {
|
|
3532
|
+
#include <logdepthbuf_fragment>
|
|
3533
|
+
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
3534
|
+
#include <tonemapping_fragment>
|
|
3535
|
+
#include <colorspace_fragment>
|
|
3536
|
+
#include <fog_fragment>
|
|
3537
|
+
}`,kf=`uniform float rotation;
|
|
3538
|
+
uniform vec2 center;
|
|
3539
|
+
#include <common>
|
|
3540
|
+
#include <uv_pars_vertex>
|
|
3541
|
+
#include <fog_pars_vertex>
|
|
3542
|
+
#include <logdepthbuf_pars_vertex>
|
|
3543
|
+
#include <clipping_planes_pars_vertex>
|
|
3544
|
+
void main() {
|
|
3545
|
+
#include <uv_vertex>
|
|
3546
|
+
vec4 mvPosition = modelViewMatrix[ 3 ];
|
|
3547
|
+
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|
3548
|
+
#ifndef USE_SIZEATTENUATION
|
|
3549
|
+
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
3550
|
+
if ( isPerspective ) scale *= - mvPosition.z;
|
|
3551
|
+
#endif
|
|
3552
|
+
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
3553
|
+
vec2 rotatedPosition;
|
|
3554
|
+
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
3555
|
+
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
3556
|
+
mvPosition.xy += rotatedPosition;
|
|
3557
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
3558
|
+
#include <logdepthbuf_vertex>
|
|
3559
|
+
#include <clipping_planes_vertex>
|
|
3560
|
+
#include <fog_vertex>
|
|
3561
|
+
}`,Gf=`uniform vec3 diffuse;
|
|
3562
|
+
uniform float opacity;
|
|
3563
|
+
#include <common>
|
|
3564
|
+
#include <uv_pars_fragment>
|
|
3565
|
+
#include <map_pars_fragment>
|
|
3566
|
+
#include <alphamap_pars_fragment>
|
|
3567
|
+
#include <alphatest_pars_fragment>
|
|
3568
|
+
#include <alphahash_pars_fragment>
|
|
3569
|
+
#include <fog_pars_fragment>
|
|
3570
|
+
#include <logdepthbuf_pars_fragment>
|
|
3571
|
+
#include <clipping_planes_pars_fragment>
|
|
3572
|
+
void main() {
|
|
3573
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3574
|
+
#include <clipping_planes_fragment>
|
|
3575
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
3576
|
+
#include <logdepthbuf_fragment>
|
|
3577
|
+
#include <map_fragment>
|
|
3578
|
+
#include <alphamap_fragment>
|
|
3579
|
+
#include <alphatest_fragment>
|
|
3580
|
+
#include <alphahash_fragment>
|
|
3581
|
+
outgoingLight = diffuseColor.rgb;
|
|
3582
|
+
#include <opaque_fragment>
|
|
3583
|
+
#include <tonemapping_fragment>
|
|
3584
|
+
#include <colorspace_fragment>
|
|
3585
|
+
#include <fog_fragment>
|
|
3586
|
+
}`,Ue={alphahash_fragment:lu,alphahash_pars_fragment:hu,alphamap_fragment:uu,alphamap_pars_fragment:du,alphatest_fragment:fu,alphatest_pars_fragment:pu,aomap_fragment:mu,aomap_pars_fragment:xu,batching_pars_vertex:gu,batching_vertex:_u,begin_vertex:vu,beginnormal_vertex:Mu,bsdfs:bu,iridescence_fragment:Su,bumpmap_pars_fragment:yu,clipping_planes_fragment:Eu,clipping_planes_pars_fragment:Tu,clipping_planes_pars_vertex:Au,clipping_planes_vertex:wu,color_fragment:Ru,color_pars_fragment:Cu,color_pars_vertex:Pu,color_vertex:Du,common:Lu,cube_uv_reflection_fragment:Iu,defaultnormal_vertex:Uu,displacementmap_pars_vertex:Nu,displacementmap_vertex:Fu,emissivemap_fragment:Ou,emissivemap_pars_fragment:Bu,colorspace_fragment:zu,colorspace_pars_fragment:Vu,envmap_fragment:ku,envmap_common_pars_fragment:Gu,envmap_pars_fragment:Hu,envmap_pars_vertex:Wu,envmap_physical_pars_fragment:td,envmap_vertex:Xu,fog_vertex:qu,fog_pars_vertex:Yu,fog_fragment:Ku,fog_pars_fragment:$u,gradientmap_pars_fragment:Zu,lightmap_pars_fragment:ju,lights_lambert_fragment:Ju,lights_lambert_pars_fragment:Qu,lights_pars_begin:ed,lights_toon_fragment:nd,lights_toon_pars_fragment:id,lights_phong_fragment:rd,lights_phong_pars_fragment:sd,lights_physical_fragment:ad,lights_physical_pars_fragment:od,lights_fragment_begin:cd,lights_fragment_maps:ld,lights_fragment_end:hd,logdepthbuf_fragment:ud,logdepthbuf_pars_fragment:dd,logdepthbuf_pars_vertex:fd,logdepthbuf_vertex:pd,map_fragment:md,map_pars_fragment:xd,map_particle_fragment:gd,map_particle_pars_fragment:_d,metalnessmap_fragment:vd,metalnessmap_pars_fragment:Md,morphinstance_vertex:bd,morphcolor_vertex:Sd,morphnormal_vertex:yd,morphtarget_pars_vertex:Ed,morphtarget_vertex:Td,normal_fragment_begin:Ad,normal_fragment_maps:wd,normal_pars_fragment:Rd,normal_pars_vertex:Cd,normal_vertex:Pd,normalmap_pars_fragment:Dd,clearcoat_normal_fragment_begin:Ld,clearcoat_normal_fragment_maps:Id,clearcoat_pars_fragment:Ud,iridescence_pars_fragment:Nd,opaque_fragment:Fd,packing:Od,premultiplied_alpha_fragment:Bd,project_vertex:zd,dithering_fragment:Vd,dithering_pars_fragment:kd,roughnessmap_fragment:Gd,roughnessmap_pars_fragment:Hd,shadowmap_pars_fragment:Wd,shadowmap_pars_vertex:Xd,shadowmap_vertex:qd,shadowmask_pars_fragment:Yd,skinbase_vertex:Kd,skinning_pars_vertex:$d,skinning_vertex:Zd,skinnormal_vertex:jd,specularmap_fragment:Jd,specularmap_pars_fragment:Qd,tonemapping_fragment:ef,tonemapping_pars_fragment:tf,transmission_fragment:nf,transmission_pars_fragment:rf,uv_pars_fragment:sf,uv_pars_vertex:af,uv_vertex:of,worldpos_vertex:cf,background_vert:lf,background_frag:hf,backgroundCube_vert:uf,backgroundCube_frag:df,cube_vert:ff,cube_frag:pf,depth_vert:mf,depth_frag:xf,distanceRGBA_vert:gf,distanceRGBA_frag:_f,equirect_vert:vf,equirect_frag:Mf,linedashed_vert:bf,linedashed_frag:Sf,meshbasic_vert:yf,meshbasic_frag:Ef,meshlambert_vert:Tf,meshlambert_frag:Af,meshmatcap_vert:wf,meshmatcap_frag:Rf,meshnormal_vert:Cf,meshnormal_frag:Pf,meshphong_vert:Df,meshphong_frag:Lf,meshphysical_vert:If,meshphysical_frag:Uf,meshtoon_vert:Nf,meshtoon_frag:Ff,points_vert:Of,points_frag:Bf,shadow_vert:zf,shadow_frag:Vf,sprite_vert:kf,sprite_frag:Gf},ae={common:{diffuse:{value:new Ne(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ie},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ie}},envmap:{envMap:{value:null},envMapRotation:{value:new Ie},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ie}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ie}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ie},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ie},normalScale:{value:new Xe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ie},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ie}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ie}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ie}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ne(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ne(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0},uvTransform:{value:new Ie}},sprite:{diffuse:{value:new Ne(16777215)},opacity:{value:1},center:{value:new Xe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ie},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0}}},Qt={basic:{uniforms:Tt([ae.common,ae.specularmap,ae.envmap,ae.aomap,ae.lightmap,ae.fog]),vertexShader:Ue.meshbasic_vert,fragmentShader:Ue.meshbasic_frag},lambert:{uniforms:Tt([ae.common,ae.specularmap,ae.envmap,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.fog,ae.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Ue.meshlambert_vert,fragmentShader:Ue.meshlambert_frag},phong:{uniforms:Tt([ae.common,ae.specularmap,ae.envmap,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.fog,ae.lights,{emissive:{value:new Ne(0)},specular:{value:new Ne(1118481)},shininess:{value:30}}]),vertexShader:Ue.meshphong_vert,fragmentShader:Ue.meshphong_frag},standard:{uniforms:Tt([ae.common,ae.envmap,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.roughnessmap,ae.metalnessmap,ae.fog,ae.lights,{emissive:{value:new Ne(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ue.meshphysical_vert,fragmentShader:Ue.meshphysical_frag},toon:{uniforms:Tt([ae.common,ae.aomap,ae.lightmap,ae.emissivemap,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.gradientmap,ae.fog,ae.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Ue.meshtoon_vert,fragmentShader:Ue.meshtoon_frag},matcap:{uniforms:Tt([ae.common,ae.bumpmap,ae.normalmap,ae.displacementmap,ae.fog,{matcap:{value:null}}]),vertexShader:Ue.meshmatcap_vert,fragmentShader:Ue.meshmatcap_frag},points:{uniforms:Tt([ae.points,ae.fog]),vertexShader:Ue.points_vert,fragmentShader:Ue.points_frag},dashed:{uniforms:Tt([ae.common,ae.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ue.linedashed_vert,fragmentShader:Ue.linedashed_frag},depth:{uniforms:Tt([ae.common,ae.displacementmap]),vertexShader:Ue.depth_vert,fragmentShader:Ue.depth_frag},normal:{uniforms:Tt([ae.common,ae.bumpmap,ae.normalmap,ae.displacementmap,{opacity:{value:1}}]),vertexShader:Ue.meshnormal_vert,fragmentShader:Ue.meshnormal_frag},sprite:{uniforms:Tt([ae.sprite,ae.fog]),vertexShader:Ue.sprite_vert,fragmentShader:Ue.sprite_frag},background:{uniforms:{uvTransform:{value:new Ie},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ue.background_vert,fragmentShader:Ue.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ie}},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},distanceRGBA:{uniforms:Tt([ae.common,ae.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ue.distanceRGBA_vert,fragmentShader:Ue.distanceRGBA_frag},shadow:{uniforms:Tt([ae.lights,ae.fog,{color:{value:new Ne(0)},opacity:{value:1}}]),vertexShader:Ue.shadow_vert,fragmentShader:Ue.shadow_frag}};Qt.physical={uniforms:Tt([Qt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ie},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ie},clearcoatNormalScale:{value:new Xe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ie},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ie},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ie},sheen:{value:0},sheenColor:{value:new Ne(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ie},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ie},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ie},transmissionSamplerSize:{value:new Xe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ie},attenuationDistance:{value:0},attenuationColor:{value:new Ne(0)},specularColor:{value:new Ne(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ie},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ie},anisotropyVector:{value:new Xe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ie}}]),vertexShader:Ue.meshphysical_vert,fragmentShader:Ue.meshphysical_frag};const _r={r:0,b:0,g:0},Fn=new Zt,Hf=new He;function Wf(i,e,t,n,r,s,a){const o=new Ne(0);let l=s===!0?0:1,c,h,u=null,d=0,p=null;function x(y){let w=y.isScene===!0?y.background:null;return w&&w.isTexture&&(w=(y.backgroundBlurriness>0?t:e).get(w)),w}function _(y){let w=!1;const C=x(y);C===null?f(o,l):C&&C.isColor&&(f(C,1),w=!0);const E=i.xr.getEnvironmentBlendMode();E==="additive"?n.buffers.color.setClear(0,0,0,1,a):E==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||w)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(y,w){const C=x(w);C&&(C.isCubeTexture||C.mapping===Ir)?(h===void 0&&(h=new St(new Gi(1,1,1),new xn({name:"BackgroundCubeMaterial",uniforms:xi(Qt.backgroundCube.uniforms),vertexShader:Qt.backgroundCube.vertexShader,fragmentShader:Qt.backgroundCube.fragmentShader,side:Ct,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(E,P,z){this.matrixWorld.copyPosition(z.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),Fn.copy(w.backgroundRotation),Fn.x*=-1,Fn.y*=-1,Fn.z*=-1,C.isCubeTexture&&C.isRenderTargetTexture===!1&&(Fn.y*=-1,Fn.z*=-1),h.material.uniforms.envMap.value=C,h.material.uniforms.flipEnvMap.value=C.isCubeTexture&&C.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Hf.makeRotationFromEuler(Fn)),h.material.toneMapped=Ye.getTransfer(C.colorSpace)!==Qe,(u!==C||d!==C.version||p!==i.toneMapping)&&(h.material.needsUpdate=!0,u=C,d=C.version,p=i.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):C&&C.isTexture&&(c===void 0&&(c=new St(new Hi(2,2),new xn({name:"BackgroundMaterial",uniforms:xi(Qt.background.uniforms),vertexShader:Qt.background.vertexShader,fragmentShader:Qt.background.fragmentShader,side:wn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=C,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=Ye.getTransfer(C.colorSpace)!==Qe,C.matrixAutoUpdate===!0&&C.updateMatrix(),c.material.uniforms.uvTransform.value.copy(C.matrix),(u!==C||d!==C.version||p!==i.toneMapping)&&(c.material.needsUpdate=!0,u=C,d=C.version,p=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function f(y,w){y.getRGB(_r,Mc(i)),n.buffers.color.setClear(_r.r,_r.g,_r.b,w,a)}function T(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,w=1){o.set(y),l=w,f(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,f(o,l)},render:_,addToRenderList:m,dispose:T}}function Xf(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null);let s=r,a=!1;function o(M,D,B,k,H){let K=!1;const q=u(k,B,D);s!==q&&(s=q,c(s.object)),K=p(M,k,B,H),K&&x(M,k,B,H),H!==null&&e.update(H,i.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,w(M,D,B,k),H!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function l(){return i.createVertexArray()}function c(M){return i.bindVertexArray(M)}function h(M){return i.deleteVertexArray(M)}function u(M,D,B){const k=B.wireframe===!0;let H=n[M.id];H===void 0&&(H={},n[M.id]=H);let K=H[D.id];K===void 0&&(K={},H[D.id]=K);let q=K[k];return q===void 0&&(q=d(l()),K[k]=q),q}function d(M){const D=[],B=[],k=[];for(let H=0;H<t;H++)D[H]=0,B[H]=0,k[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:B,attributeDivisors:k,object:M,attributes:{},index:null}}function p(M,D,B,k){const H=s.attributes,K=D.attributes;let q=0;const ne=B.getAttributes();for(const G in ne)if(ne[G].location>=0){const se=H[G];let Se=K[G];if(Se===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(Se=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(Se=M.instanceColor)),se===void 0||se.attribute!==Se||Se&&se.data!==Se.data)return!0;q++}return s.attributesNum!==q||s.index!==k}function x(M,D,B,k){const H={},K=D.attributes;let q=0;const ne=B.getAttributes();for(const G in ne)if(ne[G].location>=0){let se=K[G];se===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(se=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(se=M.instanceColor));const Se={};Se.attribute=se,se&&se.data&&(Se.data=se.data),H[G]=Se,q++}s.attributes=H,s.attributesNum=q,s.index=k}function _(){const M=s.newAttributes;for(let D=0,B=M.length;D<B;D++)M[D]=0}function m(M){f(M,0)}function f(M,D){const B=s.newAttributes,k=s.enabledAttributes,H=s.attributeDivisors;B[M]=1,k[M]===0&&(i.enableVertexAttribArray(M),k[M]=1),H[M]!==D&&(i.vertexAttribDivisor(M,D),H[M]=D)}function T(){const M=s.newAttributes,D=s.enabledAttributes;for(let B=0,k=D.length;B<k;B++)D[B]!==M[B]&&(i.disableVertexAttribArray(B),D[B]=0)}function y(M,D,B,k,H,K,q){q===!0?i.vertexAttribIPointer(M,D,B,H,K):i.vertexAttribPointer(M,D,B,k,H,K)}function w(M,D,B,k){_();const H=k.attributes,K=B.getAttributes(),q=D.defaultAttributeValues;for(const ne in K){const G=K[ne];if(G.location>=0){let te=H[ne];if(te===void 0&&(ne==="instanceMatrix"&&M.instanceMatrix&&(te=M.instanceMatrix),ne==="instanceColor"&&M.instanceColor&&(te=M.instanceColor)),te!==void 0){const se=te.normalized,Se=te.itemSize,We=e.get(te);if(We===void 0)continue;const Ze=We.buffer,nt=We.type,it=We.bytesPerElement,X=nt===i.INT||nt===i.UNSIGNED_INT||te.gpuType===_a;if(te.isInterleavedBufferAttribute){const Z=te.data,de=Z.stride,Le=te.offset;if(Z.isInstancedInterleavedBuffer){for(let ve=0;ve<G.locationSize;ve++)f(G.location+ve,Z.meshPerAttribute);M.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ve=0;ve<G.locationSize;ve++)m(G.location+ve);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let ve=0;ve<G.locationSize;ve++)y(G.location+ve,Se/G.locationSize,nt,se,de*it,(Le+Se/G.locationSize*ve)*it,X)}else{if(te.isInstancedBufferAttribute){for(let Z=0;Z<G.locationSize;Z++)f(G.location+Z,te.meshPerAttribute);M.isInstancedMesh!==!0&&k._maxInstanceCount===void 0&&(k._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let Z=0;Z<G.locationSize;Z++)m(G.location+Z);i.bindBuffer(i.ARRAY_BUFFER,Ze);for(let Z=0;Z<G.locationSize;Z++)y(G.location+Z,Se/G.locationSize,nt,se,Se*it,Se/G.locationSize*Z*it,X)}}else if(q!==void 0){const se=q[ne];if(se!==void 0)switch(se.length){case 2:i.vertexAttrib2fv(G.location,se);break;case 3:i.vertexAttrib3fv(G.location,se);break;case 4:i.vertexAttrib4fv(G.location,se);break;default:i.vertexAttrib1fv(G.location,se)}}}}T()}function C(){z();for(const M in n){const D=n[M];for(const B in D){const k=D[B];for(const H in k)h(k[H].object),delete k[H];delete D[B]}delete n[M]}}function E(M){if(n[M.id]===void 0)return;const D=n[M.id];for(const B in D){const k=D[B];for(const H in k)h(k[H].object),delete k[H];delete D[B]}delete n[M.id]}function P(M){for(const D in n){const B=n[D];if(B[M.id]===void 0)continue;const k=B[M.id];for(const H in k)h(k[H].object),delete k[H];delete B[M.id]}}function z(){b(),a=!0,s!==r&&(s=r,c(s.object))}function b(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:z,resetDefaultState:b,dispose:C,releaseStatesOfGeometry:E,releaseStatesOfProgram:P,initAttributes:_,enableAttribute:m,disableUnusedAttributes:T}}function qf(i,e,t){let n;function r(c){n=c}function s(c,h){i.drawArrays(n,c,h),t.update(h,n,1)}function a(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),t.update(h,n,u))}function o(c,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let p=0;for(let x=0;x<u;x++)p+=h[x];t.update(p,n,1)}function l(c,h,u,d){if(u===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<c.length;x++)a(c[x],h[x],d[x]);else{p.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let x=0;for(let _=0;_<u;_++)x+=h[_]*d[_];t.update(x,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Yf(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const P=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(P.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(P){return!(P!==zt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(P){const z=P===gi&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(P!==nn&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&P!==Yt&&!z)}function l(P){if(P==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";P="mediump"}return P==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(_e("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),T=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),y=i.getParameter(i.MAX_VARYING_VECTORS),w=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),C=x>0,E=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:x,maxTextureSize:_,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:T,maxVaryings:y,maxFragmentUniforms:w,vertexTextures:C,maxSamples:E}}function Kf(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new Bn,o=new Ie,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const p=u.length!==0||d||n!==0||r;return r=d,n=u.length,p},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,p){const x=u.clippingPlanes,_=u.clipIntersection,m=u.clipShadows,f=i.get(u);if(!r||x===null||x.length===0||s&&!m)s?h(null):c();else{const T=s?0:n,y=T*4;let w=f.clippingState||null;l.value=w,w=h(x,d,y,p);for(let C=0;C!==y;++C)w[C]=t[C];f.clippingState=w,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=T}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,p,x){const _=u!==null?u.length:0;let m=null;if(_!==0){if(m=l.value,x!==!0||m===null){const f=p+_*4,T=d.matrixWorldInverse;o.getNormalMatrix(T),(m===null||m.length<f)&&(m=new Float32Array(f));for(let y=0,w=p;y!==_;++y,w+=4)a.copy(u[y]).applyMatrix4(T,o),a.normal.toArray(m,w),m[w+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}function $f(i){let e=new WeakMap;function t(a,o){return o===Is?a.mapping=di:o===Us&&(a.mapping=fi),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===Is||o===Us)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Sh(l.height);return c.fromEquirectangularTexture(i,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const Tn=4,Fo=[.125,.215,.35,.446,.526,.582],Vn=20,Zf=256,Di=new Dc,Oo=new Ne;let vs=null,Ms=0,bs=0,Ss=!1;const jf=new U;class Bo{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=jf}=s;vs=this._renderer.getRenderTarget(),Ms=this._renderer.getActiveCubeFace(),bs=this._renderer.getActiveMipmapLevel(),Ss=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ko(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Vo(),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(vs,Ms,bs),this._renderer.xr.enabled=Ss,e.scissorTest=!1,ci(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===di||e.mapping===fi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),vs=this._renderer.getRenderTarget(),Ms=this._renderer.getActiveCubeFace(),bs=this._renderer.getActiveMipmapLevel(),Ss=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:At,minFilter:At,generateMipmaps:!1,type:gi,format:zt,colorSpace:pi,depthBuffer:!1},r=zo(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=zo(e,t,n);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Jf(s)),this._blurMaterial=ep(s,e,t),this._ggxMaterial=Qf(s,e,t)}return r}_compileMaterial(e){const t=new St(new Vt,e);this._renderer.compile(t,Di)}_sceneToCubeUV(e,t,n,r,s){const l=new Ft(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,p=u.toneMapping;u.getClearColor(Oo),u.toneMapping=An,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(r),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new St(new Gi,new Wn({name:"PMREM.Background",side:Ct,depthWrite:!1,depthTest:!1})));const _=this._backgroundBox,m=_.material;let f=!1;const T=e.background;T?T.isColor&&(m.color.copy(T),e.background=null,f=!0):(m.color.copy(Oo),f=!0);for(let y=0;y<6;y++){const w=y%3;w===0?(l.up.set(0,c[y],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[y],s.y,s.z)):w===1?(l.up.set(0,0,c[y]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[y],s.z)):(l.up.set(0,c[y],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[y]));const C=this._cubeSize;ci(r,w*C,y>2?C:0,C,C),u.setRenderTarget(r),f&&u.render(_,l),u.render(e,l)}u.toneMapping=p,u.autoClear=d,e.background=T}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===di||e.mapping===fi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ko()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Vo());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;ci(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Di)}_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 l=a.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-h*h),d=.05+c*.95,p=u*d,{_lodMax:x}=this,_=this._sizeLods[n],m=3*_*(n>x-Tn?n-x+Tn:0),f=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=x-t,ci(s,m,f,3*_,2*_),r.setRenderTarget(s),r.render(o,Di),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=x-n,ci(e,m,f,3*_,2*_),r.setRenderTarget(e),r.render(o,Di)}_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 l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Be("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[r];u.material=c;const d=c.uniforms,p=this._sizeLods[n]-1,x=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*Vn-1),_=s/x,m=isFinite(s)?1+Math.floor(h*_):Vn;m>Vn&&_e(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Vn}`);const f=[];let T=0;for(let P=0;P<Vn;++P){const z=P/_,b=Math.exp(-z*z/2);f.push(b),P===0?T+=b:P<m&&(T+=2*b)}for(let P=0;P<f.length;P++)f[P]=f[P]/T;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:y}=this;d.dTheta.value=x,d.mipInt.value=y-n;const w=this._sizeLods[r],C=3*w*(r>y-Tn?r-y+Tn:0),E=4*(this._cubeSize-w);ci(t,C,E,3*w,2*w),l.setRenderTarget(t),l.render(u,Di)}}function Jf(i){const e=[],t=[],n=[];let r=i;const s=i-Tn+1+Fo.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>i-Tn?l=Fo[a-i+Tn-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],p=6,x=6,_=3,m=2,f=1,T=new Float32Array(_*x*p),y=new Float32Array(m*x*p),w=new Float32Array(f*x*p);for(let E=0;E<p;E++){const P=E%3*2/3-1,z=E>2?0:-1,b=[P,z,0,P+2/3,z,0,P+2/3,z+1,0,P,z,0,P+2/3,z+1,0,P,z+1,0];T.set(b,_*x*E),y.set(d,m*x*E);const M=[E,E,E,E,E,E];w.set(M,f*x*E)}const C=new Vt;C.setAttribute("position",new bt(T,_)),C.setAttribute("uv",new bt(y,m)),C.setAttribute("faceIndex",new bt(w,f)),n.push(new St(C,null)),r>Tn&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function zo(i,e,t){const n=new Hn(i,e,t);return n.texture.mapping=Ir,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ci(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Qf(i,e,t){return new xn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Zf,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:zr(),fragmentShader:`
|
|
3587
|
+
|
|
3588
|
+
precision highp float;
|
|
3589
|
+
precision highp int;
|
|
3590
|
+
|
|
3591
|
+
varying vec3 vOutputDirection;
|
|
3592
|
+
|
|
3593
|
+
uniform sampler2D envMap;
|
|
3594
|
+
uniform float roughness;
|
|
3595
|
+
uniform float mipInt;
|
|
3596
|
+
|
|
3597
|
+
#define ENVMAP_TYPE_CUBE_UV
|
|
3598
|
+
#include <cube_uv_reflection_fragment>
|
|
3599
|
+
|
|
3600
|
+
#define PI 3.14159265359
|
|
3601
|
+
|
|
3602
|
+
// Van der Corput radical inverse
|
|
3603
|
+
float radicalInverse_VdC(uint bits) {
|
|
3604
|
+
bits = (bits << 16u) | (bits >> 16u);
|
|
3605
|
+
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
|
3606
|
+
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
|
3607
|
+
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
|
3608
|
+
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
|
3609
|
+
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
|
3610
|
+
}
|
|
3611
|
+
|
|
3612
|
+
// Hammersley sequence
|
|
3613
|
+
vec2 hammersley(uint i, uint N) {
|
|
3614
|
+
return vec2(float(i) / float(N), radicalInverse_VdC(i));
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
// GGX VNDF importance sampling (Eric Heitz 2018)
|
|
3618
|
+
// "Sampling the GGX Distribution of Visible Normals"
|
|
3619
|
+
// https://jcgt.org/published/0007/04/01/
|
|
3620
|
+
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
|
|
3621
|
+
float alpha = roughness * roughness;
|
|
3622
|
+
|
|
3623
|
+
// Section 3.2: Transform view direction to hemisphere configuration
|
|
3624
|
+
vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
|
|
3625
|
+
|
|
3626
|
+
// Section 4.1: Orthonormal basis
|
|
3627
|
+
float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
|
|
3628
|
+
vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
|
|
3629
|
+
vec3 T2 = cross(Vh, T1);
|
|
3630
|
+
|
|
3631
|
+
// Section 4.2: Parameterization of projected area
|
|
3632
|
+
float r = sqrt(Xi.x);
|
|
3633
|
+
float phi = 2.0 * PI * Xi.y;
|
|
3634
|
+
float t1 = r * cos(phi);
|
|
3635
|
+
float t2 = r * sin(phi);
|
|
3636
|
+
float s = 0.5 * (1.0 + Vh.z);
|
|
3637
|
+
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
|
|
3638
|
+
|
|
3639
|
+
// Section 4.3: Reprojection onto hemisphere
|
|
3640
|
+
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
|
|
3641
|
+
|
|
3642
|
+
// Section 3.4: Transform back to ellipsoid configuration
|
|
3643
|
+
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
void main() {
|
|
3647
|
+
vec3 N = normalize(vOutputDirection);
|
|
3648
|
+
vec3 V = N; // Assume view direction equals normal for pre-filtering
|
|
3649
|
+
|
|
3650
|
+
vec3 prefilteredColor = vec3(0.0);
|
|
3651
|
+
float totalWeight = 0.0;
|
|
3652
|
+
|
|
3653
|
+
// For very low roughness, just sample the environment directly
|
|
3654
|
+
if (roughness < 0.001) {
|
|
3655
|
+
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
|
|
3656
|
+
return;
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
// Tangent space basis for VNDF sampling
|
|
3660
|
+
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
|
3661
|
+
vec3 tangent = normalize(cross(up, N));
|
|
3662
|
+
vec3 bitangent = cross(N, tangent);
|
|
3663
|
+
|
|
3664
|
+
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
|
|
3665
|
+
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
|
|
3666
|
+
|
|
3667
|
+
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
|
|
3668
|
+
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
|
|
3669
|
+
|
|
3670
|
+
// Transform H back to world space
|
|
3671
|
+
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
|
|
3672
|
+
vec3 L = normalize(2.0 * dot(V, H) * H - V);
|
|
3673
|
+
|
|
3674
|
+
float NdotL = max(dot(N, L), 0.0);
|
|
3675
|
+
|
|
3676
|
+
if(NdotL > 0.0) {
|
|
3677
|
+
// Sample environment at fixed mip level
|
|
3678
|
+
// VNDF importance sampling handles the distribution filtering
|
|
3679
|
+
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
|
|
3680
|
+
|
|
3681
|
+
// Weight by NdotL for the split-sum approximation
|
|
3682
|
+
// VNDF PDF naturally accounts for the visible microfacet distribution
|
|
3683
|
+
prefilteredColor += sampleColor * NdotL;
|
|
3684
|
+
totalWeight += NdotL;
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
|
|
3688
|
+
if (totalWeight > 0.0) {
|
|
3689
|
+
prefilteredColor = prefilteredColor / totalWeight;
|
|
3690
|
+
}
|
|
3691
|
+
|
|
3692
|
+
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
3693
|
+
}
|
|
3694
|
+
`,blending:pn,depthTest:!1,depthWrite:!1})}function ep(i,e,t){const n=new Float32Array(Vn),r=new U(0,1,0);return new xn({name:"SphericalGaussianBlur",defines:{n:Vn,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:zr(),fragmentShader:`
|
|
3695
|
+
|
|
3696
|
+
precision mediump float;
|
|
3697
|
+
precision mediump int;
|
|
3698
|
+
|
|
3699
|
+
varying vec3 vOutputDirection;
|
|
3700
|
+
|
|
3701
|
+
uniform sampler2D envMap;
|
|
3702
|
+
uniform int samples;
|
|
3703
|
+
uniform float weights[ n ];
|
|
3704
|
+
uniform bool latitudinal;
|
|
3705
|
+
uniform float dTheta;
|
|
3706
|
+
uniform float mipInt;
|
|
3707
|
+
uniform vec3 poleAxis;
|
|
3708
|
+
|
|
3709
|
+
#define ENVMAP_TYPE_CUBE_UV
|
|
3710
|
+
#include <cube_uv_reflection_fragment>
|
|
3711
|
+
|
|
3712
|
+
vec3 getSample( float theta, vec3 axis ) {
|
|
3713
|
+
|
|
3714
|
+
float cosTheta = cos( theta );
|
|
3715
|
+
// Rodrigues' axis-angle rotation
|
|
3716
|
+
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
3717
|
+
+ cross( axis, vOutputDirection ) * sin( theta )
|
|
3718
|
+
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
3719
|
+
|
|
3720
|
+
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
3721
|
+
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
void main() {
|
|
3725
|
+
|
|
3726
|
+
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
3727
|
+
|
|
3728
|
+
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
3729
|
+
|
|
3730
|
+
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
3731
|
+
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3734
|
+
axis = normalize( axis );
|
|
3735
|
+
|
|
3736
|
+
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
3737
|
+
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
3738
|
+
|
|
3739
|
+
for ( int i = 1; i < n; i++ ) {
|
|
3740
|
+
|
|
3741
|
+
if ( i >= samples ) {
|
|
3742
|
+
|
|
3743
|
+
break;
|
|
3744
|
+
|
|
3745
|
+
}
|
|
3746
|
+
|
|
3747
|
+
float theta = dTheta * float( i );
|
|
3748
|
+
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
3749
|
+
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
3750
|
+
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
}
|
|
3754
|
+
`,blending:pn,depthTest:!1,depthWrite:!1})}function Vo(){return new xn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:zr(),fragmentShader:`
|
|
3755
|
+
|
|
3756
|
+
precision mediump float;
|
|
3757
|
+
precision mediump int;
|
|
3758
|
+
|
|
3759
|
+
varying vec3 vOutputDirection;
|
|
3760
|
+
|
|
3761
|
+
uniform sampler2D envMap;
|
|
3762
|
+
|
|
3763
|
+
#include <common>
|
|
3764
|
+
|
|
3765
|
+
void main() {
|
|
3766
|
+
|
|
3767
|
+
vec3 outputDirection = normalize( vOutputDirection );
|
|
3768
|
+
vec2 uv = equirectUv( outputDirection );
|
|
3769
|
+
|
|
3770
|
+
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3771
|
+
|
|
3772
|
+
}
|
|
3773
|
+
`,blending:pn,depthTest:!1,depthWrite:!1})}function ko(){return new xn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:zr(),fragmentShader:`
|
|
3774
|
+
|
|
3775
|
+
precision mediump float;
|
|
3776
|
+
precision mediump int;
|
|
3777
|
+
|
|
3778
|
+
uniform float flipEnvMap;
|
|
3779
|
+
|
|
3780
|
+
varying vec3 vOutputDirection;
|
|
3781
|
+
|
|
3782
|
+
uniform samplerCube envMap;
|
|
3783
|
+
|
|
3784
|
+
void main() {
|
|
3785
|
+
|
|
3786
|
+
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3787
|
+
|
|
3788
|
+
}
|
|
3789
|
+
`,blending:pn,depthTest:!1,depthWrite:!1})}function zr(){return`
|
|
3790
|
+
|
|
3791
|
+
precision mediump float;
|
|
3792
|
+
precision mediump int;
|
|
3793
|
+
|
|
3794
|
+
attribute float faceIndex;
|
|
3795
|
+
|
|
3796
|
+
varying vec3 vOutputDirection;
|
|
3797
|
+
|
|
3798
|
+
// RH coordinate system; PMREM face-indexing convention
|
|
3799
|
+
vec3 getDirection( vec2 uv, float face ) {
|
|
3800
|
+
|
|
3801
|
+
uv = 2.0 * uv - 1.0;
|
|
3802
|
+
|
|
3803
|
+
vec3 direction = vec3( uv, 1.0 );
|
|
3804
|
+
|
|
3805
|
+
if ( face == 0.0 ) {
|
|
3806
|
+
|
|
3807
|
+
direction = direction.zyx; // ( 1, v, u ) pos x
|
|
3808
|
+
|
|
3809
|
+
} else if ( face == 1.0 ) {
|
|
3810
|
+
|
|
3811
|
+
direction = direction.xzy;
|
|
3812
|
+
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
3813
|
+
|
|
3814
|
+
} else if ( face == 2.0 ) {
|
|
3815
|
+
|
|
3816
|
+
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
3817
|
+
|
|
3818
|
+
} else if ( face == 3.0 ) {
|
|
3819
|
+
|
|
3820
|
+
direction = direction.zyx;
|
|
3821
|
+
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
3822
|
+
|
|
3823
|
+
} else if ( face == 4.0 ) {
|
|
3824
|
+
|
|
3825
|
+
direction = direction.xzy;
|
|
3826
|
+
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
3827
|
+
|
|
3828
|
+
} else if ( face == 5.0 ) {
|
|
3829
|
+
|
|
3830
|
+
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
3831
|
+
|
|
3832
|
+
}
|
|
3833
|
+
|
|
3834
|
+
return direction;
|
|
3835
|
+
|
|
3836
|
+
}
|
|
3837
|
+
|
|
3838
|
+
void main() {
|
|
3839
|
+
|
|
3840
|
+
vOutputDirection = getDirection( uv, faceIndex );
|
|
3841
|
+
gl_Position = vec4( position, 1.0 );
|
|
3842
|
+
|
|
3843
|
+
}
|
|
3844
|
+
`}function tp(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===Is||l===Us,h=l===di||l===fi;if(c||h){let u=e.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Bo(i)),u=c?t.fromEquirectangular(o,u):t.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),u.texture;if(u!==void 0)return u.texture;{const p=o.image;return c&&p&&p.height>0||h&&p&&r(p)?(t===null&&(t=new Bo(i)),u=c?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",s),u.texture):null}}}return o}function r(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function np(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&&ki("WebGLRenderer: "+n+" extension not supported."),r}}}function ip(i,e,t,n){const r={},s=new WeakMap;function a(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const x in d.attributes)e.remove(d.attributes[x]);d.removeEventListener("dispose",a),delete r[d.id];const p=s.get(d);p&&(e.remove(p),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(u){const d=u.attributes;for(const p in d)e.update(d[p],i.ARRAY_BUFFER)}function c(u){const d=[],p=u.index,x=u.attributes.position;let _=0;if(p!==null){const T=p.array;_=p.version;for(let y=0,w=T.length;y<w;y+=3){const C=T[y+0],E=T[y+1],P=T[y+2];d.push(C,E,E,P,P,C)}}else if(x!==void 0){const T=x.array;_=x.version;for(let y=0,w=T.length/3-1;y<w;y+=3){const C=y+0,E=y+1,P=y+2;d.push(C,E,E,P,P,C)}}else return;const m=new(pc(d)?vc:_c)(d,1);m.version=_;const f=s.get(u);f&&e.remove(f),s.set(u,m)}function h(u){const d=s.get(u);if(d){const p=u.index;p!==null&&d.version<p.version&&c(u)}else c(u);return s.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function rp(i,e,t){let n;function r(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,p){i.drawElements(n,p,s,d*a),t.update(p,n,1)}function c(d,p,x){x!==0&&(i.drawElementsInstanced(n,p,s,d*a,x),t.update(p,n,x))}function h(d,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,s,d,0,x);let m=0;for(let f=0;f<x;f++)m+=p[f];t.update(m,n,1)}function u(d,p,x,_){if(x===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<d.length;f++)c(d[f]/a,p[f],_[f]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,s,d,0,_,0,x);let f=0;for(let T=0;T<x;T++)f+=p[T]*_[T];t.update(f,n,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function sp(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:Be("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 ap(i,e,t){const n=new WeakMap,r=new Ke;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let b=function(){P.dispose(),n.delete(o),o.removeEventListener("dispose",b)};d!==void 0&&d.texture.dispose();const p=o.morphAttributes.position!==void 0,x=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],T=o.morphAttributes.color||[];let y=0;p===!0&&(y=1),x===!0&&(y=2),_===!0&&(y=3);let w=o.attributes.position.count*y,C=1;w>e.maxTextureSize&&(C=Math.ceil(w/e.maxTextureSize),w=e.maxTextureSize);const E=new Float32Array(w*C*4*u),P=new mc(E,w,C,u);P.type=Yt,P.needsUpdate=!0;const z=y*4;for(let M=0;M<u;M++){const D=m[M],B=f[M],k=T[M],H=w*C*4*M;for(let K=0;K<D.count;K++){const q=K*z;p===!0&&(r.fromBufferAttribute(D,K),E[H+q+0]=r.x,E[H+q+1]=r.y,E[H+q+2]=r.z,E[H+q+3]=0),x===!0&&(r.fromBufferAttribute(B,K),E[H+q+4]=r.x,E[H+q+5]=r.y,E[H+q+6]=r.z,E[H+q+7]=0),_===!0&&(r.fromBufferAttribute(k,K),E[H+q+8]=r.x,E[H+q+9]=r.y,E[H+q+10]=r.z,E[H+q+11]=k.itemSize===4?r.w:1)}}d={count:u,texture:P,size:new Xe(w,C)},n.set(o,d),o.addEventListener("dispose",b)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let p=0;for(let _=0;_<c.length;_++)p+=c[_];const x=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(i,"morphTargetBaseInfluence",x),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function op(i,e,t,n){let r=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,u=e.get(l,h);if(r.get(u)!==c&&(e.update(u),r.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return u}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const Ic=new gt,Go=new wc(1,1),Uc=new mc,Nc=new sh,Fc=new Sc,Ho=[],Wo=[],Xo=new Float32Array(16),qo=new Float32Array(9),Yo=new Float32Array(4);function bi(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=Ho[r];if(s===void 0&&(s=new Float32Array(r),Ho[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 pt(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 mt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Vr(i,e){let t=Wo[e];t===void 0&&(t=new Int32Array(e),Wo[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function cp(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function lp(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(pt(t,e))return;i.uniform2fv(this.addr,e),mt(t,e)}}function hp(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(pt(t,e))return;i.uniform3fv(this.addr,e),mt(t,e)}}function up(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(pt(t,e))return;i.uniform4fv(this.addr,e),mt(t,e)}}function dp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(pt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),mt(t,e)}else{if(pt(t,n))return;Yo.set(n),i.uniformMatrix2fv(this.addr,!1,Yo),mt(t,n)}}function fp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(pt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),mt(t,e)}else{if(pt(t,n))return;qo.set(n),i.uniformMatrix3fv(this.addr,!1,qo),mt(t,n)}}function pp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(pt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),mt(t,e)}else{if(pt(t,n))return;Xo.set(n),i.uniformMatrix4fv(this.addr,!1,Xo),mt(t,n)}}function mp(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function xp(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(pt(t,e))return;i.uniform2iv(this.addr,e),mt(t,e)}}function gp(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(pt(t,e))return;i.uniform3iv(this.addr,e),mt(t,e)}}function _p(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(pt(t,e))return;i.uniform4iv(this.addr,e),mt(t,e)}}function vp(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Mp(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(pt(t,e))return;i.uniform2uiv(this.addr,e),mt(t,e)}}function bp(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(pt(t,e))return;i.uniform3uiv(this.addr,e),mt(t,e)}}function Sp(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(pt(t,e))return;i.uniform4uiv(this.addr,e),mt(t,e)}}function yp(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?(Go.compareFunction=fc,s=Go):s=Ic,t.setTexture2D(e||s,r)}function Ep(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Nc,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.setTextureCube(e||Fc,r)}function Ap(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Uc,r)}function wp(i){switch(i){case 5126:return cp;case 35664:return lp;case 35665:return hp;case 35666:return up;case 35674:return dp;case 35675:return fp;case 35676:return pp;case 5124:case 35670:return mp;case 35667:case 35671:return xp;case 35668:case 35672:return gp;case 35669:case 35673:return _p;case 5125:return vp;case 36294:return Mp;case 36295:return bp;case 36296:return Sp;case 35678:case 36198:case 36298:case 36306:case 35682:return yp;case 35679:case 36299:case 36307:return Ep;case 35680:case 36300:case 36308:case 36293:return Tp;case 36289:case 36303:case 36311:case 36292:return Ap}}function Rp(i,e){i.uniform1fv(this.addr,e)}function Cp(i,e){const t=bi(e,this.size,2);i.uniform2fv(this.addr,t)}function Pp(i,e){const t=bi(e,this.size,3);i.uniform3fv(this.addr,t)}function Dp(i,e){const t=bi(e,this.size,4);i.uniform4fv(this.addr,t)}function Lp(i,e){const t=bi(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Ip(i,e){const t=bi(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Up(i,e){const t=bi(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Np(i,e){i.uniform1iv(this.addr,e)}function Fp(i,e){i.uniform2iv(this.addr,e)}function Op(i,e){i.uniform3iv(this.addr,e)}function Bp(i,e){i.uniform4iv(this.addr,e)}function zp(i,e){i.uniform1uiv(this.addr,e)}function Vp(i,e){i.uniform2uiv(this.addr,e)}function kp(i,e){i.uniform3uiv(this.addr,e)}function Gp(i,e){i.uniform4uiv(this.addr,e)}function Hp(i,e,t){const n=this.cache,r=e.length,s=Vr(t,r);pt(n,s)||(i.uniform1iv(this.addr,s),mt(n,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Ic,s[a])}function Wp(i,e,t){const n=this.cache,r=e.length,s=Vr(t,r);pt(n,s)||(i.uniform1iv(this.addr,s),mt(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Nc,s[a])}function Xp(i,e,t){const n=this.cache,r=e.length,s=Vr(t,r);pt(n,s)||(i.uniform1iv(this.addr,s),mt(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Fc,s[a])}function qp(i,e,t){const n=this.cache,r=e.length,s=Vr(t,r);pt(n,s)||(i.uniform1iv(this.addr,s),mt(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Uc,s[a])}function Yp(i){switch(i){case 5126:return Rp;case 35664:return Cp;case 35665:return Pp;case 35666:return Dp;case 35674:return Lp;case 35675:return Ip;case 35676:return Up;case 5124:case 35670:return Np;case 35667:case 35671:return Fp;case 35668:case 35672:return Op;case 35669:case 35673:return Bp;case 5125:return zp;case 36294:return Vp;case 36295:return kp;case 36296:return Gp;case 35678:case 36198:case 36298:case 36306:case 35682:return Hp;case 35679:case 36299:case 36307:return Wp;case 35680:case 36300:case 36308:case 36293:return Xp;case 36289:case 36303:case 36311:case 36292:return qp}}class Kp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=wp(t.type)}}class $p{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Yp(t.type)}}class Zp{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 ys=/(\w+)(\])?(\[|\.)?/g;function Ko(i,e){i.seq.push(e),i.map[e.id]=e}function jp(i,e,t){const n=i.name,r=n.length;for(ys.lastIndex=0;;){const s=ys.exec(n),a=ys.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){Ko(t,c===void 0?new Kp(o,i,e):new $p(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new Zp(o),Ko(t,u)),t=u}}}class Er{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);jp(s,a,this)}}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],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.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 $o(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Jp=37297;let Qp=0;function em(i,e){const t=i.split(`
|
|
3845
|
+
`),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(`
|
|
3846
|
+
`)}const Zo=new Ie;function tm(i){Ye._getMatrix(Zo,Ye.workingColorSpace,i);const e=`mat3( ${Zo.elements.map(t=>t.toFixed(4))} )`;switch(Ye.getTransfer(i)){case Ar:return[e,"LinearTransferOETF"];case Qe:return[e,"sRGBTransferOETF"];default:return _e("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function jo(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()+`
|
|
3847
|
+
|
|
3848
|
+
`+s+`
|
|
3849
|
+
|
|
3850
|
+
`+em(i.getShaderSource(e),o)}else return s}function nm(i,e){const t=tm(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
3851
|
+
`)}function im(i,e){let t;switch(e){case xl:t="Linear";break;case gl:t="Reinhard";break;case _l:t="Cineon";break;case vl:t="ACESFilmic";break;case bl:t="AgX";break;case Sl:t="Neutral";break;case Ml:t="Custom";break;default:_e("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const vr=new U;function rm(){Ye.getLuminanceCoefficients(vr);const i=vr.x.toFixed(4),e=vr.y.toFixed(4),t=vr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
3852
|
+
`)}function sm(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ii).join(`
|
|
3853
|
+
`)}function am(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
3854
|
+
`)}function om(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 Ii(i){return i!==""}function Jo(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 Qo(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const cm=/^[ \t]*#include +<([\w\d./]+)>/gm;function ma(i){return i.replace(cm,hm)}const lm=new Map;function hm(i,e){let t=Ue[e];if(t===void 0){const n=lm.get(e);if(n!==void 0)t=Ue[n],_e('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return ma(t)}const um=/#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 ec(i){return i.replace(um,dm)}function dm(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 tc(i){let e=`precision ${i.precision} float;
|
|
3855
|
+
precision ${i.precision} int;
|
|
3856
|
+
precision ${i.precision} sampler2D;
|
|
3857
|
+
precision ${i.precision} samplerCube;
|
|
3858
|
+
precision ${i.precision} sampler3D;
|
|
3859
|
+
precision ${i.precision} sampler2DArray;
|
|
3860
|
+
precision ${i.precision} sampler2DShadow;
|
|
3861
|
+
precision ${i.precision} samplerCubeShadow;
|
|
3862
|
+
precision ${i.precision} sampler2DArrayShadow;
|
|
3863
|
+
precision ${i.precision} isampler2D;
|
|
3864
|
+
precision ${i.precision} isampler3D;
|
|
3865
|
+
precision ${i.precision} isamplerCube;
|
|
3866
|
+
precision ${i.precision} isampler2DArray;
|
|
3867
|
+
precision ${i.precision} usampler2D;
|
|
3868
|
+
precision ${i.precision} usampler3D;
|
|
3869
|
+
precision ${i.precision} usamplerCube;
|
|
3870
|
+
precision ${i.precision} usampler2DArray;
|
|
3871
|
+
`;return i.precision==="highp"?e+=`
|
|
3872
|
+
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
3873
|
+
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
3874
|
+
#define LOW_PRECISION`),e}function fm(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===sc?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===$c?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===un&&(e="SHADOWMAP_TYPE_VSM"),e}function pm(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case di:case fi:e="ENVMAP_TYPE_CUBE";break;case Ir:e="ENVMAP_TYPE_CUBE_UV";break}return e}function mm(i){let e="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===fi&&(e="ENVMAP_MODE_REFRACTION"),e}function xm(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case ga:e="ENVMAP_BLENDING_MULTIPLY";break;case pl:e="ENVMAP_BLENDING_MIX";break;case ml:e="ENVMAP_BLENDING_ADD";break}return e}function gm(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),112)),texelHeight:n,maxMip:t}}function _m(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=fm(t),c=pm(t),h=mm(t),u=xm(t),d=gm(t),p=sm(t),x=am(s),_=r.createProgram();let m,f,T=t.glslVersion?"#version "+t.glslVersion+`
|
|
3875
|
+
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(Ii).join(`
|
|
3876
|
+
`),m.length>0&&(m+=`
|
|
3877
|
+
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(Ii).join(`
|
|
3878
|
+
`),f.length>0&&(f+=`
|
|
3879
|
+
`)):(m=[tc(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,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 "+h:"",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.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 "+l:"",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",`
|
|
3880
|
+
`].filter(Ii).join(`
|
|
3881
|
+
`),f=[tc(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,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 "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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.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_IRIDESCENCE":"",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||t.batchingColor?"#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.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 "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",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?im("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ue.colorspace_pars_fragment,nm("linearToOutputTexel",t.outputColorSpace),rm(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
3882
|
+
`].filter(Ii).join(`
|
|
3883
|
+
`)),a=ma(a),a=Jo(a,t),a=Qo(a,t),o=ma(o),o=Jo(o,t),o=Qo(o,t),a=ec(a),o=ec(o),t.isRawShaderMaterial!==!0&&(T=`#version 300 es
|
|
3884
|
+
`,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3885
|
+
`)+`
|
|
3886
|
+
`+m,f=["#define varying in",t.glslVersion===Za?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Za?"":"#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(`
|
|
3887
|
+
`)+`
|
|
3888
|
+
`+f);const y=T+m+a,w=T+f+o,C=$o(r,r.VERTEX_SHADER,y),E=$o(r,r.FRAGMENT_SHADER,w);r.attachShader(_,C),r.attachShader(_,E),t.index0AttributeName!==void 0?r.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(_,0,"position"),r.linkProgram(_);function P(D){if(i.debug.checkShaderErrors){const B=r.getProgramInfoLog(_)||"",k=r.getShaderInfoLog(C)||"",H=r.getShaderInfoLog(E)||"",K=B.trim(),q=k.trim(),ne=H.trim();let G=!0,te=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(G=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,_,C,E);else{const se=jo(r,C,"vertex"),Se=jo(r,E,"fragment");Be("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
|
|
3889
|
+
|
|
3890
|
+
Material Name: `+D.name+`
|
|
3891
|
+
Material Type: `+D.type+`
|
|
3892
|
+
|
|
3893
|
+
Program Info Log: `+K+`
|
|
3894
|
+
`+se+`
|
|
3895
|
+
`+Se)}else K!==""?_e("WebGLProgram: Program Info Log:",K):(q===""||ne==="")&&(te=!1);te&&(D.diagnostics={runnable:G,programLog:K,vertexShader:{log:q,prefix:m},fragmentShader:{log:ne,prefix:f}})}r.deleteShader(C),r.deleteShader(E),z=new Er(r,_),b=om(r,_)}let z;this.getUniforms=function(){return z===void 0&&P(this),z};let b;this.getAttributes=function(){return b===void 0&&P(this),b};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(_,Jp)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Qp++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=C,this.fragmentShader=E,this}let vm=0;class Mm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.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}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}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 bm(e),t.set(e,n)),n}}class bm{constructor(e){this.id=vm++,this.code=e,this.usedTimes=0}}function Sm(i,e,t,n,r,s,a){const o=new xc,l=new Mm,c=new Set,h=[],u=r.logarithmicDepthBuffer,d=r.vertexTextures;let p=r.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 _(b){return c.add(b),b===0?"uv":`uv${b}`}function m(b,M,D,B,k){const H=B.fog,K=k.geometry,q=b.isMeshStandardMaterial?B.environment:null,ne=(b.isMeshStandardMaterial?t:e).get(b.envMap||q),G=ne&&ne.mapping===Ir?ne.image.height:null,te=x[b.type];b.precision!==null&&(p=r.getMaxPrecision(b.precision),p!==b.precision&&_e("WebGLProgram.getParameters:",b.precision,"not supported, using",p,"instead."));const se=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,Se=se!==void 0?se.length:0;let We=0;K.morphAttributes.position!==void 0&&(We=1),K.morphAttributes.normal!==void 0&&(We=2),K.morphAttributes.color!==void 0&&(We=3);let Ze,nt,it,X;if(te){const je=Qt[te];Ze=je.vertexShader,nt=je.fragmentShader}else Ze=b.vertexShader,nt=b.fragmentShader,l.update(b),it=l.getVertexShaderID(b),X=l.getFragmentShaderID(b);const Z=i.getRenderTarget(),de=i.state.buffers.depth.getReversed(),Le=k.isInstancedMesh===!0,ve=k.isBatchedMesh===!0,ze=!!b.map,_t=!!b.matcap,Oe=!!ne,at=!!b.aoMap,A=!!b.lightMap,Ve=!!b.bumpMap,ke=!!b.normalMap,rt=!!b.displacementMap,me=!!b.emissiveMap,ot=!!b.metalnessMap,be=!!b.roughnessMap,De=b.anisotropy>0,S=b.clearcoat>0,g=b.dispersion>0,N=b.iridescence>0,W=b.sheen>0,$=b.transmission>0,V=De&&!!b.anisotropyMap,ge=S&&!!b.clearcoatMap,oe=S&&!!b.clearcoatNormalMap,ye=S&&!!b.clearcoatRoughnessMap,xe=N&&!!b.iridescenceMap,j=N&&!!b.iridescenceThicknessMap,ee=W&&!!b.sheenColorMap,we=W&&!!b.sheenRoughnessMap,Te=!!b.specularMap,he=!!b.specularColorMap,Ce=!!b.specularIntensityMap,R=$&&!!b.transmissionMap,ce=$&&!!b.thicknessMap,ie=!!b.gradientMap,re=!!b.alphaMap,J=b.alphaTest>0,Y=!!b.alphaHash,fe=!!b.extensions;let Pe=An;b.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Pe=i.toneMapping);const st={shaderID:te,shaderType:b.type,shaderName:b.name,vertexShader:Ze,fragmentShader:nt,defines:b.defines,customVertexShaderID:it,customFragmentShaderID:X,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:p,batching:ve,batchingColor:ve&&k._colorsTexture!==null,instancing:Le,instancingColor:Le&&k.instanceColor!==null,instancingMorph:Le&&k.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:Z===null?i.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:pi,alphaToCoverage:!!b.alphaToCoverage,map:ze,matcap:_t,envMap:Oe,envMapMode:Oe&&ne.mapping,envMapCubeUVHeight:G,aoMap:at,lightMap:A,bumpMap:Ve,normalMap:ke,displacementMap:d&&rt,emissiveMap:me,normalMapObjectSpace:ke&&b.normalMapType===Rl,normalMapTangentSpace:ke&&b.normalMapType===Aa,metalnessMap:ot,roughnessMap:be,anisotropy:De,anisotropyMap:V,clearcoat:S,clearcoatMap:ge,clearcoatNormalMap:oe,clearcoatRoughnessMap:ye,dispersion:g,iridescence:N,iridescenceMap:xe,iridescenceThicknessMap:j,sheen:W,sheenColorMap:ee,sheenRoughnessMap:we,specularMap:Te,specularColorMap:he,specularIntensityMap:Ce,transmission:$,transmissionMap:R,thicknessMap:ce,gradientMap:ie,opaque:b.transparent===!1&&b.blending===li&&b.alphaToCoverage===!1,alphaMap:re,alphaTest:J,alphaHash:Y,combine:b.combine,mapUv:ze&&_(b.map.channel),aoMapUv:at&&_(b.aoMap.channel),lightMapUv:A&&_(b.lightMap.channel),bumpMapUv:Ve&&_(b.bumpMap.channel),normalMapUv:ke&&_(b.normalMap.channel),displacementMapUv:rt&&_(b.displacementMap.channel),emissiveMapUv:me&&_(b.emissiveMap.channel),metalnessMapUv:ot&&_(b.metalnessMap.channel),roughnessMapUv:be&&_(b.roughnessMap.channel),anisotropyMapUv:V&&_(b.anisotropyMap.channel),clearcoatMapUv:ge&&_(b.clearcoatMap.channel),clearcoatNormalMapUv:oe&&_(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ye&&_(b.clearcoatRoughnessMap.channel),iridescenceMapUv:xe&&_(b.iridescenceMap.channel),iridescenceThicknessMapUv:j&&_(b.iridescenceThicknessMap.channel),sheenColorMapUv:ee&&_(b.sheenColorMap.channel),sheenRoughnessMapUv:we&&_(b.sheenRoughnessMap.channel),specularMapUv:Te&&_(b.specularMap.channel),specularColorMapUv:he&&_(b.specularColorMap.channel),specularIntensityMapUv:Ce&&_(b.specularIntensityMap.channel),transmissionMapUv:R&&_(b.transmissionMap.channel),thicknessMapUv:ce&&_(b.thicknessMap.channel),alphaMapUv:re&&_(b.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(ke||De),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:k.isPoints===!0&&!!K.attributes.uv&&(ze||re),fog:!!H,useFog:b.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:b.flatShading===!0&&b.wireframe===!1,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:de,skinning:k.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:Se,morphTextureStride:We,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:b.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:Pe,decodeVideoTexture:ze&&b.map.isVideoTexture===!0&&Ye.getTransfer(b.map.colorSpace)===Qe,decodeVideoTextureEmissive:me&&b.emissiveMap.isVideoTexture===!0&&Ye.getTransfer(b.emissiveMap.colorSpace)===Qe,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===en,flipSided:b.side===Ct,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:fe&&b.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(fe&&b.extensions.multiDraw===!0||ve)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return st.vertexUv1s=c.has(1),st.vertexUv2s=c.has(2),st.vertexUv3s=c.has(3),c.clear(),st}function f(b){const M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(const D in b.defines)M.push(D),M.push(b.defines[D]);return b.isRawShaderMaterial===!1&&(T(M,b),y(M,b),M.push(i.outputColorSpace)),M.push(b.customProgramCacheKey),M.join()}function T(b,M){b.push(M.precision),b.push(M.outputColorSpace),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.mapUv),b.push(M.alphaMapUv),b.push(M.lightMapUv),b.push(M.aoMapUv),b.push(M.bumpMapUv),b.push(M.normalMapUv),b.push(M.displacementMapUv),b.push(M.emissiveMapUv),b.push(M.metalnessMapUv),b.push(M.roughnessMapUv),b.push(M.anisotropyMapUv),b.push(M.clearcoatMapUv),b.push(M.clearcoatNormalMapUv),b.push(M.clearcoatRoughnessMapUv),b.push(M.iridescenceMapUv),b.push(M.iridescenceThicknessMapUv),b.push(M.sheenColorMapUv),b.push(M.sheenRoughnessMapUv),b.push(M.specularMapUv),b.push(M.specularColorMapUv),b.push(M.specularIntensityMapUv),b.push(M.transmissionMapUv),b.push(M.thicknessMapUv),b.push(M.combine),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.numLightProbes),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function y(b,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),M.gradientMap&&o.enable(22),b.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reversedDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),b.push(o.mask)}function w(b){const M=x[b.type];let D;if(M){const B=Qt[M];D=_h.clone(B.uniforms)}else D=b.uniforms;return D}function C(b,M){let D;for(let B=0,k=h.length;B<k;B++){const H=h[B];if(H.cacheKey===M){D=H,++D.usedTimes;break}}return D===void 0&&(D=new _m(i,M,b,s),h.push(D)),D}function E(b){if(--b.usedTimes===0){const M=h.indexOf(b);h[M]=h[h.length-1],h.pop(),b.destroy()}}function P(b){l.remove(b)}function z(){l.dispose()}return{getParameters:m,getProgramCacheKey:f,getUniforms:w,acquireProgram:C,releaseProgram:E,releaseShaderCache:P,programs:h,dispose:z}}function ym(){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,l){i.get(a)[o]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function Em(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.z!==e.z?i.z-e.z:i.id-e.id}function nc(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 ic(){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,d,p,x,_,m){let f=i[e];return f===void 0?(f={id:u.id,object:u,geometry:d,material:p,groupOrder:x,renderOrder:u.renderOrder,z:_,group:m},i[e]=f):(f.id=u.id,f.object=u,f.geometry=d,f.material=p,f.groupOrder=x,f.renderOrder=u.renderOrder,f.z=_,f.group=m),e++,f}function o(u,d,p,x,_,m){const f=a(u,d,p,x,_,m);p.transmission>0?n.push(f):p.transparent===!0?r.push(f):t.push(f)}function l(u,d,p,x,_,m){const f=a(u,d,p,x,_,m);p.transmission>0?n.unshift(f):p.transparent===!0?r.unshift(f):t.unshift(f)}function c(u,d){t.length>1&&t.sort(u||Em),n.length>1&&n.sort(d||nc),r.length>1&&r.sort(d||nc)}function h(){for(let u=e,d=i.length;u<d;u++){const p=i[u];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:o,unshift:l,finish:h,sort:c}}function Tm(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new ic,i.set(n,[a])):r>=s.length?(a=new ic,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Am(){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 U,color:new Ne};break;case"SpotLight":t={position:new U,direction:new U,color:new Ne,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new Ne,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new Ne,groundColor:new Ne};break;case"RectAreaLight":t={color:new Ne,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function wm(){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 Xe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Rm=0;function Cm(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Pm(i){const e=new Am,t=wm(),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 c=0;c<9;c++)n.probe.push(new U);const r=new U,s=new He,a=new He;function o(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let p=0,x=0,_=0,m=0,f=0,T=0,y=0,w=0,C=0,E=0,P=0;c.sort(Cm);for(let b=0,M=c.length;b<M;b++){const D=c[b],B=D.color,k=D.intensity,H=D.distance,K=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)h+=B.r*k,u+=B.g*k,d+=B.b*k;else if(D.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(D.sh.coefficients[q],k);P++}else if(D.isDirectionalLight){const q=e.get(D);if(q.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const ne=D.shadow,G=t.get(D);G.shadowIntensity=ne.intensity,G.shadowBias=ne.bias,G.shadowNormalBias=ne.normalBias,G.shadowRadius=ne.radius,G.shadowMapSize=ne.mapSize,n.directionalShadow[p]=G,n.directionalShadowMap[p]=K,n.directionalShadowMatrix[p]=D.shadow.matrix,T++}n.directional[p]=q,p++}else if(D.isSpotLight){const q=e.get(D);q.position.setFromMatrixPosition(D.matrixWorld),q.color.copy(B).multiplyScalar(k),q.distance=H,q.coneCos=Math.cos(D.angle),q.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),q.decay=D.decay,n.spot[_]=q;const ne=D.shadow;if(D.map&&(n.spotLightMap[C]=D.map,C++,ne.updateMatrices(D),D.castShadow&&E++),n.spotLightMatrix[_]=ne.matrix,D.castShadow){const G=t.get(D);G.shadowIntensity=ne.intensity,G.shadowBias=ne.bias,G.shadowNormalBias=ne.normalBias,G.shadowRadius=ne.radius,G.shadowMapSize=ne.mapSize,n.spotShadow[_]=G,n.spotShadowMap[_]=K,w++}_++}else if(D.isRectAreaLight){const q=e.get(D);q.color.copy(B).multiplyScalar(k),q.halfWidth.set(D.width*.5,0,0),q.halfHeight.set(0,D.height*.5,0),n.rectArea[m]=q,m++}else if(D.isPointLight){const q=e.get(D);if(q.color.copy(D.color).multiplyScalar(D.intensity),q.distance=D.distance,q.decay=D.decay,D.castShadow){const ne=D.shadow,G=t.get(D);G.shadowIntensity=ne.intensity,G.shadowBias=ne.bias,G.shadowNormalBias=ne.normalBias,G.shadowRadius=ne.radius,G.shadowMapSize=ne.mapSize,G.shadowCameraNear=ne.camera.near,G.shadowCameraFar=ne.camera.far,n.pointShadow[x]=G,n.pointShadowMap[x]=K,n.pointShadowMatrix[x]=D.shadow.matrix,y++}n.point[x]=q,x++}else if(D.isHemisphereLight){const q=e.get(D);q.skyColor.copy(D.color).multiplyScalar(k),q.groundColor.copy(D.groundColor).multiplyScalar(k),n.hemi[f]=q,f++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ae.LTC_FLOAT_1,n.rectAreaLTC2=ae.LTC_FLOAT_2):(n.rectAreaLTC1=ae.LTC_HALF_1,n.rectAreaLTC2=ae.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const z=n.hash;(z.directionalLength!==p||z.pointLength!==x||z.spotLength!==_||z.rectAreaLength!==m||z.hemiLength!==f||z.numDirectionalShadows!==T||z.numPointShadows!==y||z.numSpotShadows!==w||z.numSpotMaps!==C||z.numLightProbes!==P)&&(n.directional.length=p,n.spot.length=_,n.rectArea.length=m,n.point.length=x,n.hemi.length=f,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.pointShadow.length=y,n.pointShadowMap.length=y,n.spotShadow.length=w,n.spotShadowMap.length=w,n.directionalShadowMatrix.length=T,n.pointShadowMatrix.length=y,n.spotLightMatrix.length=w+C-E,n.spotLightMap.length=C,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=P,z.directionalLength=p,z.pointLength=x,z.spotLength=_,z.rectAreaLength=m,z.hemiLength=f,z.numDirectionalShadows=T,z.numPointShadows=y,z.numSpotShadows=w,z.numSpotMaps=C,z.numLightProbes=P,n.version=Rm++)}function l(c,h){let u=0,d=0,p=0,x=0,_=0;const m=h.matrixWorldInverse;for(let f=0,T=c.length;f<T;f++){const y=c[f];if(y.isDirectionalLight){const w=n.directional[u];w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(m),u++}else if(y.isSpotLight){const w=n.spot[p];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(m),w.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(m),p++}else if(y.isRectAreaLight){const w=n.rectArea[x];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(m),a.identity(),s.copy(y.matrixWorld),s.premultiply(m),a.extractRotation(s),w.halfWidth.set(y.width*.5,0,0),w.halfHeight.set(0,y.height*.5,0),w.halfWidth.applyMatrix4(a),w.halfHeight.applyMatrix4(a),x++}else if(y.isPointLight){const w=n.point[d];w.position.setFromMatrixPosition(y.matrixWorld),w.position.applyMatrix4(m),d++}else if(y.isHemisphereLight){const w=n.hemi[_];w.direction.setFromMatrixPosition(y.matrixWorld),w.direction.transformDirection(m),_++}}}return{setup:o,setupView:l,state:n}}function rc(i){const e=new Pm(i),t=[],n=[];function r(h){c.camera=h,t.length=0,n.length=0}function s(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function Dm(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new rc(i),e.set(r,[o])):s>=a.length?(o=new rc(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Lm=`void main() {
|
|
3896
|
+
gl_Position = vec4( position, 1.0 );
|
|
3897
|
+
}`,Im=`uniform sampler2D shadow_pass;
|
|
3898
|
+
uniform vec2 resolution;
|
|
3899
|
+
uniform float radius;
|
|
3900
|
+
#include <packing>
|
|
3901
|
+
void main() {
|
|
3902
|
+
const float samples = float( VSM_SAMPLES );
|
|
3903
|
+
float mean = 0.0;
|
|
3904
|
+
float squared_mean = 0.0;
|
|
3905
|
+
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|
3906
|
+
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|
3907
|
+
for ( float i = 0.0; i < samples; i ++ ) {
|
|
3908
|
+
float uvOffset = uvStart + i * uvStride;
|
|
3909
|
+
#ifdef HORIZONTAL_PASS
|
|
3910
|
+
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|
3911
|
+
mean += distribution.x;
|
|
3912
|
+
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
3913
|
+
#else
|
|
3914
|
+
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|
3915
|
+
mean += depth;
|
|
3916
|
+
squared_mean += depth * depth;
|
|
3917
|
+
#endif
|
|
3918
|
+
}
|
|
3919
|
+
mean = mean / samples;
|
|
3920
|
+
squared_mean = squared_mean / samples;
|
|
3921
|
+
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3922
|
+
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3923
|
+
}`;function Um(i,e,t){let n=new Ca;const r=new Xe,s=new Xe,a=new Ke,o=new Uh({depthPacking:wl}),l=new Nh,c={},h=t.maxTextureSize,u={[wn]:Ct,[Ct]:wn,[en]:en},d=new xn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Xe},radius:{value:4}},vertexShader:Lm,fragmentShader:Im}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const x=new Vt;x.setAttribute("position",new bt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new St(x,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=sc;let f=this.type;this.render=function(E,P,z){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||E.length===0)return;const b=i.getRenderTarget(),M=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),B=i.state;B.setBlending(pn),B.buffers.depth.getReversed()===!0?B.buffers.color.setClear(0,0,0,0):B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);const k=f!==un&&this.type===un,H=f===un&&this.type!==un;for(let K=0,q=E.length;K<q;K++){const ne=E[K],G=ne.shadow;if(G===void 0){_e("WebGLShadowMap:",ne,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;r.copy(G.mapSize);const te=G.getFrameExtents();if(r.multiply(te),s.copy(G.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/te.x),r.x=s.x*te.x,G.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/te.y),r.y=s.y*te.y,G.mapSize.y=s.y)),G.map===null||k===!0||H===!0){const Se=this.type!==un?{minFilter:Pt,magFilter:Pt}:{};G.map!==null&&G.map.dispose(),G.map=new Hn(r.x,r.y,Se),G.map.texture.name=ne.name+".shadowMap",G.camera.updateProjectionMatrix()}i.setRenderTarget(G.map),i.clear();const se=G.getViewportCount();for(let Se=0;Se<se;Se++){const We=G.getViewport(Se);a.set(s.x*We.x,s.y*We.y,s.x*We.z,s.y*We.w),B.viewport(a),G.updateMatrices(ne,Se),n=G.getFrustum(),w(P,z,G.camera,ne,this.type)}G.isPointLightShadow!==!0&&this.type===un&&T(G,z),G.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(b,M,D)};function T(E,P){const z=e.update(_);d.defines.VSM_SAMPLES!==E.blurSamples&&(d.defines.VSM_SAMPLES=E.blurSamples,p.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Hn(r.x,r.y)),d.uniforms.shadow_pass.value=E.map.texture,d.uniforms.resolution.value=E.mapSize,d.uniforms.radius.value=E.radius,i.setRenderTarget(E.mapPass),i.clear(),i.renderBufferDirect(P,null,z,d,_,null),p.uniforms.shadow_pass.value=E.mapPass.texture,p.uniforms.resolution.value=E.mapSize,p.uniforms.radius.value=E.radius,i.setRenderTarget(E.map),i.clear(),i.renderBufferDirect(P,null,z,p,_,null)}function y(E,P,z,b){let M=null;const D=z.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(D!==void 0)M=D;else if(M=z.isPointLight===!0?l:o,i.localClippingEnabled&&P.clipShadows===!0&&Array.isArray(P.clippingPlanes)&&P.clippingPlanes.length!==0||P.displacementMap&&P.displacementScale!==0||P.alphaMap&&P.alphaTest>0||P.map&&P.alphaTest>0||P.alphaToCoverage===!0){const B=M.uuid,k=P.uuid;let H=c[B];H===void 0&&(H={},c[B]=H);let K=H[k];K===void 0&&(K=M.clone(),H[k]=K,P.addEventListener("dispose",C)),M=K}if(M.visible=P.visible,M.wireframe=P.wireframe,b===un?M.side=P.shadowSide!==null?P.shadowSide:P.side:M.side=P.shadowSide!==null?P.shadowSide:u[P.side],M.alphaMap=P.alphaMap,M.alphaTest=P.alphaToCoverage===!0?.5:P.alphaTest,M.map=P.map,M.clipShadows=P.clipShadows,M.clippingPlanes=P.clippingPlanes,M.clipIntersection=P.clipIntersection,M.displacementMap=P.displacementMap,M.displacementScale=P.displacementScale,M.displacementBias=P.displacementBias,M.wireframeLinewidth=P.wireframeLinewidth,M.linewidth=P.linewidth,z.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const B=i.properties.get(M);B.light=z}return M}function w(E,P,z,b,M){if(E.visible===!1)return;if(E.layers.test(P.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&M===un)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse,E.matrixWorld);const k=e.update(E),H=E.material;if(Array.isArray(H)){const K=k.groups;for(let q=0,ne=K.length;q<ne;q++){const G=K[q],te=H[G.materialIndex];if(te&&te.visible){const se=y(E,te,b,M);E.onBeforeShadow(i,E,P,z,k,se,G),i.renderBufferDirect(z,null,k,se,E,G),E.onAfterShadow(i,E,P,z,k,se,G)}}}else if(H.visible){const K=y(E,H,b,M);E.onBeforeShadow(i,E,P,z,k,K,null),i.renderBufferDirect(z,null,k,K,E,null),E.onAfterShadow(i,E,P,z,k,K,null)}}const B=E.children;for(let k=0,H=B.length;k<H;k++)w(B[k],P,z,b,M)}function C(E){E.target.removeEventListener("dispose",C);for(const z in c){const b=c[z],M=E.target.uuid;M in b&&(b[M].dispose(),delete b[M])}}}const Nm={[As]:ws,[Rs]:Ds,[Cs]:Ls,[ui]:Ps,[ws]:As,[Ds]:Rs,[Ls]:Cs,[Ps]:ui};function Fm(i,e){function t(){let R=!1;const ce=new Ke;let ie=null;const re=new Ke(0,0,0,0);return{setMask:function(J){ie!==J&&!R&&(i.colorMask(J,J,J,J),ie=J)},setLocked:function(J){R=J},setClear:function(J,Y,fe,Pe,st){st===!0&&(J*=Pe,Y*=Pe,fe*=Pe),ce.set(J,Y,fe,Pe),re.equals(ce)===!1&&(i.clearColor(J,Y,fe,Pe),re.copy(ce))},reset:function(){R=!1,ie=null,re.set(-1,0,0,0)}}}function n(){let R=!1,ce=!1,ie=null,re=null,J=null;return{setReversed:function(Y){if(ce!==Y){const fe=e.get("EXT_clip_control");Y?fe.clipControlEXT(fe.LOWER_LEFT_EXT,fe.ZERO_TO_ONE_EXT):fe.clipControlEXT(fe.LOWER_LEFT_EXT,fe.NEGATIVE_ONE_TO_ONE_EXT),ce=Y;const Pe=J;J=null,this.setClear(Pe)}},getReversed:function(){return ce},setTest:function(Y){Y?Z(i.DEPTH_TEST):de(i.DEPTH_TEST)},setMask:function(Y){ie!==Y&&!R&&(i.depthMask(Y),ie=Y)},setFunc:function(Y){if(ce&&(Y=Nm[Y]),re!==Y){switch(Y){case As:i.depthFunc(i.NEVER);break;case ws:i.depthFunc(i.ALWAYS);break;case Rs:i.depthFunc(i.LESS);break;case ui:i.depthFunc(i.LEQUAL);break;case Cs:i.depthFunc(i.EQUAL);break;case Ps:i.depthFunc(i.GEQUAL);break;case Ds:i.depthFunc(i.GREATER);break;case Ls:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}re=Y}},setLocked:function(Y){R=Y},setClear:function(Y){J!==Y&&(ce&&(Y=1-Y),i.clearDepth(Y),J=Y)},reset:function(){R=!1,ie=null,re=null,J=null,ce=!1}}}function r(){let R=!1,ce=null,ie=null,re=null,J=null,Y=null,fe=null,Pe=null,st=null;return{setTest:function(je){R||(je?Z(i.STENCIL_TEST):de(i.STENCIL_TEST))},setMask:function(je){ce!==je&&!R&&(i.stencilMask(je),ce=je)},setFunc:function(je,Jt,kt){(ie!==je||re!==Jt||J!==kt)&&(i.stencilFunc(je,Jt,kt),ie=je,re=Jt,J=kt)},setOp:function(je,Jt,kt){(Y!==je||fe!==Jt||Pe!==kt)&&(i.stencilOp(je,Jt,kt),Y=je,fe=Jt,Pe=kt)},setLocked:function(je){R=je},setClear:function(je){st!==je&&(i.clearStencil(je),st=je)},reset:function(){R=!1,ce=null,ie=null,re=null,J=null,Y=null,fe=null,Pe=null,st=null}}}const s=new t,a=new n,o=new r,l=new WeakMap,c=new WeakMap;let h={},u={},d=new WeakMap,p=[],x=null,_=!1,m=null,f=null,T=null,y=null,w=null,C=null,E=null,P=new Ne(0,0,0),z=0,b=!1,M=null,D=null,B=null,k=null,H=null;const K=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,ne=0;const G=i.getParameter(i.VERSION);G.indexOf("WebGL")!==-1?(ne=parseFloat(/^WebGL (\d)/.exec(G)[1]),q=ne>=1):G.indexOf("OpenGL ES")!==-1&&(ne=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),q=ne>=2);let te=null,se={};const Se=i.getParameter(i.SCISSOR_BOX),We=i.getParameter(i.VIEWPORT),Ze=new Ke().fromArray(Se),nt=new Ke().fromArray(We);function it(R,ce,ie,re){const J=new Uint8Array(4),Y=i.createTexture();i.bindTexture(R,Y),i.texParameteri(R,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(R,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let fe=0;fe<ie;fe++)R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY?i.texImage3D(ce,0,i.RGBA,1,1,re,0,i.RGBA,i.UNSIGNED_BYTE,J):i.texImage2D(ce+fe,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,J);return Y}const X={};X[i.TEXTURE_2D]=it(i.TEXTURE_2D,i.TEXTURE_2D,1),X[i.TEXTURE_CUBE_MAP]=it(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),X[i.TEXTURE_2D_ARRAY]=it(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),X[i.TEXTURE_3D]=it(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Z(i.DEPTH_TEST),a.setFunc(ui),Ve(!1),ke(ka),Z(i.CULL_FACE),at(pn);function Z(R){h[R]!==!0&&(i.enable(R),h[R]=!0)}function de(R){h[R]!==!1&&(i.disable(R),h[R]=!1)}function Le(R,ce){return u[R]!==ce?(i.bindFramebuffer(R,ce),u[R]=ce,R===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ce),R===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ce),!0):!1}function ve(R,ce){let ie=p,re=!1;if(R){ie=d.get(ce),ie===void 0&&(ie=[],d.set(ce,ie));const J=R.textures;if(ie.length!==J.length||ie[0]!==i.COLOR_ATTACHMENT0){for(let Y=0,fe=J.length;Y<fe;Y++)ie[Y]=i.COLOR_ATTACHMENT0+Y;ie.length=J.length,re=!0}}else ie[0]!==i.BACK&&(ie[0]=i.BACK,re=!0);re&&i.drawBuffers(ie)}function ze(R){return x!==R?(i.useProgram(R),x=R,!0):!1}const _t={[zn]:i.FUNC_ADD,[jc]:i.FUNC_SUBTRACT,[Jc]:i.FUNC_REVERSE_SUBTRACT};_t[Qc]=i.MIN,_t[el]=i.MAX;const Oe={[tl]:i.ZERO,[nl]:i.ONE,[il]:i.SRC_COLOR,[Es]:i.SRC_ALPHA,[ll]:i.SRC_ALPHA_SATURATE,[ol]:i.DST_COLOR,[sl]:i.DST_ALPHA,[rl]:i.ONE_MINUS_SRC_COLOR,[Ts]:i.ONE_MINUS_SRC_ALPHA,[cl]:i.ONE_MINUS_DST_COLOR,[al]:i.ONE_MINUS_DST_ALPHA,[hl]:i.CONSTANT_COLOR,[ul]:i.ONE_MINUS_CONSTANT_COLOR,[dl]:i.CONSTANT_ALPHA,[fl]:i.ONE_MINUS_CONSTANT_ALPHA};function at(R,ce,ie,re,J,Y,fe,Pe,st,je){if(R===pn){_===!0&&(de(i.BLEND),_=!1);return}if(_===!1&&(Z(i.BLEND),_=!0),R!==Zc){if(R!==m||je!==b){if((f!==zn||w!==zn)&&(i.blendEquation(i.FUNC_ADD),f=zn,w=zn),je)switch(R){case li:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ga:i.blendFunc(i.ONE,i.ONE);break;case Ha:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Wa:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Be("WebGLState: Invalid blending: ",R);break}else switch(R){case li:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ga:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Ha:Be("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Wa:Be("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Be("WebGLState: Invalid blending: ",R);break}T=null,y=null,C=null,E=null,P.set(0,0,0),z=0,m=R,b=je}return}J=J||ce,Y=Y||ie,fe=fe||re,(ce!==f||J!==w)&&(i.blendEquationSeparate(_t[ce],_t[J]),f=ce,w=J),(ie!==T||re!==y||Y!==C||fe!==E)&&(i.blendFuncSeparate(Oe[ie],Oe[re],Oe[Y],Oe[fe]),T=ie,y=re,C=Y,E=fe),(Pe.equals(P)===!1||st!==z)&&(i.blendColor(Pe.r,Pe.g,Pe.b,st),P.copy(Pe),z=st),m=R,b=!1}function A(R,ce){R.side===en?de(i.CULL_FACE):Z(i.CULL_FACE);let ie=R.side===Ct;ce&&(ie=!ie),Ve(ie),R.blending===li&&R.transparent===!1?at(pn):at(R.blending,R.blendEquation,R.blendSrc,R.blendDst,R.blendEquationAlpha,R.blendSrcAlpha,R.blendDstAlpha,R.blendColor,R.blendAlpha,R.premultipliedAlpha),a.setFunc(R.depthFunc),a.setTest(R.depthTest),a.setMask(R.depthWrite),s.setMask(R.colorWrite);const re=R.stencilWrite;o.setTest(re),re&&(o.setMask(R.stencilWriteMask),o.setFunc(R.stencilFunc,R.stencilRef,R.stencilFuncMask),o.setOp(R.stencilFail,R.stencilZFail,R.stencilZPass)),me(R.polygonOffset,R.polygonOffsetFactor,R.polygonOffsetUnits),R.alphaToCoverage===!0?Z(i.SAMPLE_ALPHA_TO_COVERAGE):de(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ve(R){M!==R&&(R?i.frontFace(i.CW):i.frontFace(i.CCW),M=R)}function ke(R){R!==Yc?(Z(i.CULL_FACE),R!==D&&(R===ka?i.cullFace(i.BACK):R===Kc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):de(i.CULL_FACE),D=R}function rt(R){R!==B&&(q&&i.lineWidth(R),B=R)}function me(R,ce,ie){R?(Z(i.POLYGON_OFFSET_FILL),(k!==ce||H!==ie)&&(i.polygonOffset(ce,ie),k=ce,H=ie)):de(i.POLYGON_OFFSET_FILL)}function ot(R){R?Z(i.SCISSOR_TEST):de(i.SCISSOR_TEST)}function be(R){R===void 0&&(R=i.TEXTURE0+K-1),te!==R&&(i.activeTexture(R),te=R)}function De(R,ce,ie){ie===void 0&&(te===null?ie=i.TEXTURE0+K-1:ie=te);let re=se[ie];re===void 0&&(re={type:void 0,texture:void 0},se[ie]=re),(re.type!==R||re.texture!==ce)&&(te!==ie&&(i.activeTexture(ie),te=ie),i.bindTexture(R,ce||X[R]),re.type=R,re.texture=ce)}function S(){const R=se[te];R!==void 0&&R.type!==void 0&&(i.bindTexture(R.type,null),R.type=void 0,R.texture=void 0)}function g(){try{i.compressedTexImage2D(...arguments)}catch(R){R("WebGLState:",R)}}function N(){try{i.compressedTexImage3D(...arguments)}catch(R){R("WebGLState:",R)}}function W(){try{i.texSubImage2D(...arguments)}catch(R){R("WebGLState:",R)}}function $(){try{i.texSubImage3D(...arguments)}catch(R){R("WebGLState:",R)}}function V(){try{i.compressedTexSubImage2D(...arguments)}catch(R){R("WebGLState:",R)}}function ge(){try{i.compressedTexSubImage3D(...arguments)}catch(R){R("WebGLState:",R)}}function oe(){try{i.texStorage2D(...arguments)}catch(R){R("WebGLState:",R)}}function ye(){try{i.texStorage3D(...arguments)}catch(R){R("WebGLState:",R)}}function xe(){try{i.texImage2D(...arguments)}catch(R){R("WebGLState:",R)}}function j(){try{i.texImage3D(...arguments)}catch(R){R("WebGLState:",R)}}function ee(R){Ze.equals(R)===!1&&(i.scissor(R.x,R.y,R.z,R.w),Ze.copy(R))}function we(R){nt.equals(R)===!1&&(i.viewport(R.x,R.y,R.z,R.w),nt.copy(R))}function Te(R,ce){let ie=c.get(ce);ie===void 0&&(ie=new WeakMap,c.set(ce,ie));let re=ie.get(R);re===void 0&&(re=i.getUniformBlockIndex(ce,R.name),ie.set(R,re))}function he(R,ce){const re=c.get(ce).get(R);l.get(ce)!==re&&(i.uniformBlockBinding(ce,re,R.__bindingPointIndex),l.set(ce,re))}function Ce(){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),h={},te=null,se={},u={},d=new WeakMap,p=[],x=null,_=!1,m=null,f=null,T=null,y=null,w=null,C=null,E=null,P=new Ne(0,0,0),z=0,b=!1,M=null,D=null,B=null,k=null,H=null,Ze.set(0,0,i.canvas.width,i.canvas.height),nt.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:Z,disable:de,bindFramebuffer:Le,drawBuffers:ve,useProgram:ze,setBlending:at,setMaterial:A,setFlipSided:Ve,setCullFace:ke,setLineWidth:rt,setPolygonOffset:me,setScissorTest:ot,activeTexture:be,bindTexture:De,unbindTexture:S,compressedTexImage2D:g,compressedTexImage3D:N,texImage2D:xe,texImage3D:j,updateUBOMapping:Te,uniformBlockBinding:he,texStorage2D:oe,texStorage3D:ye,texSubImage2D:W,texSubImage3D:$,compressedTexSubImage2D:V,compressedTexSubImage3D:ge,scissor:ee,viewport:we,reset:Ce}}function Om(i,e,t,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Xe,h=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(S,g){return p?new OffscreenCanvas(S,g):Vi("canvas")}function _(S,g,N){let W=1;const $=De(S);if(($.width>N||$.height>N)&&(W=N/Math.max($.width,$.height)),W<1)if(typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&S instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&S instanceof ImageBitmap||typeof VideoFrame<"u"&&S instanceof VideoFrame){const V=Math.floor(W*$.width),ge=Math.floor(W*$.height);u===void 0&&(u=x(V,ge));const oe=g?x(V,ge):u;return oe.width=V,oe.height=ge,oe.getContext("2d").drawImage(S,0,0,V,ge),_e("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+V+"x"+ge+")."),oe}else return"data"in S&&_e("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),S;return S}function m(S){return S.generateMipmaps}function f(S){i.generateMipmap(S)}function T(S){return S.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:S.isWebGL3DRenderTarget?i.TEXTURE_3D:S.isWebGLArrayRenderTarget||S.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function y(S,g,N,W,$=!1){if(S!==null){if(i[S]!==void 0)return i[S];_e("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let V=g;if(g===i.RED&&(N===i.FLOAT&&(V=i.R32F),N===i.HALF_FLOAT&&(V=i.R16F),N===i.UNSIGNED_BYTE&&(V=i.R8)),g===i.RED_INTEGER&&(N===i.UNSIGNED_BYTE&&(V=i.R8UI),N===i.UNSIGNED_SHORT&&(V=i.R16UI),N===i.UNSIGNED_INT&&(V=i.R32UI),N===i.BYTE&&(V=i.R8I),N===i.SHORT&&(V=i.R16I),N===i.INT&&(V=i.R32I)),g===i.RG&&(N===i.FLOAT&&(V=i.RG32F),N===i.HALF_FLOAT&&(V=i.RG16F),N===i.UNSIGNED_BYTE&&(V=i.RG8)),g===i.RG_INTEGER&&(N===i.UNSIGNED_BYTE&&(V=i.RG8UI),N===i.UNSIGNED_SHORT&&(V=i.RG16UI),N===i.UNSIGNED_INT&&(V=i.RG32UI),N===i.BYTE&&(V=i.RG8I),N===i.SHORT&&(V=i.RG16I),N===i.INT&&(V=i.RG32I)),g===i.RGB_INTEGER&&(N===i.UNSIGNED_BYTE&&(V=i.RGB8UI),N===i.UNSIGNED_SHORT&&(V=i.RGB16UI),N===i.UNSIGNED_INT&&(V=i.RGB32UI),N===i.BYTE&&(V=i.RGB8I),N===i.SHORT&&(V=i.RGB16I),N===i.INT&&(V=i.RGB32I)),g===i.RGBA_INTEGER&&(N===i.UNSIGNED_BYTE&&(V=i.RGBA8UI),N===i.UNSIGNED_SHORT&&(V=i.RGBA16UI),N===i.UNSIGNED_INT&&(V=i.RGBA32UI),N===i.BYTE&&(V=i.RGBA8I),N===i.SHORT&&(V=i.RGBA16I),N===i.INT&&(V=i.RGBA32I)),g===i.RGB&&(N===i.UNSIGNED_INT_5_9_9_9_REV&&(V=i.RGB9_E5),N===i.UNSIGNED_INT_10F_11F_11F_REV&&(V=i.R11F_G11F_B10F)),g===i.RGBA){const ge=$?Ar:Ye.getTransfer(W);N===i.FLOAT&&(V=i.RGBA32F),N===i.HALF_FLOAT&&(V=i.RGBA16F),N===i.UNSIGNED_BYTE&&(V=ge===Qe?i.SRGB8_ALPHA8:i.RGBA8),N===i.UNSIGNED_SHORT_4_4_4_4&&(V=i.RGBA4),N===i.UNSIGNED_SHORT_5_5_5_1&&(V=i.RGB5_A1)}return(V===i.R16F||V===i.R32F||V===i.RG16F||V===i.RG32F||V===i.RGBA16F||V===i.RGBA32F)&&e.get("EXT_color_buffer_float"),V}function w(S,g){let N;return S?g===null||g===Gn||g===Oi?N=i.DEPTH24_STENCIL8:g===Yt?N=i.DEPTH32F_STENCIL8:g===Fi&&(N=i.DEPTH24_STENCIL8,_e("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===Gn||g===Oi?N=i.DEPTH_COMPONENT24:g===Yt?N=i.DEPTH_COMPONENT32F:g===Fi&&(N=i.DEPTH_COMPONENT16),N}function C(S,g){return m(S)===!0||S.isFramebufferTexture&&S.minFilter!==Pt&&S.minFilter!==At?Math.log2(Math.max(g.width,g.height))+1:S.mipmaps!==void 0&&S.mipmaps.length>0?S.mipmaps.length:S.isCompressedTexture&&Array.isArray(S.image)?g.mipmaps.length:1}function E(S){const g=S.target;g.removeEventListener("dispose",E),z(g),g.isVideoTexture&&h.delete(g)}function P(S){const g=S.target;g.removeEventListener("dispose",P),M(g)}function z(S){const g=n.get(S);if(g.__webglInit===void 0)return;const N=S.source,W=d.get(N);if(W){const $=W[g.__cacheKey];$.usedTimes--,$.usedTimes===0&&b(S),Object.keys(W).length===0&&d.delete(N)}n.remove(S)}function b(S){const g=n.get(S);i.deleteTexture(g.__webglTexture);const N=S.source,W=d.get(N);delete W[g.__cacheKey],a.memory.textures--}function M(S){const g=n.get(S);if(S.depthTexture&&(S.depthTexture.dispose(),n.remove(S.depthTexture)),S.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(g.__webglFramebuffer[W]))for(let $=0;$<g.__webglFramebuffer[W].length;$++)i.deleteFramebuffer(g.__webglFramebuffer[W][$]);else i.deleteFramebuffer(g.__webglFramebuffer[W]);g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer[W])}else{if(Array.isArray(g.__webglFramebuffer))for(let W=0;W<g.__webglFramebuffer.length;W++)i.deleteFramebuffer(g.__webglFramebuffer[W]);else i.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer),g.__webglMultisampledFramebuffer&&i.deleteFramebuffer(g.__webglMultisampledFramebuffer),g.__webglColorRenderbuffer)for(let W=0;W<g.__webglColorRenderbuffer.length;W++)g.__webglColorRenderbuffer[W]&&i.deleteRenderbuffer(g.__webglColorRenderbuffer[W]);g.__webglDepthRenderbuffer&&i.deleteRenderbuffer(g.__webglDepthRenderbuffer)}const N=S.textures;for(let W=0,$=N.length;W<$;W++){const V=n.get(N[W]);V.__webglTexture&&(i.deleteTexture(V.__webglTexture),a.memory.textures--),n.remove(N[W])}n.remove(S)}let D=0;function B(){D=0}function k(){const S=D;return S>=r.maxTextures&&_e("WebGLTextures: Trying to use "+S+" texture units while this GPU supports only "+r.maxTextures),D+=1,S}function H(S){const g=[];return g.push(S.wrapS),g.push(S.wrapT),g.push(S.wrapR||0),g.push(S.magFilter),g.push(S.minFilter),g.push(S.anisotropy),g.push(S.internalFormat),g.push(S.format),g.push(S.type),g.push(S.generateMipmaps),g.push(S.premultiplyAlpha),g.push(S.flipY),g.push(S.unpackAlignment),g.push(S.colorSpace),g.join()}function K(S,g){const N=n.get(S);if(S.isVideoTexture&&ot(S),S.isRenderTargetTexture===!1&&S.isExternalTexture!==!0&&S.version>0&&N.__version!==S.version){const W=S.image;if(W===null)_e("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)_e("WebGLRenderer: Texture marked for update but image is incomplete");else{X(N,S,g);return}}else S.isExternalTexture&&(N.__webglTexture=S.sourceTexture?S.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,N.__webglTexture,i.TEXTURE0+g)}function q(S,g){const N=n.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&N.__version!==S.version){X(N,S,g);return}else S.isExternalTexture&&(N.__webglTexture=S.sourceTexture?S.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,N.__webglTexture,i.TEXTURE0+g)}function ne(S,g){const N=n.get(S);if(S.isRenderTargetTexture===!1&&S.version>0&&N.__version!==S.version){X(N,S,g);return}t.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+g)}function G(S,g){const N=n.get(S);if(S.version>0&&N.__version!==S.version){Z(N,S,g);return}t.bindTexture(i.TEXTURE_CUBE_MAP,N.__webglTexture,i.TEXTURE0+g)}const te={[Ns]:i.REPEAT,[dn]:i.CLAMP_TO_EDGE,[Fs]:i.MIRRORED_REPEAT},se={[Pt]:i.NEAREST,[El]:i.NEAREST_MIPMAP_NEAREST,[Yi]:i.NEAREST_MIPMAP_LINEAR,[At]:i.LINEAR,[Hr]:i.LINEAR_MIPMAP_NEAREST,[kn]:i.LINEAR_MIPMAP_LINEAR},Se={[Cl]:i.NEVER,[Nl]:i.ALWAYS,[Pl]:i.LESS,[fc]:i.LEQUAL,[Dl]:i.EQUAL,[Ul]:i.GEQUAL,[Ll]:i.GREATER,[Il]:i.NOTEQUAL};function We(S,g){if(g.type===Yt&&e.has("OES_texture_float_linear")===!1&&(g.magFilter===At||g.magFilter===Hr||g.magFilter===Yi||g.magFilter===kn||g.minFilter===At||g.minFilter===Hr||g.minFilter===Yi||g.minFilter===kn)&&_e("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(S,i.TEXTURE_WRAP_S,te[g.wrapS]),i.texParameteri(S,i.TEXTURE_WRAP_T,te[g.wrapT]),(S===i.TEXTURE_3D||S===i.TEXTURE_2D_ARRAY)&&i.texParameteri(S,i.TEXTURE_WRAP_R,te[g.wrapR]),i.texParameteri(S,i.TEXTURE_MAG_FILTER,se[g.magFilter]),i.texParameteri(S,i.TEXTURE_MIN_FILTER,se[g.minFilter]),g.compareFunction&&(i.texParameteri(S,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(S,i.TEXTURE_COMPARE_FUNC,Se[g.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===Pt||g.minFilter!==Yi&&g.minFilter!==kn||g.type===Yt&&e.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||n.get(g).__currentAnisotropy){const N=e.get("EXT_texture_filter_anisotropic");i.texParameterf(S,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,r.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function Ze(S,g){let N=!1;S.__webglInit===void 0&&(S.__webglInit=!0,g.addEventListener("dispose",E));const W=g.source;let $=d.get(W);$===void 0&&($={},d.set(W,$));const V=H(g);if(V!==S.__cacheKey){$[V]===void 0&&($[V]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,N=!0),$[V].usedTimes++;const ge=$[S.__cacheKey];ge!==void 0&&($[S.__cacheKey].usedTimes--,ge.usedTimes===0&&b(g)),S.__cacheKey=V,S.__webglTexture=$[V].texture}return N}function nt(S,g,N){return Math.floor(Math.floor(S/N)/g)}function it(S,g,N,W){const V=S.updateRanges;if(V.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,g.width,g.height,N,W,g.data);else{V.sort((j,ee)=>j.start-ee.start);let ge=0;for(let j=1;j<V.length;j++){const ee=V[ge],we=V[j],Te=ee.start+ee.count,he=nt(we.start,g.width,4),Ce=nt(ee.start,g.width,4);we.start<=Te+1&&he===Ce&&nt(we.start+we.count-1,g.width,4)===he?ee.count=Math.max(ee.count,we.start+we.count-ee.start):(++ge,V[ge]=we)}V.length=ge+1;const oe=i.getParameter(i.UNPACK_ROW_LENGTH),ye=i.getParameter(i.UNPACK_SKIP_PIXELS),xe=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,g.width);for(let j=0,ee=V.length;j<ee;j++){const we=V[j],Te=Math.floor(we.start/4),he=Math.ceil(we.count/4),Ce=Te%g.width,R=Math.floor(Te/g.width),ce=he,ie=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Ce),i.pixelStorei(i.UNPACK_SKIP_ROWS,R),t.texSubImage2D(i.TEXTURE_2D,0,Ce,R,ce,ie,N,W,g.data)}S.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,oe),i.pixelStorei(i.UNPACK_SKIP_PIXELS,ye),i.pixelStorei(i.UNPACK_SKIP_ROWS,xe)}}function X(S,g,N){let W=i.TEXTURE_2D;(g.isDataArrayTexture||g.isCompressedArrayTexture)&&(W=i.TEXTURE_2D_ARRAY),g.isData3DTexture&&(W=i.TEXTURE_3D);const $=Ze(S,g),V=g.source;t.bindTexture(W,S.__webglTexture,i.TEXTURE0+N);const ge=n.get(V);if(V.version!==ge.__version||$===!0){t.activeTexture(i.TEXTURE0+N);const oe=Ye.getPrimaries(Ye.workingColorSpace),ye=g.colorSpace===En?null:Ye.getPrimaries(g.colorSpace),xe=g.colorSpace===En||oe===ye?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,xe);let j=_(g.image,!1,r.maxTextureSize);j=be(g,j);const ee=s.convert(g.format,g.colorSpace),we=s.convert(g.type);let Te=y(g.internalFormat,ee,we,g.colorSpace,g.isVideoTexture);We(W,g);let he;const Ce=g.mipmaps,R=g.isVideoTexture!==!0,ce=ge.__version===void 0||$===!0,ie=V.dataReady,re=C(g,j);if(g.isDepthTexture)Te=w(g.format===zi,g.type),ce&&(R?t.texStorage2D(i.TEXTURE_2D,1,Te,j.width,j.height):t.texImage2D(i.TEXTURE_2D,0,Te,j.width,j.height,0,ee,we,null));else if(g.isDataTexture)if(Ce.length>0){R&&ce&&t.texStorage2D(i.TEXTURE_2D,re,Te,Ce[0].width,Ce[0].height);for(let J=0,Y=Ce.length;J<Y;J++)he=Ce[J],R?ie&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,he.width,he.height,ee,we,he.data):t.texImage2D(i.TEXTURE_2D,J,Te,he.width,he.height,0,ee,we,he.data);g.generateMipmaps=!1}else R?(ce&&t.texStorage2D(i.TEXTURE_2D,re,Te,j.width,j.height),ie&&it(g,j,ee,we)):t.texImage2D(i.TEXTURE_2D,0,Te,j.width,j.height,0,ee,we,j.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){R&&ce&&t.texStorage3D(i.TEXTURE_2D_ARRAY,re,Te,Ce[0].width,Ce[0].height,j.depth);for(let J=0,Y=Ce.length;J<Y;J++)if(he=Ce[J],g.format!==zt)if(ee!==null)if(R){if(ie)if(g.layerUpdates.size>0){const fe=No(he.width,he.height,g.format,g.type);for(const Pe of g.layerUpdates){const st=he.data.subarray(Pe*fe/he.data.BYTES_PER_ELEMENT,(Pe+1)*fe/he.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,Pe,he.width,he.height,1,ee,st)}g.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,he.width,he.height,j.depth,ee,he.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,Te,he.width,he.height,j.depth,0,he.data,0,0);else _e("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else R?ie&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,he.width,he.height,j.depth,ee,we,he.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,Te,he.width,he.height,j.depth,0,ee,we,he.data)}else{R&&ce&&t.texStorage2D(i.TEXTURE_2D,re,Te,Ce[0].width,Ce[0].height);for(let J=0,Y=Ce.length;J<Y;J++)he=Ce[J],g.format!==zt?ee!==null?R?ie&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,he.width,he.height,ee,he.data):t.compressedTexImage2D(i.TEXTURE_2D,J,Te,he.width,he.height,0,he.data):_e("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):R?ie&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,he.width,he.height,ee,we,he.data):t.texImage2D(i.TEXTURE_2D,J,Te,he.width,he.height,0,ee,we,he.data)}else if(g.isDataArrayTexture)if(R){if(ce&&t.texStorage3D(i.TEXTURE_2D_ARRAY,re,Te,j.width,j.height,j.depth),ie)if(g.layerUpdates.size>0){const J=No(j.width,j.height,g.format,g.type);for(const Y of g.layerUpdates){const fe=j.data.subarray(Y*J/j.data.BYTES_PER_ELEMENT,(Y+1)*J/j.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Y,j.width,j.height,1,ee,we,fe)}g.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,j.width,j.height,j.depth,ee,we,j.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Te,j.width,j.height,j.depth,0,ee,we,j.data);else if(g.isData3DTexture)R?(ce&&t.texStorage3D(i.TEXTURE_3D,re,Te,j.width,j.height,j.depth),ie&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,j.width,j.height,j.depth,ee,we,j.data)):t.texImage3D(i.TEXTURE_3D,0,Te,j.width,j.height,j.depth,0,ee,we,j.data);else if(g.isFramebufferTexture){if(ce)if(R)t.texStorage2D(i.TEXTURE_2D,re,Te,j.width,j.height);else{let J=j.width,Y=j.height;for(let fe=0;fe<re;fe++)t.texImage2D(i.TEXTURE_2D,fe,Te,J,Y,0,ee,we,null),J>>=1,Y>>=1}}else if(Ce.length>0){if(R&&ce){const J=De(Ce[0]);t.texStorage2D(i.TEXTURE_2D,re,Te,J.width,J.height)}for(let J=0,Y=Ce.length;J<Y;J++)he=Ce[J],R?ie&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,ee,we,he):t.texImage2D(i.TEXTURE_2D,J,Te,ee,we,he);g.generateMipmaps=!1}else if(R){if(ce){const J=De(j);t.texStorage2D(i.TEXTURE_2D,re,Te,J.width,J.height)}ie&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ee,we,j)}else t.texImage2D(i.TEXTURE_2D,0,Te,ee,we,j);m(g)&&f(W),ge.__version=V.version,g.onUpdate&&g.onUpdate(g)}S.__version=g.version}function Z(S,g,N){if(g.image.length!==6)return;const W=Ze(S,g),$=g.source;t.bindTexture(i.TEXTURE_CUBE_MAP,S.__webglTexture,i.TEXTURE0+N);const V=n.get($);if($.version!==V.__version||W===!0){t.activeTexture(i.TEXTURE0+N);const ge=Ye.getPrimaries(Ye.workingColorSpace),oe=g.colorSpace===En?null:Ye.getPrimaries(g.colorSpace),ye=g.colorSpace===En||ge===oe?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye);const xe=g.isCompressedTexture||g.image[0].isCompressedTexture,j=g.image[0]&&g.image[0].isDataTexture,ee=[];for(let Y=0;Y<6;Y++)!xe&&!j?ee[Y]=_(g.image[Y],!0,r.maxCubemapSize):ee[Y]=j?g.image[Y].image:g.image[Y],ee[Y]=be(g,ee[Y]);const we=ee[0],Te=s.convert(g.format,g.colorSpace),he=s.convert(g.type),Ce=y(g.internalFormat,Te,he,g.colorSpace),R=g.isVideoTexture!==!0,ce=V.__version===void 0||W===!0,ie=$.dataReady;let re=C(g,we);We(i.TEXTURE_CUBE_MAP,g);let J;if(xe){R&&ce&&t.texStorage2D(i.TEXTURE_CUBE_MAP,re,Ce,we.width,we.height);for(let Y=0;Y<6;Y++){J=ee[Y].mipmaps;for(let fe=0;fe<J.length;fe++){const Pe=J[fe];g.format!==zt?Te!==null?R?ie&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,fe,0,0,Pe.width,Pe.height,Te,Pe.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,fe,Ce,Pe.width,Pe.height,0,Pe.data):_e("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,fe,0,0,Pe.width,Pe.height,Te,he,Pe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,fe,Ce,Pe.width,Pe.height,0,Te,he,Pe.data)}}}else{if(J=g.mipmaps,R&&ce){J.length>0&&re++;const Y=De(ee[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,re,Ce,Y.width,Y.height)}for(let Y=0;Y<6;Y++)if(j){R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,ee[Y].width,ee[Y].height,Te,he,ee[Y].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Ce,ee[Y].width,ee[Y].height,0,Te,he,ee[Y].data);for(let fe=0;fe<J.length;fe++){const st=J[fe].image[Y].image;R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,fe+1,0,0,st.width,st.height,Te,he,st.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,fe+1,Ce,st.width,st.height,0,Te,he,st.data)}}else{R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,Te,he,ee[Y]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Ce,Te,he,ee[Y]);for(let fe=0;fe<J.length;fe++){const Pe=J[fe];R?ie&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,fe+1,0,0,Te,he,Pe.image[Y]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,fe+1,Ce,Te,he,Pe.image[Y])}}}m(g)&&f(i.TEXTURE_CUBE_MAP),V.__version=$.version,g.onUpdate&&g.onUpdate(g)}S.__version=g.version}function de(S,g,N,W,$,V){const ge=s.convert(N.format,N.colorSpace),oe=s.convert(N.type),ye=y(N.internalFormat,ge,oe,N.colorSpace),xe=n.get(g),j=n.get(N);if(j.__renderTarget=g,!xe.__hasExternalTextures){const ee=Math.max(1,g.width>>V),we=Math.max(1,g.height>>V);$===i.TEXTURE_3D||$===i.TEXTURE_2D_ARRAY?t.texImage3D($,V,ye,ee,we,g.depth,0,ge,oe,null):t.texImage2D($,V,ye,ee,we,0,ge,oe,null)}t.bindFramebuffer(i.FRAMEBUFFER,S),me(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,W,$,j.__webglTexture,0,rt(g)):($===i.TEXTURE_2D||$>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,W,$,j.__webglTexture,V),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Le(S,g,N){if(i.bindRenderbuffer(i.RENDERBUFFER,S),g.depthBuffer){const W=g.depthTexture,$=W&&W.isDepthTexture?W.type:null,V=w(g.stencilBuffer,$),ge=g.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=rt(g);me(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,oe,V,g.width,g.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,oe,V,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,V,g.width,g.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ge,i.RENDERBUFFER,S)}else{const W=g.textures;for(let $=0;$<W.length;$++){const V=W[$],ge=s.convert(V.format,V.colorSpace),oe=s.convert(V.type),ye=y(V.internalFormat,ge,oe,V.colorSpace),xe=rt(g);N&&me(g)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,xe,ye,g.width,g.height):me(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,xe,ye,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,ye,g.width,g.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ve(S,g){if(g&&g.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,S),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const W=n.get(g.depthTexture);W.__renderTarget=g,(!W.__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)&&(g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0),K(g.depthTexture,0);const $=W.__webglTexture,V=rt(g);if(g.depthTexture.format===Bi)me(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,$,0,V):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,$,0);else if(g.depthTexture.format===zi)me(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,$,0,V):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,$,0);else throw new Error("Unknown depthTexture format")}function ze(S){const g=n.get(S),N=S.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==S.depthTexture){const W=S.depthTexture;if(g.__depthDisposeCallback&&g.__depthDisposeCallback(),W){const $=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,W.removeEventListener("dispose",$)};W.addEventListener("dispose",$),g.__depthDisposeCallback=$}g.__boundDepthTexture=W}if(S.depthTexture&&!g.__autoAllocateDepthBuffer){if(N)throw new Error("target.depthTexture not supported in Cube render targets");const W=S.texture.mipmaps;W&&W.length>0?ve(g.__webglFramebuffer[0],S):ve(g.__webglFramebuffer,S)}else if(N){g.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[W]),g.__webglDepthbuffer[W]===void 0)g.__webglDepthbuffer[W]=i.createRenderbuffer(),Le(g.__webglDepthbuffer[W],S,!1);else{const $=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,V=g.__webglDepthbuffer[W];i.bindRenderbuffer(i.RENDERBUFFER,V),i.framebufferRenderbuffer(i.FRAMEBUFFER,$,i.RENDERBUFFER,V)}}else{const W=S.texture.mipmaps;if(W&&W.length>0?t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer),g.__webglDepthbuffer===void 0)g.__webglDepthbuffer=i.createRenderbuffer(),Le(g.__webglDepthbuffer,S,!1);else{const $=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,V=g.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,V),i.framebufferRenderbuffer(i.FRAMEBUFFER,$,i.RENDERBUFFER,V)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function _t(S,g,N){const W=n.get(S);g!==void 0&&de(W.__webglFramebuffer,S,S.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),N!==void 0&&ze(S)}function Oe(S){const g=S.texture,N=n.get(S),W=n.get(g);S.addEventListener("dispose",P);const $=S.textures,V=S.isWebGLCubeRenderTarget===!0,ge=$.length>1;if(ge||(W.__webglTexture===void 0&&(W.__webglTexture=i.createTexture()),W.__version=g.version,a.memory.textures++),V){N.__webglFramebuffer=[];for(let oe=0;oe<6;oe++)if(g.mipmaps&&g.mipmaps.length>0){N.__webglFramebuffer[oe]=[];for(let ye=0;ye<g.mipmaps.length;ye++)N.__webglFramebuffer[oe][ye]=i.createFramebuffer()}else N.__webglFramebuffer[oe]=i.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){N.__webglFramebuffer=[];for(let oe=0;oe<g.mipmaps.length;oe++)N.__webglFramebuffer[oe]=i.createFramebuffer()}else N.__webglFramebuffer=i.createFramebuffer();if(ge)for(let oe=0,ye=$.length;oe<ye;oe++){const xe=n.get($[oe]);xe.__webglTexture===void 0&&(xe.__webglTexture=i.createTexture(),a.memory.textures++)}if(S.samples>0&&me(S)===!1){N.__webglMultisampledFramebuffer=i.createFramebuffer(),N.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let oe=0;oe<$.length;oe++){const ye=$[oe];N.__webglColorRenderbuffer[oe]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,N.__webglColorRenderbuffer[oe]);const xe=s.convert(ye.format,ye.colorSpace),j=s.convert(ye.type),ee=y(ye.internalFormat,xe,j,ye.colorSpace,S.isXRRenderTarget===!0),we=rt(S);i.renderbufferStorageMultisample(i.RENDERBUFFER,we,ee,S.width,S.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.RENDERBUFFER,N.__webglColorRenderbuffer[oe])}i.bindRenderbuffer(i.RENDERBUFFER,null),S.depthBuffer&&(N.__webglDepthRenderbuffer=i.createRenderbuffer(),Le(N.__webglDepthRenderbuffer,S,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(V){t.bindTexture(i.TEXTURE_CUBE_MAP,W.__webglTexture),We(i.TEXTURE_CUBE_MAP,g);for(let oe=0;oe<6;oe++)if(g.mipmaps&&g.mipmaps.length>0)for(let ye=0;ye<g.mipmaps.length;ye++)de(N.__webglFramebuffer[oe][ye],S,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,ye);else de(N.__webglFramebuffer[oe],S,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0);m(g)&&f(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ge){for(let oe=0,ye=$.length;oe<ye;oe++){const xe=$[oe],j=n.get(xe);let ee=i.TEXTURE_2D;(S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)&&(ee=S.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ee,j.__webglTexture),We(ee,xe),de(N.__webglFramebuffer,S,xe,i.COLOR_ATTACHMENT0+oe,ee,0),m(xe)&&f(ee)}t.unbindTexture()}else{let oe=i.TEXTURE_2D;if((S.isWebGL3DRenderTarget||S.isWebGLArrayRenderTarget)&&(oe=S.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(oe,W.__webglTexture),We(oe,g),g.mipmaps&&g.mipmaps.length>0)for(let ye=0;ye<g.mipmaps.length;ye++)de(N.__webglFramebuffer[ye],S,g,i.COLOR_ATTACHMENT0,oe,ye);else de(N.__webglFramebuffer,S,g,i.COLOR_ATTACHMENT0,oe,0);m(g)&&f(oe),t.unbindTexture()}S.depthBuffer&&ze(S)}function at(S){const g=S.textures;for(let N=0,W=g.length;N<W;N++){const $=g[N];if(m($)){const V=T(S),ge=n.get($).__webglTexture;t.bindTexture(V,ge),f(V),t.unbindTexture()}}}const A=[],Ve=[];function ke(S){if(S.samples>0){if(me(S)===!1){const g=S.textures,N=S.width,W=S.height;let $=i.COLOR_BUFFER_BIT;const V=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ge=n.get(S),oe=g.length>1;if(oe)for(let xe=0;xe<g.length;xe++)t.bindFramebuffer(i.FRAMEBUFFER,ge.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ge.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ge.__webglMultisampledFramebuffer);const ye=S.texture.mipmaps;ye&&ye.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ge.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ge.__webglFramebuffer);for(let xe=0;xe<g.length;xe++){if(S.resolveDepthBuffer&&(S.depthBuffer&&($|=i.DEPTH_BUFFER_BIT),S.stencilBuffer&&S.resolveStencilBuffer&&($|=i.STENCIL_BUFFER_BIT)),oe){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ge.__webglColorRenderbuffer[xe]);const j=n.get(g[xe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,j,0)}i.blitFramebuffer(0,0,N,W,0,0,N,W,$,i.NEAREST),l===!0&&(A.length=0,Ve.length=0,A.push(i.COLOR_ATTACHMENT0+xe),S.depthBuffer&&S.resolveDepthBuffer===!1&&(A.push(V),Ve.push(V),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Ve)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,A))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),oe)for(let xe=0;xe<g.length;xe++){t.bindFramebuffer(i.FRAMEBUFFER,ge.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.RENDERBUFFER,ge.__webglColorRenderbuffer[xe]);const j=n.get(g[xe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ge.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.TEXTURE_2D,j,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ge.__webglMultisampledFramebuffer)}else if(S.depthBuffer&&S.resolveDepthBuffer===!1&&l){const g=S.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[g])}}}function rt(S){return Math.min(r.maxSamples,S.samples)}function me(S){const g=n.get(S);return S.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function ot(S){const g=a.render.frame;h.get(S)!==g&&(h.set(S,g),S.update())}function be(S,g){const N=S.colorSpace,W=S.format,$=S.type;return S.isCompressedTexture===!0||S.isVideoTexture===!0||N!==pi&&N!==En&&(Ye.getTransfer(N)===Qe?(W!==zt||$!==nn)&&_e("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Be("WebGLTextures: Unsupported texture color space:",N)),g}function De(S){return typeof HTMLImageElement<"u"&&S instanceof HTMLImageElement?(c.width=S.naturalWidth||S.width,c.height=S.naturalHeight||S.height):typeof VideoFrame<"u"&&S instanceof VideoFrame?(c.width=S.displayWidth,c.height=S.displayHeight):(c.width=S.width,c.height=S.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=B,this.setTexture2D=K,this.setTexture2DArray=q,this.setTexture3D=ne,this.setTextureCube=G,this.rebindTextures=_t,this.setupRenderTarget=Oe,this.updateRenderTargetMipmap=at,this.updateMultisampleRenderTarget=ke,this.setupDepthRenderbuffer=ze,this.setupFrameBufferTexture=de,this.useMultisampledRTT=me}function Bm(i,e){function t(n,r=En){let s;const a=Ye.getTransfer(r);if(n===nn)return i.UNSIGNED_BYTE;if(n===va)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ma)return i.UNSIGNED_SHORT_5_5_5_1;if(n===lc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===hc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===oc)return i.BYTE;if(n===cc)return i.SHORT;if(n===Fi)return i.UNSIGNED_SHORT;if(n===_a)return i.INT;if(n===Gn)return i.UNSIGNED_INT;if(n===Yt)return i.FLOAT;if(n===gi)return i.HALF_FLOAT;if(n===uc)return i.ALPHA;if(n===dc)return i.RGB;if(n===zt)return i.RGBA;if(n===Bi)return i.DEPTH_COMPONENT;if(n===zi)return i.DEPTH_STENCIL;if(n===ba)return i.RED;if(n===Sa)return i.RED_INTEGER;if(n===ya)return i.RG;if(n===Ea)return i.RG_INTEGER;if(n===Ta)return i.RGBA_INTEGER;if(n===Mr||n===br||n===Sr||n===yr)if(a===Qe)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Mr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===br)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Sr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===yr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Mr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===br)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Sr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===yr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Os||n===Bs||n===zs||n===Vs)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Os)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Bs)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===zs)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Vs)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ks||n===Gs||n===Hs)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ks||n===Gs)return a===Qe?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Hs)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Ws||n===Xs||n===qs||n===Ys||n===Ks||n===$s||n===Zs||n===js||n===Js||n===Qs||n===ea||n===ta||n===na||n===ia)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Ws)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Xs)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qs)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ys)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ks)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===$s)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Zs)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===js)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Js)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Qs)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ea)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ta)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===na)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ia)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ra||n===sa||n===aa)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===ra)return a===Qe?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===sa)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===aa)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===oa||n===ca||n===la||n===ha)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===oa)return s.COMPRESSED_RED_RGTC1_EXT;if(n===ca)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===la)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ha)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Oi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const zm=`
|
|
3924
|
+
void main() {
|
|
3925
|
+
|
|
3926
|
+
gl_Position = vec4( position, 1.0 );
|
|
3927
|
+
|
|
3928
|
+
}`,Vm=`
|
|
3929
|
+
uniform sampler2DArray depthColor;
|
|
3930
|
+
uniform float depthWidth;
|
|
3931
|
+
uniform float depthHeight;
|
|
3932
|
+
|
|
3933
|
+
void main() {
|
|
3934
|
+
|
|
3935
|
+
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
|
3936
|
+
|
|
3937
|
+
if ( coord.x >= 1.0 ) {
|
|
3938
|
+
|
|
3939
|
+
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|
3940
|
+
|
|
3941
|
+
} else {
|
|
3942
|
+
|
|
3943
|
+
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|
3944
|
+
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
}`;class km{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Rc(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 xn({vertexShader:zm,fragmentShader:Vm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new St(new Hi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Gm extends Xn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,p=null,x=null;const _=typeof XRWebGLBinding<"u",m=new km,f={},T=t.getContextAttributes();let y=null,w=null;const C=[],E=[],P=new Xe;let z=null;const b=new Ft;b.viewport=new Ke;const M=new Ft;M.viewport=new Ke;const D=[b,M],B=new jh;let k=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let Z=C[X];return Z===void 0&&(Z=new us,C[X]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(X){let Z=C[X];return Z===void 0&&(Z=new us,C[X]=Z),Z.getGripSpace()},this.getHand=function(X){let Z=C[X];return Z===void 0&&(Z=new us,C[X]=Z),Z.getHandSpace()};function K(X){const Z=E.indexOf(X.inputSource);if(Z===-1)return;const de=C[Z];de!==void 0&&(de.update(X.inputSource,X.frame,c||a),de.dispatchEvent({type:X.type,data:X.inputSource}))}function q(){r.removeEventListener("select",K),r.removeEventListener("selectstart",K),r.removeEventListener("selectend",K),r.removeEventListener("squeeze",K),r.removeEventListener("squeezestart",K),r.removeEventListener("squeezeend",K),r.removeEventListener("end",q),r.removeEventListener("inputsourceschange",ne);for(let X=0;X<C.length;X++){const Z=E[X];Z!==null&&(E[X]=null,C[X].disconnect(Z))}k=null,H=null,m.reset();for(const X in f)delete f[X];e.setRenderTarget(y),p=null,d=null,u=null,r=null,w=null,it.stop(),n.isPresenting=!1,e.setPixelRatio(z),e.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,n.isPresenting===!0&&_e("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,n.isPresenting===!0&&_e("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u===null&&_&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return x},this.getSession=function(){return r},this.setSession=async function(X){if(r=X,r!==null){if(y=e.getRenderTarget(),r.addEventListener("select",K),r.addEventListener("selectstart",K),r.addEventListener("selectend",K),r.addEventListener("squeeze",K),r.addEventListener("squeezestart",K),r.addEventListener("squeezeend",K),r.addEventListener("end",q),r.addEventListener("inputsourceschange",ne),T.xrCompatible!==!0&&await t.makeXRCompatible(),z=e.getPixelRatio(),e.getSize(P),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let de=null,Le=null,ve=null;T.depth&&(ve=T.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,de=T.stencil?zi:Bi,Le=T.stencil?Oi:Gn);const ze={colorFormat:t.RGBA8,depthFormat:ve,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(ze),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),w=new Hn(d.textureWidth,d.textureHeight,{format:zt,type:nn,depthTexture:new wc(d.textureWidth,d.textureHeight,Le,void 0,void 0,void 0,void 0,void 0,void 0,de),stencilBuffer:T.stencil,colorSpace:e.outputColorSpace,samples:T.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const de={antialias:T.antialias,alpha:!0,depth:T.depth,stencil:T.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,de),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),w=new Hn(p.framebufferWidth,p.framebufferHeight,{format:zt,type:nn,colorSpace:e.outputColorSpace,stencilBuffer:T.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}w.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),it.setContext(r),it.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function ne(X){for(let Z=0;Z<X.removed.length;Z++){const de=X.removed[Z],Le=E.indexOf(de);Le>=0&&(E[Le]=null,C[Le].disconnect(de))}for(let Z=0;Z<X.added.length;Z++){const de=X.added[Z];let Le=E.indexOf(de);if(Le===-1){for(let ze=0;ze<C.length;ze++)if(ze>=E.length){E.push(de),Le=ze;break}else if(E[ze]===null){E[ze]=de,Le=ze;break}if(Le===-1)break}const ve=C[Le];ve&&ve.connect(de)}}const G=new U,te=new U;function se(X,Z,de){G.setFromMatrixPosition(Z.matrixWorld),te.setFromMatrixPosition(de.matrixWorld);const Le=G.distanceTo(te),ve=Z.projectionMatrix.elements,ze=de.projectionMatrix.elements,_t=ve[14]/(ve[10]-1),Oe=ve[14]/(ve[10]+1),at=(ve[9]+1)/ve[5],A=(ve[9]-1)/ve[5],Ve=(ve[8]-1)/ve[0],ke=(ze[8]+1)/ze[0],rt=_t*Ve,me=_t*ke,ot=Le/(-Ve+ke),be=ot*-Ve;if(Z.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(be),X.translateZ(ot),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),ve[10]===-1)X.projectionMatrix.copy(Z.projectionMatrix),X.projectionMatrixInverse.copy(Z.projectionMatrixInverse);else{const De=_t+ot,S=Oe+ot,g=rt-be,N=me+(Le-be),W=at*Oe/S*De,$=A*Oe/S*De;X.projectionMatrix.makePerspective(g,N,W,$,De,S),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function Se(X,Z){Z===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(Z.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(r===null)return;let Z=X.near,de=X.far;m.texture!==null&&(m.depthNear>0&&(Z=m.depthNear),m.depthFar>0&&(de=m.depthFar)),B.near=M.near=b.near=Z,B.far=M.far=b.far=de,(k!==B.near||H!==B.far)&&(r.updateRenderState({depthNear:B.near,depthFar:B.far}),k=B.near,H=B.far),B.layers.mask=X.layers.mask|6,b.layers.mask=B.layers.mask&3,M.layers.mask=B.layers.mask&5;const Le=X.parent,ve=B.cameras;Se(B,Le);for(let ze=0;ze<ve.length;ze++)Se(ve[ze],Le);ve.length===2?se(B,b,M):B.projectionMatrix.copy(b.projectionMatrix),We(X,B,Le)};function We(X,Z,de){de===null?X.matrix.copy(Z.matrixWorld):(X.matrix.copy(de.matrixWorld),X.matrix.invert(),X.matrix.multiply(Z.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(Z.projectionMatrix),X.projectionMatrixInverse.copy(Z.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=mi*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return B},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(X){l=X,d!==null&&(d.fixedFoveation=X),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=X)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(B)},this.getCameraTexture=function(X){return f[X]};let Ze=null;function nt(X,Z){if(h=Z.getViewerPose(c||a),x=Z,h!==null){const de=h.views;p!==null&&(e.setRenderTargetFramebuffer(w,p.framebuffer),e.setRenderTarget(w));let Le=!1;de.length!==B.cameras.length&&(B.cameras.length=0,Le=!0);for(let Oe=0;Oe<de.length;Oe++){const at=de[Oe];let A=null;if(p!==null)A=p.getViewport(at);else{const ke=u.getViewSubImage(d,at);A=ke.viewport,Oe===0&&(e.setRenderTargetTextures(w,ke.colorTexture,ke.depthStencilTexture),e.setRenderTarget(w))}let Ve=D[Oe];Ve===void 0&&(Ve=new Ft,Ve.layers.enable(Oe),Ve.viewport=new Ke,D[Oe]=Ve),Ve.matrix.fromArray(at.transform.matrix),Ve.matrix.decompose(Ve.position,Ve.quaternion,Ve.scale),Ve.projectionMatrix.fromArray(at.projectionMatrix),Ve.projectionMatrixInverse.copy(Ve.projectionMatrix).invert(),Ve.viewport.set(A.x,A.y,A.width,A.height),Oe===0&&(B.matrix.copy(Ve.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale)),Le===!0&&B.cameras.push(Ve)}const ve=r.enabledFeatures;if(ve&&ve.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&_){u=n.getBinding();const Oe=u.getDepthInformation(de[0]);Oe&&Oe.isValid&&Oe.texture&&m.init(Oe,r.renderState)}if(ve&&ve.includes("camera-access")&&_){e.state.unbindTexture(),u=n.getBinding();for(let Oe=0;Oe<de.length;Oe++){const at=de[Oe].camera;if(at){let A=f[at];A||(A=new Rc,f[at]=A);const Ve=u.getCameraImage(at);A.sourceTexture=Ve}}}}for(let de=0;de<C.length;de++){const Le=E[de],ve=C[de];Le!==null&&ve!==void 0&&ve.update(Le,Z,c||a)}Ze&&Ze(X,Z),Z.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Z}),x=null}const it=new Lc;it.setAnimationLoop(nt),this.setAnimationLoop=function(X){Ze=X},this.dispose=function(){}}}const On=new Zt,Hm=new He;function Wm(i,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,Mc(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function r(m,f,T,y,w){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(m,f):f.isMeshToonMaterial?(s(m,f),u(m,f)):f.isMeshPhongMaterial?(s(m,f),h(m,f)):f.isMeshStandardMaterial?(s(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,w)):f.isMeshMatcapMaterial?(s(m,f),x(m,f)):f.isMeshDepthMaterial?s(m,f):f.isMeshDistanceMaterial?(s(m,f),_(m,f)):f.isMeshNormalMaterial?s(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,T,y):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Ct&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Ct&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const T=e.get(f),y=T.envMap,w=T.envMapRotation;y&&(m.envMap.value=y,On.copy(w),On.x*=-1,On.y*=-1,On.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(On.y*=-1,On.z*=-1),m.envMapRotation.value.setFromMatrix4(Hm.makeRotationFromEuler(On)),m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,T,y){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*T,m.scale.value=y*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function u(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,T){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Ct&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=T.texture,m.transmissionSamplerSize.value.set(T.width,T.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function x(m,f){f.matcap&&(m.matcap.value=f.matcap)}function _(m,f){const T=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(T.matrixWorld),m.nearDistance.value=T.shadow.camera.near,m.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Xm(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(T,y){const w=y.program;n.uniformBlockBinding(T,w)}function c(T,y){let w=r[T.id];w===void 0&&(x(T),w=h(T),r[T.id]=w,T.addEventListener("dispose",m));const C=y.program;n.updateUBOMapping(T,C);const E=e.render.frame;s[T.id]!==E&&(d(T),s[T.id]=E)}function h(T){const y=u();T.__bindingPointIndex=y;const w=i.createBuffer(),C=T.__size,E=T.usage;return i.bindBuffer(i.UNIFORM_BUFFER,w),i.bufferData(i.UNIFORM_BUFFER,C,E),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,w),w}function u(){for(let T=0;T<o;T++)if(a.indexOf(T)===-1)return a.push(T),T;return Be("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(T){const y=r[T.id],w=T.uniforms,C=T.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let E=0,P=w.length;E<P;E++){const z=Array.isArray(w[E])?w[E]:[w[E]];for(let b=0,M=z.length;b<M;b++){const D=z[b];if(p(D,E,b,C)===!0){const B=D.__offset,k=Array.isArray(D.value)?D.value:[D.value];let H=0;for(let K=0;K<k.length;K++){const q=k[K],ne=_(q);typeof q=="number"||typeof q=="boolean"?(D.__data[0]=q,i.bufferSubData(i.UNIFORM_BUFFER,B+H,D.__data)):q.isMatrix3?(D.__data[0]=q.elements[0],D.__data[1]=q.elements[1],D.__data[2]=q.elements[2],D.__data[3]=0,D.__data[4]=q.elements[3],D.__data[5]=q.elements[4],D.__data[6]=q.elements[5],D.__data[7]=0,D.__data[8]=q.elements[6],D.__data[9]=q.elements[7],D.__data[10]=q.elements[8],D.__data[11]=0):(q.toArray(D.__data,H),H+=ne.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,B,D.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(T,y,w,C){const E=T.value,P=y+"_"+w;if(C[P]===void 0)return typeof E=="number"||typeof E=="boolean"?C[P]=E:C[P]=E.clone(),!0;{const z=C[P];if(typeof E=="number"||typeof E=="boolean"){if(z!==E)return C[P]=E,!0}else if(z.equals(E)===!1)return z.copy(E),!0}return!1}function x(T){const y=T.uniforms;let w=0;const C=16;for(let P=0,z=y.length;P<z;P++){const b=Array.isArray(y[P])?y[P]:[y[P]];for(let M=0,D=b.length;M<D;M++){const B=b[M],k=Array.isArray(B.value)?B.value:[B.value];for(let H=0,K=k.length;H<K;H++){const q=k[H],ne=_(q),G=w%C,te=G%ne.boundary,se=G+te;w+=te,se!==0&&C-se<ne.storage&&(w+=C-se),B.__data=new Float32Array(ne.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=w,w+=ne.storage}}}const E=w%C;return E>0&&(w+=C-E),T.__size=w,T.__cache={},this}function _(T){const y={boundary:0,storage:0};return typeof T=="number"||typeof T=="boolean"?(y.boundary=4,y.storage=4):T.isVector2?(y.boundary=8,y.storage=8):T.isVector3||T.isColor?(y.boundary=16,y.storage=12):T.isVector4?(y.boundary=16,y.storage=16):T.isMatrix3?(y.boundary=48,y.storage=48):T.isMatrix4?(y.boundary=64,y.storage=64):T.isTexture?_e("WebGLRenderer: Texture samplers can not be part of an uniforms group."):_e("WebGLRenderer: Unsupported uniform value type.",T),y}function m(T){const y=T.target;y.removeEventListener("dispose",m);const w=a.indexOf(y.__bindingPointIndex);a.splice(w,1),i.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function f(){for(const T in r)i.deleteBuffer(r[T]);a=[],r={},s={}}return{bind:l,update:c,dispose:f}}const qm=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let hn=null;function Ym(){return hn===null&&(hn=new Nr(qm,32,32,ya,gi),hn.minFilter=At,hn.magFilter=At,hn.wrapS=dn,hn.wrapT=dn,hn.generateMipmaps=!1,hn.needsUpdate=!0),hn}class E0{constructor(e={}){const{canvas:t=Fl(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const x=new Set([Ta,Ea,Sa]),_=new Set([nn,Gn,Fi,Oi,va,Ma]),m=new Uint32Array(4),f=new Int32Array(4);let T=null,y=null;const w=[],C=[];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 E=this;let P=!1;this._outputColorSpace=Nt;let z=0,b=0,M=null,D=-1,B=null;const k=new Ke,H=new Ke;let K=null;const q=new Ne(0);let ne=0,G=t.width,te=t.height,se=1,Se=null,We=null;const Ze=new Ke(0,0,G,te),nt=new Ke(0,0,G,te);let it=!1;const X=new Ca;let Z=!1,de=!1;const Le=new He,ve=new U,ze=new Ke,_t={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Oe=!1;function at(){return M===null?se:1}let A=n;function Ve(v,L){return t.getContext(v,L)}try{const v={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${xa}`),t.addEventListener("webglcontextlost",J,!1),t.addEventListener("webglcontextrestored",Y,!1),t.addEventListener("webglcontextcreationerror",fe,!1),A===null){const L="webgl2";if(A=Ve(L,v),A===null)throw Ve(L)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(v){throw v("WebGLRenderer: "+v.message),v}let ke,rt,me,ot,be,De,S,g,N,W,$,V,ge,oe,ye,xe,j,ee,we,Te,he,Ce,R,ce;function ie(){ke=new np(A),ke.init(),Ce=new Bm(A,ke),rt=new Yf(A,ke,e,Ce),me=new Fm(A,ke),rt.reversedDepthBuffer&&d&&me.buffers.depth.setReversed(!0),ot=new sp(A),be=new ym,De=new Om(A,ke,me,be,rt,Ce,ot),S=new $f(E),g=new tp(E),N=new cu(A),R=new Xf(A,N),W=new ip(A,N,ot,R),$=new op(A,W,N,ot),we=new ap(A,rt,De),xe=new Kf(be),V=new Sm(E,S,g,ke,rt,R,xe),ge=new Wm(E,be),oe=new Tm,ye=new Dm(ke),ee=new Wf(E,S,g,me,$,p,l),j=new Um(E,$,rt),ce=new Xm(A,ot,rt,me),Te=new qf(A,ke,ot),he=new rp(A,ke,ot),ot.programs=V.programs,E.capabilities=rt,E.extensions=ke,E.properties=be,E.renderLists=oe,E.shadowMap=j,E.state=me,E.info=ot}ie();const re=new Gm(E,A);this.xr=re,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){const v=ke.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){const v=ke.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(v){v!==void 0&&(se=v,this.setSize(G,te,!1))},this.getSize=function(v){return v.set(G,te)},this.setSize=function(v,L,F=!0){if(re.isPresenting){_e("WebGLRenderer: Can't change size while VR device is presenting.");return}G=v,te=L,t.width=Math.floor(v*se),t.height=Math.floor(L*se),F===!0&&(t.style.width=v+"px",t.style.height=L+"px"),this.setViewport(0,0,v,L)},this.getDrawingBufferSize=function(v){return v.set(G*se,te*se).floor()},this.setDrawingBufferSize=function(v,L,F){G=v,te=L,se=F,t.width=Math.floor(v*F),t.height=Math.floor(L*F),this.setViewport(0,0,v,L)},this.getCurrentViewport=function(v){return v.copy(k)},this.getViewport=function(v){return v.copy(Ze)},this.setViewport=function(v,L,F,O){v.isVector4?Ze.set(v.x,v.y,v.z,v.w):Ze.set(v,L,F,O),me.viewport(k.copy(Ze).multiplyScalar(se).round())},this.getScissor=function(v){return v.copy(nt)},this.setScissor=function(v,L,F,O){v.isVector4?nt.set(v.x,v.y,v.z,v.w):nt.set(v,L,F,O),me.scissor(H.copy(nt).multiplyScalar(se).round())},this.getScissorTest=function(){return it},this.setScissorTest=function(v){me.setScissorTest(it=v)},this.setOpaqueSort=function(v){Se=v},this.setTransparentSort=function(v){We=v},this.getClearColor=function(v){return v.copy(ee.getClearColor())},this.setClearColor=function(){ee.setClearColor(...arguments)},this.getClearAlpha=function(){return ee.getClearAlpha()},this.setClearAlpha=function(){ee.setClearAlpha(...arguments)},this.clear=function(v=!0,L=!0,F=!0){let O=0;if(v){let I=!1;if(M!==null){const Q=M.texture.format;I=x.has(Q)}if(I){const Q=M.texture.type,le=_.has(Q),pe=ee.getClearColor(),ue=ee.getClearAlpha(),Ae=pe.r,Re=pe.g,Me=pe.b;le?(m[0]=Ae,m[1]=Re,m[2]=Me,m[3]=ue,A.clearBufferuiv(A.COLOR,0,m)):(f[0]=Ae,f[1]=Re,f[2]=Me,f[3]=ue,A.clearBufferiv(A.COLOR,0,f))}else O|=A.COLOR_BUFFER_BIT}L&&(O|=A.DEPTH_BUFFER_BIT),F&&(O|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(O)},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.dispose=function(){t.removeEventListener("webglcontextlost",J,!1),t.removeEventListener("webglcontextrestored",Y,!1),t.removeEventListener("webglcontextcreationerror",fe,!1),ee.dispose(),oe.dispose(),ye.dispose(),be.dispose(),S.dispose(),g.dispose(),$.dispose(),R.dispose(),ce.dispose(),V.dispose(),re.dispose(),re.removeEventListener("sessionstart",Ua),re.removeEventListener("sessionend",Na),Pn.stop()};function J(v){v.preventDefault(),Rr("WebGLRenderer: Context Lost."),P=!0}function Y(){Rr("WebGLRenderer: Context Restored."),P=!1;const v=ot.autoReset,L=j.enabled,F=j.autoUpdate,O=j.needsUpdate,I=j.type;ie(),ot.autoReset=v,j.enabled=L,j.autoUpdate=F,j.needsUpdate=O,j.type=I}function fe(v){Be("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function Pe(v){const L=v.target;L.removeEventListener("dispose",Pe),st(L)}function st(v){je(v),be.remove(v)}function je(v){const L=be.get(v).programs;L!==void 0&&(L.forEach(function(F){V.releaseProgram(F)}),v.isShaderMaterial&&V.releaseShaderCache(v))}this.renderBufferDirect=function(v,L,F,O,I,Q){L===null&&(L=_t);const le=I.isMesh&&I.matrixWorld.determinant()<0,pe=kc(v,L,F,O,I);me.setMaterial(O,le);let ue=F.index,Ae=1;if(O.wireframe===!0){if(ue=W.getWireframeAttribute(F),ue===void 0)return;Ae=2}const Re=F.drawRange,Me=F.attributes.position;let Ge=Re.start*Ae,Je=(Re.start+Re.count)*Ae;Q!==null&&(Ge=Math.max(Ge,Q.start*Ae),Je=Math.min(Je,(Q.start+Q.count)*Ae)),ue!==null?(Ge=Math.max(Ge,0),Je=Math.min(Je,ue.count)):Me!=null&&(Ge=Math.max(Ge,0),Je=Math.min(Je,Me.count));const ht=Je-Ge;if(ht<0||ht===1/0)return;R.setup(I,O,pe,F,ue);let ut,tt=Te;if(ue!==null&&(ut=N.get(ue),tt=he,tt.setIndex(ut)),I.isMesh)O.wireframe===!0?(me.setLineWidth(O.wireframeLinewidth*at()),tt.setMode(A.LINES)):tt.setMode(A.TRIANGLES);else if(I.isLine){let Ee=O.linewidth;Ee===void 0&&(Ee=1),me.setLineWidth(Ee*at()),I.isLineSegments?tt.setMode(A.LINES):I.isLineLoop?tt.setMode(A.LINE_LOOP):tt.setMode(A.LINE_STRIP)}else I.isPoints?tt.setMode(A.POINTS):I.isSprite&&tt.setMode(A.TRIANGLES);if(I.isBatchedMesh)if(I._multiDrawInstances!==null)ki("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),tt.renderMultiDrawInstances(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount,I._multiDrawInstances);else if(ke.get("WEBGL_multi_draw"))tt.renderMultiDraw(I._multiDrawStarts,I._multiDrawCounts,I._multiDrawCount);else{const Ee=I._multiDrawStarts,ct=I._multiDrawCounts,qe=I._multiDrawCount,Dt=ue?N.get(ue).bytesPerElement:1,qn=be.get(O).currentProgram.getUniforms();for(let Lt=0;Lt<qe;Lt++)qn.setValue(A,"_gl_DrawID",Lt),tt.render(Ee[Lt]/Dt,ct[Lt])}else if(I.isInstancedMesh)tt.renderInstances(Ge,ht,I.count);else if(F.isInstancedBufferGeometry){const Ee=F._maxInstanceCount!==void 0?F._maxInstanceCount:1/0,ct=Math.min(F.instanceCount,Ee);tt.renderInstances(Ge,ht,ct)}else tt.render(Ge,ht)};function Jt(v,L,F){v.transparent===!0&&v.side===en&&v.forceSinglePass===!1?(v.side=Ct,v.needsUpdate=!0,qi(v,L,F),v.side=wn,v.needsUpdate=!0,qi(v,L,F),v.side=en):qi(v,L,F)}this.compile=function(v,L,F=null){F===null&&(F=v),y=ye.get(F),y.init(L),C.push(y),F.traverseVisible(function(I){I.isLight&&I.layers.test(L.layers)&&(y.pushLight(I),I.castShadow&&y.pushShadow(I))}),v!==F&&v.traverseVisible(function(I){I.isLight&&I.layers.test(L.layers)&&(y.pushLight(I),I.castShadow&&y.pushShadow(I))}),y.setupLights();const O=new Set;return v.traverse(function(I){if(!(I.isMesh||I.isPoints||I.isLine||I.isSprite))return;const Q=I.material;if(Q)if(Array.isArray(Q))for(let le=0;le<Q.length;le++){const pe=Q[le];Jt(pe,F,I),O.add(pe)}else Jt(Q,F,I),O.add(Q)}),y=C.pop(),O},this.compileAsync=function(v,L,F=null){const O=this.compile(v,L,F);return new Promise(I=>{function Q(){if(O.forEach(function(le){be.get(le).currentProgram.isReady()&&O.delete(le)}),O.size===0){I(v);return}setTimeout(Q,10)}ke.get("KHR_parallel_shader_compile")!==null?Q():setTimeout(Q,10)})};let kt=null;function Vc(v){kt&&kt(v)}function Ua(){Pn.stop()}function Na(){Pn.start()}const Pn=new Lc;Pn.setAnimationLoop(Vc),typeof self<"u"&&Pn.setContext(self),this.setAnimationLoop=function(v){kt=v,re.setAnimationLoop(v),v===null?Pn.stop():Pn.start()},re.addEventListener("sessionstart",Ua),re.addEventListener("sessionend",Na),this.render=function(v,L){if(L!==void 0&&L.isCamera!==!0){Be("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(re.cameraAutoUpdate===!0&&re.updateCamera(L),L=re.getCamera()),v.isScene===!0&&v.onBeforeRender(E,v,L,M),y=ye.get(v,C.length),y.init(L),C.push(y),Le.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),X.setFromProjectionMatrix(Le,tn,L.reversedDepth),de=this.localClippingEnabled,Z=xe.init(this.clippingPlanes,de),T=oe.get(v,w.length),T.init(),w.push(T),re.enabled===!0&&re.isPresenting===!0){const Q=E.xr.getDepthSensingMesh();Q!==null&&kr(Q,L,-1/0,E.sortObjects)}kr(v,L,0,E.sortObjects),T.finish(),E.sortObjects===!0&&T.sort(Se,We),Oe=re.enabled===!1||re.isPresenting===!1||re.hasDepthSensing()===!1,Oe&&ee.addToRenderList(T,v),this.info.render.frame++,Z===!0&&xe.beginShadows();const F=y.state.shadowsArray;j.render(F,v,L),Z===!0&&xe.endShadows(),this.info.autoReset===!0&&this.info.reset();const O=T.opaque,I=T.transmissive;if(y.setupLights(),L.isArrayCamera){const Q=L.cameras;if(I.length>0)for(let le=0,pe=Q.length;le<pe;le++){const ue=Q[le];Oa(O,I,v,ue)}Oe&&ee.render(v);for(let le=0,pe=Q.length;le<pe;le++){const ue=Q[le];Fa(T,v,ue,ue.viewport)}}else I.length>0&&Oa(O,I,v,L),Oe&&ee.render(v),Fa(T,v,L);M!==null&&b===0&&(De.updateMultisampleRenderTarget(M),De.updateRenderTargetMipmap(M)),v.isScene===!0&&v.onAfterRender(E,v,L),R.resetDefaultState(),D=-1,B=null,C.pop(),C.length>0?(y=C[C.length-1],Z===!0&&xe.setGlobalState(E.clippingPlanes,y.state.camera)):y=null,w.pop(),w.length>0?T=w[w.length-1]:T=null};function kr(v,L,F,O){if(v.visible===!1)return;if(v.layers.test(L.layers)){if(v.isGroup)F=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(L);else if(v.isLight)y.pushLight(v),v.castShadow&&y.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||X.intersectsSprite(v)){O&&ze.setFromMatrixPosition(v.matrixWorld).applyMatrix4(Le);const le=$.update(v),pe=v.material;pe.visible&&T.push(v,le,pe,F,ze.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||X.intersectsObject(v))){const le=$.update(v),pe=v.material;if(O&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),ze.copy(v.boundingSphere.center)):(le.boundingSphere===null&&le.computeBoundingSphere(),ze.copy(le.boundingSphere.center)),ze.applyMatrix4(v.matrixWorld).applyMatrix4(Le)),Array.isArray(pe)){const ue=le.groups;for(let Ae=0,Re=ue.length;Ae<Re;Ae++){const Me=ue[Ae],Ge=pe[Me.materialIndex];Ge&&Ge.visible&&T.push(v,le,Ge,F,ze.z,Me)}}else pe.visible&&T.push(v,le,pe,F,ze.z,null)}}const Q=v.children;for(let le=0,pe=Q.length;le<pe;le++)kr(Q[le],L,F,O)}function Fa(v,L,F,O){const{opaque:I,transmissive:Q,transparent:le}=v;y.setupLightsView(F),Z===!0&&xe.setGlobalState(E.clippingPlanes,F),O&&me.viewport(k.copy(O)),I.length>0&&Xi(I,L,F),Q.length>0&&Xi(Q,L,F),le.length>0&&Xi(le,L,F),me.buffers.depth.setTest(!0),me.buffers.depth.setMask(!0),me.buffers.color.setMask(!0),me.setPolygonOffset(!1)}function Oa(v,L,F,O){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;y.state.transmissionRenderTarget[O.id]===void 0&&(y.state.transmissionRenderTarget[O.id]=new Hn(1,1,{generateMipmaps:!0,type:ke.has("EXT_color_buffer_half_float")||ke.has("EXT_color_buffer_float")?gi:nn,minFilter:kn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ye.workingColorSpace}));const Q=y.state.transmissionRenderTarget[O.id],le=O.viewport||k;Q.setSize(le.z*E.transmissionResolutionScale,le.w*E.transmissionResolutionScale);const pe=E.getRenderTarget(),ue=E.getActiveCubeFace(),Ae=E.getActiveMipmapLevel();E.setRenderTarget(Q),E.getClearColor(q),ne=E.getClearAlpha(),ne<1&&E.setClearColor(16777215,.5),E.clear(),Oe&&ee.render(F);const Re=E.toneMapping;E.toneMapping=An;const Me=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),y.setupLightsView(O),Z===!0&&xe.setGlobalState(E.clippingPlanes,O),Xi(v,F,O),De.updateMultisampleRenderTarget(Q),De.updateRenderTargetMipmap(Q),ke.has("WEBGL_multisampled_render_to_texture")===!1){let Ge=!1;for(let Je=0,ht=L.length;Je<ht;Je++){const ut=L[Je],{object:tt,geometry:Ee,material:ct,group:qe}=ut;if(ct.side===en&&tt.layers.test(O.layers)){const Dt=ct.side;ct.side=Ct,ct.needsUpdate=!0,Ba(tt,F,O,Ee,ct,qe),ct.side=Dt,ct.needsUpdate=!0,Ge=!0}}Ge===!0&&(De.updateMultisampleRenderTarget(Q),De.updateRenderTargetMipmap(Q))}E.setRenderTarget(pe,ue,Ae),E.setClearColor(q,ne),Me!==void 0&&(O.viewport=Me),E.toneMapping=Re}function Xi(v,L,F){const O=L.isScene===!0?L.overrideMaterial:null;for(let I=0,Q=v.length;I<Q;I++){const le=v[I],{object:pe,geometry:ue,group:Ae}=le;let Re=le.material;Re.allowOverride===!0&&O!==null&&(Re=O),pe.layers.test(F.layers)&&Ba(pe,L,F,ue,Re,Ae)}}function Ba(v,L,F,O,I,Q){v.onBeforeRender(E,L,F,O,I,Q),v.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),I.onBeforeRender(E,L,F,O,v,Q),I.transparent===!0&&I.side===en&&I.forceSinglePass===!1?(I.side=Ct,I.needsUpdate=!0,E.renderBufferDirect(F,L,O,I,v,Q),I.side=wn,I.needsUpdate=!0,E.renderBufferDirect(F,L,O,I,v,Q),I.side=en):E.renderBufferDirect(F,L,O,I,v,Q),v.onAfterRender(E,L,F,O,I,Q)}function qi(v,L,F){L.isScene!==!0&&(L=_t);const O=be.get(v),I=y.state.lights,Q=y.state.shadowsArray,le=I.state.version,pe=V.getParameters(v,I.state,Q,L,F),ue=V.getProgramCacheKey(pe);let Ae=O.programs;O.environment=v.isMeshStandardMaterial?L.environment:null,O.fog=L.fog,O.envMap=(v.isMeshStandardMaterial?g:S).get(v.envMap||O.environment),O.envMapRotation=O.environment!==null&&v.envMap===null?L.environmentRotation:v.envMapRotation,Ae===void 0&&(v.addEventListener("dispose",Pe),Ae=new Map,O.programs=Ae);let Re=Ae.get(ue);if(Re!==void 0){if(O.currentProgram===Re&&O.lightsStateVersion===le)return Va(v,pe),Re}else pe.uniforms=V.getUniforms(v),v.onBeforeCompile(pe,E),Re=V.acquireProgram(pe,ue),Ae.set(ue,Re),O.uniforms=pe.uniforms;const Me=O.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(Me.clippingPlanes=xe.uniform),Va(v,pe),O.needsLights=Hc(v),O.lightsStateVersion=le,O.needsLights&&(Me.ambientLightColor.value=I.state.ambient,Me.lightProbe.value=I.state.probe,Me.directionalLights.value=I.state.directional,Me.directionalLightShadows.value=I.state.directionalShadow,Me.spotLights.value=I.state.spot,Me.spotLightShadows.value=I.state.spotShadow,Me.rectAreaLights.value=I.state.rectArea,Me.ltc_1.value=I.state.rectAreaLTC1,Me.ltc_2.value=I.state.rectAreaLTC2,Me.pointLights.value=I.state.point,Me.pointLightShadows.value=I.state.pointShadow,Me.hemisphereLights.value=I.state.hemi,Me.directionalShadowMap.value=I.state.directionalShadowMap,Me.directionalShadowMatrix.value=I.state.directionalShadowMatrix,Me.spotShadowMap.value=I.state.spotShadowMap,Me.spotLightMatrix.value=I.state.spotLightMatrix,Me.spotLightMap.value=I.state.spotLightMap,Me.pointShadowMap.value=I.state.pointShadowMap,Me.pointShadowMatrix.value=I.state.pointShadowMatrix),O.currentProgram=Re,O.uniformsList=null,Re}function za(v){if(v.uniformsList===null){const L=v.currentProgram.getUniforms();v.uniformsList=Er.seqWithValue(L.seq,v.uniforms)}return v.uniformsList}function Va(v,L){const F=be.get(v);F.outputColorSpace=L.outputColorSpace,F.batching=L.batching,F.batchingColor=L.batchingColor,F.instancing=L.instancing,F.instancingColor=L.instancingColor,F.instancingMorph=L.instancingMorph,F.skinning=L.skinning,F.morphTargets=L.morphTargets,F.morphNormals=L.morphNormals,F.morphColors=L.morphColors,F.morphTargetsCount=L.morphTargetsCount,F.numClippingPlanes=L.numClippingPlanes,F.numIntersection=L.numClipIntersection,F.vertexAlphas=L.vertexAlphas,F.vertexTangents=L.vertexTangents,F.toneMapping=L.toneMapping}function kc(v,L,F,O,I){L.isScene!==!0&&(L=_t),De.resetTextureUnits();const Q=L.fog,le=O.isMeshStandardMaterial?L.environment:null,pe=M===null?E.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:pi,ue=(O.isMeshStandardMaterial?g:S).get(O.envMap||le),Ae=O.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,Re=!!F.attributes.tangent&&(!!O.normalMap||O.anisotropy>0),Me=!!F.morphAttributes.position,Ge=!!F.morphAttributes.normal,Je=!!F.morphAttributes.color;let ht=An;O.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(ht=E.toneMapping);const ut=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,tt=ut!==void 0?ut.length:0,Ee=be.get(O),ct=y.state.lights;if(Z===!0&&(de===!0||v!==B)){const yt=v===B&&O.id===D;xe.setState(O,v,yt)}let qe=!1;O.version===Ee.__version?(Ee.needsLights&&Ee.lightsStateVersion!==ct.state.version||Ee.outputColorSpace!==pe||I.isBatchedMesh&&Ee.batching===!1||!I.isBatchedMesh&&Ee.batching===!0||I.isBatchedMesh&&Ee.batchingColor===!0&&I.colorTexture===null||I.isBatchedMesh&&Ee.batchingColor===!1&&I.colorTexture!==null||I.isInstancedMesh&&Ee.instancing===!1||!I.isInstancedMesh&&Ee.instancing===!0||I.isSkinnedMesh&&Ee.skinning===!1||!I.isSkinnedMesh&&Ee.skinning===!0||I.isInstancedMesh&&Ee.instancingColor===!0&&I.instanceColor===null||I.isInstancedMesh&&Ee.instancingColor===!1&&I.instanceColor!==null||I.isInstancedMesh&&Ee.instancingMorph===!0&&I.morphTexture===null||I.isInstancedMesh&&Ee.instancingMorph===!1&&I.morphTexture!==null||Ee.envMap!==ue||O.fog===!0&&Ee.fog!==Q||Ee.numClippingPlanes!==void 0&&(Ee.numClippingPlanes!==xe.numPlanes||Ee.numIntersection!==xe.numIntersection)||Ee.vertexAlphas!==Ae||Ee.vertexTangents!==Re||Ee.morphTargets!==Me||Ee.morphNormals!==Ge||Ee.morphColors!==Je||Ee.toneMapping!==ht||Ee.morphTargetsCount!==tt)&&(qe=!0):(qe=!0,Ee.__version=O.version);let Dt=Ee.currentProgram;qe===!0&&(Dt=qi(O,L,I));let qn=!1,Lt=!1,Si=!1;const lt=Dt.getUniforms(),wt=Ee.uniforms;if(me.useProgram(Dt.program)&&(qn=!0,Lt=!0,Si=!0),O.id!==D&&(D=O.id,Lt=!0),qn||B!==v){me.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),lt.setValue(A,"projectionMatrix",v.projectionMatrix),lt.setValue(A,"viewMatrix",v.matrixWorldInverse);const Rt=lt.map.cameraPosition;Rt!==void 0&&Rt.setValue(A,ve.setFromMatrixPosition(v.matrixWorld)),rt.logarithmicDepthBuffer&<.setValue(A,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&<.setValue(A,"isOrthographic",v.isOrthographicCamera===!0),B!==v&&(B=v,Lt=!0,Si=!0)}if(I.isSkinnedMesh){lt.setOptional(A,I,"bindMatrix"),lt.setOptional(A,I,"bindMatrixInverse");const yt=I.skeleton;yt&&(yt.boneTexture===null&&yt.computeBoneTexture(),lt.setValue(A,"boneTexture",yt.boneTexture,De))}I.isBatchedMesh&&(lt.setOptional(A,I,"batchingTexture"),lt.setValue(A,"batchingTexture",I._matricesTexture,De),lt.setOptional(A,I,"batchingIdTexture"),lt.setValue(A,"batchingIdTexture",I._indirectTexture,De),lt.setOptional(A,I,"batchingColorTexture"),I._colorsTexture!==null&<.setValue(A,"batchingColorTexture",I._colorsTexture,De));const Ot=F.morphAttributes;if((Ot.position!==void 0||Ot.normal!==void 0||Ot.color!==void 0)&&we.update(I,F,Dt),(Lt||Ee.receiveShadow!==I.receiveShadow)&&(Ee.receiveShadow=I.receiveShadow,lt.setValue(A,"receiveShadow",I.receiveShadow)),O.isMeshGouraudMaterial&&O.envMap!==null&&(wt.envMap.value=ue,wt.flipEnvMap.value=ue.isCubeTexture&&ue.isRenderTargetTexture===!1?-1:1),O.isMeshStandardMaterial&&O.envMap===null&&L.environment!==null&&(wt.envMapIntensity.value=L.environmentIntensity),wt.dfgLUT!==void 0&&(wt.dfgLUT.value=Ym()),Lt&&(lt.setValue(A,"toneMappingExposure",E.toneMappingExposure),Ee.needsLights&&Gc(wt,Si),Q&&O.fog===!0&&ge.refreshFogUniforms(wt,Q),ge.refreshMaterialUniforms(wt,O,se,te,y.state.transmissionRenderTarget[v.id]),Er.upload(A,za(Ee),wt,De)),O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(Er.upload(A,za(Ee),wt,De),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&<.setValue(A,"center",I.center),lt.setValue(A,"modelViewMatrix",I.modelViewMatrix),lt.setValue(A,"normalMatrix",I.normalMatrix),lt.setValue(A,"modelMatrix",I.matrixWorld),O.isShaderMaterial||O.isRawShaderMaterial){const yt=O.uniformsGroups;for(let Rt=0,Gr=yt.length;Rt<Gr;Rt++){const Dn=yt[Rt];ce.update(Dn,Dt),ce.bind(Dn,Dt)}}return Dt}function Gc(v,L){v.ambientLightColor.needsUpdate=L,v.lightProbe.needsUpdate=L,v.directionalLights.needsUpdate=L,v.directionalLightShadows.needsUpdate=L,v.pointLights.needsUpdate=L,v.pointLightShadows.needsUpdate=L,v.spotLights.needsUpdate=L,v.spotLightShadows.needsUpdate=L,v.rectAreaLights.needsUpdate=L,v.hemisphereLights.needsUpdate=L}function Hc(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return z},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(v,L,F){const O=be.get(v);O.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,O.__autoAllocateDepthBuffer===!1&&(O.__useRenderToTexture=!1),be.get(v.texture).__webglTexture=L,be.get(v.depthTexture).__webglTexture=O.__autoAllocateDepthBuffer?void 0:F,O.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,L){const F=be.get(v);F.__webglFramebuffer=L,F.__useDefaultFramebuffer=L===void 0};const Wc=A.createFramebuffer();this.setRenderTarget=function(v,L=0,F=0){M=v,z=L,b=F;let O=!0,I=null,Q=!1,le=!1;if(v){const ue=be.get(v);if(ue.__useDefaultFramebuffer!==void 0)me.bindFramebuffer(A.FRAMEBUFFER,null),O=!1;else if(ue.__webglFramebuffer===void 0)De.setupRenderTarget(v);else if(ue.__hasExternalTextures)De.rebindTextures(v,be.get(v.texture).__webglTexture,be.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){const Me=v.depthTexture;if(ue.__boundDepthTexture!==Me){if(Me!==null&&be.has(Me)&&(v.width!==Me.image.width||v.height!==Me.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");De.setupDepthRenderbuffer(v)}}const Ae=v.texture;(Ae.isData3DTexture||Ae.isDataArrayTexture||Ae.isCompressedArrayTexture)&&(le=!0);const Re=be.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(Re[L])?I=Re[L][F]:I=Re[L],Q=!0):v.samples>0&&De.useMultisampledRTT(v)===!1?I=be.get(v).__webglMultisampledFramebuffer:Array.isArray(Re)?I=Re[F]:I=Re,k.copy(v.viewport),H.copy(v.scissor),K=v.scissorTest}else k.copy(Ze).multiplyScalar(se).floor(),H.copy(nt).multiplyScalar(se).floor(),K=it;if(F!==0&&(I=Wc),me.bindFramebuffer(A.FRAMEBUFFER,I)&&O&&me.drawBuffers(v,I),me.viewport(k),me.scissor(H),me.setScissorTest(K),Q){const ue=be.get(v.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+L,ue.__webglTexture,F)}else if(le){const ue=L;for(let Ae=0;Ae<v.textures.length;Ae++){const Re=be.get(v.textures[Ae]);A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0+Ae,Re.__webglTexture,F,ue)}}else if(v!==null&&F!==0){const ue=be.get(v.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,ue.__webglTexture,F)}D=-1},this.readRenderTargetPixels=function(v,L,F,O,I,Q,le,pe=0){if(!(v&&v.isWebGLRenderTarget)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ue=be.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&le!==void 0&&(ue=ue[le]),ue){me.bindFramebuffer(A.FRAMEBUFFER,ue);try{const Ae=v.textures[pe],Re=Ae.format,Me=Ae.type;if(!rt.textureFormatReadable(Re)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!rt.textureTypeReadable(Me)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=v.width-O&&F>=0&&F<=v.height-I&&(v.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+pe),A.readPixels(L,F,O,I,Ce.convert(Re),Ce.convert(Me),Q))}finally{const Ae=M!==null?be.get(M).__webglFramebuffer:null;me.bindFramebuffer(A.FRAMEBUFFER,Ae)}}},this.readRenderTargetPixelsAsync=async function(v,L,F,O,I,Q,le,pe=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ue=be.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&le!==void 0&&(ue=ue[le]),ue)if(L>=0&&L<=v.width-O&&F>=0&&F<=v.height-I){me.bindFramebuffer(A.FRAMEBUFFER,ue);const Ae=v.textures[pe],Re=Ae.format,Me=Ae.type;if(!rt.textureFormatReadable(Re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!rt.textureTypeReadable(Me))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ge=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,Ge),A.bufferData(A.PIXEL_PACK_BUFFER,Q.byteLength,A.STREAM_READ),v.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+pe),A.readPixels(L,F,O,I,Ce.convert(Re),Ce.convert(Me),0);const Je=M!==null?be.get(M).__webglFramebuffer:null;me.bindFramebuffer(A.FRAMEBUFFER,Je);const ht=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await Ol(A,ht,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,Ge),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,Q),A.deleteBuffer(Ge),A.deleteSync(ht),Q}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,L=null,F=0){const O=Math.pow(2,-F),I=Math.floor(v.image.width*O),Q=Math.floor(v.image.height*O),le=L!==null?L.x:0,pe=L!==null?L.y:0;De.setTexture2D(v,0),A.copyTexSubImage2D(A.TEXTURE_2D,F,0,0,le,pe,I,Q),me.unbindTexture()};const Xc=A.createFramebuffer(),qc=A.createFramebuffer();this.copyTextureToTexture=function(v,L,F=null,O=null,I=0,Q=null){Q===null&&(I!==0?(ki("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Q=I,I=0):Q=0);let le,pe,ue,Ae,Re,Me,Ge,Je,ht;const ut=v.isCompressedTexture?v.mipmaps[Q]:v.image;if(F!==null)le=F.max.x-F.min.x,pe=F.max.y-F.min.y,ue=F.isBox3?F.max.z-F.min.z:1,Ae=F.min.x,Re=F.min.y,Me=F.isBox3?F.min.z:0;else{const Ot=Math.pow(2,-I);le=Math.floor(ut.width*Ot),pe=Math.floor(ut.height*Ot),v.isDataArrayTexture?ue=ut.depth:v.isData3DTexture?ue=Math.floor(ut.depth*Ot):ue=1,Ae=0,Re=0,Me=0}O!==null?(Ge=O.x,Je=O.y,ht=O.z):(Ge=0,Je=0,ht=0);const tt=Ce.convert(L.format),Ee=Ce.convert(L.type);let ct;L.isData3DTexture?(De.setTexture3D(L,0),ct=A.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(De.setTexture2DArray(L,0),ct=A.TEXTURE_2D_ARRAY):(De.setTexture2D(L,0),ct=A.TEXTURE_2D),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,L.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,L.unpackAlignment);const qe=A.getParameter(A.UNPACK_ROW_LENGTH),Dt=A.getParameter(A.UNPACK_IMAGE_HEIGHT),qn=A.getParameter(A.UNPACK_SKIP_PIXELS),Lt=A.getParameter(A.UNPACK_SKIP_ROWS),Si=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,ut.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,ut.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Ae),A.pixelStorei(A.UNPACK_SKIP_ROWS,Re),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Me);const lt=v.isDataArrayTexture||v.isData3DTexture,wt=L.isDataArrayTexture||L.isData3DTexture;if(v.isDepthTexture){const Ot=be.get(v),yt=be.get(L),Rt=be.get(Ot.__renderTarget),Gr=be.get(yt.__renderTarget);me.bindFramebuffer(A.READ_FRAMEBUFFER,Rt.__webglFramebuffer),me.bindFramebuffer(A.DRAW_FRAMEBUFFER,Gr.__webglFramebuffer);for(let Dn=0;Dn<ue;Dn++)lt&&(A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,be.get(v).__webglTexture,I,Me+Dn),A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,be.get(L).__webglTexture,Q,ht+Dn)),A.blitFramebuffer(Ae,Re,le,pe,Ge,Je,le,pe,A.DEPTH_BUFFER_BIT,A.NEAREST);me.bindFramebuffer(A.READ_FRAMEBUFFER,null),me.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else if(I!==0||v.isRenderTargetTexture||be.has(v)){const Ot=be.get(v),yt=be.get(L);me.bindFramebuffer(A.READ_FRAMEBUFFER,Xc),me.bindFramebuffer(A.DRAW_FRAMEBUFFER,qc);for(let Rt=0;Rt<ue;Rt++)lt?A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Ot.__webglTexture,I,Me+Rt):A.framebufferTexture2D(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Ot.__webglTexture,I),wt?A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,yt.__webglTexture,Q,ht+Rt):A.framebufferTexture2D(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,yt.__webglTexture,Q),I!==0?A.blitFramebuffer(Ae,Re,le,pe,Ge,Je,le,pe,A.COLOR_BUFFER_BIT,A.NEAREST):wt?A.copyTexSubImage3D(ct,Q,Ge,Je,ht+Rt,Ae,Re,le,pe):A.copyTexSubImage2D(ct,Q,Ge,Je,Ae,Re,le,pe);me.bindFramebuffer(A.READ_FRAMEBUFFER,null),me.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else wt?v.isDataTexture||v.isData3DTexture?A.texSubImage3D(ct,Q,Ge,Je,ht,le,pe,ue,tt,Ee,ut.data):L.isCompressedArrayTexture?A.compressedTexSubImage3D(ct,Q,Ge,Je,ht,le,pe,ue,tt,ut.data):A.texSubImage3D(ct,Q,Ge,Je,ht,le,pe,ue,tt,Ee,ut):v.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,Q,Ge,Je,le,pe,tt,Ee,ut.data):v.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,Q,Ge,Je,ut.width,ut.height,tt,ut.data):A.texSubImage2D(A.TEXTURE_2D,Q,Ge,Je,le,pe,tt,Ee,ut);A.pixelStorei(A.UNPACK_ROW_LENGTH,qe),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Dt),A.pixelStorei(A.UNPACK_SKIP_PIXELS,qn),A.pixelStorei(A.UNPACK_SKIP_ROWS,Lt),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Si),Q===0&&L.generateMipmaps&&A.generateMipmap(ct),me.unbindTexture()},this.initRenderTarget=function(v){be.get(v).__webglFramebuffer===void 0&&De.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?De.setTextureCube(v,0):v.isData3DTexture?De.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?De.setTexture2DArray(v,0):De.setTexture2D(v,0),me.unbindTexture()},this.resetState=function(){z=0,b=0,M=null,me.reset(),R.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return tn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ye._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ye._getUnpackColorSpace()}}class Km{constructor(e){this.source=e;const t=e.texture.data.slice(),n=new Uint32Array(t.buffer);this.output=new Uint32Array(n.length),this.asset={...e,texture:{...e.texture,data:new Uint8Array(this.output.buffer)}},this.rows=new Int32Array(e.depth*e.layers);const{width:r,depth:s,columns:a,texture:o}=e;this.rowOffsets=Uint32Array.from(this.rows,(l,c)=>{const h=Math.floor(c/s),u=c%s;return(Math.floor(h/a)*s+u)*o.width+h%a*r}),this.sourceRows=Array.from(this.rowOffsets,l=>n.subarray(l,l+r)),this.update(0,1)}source;asset;rows;cos=1;sin=0;angle=NaN;spacing=NaN;output;rowOffsets;sourceRows;update(e,t){const n=Math.round(e*2)%720/2;if(this.angle===n&&this.spacing===t)return!1;this.angle=n,this.spacing=t,this.cos=Math.cos(n*Math.PI/180),this.sin=Math.sin(n*Math.PI/180);const{depth:r,layers:s,size:a}=this.source,o=a[1]/Math.max(1,r-1),l=this.source.spacing*t,c=(r-1)/2,h=(s-1)/2;this.output.fill(0);for(let u=0;u<s;u++)for(let d=0;d<r;d++){const p=(d-c)*o,x=(u-h)*l,_=Math.round(c+(this.cos*p-this.sin*x)/o),m=Math.round(h+(this.sin*p+this.cos*x)/l),f=u*r+d;if(_<0||_>=r||m<0||m>=s){this.rows[f]=-1;continue}this.rows[f]=m*r+_,this.output.set(this.sourceRows[this.rows[f]],this.rowOffsets[f])}return!0}}function $m(i,e,t,n){if(i>n)return 2*n+(Math.atan2(e,i-n)+Math.PI/2)*t;if(i<-n){const r=Math.atan2(e,i+n);return 4*n+Math.PI*t+((r<0?r+2*Math.PI:r)-Math.PI/2)*t}return e<0?i+n:3*n-i+Math.PI*t}class Zm{constructor(e,t){this.source=e,this.tread=t,this.asset={...e,texture:{...e.texture,data:e.texture.data.slice()}}}source;tread;asset;pixels=[];depth=0;height=0;repeat=0;phase;prepare(e,t){this.depth=e,this.height=t;const n=t/2,r=Math.max(0,e/2-n),s=4*r+2*Math.PI*n;this.repeat=s/Math.max(1,Math.round(s/(e*.8))),this.pixels=[];const{layers:a,width:o,depth:l,columns:c,texture:h}=this.source;for(let u=0;u<a;u++){const d=u%c*o,p=Math.floor(u/c)*l,x=((u+.5)/a-.5)*t;for(let _=0;_<l;_++){const m=((_+.5)/l-.5)*e;if(Math.hypot(Math.max(0,Math.abs(m)-r),x)<n*.77)continue;const f=$m(m,x,n,r);for(let T=0;T<o;T++){const y=((p+_)*h.width+d+T)*4;h.data[y+3]&&this.pixels.push({offset:y,column:Math.floor((T+.5)*this.tread.width/o),distance:f})}}}}update(e,t,n){const r=this.source.texture.data,s=this.asset.texture.data;if(e===void 0)return this.phase===void 0?!1:(this.phase=void 0,s.set(r),!0);const a=this.depth!==t||this.height!==n;a&&(this.prepare(t,n),s.set(r));const o=Math.max(1,Math.round(this.tread.height*.8)),l=Math.round(e/this.repeat*o)%o;if(!a&&this.phase===l)return!1;this.phase=l;const c=l/o*this.repeat;for(const{offset:h,column:u,distance:d}of this.pixels){const p=((d+c)%this.repeat+this.repeat)%this.repeat/this.repeat,_=(Math.floor((.1+.8*p)*this.tread.height)*this.tread.width+u)*4,m=this.tread.data[_+3]>=128?.77:0;for(let f=0;f<3;f++)s[h+f]=Math.round(r[h+f]*(1-m)+this.tread.data[_+f]*m)}return!0}}const Oc=new WeakMap;function T0(i){return Oc.get(i)}function Bc(i,e){const t=new Nr(i.data,i.width,i.height);return t.colorSpace=Nt,t.magFilter=e,t.minFilter=e,t.needsUpdate=!0,t}function jm(i){const e=new Vt;e.setAttribute("position",new bt(i.positions,3)),e.setAttribute("normal",new bt(i.normals,3)),e.setAttribute("uv",new bt(i.uvs,2)),e.setIndex(new bt(i.indices,1));const t=Bc(i.texture,At);return new St(e,new Wn({map:t}))}function Ia(i,e){const t=new Li,n=new Hi(i.size[0],i.size[1]);n.rotateX(-Math.PI/2);const r=Bc(i.texture,At);for(let s=0;s<i.layers;s++){const a=s===0?r:r.clone(),o=s%i.columns*i.width,l=Math.floor(s/i.columns)*i.depth;a.offset.set((o+.5)/i.texture.width,(l+.5)/i.texture.height),a.repeat.set((i.width-1)/i.texture.width,(i.depth-1)/i.texture.height);const c=new Wn({map:a,alphaTest:.5,alphaToCoverage:!0,side:en}),h=new St(n,c);let u=i.width,d=i.depth,p=-1,x=-1;if(!e)for(let _=0;_<i.depth;_++)for(let m=0;m<i.width;m++)i.texture.data[((l+_)*i.texture.width+o+m)*4+3]!==0&&(u=Math.min(u,m),p=Math.max(p,m),d=Math.min(d,_),x=Math.max(x,_));Oc.set(h,{stack:i,layer:s,roll:e,bounds:e?[0,0,1,1]:p<0?null:[Math.max(0,u-1)/(i.width-1),Math.max(0,d-1)/(i.depth-1),Math.min(i.width-1,p+1)/(i.width-1),Math.min(i.depth-1,x+1)/(i.depth-1)]}),h.position.y=(s+.5)*i.spacing-i.pivot[2],t.add(h)}return t}function zc(i){for(const e of i.children)e.material.map.needsUpdate=!0}function A0(i){const e=new Km(i),t=Ia(e.asset,e);return{object:t,setRoll(n,r){e.update(n,r)&&zc(t)}}}function w0(i,e){const t=new Zm(i,e),n=Ia(t.asset);return{object:n,setTravel(r,s,a){t.update(r,s,a)&&zc(n)}}}function R0(i,e,t){const n=e?Pt:At;i.traverse(r=>{if(!(r instanceof St)||!(r.material instanceof Wn||r.material instanceof pa))return;const{material:s}=r,a=s.map;a&&a.magFilter!==n&&(a.magFilter=n,a.minFilter=n,a.needsUpdate=!0),s.alphaToCoverage!==t&&(s.alphaToCoverage=t,s.needsUpdate=!0)})}function C0(i){return i.target==="mesh"?jm(i):Ia(i)}function P0(i,e){i.traverse(t=>{if(!(t instanceof St))return;const n=t.material;if(e&&!(n instanceof Wn)||!e&&!(n instanceof pa))return;const r={map:n.map,side:n.side,alphaTest:n.alphaTest,alphaToCoverage:n.alphaToCoverage};t.material=e?new pa(r):new Wn(r),n.dispose()})}function D0(i){const e=new Set,t=new Set,n=new Set;i.traverse(r=>{if(r instanceof St){e.add(r.geometry);for(const s of Array.isArray(r.material)?r.material:[r.material])t.add(s),s.map instanceof gt&&n.add(s.map)}}),e.forEach(r=>r.dispose()),t.forEach(r=>r.dispose()),n.forEach(r=>r.dispose())}export{s0 as $,_0 as A,bt as B,Ne as C,en as D,Xe as E,f0 as F,Li as G,pi as H,th as I,m0 as J,x0 as K,At as L,He as M,En as N,Dc as O,et as P,_i as Q,xa as R,Ra as S,e0 as T,o0 as U,U as V,E0 as W,So as X,dt as Y,p0 as Z,M0 as _,h0 as a,Lh as a0,Cn as a1,Tc as a2,Wn as a3,Vt as a4,a0 as a5,St as a6,Dh as a7,Ac as a8,c0 as a9,Bn as aA,Ie as aB,T0 as aC,Ke as aD,pa as aE,l0 as aa,Ft as ab,Ec as ac,d0 as ad,Th as ae,yc as af,gt as ag,Lr as ah,Dr as ai,Or as aj,Ye as ak,wn as al,Fr as am,gn as an,S0 as ao,D0 as ap,R0 as aq,P0 as ar,b0 as as,w0 as at,A0 as au,Zt as av,y0 as aw,Jm as ax,Qm as ay,Ur as az,i0 as b,zt as c,Tr as d,r0 as e,Nt as f,Pt as g,El as h,Yi as i,Hr as j,kn as k,dn as l,Ns as m,Fs as n,ua as o,C0 as p,Rn as q,Ih as r,g0 as s,Nr as t,Rl as u,n0 as v,t0 as w,Wi as x,v0 as y,u0 as z};
|