tinker-gomoku 0.1.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.
@@ -0,0 +1,3830 @@
1
+ var Vu=Object.defineProperty;var Wu=(i,t,e)=>t in i?Vu(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var ur=(i,t,e)=>Wu(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.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 o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function e(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=e(r);fetch(r.href,s)}})();function Rl(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Bs={exports:{}},zs={exports:{}};(function(i,t){t=function(e){return e===void 0},i.exports=t})(zs,zs.exports);var nr=zs.exports;(function(i,t){var e=nr;t=function(n,r,s){return e(s)&&(s=r,r=void 0),!e(r)&&n<r?r:n>s?s:n},i.exports=t})(Bs,Bs.exports);var Xu=Bs.exports;const Hn=Rl(Xu);class qu{constructor(){ur(this,"enabled",!0);ur(this,"loadStarted",!1);ur(this,"turnAudio",new Audio("sound/turn.mp3"));this.turnAudio.preload="auto",this.turnAudio.volume=.7}setEnabled(t){this.enabled=t}unlock(){this.loadStarted||(this.loadStarted=!0,this.turnAudio.load())}play(){this.enabled&&(this.turnAudio.currentTime=0,this.turnAudio.play().catch(()=>{}))}}const ge=15,kr=ge*ge,qe=0,Ke=1,Cl=2,Pl=[[1,0],[0,1],[1,1],[1,-1]];function yn(i,t){return i*ge+t}function Gr(i,t){return i>=0&&i<ge&&t>=0&&t<ge}function Da(){return new Uint8Array(kr)}function Ua(i){return i===Ke?Cl:Ke}function Yu(i){for(const t of i)if(t===qe)return!1;return!0}function Zu(i,t,e){const n=i[yn(t,e)];if(n===qe)return null;for(const[r,s]of Pl){const o=[[t,e]];for(let a=1;a<ge;a++){const c=t+r*a,l=e+s*a;if(!Gr(c,l)||i[yn(c,l)]!==n)break;o.push([c,l])}for(let a=1;a<ge;a++){const c=t-r*a,l=e-s*a;if(!Gr(c,l)||i[yn(c,l)]!==n)break;o.unshift([c,l])}if(o.length>=5)return o}return null}const Sn={five:1e7,"4-open":2e5,"4-closed":12e3,"3-open":9e3,"3-closed":800,"2-open":600,"2-closed":90,"1-open":40,"1-closed":6};function Hs(i,t,e,n){let r=0;for(const[s,o]of Pl){let a=1,c=0;for(const u of[1,-1])for(let h=1;h<5;h++){const f=t+s*h*u,d=e+o*h*u;if(!Gr(f,d))break;const g=i[yn(f,d)];if(g===n){a++;continue}g===qe&&c++;break}if(a>=5){r+=Sn.five;continue}const l=c>=2?"open":c===1?"closed":"blocked";r+=Sn[`${a}-${l}`]??0}return r}function Ll(i,t,e){const n=new Uint8Array(kr),r=[];let s=!1;for(let o=0;o<kr;o++){if(i[o]===qe)continue;s=!0;const a=Math.floor(o/ge),c=o%ge;for(let l=-2;l<=2;l++)for(let u=-2;u<=2;u++){const h=a+l,f=c+u;if(!Gr(h,f))continue;const d=yn(h,f);if(i[d]!==qe||n[d])continue;n[d]=1;const g=Hs(i,h,f,e),v=Hs(i,h,f,Ua(e));r.push({row:h,column:f,cell:d,attack:g,defense:v,weight:g+v*.95})}}if(!s){const o=Math.floor(ge/2);return[{row:o,column:o,cell:yn(o,o),attack:0,defense:0,weight:0}]}return r.sort((o,a)=>a.weight-o.weight),r.slice(0,t)}function vc(i,t){let e=0;for(let n=0;n<kr;n++){const r=i[n];if(r===qe)continue;const s=Math.floor(n/ge),o=n%ge;i[n]=qe;const a=Hs(i,s,o,r);i[n]=r,e+=r===t?a:-a*1.15}return e}function ks(i,t,e,n,r,s){if(e===0)return vc(i,t);const o=s?t:Ua(t),a=Ll(i,6,o);if(a.length===0)return vc(i,t);if(s){let l=-1/0;for(const u of a){i[u.cell]=o;const h=u.attack>=Sn.five?9e6+e*1e3:ks(i,t,e-1,n,r,!1);if(i[u.cell]=qe,l=Math.max(l,h),n=Math.max(n,l),r<=n)break}return l}let c=1/0;for(const l of a){i[l.cell]=o;const u=l.attack>=Sn.five?-9e6-e*1e3:ks(i,t,e-1,n,r,!0);if(i[l.cell]=qe,c=Math.min(c,u),r=Math.min(r,c),r<=n)break}return c}function Ju(i,t,e){const n=Ll(i,e==="easy"?14:12,t);if(n.length===0)return null;const r=n.find(u=>u.attack>=Sn.five);if(r)return r;const s=n.find(u=>u.defense>=Sn.five);if(s)return s;if(e==="easy"){const u=n.map(h=>({move:h,score:h.attack*.9+h.defense*.45+Math.random()*900}));return u.sort((h,f)=>f.score-h.score),u[0].move}if(e==="normal"){const u=n.map(h=>({move:h,score:h.attack*1.05+h.defense+Math.random()*60}));return u.sort((h,f)=>f.score-h.score),u[0].move}const o=n.find(u=>u.attack>=Sn["4-open"]);if(o)return o;const a=n.find(u=>u.defense>=Sn["4-open"]);if(a)return a;let c=n[0],l=-1/0;for(const u of n.slice(0,8)){i[u.cell]=t;const h=ks(i,t,2,-1/0,1/0,!1)+u.weight*.02;i[u.cell]=qe,h>l&&(l=h,c=u)}return c}function Ku(i="pvp",t="normal"){return{board:Da(),mode:i,difficulty:t,phase:"menu",turn:Ke,cursor:{row:7,column:7},sound:!0}}function ju(i,t,e){document.querySelectorAll("[data-mode]").forEach(h=>{h.addEventListener("click",()=>{e.setMode(h.dataset.mode)})}),document.querySelectorAll("[data-difficulty]").forEach(h=>{h.addEventListener("click",()=>{e.setDifficulty(h.dataset.difficulty)})}),t.startButton.addEventListener("click",e.startMatch),t.againButton.addEventListener("click",e.startMatch),t.menuButton.addEventListener("click",e.openMenu),t.resultMenuButton.addEventListener("click",e.openMenu),t.soundButton.addEventListener("click",e.toggleSound),document.querySelectorAll("[data-direction]").forEach(h=>{h.addEventListener("click",()=>{const f=h.dataset.direction;f==="up"&&e.moveCursor(-1,0),f==="down"&&e.moveCursor(1,0),f==="left"&&e.moveCursor(0,-1),f==="right"&&e.moveCursor(0,1)})}),document.querySelector('[data-action="place"]').addEventListener("click",()=>{const h=e.getCursor();e.placeStone(h.row,h.column)}),window.addEventListener("keydown",h=>{if(h.key==="Escape"){e.getPhase()!=="menu"&&e.openMenu();return}if(h.key.toLowerCase()==="r"&&e.getPhase()!=="menu"){e.startMatch();return}if(e.getPhase()!=="play"&&e.getPhase()!=="thinking")return;const d={ArrowUp:[-1,0],w:[-1,0],ArrowDown:[1,0],s:[1,0],ArrowLeft:[0,-1],a:[0,-1],ArrowRight:[0,1],d:[0,1]}[h.key];if(d)h.preventDefault(),e.moveCursor(d[0],d[1]);else if(h.key===" "||h.key==="Enter"){h.preventDefault();const g=e.getCursor();e.placeStone(g.row,g.column)}});let n=null,r=0,s=0,o=null;const a=h=>{if(h.pointerId===n){n=null,o=null,i.renderer.domElement.style.cursor="grab";try{i.renderer.domElement.releasePointerCapture(h.pointerId)}catch{}}};i.renderer.domElement.addEventListener("pointerdown",h=>{e.unlockAudio();const f=i.pickCell(h.clientX,h.clientY);if(h.button===0&&f&&e.getPhase()==="play"){e.setCursor(f.row,f.column),e.placeStone(f.row,f.column);return}(h.button===0||h.button===2)&&(n=h.pointerId,r=h.clientX,s=h.clientY,o=h.button===2?"pan":"rotate",i.renderer.domElement.style.cursor="grabbing",i.renderer.domElement.setPointerCapture(h.pointerId),h.preventDefault())}),i.renderer.domElement.addEventListener("pointermove",h=>{if(h.pointerId===n){const d=h.clientX-r,g=h.clientY-s;o==="pan"?i.pan(d,g):i.orbit(d,g),r=h.clientX,s=h.clientY,h.preventDefault();return}if(e.getPhase()!=="play")return;const f=i.pickCell(h.clientX,h.clientY);f&&e.setCursor(f.row,f.column)}),i.renderer.domElement.addEventListener("pointerup",a),i.renderer.domElement.addEventListener("pointercancel",a),i.renderer.domElement.addEventListener("contextmenu",h=>h.preventDefault());let c=0,l=!1;return{pollGamepad:()=>{var b,T;const h=(b=navigator.getGamepads)==null?void 0:b.call(navigator)[0];if(!h||e.getPhase()==="menu"||e.getPhase()==="over")return;const f=.55,d=h.axes[0]??0,g=h.axes[1]??0,v=Math.abs(d)>Math.abs(g)?d>f?[0,1]:d<-f?[0,-1]:null:g>f?[1,0]:g<-f?[-1,0]:null,m=performance.now();v&&m-c>180&&(e.moveCursor(v[0],v[1]),c=m);const p=!!((T=h.buttons[0])!=null&&T.pressed);if(p&&!l){const S=e.getCursor();e.placeStone(S.row,S.column)}l=p}}}/**
2
+ * @license
3
+ * Copyright 2010-2024 Three.js Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */const Ia="172",$u=0,xc=1,Qu=2,Dl=1,Ul=2,an=3,bn=0,Ce=1,Ze=2,En=0,Mi=1,Mc=2,Sc=3,yc=4,th=5,On=100,eh=101,nh=102,ih=103,rh=104,sh=200,oh=201,ah=202,ch=203,Gs=204,Vs=205,lh=206,uh=207,hh=208,fh=209,dh=210,ph=211,mh=212,gh=213,_h=214,Ws=0,Xs=1,qs=2,Ti=3,Ys=4,Zs=5,Js=6,Ks=7,Il=0,vh=1,xh=2,Tn=0,Mh=1,Sh=2,yh=3,Nl=4,Eh=5,Th=6,Ah=7,Fl=300,Ai=301,bi=302,js=303,$s=304,Jr=306,wi=1e3,kn=1001,Qs=1002,Xe=1003,bh=1004,hr=1005,Je=1006,ss=1007,Gn=1008,fn=1009,Ol=1010,Bl=1011,Ki=1012,Na=1013,qn=1014,ln=1015,ir=1016,Fa=1017,Oa=1018,Ri=1020,zl=35902,Hl=1021,kl=1022,We=1023,Gl=1024,Vl=1025,Si=1026,Ci=1027,Wl=1028,Ba=1029,Xl=1030,za=1031,Ha=1033,Nr=33776,Fr=33777,Or=33778,Br=33779,to=35840,eo=35841,no=35842,io=35843,ro=36196,so=37492,oo=37496,ao=37808,co=37809,lo=37810,uo=37811,ho=37812,fo=37813,po=37814,mo=37815,go=37816,_o=37817,vo=37818,xo=37819,Mo=37820,So=37821,zr=36492,yo=36494,Eo=36495,ql=36283,To=36284,Ao=36285,bo=36286,wh=3200,Rh=3201,Yl=0,Ch=1,Mn="",we="srgb",Pi="srgb-linear",Vr="linear",te="srgb",ti=7680,Ec=519,Ph=512,Lh=513,Dh=514,Zl=515,Uh=516,Ih=517,Nh=518,Fh=519,Tc=35044,Ac="300 es",un=2e3,Wr=2001;class Di{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const r=this._listeners[t];if(r!==void 0){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const r=n.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,t);t.target=null}}}const Me=["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 bc=1234567;const Wi=Math.PI/180,ji=180/Math.PI;function Kn(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Me[i&255]+Me[i>>8&255]+Me[i>>16&255]+Me[i>>24&255]+"-"+Me[t&255]+Me[t>>8&255]+"-"+Me[t>>16&15|64]+Me[t>>24&255]+"-"+Me[e&63|128]+Me[e>>8&255]+"-"+Me[e>>16&255]+Me[e>>24&255]+Me[n&255]+Me[n>>8&255]+Me[n>>16&255]+Me[n>>24&255]).toLowerCase()}function Gt(i,t,e){return Math.max(t,Math.min(e,i))}function ka(i,t){return(i%t+t)%t}function Oh(i,t,e,n,r){return n+(i-t)*(r-n)/(e-t)}function Bh(i,t,e){return i!==t?(e-i)/(t-i):0}function Xi(i,t,e){return(1-e)*i+e*t}function zh(i,t,e,n){return Xi(i,t,1-Math.exp(-e*n))}function Hh(i,t=1){return t-Math.abs(ka(i,t*2)-t)}function kh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Gh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Vh(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Wh(i,t){return i+Math.random()*(t-i)}function Xh(i){return i*(.5-Math.random())}function qh(i){i!==void 0&&(bc=i);let t=bc+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Yh(i){return i*Wi}function Zh(i){return i*ji}function Jh(i){return(i&i-1)===0&&i!==0}function Kh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function jh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function $h(i,t,e,n,r){const s=Math.cos,o=Math.sin,a=s(e/2),c=o(e/2),l=s((t+n)/2),u=o((t+n)/2),h=s((t-n)/2),f=o((t-n)/2),d=s((n-t)/2),g=o((n-t)/2);switch(r){case"XYX":i.set(a*u,c*h,c*f,a*l);break;case"YZY":i.set(c*f,a*u,c*h,a*l);break;case"ZXZ":i.set(c*h,c*f,a*u,a*l);break;case"XZX":i.set(a*u,c*g,c*d,a*l);break;case"YXY":i.set(c*d,a*u,c*g,a*l);break;case"ZYZ":i.set(c*g,c*d,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function pi(i,t){switch(t.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 Te(i,t){switch(t.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 Qh={DEG2RAD:Wi,RAD2DEG:ji,generateUUID:Kn,clamp:Gt,euclideanModulo:ka,mapLinear:Oh,inverseLerp:Bh,lerp:Xi,damp:zh,pingpong:Hh,smoothstep:kh,smootherstep:Gh,randInt:Vh,randFloat:Wh,randFloatSpread:Xh,seededRandom:qh,degToRad:Yh,radToDeg:Zh,isPowerOfTwo:Jh,ceilPowerOfTwo:Kh,floorPowerOfTwo:jh,setQuaternionFromProperEuler:$h,normalize:Te,denormalize:pi};class at{constructor(t=0,e=0){at.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(n,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Gt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*n-o*r+t.x,this.y=s*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class zt{constructor(t,e,n,r,s,o,a,c,l){zt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,o,a,c,l)}set(t,e,n,r,s,o,a,c,l){const u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=s,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],d=n[5],g=n[8],v=r[0],m=r[3],p=r[6],b=r[1],T=r[4],S=r[7],L=r[2],C=r[5],R=r[8];return s[0]=o*v+a*b+c*L,s[3]=o*m+a*T+c*C,s[6]=o*p+a*S+c*R,s[1]=l*v+u*b+h*L,s[4]=l*m+u*T+h*C,s[7]=l*p+u*S+h*R,s[2]=f*v+d*b+g*L,s[5]=f*m+d*T+g*C,s[8]=f*p+d*S+g*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-n*s*u+n*a*c+r*s*l-r*o*c}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=u*o-a*l,f=a*c-u*s,d=l*s-o*c,g=e*h+n*f+r*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return t[0]=h*v,t[1]=(r*l-u*n)*v,t[2]=(a*n-r*o)*v,t[3]=f*v,t[4]=(u*e-r*c)*v,t[5]=(r*s-a*e)*v,t[6]=d*v,t[7]=(n*c-l*e)*v,t[8]=(o*e-n*s)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,s,o,a){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*o+l*a)+o+t,-r*l,r*c,-r*(-l*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(os.makeScale(t,e)),this}rotate(t){return this.premultiply(os.makeRotation(-t)),this}translate(t,e){return this.premultiply(os.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<9;r++)if(e[r]!==n[r])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const os=new zt;function Jl(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function $i(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function tf(){const i=$i("canvas");return i.style.display="block",i}const wc={};function mi(i){i in wc||(wc[i]=!0,console.warn(i))}function ef(i,t,e){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}function nf(i){const t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function rf(i){const t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const Rc=new zt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Cc=new zt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function sf(){const i={enabled:!0,workingColorSpace:Pi,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===te&&(r.r=hn(r.r),r.g=hn(r.g),r.b=hn(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===te&&(r.r=yi(r.r),r.g=yi(r.g),r.b=yi(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Mn?Vr:this.spaces[r].transfer},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,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Pi]:{primaries:t,whitePoint:n,transfer:Vr,toXYZ:Rc,fromXYZ:Cc,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:we},outputColorSpaceConfig:{drawingBufferColorSpace:we}},[we]:{primaries:t,whitePoint:n,transfer:te,toXYZ:Rc,fromXYZ:Cc,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:we}}}),i}const Kt=sf();function hn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function yi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ei;class of{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ei===void 0&&(ei=$i("canvas")),ei.width=t.width,ei.height=t.height;const n=ei.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=ei}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=$i("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const r=n.getImageData(0,0,t.width,t.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=hn(s[o]/255)*255;return n.putImageData(r,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(hn(e[n]/255)*255):e[n]=hn(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let af=0;class Kl{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:af++}),this.uuid=Kn(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(as(r[o].image)):s.push(as(r[o]))}else s=as(r);n.url=s}return e||(t.images[this.uuid]=n),n}}function as(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?of.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let cf=0;class ye extends Di{constructor(t=ye.DEFAULT_IMAGE,e=ye.DEFAULT_MAPPING,n=kn,r=kn,s=Je,o=Gn,a=We,c=fn,l=ye.DEFAULT_ANISOTROPY,u=Mn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:cf++}),this.uuid=Kn(),this.name="",this.source=new Kl(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new at(0,0),this.repeat=new at(1,1),this.center=new at(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new zt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Fl)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case wi:t.x=t.x-Math.floor(t.x);break;case kn:t.x=t.x<0?0:1;break;case Qs:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case wi:t.y=t.y-Math.floor(t.y);break;case kn:t.y=t.y<0?0:1;break;case Qs:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ye.DEFAULT_IMAGE=null;ye.DEFAULT_MAPPING=Fl;ye.DEFAULT_ANISOTROPY=1;class ee{constructor(t=0,e=0,n=0,r=1){ee.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,s;const c=t.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],g=c[9],v=c[2],m=c[6],p=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(g+m)<.1&&Math.abs(l+d+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const T=(l+1)/2,S=(d+1)/2,L=(p+1)/2,C=(u+f)/4,R=(h+v)/4,D=(g+m)/4;return T>S&&T>L?T<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(T),r=C/n,s=R/n):S>L?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=C/r,s=D/r):L<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(L),n=R/s,r=D/s),this.set(n,r,s,e),this}let b=Math.sqrt((m-g)*(m-g)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(h-v)/b,this.z=(f-u)/b,this.w=Math.acos((l+d+p-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this.w=Gt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this.w=Gt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(n,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class lf extends Di{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new ee(0,0,t,e),this.scissorTest=!1,this.viewport=new ee(0,0,t,e);const r={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Je,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new ye(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;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}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=t,this.textures[r].image.height=e,this.textures[r].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,r=t.textures.length;n<r;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const e=Object.assign({},t.texture.image);return this.texture.source=new Kl(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Yn extends lf{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class jl extends ye{constructor(t=null,e=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=Xe,this.minFilter=Xe,this.wrapR=kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class uf extends ye{constructor(t=null,e=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=Xe,this.minFilter=Xe,this.wrapR=kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class rr{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,s,o,a){let c=n[r+0],l=n[r+1],u=n[r+2],h=n[r+3];const f=s[o+0],d=s[o+1],g=s[o+2],v=s[o+3];if(a===0){t[e+0]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h;return}if(a===1){t[e+0]=f,t[e+1]=d,t[e+2]=g,t[e+3]=v;return}if(h!==v||c!==f||l!==d||u!==g){let m=1-a;const p=c*f+l*d+u*g+h*v,b=p>=0?1:-1,T=1-p*p;if(T>Number.EPSILON){const L=Math.sqrt(T),C=Math.atan2(L,p*b);m=Math.sin(m*C)/L,a=Math.sin(a*C)/L}const S=a*b;if(c=c*m+f*S,l=l*m+d*S,u=u*m+g*S,h=h*m+v*S,m===1-a){const L=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=L,l*=L,u*=L,h*=L}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,r,s,o){const a=n[r],c=n[r+1],l=n[r+2],u=n[r+3],h=s[o],f=s[o+1],d=s[o+2],g=s[o+3];return t[e]=a*g+u*h+c*d-l*f,t[e+1]=c*g+u*f+l*h-a*d,t[e+2]=l*g+u*d+a*f-c*h,t[e+3]=u*g-a*h-c*f-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,r=t._y,s=t._z,o=t._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(r/2),h=a(s/2),f=c(n/2),d=c(r/2),g=c(s/2);switch(o){case"XYZ":this._x=f*u*h+l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h-f*d*g;break;case"YXZ":this._x=f*u*h+l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h+f*d*g;break;case"ZXY":this._x=f*u*h-l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h-f*d*g;break;case"ZYX":this._x=f*u*h-l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h+f*d*g;break;case"YZX":this._x=f*u*h+l*d*g,this._y=l*d*h+f*u*g,this._z=l*u*g-f*d*h,this._w=l*u*h-f*d*g;break;case"XZY":this._x=f*u*h-l*d*g,this._y=l*d*h-f*u*g,this._z=l*u*g+f*d*h,this._w=l*u*h+f*d*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],s=e[8],o=e[1],a=e[5],c=e[9],l=e[2],u=e[6],h=e[10],f=n+a+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(o-r)*d}else if(n>a&&n>h){const d=2*Math.sqrt(1+n-a-h);this._w=(u-c)/d,this._x=.25*d,this._y=(r+o)/d,this._z=(s+l)/d}else if(a>h){const d=2*Math.sqrt(1+a-n-h);this._w=(s-l)/d,this._x=(r+o)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-n-a);this._w=(o-r)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Gt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const r=Math.min(1,e/n);return this.slerp(t,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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,s=t._z,o=t._w,a=e._x,c=e._y,l=e._z,u=e._w;return this._x=n*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-n*l,this._z=s*u+o*l+n*c-r*a,this._w=o*u-n*a-r*c-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,r=this._y,s=this._z,o=this._w;let a=o*t._w+n*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const d=1-e;return this._w=d*o+e*this._w,this._x=d*n+e*this._x,this._y=d*r+e*this._y,this._z=d*s+e*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-e)*u)/l,f=Math.sin(e*u)/l;return this._w=o*h+this._w*f,this._x=n*h+this._x*f,this._y=r*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{constructor(t=0,e=0,n=0){P.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Pc.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Pc.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*r,this.y=s[1]*e+s[4]*n+s[7]*r,this.z=s[2]*e+s[5]*n+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=t.elements,o=1/(s[3]*e+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*e+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,s=t.x,o=t.y,a=t.z,c=t.w,l=2*(o*r-a*n),u=2*(a*e-s*r),h=2*(s*n-o*e);return this.x=e+c*l+o*h-a*u,this.y=n+c*u+a*l-s*h,this.z=r+c*h+s*u-o*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*r,this.y=s[1]*e+s[5]*n+s[9]*r,this.z=s[2]*e+s[6]*n+s[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Gt(this.x,t.x,e.x),this.y=Gt(this.y,t.y,e.y),this.z=Gt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Gt(this.x,t,e),this.y=Gt(this.y,t,e),this.z=Gt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Gt(n,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,s=t.z,o=e.x,a=e.y,c=e.z;return this.x=r*c-s*a,this.y=s*o-n*c,this.z=n*a-r*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return cs.copy(this).projectOnVector(t),this.sub(cs)}reflect(t){return this.sub(cs.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Gt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const cs=new P,Pc=new rr;class sr{constructor(t=new P(1/0,1/0,1/0),e=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(He.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(He.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=He.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,He):He.fromBufferAttribute(s,o),He.applyMatrix4(t.matrixWorld),this.expandByPoint(He);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),fr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),fr.copy(n.boundingBox)),fr.applyMatrix4(t.matrixWorld),this.union(fr)}const r=t.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,He),He.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Bi),dr.subVectors(this.max,Bi),ni.subVectors(t.a,Bi),ii.subVectors(t.b,Bi),ri.subVectors(t.c,Bi),dn.subVectors(ii,ni),pn.subVectors(ri,ii),Pn.subVectors(ni,ri);let e=[0,-dn.z,dn.y,0,-pn.z,pn.y,0,-Pn.z,Pn.y,dn.z,0,-dn.x,pn.z,0,-pn.x,Pn.z,0,-Pn.x,-dn.y,dn.x,0,-pn.y,pn.x,0,-Pn.y,Pn.x,0];return!ls(e,ni,ii,ri,dr)||(e=[1,0,0,0,1,0,0,0,1],!ls(e,ni,ii,ri,dr))?!1:(pr.crossVectors(dn,pn),e=[pr.x,pr.y,pr.z],ls(e,ni,ii,ri,dr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,He).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(He).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(en[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),en[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),en[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),en[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),en[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),en[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),en[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),en[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(en),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const en=[new P,new P,new P,new P,new P,new P,new P,new P],He=new P,fr=new sr,ni=new P,ii=new P,ri=new P,dn=new P,pn=new P,Pn=new P,Bi=new P,dr=new P,pr=new P,Ln=new P;function ls(i,t,e,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){Ln.fromArray(i,s);const a=r.x*Math.abs(Ln.x)+r.y*Math.abs(Ln.y)+r.z*Math.abs(Ln.z),c=t.dot(Ln),l=e.dot(Ln),u=n.dot(Ln);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}const hf=new sr,zi=new P,us=new P;class Ga{constructor(t=new P,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):hf.setFromPoints(t).getCenter(n);let r=0;for(let s=0,o=t.length;s<o;s++)r=Math.max(r,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(r),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;zi.subVectors(t,this.center);const e=zi.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),r=(n-this.radius)*.5;this.center.addScaledVector(zi,r/n),this.radius+=r}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(us.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(zi.copy(t.center).add(us)),this.expandByPoint(zi.copy(t.center).sub(us))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const nn=new P,hs=new P,mr=new P,mn=new P,fs=new P,gr=new P,ds=new P;class $l{constructor(t=new P,e=new P(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,nn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=nn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(nn.copy(this.origin).addScaledVector(this.direction,e),nn.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){hs.copy(t).add(e).multiplyScalar(.5),mr.copy(e).sub(t).normalize(),mn.copy(this.origin).sub(hs);const s=t.distanceTo(e)*.5,o=-this.direction.dot(mr),a=mn.dot(this.direction),c=-mn.dot(mr),l=mn.lengthSq(),u=Math.abs(1-o*o);let h,f,d,g;if(u>0)if(h=o*c-a,f=o*a-c,g=s*u,h>=0)if(f>=-g)if(f<=g){const v=1/u;h*=v,f*=v,d=h*(h+o*f+2*a)+f*(o*h+f+2*c)+l}else f=s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f<=-g?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=g?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(hs).addScaledVector(mr,f),d}intersectSphere(t,e){nn.subVectors(t.center,this.origin);const n=nn.dot(this.direction),r=nn.dot(nn)-n*n,s=t.radius*t.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,s,o,a,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(t.min.x-f.x)*l,r=(t.max.x-f.x)*l):(n=(t.max.x-f.x)*l,r=(t.min.x-f.x)*l),u>=0?(s=(t.min.y-f.y)*u,o=(t.max.y-f.y)*u):(s=(t.max.y-f.y)*u,o=(t.min.y-f.y)*u),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(t.min.z-f.z)*h,c=(t.max.z-f.z)*h):(a=(t.max.z-f.z)*h,c=(t.min.z-f.z)*h),n>c||a>r)||((a>n||n!==n)&&(n=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,e)}intersectsBox(t){return this.intersectBox(t,nn)!==null}intersectTriangle(t,e,n,r,s){fs.subVectors(e,t),gr.subVectors(n,t),ds.crossVectors(fs,gr);let o=this.direction.dot(ds),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;mn.subVectors(this.origin,t);const c=a*this.direction.dot(gr.crossVectors(mn,gr));if(c<0)return null;const l=a*this.direction.dot(fs.cross(mn));if(l<0||c+l>o)return null;const u=-a*mn.dot(ds);return u<0?null:this.at(u/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class re{constructor(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m){re.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m)}set(t,e,n,r,s,o,a,c,l,u,h,f,d,g,v,m){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=r,p[1]=s,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=u,p[10]=h,p[14]=f,p[3]=d,p[7]=g,p[11]=v,p[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 re().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/si.setFromMatrixColumn(t,0).length(),s=1/si.setFromMatrixColumn(t,1).length(),o=1/si.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,r=t.y,s=t.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){const f=o*u,d=o*h,g=a*u,v=a*h;e[0]=c*u,e[4]=-c*h,e[8]=l,e[1]=d+g*l,e[5]=f-v*l,e[9]=-a*c,e[2]=v-f*l,e[6]=g+d*l,e[10]=o*c}else if(t.order==="YXZ"){const f=c*u,d=c*h,g=l*u,v=l*h;e[0]=f+v*a,e[4]=g*a-d,e[8]=o*l,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=d*a-g,e[6]=v+f*a,e[10]=o*c}else if(t.order==="ZXY"){const f=c*u,d=c*h,g=l*u,v=l*h;e[0]=f-v*a,e[4]=-o*h,e[8]=g+d*a,e[1]=d+g*a,e[5]=o*u,e[9]=v-f*a,e[2]=-o*l,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){const f=o*u,d=o*h,g=a*u,v=a*h;e[0]=c*u,e[4]=g*l-d,e[8]=f*l+v,e[1]=c*h,e[5]=v*l+f,e[9]=d*l-g,e[2]=-l,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){const f=o*c,d=o*l,g=a*c,v=a*l;e[0]=c*u,e[4]=v-f*h,e[8]=g*h+d,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=d*h+g,e[10]=f-v*h}else if(t.order==="XZY"){const f=o*c,d=o*l,g=a*c,v=a*l;e[0]=c*u,e[4]=-h,e[8]=l*u,e[1]=f*h+v,e[5]=o*u,e[9]=d*h-g,e[2]=g*h-d,e[6]=a*u,e[10]=v*h+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ff,t,df)}lookAt(t,e,n){const r=this.elements;return De.subVectors(t,e),De.lengthSq()===0&&(De.z=1),De.normalize(),gn.crossVectors(n,De),gn.lengthSq()===0&&(Math.abs(n.z)===1?De.x+=1e-4:De.z+=1e-4,De.normalize(),gn.crossVectors(n,De)),gn.normalize(),_r.crossVectors(De,gn),r[0]=gn.x,r[4]=_r.x,r[8]=De.x,r[1]=gn.y,r[5]=_r.y,r[9]=De.y,r[2]=gn.z,r[6]=_r.z,r[10]=De.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],d=n[13],g=n[2],v=n[6],m=n[10],p=n[14],b=n[3],T=n[7],S=n[11],L=n[15],C=r[0],R=r[4],D=r[8],y=r[12],M=r[1],w=r[5],H=r[9],O=r[13],V=r[2],X=r[6],G=r[10],K=r[14],k=r[3],ct=r[7],pt=r[11],Mt=r[15];return s[0]=o*C+a*M+c*V+l*k,s[4]=o*R+a*w+c*X+l*ct,s[8]=o*D+a*H+c*G+l*pt,s[12]=o*y+a*O+c*K+l*Mt,s[1]=u*C+h*M+f*V+d*k,s[5]=u*R+h*w+f*X+d*ct,s[9]=u*D+h*H+f*G+d*pt,s[13]=u*y+h*O+f*K+d*Mt,s[2]=g*C+v*M+m*V+p*k,s[6]=g*R+v*w+m*X+p*ct,s[10]=g*D+v*H+m*G+p*pt,s[14]=g*y+v*O+m*K+p*Mt,s[3]=b*C+T*M+S*V+L*k,s[7]=b*R+T*w+S*X+L*ct,s[11]=b*D+T*H+S*G+L*pt,s[15]=b*y+T*O+S*K+L*Mt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],s=t[12],o=t[1],a=t[5],c=t[9],l=t[13],u=t[2],h=t[6],f=t[10],d=t[14],g=t[3],v=t[7],m=t[11],p=t[15];return g*(+s*c*h-r*l*h-s*a*f+n*l*f+r*a*d-n*c*d)+v*(+e*c*d-e*l*f+s*o*f-r*o*d+r*l*u-s*c*u)+m*(+e*l*h-e*a*d-s*o*h+n*o*d+s*a*u-n*l*u)+p*(-r*a*u-e*c*h+e*a*f+r*o*h-n*o*f+n*c*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=t[9],f=t[10],d=t[11],g=t[12],v=t[13],m=t[14],p=t[15],b=h*m*l-v*f*l+v*c*d-a*m*d-h*c*p+a*f*p,T=g*f*l-u*m*l-g*c*d+o*m*d+u*c*p-o*f*p,S=u*v*l-g*h*l+g*a*d-o*v*d-u*a*p+o*h*p,L=g*h*c-u*v*c-g*a*f+o*v*f+u*a*m-o*h*m,C=e*b+n*T+r*S+s*L;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/C;return t[0]=b*R,t[1]=(v*f*s-h*m*s-v*r*d+n*m*d+h*r*p-n*f*p)*R,t[2]=(a*m*s-v*c*s+v*r*l-n*m*l-a*r*p+n*c*p)*R,t[3]=(h*c*s-a*f*s-h*r*l+n*f*l+a*r*d-n*c*d)*R,t[4]=T*R,t[5]=(u*m*s-g*f*s+g*r*d-e*m*d-u*r*p+e*f*p)*R,t[6]=(g*c*s-o*m*s-g*r*l+e*m*l+o*r*p-e*c*p)*R,t[7]=(o*f*s-u*c*s+u*r*l-e*f*l-o*r*d+e*c*d)*R,t[8]=S*R,t[9]=(g*h*s-u*v*s-g*n*d+e*v*d+u*n*p-e*h*p)*R,t[10]=(o*v*s-g*a*s+g*n*l-e*v*l-o*n*p+e*a*p)*R,t[11]=(u*a*s-o*h*s-u*n*l+e*h*l+o*n*d-e*a*d)*R,t[12]=L*R,t[13]=(u*v*r-g*h*r+g*n*f-e*v*f-u*n*m+e*h*m)*R,t[14]=(g*a*r-o*v*r-g*n*c+e*v*c+o*n*m-e*a*m)*R,t[15]=(o*h*r-u*a*r+u*n*c-e*h*c-o*n*f+e*a*f)*R,this}scale(t){const e=this.elements,n=t.x,r=t.y,s=t.z;return e[0]*=n,e[4]*=r,e[8]*=s,e[1]*=n,e[5]*=r,e[9]*=s,e[2]*=n,e[6]*=r,e[10]*=s,e[3]*=n,e[7]*=r,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),s=1-n,o=t.x,a=t.y,c=t.z,l=s*o,u=s*a;return this.set(l*o+n,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+n,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,s,o){return this.set(1,n,s,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,s=e._x,o=e._y,a=e._z,c=e._w,l=s+s,u=o+o,h=a+a,f=s*l,d=s*u,g=s*h,v=o*u,m=o*h,p=a*h,b=c*l,T=c*u,S=c*h,L=n.x,C=n.y,R=n.z;return r[0]=(1-(v+p))*L,r[1]=(d+S)*L,r[2]=(g-T)*L,r[3]=0,r[4]=(d-S)*C,r[5]=(1-(f+p))*C,r[6]=(m+b)*C,r[7]=0,r[8]=(g+T)*R,r[9]=(m-b)*R,r[10]=(1-(f+v))*R,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let s=si.set(r[0],r[1],r[2]).length();const o=si.set(r[4],r[5],r[6]).length(),a=si.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],ke.copy(this);const l=1/s,u=1/o,h=1/a;return ke.elements[0]*=l,ke.elements[1]*=l,ke.elements[2]*=l,ke.elements[4]*=u,ke.elements[5]*=u,ke.elements[6]*=u,ke.elements[8]*=h,ke.elements[9]*=h,ke.elements[10]*=h,e.setFromRotationMatrix(ke),n.x=s,n.y=o,n.z=a,this}makePerspective(t,e,n,r,s,o,a=un){const c=this.elements,l=2*s/(e-t),u=2*s/(n-r),h=(e+t)/(e-t),f=(n+r)/(n-r);let d,g;if(a===un)d=-(o+s)/(o-s),g=-2*o*s/(o-s);else if(a===Wr)d=-o/(o-s),g=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,r,s,o,a=un){const c=this.elements,l=1/(e-t),u=1/(n-r),h=1/(o-s),f=(e+t)*l,d=(n+r)*u;let g,v;if(a===un)g=(o+s)*h,v=-2*h;else if(a===Wr)g=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-d,c[2]=0,c[6]=0,c[10]=v,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<16;r++)if(e[r]!==n[r])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const si=new P,ke=new re,ff=new P(0,0,0),df=new P(1,1,1),gn=new P,_r=new P,De=new P,Lc=new re,Dc=new rr;class $e{constructor(t=0,e=0,n=0,r=$e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],h=r[2],f=r[6],d=r[10];switch(e){case"XYZ":this._y=Math.asin(Gt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Gt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Gt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Gt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Gt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Lc.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Lc,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Dc.setFromEuler(this),this.setFromQuaternion(Dc,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}$e.DEFAULT_ORDER="XYZ";class Va{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let pf=0;const Uc=new P,oi=new rr,rn=new re,vr=new P,Hi=new P,mf=new P,gf=new rr,Ic=new P(1,0,0),Nc=new P(0,1,0),Fc=new P(0,0,1),Oc={type:"added"},_f={type:"removed"},ai={type:"childadded",child:null},ps={type:"childremoved",child:null};class ve extends Di{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:pf++}),this.uuid=Kn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ve.DEFAULT_UP.clone();const t=new P,e=new $e,n=new rr,r=new P(1,1,1);function s(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new re},normalMatrix:{value:new zt}}),this.matrix=new re,this.matrixWorld=new re,this.matrixAutoUpdate=ve.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ve.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Va,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return oi.setFromAxisAngle(t,e),this.quaternion.multiply(oi),this}rotateOnWorldAxis(t,e){return oi.setFromAxisAngle(t,e),this.quaternion.premultiply(oi),this}rotateX(t){return this.rotateOnAxis(Ic,t)}rotateY(t){return this.rotateOnAxis(Nc,t)}rotateZ(t){return this.rotateOnAxis(Fc,t)}translateOnAxis(t,e){return Uc.copy(t).applyQuaternion(this.quaternion),this.position.add(Uc.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ic,t)}translateY(t){return this.translateOnAxis(Nc,t)}translateZ(t){return this.translateOnAxis(Fc,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(rn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?vr.copy(t):vr.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Hi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?rn.lookAt(Hi,vr,this.up):rn.lookAt(vr,Hi,this.up),this.quaternion.setFromRotationMatrix(rn),r&&(rn.extractRotation(r.matrixWorld),oi.setFromRotationMatrix(rn),this.quaternion.premultiply(oi.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Oc),ai.child=t,this.dispatchEvent(ai),ai.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(_f),ps.child=t,this.dispatchEvent(ps),ps.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),rn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),rn.multiply(t.parent.matrixWorld)),t.applyMatrix4(rn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Oc),ai.child=t,this.dispatchEvent(ai),ai.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,r=this.children.length;n<r;n++){const o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hi,t,mf),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hi,gf,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!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)),e===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,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.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const h=c[l];s(t.shapes,h)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(t.materials,this.material[c]));r.material=a}else r.material=s(t.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];r.animations.push(s(t.animations,c))}}if(e){const a=o(t.geometries),c=o(t.materials),l=o(t.textures),u=o(t.images),h=o(t.shapes),f=o(t.skeletons),d=o(t.animations),g=o(t.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),g.length>0&&(n.nodes=g)}return n.object=r,n;function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const r=t.children[n];this.add(r.clone())}return this}}ve.DEFAULT_UP=new P(0,1,0);ve.DEFAULT_MATRIX_AUTO_UPDATE=!0;ve.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ge=new P,sn=new P,ms=new P,on=new P,ci=new P,li=new P,Bc=new P,gs=new P,_s=new P,vs=new P,xs=new ee,Ms=new ee,Ss=new ee;class Ve{constructor(t=new P,e=new P,n=new P){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,r){r.subVectors(n,e),Ge.subVectors(t,e),r.cross(Ge);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(t,e,n,r,s){Ge.subVectors(r,e),sn.subVectors(n,e),ms.subVectors(t,e);const o=Ge.dot(Ge),a=Ge.dot(sn),c=Ge.dot(ms),l=sn.dot(sn),u=sn.dot(ms),h=o*l-a*a;if(h===0)return s.set(0,0,0),null;const f=1/h,d=(l*c-a*u)*f,g=(o*u-a*c)*f;return s.set(1-d-g,g,d)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,on)===null?!1:on.x>=0&&on.y>=0&&on.x+on.y<=1}static getInterpolation(t,e,n,r,s,o,a,c){return this.getBarycoord(t,e,n,r,on)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,on.x),c.addScaledVector(o,on.y),c.addScaledVector(a,on.z),c)}static getInterpolatedAttribute(t,e,n,r,s,o){return xs.setScalar(0),Ms.setScalar(0),Ss.setScalar(0),xs.fromBufferAttribute(t,e),Ms.fromBufferAttribute(t,n),Ss.fromBufferAttribute(t,r),o.setScalar(0),o.addScaledVector(xs,s.x),o.addScaledVector(Ms,s.y),o.addScaledVector(Ss,s.z),o}static isFrontFacing(t,e,n,r){return Ge.subVectors(n,e),sn.subVectors(t,e),Ge.cross(sn).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ge.subVectors(this.c,this.b),sn.subVectors(this.a,this.b),Ge.cross(sn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ve.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ve.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,r,s){return Ve.getInterpolation(t,this.a,this.b,this.c,e,n,r,s)}containsPoint(t){return Ve.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ve.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,s=this.c;let o,a;ci.subVectors(r,n),li.subVectors(s,n),gs.subVectors(t,n);const c=ci.dot(gs),l=li.dot(gs);if(c<=0&&l<=0)return e.copy(n);_s.subVectors(t,r);const u=ci.dot(_s),h=li.dot(_s);if(u>=0&&h<=u)return e.copy(r);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),e.copy(n).addScaledVector(ci,o);vs.subVectors(t,s);const d=ci.dot(vs),g=li.dot(vs);if(g>=0&&d<=g)return e.copy(s);const v=d*l-c*g;if(v<=0&&l>=0&&g<=0)return a=l/(l-g),e.copy(n).addScaledVector(li,a);const m=u*g-d*h;if(m<=0&&h-u>=0&&d-g>=0)return Bc.subVectors(s,r),a=(h-u)/(h-u+(d-g)),e.copy(r).addScaledVector(Bc,a);const p=1/(m+v+f);return o=v*p,a=f*p,e.copy(n).addScaledVector(ci,o).addScaledVector(li,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Ql={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},_n={h:0,s:0,l:0},xr={h:0,s:0,l:0};function ys(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class Wt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const r=t;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=we){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,r=Kt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Kt.toWorkingColorSpace(this,r),this}setHSL(t,e,n,r=Kt.workingColorSpace){if(t=ka(t,1),e=Gt(e,0,1),n=Gt(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,o=2*n-s;this.r=ys(o,s,t+1/3),this.g=ys(o,s,t),this.b=ys(o,s,t-1/3)}return Kt.toWorkingColorSpace(this,r),this}setStyle(t,e=we){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=we){const n=Ql[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=hn(t.r),this.g=hn(t.g),this.b=hn(t.b),this}copyLinearToSRGB(t){return this.r=yi(t.r),this.g=yi(t.g),this.b=yi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=we){return Kt.fromWorkingColorSpace(Se.copy(this),t),Math.round(Gt(Se.r*255,0,255))*65536+Math.round(Gt(Se.g*255,0,255))*256+Math.round(Gt(Se.b*255,0,255))}getHexString(t=we){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kt.workingColorSpace){Kt.fromWorkingColorSpace(Se.copy(this),e);const n=Se.r,r=Se.g,s=Se.b,o=Math.max(n,r,s),a=Math.min(n,r,s);let c,l;const u=(a+o)/2;if(a===o)c=0,l=0;else{const h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(r-s)/h+(r<s?6:0);break;case r:c=(s-n)/h+2;break;case s:c=(n-r)/h+4;break}c/=6}return t.h=c,t.s=l,t.l=u,t}getRGB(t,e=Kt.workingColorSpace){return Kt.fromWorkingColorSpace(Se.copy(this),e),t.r=Se.r,t.g=Se.g,t.b=Se.b,t}getStyle(t=we){Kt.fromWorkingColorSpace(Se.copy(this),t);const e=Se.r,n=Se.g,r=Se.b;return t!==we?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(t,e,n){return this.getHSL(_n),this.setHSL(_n.h+t,_n.s+e,_n.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(_n),t.getHSL(xr);const n=Xi(_n.h,xr.h,e),r=Xi(_n.s,xr.s,e),s=Xi(_n.l,xr.l,e);return this.setHSL(n,r,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,r=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*r,this.g=s[1]*e+s[4]*n+s[7]*r,this.b=s[2]*e+s[5]*n+s[8]*r,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Se=new Wt;Wt.NAMES=Ql;let vf=0;class or extends Di{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:vf++}),this.uuid=Kn(),this.name="",this.type="Material",this.blending=Mi,this.side=bn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Gs,this.blendDst=Vs,this.blendEquation=On,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Wt(0,0,0),this.blendAlpha=0,this.depthFunc=Ti,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ec,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ti,this.stencilZFail=ti,this.stencilZPass=ti,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const r=this[e];if(r===void 0){console.warn(`THREE.Material: '${e}' 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[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Mi&&(n.blending=this.blending),this.side!==bn&&(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!==Gs&&(n.blendSrc=this.blendSrc),this.blendDst!==Vs&&(n.blendDst=this.blendDst),this.blendEquation!==On&&(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!==Ti&&(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!==Ec&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ti&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ti&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ti&&(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 o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(e){const s=r(t.textures),o=r(t.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const r=e.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Vn extends or{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Wt(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 $e,this.combine=Il,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const he=new P,Mr=new at;class je{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Tc,this.updateRanges=[],this.gpuType=ln,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[t+r]=e.array[n+r];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Mr.fromBufferAttribute(this,e),Mr.applyMatrix3(t),this.setXY(e,Mr.x,Mr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyMatrix3(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyMatrix4(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyNormalMatrix(t),this.setXYZ(e,he.x,he.y,he.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.transformDirection(t),this.setXYZ(e,he.x,he.y,he.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=pi(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Te(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=pi(e,this.array)),e}setX(t,e){return this.normalized&&(e=Te(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=pi(e,this.array)),e}setY(t,e){return this.normalized&&(e=Te(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=pi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Te(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=pi(e,this.array)),e}setW(t,e){return this.normalized&&(e=Te(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Te(e,this.array),n=Te(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,r){return t*=this.itemSize,this.normalized&&(e=Te(e,this.array),n=Te(n,this.array),r=Te(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t*=this.itemSize,this.normalized&&(e=Te(e,this.array),n=Te(n,this.array),r=Te(r,this.array),s=Te(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Tc&&(t.usage=this.usage),t}}class tu extends je{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class eu extends je{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class ne extends je{constructor(t,e,n){super(new Float32Array(t),e,n)}}let xf=0;const Oe=new re,Es=new ve,ui=new P,Ue=new sr,ki=new sr,pe=new P;class Pe extends Di{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:xf++}),this.uuid=Kn(),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(t){return Array.isArray(t)?this.index=new(Jl(t)?eu:tu)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new zt().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Oe.makeRotationFromQuaternion(t),this.applyMatrix4(Oe),this}rotateX(t){return Oe.makeRotationX(t),this.applyMatrix4(Oe),this}rotateY(t){return Oe.makeRotationY(t),this.applyMatrix4(Oe),this}rotateZ(t){return Oe.makeRotationZ(t),this.applyMatrix4(Oe),this}translate(t,e,n){return Oe.makeTranslation(t,e,n),this.applyMatrix4(Oe),this}scale(t,e,n){return Oe.makeScale(t,e,n),this.applyMatrix4(Oe),this}lookAt(t){return Es.lookAt(t),Es.updateMatrix(),this.applyMatrix4(Es.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ui).negate(),this.translate(ui.x,ui.y,ui.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let r=0,s=t.length;r<s;r++){const o=t[r];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new ne(n,3))}else{const n=Math.min(t.length,e.count);for(let r=0;r<n;r++){const s=t[r];e.setXYZ(r,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new sr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const s=e[n];Ue.setFromBufferAttribute(s),this.morphTargetsRelative?(pe.addVectors(this.boundingBox.min,Ue.min),this.boundingBox.expandByPoint(pe),pe.addVectors(this.boundingBox.max,Ue.max),this.boundingBox.expandByPoint(pe)):(this.boundingBox.expandByPoint(Ue.min),this.boundingBox.expandByPoint(Ue.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 Ga);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(t){const n=this.boundingSphere.center;if(Ue.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];ki.setFromBufferAttribute(a),this.morphTargetsRelative?(pe.addVectors(Ue.min,ki.min),Ue.expandByPoint(pe),pe.addVectors(Ue.max,ki.max),Ue.expandByPoint(pe)):(Ue.expandByPoint(ki.min),Ue.expandByPoint(ki.max))}Ue.getCenter(n);let r=0;for(let s=0,o=t.count;s<o;s++)pe.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(pe));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)pe.fromBufferAttribute(a,l),c&&(ui.fromBufferAttribute(t,l),pe.add(ui)),r=Math.max(r,n.distanceToSquared(pe))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,r=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new je(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let D=0;D<n.count;D++)a[D]=new P,c[D]=new P;const l=new P,u=new P,h=new P,f=new at,d=new at,g=new at,v=new P,m=new P;function p(D,y,M){l.fromBufferAttribute(n,D),u.fromBufferAttribute(n,y),h.fromBufferAttribute(n,M),f.fromBufferAttribute(s,D),d.fromBufferAttribute(s,y),g.fromBufferAttribute(s,M),u.sub(l),h.sub(l),d.sub(f),g.sub(f);const w=1/(d.x*g.y-g.x*d.y);isFinite(w)&&(v.copy(u).multiplyScalar(g.y).addScaledVector(h,-d.y).multiplyScalar(w),m.copy(h).multiplyScalar(d.x).addScaledVector(u,-g.x).multiplyScalar(w),a[D].add(v),a[y].add(v),a[M].add(v),c[D].add(m),c[y].add(m),c[M].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let D=0,y=b.length;D<y;++D){const M=b[D],w=M.start,H=M.count;for(let O=w,V=w+H;O<V;O+=3)p(t.getX(O+0),t.getX(O+1),t.getX(O+2))}const T=new P,S=new P,L=new P,C=new P;function R(D){L.fromBufferAttribute(r,D),C.copy(L);const y=a[D];T.copy(y),T.sub(L.multiplyScalar(L.dot(y))).normalize(),S.crossVectors(C,y);const w=S.dot(c[D])<0?-1:1;o.setXYZW(D,T.x,T.y,T.z,w)}for(let D=0,y=b.length;D<y;++D){const M=b[D],w=M.start,H=M.count;for(let O=w,V=w+H;O<V;O+=3)R(t.getX(O+0)),R(t.getX(O+1)),R(t.getX(O+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new je(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);const r=new P,s=new P,o=new P,a=new P,c=new P,l=new P,u=new P,h=new P;if(t)for(let f=0,d=t.count;f<d;f+=3){const g=t.getX(f+0),v=t.getX(f+1),m=t.getX(f+2);r.fromBufferAttribute(e,g),s.fromBufferAttribute(e,v),o.fromBufferAttribute(e,m),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,m),a.add(u),c.add(u),l.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let f=0,d=e.count;f<d;f+=3)r.fromBufferAttribute(e,f+0),s.fromBufferAttribute(e,f+1),o.fromBufferAttribute(e,f+2),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)pe.fromBufferAttribute(t,e),pe.normalize(),t.setXYZ(e,pe.x,pe.y,pe.z)}toNonIndexed(){function t(a,c){const l=a.array,u=a.itemSize,h=a.normalized,f=new l.constructor(c.length*u);let d=0,g=0;for(let v=0,m=c.length;v<m;v++){a.isInterleavedBufferAttribute?d=c[v]*a.data.stride+a.offset:d=c[v]*u;for(let p=0;p<u;p++)f[g++]=l[d++]}return new je(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Pe,n=this.index.array,r=this.attributes;for(const a in r){const c=r[a],l=t(c,n);e.setAttribute(a,l)}const s=this.morphAttributes;for(const a in s){const c=[],l=s[a];for(let u=0,h=l.length;u<h;u++){const f=l[u],d=t(f,n);c.push(d)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h<f;h++){const d=l[h];u.push(d.toJSON(t.data))}u.length>0&&(r[c]=u,s=!0)}s&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const r=t.attributes;for(const l in r){const u=r[l];this.setAttribute(l,u.clone(e))}const s=t.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,d=h.length;f<d;f++)u.push(h[f].clone(e));this.morphAttributes[l]=u}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let l=0,u=o.length;l<u;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const zc=new re,Dn=new $l,Sr=new Ga,Hc=new P,yr=new P,Er=new P,Tr=new P,Ts=new P,Ar=new P,kc=new P,br=new P;class le extends ve{constructor(t=new Pe,e=new Vn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(r,t);const a=this.morphTargetInfluences;if(s&&a){Ar.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=a[c],h=s[c];u!==0&&(Ts.fromBufferAttribute(h,t),o?Ar.addScaledVector(Ts,u):Ar.addScaledVector(Ts.sub(e),u))}e.add(Ar)}return e}raycast(t,e){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Sr.copy(n.boundingSphere),Sr.applyMatrix4(s),Dn.copy(t.ray).recast(t.near),!(Sr.containsPoint(Dn.origin)===!1&&(Dn.intersectSphere(Sr,Hc)===null||Dn.origin.distanceToSquared(Hc)>(t.far-t.near)**2))&&(zc.copy(s).invert(),Dn.copy(t.ray).applyMatrix4(zc),!(n.boundingBox!==null&&Dn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Dn)))}_computeIntersections(t,e,n){let r;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,v=f.length;g<v;g++){const m=f[g],p=o[m.materialIndex],b=Math.max(m.start,d.start),T=Math.min(a.count,Math.min(m.start+m.count,d.start+d.count));for(let S=b,L=T;S<L;S+=3){const C=a.getX(S),R=a.getX(S+1),D=a.getX(S+2);r=wr(this,p,t,n,l,u,h,C,R,D),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const g=Math.max(0,d.start),v=Math.min(a.count,d.start+d.count);for(let m=g,p=v;m<p;m+=3){const b=a.getX(m),T=a.getX(m+1),S=a.getX(m+2);r=wr(this,o,t,n,l,u,h,b,T,S),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,v=f.length;g<v;g++){const m=f[g],p=o[m.materialIndex],b=Math.max(m.start,d.start),T=Math.min(c.count,Math.min(m.start+m.count,d.start+d.count));for(let S=b,L=T;S<L;S+=3){const C=S,R=S+1,D=S+2;r=wr(this,p,t,n,l,u,h,C,R,D),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const g=Math.max(0,d.start),v=Math.min(c.count,d.start+d.count);for(let m=g,p=v;m<p;m+=3){const b=m,T=m+1,S=m+2;r=wr(this,o,t,n,l,u,h,b,T,S),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}}}function Mf(i,t,e,n,r,s,o,a){let c;if(t.side===Ce?c=n.intersectTriangle(o,s,r,!0,a):c=n.intersectTriangle(r,s,o,t.side===bn,a),c===null)return null;br.copy(a),br.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(br);return l<e.near||l>e.far?null:{distance:l,point:br.clone(),object:i}}function wr(i,t,e,n,r,s,o,a,c,l){i.getVertexPosition(a,yr),i.getVertexPosition(c,Er),i.getVertexPosition(l,Tr);const u=Mf(i,t,e,n,yr,Er,Tr,kc);if(u){const h=new P;Ve.getBarycoord(kc,yr,Er,Tr,h),r&&(u.uv=Ve.getInterpolatedAttribute(r,a,c,l,h,new at)),s&&(u.uv1=Ve.getInterpolatedAttribute(s,a,c,l,h,new at)),o&&(u.normal=Ve.getInterpolatedAttribute(o,a,c,l,h,new P),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const f={a,b:c,c:l,normal:new P,materialIndex:0};Ve.getNormal(yr,Er,Tr,f.normal),u.face=f,u.barycoord=h}return u}class Zn extends Pe{constructor(t=1,e=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const c=[],l=[],u=[],h=[];let f=0,d=0;g("z","y","x",-1,-1,n,e,t,o,s,0),g("z","y","x",1,-1,n,e,-t,o,s,1),g("x","z","y",1,1,t,n,e,r,o,2),g("x","z","y",1,-1,t,n,-e,r,o,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new ne(l,3)),this.setAttribute("normal",new ne(u,3)),this.setAttribute("uv",new ne(h,2));function g(v,m,p,b,T,S,L,C,R,D,y){const M=S/R,w=L/D,H=S/2,O=L/2,V=C/2,X=R+1,G=D+1;let K=0,k=0;const ct=new P;for(let pt=0;pt<G;pt++){const Mt=pt*w-O;for(let Ft=0;Ft<X;Ft++){const Zt=Ft*M-H;ct[v]=Zt*b,ct[m]=Mt*T,ct[p]=V,l.push(ct.x,ct.y,ct.z),ct[v]=0,ct[m]=0,ct[p]=C>0?1:-1,u.push(ct.x,ct.y,ct.z),h.push(Ft/R),h.push(1-pt/D),K+=1}}for(let pt=0;pt<D;pt++)for(let Mt=0;Mt<R;Mt++){const Ft=f+Mt+X*pt,Zt=f+Mt+X*(pt+1),Y=f+(Mt+1)+X*(pt+1),st=f+(Mt+1)+X*pt;c.push(Ft,Zt,st),c.push(Zt,Y,st),k+=6}a.addGroup(d,k,y),d+=k,f+=K}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Li(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const r=i[e][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=r.clone():Array.isArray(r)?t[e][n]=r.slice():t[e][n]=r}}return t}function Ae(i){const t={};for(let e=0;e<i.length;e++){const n=Li(i[e]);for(const r in n)t[r]=n[r]}return t}function Sf(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function nu(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Kt.workingColorSpace}const yf={clone:Li,merge:Ae};var Ef=`void main() {
6
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
+ }`,Tf=`void main() {
8
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
+ }`;class wn extends or{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ef,this.fragmentShader=Tf,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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Li(t.uniforms),this.uniformsGroups=Sf(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const r in this.uniforms){const o=this.uniforms[r].value;o&&o.isTexture?e.uniforms[r]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[r]={type:"m4",value:o.toArray()}:e.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class iu extends ve{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new re,this.projectionMatrix=new re,this.projectionMatrixInverse=new re,this.coordinateSystem=un}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const vn=new P,Gc=new at,Vc=new at;class Ie extends iu{constructor(t=50,e=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=ji*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Wi*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return ji*2*Math.atan(Math.tan(Wi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){vn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(vn.x,vn.y).multiplyScalar(-t/vn.z),vn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(vn.x,vn.y).multiplyScalar(-t/vn.z)}getViewSize(t,e){return this.getViewBounds(t,Gc,Vc),e.subVectors(Vc,Gc)}setViewOffset(t,e,n,r,s,o){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Wi*.5*this.fov)/this.zoom,n=2*e,r=this.aspect*n,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,e-=o.offsetY*n/l,r*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const hi=-90,fi=1;class Af extends ve{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ie(hi,fi,t,e);r.layers=this.layers,this.add(r);const s=new Ie(hi,fi,t,e);s.layers=this.layers,this.add(s);const o=new Ie(hi,fi,t,e);o.layers=this.layers,this.add(o);const a=new Ie(hi,fi,t,e);a.layers=this.layers,this.add(a);const c=new Ie(hi,fi,t,e);c.layers=this.layers,this.add(c);const l=new Ie(hi,fi,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,r,s,o,a,c]=e;for(const l of e)this.remove(l);if(t===un)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),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===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),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,c,l,u]=this.children,h=t.getRenderTarget(),f=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,r),t.render(e,s),t.setRenderTarget(n,1,r),t.render(e,o),t.setRenderTarget(n,2,r),t.render(e,a),t.setRenderTarget(n,3,r),t.render(e,c),t.setRenderTarget(n,4,r),t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,r),t.render(e,u),t.setRenderTarget(h,f,d),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class ru extends ye{constructor(t,e,n,r,s,o,a,c,l,u){t=t!==void 0?t:[],e=e!==void 0?e:Ai,super(t,e,n,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class bf extends Yn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},r=[n,n,n,n,n,n];this.texture=new ru(r,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Je}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
10
+
11
+ varying vec3 vWorldDirection;
12
+
13
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
14
+
15
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
16
+
17
+ }
18
+
19
+ void main() {
20
+
21
+ vWorldDirection = transformDirection( position, modelMatrix );
22
+
23
+ #include <begin_vertex>
24
+ #include <project_vertex>
25
+
26
+ }
27
+ `,fragmentShader:`
28
+
29
+ uniform sampler2D tEquirect;
30
+
31
+ varying vec3 vWorldDirection;
32
+
33
+ #include <common>
34
+
35
+ void main() {
36
+
37
+ vec3 direction = normalize( vWorldDirection );
38
+
39
+ vec2 sampleUV = equirectUv( direction );
40
+
41
+ gl_FragColor = texture2D( tEquirect, sampleUV );
42
+
43
+ }
44
+ `},r=new Zn(5,5,5),s=new wn({name:"CubemapFromEquirect",uniforms:Li(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ce,blending:En});s.uniforms.tEquirect.value=e;const o=new le(r,s),a=e.minFilter;return e.minFilter===Gn&&(e.minFilter=Je),new Af(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,r){const s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,r);t.setRenderTarget(s)}}class Wa{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Wt(t),this.near=e,this.far=n}clone(){return new Wa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class wf extends ve{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 $e,this.environmentIntensity=1,this.environmentRotation=new $e,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const As=new P,Rf=new P,Cf=new zt;class xn{constructor(t=new P(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=As.subVectors(n,e).cross(Rf.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(As),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Cf.getNormalMatrix(t),r=this.coplanarPoint(As).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Un=new Ga,Rr=new P;class Xa{constructor(t=new xn,e=new xn,n=new xn,r=new xn,s=new xn,o=new xn){this.planes=[t,e,n,r,s,o]}set(t,e,n,r,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=un){const n=this.planes,r=t.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],f=r[7],d=r[8],g=r[9],v=r[10],m=r[11],p=r[12],b=r[13],T=r[14],S=r[15];if(n[0].setComponents(c-s,f-l,m-d,S-p).normalize(),n[1].setComponents(c+s,f+l,m+d,S+p).normalize(),n[2].setComponents(c+o,f+u,m+g,S+b).normalize(),n[3].setComponents(c-o,f-u,m-g,S-b).normalize(),n[4].setComponents(c-a,f-h,m-v,S-T).normalize(),e===un)n[5].setComponents(c+a,f+h,m+v,S+T).normalize();else if(e===Wr)n[5].setComponents(a,h,v,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Un.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Un.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Un)}intersectsSprite(t){return Un.center.set(0,0,0),Un.radius=.7071067811865476,Un.applyMatrix4(t.matrixWorld),this.intersectsSphere(Un)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(Rr.x=r.normal.x>0?t.max.x:t.min.x,Rr.y=r.normal.y>0?t.max.y:t.min.y,Rr.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(Rr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Wn extends ve{constructor(){super(),this.isGroup=!0,this.type="Group"}}class su extends ye{constructor(t,e,n,r,s,o,a,c,l){super(t,e,n,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ou extends ye{constructor(t,e,n,r,s,o,a,c,l,u=Si){if(u!==Si&&u!==Ci)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Si&&(n=qn),n===void 0&&u===Ci&&(n=Ri),super(null,r,s,o,a,c,u,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Xe,this.minFilter=c!==void 0?c:Xe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class Qe{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,r=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let r=0;const s=n.length;let o;e?o=e:o=t*n[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=n[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,n[r]===o)return r/(s-1);const u=n[r],f=n[r+1]-u,d=(o-u)/f;return(r+d)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),c=e||(o.isVector2?new at:new P);return c.copy(a).sub(o).normalize(),c}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new P,r=[],s=[],o=[],a=new P,c=new re;for(let d=0;d<=t;d++){const g=d/t;r[d]=this.getTangentAt(g,new P)}s[0]=new P,o[0]=new P;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),f=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let d=1;d<=t;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();const g=Math.acos(Gt(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(a,g))}o[d].crossVectors(r[d],s[d])}if(e===!0){let d=Math.acos(Gt(s[0].dot(s[t]),-1,1));d/=t,r[0].dot(a.crossVectors(s[0],s[t]))>0&&(d=-d);for(let g=1;g<=t;g++)s[g].applyMatrix4(c.makeRotationAxis(r[g],d*g)),o[g].crossVectors(r[g],s[g])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class qa extends Qe{constructor(t=0,e=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(t,e=new at){const n=e,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const a=this.aStartAngle+t*s;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,d=l-this.aY;c=f*u-d*h+this.aX,l=f*h+d*u+this.aY}return n.set(c,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class Pf extends qa{constructor(t,e,n,r,s,o){super(t,e,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Ya(){let i=0,t=0,e=0,n=0;function r(s,o,a,c){i=s,t=a,e=-3*s+3*o-2*a-c,n=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,h){let f=(o-s)/l-(a-s)/(l+u)+(a-o)/u,d=(a-o)/u-(c-o)/(u+h)+(c-a)/h;f*=u,d*=u,r(o,a,f,d)},calc:function(s){const o=s*s,a=o*s;return i+t*s+e*o+n*a}}}const Cr=new P,bs=new Ya,ws=new Ya,Rs=new Ya;class Lf extends Qe{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new P){const n=e,r=this.points,s=r.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(Cr.subVectors(r[0],r[1]).add(r[0]),l=Cr);const h=r[a%s],f=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(Cr.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Cr),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let g=Math.pow(l.distanceToSquared(h),d),v=Math.pow(h.distanceToSquared(f),d),m=Math.pow(f.distanceToSquared(u),d);v<1e-4&&(v=1),g<1e-4&&(g=v),m<1e-4&&(m=v),bs.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,g,v,m),ws.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,g,v,m),Rs.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,g,v,m)}else this.curveType==="catmullrom"&&(bs.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),ws.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),Rs.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return n.set(bs.calc(c),ws.calc(c),Rs.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(new P().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Wc(i,t,e,n,r){const s=(n-t)*.5,o=(r-e)*.5,a=i*i,c=i*a;return(2*e-2*n+s+o)*c+(-3*e+3*n-2*s-o)*a+s*i+e}function Df(i,t){const e=1-i;return e*e*t}function Uf(i,t){return 2*(1-i)*i*t}function If(i,t){return i*i*t}function qi(i,t,e,n){return Df(i,t)+Uf(i,e)+If(i,n)}function Nf(i,t){const e=1-i;return e*e*e*t}function Ff(i,t){const e=1-i;return 3*e*e*i*t}function Of(i,t){return 3*(1-i)*i*i*t}function Bf(i,t){return i*i*i*t}function Yi(i,t,e,n,r){return Nf(i,t)+Ff(i,e)+Of(i,n)+Bf(i,r)}class au extends Qe{constructor(t=new at,e=new at,n=new at,r=new at){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new at){const n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Yi(t,r.x,s.x,o.x,a.x),Yi(t,r.y,s.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class zf extends Qe{constructor(t=new P,e=new P,n=new P,r=new P){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new P){const n=e,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Yi(t,r.x,s.x,o.x,a.x),Yi(t,r.y,s.y,o.y,a.y),Yi(t,r.z,s.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class cu extends Qe{constructor(t=new at,e=new at){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new at){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new at){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Hf extends Qe{constructor(t=new P,e=new P){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new P){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new P){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class lu extends Qe{constructor(t=new at,e=new at,n=new at){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new at){const n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(qi(t,r.x,s.x,o.x),qi(t,r.y,s.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class kf extends Qe{constructor(t=new P,e=new P,n=new P){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new P){const n=e,r=this.v0,s=this.v1,o=this.v2;return n.set(qi(t,r.x,s.x,o.x),qi(t,r.y,s.y,o.y),qi(t,r.z,s.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class uu extends Qe{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new at){const n=e,r=this.points,s=(r.length-1)*t,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return n.set(Wc(a,c.x,l.x,u.x,h.x),Wc(a,c.y,l.y,u.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(r.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const r=this.points[e];t.points.push(r.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(new at().fromArray(r))}return this}}var wo=Object.freeze({__proto__:null,ArcCurve:Pf,CatmullRomCurve3:Lf,CubicBezierCurve:au,CubicBezierCurve3:zf,EllipseCurve:qa,LineCurve:cu,LineCurve3:Hf,QuadraticBezierCurve:lu,QuadraticBezierCurve3:kf,SplineCurve:uu});class Gf extends Qe{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new wo[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=n){const o=r[s]-n,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let r=0,s=this.curves;r<s.length;r++){const o=s[r],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,c=o.getPoints(a);for(let l=0;l<c.length;l++){const u=c[l];n&&n.equals(u)||(e.push(u),n=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const r=this.curves[e];t.curves.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const r=t.curves[e];this.curves.push(new wo[r.type]().fromJSON(r))}return this}}class Xc extends Gf{constructor(t){super(),this.type="Path",this.currentPoint=new at,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new cu(this.currentPoint.clone(),new at(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){const s=new lu(this.currentPoint.clone(),new at(t,e),new at(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,s,o){const a=new au(this.currentPoint.clone(),new at(t,e),new at(n,r),new at(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new uu(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,s,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(t+a,e+c,n,r,s,o),this}absarc(t,e,n,r,s,o){return this.absellipse(t,e,n,n,r,s,o),this}ellipse(t,e,n,r,s,o,a,c){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+l,e+u,n,r,s,o,a,c),this}absellipse(t,e,n,r,s,o,a,c){const l=new qa(t,e,n,r,s,o,a,c);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Xr extends Pe{constructor(t=1,e=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const s=[],o=[],a=[],c=[],l=new P,u=new at;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=e;h++,f+=3){const d=n+h/e*r;l.x=t*Math.cos(d),l.y=t*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/t+1)/2,u.y=(o[f+1]/t+1)/2,c.push(u.x,u.y)}for(let h=1;h<=e;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new ne(o,3)),this.setAttribute("normal",new ne(a,3)),this.setAttribute("uv",new ne(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xr(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Za extends Pe{constructor(t=1,e=1,n=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};const l=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],f=[],d=[];let g=0;const v=[],m=n/2;let p=0;b(),o===!1&&(t>0&&T(!0),e>0&&T(!1)),this.setIndex(u),this.setAttribute("position",new ne(h,3)),this.setAttribute("normal",new ne(f,3)),this.setAttribute("uv",new ne(d,2));function b(){const S=new P,L=new P;let C=0;const R=(e-t)/n;for(let D=0;D<=s;D++){const y=[],M=D/s,w=M*(e-t)+t;for(let H=0;H<=r;H++){const O=H/r,V=O*c+a,X=Math.sin(V),G=Math.cos(V);L.x=w*X,L.y=-M*n+m,L.z=w*G,h.push(L.x,L.y,L.z),S.set(X,R,G).normalize(),f.push(S.x,S.y,S.z),d.push(O,1-M),y.push(g++)}v.push(y)}for(let D=0;D<r;D++)for(let y=0;y<s;y++){const M=v[y][D],w=v[y+1][D],H=v[y+1][D+1],O=v[y][D+1];(t>0||y!==0)&&(u.push(M,w,O),C+=3),(e>0||y!==s-1)&&(u.push(w,H,O),C+=3)}l.addGroup(p,C,0),p+=C}function T(S){const L=g,C=new at,R=new P;let D=0;const y=S===!0?t:e,M=S===!0?1:-1;for(let H=1;H<=r;H++)h.push(0,m*M,0),f.push(0,M,0),d.push(.5,.5),g++;const w=g;for(let H=0;H<=r;H++){const V=H/r*c+a,X=Math.cos(V),G=Math.sin(V);R.x=y*G,R.y=m*M,R.z=y*X,h.push(R.x,R.y,R.z),f.push(0,M,0),C.x=X*.5+.5,C.y=G*.5*M+.5,d.push(C.x,C.y),g++}for(let H=0;H<r;H++){const O=L+H,V=w+H;S===!0?u.push(V,V+1,O):u.push(V+1,V,O),D+=3}l.addGroup(p,D,S===!0?1:2),p+=D}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Za(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ja extends Xc{constructor(t){super(t),this.uuid=Kn(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const r=t.holes[e];this.holes.push(r.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const r=this.holes[e];t.holes.push(r.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const r=t.holes[e];this.holes.push(new Xc().fromJSON(r))}return this}}const Vf={triangulate:function(i,t,e=2){const n=t&&t.length,r=n?t[0]*e:i.length;let s=hu(i,0,r,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,f,d;if(n&&(s=Zf(i,t,s,e)),i.length>80*e){a=l=i[0],c=u=i[1];for(let g=e;g<r;g+=e)h=i[g],f=i[g+1],h<a&&(a=h),f<c&&(c=f),h>l&&(l=h),f>u&&(u=f);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return Qi(s,o,e,a,c,d,0),o}};function hu(i,t,e,n,r){let s,o;if(r===sd(i,t,e,n)>0)for(s=t;s<e;s+=n)o=qc(s,i[s],i[s+1],o);else for(s=e-n;s>=t;s-=n)o=qc(s,i[s],i[s+1],o);return o&&Kr(o,o.next)&&(er(o),o=o.next),o}function Jn(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(Kr(e,e.next)||oe(e.prev,e,e.next)===0)){if(er(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Qi(i,t,e,n,r,s,o){if(!i)return;!o&&s&&Qf(i,n,r,s);let a=i,c,l;for(;i.prev!==i.next;){if(c=i.prev,l=i.next,s?Xf(i,n,r,s):Wf(i)){t.push(c.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),er(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=qf(Jn(i),t,e),Qi(i,t,e,n,r,s,2)):o===2&&Yf(i,t,e,n,r,s):Qi(Jn(i),t,e,n,r,s,1);break}}}function Wf(i){const t=i.prev,e=i,n=i.next;if(oe(t,e,n)>=0)return!1;const r=t.x,s=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,f=r>s?r>o?r:o:s>o?s:o,d=a>c?a>l?a:l:c>l?c:l;let g=n.next;for(;g!==t;){if(g.x>=u&&g.x<=f&&g.y>=h&&g.y<=d&&_i(r,a,s,c,o,l,g.x,g.y)&&oe(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function Xf(i,t,e,n){const r=i.prev,s=i,o=i.next;if(oe(r,s,o)>=0)return!1;const a=r.x,c=s.x,l=o.x,u=r.y,h=s.y,f=o.y,d=a<c?a<l?a:l:c<l?c:l,g=u<h?u<f?u:f:h<f?h:f,v=a>c?a>l?a:l:c>l?c:l,m=u>h?u>f?u:f:h>f?h:f,p=Ro(d,g,t,e,n),b=Ro(v,m,t,e,n);let T=i.prevZ,S=i.nextZ;for(;T&&T.z>=p&&S&&S.z<=b;){if(T.x>=d&&T.x<=v&&T.y>=g&&T.y<=m&&T!==r&&T!==o&&_i(a,u,c,h,l,f,T.x,T.y)&&oe(T.prev,T,T.next)>=0||(T=T.prevZ,S.x>=d&&S.x<=v&&S.y>=g&&S.y<=m&&S!==r&&S!==o&&_i(a,u,c,h,l,f,S.x,S.y)&&oe(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;T&&T.z>=p;){if(T.x>=d&&T.x<=v&&T.y>=g&&T.y<=m&&T!==r&&T!==o&&_i(a,u,c,h,l,f,T.x,T.y)&&oe(T.prev,T,T.next)>=0)return!1;T=T.prevZ}for(;S&&S.z<=b;){if(S.x>=d&&S.x<=v&&S.y>=g&&S.y<=m&&S!==r&&S!==o&&_i(a,u,c,h,l,f,S.x,S.y)&&oe(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function qf(i,t,e){let n=i;do{const r=n.prev,s=n.next.next;!Kr(r,s)&&fu(r,n,n.next,s)&&tr(r,s)&&tr(s,r)&&(t.push(r.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),er(n),er(n.next),n=i=s),n=n.next}while(n!==i);return Jn(n)}function Yf(i,t,e,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&nd(o,a)){let c=du(o,a);o=Jn(o,o.next),c=Jn(c,c.next),Qi(o,t,e,n,r,s,0),Qi(c,t,e,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function Zf(i,t,e,n){const r=[];let s,o,a,c,l;for(s=0,o=t.length;s<o;s++)a=t[s]*n,c=s<o-1?t[s+1]*n:i.length,l=hu(i,a,c,n,!1),l===l.next&&(l.steiner=!0),r.push(ed(l));for(r.sort(Jf),s=0;s<r.length;s++)e=Kf(r[s],e);return e}function Jf(i,t){return i.x-t.x}function Kf(i,t){const e=jf(i,t);if(!e)return t;const n=du(e,i);return Jn(n,n.next),Jn(e,e.next)}function jf(i,t){let e=t,n=-1/0,r;const s=i.x,o=i.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){const f=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=s&&f>n&&(n=f,r=e.x<e.next.x?e:e.next,f===s))return r}e=e.next}while(e!==t);if(!r)return null;const a=r,c=r.x,l=r.y;let u=1/0,h;e=r;do s>=e.x&&e.x>=c&&s!==e.x&&_i(o<l?s:n,o,c,l,o<l?n:s,o,e.x,e.y)&&(h=Math.abs(o-e.y)/(s-e.x),tr(e,i)&&(h<u||h===u&&(e.x>r.x||e.x===r.x&&$f(r,e)))&&(r=e,u=h)),e=e.next;while(e!==a);return r}function $f(i,t){return oe(i.prev,i,t.prev)<0&&oe(t.next,i,i.next)<0}function Qf(i,t,e,n){let r=i;do r.z===0&&(r.z=Ro(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,td(r)}function td(i){let t,e,n,r,s,o,a,c,l=1;do{for(e=i,i=null,s=null,o=0;e;){for(o++,n=e,a=0,t=0;t<l&&(a++,n=n.nextZ,!!n);t++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||e.z<=n.z)?(r=e,e=e.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;e=n}s.nextZ=null,l*=2}while(o>1);return i}function Ro(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function ed(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function _i(i,t,e,n,r,s,o,a){return(r-o)*(t-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(r-o)*(n-a)}function nd(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!id(i,t)&&(tr(i,t)&&tr(t,i)&&rd(i,t)&&(oe(i.prev,i,t.prev)||oe(i,t.prev,t))||Kr(i,t)&&oe(i.prev,i,i.next)>0&&oe(t.prev,t,t.next)>0)}function oe(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Kr(i,t){return i.x===t.x&&i.y===t.y}function fu(i,t,e,n){const r=Lr(oe(i,t,e)),s=Lr(oe(i,t,n)),o=Lr(oe(e,n,i)),a=Lr(oe(e,n,t));return!!(r!==s&&o!==a||r===0&&Pr(i,e,t)||s===0&&Pr(i,n,t)||o===0&&Pr(e,i,n)||a===0&&Pr(e,t,n))}function Pr(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function Lr(i){return i>0?1:i<0?-1:0}function id(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&fu(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function tr(i,t){return oe(i.prev,i,i.next)<0?oe(i,t,i.next)>=0&&oe(i,i.prev,t)>=0:oe(i,t,i.prev)<0||oe(i,i.next,t)<0}function rd(i,t){let e=i,n=!1;const r=(i.x+t.x)/2,s=(i.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&r<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function du(i,t){const e=new Co(i.i,i.x,i.y),n=new Co(t.i,t.x,t.y),r=i.next,s=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function qc(i,t,e,n){const r=new Co(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function er(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Co(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sd(i,t,e,n){let r=0;for(let s=t,o=e-n;s<e;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}class An{static area(t){const e=t.length;let n=0;for(let r=e-1,s=0;s<e;r=s++)n+=t[r].x*t[s].y-t[s].x*t[r].y;return n*.5}static isClockWise(t){return An.area(t)<0}static triangulateShape(t,e){const n=[],r=[],s=[];Yc(t),Zc(n,t);let o=t.length;e.forEach(Yc);for(let c=0;c<e.length;c++)r.push(o),o+=e[c].length,Zc(n,e[c]);const a=Vf.triangulate(n,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}}function Yc(i){const t=i.length;t>2&&i[t-1].equals(i[0])&&i.pop()}function Zc(i,t){for(let e=0;e<t.length;e++)i.push(t[e].x),i.push(t[e].y)}class Ka extends Pe{constructor(t=new Ja([new at(.5,.5),new at(-.5,.5),new at(-.5,-.5),new at(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,r=[],s=[];for(let a=0,c=t.length;a<c;a++){const l=t[a];o(l)}this.setAttribute("position",new ne(r,3)),this.setAttribute("uv",new ne(s,2)),this.computeVertexNormals();function o(a){const c=[],l=e.curveSegments!==void 0?e.curveSegments:12,u=e.steps!==void 0?e.steps:1,h=e.depth!==void 0?e.depth:1;let f=e.bevelEnabled!==void 0?e.bevelEnabled:!0,d=e.bevelThickness!==void 0?e.bevelThickness:.2,g=e.bevelSize!==void 0?e.bevelSize:d-.1,v=e.bevelOffset!==void 0?e.bevelOffset:0,m=e.bevelSegments!==void 0?e.bevelSegments:3;const p=e.extrudePath,b=e.UVGenerator!==void 0?e.UVGenerator:od;let T,S=!1,L,C,R,D;p&&(T=p.getSpacedPoints(u),S=!0,f=!1,L=p.computeFrenetFrames(u,!1),C=new P,R=new P,D=new P),f||(m=0,d=0,g=0,v=0);const y=a.extractPoints(l);let M=y.shape;const w=y.holes;if(!An.isClockWise(M)){M=M.reverse();for(let J=0,et=w.length;J<et;J++){const A=w[J];An.isClockWise(A)&&(w[J]=A.reverse())}}const O=An.triangulateShape(M,w),V=M;for(let J=0,et=w.length;J<et;J++){const A=w[J];M=M.concat(A)}function X(J,et,A){return et||console.error("THREE.ExtrudeGeometry: vec does not exist"),J.clone().addScaledVector(et,A)}const G=M.length,K=O.length;function k(J,et,A){let bt,nt,St;const ot=J.x-et.x,Dt=J.y-et.y,mt=A.x-J.x,E=A.y-J.y,_=ot*ot+Dt*Dt,F=ot*E-Dt*mt;if(Math.abs(F)>Number.EPSILON){const q=Math.sqrt(_),tt=Math.sqrt(mt*mt+E*E),Z=et.x-Dt/q,wt=et.y+ot/q,ht=A.x-E/tt,xt=A.y+mt/tt,Xt=((ht-Z)*E-(xt-wt)*mt)/(ot*E-Dt*mt);bt=Z+ot*Xt-J.x,nt=wt+Dt*Xt-J.y;const rt=bt*bt+nt*nt;if(rt<=2)return new at(bt,nt);St=Math.sqrt(rt/2)}else{let q=!1;ot>Number.EPSILON?mt>Number.EPSILON&&(q=!0):ot<-Number.EPSILON?mt<-Number.EPSILON&&(q=!0):Math.sign(Dt)===Math.sign(E)&&(q=!0),q?(bt=-Dt,nt=ot,St=Math.sqrt(_)):(bt=ot,nt=Dt,St=Math.sqrt(_/2))}return new at(bt/St,nt/St)}const ct=[];for(let J=0,et=V.length,A=et-1,bt=J+1;J<et;J++,A++,bt++)A===et&&(A=0),bt===et&&(bt=0),ct[J]=k(V[J],V[A],V[bt]);const pt=[];let Mt,Ft=ct.concat();for(let J=0,et=w.length;J<et;J++){const A=w[J];Mt=[];for(let bt=0,nt=A.length,St=nt-1,ot=bt+1;bt<nt;bt++,St++,ot++)St===nt&&(St=0),ot===nt&&(ot=0),Mt[bt]=k(A[bt],A[St],A[ot]);pt.push(Mt),Ft=Ft.concat(Mt)}for(let J=0;J<m;J++){const et=J/m,A=d*Math.cos(et*Math.PI/2),bt=g*Math.sin(et*Math.PI/2)+v;for(let nt=0,St=V.length;nt<St;nt++){const ot=X(V[nt],ct[nt],bt);j(ot.x,ot.y,-A)}for(let nt=0,St=w.length;nt<St;nt++){const ot=w[nt];Mt=pt[nt];for(let Dt=0,mt=ot.length;Dt<mt;Dt++){const E=X(ot[Dt],Mt[Dt],bt);j(E.x,E.y,-A)}}}const Zt=g+v;for(let J=0;J<G;J++){const et=f?X(M[J],Ft[J],Zt):M[J];S?(R.copy(L.normals[0]).multiplyScalar(et.x),C.copy(L.binormals[0]).multiplyScalar(et.y),D.copy(T[0]).add(R).add(C),j(D.x,D.y,D.z)):j(et.x,et.y,0)}for(let J=1;J<=u;J++)for(let et=0;et<G;et++){const A=f?X(M[et],Ft[et],Zt):M[et];S?(R.copy(L.normals[J]).multiplyScalar(A.x),C.copy(L.binormals[J]).multiplyScalar(A.y),D.copy(T[J]).add(R).add(C),j(D.x,D.y,D.z)):j(A.x,A.y,h/u*J)}for(let J=m-1;J>=0;J--){const et=J/m,A=d*Math.cos(et*Math.PI/2),bt=g*Math.sin(et*Math.PI/2)+v;for(let nt=0,St=V.length;nt<St;nt++){const ot=X(V[nt],ct[nt],bt);j(ot.x,ot.y,h+A)}for(let nt=0,St=w.length;nt<St;nt++){const ot=w[nt];Mt=pt[nt];for(let Dt=0,mt=ot.length;Dt<mt;Dt++){const E=X(ot[Dt],Mt[Dt],bt);S?j(E.x,E.y+T[u-1].y,T[u-1].x+A):j(E.x,E.y,h+A)}}}Y(),st();function Y(){const J=r.length/3;if(f){let et=0,A=G*et;for(let bt=0;bt<K;bt++){const nt=O[bt];ut(nt[2]+A,nt[1]+A,nt[0]+A)}et=u+m*2,A=G*et;for(let bt=0;bt<K;bt++){const nt=O[bt];ut(nt[0]+A,nt[1]+A,nt[2]+A)}}else{for(let et=0;et<K;et++){const A=O[et];ut(A[2],A[1],A[0])}for(let et=0;et<K;et++){const A=O[et];ut(A[0]+G*u,A[1]+G*u,A[2]+G*u)}}n.addGroup(J,r.length/3-J,0)}function st(){const J=r.length/3;let et=0;Q(V,et),et+=V.length;for(let A=0,bt=w.length;A<bt;A++){const nt=w[A];Q(nt,et),et+=nt.length}n.addGroup(J,r.length/3-J,1)}function Q(J,et){let A=J.length;for(;--A>=0;){const bt=A;let nt=A-1;nt<0&&(nt=J.length-1);for(let St=0,ot=u+m*2;St<ot;St++){const Dt=G*St,mt=G*(St+1),E=et+bt+Dt,_=et+nt+Dt,F=et+nt+mt,q=et+bt+mt;vt(E,_,F,q)}}}function j(J,et,A){c.push(J),c.push(et),c.push(A)}function ut(J,et,A){Rt(J),Rt(et),Rt(A);const bt=r.length/3,nt=b.generateTopUV(n,r,bt-3,bt-2,bt-1);Vt(nt[0]),Vt(nt[1]),Vt(nt[2])}function vt(J,et,A,bt){Rt(J),Rt(et),Rt(bt),Rt(et),Rt(A),Rt(bt);const nt=r.length/3,St=b.generateSideWallUV(n,r,nt-6,nt-3,nt-2,nt-1);Vt(St[0]),Vt(St[1]),Vt(St[3]),Vt(St[1]),Vt(St[2]),Vt(St[3])}function Rt(J){r.push(c[J*3+0]),r.push(c[J*3+1]),r.push(c[J*3+2])}function Vt(J){s.push(J.x),s.push(J.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return ad(e,n,t)}static fromJSON(t,e){const n=[];for(let s=0,o=t.shapes.length;s<o;s++){const a=e[t.shapes[s]];n.push(a)}const r=t.options.extrudePath;return r!==void 0&&(t.options.extrudePath=new wo[r.type]().fromJSON(r)),new Ka(n,t.options)}}const od={generateTopUV:function(i,t,e,n,r){const s=t[e*3],o=t[e*3+1],a=t[n*3],c=t[n*3+1],l=t[r*3],u=t[r*3+1];return[new at(s,o),new at(a,c),new at(l,u)]},generateSideWallUV:function(i,t,e,n,r,s){const o=t[e*3],a=t[e*3+1],c=t[e*3+2],l=t[n*3],u=t[n*3+1],h=t[n*3+2],f=t[r*3],d=t[r*3+1],g=t[r*3+2],v=t[s*3],m=t[s*3+1],p=t[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new at(o,1-c),new at(l,1-h),new at(f,1-g),new at(v,1-p)]:[new at(a,1-c),new at(u,1-h),new at(d,1-g),new at(m,1-p)]}};function ad(i,t,e){if(e.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const s=i[n];e.shapes.push(s.uuid)}else e.shapes.push(i.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class ar extends Pe{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const s=t/2,o=e/2,a=Math.floor(n),c=Math.floor(r),l=a+1,u=c+1,h=t/a,f=e/c,d=[],g=[],v=[],m=[];for(let p=0;p<u;p++){const b=p*f-o;for(let T=0;T<l;T++){const S=T*h-s;g.push(S,-b,0),v.push(0,0,1),m.push(T/a),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let b=0;b<a;b++){const T=b+l*p,S=b+l*(p+1),L=b+1+l*(p+1),C=b+1+l*p;d.push(T,S,C),d.push(S,L,C)}this.setIndex(d),this.setAttribute("position",new ne(g,3)),this.setAttribute("normal",new ne(v,3)),this.setAttribute("uv",new ne(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ar(t.width,t.height,t.widthSegments,t.heightSegments)}}class qr extends Pe{constructor(t=.5,e=1,n=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:o},n=Math.max(3,n),r=Math.max(1,r);const a=[],c=[],l=[],u=[];let h=t;const f=(e-t)/r,d=new P,g=new at;for(let v=0;v<=r;v++){for(let m=0;m<=n;m++){const p=s+m/n*o;d.x=h*Math.cos(p),d.y=h*Math.sin(p),c.push(d.x,d.y,d.z),l.push(0,0,1),g.x=(d.x/e+1)/2,g.y=(d.y/e+1)/2,u.push(g.x,g.y)}h+=f}for(let v=0;v<r;v++){const m=v*(n+1);for(let p=0;p<n;p++){const b=p+m,T=b,S=b+n+1,L=b+n+2,C=b+1;a.push(T,S,C),a.push(S,L,C)}}this.setIndex(a),this.setAttribute("position",new ne(c,3)),this.setAttribute("normal",new ne(l,3)),this.setAttribute("uv",new ne(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qr(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class ja extends Pe{constructor(t=new Ja([new at(0,.5),new at(-.5,-.5),new at(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const n=[],r=[],s=[],o=[];let a=0,c=0;if(Array.isArray(t)===!1)l(t);else for(let u=0;u<t.length;u++)l(t[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new ne(r,3)),this.setAttribute("normal",new ne(s,3)),this.setAttribute("uv",new ne(o,2));function l(u){const h=r.length/3,f=u.extractPoints(e);let d=f.shape;const g=f.holes;An.isClockWise(d)===!1&&(d=d.reverse());for(let m=0,p=g.length;m<p;m++){const b=g[m];An.isClockWise(b)===!0&&(g[m]=b.reverse())}const v=An.triangulateShape(d,g);for(let m=0,p=g.length;m<p;m++){const b=g[m];d=d.concat(b)}for(let m=0,p=d.length;m<p;m++){const b=d[m];r.push(b.x,b.y,0),s.push(0,0,1),o.push(b.x,b.y)}for(let m=0,p=v.length;m<p;m++){const b=v[m],T=b[0]+h,S=b[1]+h,L=b[2]+h;n.push(T,S,L),c+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return cd(e,t)}static fromJSON(t,e){const n=[];for(let r=0,s=t.shapes.length;r<s;r++){const o=e[t.shapes[r]];n.push(o)}return new ja(n,t.curveSegments)}}function cd(i,t){if(t.shapes=[],Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const r=i[e];t.shapes.push(r.uuid)}else t.shapes.push(i.uuid);return t}class $a extends Pe{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const u=[],h=new P,f=new P,d=[],g=[],v=[],m=[];for(let p=0;p<=n;p++){const b=[],T=p/n;let S=0;p===0&&o===0?S=.5/e:p===n&&c===Math.PI&&(S=-.5/e);for(let L=0;L<=e;L++){const C=L/e;h.x=-t*Math.cos(r+C*s)*Math.sin(o+T*a),h.y=t*Math.cos(o+T*a),h.z=t*Math.sin(r+C*s)*Math.sin(o+T*a),g.push(h.x,h.y,h.z),f.copy(h).normalize(),v.push(f.x,f.y,f.z),m.push(C+S,1-T),b.push(l++)}u.push(b)}for(let p=0;p<n;p++)for(let b=0;b<e;b++){const T=u[p][b+1],S=u[p][b],L=u[p+1][b],C=u[p+1][b+1];(p!==0||o>0)&&d.push(T,S,C),(p!==n-1||c<Math.PI)&&d.push(S,L,C)}this.setIndex(d),this.setAttribute("position",new ne(g,3)),this.setAttribute("normal",new ne(v,3)),this.setAttribute("uv",new ne(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $a(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Qa extends Pe{constructor(t=1,e=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const o=[],a=[],c=[],l=[],u=new P,h=new P,f=new P;for(let d=0;d<=n;d++)for(let g=0;g<=r;g++){const v=g/r*s,m=d/n*Math.PI*2;h.x=(t+e*Math.cos(m))*Math.cos(v),h.y=(t+e*Math.cos(m))*Math.sin(v),h.z=e*Math.sin(m),a.push(h.x,h.y,h.z),u.x=t*Math.cos(v),u.y=t*Math.sin(v),f.subVectors(h,u).normalize(),c.push(f.x,f.y,f.z),l.push(g/r),l.push(d/n)}for(let d=1;d<=n;d++)for(let g=1;g<=r;g++){const v=(r+1)*d+g-1,m=(r+1)*(d-1)+g-1,p=(r+1)*(d-1)+g,b=(r+1)*d+g;o.push(v,m,b),o.push(m,p,b)}this.setIndex(o),this.setAttribute("position",new ne(a,3)),this.setAttribute("normal",new ne(c,3)),this.setAttribute("uv",new ne(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Qa(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class gi extends or{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Wt(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 Wt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yl,this.normalScale=new at(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 $e,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Jc extends gi{constructor(t){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 at(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Wt(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 Wt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Wt(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(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class ld extends or{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=wh,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class ud extends or{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const Kc={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class hd{constructor(t,e,n){const r=this;let s=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h<f;h+=2){const d=l[h],g=l[h+1];if(d.global&&(d.lastIndex=0),d.test(u))return g}return null}}}const fd=new hd;class tc{constructor(t){this.manager=t!==void 0?t:fd,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise(function(r,s){n.load(t,r,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}tc.DEFAULT_MATERIAL_NAME="__DEFAULT";class dd extends tc{constructor(t){super(t)}load(t,e,n,r){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=Kc.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;const a=$i("img");function c(){u(),Kc.add(t,this),e&&e(this),s.manager.itemEnd(t)}function l(h){u(),r&&r(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}}class pd extends tc{constructor(t){super(t)}load(t,e,n,r){const s=new ye,o=new dd(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},n,r),s}}class ec extends ve{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Wt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class md extends ec{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Wt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Cs=new re,jc=new P,$c=new P;class pu{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new at(512,512),this.map=null,this.mapPass=null,this.matrix=new re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Xa,this._frameExtents=new at(1,1),this._viewportCount=1,this._viewports=[new ee(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;jc.setFromMatrixPosition(t.matrixWorld),e.position.copy(jc),$c.setFromMatrixPosition(t.target.matrixWorld),e.lookAt($c),e.updateMatrixWorld(),Cs.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cs),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Cs)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const Qc=new re,Gi=new P,Ps=new P;class gd extends pu{constructor(){super(new Ie(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new at(4,2),this._viewportCount=6,this._viewports=[new ee(2,1,1,1),new ee(0,1,1,1),new ee(3,1,1,1),new ee(1,1,1,1),new ee(3,0,1,1),new ee(1,0,1,1)],this._cubeDirections=[new P(1,0,0),new P(-1,0,0),new P(0,0,1),new P(0,0,-1),new P(0,1,0),new P(0,-1,0)],this._cubeUps=[new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,1,0),new P(0,0,1),new P(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Gi.setFromMatrixPosition(t.matrixWorld),n.position.copy(Gi),Ps.copy(n.position),Ps.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Ps),n.updateMatrixWorld(),r.makeTranslation(-Gi.x,-Gi.y,-Gi.z),Qc.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Qc)}}class _d extends ec{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new gd}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class mu extends iu{constructor(t=-1,e=1,n=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,r,s,o){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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-t,o=n+t,a=r+e,c=r-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class vd extends pu{constructor(){super(new mu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xd extends ec{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ve.DEFAULT_UP),this.updateMatrix(),this.target=new ve,this.shadow=new vd}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Md extends Ie{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}const tl=new re;class Sd{constructor(t,e,n=0,r=1/0){this.ray=new $l(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new Va,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return tl.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(tl),this}intersectObject(t,e=!0,n=[]){return Po(t,this,n,e),n.sort(el),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)Po(t[r],this,n,e);return n.sort(el),n}}function el(i,t){return i.distance-t.distance}function Po(i,t,e,n){let r=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let o=0,a=s.length;o<a;o++)Po(s[o],t,e,!0)}}function nl(i,t,e,n){const r=yd(n);switch(e){case Hl:return i*t;case Gl:return i*t;case Vl:return i*t*2;case Wl:return i*t/r.components*r.byteLength;case Ba:return i*t/r.components*r.byteLength;case Xl:return i*t*2/r.components*r.byteLength;case za:return i*t*2/r.components*r.byteLength;case kl:return i*t*3/r.components*r.byteLength;case We:return i*t*4/r.components*r.byteLength;case Ha:return i*t*4/r.components*r.byteLength;case Nr:case Fr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Or:case Br:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case eo:case io:return Math.max(i,16)*Math.max(t,8)/4;case to:case no:return Math.max(i,8)*Math.max(t,8)/2;case ro:case so:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case oo:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case ao:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case co:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case lo:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case uo:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case ho:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case fo:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case po:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case mo:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case go:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case _o:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case vo:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case xo:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Mo:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case So:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case zr:case yo:case Eo:return Math.ceil(i/4)*Math.ceil(t/4)*16;case ql:case To:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Ao:case bo:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function yd(i){switch(i){case fn:case Ol:return{byteLength:1,components:1};case Ki:case Bl:case ir:return{byteLength:2,components:1};case Fa:case Oa:return{byteLength:2,components:4};case qn:case Na:case ln:return{byteLength:4,components:1};case zl:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ia}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ia);/**
45
+ * @license
46
+ * Copyright 2010-2024 Three.js Authors
47
+ * SPDX-License-Identifier: MIT
48
+ */function gu(){let i=null,t=!1,e=null,n=null;function r(s,o){e(s,o),n=i.requestAnimationFrame(r)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(r),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){i=s}}}function Ed(i){const t=new WeakMap;function e(a,c){const l=a.array,u=a.usage,h=l.byteLength,f=i.createBuffer();i.bindBuffer(c,f),i.bufferData(c,l,u),a.onUploadCallback();let d;if(l instanceof Float32Array)d=i.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?d=i.HALF_FLOAT:d=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=i.SHORT;else if(l instanceof Uint32Array)d=i.UNSIGNED_INT;else if(l instanceof Int32Array)d=i.INT;else if(l instanceof Int8Array)d=i.BYTE;else if(l instanceof Uint8Array)d=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,c,l){const u=c.array,h=c.updateRanges;if(i.bindBuffer(l,a),h.length===0)i.bufferSubData(l,0,u);else{h.sort((d,g)=>d.start-g.start);let f=0;for(let d=1;d<h.length;d++){const g=h[f],v=h[d];v.start<=g.start+g.count+1?g.count=Math.max(g.count,v.start+v.count-g.start):(++f,h[f]=v)}h.length=f+1;for(let d=0,g=h.length;d<g;d++){const v=h[d];i.bufferSubData(l,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),t.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const c=t.get(a);c&&(i.deleteBuffer(c.buffer),t.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const u=t.get(a);(!u||u.version<a.version)&&t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const l=t.get(a);if(l===void 0)t.set(a,e(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var Td=`#ifdef USE_ALPHAHASH
49
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
50
+ #endif`,Ad=`#ifdef USE_ALPHAHASH
51
+ const float ALPHA_HASH_SCALE = 0.05;
52
+ float hash2D( vec2 value ) {
53
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
54
+ }
55
+ float hash3D( vec3 value ) {
56
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
57
+ }
58
+ float getAlphaHashThreshold( vec3 position ) {
59
+ float maxDeriv = max(
60
+ length( dFdx( position.xyz ) ),
61
+ length( dFdy( position.xyz ) )
62
+ );
63
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
64
+ vec2 pixScales = vec2(
65
+ exp2( floor( log2( pixScale ) ) ),
66
+ exp2( ceil( log2( pixScale ) ) )
67
+ );
68
+ vec2 alpha = vec2(
69
+ hash3D( floor( pixScales.x * position.xyz ) ),
70
+ hash3D( floor( pixScales.y * position.xyz ) )
71
+ );
72
+ float lerpFactor = fract( log2( pixScale ) );
73
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
74
+ float a = min( lerpFactor, 1.0 - lerpFactor );
75
+ vec3 cases = vec3(
76
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
77
+ ( x - 0.5 * a ) / ( 1.0 - a ),
78
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
79
+ );
80
+ float threshold = ( x < ( 1.0 - a ) )
81
+ ? ( ( x < a ) ? cases.x : cases.y )
82
+ : cases.z;
83
+ return clamp( threshold , 1.0e-6, 1.0 );
84
+ }
85
+ #endif`,bd=`#ifdef USE_ALPHAMAP
86
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
87
+ #endif`,wd=`#ifdef USE_ALPHAMAP
88
+ uniform sampler2D alphaMap;
89
+ #endif`,Rd=`#ifdef USE_ALPHATEST
90
+ #ifdef ALPHA_TO_COVERAGE
91
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
92
+ if ( diffuseColor.a == 0.0 ) discard;
93
+ #else
94
+ if ( diffuseColor.a < alphaTest ) discard;
95
+ #endif
96
+ #endif`,Cd=`#ifdef USE_ALPHATEST
97
+ uniform float alphaTest;
98
+ #endif`,Pd=`#ifdef USE_AOMAP
99
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
100
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
101
+ #if defined( USE_CLEARCOAT )
102
+ clearcoatSpecularIndirect *= ambientOcclusion;
103
+ #endif
104
+ #if defined( USE_SHEEN )
105
+ sheenSpecularIndirect *= ambientOcclusion;
106
+ #endif
107
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
108
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
109
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
110
+ #endif
111
+ #endif`,Ld=`#ifdef USE_AOMAP
112
+ uniform sampler2D aoMap;
113
+ uniform float aoMapIntensity;
114
+ #endif`,Dd=`#ifdef USE_BATCHING
115
+ #if ! defined( GL_ANGLE_multi_draw )
116
+ #define gl_DrawID _gl_DrawID
117
+ uniform int _gl_DrawID;
118
+ #endif
119
+ uniform highp sampler2D batchingTexture;
120
+ uniform highp usampler2D batchingIdTexture;
121
+ mat4 getBatchingMatrix( const in float i ) {
122
+ int size = textureSize( batchingTexture, 0 ).x;
123
+ int j = int( i ) * 4;
124
+ int x = j % size;
125
+ int y = j / size;
126
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
127
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
128
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
129
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
130
+ return mat4( v1, v2, v3, v4 );
131
+ }
132
+ float getIndirectIndex( const in int i ) {
133
+ int size = textureSize( batchingIdTexture, 0 ).x;
134
+ int x = i % size;
135
+ int y = i / size;
136
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
137
+ }
138
+ #endif
139
+ #ifdef USE_BATCHING_COLOR
140
+ uniform sampler2D batchingColorTexture;
141
+ vec3 getBatchingColor( const in float i ) {
142
+ int size = textureSize( batchingColorTexture, 0 ).x;
143
+ int j = int( i );
144
+ int x = j % size;
145
+ int y = j / size;
146
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
147
+ }
148
+ #endif`,Ud=`#ifdef USE_BATCHING
149
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
150
+ #endif`,Id=`vec3 transformed = vec3( position );
151
+ #ifdef USE_ALPHAHASH
152
+ vPosition = vec3( position );
153
+ #endif`,Nd=`vec3 objectNormal = vec3( normal );
154
+ #ifdef USE_TANGENT
155
+ vec3 objectTangent = vec3( tangent.xyz );
156
+ #endif`,Fd=`float G_BlinnPhong_Implicit( ) {
157
+ return 0.25;
158
+ }
159
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
160
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
161
+ }
162
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
163
+ vec3 halfDir = normalize( lightDir + viewDir );
164
+ float dotNH = saturate( dot( normal, halfDir ) );
165
+ float dotVH = saturate( dot( viewDir, halfDir ) );
166
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
167
+ float G = G_BlinnPhong_Implicit( );
168
+ float D = D_BlinnPhong( shininess, dotNH );
169
+ return F * ( G * D );
170
+ } // validated`,Od=`#ifdef USE_IRIDESCENCE
171
+ const mat3 XYZ_TO_REC709 = mat3(
172
+ 3.2404542, -0.9692660, 0.0556434,
173
+ -1.5371385, 1.8760108, -0.2040259,
174
+ -0.4985314, 0.0415560, 1.0572252
175
+ );
176
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
177
+ vec3 sqrtF0 = sqrt( fresnel0 );
178
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
179
+ }
180
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
181
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
182
+ }
183
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
184
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
185
+ }
186
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
187
+ float phase = 2.0 * PI * OPD * 1.0e-9;
188
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
189
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
190
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
191
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
192
+ 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 ) );
193
+ xyz /= 1.0685e-7;
194
+ vec3 rgb = XYZ_TO_REC709 * xyz;
195
+ return rgb;
196
+ }
197
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
198
+ vec3 I;
199
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
200
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
201
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
202
+ if ( cosTheta2Sq < 0.0 ) {
203
+ return vec3( 1.0 );
204
+ }
205
+ float cosTheta2 = sqrt( cosTheta2Sq );
206
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
207
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
208
+ float T121 = 1.0 - R12;
209
+ float phi12 = 0.0;
210
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
211
+ float phi21 = PI - phi12;
212
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
213
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
214
+ vec3 phi23 = vec3( 0.0 );
215
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
216
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
217
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
218
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
219
+ vec3 phi = vec3( phi21 ) + phi23;
220
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
221
+ vec3 r123 = sqrt( R123 );
222
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
223
+ vec3 C0 = R12 + Rs;
224
+ I = C0;
225
+ vec3 Cm = Rs - T121;
226
+ for ( int m = 1; m <= 2; ++ m ) {
227
+ Cm *= r123;
228
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
229
+ I += Cm * Sm;
230
+ }
231
+ return max( I, vec3( 0.0 ) );
232
+ }
233
+ #endif`,Bd=`#ifdef USE_BUMPMAP
234
+ uniform sampler2D bumpMap;
235
+ uniform float bumpScale;
236
+ vec2 dHdxy_fwd() {
237
+ vec2 dSTdx = dFdx( vBumpMapUv );
238
+ vec2 dSTdy = dFdy( vBumpMapUv );
239
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
240
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
241
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
242
+ return vec2( dBx, dBy );
243
+ }
244
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
245
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
246
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
247
+ vec3 vN = surf_norm;
248
+ vec3 R1 = cross( vSigmaY, vN );
249
+ vec3 R2 = cross( vN, vSigmaX );
250
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
251
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
252
+ return normalize( abs( fDet ) * surf_norm - vGrad );
253
+ }
254
+ #endif`,zd=`#if NUM_CLIPPING_PLANES > 0
255
+ vec4 plane;
256
+ #ifdef ALPHA_TO_COVERAGE
257
+ float distanceToPlane, distanceGradient;
258
+ float clipOpacity = 1.0;
259
+ #pragma unroll_loop_start
260
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
261
+ plane = clippingPlanes[ i ];
262
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
263
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
264
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
265
+ if ( clipOpacity == 0.0 ) discard;
266
+ }
267
+ #pragma unroll_loop_end
268
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
269
+ float unionClipOpacity = 1.0;
270
+ #pragma unroll_loop_start
271
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
272
+ plane = clippingPlanes[ i ];
273
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
274
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
275
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
276
+ }
277
+ #pragma unroll_loop_end
278
+ clipOpacity *= 1.0 - unionClipOpacity;
279
+ #endif
280
+ diffuseColor.a *= clipOpacity;
281
+ if ( diffuseColor.a == 0.0 ) discard;
282
+ #else
283
+ #pragma unroll_loop_start
284
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
285
+ plane = clippingPlanes[ i ];
286
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
287
+ }
288
+ #pragma unroll_loop_end
289
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
290
+ bool clipped = true;
291
+ #pragma unroll_loop_start
292
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
293
+ plane = clippingPlanes[ i ];
294
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
295
+ }
296
+ #pragma unroll_loop_end
297
+ if ( clipped ) discard;
298
+ #endif
299
+ #endif
300
+ #endif`,Hd=`#if NUM_CLIPPING_PLANES > 0
301
+ varying vec3 vClipPosition;
302
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
303
+ #endif`,kd=`#if NUM_CLIPPING_PLANES > 0
304
+ varying vec3 vClipPosition;
305
+ #endif`,Gd=`#if NUM_CLIPPING_PLANES > 0
306
+ vClipPosition = - mvPosition.xyz;
307
+ #endif`,Vd=`#if defined( USE_COLOR_ALPHA )
308
+ diffuseColor *= vColor;
309
+ #elif defined( USE_COLOR )
310
+ diffuseColor.rgb *= vColor;
311
+ #endif`,Wd=`#if defined( USE_COLOR_ALPHA )
312
+ varying vec4 vColor;
313
+ #elif defined( USE_COLOR )
314
+ varying vec3 vColor;
315
+ #endif`,Xd=`#if defined( USE_COLOR_ALPHA )
316
+ varying vec4 vColor;
317
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
318
+ varying vec3 vColor;
319
+ #endif`,qd=`#if defined( USE_COLOR_ALPHA )
320
+ vColor = vec4( 1.0 );
321
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
322
+ vColor = vec3( 1.0 );
323
+ #endif
324
+ #ifdef USE_COLOR
325
+ vColor *= color;
326
+ #endif
327
+ #ifdef USE_INSTANCING_COLOR
328
+ vColor.xyz *= instanceColor.xyz;
329
+ #endif
330
+ #ifdef USE_BATCHING_COLOR
331
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
332
+ vColor.xyz *= batchingColor.xyz;
333
+ #endif`,Yd=`#define PI 3.141592653589793
334
+ #define PI2 6.283185307179586
335
+ #define PI_HALF 1.5707963267948966
336
+ #define RECIPROCAL_PI 0.3183098861837907
337
+ #define RECIPROCAL_PI2 0.15915494309189535
338
+ #define EPSILON 1e-6
339
+ #ifndef saturate
340
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
341
+ #endif
342
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
343
+ float pow2( const in float x ) { return x*x; }
344
+ vec3 pow2( const in vec3 x ) { return x*x; }
345
+ float pow3( const in float x ) { return x*x*x; }
346
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
347
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
348
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
349
+ highp float rand( const in vec2 uv ) {
350
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
351
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
352
+ return fract( sin( sn ) * c );
353
+ }
354
+ #ifdef HIGH_PRECISION
355
+ float precisionSafeLength( vec3 v ) { return length( v ); }
356
+ #else
357
+ float precisionSafeLength( vec3 v ) {
358
+ float maxComponent = max3( abs( v ) );
359
+ return length( v / maxComponent ) * maxComponent;
360
+ }
361
+ #endif
362
+ struct IncidentLight {
363
+ vec3 color;
364
+ vec3 direction;
365
+ bool visible;
366
+ };
367
+ struct ReflectedLight {
368
+ vec3 directDiffuse;
369
+ vec3 directSpecular;
370
+ vec3 indirectDiffuse;
371
+ vec3 indirectSpecular;
372
+ };
373
+ #ifdef USE_ALPHAHASH
374
+ varying vec3 vPosition;
375
+ #endif
376
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
377
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
378
+ }
379
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
380
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
381
+ }
382
+ mat3 transposeMat3( const in mat3 m ) {
383
+ mat3 tmp;
384
+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
385
+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
386
+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
387
+ return tmp;
388
+ }
389
+ bool isPerspectiveMatrix( mat4 m ) {
390
+ return m[ 2 ][ 3 ] == - 1.0;
391
+ }
392
+ vec2 equirectUv( in vec3 dir ) {
393
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
394
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
395
+ return vec2( u, v );
396
+ }
397
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
398
+ return RECIPROCAL_PI * diffuseColor;
399
+ }
400
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
401
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
402
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
403
+ }
404
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
405
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
406
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
407
+ } // validated`,Zd=`#ifdef ENVMAP_TYPE_CUBE_UV
408
+ #define cubeUV_minMipLevel 4.0
409
+ #define cubeUV_minTileSize 16.0
410
+ float getFace( vec3 direction ) {
411
+ vec3 absDirection = abs( direction );
412
+ float face = - 1.0;
413
+ if ( absDirection.x > absDirection.z ) {
414
+ if ( absDirection.x > absDirection.y )
415
+ face = direction.x > 0.0 ? 0.0 : 3.0;
416
+ else
417
+ face = direction.y > 0.0 ? 1.0 : 4.0;
418
+ } else {
419
+ if ( absDirection.z > absDirection.y )
420
+ face = direction.z > 0.0 ? 2.0 : 5.0;
421
+ else
422
+ face = direction.y > 0.0 ? 1.0 : 4.0;
423
+ }
424
+ return face;
425
+ }
426
+ vec2 getUV( vec3 direction, float face ) {
427
+ vec2 uv;
428
+ if ( face == 0.0 ) {
429
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
430
+ } else if ( face == 1.0 ) {
431
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
432
+ } else if ( face == 2.0 ) {
433
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
434
+ } else if ( face == 3.0 ) {
435
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
436
+ } else if ( face == 4.0 ) {
437
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
438
+ } else {
439
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
440
+ }
441
+ return 0.5 * ( uv + 1.0 );
442
+ }
443
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
444
+ float face = getFace( direction );
445
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
446
+ mipInt = max( mipInt, cubeUV_minMipLevel );
447
+ float faceSize = exp2( mipInt );
448
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
449
+ if ( face > 2.0 ) {
450
+ uv.y += faceSize;
451
+ face -= 3.0;
452
+ }
453
+ uv.x += face * faceSize;
454
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
455
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
456
+ uv.x *= CUBEUV_TEXEL_WIDTH;
457
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
458
+ #ifdef texture2DGradEXT
459
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
460
+ #else
461
+ return texture2D( envMap, uv ).rgb;
462
+ #endif
463
+ }
464
+ #define cubeUV_r0 1.0
465
+ #define cubeUV_m0 - 2.0
466
+ #define cubeUV_r1 0.8
467
+ #define cubeUV_m1 - 1.0
468
+ #define cubeUV_r4 0.4
469
+ #define cubeUV_m4 2.0
470
+ #define cubeUV_r5 0.305
471
+ #define cubeUV_m5 3.0
472
+ #define cubeUV_r6 0.21
473
+ #define cubeUV_m6 4.0
474
+ float roughnessToMip( float roughness ) {
475
+ float mip = 0.0;
476
+ if ( roughness >= cubeUV_r1 ) {
477
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
478
+ } else if ( roughness >= cubeUV_r4 ) {
479
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
480
+ } else if ( roughness >= cubeUV_r5 ) {
481
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
482
+ } else if ( roughness >= cubeUV_r6 ) {
483
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
484
+ } else {
485
+ mip = - 2.0 * log2( 1.16 * roughness ); }
486
+ return mip;
487
+ }
488
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
489
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
490
+ float mipF = fract( mip );
491
+ float mipInt = floor( mip );
492
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
493
+ if ( mipF == 0.0 ) {
494
+ return vec4( color0, 1.0 );
495
+ } else {
496
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
497
+ return vec4( mix( color0, color1, mipF ), 1.0 );
498
+ }
499
+ }
500
+ #endif`,Jd=`vec3 transformedNormal = objectNormal;
501
+ #ifdef USE_TANGENT
502
+ vec3 transformedTangent = objectTangent;
503
+ #endif
504
+ #ifdef USE_BATCHING
505
+ mat3 bm = mat3( batchingMatrix );
506
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
507
+ transformedNormal = bm * transformedNormal;
508
+ #ifdef USE_TANGENT
509
+ transformedTangent = bm * transformedTangent;
510
+ #endif
511
+ #endif
512
+ #ifdef USE_INSTANCING
513
+ mat3 im = mat3( instanceMatrix );
514
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
515
+ transformedNormal = im * transformedNormal;
516
+ #ifdef USE_TANGENT
517
+ transformedTangent = im * transformedTangent;
518
+ #endif
519
+ #endif
520
+ transformedNormal = normalMatrix * transformedNormal;
521
+ #ifdef FLIP_SIDED
522
+ transformedNormal = - transformedNormal;
523
+ #endif
524
+ #ifdef USE_TANGENT
525
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
526
+ #ifdef FLIP_SIDED
527
+ transformedTangent = - transformedTangent;
528
+ #endif
529
+ #endif`,Kd=`#ifdef USE_DISPLACEMENTMAP
530
+ uniform sampler2D displacementMap;
531
+ uniform float displacementScale;
532
+ uniform float displacementBias;
533
+ #endif`,jd=`#ifdef USE_DISPLACEMENTMAP
534
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
535
+ #endif`,$d=`#ifdef USE_EMISSIVEMAP
536
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
537
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
538
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
539
+ #endif
540
+ totalEmissiveRadiance *= emissiveColor.rgb;
541
+ #endif`,Qd=`#ifdef USE_EMISSIVEMAP
542
+ uniform sampler2D emissiveMap;
543
+ #endif`,tp="gl_FragColor = linearToOutputTexel( gl_FragColor );",ep=`vec4 LinearTransferOETF( in vec4 value ) {
544
+ return value;
545
+ }
546
+ vec4 sRGBTransferEOTF( in vec4 value ) {
547
+ 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 );
548
+ }
549
+ vec4 sRGBTransferOETF( in vec4 value ) {
550
+ 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 );
551
+ }`,np=`#ifdef USE_ENVMAP
552
+ #ifdef ENV_WORLDPOS
553
+ vec3 cameraToFrag;
554
+ if ( isOrthographic ) {
555
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
556
+ } else {
557
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
558
+ }
559
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
560
+ #ifdef ENVMAP_MODE_REFLECTION
561
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
562
+ #else
563
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
564
+ #endif
565
+ #else
566
+ vec3 reflectVec = vReflect;
567
+ #endif
568
+ #ifdef ENVMAP_TYPE_CUBE
569
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
570
+ #else
571
+ vec4 envColor = vec4( 0.0 );
572
+ #endif
573
+ #ifdef ENVMAP_BLENDING_MULTIPLY
574
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
575
+ #elif defined( ENVMAP_BLENDING_MIX )
576
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
577
+ #elif defined( ENVMAP_BLENDING_ADD )
578
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
579
+ #endif
580
+ #endif`,ip=`#ifdef USE_ENVMAP
581
+ uniform float envMapIntensity;
582
+ uniform float flipEnvMap;
583
+ uniform mat3 envMapRotation;
584
+ #ifdef ENVMAP_TYPE_CUBE
585
+ uniform samplerCube envMap;
586
+ #else
587
+ uniform sampler2D envMap;
588
+ #endif
589
+
590
+ #endif`,rp=`#ifdef USE_ENVMAP
591
+ uniform float reflectivity;
592
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
593
+ #define ENV_WORLDPOS
594
+ #endif
595
+ #ifdef ENV_WORLDPOS
596
+ varying vec3 vWorldPosition;
597
+ uniform float refractionRatio;
598
+ #else
599
+ varying vec3 vReflect;
600
+ #endif
601
+ #endif`,sp=`#ifdef USE_ENVMAP
602
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
603
+ #define ENV_WORLDPOS
604
+ #endif
605
+ #ifdef ENV_WORLDPOS
606
+
607
+ varying vec3 vWorldPosition;
608
+ #else
609
+ varying vec3 vReflect;
610
+ uniform float refractionRatio;
611
+ #endif
612
+ #endif`,op=`#ifdef USE_ENVMAP
613
+ #ifdef ENV_WORLDPOS
614
+ vWorldPosition = worldPosition.xyz;
615
+ #else
616
+ vec3 cameraToVertex;
617
+ if ( isOrthographic ) {
618
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
619
+ } else {
620
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
621
+ }
622
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
623
+ #ifdef ENVMAP_MODE_REFLECTION
624
+ vReflect = reflect( cameraToVertex, worldNormal );
625
+ #else
626
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
627
+ #endif
628
+ #endif
629
+ #endif`,ap=`#ifdef USE_FOG
630
+ vFogDepth = - mvPosition.z;
631
+ #endif`,cp=`#ifdef USE_FOG
632
+ varying float vFogDepth;
633
+ #endif`,lp=`#ifdef USE_FOG
634
+ #ifdef FOG_EXP2
635
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
636
+ #else
637
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
638
+ #endif
639
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
640
+ #endif`,up=`#ifdef USE_FOG
641
+ uniform vec3 fogColor;
642
+ varying float vFogDepth;
643
+ #ifdef FOG_EXP2
644
+ uniform float fogDensity;
645
+ #else
646
+ uniform float fogNear;
647
+ uniform float fogFar;
648
+ #endif
649
+ #endif`,hp=`#ifdef USE_GRADIENTMAP
650
+ uniform sampler2D gradientMap;
651
+ #endif
652
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
653
+ float dotNL = dot( normal, lightDirection );
654
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
655
+ #ifdef USE_GRADIENTMAP
656
+ return vec3( texture2D( gradientMap, coord ).r );
657
+ #else
658
+ vec2 fw = fwidth( coord ) * 0.5;
659
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
660
+ #endif
661
+ }`,fp=`#ifdef USE_LIGHTMAP
662
+ uniform sampler2D lightMap;
663
+ uniform float lightMapIntensity;
664
+ #endif`,dp=`LambertMaterial material;
665
+ material.diffuseColor = diffuseColor.rgb;
666
+ material.specularStrength = specularStrength;`,pp=`varying vec3 vViewPosition;
667
+ struct LambertMaterial {
668
+ vec3 diffuseColor;
669
+ float specularStrength;
670
+ };
671
+ 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 ) {
672
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
673
+ vec3 irradiance = dotNL * directLight.color;
674
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
675
+ }
676
+ 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 ) {
677
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
678
+ }
679
+ #define RE_Direct RE_Direct_Lambert
680
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,mp=`uniform bool receiveShadow;
681
+ uniform vec3 ambientLightColor;
682
+ #if defined( USE_LIGHT_PROBES )
683
+ uniform vec3 lightProbe[ 9 ];
684
+ #endif
685
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
686
+ float x = normal.x, y = normal.y, z = normal.z;
687
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
688
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
689
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
690
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
691
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
692
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
693
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
694
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
695
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
696
+ return result;
697
+ }
698
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
699
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
700
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
701
+ return irradiance;
702
+ }
703
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
704
+ vec3 irradiance = ambientLightColor;
705
+ return irradiance;
706
+ }
707
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
708
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
709
+ if ( cutoffDistance > 0.0 ) {
710
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
711
+ }
712
+ return distanceFalloff;
713
+ }
714
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
715
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
716
+ }
717
+ #if NUM_DIR_LIGHTS > 0
718
+ struct DirectionalLight {
719
+ vec3 direction;
720
+ vec3 color;
721
+ };
722
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
723
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
724
+ light.color = directionalLight.color;
725
+ light.direction = directionalLight.direction;
726
+ light.visible = true;
727
+ }
728
+ #endif
729
+ #if NUM_POINT_LIGHTS > 0
730
+ struct PointLight {
731
+ vec3 position;
732
+ vec3 color;
733
+ float distance;
734
+ float decay;
735
+ };
736
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
737
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
738
+ vec3 lVector = pointLight.position - geometryPosition;
739
+ light.direction = normalize( lVector );
740
+ float lightDistance = length( lVector );
741
+ light.color = pointLight.color;
742
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
743
+ light.visible = ( light.color != vec3( 0.0 ) );
744
+ }
745
+ #endif
746
+ #if NUM_SPOT_LIGHTS > 0
747
+ struct SpotLight {
748
+ vec3 position;
749
+ vec3 direction;
750
+ vec3 color;
751
+ float distance;
752
+ float decay;
753
+ float coneCos;
754
+ float penumbraCos;
755
+ };
756
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
757
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
758
+ vec3 lVector = spotLight.position - geometryPosition;
759
+ light.direction = normalize( lVector );
760
+ float angleCos = dot( light.direction, spotLight.direction );
761
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
762
+ if ( spotAttenuation > 0.0 ) {
763
+ float lightDistance = length( lVector );
764
+ light.color = spotLight.color * spotAttenuation;
765
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
766
+ light.visible = ( light.color != vec3( 0.0 ) );
767
+ } else {
768
+ light.color = vec3( 0.0 );
769
+ light.visible = false;
770
+ }
771
+ }
772
+ #endif
773
+ #if NUM_RECT_AREA_LIGHTS > 0
774
+ struct RectAreaLight {
775
+ vec3 color;
776
+ vec3 position;
777
+ vec3 halfWidth;
778
+ vec3 halfHeight;
779
+ };
780
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
781
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
782
+ #endif
783
+ #if NUM_HEMI_LIGHTS > 0
784
+ struct HemisphereLight {
785
+ vec3 direction;
786
+ vec3 skyColor;
787
+ vec3 groundColor;
788
+ };
789
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
790
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
791
+ float dotNL = dot( normal, hemiLight.direction );
792
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
793
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
794
+ return irradiance;
795
+ }
796
+ #endif`,gp=`#ifdef USE_ENVMAP
797
+ vec3 getIBLIrradiance( const in vec3 normal ) {
798
+ #ifdef ENVMAP_TYPE_CUBE_UV
799
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
800
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
801
+ return PI * envMapColor.rgb * envMapIntensity;
802
+ #else
803
+ return vec3( 0.0 );
804
+ #endif
805
+ }
806
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
807
+ #ifdef ENVMAP_TYPE_CUBE_UV
808
+ vec3 reflectVec = reflect( - viewDir, normal );
809
+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
810
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
811
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
812
+ return envMapColor.rgb * envMapIntensity;
813
+ #else
814
+ return vec3( 0.0 );
815
+ #endif
816
+ }
817
+ #ifdef USE_ANISOTROPY
818
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
819
+ #ifdef ENVMAP_TYPE_CUBE_UV
820
+ vec3 bentNormal = cross( bitangent, viewDir );
821
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
822
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
823
+ return getIBLRadiance( viewDir, bentNormal, roughness );
824
+ #else
825
+ return vec3( 0.0 );
826
+ #endif
827
+ }
828
+ #endif
829
+ #endif`,_p=`ToonMaterial material;
830
+ material.diffuseColor = diffuseColor.rgb;`,vp=`varying vec3 vViewPosition;
831
+ struct ToonMaterial {
832
+ vec3 diffuseColor;
833
+ };
834
+ 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 ) {
835
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
836
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
837
+ }
838
+ 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 ) {
839
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
840
+ }
841
+ #define RE_Direct RE_Direct_Toon
842
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,xp=`BlinnPhongMaterial material;
843
+ material.diffuseColor = diffuseColor.rgb;
844
+ material.specularColor = specular;
845
+ material.specularShininess = shininess;
846
+ material.specularStrength = specularStrength;`,Mp=`varying vec3 vViewPosition;
847
+ struct BlinnPhongMaterial {
848
+ vec3 diffuseColor;
849
+ vec3 specularColor;
850
+ float specularShininess;
851
+ float specularStrength;
852
+ };
853
+ 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 ) {
854
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
855
+ vec3 irradiance = dotNL * directLight.color;
856
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
857
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
858
+ }
859
+ 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 ) {
860
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
861
+ }
862
+ #define RE_Direct RE_Direct_BlinnPhong
863
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Sp=`PhysicalMaterial material;
864
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
865
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
866
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
867
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
868
+ material.roughness = min( material.roughness, 1.0 );
869
+ #ifdef IOR
870
+ material.ior = ior;
871
+ #ifdef USE_SPECULAR
872
+ float specularIntensityFactor = specularIntensity;
873
+ vec3 specularColorFactor = specularColor;
874
+ #ifdef USE_SPECULAR_COLORMAP
875
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
876
+ #endif
877
+ #ifdef USE_SPECULAR_INTENSITYMAP
878
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
879
+ #endif
880
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
881
+ #else
882
+ float specularIntensityFactor = 1.0;
883
+ vec3 specularColorFactor = vec3( 1.0 );
884
+ material.specularF90 = 1.0;
885
+ #endif
886
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
887
+ #else
888
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
889
+ material.specularF90 = 1.0;
890
+ #endif
891
+ #ifdef USE_CLEARCOAT
892
+ material.clearcoat = clearcoat;
893
+ material.clearcoatRoughness = clearcoatRoughness;
894
+ material.clearcoatF0 = vec3( 0.04 );
895
+ material.clearcoatF90 = 1.0;
896
+ #ifdef USE_CLEARCOATMAP
897
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
898
+ #endif
899
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
900
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
901
+ #endif
902
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
903
+ material.clearcoatRoughness += geometryRoughness;
904
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
905
+ #endif
906
+ #ifdef USE_DISPERSION
907
+ material.dispersion = dispersion;
908
+ #endif
909
+ #ifdef USE_IRIDESCENCE
910
+ material.iridescence = iridescence;
911
+ material.iridescenceIOR = iridescenceIOR;
912
+ #ifdef USE_IRIDESCENCEMAP
913
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
914
+ #endif
915
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
916
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
917
+ #else
918
+ material.iridescenceThickness = iridescenceThicknessMaximum;
919
+ #endif
920
+ #endif
921
+ #ifdef USE_SHEEN
922
+ material.sheenColor = sheenColor;
923
+ #ifdef USE_SHEEN_COLORMAP
924
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
925
+ #endif
926
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
927
+ #ifdef USE_SHEEN_ROUGHNESSMAP
928
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
929
+ #endif
930
+ #endif
931
+ #ifdef USE_ANISOTROPY
932
+ #ifdef USE_ANISOTROPYMAP
933
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
934
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
935
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
936
+ #else
937
+ vec2 anisotropyV = anisotropyVector;
938
+ #endif
939
+ material.anisotropy = length( anisotropyV );
940
+ if( material.anisotropy == 0.0 ) {
941
+ anisotropyV = vec2( 1.0, 0.0 );
942
+ } else {
943
+ anisotropyV /= material.anisotropy;
944
+ material.anisotropy = saturate( material.anisotropy );
945
+ }
946
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
947
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
948
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
949
+ #endif`,yp=`struct PhysicalMaterial {
950
+ vec3 diffuseColor;
951
+ float roughness;
952
+ vec3 specularColor;
953
+ float specularF90;
954
+ float dispersion;
955
+ #ifdef USE_CLEARCOAT
956
+ float clearcoat;
957
+ float clearcoatRoughness;
958
+ vec3 clearcoatF0;
959
+ float clearcoatF90;
960
+ #endif
961
+ #ifdef USE_IRIDESCENCE
962
+ float iridescence;
963
+ float iridescenceIOR;
964
+ float iridescenceThickness;
965
+ vec3 iridescenceFresnel;
966
+ vec3 iridescenceF0;
967
+ #endif
968
+ #ifdef USE_SHEEN
969
+ vec3 sheenColor;
970
+ float sheenRoughness;
971
+ #endif
972
+ #ifdef IOR
973
+ float ior;
974
+ #endif
975
+ #ifdef USE_TRANSMISSION
976
+ float transmission;
977
+ float transmissionAlpha;
978
+ float thickness;
979
+ float attenuationDistance;
980
+ vec3 attenuationColor;
981
+ #endif
982
+ #ifdef USE_ANISOTROPY
983
+ float anisotropy;
984
+ float alphaT;
985
+ vec3 anisotropyT;
986
+ vec3 anisotropyB;
987
+ #endif
988
+ };
989
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
990
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
991
+ vec3 sheenSpecularDirect = vec3( 0.0 );
992
+ vec3 sheenSpecularIndirect = vec3(0.0 );
993
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
994
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
995
+ float x2 = x * x;
996
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
997
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
998
+ }
999
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
1000
+ float a2 = pow2( alpha );
1001
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
1002
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
1003
+ return 0.5 / max( gv + gl, EPSILON );
1004
+ }
1005
+ float D_GGX( const in float alpha, const in float dotNH ) {
1006
+ float a2 = pow2( alpha );
1007
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1008
+ return RECIPROCAL_PI * a2 / pow2( denom );
1009
+ }
1010
+ #ifdef USE_ANISOTROPY
1011
+ 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 ) {
1012
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1013
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1014
+ float v = 0.5 / ( gv + gl );
1015
+ return saturate(v);
1016
+ }
1017
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1018
+ float a2 = alphaT * alphaB;
1019
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1020
+ highp float v2 = dot( v, v );
1021
+ float w2 = a2 / v2;
1022
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1023
+ }
1024
+ #endif
1025
+ #ifdef USE_CLEARCOAT
1026
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1027
+ vec3 f0 = material.clearcoatF0;
1028
+ float f90 = material.clearcoatF90;
1029
+ float roughness = material.clearcoatRoughness;
1030
+ float alpha = pow2( roughness );
1031
+ vec3 halfDir = normalize( lightDir + viewDir );
1032
+ float dotNL = saturate( dot( normal, lightDir ) );
1033
+ float dotNV = saturate( dot( normal, viewDir ) );
1034
+ float dotNH = saturate( dot( normal, halfDir ) );
1035
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1036
+ vec3 F = F_Schlick( f0, f90, dotVH );
1037
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1038
+ float D = D_GGX( alpha, dotNH );
1039
+ return F * ( V * D );
1040
+ }
1041
+ #endif
1042
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1043
+ vec3 f0 = material.specularColor;
1044
+ float f90 = material.specularF90;
1045
+ float roughness = material.roughness;
1046
+ float alpha = pow2( roughness );
1047
+ vec3 halfDir = normalize( lightDir + viewDir );
1048
+ float dotNL = saturate( dot( normal, lightDir ) );
1049
+ float dotNV = saturate( dot( normal, viewDir ) );
1050
+ float dotNH = saturate( dot( normal, halfDir ) );
1051
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1052
+ vec3 F = F_Schlick( f0, f90, dotVH );
1053
+ #ifdef USE_IRIDESCENCE
1054
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1055
+ #endif
1056
+ #ifdef USE_ANISOTROPY
1057
+ float dotTL = dot( material.anisotropyT, lightDir );
1058
+ float dotTV = dot( material.anisotropyT, viewDir );
1059
+ float dotTH = dot( material.anisotropyT, halfDir );
1060
+ float dotBL = dot( material.anisotropyB, lightDir );
1061
+ float dotBV = dot( material.anisotropyB, viewDir );
1062
+ float dotBH = dot( material.anisotropyB, halfDir );
1063
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1064
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1065
+ #else
1066
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1067
+ float D = D_GGX( alpha, dotNH );
1068
+ #endif
1069
+ return F * ( V * D );
1070
+ }
1071
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1072
+ const float LUT_SIZE = 64.0;
1073
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1074
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1075
+ float dotNV = saturate( dot( N, V ) );
1076
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1077
+ uv = uv * LUT_SCALE + LUT_BIAS;
1078
+ return uv;
1079
+ }
1080
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1081
+ float l = length( f );
1082
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1083
+ }
1084
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1085
+ float x = dot( v1, v2 );
1086
+ float y = abs( x );
1087
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1088
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1089
+ float v = a / b;
1090
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1091
+ return cross( v1, v2 ) * theta_sintheta;
1092
+ }
1093
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1094
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1095
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1096
+ vec3 lightNormal = cross( v1, v2 );
1097
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1098
+ vec3 T1, T2;
1099
+ T1 = normalize( V - N * dot( V, N ) );
1100
+ T2 = - cross( N, T1 );
1101
+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1102
+ vec3 coords[ 4 ];
1103
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1104
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1105
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1106
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1107
+ coords[ 0 ] = normalize( coords[ 0 ] );
1108
+ coords[ 1 ] = normalize( coords[ 1 ] );
1109
+ coords[ 2 ] = normalize( coords[ 2 ] );
1110
+ coords[ 3 ] = normalize( coords[ 3 ] );
1111
+ vec3 vectorFormFactor = vec3( 0.0 );
1112
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1113
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1114
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1115
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1116
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1117
+ return vec3( result );
1118
+ }
1119
+ #if defined( USE_SHEEN )
1120
+ float D_Charlie( float roughness, float dotNH ) {
1121
+ float alpha = pow2( roughness );
1122
+ float invAlpha = 1.0 / alpha;
1123
+ float cos2h = dotNH * dotNH;
1124
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1125
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1126
+ }
1127
+ float V_Neubelt( float dotNV, float dotNL ) {
1128
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1129
+ }
1130
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1131
+ vec3 halfDir = normalize( lightDir + viewDir );
1132
+ float dotNL = saturate( dot( normal, lightDir ) );
1133
+ float dotNV = saturate( dot( normal, viewDir ) );
1134
+ float dotNH = saturate( dot( normal, halfDir ) );
1135
+ float D = D_Charlie( sheenRoughness, dotNH );
1136
+ float V = V_Neubelt( dotNV, dotNL );
1137
+ return sheenColor * ( D * V );
1138
+ }
1139
+ #endif
1140
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1141
+ float dotNV = saturate( dot( normal, viewDir ) );
1142
+ float r2 = roughness * roughness;
1143
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1144
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1145
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1146
+ return saturate( DG * RECIPROCAL_PI );
1147
+ }
1148
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1149
+ float dotNV = saturate( dot( normal, viewDir ) );
1150
+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1151
+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1152
+ vec4 r = roughness * c0 + c1;
1153
+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1154
+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1155
+ return fab;
1156
+ }
1157
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1158
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1159
+ return specularColor * fab.x + specularF90 * fab.y;
1160
+ }
1161
+ #ifdef USE_IRIDESCENCE
1162
+ 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 ) {
1163
+ #else
1164
+ 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 ) {
1165
+ #endif
1166
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1167
+ #ifdef USE_IRIDESCENCE
1168
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1169
+ #else
1170
+ vec3 Fr = specularColor;
1171
+ #endif
1172
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1173
+ float Ess = fab.x + fab.y;
1174
+ float Ems = 1.0 - Ess;
1175
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1176
+ singleScatter += FssEss;
1177
+ multiScatter += Fms * Ems;
1178
+ }
1179
+ #if NUM_RECT_AREA_LIGHTS > 0
1180
+ 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 ) {
1181
+ vec3 normal = geometryNormal;
1182
+ vec3 viewDir = geometryViewDir;
1183
+ vec3 position = geometryPosition;
1184
+ vec3 lightPos = rectAreaLight.position;
1185
+ vec3 halfWidth = rectAreaLight.halfWidth;
1186
+ vec3 halfHeight = rectAreaLight.halfHeight;
1187
+ vec3 lightColor = rectAreaLight.color;
1188
+ float roughness = material.roughness;
1189
+ vec3 rectCoords[ 4 ];
1190
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1191
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1192
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1193
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1194
+ vec4 t1 = texture2D( ltc_1, uv );
1195
+ vec4 t2 = texture2D( ltc_2, uv );
1196
+ mat3 mInv = mat3(
1197
+ vec3( t1.x, 0, t1.y ),
1198
+ vec3( 0, 1, 0 ),
1199
+ vec3( t1.z, 0, t1.w )
1200
+ );
1201
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1202
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1203
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1204
+ }
1205
+ #endif
1206
+ 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 ) {
1207
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1208
+ vec3 irradiance = dotNL * directLight.color;
1209
+ #ifdef USE_CLEARCOAT
1210
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1211
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1212
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1213
+ #endif
1214
+ #ifdef USE_SHEEN
1215
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1216
+ #endif
1217
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1218
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1219
+ }
1220
+ 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 ) {
1221
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1222
+ }
1223
+ 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) {
1224
+ #ifdef USE_CLEARCOAT
1225
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1226
+ #endif
1227
+ #ifdef USE_SHEEN
1228
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1229
+ #endif
1230
+ vec3 singleScattering = vec3( 0.0 );
1231
+ vec3 multiScattering = vec3( 0.0 );
1232
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1233
+ #ifdef USE_IRIDESCENCE
1234
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1235
+ #else
1236
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1237
+ #endif
1238
+ vec3 totalScattering = singleScattering + multiScattering;
1239
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1240
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1241
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1242
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1243
+ }
1244
+ #define RE_Direct RE_Direct_Physical
1245
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1246
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1247
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1248
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1249
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1250
+ }`,Ep=`
1251
+ vec3 geometryPosition = - vViewPosition;
1252
+ vec3 geometryNormal = normal;
1253
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1254
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1255
+ #ifdef USE_CLEARCOAT
1256
+ geometryClearcoatNormal = clearcoatNormal;
1257
+ #endif
1258
+ #ifdef USE_IRIDESCENCE
1259
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1260
+ if ( material.iridescenceThickness == 0.0 ) {
1261
+ material.iridescence = 0.0;
1262
+ } else {
1263
+ material.iridescence = saturate( material.iridescence );
1264
+ }
1265
+ if ( material.iridescence > 0.0 ) {
1266
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1267
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1268
+ }
1269
+ #endif
1270
+ IncidentLight directLight;
1271
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1272
+ PointLight pointLight;
1273
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1274
+ PointLightShadow pointLightShadow;
1275
+ #endif
1276
+ #pragma unroll_loop_start
1277
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1278
+ pointLight = pointLights[ i ];
1279
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1280
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1281
+ pointLightShadow = pointLightShadows[ i ];
1282
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1283
+ #endif
1284
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1285
+ }
1286
+ #pragma unroll_loop_end
1287
+ #endif
1288
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1289
+ SpotLight spotLight;
1290
+ vec4 spotColor;
1291
+ vec3 spotLightCoord;
1292
+ bool inSpotLightMap;
1293
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1294
+ SpotLightShadow spotLightShadow;
1295
+ #endif
1296
+ #pragma unroll_loop_start
1297
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1298
+ spotLight = spotLights[ i ];
1299
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1300
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1301
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1302
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1303
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1304
+ #else
1305
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1306
+ #endif
1307
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1308
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1309
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1310
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1311
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1312
+ #endif
1313
+ #undef SPOT_LIGHT_MAP_INDEX
1314
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1315
+ spotLightShadow = spotLightShadows[ i ];
1316
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1317
+ #endif
1318
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1319
+ }
1320
+ #pragma unroll_loop_end
1321
+ #endif
1322
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1323
+ DirectionalLight directionalLight;
1324
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1325
+ DirectionalLightShadow directionalLightShadow;
1326
+ #endif
1327
+ #pragma unroll_loop_start
1328
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1329
+ directionalLight = directionalLights[ i ];
1330
+ getDirectionalLightInfo( directionalLight, directLight );
1331
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1332
+ directionalLightShadow = directionalLightShadows[ i ];
1333
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1334
+ #endif
1335
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1336
+ }
1337
+ #pragma unroll_loop_end
1338
+ #endif
1339
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1340
+ RectAreaLight rectAreaLight;
1341
+ #pragma unroll_loop_start
1342
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1343
+ rectAreaLight = rectAreaLights[ i ];
1344
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1345
+ }
1346
+ #pragma unroll_loop_end
1347
+ #endif
1348
+ #if defined( RE_IndirectDiffuse )
1349
+ vec3 iblIrradiance = vec3( 0.0 );
1350
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1351
+ #if defined( USE_LIGHT_PROBES )
1352
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1353
+ #endif
1354
+ #if ( NUM_HEMI_LIGHTS > 0 )
1355
+ #pragma unroll_loop_start
1356
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1357
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1358
+ }
1359
+ #pragma unroll_loop_end
1360
+ #endif
1361
+ #endif
1362
+ #if defined( RE_IndirectSpecular )
1363
+ vec3 radiance = vec3( 0.0 );
1364
+ vec3 clearcoatRadiance = vec3( 0.0 );
1365
+ #endif`,Tp=`#if defined( RE_IndirectDiffuse )
1366
+ #ifdef USE_LIGHTMAP
1367
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1368
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1369
+ irradiance += lightMapIrradiance;
1370
+ #endif
1371
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1372
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1373
+ #endif
1374
+ #endif
1375
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1376
+ #ifdef USE_ANISOTROPY
1377
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1378
+ #else
1379
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1380
+ #endif
1381
+ #ifdef USE_CLEARCOAT
1382
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1383
+ #endif
1384
+ #endif`,Ap=`#if defined( RE_IndirectDiffuse )
1385
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1386
+ #endif
1387
+ #if defined( RE_IndirectSpecular )
1388
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1389
+ #endif`,bp=`#if defined( USE_LOGDEPTHBUF )
1390
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1391
+ #endif`,wp=`#if defined( USE_LOGDEPTHBUF )
1392
+ uniform float logDepthBufFC;
1393
+ varying float vFragDepth;
1394
+ varying float vIsPerspective;
1395
+ #endif`,Rp=`#ifdef USE_LOGDEPTHBUF
1396
+ varying float vFragDepth;
1397
+ varying float vIsPerspective;
1398
+ #endif`,Cp=`#ifdef USE_LOGDEPTHBUF
1399
+ vFragDepth = 1.0 + gl_Position.w;
1400
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1401
+ #endif`,Pp=`#ifdef USE_MAP
1402
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1403
+ #ifdef DECODE_VIDEO_TEXTURE
1404
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1405
+ #endif
1406
+ diffuseColor *= sampledDiffuseColor;
1407
+ #endif`,Lp=`#ifdef USE_MAP
1408
+ uniform sampler2D map;
1409
+ #endif`,Dp=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1410
+ #if defined( USE_POINTS_UV )
1411
+ vec2 uv = vUv;
1412
+ #else
1413
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1414
+ #endif
1415
+ #endif
1416
+ #ifdef USE_MAP
1417
+ diffuseColor *= texture2D( map, uv );
1418
+ #endif
1419
+ #ifdef USE_ALPHAMAP
1420
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1421
+ #endif`,Up=`#if defined( USE_POINTS_UV )
1422
+ varying vec2 vUv;
1423
+ #else
1424
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1425
+ uniform mat3 uvTransform;
1426
+ #endif
1427
+ #endif
1428
+ #ifdef USE_MAP
1429
+ uniform sampler2D map;
1430
+ #endif
1431
+ #ifdef USE_ALPHAMAP
1432
+ uniform sampler2D alphaMap;
1433
+ #endif`,Ip=`float metalnessFactor = metalness;
1434
+ #ifdef USE_METALNESSMAP
1435
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1436
+ metalnessFactor *= texelMetalness.b;
1437
+ #endif`,Np=`#ifdef USE_METALNESSMAP
1438
+ uniform sampler2D metalnessMap;
1439
+ #endif`,Fp=`#ifdef USE_INSTANCING_MORPH
1440
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1441
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1442
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1443
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1444
+ }
1445
+ #endif`,Op=`#if defined( USE_MORPHCOLORS )
1446
+ vColor *= morphTargetBaseInfluence;
1447
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1448
+ #if defined( USE_COLOR_ALPHA )
1449
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1450
+ #elif defined( USE_COLOR )
1451
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1452
+ #endif
1453
+ }
1454
+ #endif`,Bp=`#ifdef USE_MORPHNORMALS
1455
+ objectNormal *= morphTargetBaseInfluence;
1456
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1457
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1458
+ }
1459
+ #endif`,zp=`#ifdef USE_MORPHTARGETS
1460
+ #ifndef USE_INSTANCING_MORPH
1461
+ uniform float morphTargetBaseInfluence;
1462
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1463
+ #endif
1464
+ uniform sampler2DArray morphTargetsTexture;
1465
+ uniform ivec2 morphTargetsTextureSize;
1466
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1467
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1468
+ int y = texelIndex / morphTargetsTextureSize.x;
1469
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1470
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1471
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1472
+ }
1473
+ #endif`,Hp=`#ifdef USE_MORPHTARGETS
1474
+ transformed *= morphTargetBaseInfluence;
1475
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1476
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1477
+ }
1478
+ #endif`,kp=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1479
+ #ifdef FLAT_SHADED
1480
+ vec3 fdx = dFdx( vViewPosition );
1481
+ vec3 fdy = dFdy( vViewPosition );
1482
+ vec3 normal = normalize( cross( fdx, fdy ) );
1483
+ #else
1484
+ vec3 normal = normalize( vNormal );
1485
+ #ifdef DOUBLE_SIDED
1486
+ normal *= faceDirection;
1487
+ #endif
1488
+ #endif
1489
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1490
+ #ifdef USE_TANGENT
1491
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1492
+ #else
1493
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1494
+ #if defined( USE_NORMALMAP )
1495
+ vNormalMapUv
1496
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1497
+ vClearcoatNormalMapUv
1498
+ #else
1499
+ vUv
1500
+ #endif
1501
+ );
1502
+ #endif
1503
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1504
+ tbn[0] *= faceDirection;
1505
+ tbn[1] *= faceDirection;
1506
+ #endif
1507
+ #endif
1508
+ #ifdef USE_CLEARCOAT_NORMALMAP
1509
+ #ifdef USE_TANGENT
1510
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1511
+ #else
1512
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1513
+ #endif
1514
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1515
+ tbn2[0] *= faceDirection;
1516
+ tbn2[1] *= faceDirection;
1517
+ #endif
1518
+ #endif
1519
+ vec3 nonPerturbedNormal = normal;`,Gp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1520
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1521
+ #ifdef FLIP_SIDED
1522
+ normal = - normal;
1523
+ #endif
1524
+ #ifdef DOUBLE_SIDED
1525
+ normal = normal * faceDirection;
1526
+ #endif
1527
+ normal = normalize( normalMatrix * normal );
1528
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1529
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1530
+ mapN.xy *= normalScale;
1531
+ normal = normalize( tbn * mapN );
1532
+ #elif defined( USE_BUMPMAP )
1533
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1534
+ #endif`,Vp=`#ifndef FLAT_SHADED
1535
+ varying vec3 vNormal;
1536
+ #ifdef USE_TANGENT
1537
+ varying vec3 vTangent;
1538
+ varying vec3 vBitangent;
1539
+ #endif
1540
+ #endif`,Wp=`#ifndef FLAT_SHADED
1541
+ varying vec3 vNormal;
1542
+ #ifdef USE_TANGENT
1543
+ varying vec3 vTangent;
1544
+ varying vec3 vBitangent;
1545
+ #endif
1546
+ #endif`,Xp=`#ifndef FLAT_SHADED
1547
+ vNormal = normalize( transformedNormal );
1548
+ #ifdef USE_TANGENT
1549
+ vTangent = normalize( transformedTangent );
1550
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1551
+ #endif
1552
+ #endif`,qp=`#ifdef USE_NORMALMAP
1553
+ uniform sampler2D normalMap;
1554
+ uniform vec2 normalScale;
1555
+ #endif
1556
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1557
+ uniform mat3 normalMatrix;
1558
+ #endif
1559
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1560
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1561
+ vec3 q0 = dFdx( eye_pos.xyz );
1562
+ vec3 q1 = dFdy( eye_pos.xyz );
1563
+ vec2 st0 = dFdx( uv.st );
1564
+ vec2 st1 = dFdy( uv.st );
1565
+ vec3 N = surf_norm;
1566
+ vec3 q1perp = cross( q1, N );
1567
+ vec3 q0perp = cross( N, q0 );
1568
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1569
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1570
+ float det = max( dot( T, T ), dot( B, B ) );
1571
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1572
+ return mat3( T * scale, B * scale, N );
1573
+ }
1574
+ #endif`,Yp=`#ifdef USE_CLEARCOAT
1575
+ vec3 clearcoatNormal = nonPerturbedNormal;
1576
+ #endif`,Zp=`#ifdef USE_CLEARCOAT_NORMALMAP
1577
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1578
+ clearcoatMapN.xy *= clearcoatNormalScale;
1579
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1580
+ #endif`,Jp=`#ifdef USE_CLEARCOATMAP
1581
+ uniform sampler2D clearcoatMap;
1582
+ #endif
1583
+ #ifdef USE_CLEARCOAT_NORMALMAP
1584
+ uniform sampler2D clearcoatNormalMap;
1585
+ uniform vec2 clearcoatNormalScale;
1586
+ #endif
1587
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1588
+ uniform sampler2D clearcoatRoughnessMap;
1589
+ #endif`,Kp=`#ifdef USE_IRIDESCENCEMAP
1590
+ uniform sampler2D iridescenceMap;
1591
+ #endif
1592
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1593
+ uniform sampler2D iridescenceThicknessMap;
1594
+ #endif`,jp=`#ifdef OPAQUE
1595
+ diffuseColor.a = 1.0;
1596
+ #endif
1597
+ #ifdef USE_TRANSMISSION
1598
+ diffuseColor.a *= material.transmissionAlpha;
1599
+ #endif
1600
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,$p=`vec3 packNormalToRGB( const in vec3 normal ) {
1601
+ return normalize( normal ) * 0.5 + 0.5;
1602
+ }
1603
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1604
+ return 2.0 * rgb.xyz - 1.0;
1605
+ }
1606
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1607
+ const float Inv255 = 1. / 255.;
1608
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1609
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1610
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1611
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1612
+ vec4 packDepthToRGBA( const in float v ) {
1613
+ if( v <= 0.0 )
1614
+ return vec4( 0., 0., 0., 0. );
1615
+ if( v >= 1.0 )
1616
+ return vec4( 1., 1., 1., 1. );
1617
+ float vuf;
1618
+ float af = modf( v * PackFactors.a, vuf );
1619
+ float bf = modf( vuf * ShiftRight8, vuf );
1620
+ float gf = modf( vuf * ShiftRight8, vuf );
1621
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1622
+ }
1623
+ vec3 packDepthToRGB( const in float v ) {
1624
+ if( v <= 0.0 )
1625
+ return vec3( 0., 0., 0. );
1626
+ if( v >= 1.0 )
1627
+ return vec3( 1., 1., 1. );
1628
+ float vuf;
1629
+ float bf = modf( v * PackFactors.b, vuf );
1630
+ float gf = modf( vuf * ShiftRight8, vuf );
1631
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1632
+ }
1633
+ vec2 packDepthToRG( const in float v ) {
1634
+ if( v <= 0.0 )
1635
+ return vec2( 0., 0. );
1636
+ if( v >= 1.0 )
1637
+ return vec2( 1., 1. );
1638
+ float vuf;
1639
+ float gf = modf( v * 256., vuf );
1640
+ return vec2( vuf * Inv255, gf );
1641
+ }
1642
+ float unpackRGBAToDepth( const in vec4 v ) {
1643
+ return dot( v, UnpackFactors4 );
1644
+ }
1645
+ float unpackRGBToDepth( const in vec3 v ) {
1646
+ return dot( v, UnpackFactors3 );
1647
+ }
1648
+ float unpackRGToDepth( const in vec2 v ) {
1649
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1650
+ }
1651
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1652
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1653
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1654
+ }
1655
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1656
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1657
+ }
1658
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1659
+ return ( viewZ + near ) / ( near - far );
1660
+ }
1661
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1662
+ return depth * ( near - far ) - near;
1663
+ }
1664
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1665
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1666
+ }
1667
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1668
+ return ( near * far ) / ( ( far - near ) * depth - far );
1669
+ }`,Qp=`#ifdef PREMULTIPLIED_ALPHA
1670
+ gl_FragColor.rgb *= gl_FragColor.a;
1671
+ #endif`,tm=`vec4 mvPosition = vec4( transformed, 1.0 );
1672
+ #ifdef USE_BATCHING
1673
+ mvPosition = batchingMatrix * mvPosition;
1674
+ #endif
1675
+ #ifdef USE_INSTANCING
1676
+ mvPosition = instanceMatrix * mvPosition;
1677
+ #endif
1678
+ mvPosition = modelViewMatrix * mvPosition;
1679
+ gl_Position = projectionMatrix * mvPosition;`,em=`#ifdef DITHERING
1680
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1681
+ #endif`,nm=`#ifdef DITHERING
1682
+ vec3 dithering( vec3 color ) {
1683
+ float grid_position = rand( gl_FragCoord.xy );
1684
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1685
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1686
+ return color + dither_shift_RGB;
1687
+ }
1688
+ #endif`,im=`float roughnessFactor = roughness;
1689
+ #ifdef USE_ROUGHNESSMAP
1690
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1691
+ roughnessFactor *= texelRoughness.g;
1692
+ #endif`,rm=`#ifdef USE_ROUGHNESSMAP
1693
+ uniform sampler2D roughnessMap;
1694
+ #endif`,sm=`#if NUM_SPOT_LIGHT_COORDS > 0
1695
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1696
+ #endif
1697
+ #if NUM_SPOT_LIGHT_MAPS > 0
1698
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1699
+ #endif
1700
+ #ifdef USE_SHADOWMAP
1701
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1702
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1703
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1704
+ struct DirectionalLightShadow {
1705
+ float shadowIntensity;
1706
+ float shadowBias;
1707
+ float shadowNormalBias;
1708
+ float shadowRadius;
1709
+ vec2 shadowMapSize;
1710
+ };
1711
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1712
+ #endif
1713
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1714
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1715
+ struct SpotLightShadow {
1716
+ float shadowIntensity;
1717
+ float shadowBias;
1718
+ float shadowNormalBias;
1719
+ float shadowRadius;
1720
+ vec2 shadowMapSize;
1721
+ };
1722
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1723
+ #endif
1724
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1725
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1726
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1727
+ struct PointLightShadow {
1728
+ float shadowIntensity;
1729
+ float shadowBias;
1730
+ float shadowNormalBias;
1731
+ float shadowRadius;
1732
+ vec2 shadowMapSize;
1733
+ float shadowCameraNear;
1734
+ float shadowCameraFar;
1735
+ };
1736
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1737
+ #endif
1738
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1739
+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1740
+ }
1741
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1742
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1743
+ }
1744
+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1745
+ float occlusion = 1.0;
1746
+ vec2 distribution = texture2DDistribution( shadow, uv );
1747
+ float hard_shadow = step( compare , distribution.x );
1748
+ if (hard_shadow != 1.0 ) {
1749
+ float distance = compare - distribution.x ;
1750
+ float variance = max( 0.00000, distribution.y * distribution.y );
1751
+ 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 );
1752
+ }
1753
+ return occlusion;
1754
+ }
1755
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1756
+ float shadow = 1.0;
1757
+ shadowCoord.xyz /= shadowCoord.w;
1758
+ shadowCoord.z += shadowBias;
1759
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1760
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1761
+ if ( frustumTest ) {
1762
+ #if defined( SHADOWMAP_TYPE_PCF )
1763
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1764
+ float dx0 = - texelSize.x * shadowRadius;
1765
+ float dy0 = - texelSize.y * shadowRadius;
1766
+ float dx1 = + texelSize.x * shadowRadius;
1767
+ float dy1 = + texelSize.y * shadowRadius;
1768
+ float dx2 = dx0 / 2.0;
1769
+ float dy2 = dy0 / 2.0;
1770
+ float dx3 = dx1 / 2.0;
1771
+ float dy3 = dy1 / 2.0;
1772
+ shadow = (
1773
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1774
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1775
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1776
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1777
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1778
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1779
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1780
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1781
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1782
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1783
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1784
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1785
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1786
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1787
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1788
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1789
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1790
+ ) * ( 1.0 / 17.0 );
1791
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1792
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1793
+ float dx = texelSize.x;
1794
+ float dy = texelSize.y;
1795
+ vec2 uv = shadowCoord.xy;
1796
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1797
+ uv -= f * texelSize;
1798
+ shadow = (
1799
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1800
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1801
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1802
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1803
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1804
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1805
+ f.x ) +
1806
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1807
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1808
+ f.x ) +
1809
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1810
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1811
+ f.y ) +
1812
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1813
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1814
+ f.y ) +
1815
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1816
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1817
+ f.x ),
1818
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1819
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1820
+ f.x ),
1821
+ f.y )
1822
+ ) * ( 1.0 / 9.0 );
1823
+ #elif defined( SHADOWMAP_TYPE_VSM )
1824
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1825
+ #else
1826
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1827
+ #endif
1828
+ }
1829
+ return mix( 1.0, shadow, shadowIntensity );
1830
+ }
1831
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1832
+ vec3 absV = abs( v );
1833
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1834
+ absV *= scaleToCube;
1835
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1836
+ vec2 planar = v.xy;
1837
+ float almostATexel = 1.5 * texelSizeY;
1838
+ float almostOne = 1.0 - almostATexel;
1839
+ if ( absV.z >= almostOne ) {
1840
+ if ( v.z > 0.0 )
1841
+ planar.x = 4.0 - v.x;
1842
+ } else if ( absV.x >= almostOne ) {
1843
+ float signX = sign( v.x );
1844
+ planar.x = v.z * signX + 2.0 * signX;
1845
+ } else if ( absV.y >= almostOne ) {
1846
+ float signY = sign( v.y );
1847
+ planar.x = v.x + 2.0 * signY + 2.0;
1848
+ planar.y = v.z * signY - 2.0;
1849
+ }
1850
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1851
+ }
1852
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1853
+ float shadow = 1.0;
1854
+ vec3 lightToPosition = shadowCoord.xyz;
1855
+
1856
+ float lightToPositionLength = length( lightToPosition );
1857
+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1858
+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1859
+ vec3 bd3D = normalize( lightToPosition );
1860
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1861
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1862
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1863
+ shadow = (
1864
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1865
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1866
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1867
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1868
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1869
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1870
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1871
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1872
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1873
+ ) * ( 1.0 / 9.0 );
1874
+ #else
1875
+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1876
+ #endif
1877
+ }
1878
+ return mix( 1.0, shadow, shadowIntensity );
1879
+ }
1880
+ #endif`,om=`#if NUM_SPOT_LIGHT_COORDS > 0
1881
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1882
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1883
+ #endif
1884
+ #ifdef USE_SHADOWMAP
1885
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1886
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1887
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1888
+ struct DirectionalLightShadow {
1889
+ float shadowIntensity;
1890
+ float shadowBias;
1891
+ float shadowNormalBias;
1892
+ float shadowRadius;
1893
+ vec2 shadowMapSize;
1894
+ };
1895
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1896
+ #endif
1897
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1898
+ struct SpotLightShadow {
1899
+ float shadowIntensity;
1900
+ float shadowBias;
1901
+ float shadowNormalBias;
1902
+ float shadowRadius;
1903
+ vec2 shadowMapSize;
1904
+ };
1905
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1906
+ #endif
1907
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1908
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1909
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1910
+ struct PointLightShadow {
1911
+ float shadowIntensity;
1912
+ float shadowBias;
1913
+ float shadowNormalBias;
1914
+ float shadowRadius;
1915
+ vec2 shadowMapSize;
1916
+ float shadowCameraNear;
1917
+ float shadowCameraFar;
1918
+ };
1919
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1920
+ #endif
1921
+ #endif`,am=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1922
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1923
+ vec4 shadowWorldPosition;
1924
+ #endif
1925
+ #if defined( USE_SHADOWMAP )
1926
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1927
+ #pragma unroll_loop_start
1928
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1929
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1930
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1931
+ }
1932
+ #pragma unroll_loop_end
1933
+ #endif
1934
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1935
+ #pragma unroll_loop_start
1936
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1937
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1938
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1939
+ }
1940
+ #pragma unroll_loop_end
1941
+ #endif
1942
+ #endif
1943
+ #if NUM_SPOT_LIGHT_COORDS > 0
1944
+ #pragma unroll_loop_start
1945
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1946
+ shadowWorldPosition = worldPosition;
1947
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1948
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1949
+ #endif
1950
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1951
+ }
1952
+ #pragma unroll_loop_end
1953
+ #endif`,cm=`float getShadowMask() {
1954
+ float shadow = 1.0;
1955
+ #ifdef USE_SHADOWMAP
1956
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1957
+ DirectionalLightShadow directionalLight;
1958
+ #pragma unroll_loop_start
1959
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1960
+ directionalLight = directionalLightShadows[ i ];
1961
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1962
+ }
1963
+ #pragma unroll_loop_end
1964
+ #endif
1965
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1966
+ SpotLightShadow spotLight;
1967
+ #pragma unroll_loop_start
1968
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1969
+ spotLight = spotLightShadows[ i ];
1970
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1971
+ }
1972
+ #pragma unroll_loop_end
1973
+ #endif
1974
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1975
+ PointLightShadow pointLight;
1976
+ #pragma unroll_loop_start
1977
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1978
+ pointLight = pointLightShadows[ i ];
1979
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1980
+ }
1981
+ #pragma unroll_loop_end
1982
+ #endif
1983
+ #endif
1984
+ return shadow;
1985
+ }`,lm=`#ifdef USE_SKINNING
1986
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1987
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1988
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1989
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1990
+ #endif`,um=`#ifdef USE_SKINNING
1991
+ uniform mat4 bindMatrix;
1992
+ uniform mat4 bindMatrixInverse;
1993
+ uniform highp sampler2D boneTexture;
1994
+ mat4 getBoneMatrix( const in float i ) {
1995
+ int size = textureSize( boneTexture, 0 ).x;
1996
+ int j = int( i ) * 4;
1997
+ int x = j % size;
1998
+ int y = j / size;
1999
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
2000
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
2001
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2002
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2003
+ return mat4( v1, v2, v3, v4 );
2004
+ }
2005
+ #endif`,hm=`#ifdef USE_SKINNING
2006
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2007
+ vec4 skinned = vec4( 0.0 );
2008
+ skinned += boneMatX * skinVertex * skinWeight.x;
2009
+ skinned += boneMatY * skinVertex * skinWeight.y;
2010
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2011
+ skinned += boneMatW * skinVertex * skinWeight.w;
2012
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2013
+ #endif`,fm=`#ifdef USE_SKINNING
2014
+ mat4 skinMatrix = mat4( 0.0 );
2015
+ skinMatrix += skinWeight.x * boneMatX;
2016
+ skinMatrix += skinWeight.y * boneMatY;
2017
+ skinMatrix += skinWeight.z * boneMatZ;
2018
+ skinMatrix += skinWeight.w * boneMatW;
2019
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2020
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2021
+ #ifdef USE_TANGENT
2022
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2023
+ #endif
2024
+ #endif`,dm=`float specularStrength;
2025
+ #ifdef USE_SPECULARMAP
2026
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2027
+ specularStrength = texelSpecular.r;
2028
+ #else
2029
+ specularStrength = 1.0;
2030
+ #endif`,pm=`#ifdef USE_SPECULARMAP
2031
+ uniform sampler2D specularMap;
2032
+ #endif`,mm=`#if defined( TONE_MAPPING )
2033
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2034
+ #endif`,gm=`#ifndef saturate
2035
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2036
+ #endif
2037
+ uniform float toneMappingExposure;
2038
+ vec3 LinearToneMapping( vec3 color ) {
2039
+ return saturate( toneMappingExposure * color );
2040
+ }
2041
+ vec3 ReinhardToneMapping( vec3 color ) {
2042
+ color *= toneMappingExposure;
2043
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2044
+ }
2045
+ vec3 CineonToneMapping( vec3 color ) {
2046
+ color *= toneMappingExposure;
2047
+ color = max( vec3( 0.0 ), color - 0.004 );
2048
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2049
+ }
2050
+ vec3 RRTAndODTFit( vec3 v ) {
2051
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2052
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2053
+ return a / b;
2054
+ }
2055
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2056
+ const mat3 ACESInputMat = mat3(
2057
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2058
+ vec3( 0.04823, 0.01566, 0.83777 )
2059
+ );
2060
+ const mat3 ACESOutputMat = mat3(
2061
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2062
+ vec3( -0.07367, -0.00605, 1.07602 )
2063
+ );
2064
+ color *= toneMappingExposure / 0.6;
2065
+ color = ACESInputMat * color;
2066
+ color = RRTAndODTFit( color );
2067
+ color = ACESOutputMat * color;
2068
+ return saturate( color );
2069
+ }
2070
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2071
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2072
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2073
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2074
+ );
2075
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2076
+ vec3( 0.6274, 0.0691, 0.0164 ),
2077
+ vec3( 0.3293, 0.9195, 0.0880 ),
2078
+ vec3( 0.0433, 0.0113, 0.8956 )
2079
+ );
2080
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2081
+ vec3 x2 = x * x;
2082
+ vec3 x4 = x2 * x2;
2083
+ return + 15.5 * x4 * x2
2084
+ - 40.14 * x4 * x
2085
+ + 31.96 * x4
2086
+ - 6.868 * x2 * x
2087
+ + 0.4298 * x2
2088
+ + 0.1191 * x
2089
+ - 0.00232;
2090
+ }
2091
+ vec3 AgXToneMapping( vec3 color ) {
2092
+ const mat3 AgXInsetMatrix = mat3(
2093
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2094
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2095
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2096
+ );
2097
+ const mat3 AgXOutsetMatrix = mat3(
2098
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2099
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2100
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2101
+ );
2102
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2103
+ color *= toneMappingExposure;
2104
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2105
+ color = AgXInsetMatrix * color;
2106
+ color = max( color, 1e-10 ); color = log2( color );
2107
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2108
+ color = clamp( color, 0.0, 1.0 );
2109
+ color = agxDefaultContrastApprox( color );
2110
+ color = AgXOutsetMatrix * color;
2111
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2112
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2113
+ color = clamp( color, 0.0, 1.0 );
2114
+ return color;
2115
+ }
2116
+ vec3 NeutralToneMapping( vec3 color ) {
2117
+ const float StartCompression = 0.8 - 0.04;
2118
+ const float Desaturation = 0.15;
2119
+ color *= toneMappingExposure;
2120
+ float x = min( color.r, min( color.g, color.b ) );
2121
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2122
+ color -= offset;
2123
+ float peak = max( color.r, max( color.g, color.b ) );
2124
+ if ( peak < StartCompression ) return color;
2125
+ float d = 1. - StartCompression;
2126
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2127
+ color *= newPeak / peak;
2128
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2129
+ return mix( color, vec3( newPeak ), g );
2130
+ }
2131
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,_m=`#ifdef USE_TRANSMISSION
2132
+ material.transmission = transmission;
2133
+ material.transmissionAlpha = 1.0;
2134
+ material.thickness = thickness;
2135
+ material.attenuationDistance = attenuationDistance;
2136
+ material.attenuationColor = attenuationColor;
2137
+ #ifdef USE_TRANSMISSIONMAP
2138
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2139
+ #endif
2140
+ #ifdef USE_THICKNESSMAP
2141
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2142
+ #endif
2143
+ vec3 pos = vWorldPosition;
2144
+ vec3 v = normalize( cameraPosition - pos );
2145
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2146
+ vec4 transmitted = getIBLVolumeRefraction(
2147
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2148
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2149
+ material.attenuationColor, material.attenuationDistance );
2150
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2151
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2152
+ #endif`,vm=`#ifdef USE_TRANSMISSION
2153
+ uniform float transmission;
2154
+ uniform float thickness;
2155
+ uniform float attenuationDistance;
2156
+ uniform vec3 attenuationColor;
2157
+ #ifdef USE_TRANSMISSIONMAP
2158
+ uniform sampler2D transmissionMap;
2159
+ #endif
2160
+ #ifdef USE_THICKNESSMAP
2161
+ uniform sampler2D thicknessMap;
2162
+ #endif
2163
+ uniform vec2 transmissionSamplerSize;
2164
+ uniform sampler2D transmissionSamplerMap;
2165
+ uniform mat4 modelMatrix;
2166
+ uniform mat4 projectionMatrix;
2167
+ varying vec3 vWorldPosition;
2168
+ float w0( float a ) {
2169
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2170
+ }
2171
+ float w1( float a ) {
2172
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2173
+ }
2174
+ float w2( float a ){
2175
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2176
+ }
2177
+ float w3( float a ) {
2178
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2179
+ }
2180
+ float g0( float a ) {
2181
+ return w0( a ) + w1( a );
2182
+ }
2183
+ float g1( float a ) {
2184
+ return w2( a ) + w3( a );
2185
+ }
2186
+ float h0( float a ) {
2187
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2188
+ }
2189
+ float h1( float a ) {
2190
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2191
+ }
2192
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2193
+ uv = uv * texelSize.zw + 0.5;
2194
+ vec2 iuv = floor( uv );
2195
+ vec2 fuv = fract( uv );
2196
+ float g0x = g0( fuv.x );
2197
+ float g1x = g1( fuv.x );
2198
+ float h0x = h0( fuv.x );
2199
+ float h1x = h1( fuv.x );
2200
+ float h0y = h0( fuv.y );
2201
+ float h1y = h1( fuv.y );
2202
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2203
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2204
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2205
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2206
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2207
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2208
+ }
2209
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2210
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2211
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2212
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2213
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2214
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2215
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2216
+ return mix( fSample, cSample, fract( lod ) );
2217
+ }
2218
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2219
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2220
+ vec3 modelScale;
2221
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2222
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2223
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2224
+ return normalize( refractionVector ) * thickness * modelScale;
2225
+ }
2226
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2227
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2228
+ }
2229
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2230
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2231
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2232
+ }
2233
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2234
+ if ( isinf( attenuationDistance ) ) {
2235
+ return vec3( 1.0 );
2236
+ } else {
2237
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2238
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2239
+ }
2240
+ }
2241
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2242
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2243
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2244
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2245
+ vec4 transmittedLight;
2246
+ vec3 transmittance;
2247
+ #ifdef USE_DISPERSION
2248
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2249
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2250
+ for ( int i = 0; i < 3; i ++ ) {
2251
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2252
+ vec3 refractedRayExit = position + transmissionRay;
2253
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2254
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2255
+ refractionCoords += 1.0;
2256
+ refractionCoords /= 2.0;
2257
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2258
+ transmittedLight[ i ] = transmissionSample[ i ];
2259
+ transmittedLight.a += transmissionSample.a;
2260
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2261
+ }
2262
+ transmittedLight.a /= 3.0;
2263
+ #else
2264
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2265
+ vec3 refractedRayExit = position + transmissionRay;
2266
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2267
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2268
+ refractionCoords += 1.0;
2269
+ refractionCoords /= 2.0;
2270
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2271
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2272
+ #endif
2273
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2274
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2275
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2276
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2277
+ }
2278
+ #endif`,xm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2279
+ varying vec2 vUv;
2280
+ #endif
2281
+ #ifdef USE_MAP
2282
+ varying vec2 vMapUv;
2283
+ #endif
2284
+ #ifdef USE_ALPHAMAP
2285
+ varying vec2 vAlphaMapUv;
2286
+ #endif
2287
+ #ifdef USE_LIGHTMAP
2288
+ varying vec2 vLightMapUv;
2289
+ #endif
2290
+ #ifdef USE_AOMAP
2291
+ varying vec2 vAoMapUv;
2292
+ #endif
2293
+ #ifdef USE_BUMPMAP
2294
+ varying vec2 vBumpMapUv;
2295
+ #endif
2296
+ #ifdef USE_NORMALMAP
2297
+ varying vec2 vNormalMapUv;
2298
+ #endif
2299
+ #ifdef USE_EMISSIVEMAP
2300
+ varying vec2 vEmissiveMapUv;
2301
+ #endif
2302
+ #ifdef USE_METALNESSMAP
2303
+ varying vec2 vMetalnessMapUv;
2304
+ #endif
2305
+ #ifdef USE_ROUGHNESSMAP
2306
+ varying vec2 vRoughnessMapUv;
2307
+ #endif
2308
+ #ifdef USE_ANISOTROPYMAP
2309
+ varying vec2 vAnisotropyMapUv;
2310
+ #endif
2311
+ #ifdef USE_CLEARCOATMAP
2312
+ varying vec2 vClearcoatMapUv;
2313
+ #endif
2314
+ #ifdef USE_CLEARCOAT_NORMALMAP
2315
+ varying vec2 vClearcoatNormalMapUv;
2316
+ #endif
2317
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2318
+ varying vec2 vClearcoatRoughnessMapUv;
2319
+ #endif
2320
+ #ifdef USE_IRIDESCENCEMAP
2321
+ varying vec2 vIridescenceMapUv;
2322
+ #endif
2323
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2324
+ varying vec2 vIridescenceThicknessMapUv;
2325
+ #endif
2326
+ #ifdef USE_SHEEN_COLORMAP
2327
+ varying vec2 vSheenColorMapUv;
2328
+ #endif
2329
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2330
+ varying vec2 vSheenRoughnessMapUv;
2331
+ #endif
2332
+ #ifdef USE_SPECULARMAP
2333
+ varying vec2 vSpecularMapUv;
2334
+ #endif
2335
+ #ifdef USE_SPECULAR_COLORMAP
2336
+ varying vec2 vSpecularColorMapUv;
2337
+ #endif
2338
+ #ifdef USE_SPECULAR_INTENSITYMAP
2339
+ varying vec2 vSpecularIntensityMapUv;
2340
+ #endif
2341
+ #ifdef USE_TRANSMISSIONMAP
2342
+ uniform mat3 transmissionMapTransform;
2343
+ varying vec2 vTransmissionMapUv;
2344
+ #endif
2345
+ #ifdef USE_THICKNESSMAP
2346
+ uniform mat3 thicknessMapTransform;
2347
+ varying vec2 vThicknessMapUv;
2348
+ #endif`,Mm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2349
+ varying vec2 vUv;
2350
+ #endif
2351
+ #ifdef USE_MAP
2352
+ uniform mat3 mapTransform;
2353
+ varying vec2 vMapUv;
2354
+ #endif
2355
+ #ifdef USE_ALPHAMAP
2356
+ uniform mat3 alphaMapTransform;
2357
+ varying vec2 vAlphaMapUv;
2358
+ #endif
2359
+ #ifdef USE_LIGHTMAP
2360
+ uniform mat3 lightMapTransform;
2361
+ varying vec2 vLightMapUv;
2362
+ #endif
2363
+ #ifdef USE_AOMAP
2364
+ uniform mat3 aoMapTransform;
2365
+ varying vec2 vAoMapUv;
2366
+ #endif
2367
+ #ifdef USE_BUMPMAP
2368
+ uniform mat3 bumpMapTransform;
2369
+ varying vec2 vBumpMapUv;
2370
+ #endif
2371
+ #ifdef USE_NORMALMAP
2372
+ uniform mat3 normalMapTransform;
2373
+ varying vec2 vNormalMapUv;
2374
+ #endif
2375
+ #ifdef USE_DISPLACEMENTMAP
2376
+ uniform mat3 displacementMapTransform;
2377
+ varying vec2 vDisplacementMapUv;
2378
+ #endif
2379
+ #ifdef USE_EMISSIVEMAP
2380
+ uniform mat3 emissiveMapTransform;
2381
+ varying vec2 vEmissiveMapUv;
2382
+ #endif
2383
+ #ifdef USE_METALNESSMAP
2384
+ uniform mat3 metalnessMapTransform;
2385
+ varying vec2 vMetalnessMapUv;
2386
+ #endif
2387
+ #ifdef USE_ROUGHNESSMAP
2388
+ uniform mat3 roughnessMapTransform;
2389
+ varying vec2 vRoughnessMapUv;
2390
+ #endif
2391
+ #ifdef USE_ANISOTROPYMAP
2392
+ uniform mat3 anisotropyMapTransform;
2393
+ varying vec2 vAnisotropyMapUv;
2394
+ #endif
2395
+ #ifdef USE_CLEARCOATMAP
2396
+ uniform mat3 clearcoatMapTransform;
2397
+ varying vec2 vClearcoatMapUv;
2398
+ #endif
2399
+ #ifdef USE_CLEARCOAT_NORMALMAP
2400
+ uniform mat3 clearcoatNormalMapTransform;
2401
+ varying vec2 vClearcoatNormalMapUv;
2402
+ #endif
2403
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2404
+ uniform mat3 clearcoatRoughnessMapTransform;
2405
+ varying vec2 vClearcoatRoughnessMapUv;
2406
+ #endif
2407
+ #ifdef USE_SHEEN_COLORMAP
2408
+ uniform mat3 sheenColorMapTransform;
2409
+ varying vec2 vSheenColorMapUv;
2410
+ #endif
2411
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2412
+ uniform mat3 sheenRoughnessMapTransform;
2413
+ varying vec2 vSheenRoughnessMapUv;
2414
+ #endif
2415
+ #ifdef USE_IRIDESCENCEMAP
2416
+ uniform mat3 iridescenceMapTransform;
2417
+ varying vec2 vIridescenceMapUv;
2418
+ #endif
2419
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2420
+ uniform mat3 iridescenceThicknessMapTransform;
2421
+ varying vec2 vIridescenceThicknessMapUv;
2422
+ #endif
2423
+ #ifdef USE_SPECULARMAP
2424
+ uniform mat3 specularMapTransform;
2425
+ varying vec2 vSpecularMapUv;
2426
+ #endif
2427
+ #ifdef USE_SPECULAR_COLORMAP
2428
+ uniform mat3 specularColorMapTransform;
2429
+ varying vec2 vSpecularColorMapUv;
2430
+ #endif
2431
+ #ifdef USE_SPECULAR_INTENSITYMAP
2432
+ uniform mat3 specularIntensityMapTransform;
2433
+ varying vec2 vSpecularIntensityMapUv;
2434
+ #endif
2435
+ #ifdef USE_TRANSMISSIONMAP
2436
+ uniform mat3 transmissionMapTransform;
2437
+ varying vec2 vTransmissionMapUv;
2438
+ #endif
2439
+ #ifdef USE_THICKNESSMAP
2440
+ uniform mat3 thicknessMapTransform;
2441
+ varying vec2 vThicknessMapUv;
2442
+ #endif`,Sm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2443
+ vUv = vec3( uv, 1 ).xy;
2444
+ #endif
2445
+ #ifdef USE_MAP
2446
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2447
+ #endif
2448
+ #ifdef USE_ALPHAMAP
2449
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2450
+ #endif
2451
+ #ifdef USE_LIGHTMAP
2452
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2453
+ #endif
2454
+ #ifdef USE_AOMAP
2455
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2456
+ #endif
2457
+ #ifdef USE_BUMPMAP
2458
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2459
+ #endif
2460
+ #ifdef USE_NORMALMAP
2461
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2462
+ #endif
2463
+ #ifdef USE_DISPLACEMENTMAP
2464
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2465
+ #endif
2466
+ #ifdef USE_EMISSIVEMAP
2467
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2468
+ #endif
2469
+ #ifdef USE_METALNESSMAP
2470
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2471
+ #endif
2472
+ #ifdef USE_ROUGHNESSMAP
2473
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2474
+ #endif
2475
+ #ifdef USE_ANISOTROPYMAP
2476
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2477
+ #endif
2478
+ #ifdef USE_CLEARCOATMAP
2479
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2480
+ #endif
2481
+ #ifdef USE_CLEARCOAT_NORMALMAP
2482
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2483
+ #endif
2484
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2485
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2486
+ #endif
2487
+ #ifdef USE_IRIDESCENCEMAP
2488
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2489
+ #endif
2490
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2491
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2492
+ #endif
2493
+ #ifdef USE_SHEEN_COLORMAP
2494
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2495
+ #endif
2496
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2497
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2498
+ #endif
2499
+ #ifdef USE_SPECULARMAP
2500
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2501
+ #endif
2502
+ #ifdef USE_SPECULAR_COLORMAP
2503
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2504
+ #endif
2505
+ #ifdef USE_SPECULAR_INTENSITYMAP
2506
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2507
+ #endif
2508
+ #ifdef USE_TRANSMISSIONMAP
2509
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2510
+ #endif
2511
+ #ifdef USE_THICKNESSMAP
2512
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2513
+ #endif`,ym=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2514
+ vec4 worldPosition = vec4( transformed, 1.0 );
2515
+ #ifdef USE_BATCHING
2516
+ worldPosition = batchingMatrix * worldPosition;
2517
+ #endif
2518
+ #ifdef USE_INSTANCING
2519
+ worldPosition = instanceMatrix * worldPosition;
2520
+ #endif
2521
+ worldPosition = modelMatrix * worldPosition;
2522
+ #endif`;const Em=`varying vec2 vUv;
2523
+ uniform mat3 uvTransform;
2524
+ void main() {
2525
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2526
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2527
+ }`,Tm=`uniform sampler2D t2D;
2528
+ uniform float backgroundIntensity;
2529
+ varying vec2 vUv;
2530
+ void main() {
2531
+ vec4 texColor = texture2D( t2D, vUv );
2532
+ #ifdef DECODE_VIDEO_TEXTURE
2533
+ 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 );
2534
+ #endif
2535
+ texColor.rgb *= backgroundIntensity;
2536
+ gl_FragColor = texColor;
2537
+ #include <tonemapping_fragment>
2538
+ #include <colorspace_fragment>
2539
+ }`,Am=`varying vec3 vWorldDirection;
2540
+ #include <common>
2541
+ void main() {
2542
+ vWorldDirection = transformDirection( position, modelMatrix );
2543
+ #include <begin_vertex>
2544
+ #include <project_vertex>
2545
+ gl_Position.z = gl_Position.w;
2546
+ }`,bm=`#ifdef ENVMAP_TYPE_CUBE
2547
+ uniform samplerCube envMap;
2548
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2549
+ uniform sampler2D envMap;
2550
+ #endif
2551
+ uniform float flipEnvMap;
2552
+ uniform float backgroundBlurriness;
2553
+ uniform float backgroundIntensity;
2554
+ uniform mat3 backgroundRotation;
2555
+ varying vec3 vWorldDirection;
2556
+ #include <cube_uv_reflection_fragment>
2557
+ void main() {
2558
+ #ifdef ENVMAP_TYPE_CUBE
2559
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2560
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2561
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2562
+ #else
2563
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2564
+ #endif
2565
+ texColor.rgb *= backgroundIntensity;
2566
+ gl_FragColor = texColor;
2567
+ #include <tonemapping_fragment>
2568
+ #include <colorspace_fragment>
2569
+ }`,wm=`varying vec3 vWorldDirection;
2570
+ #include <common>
2571
+ void main() {
2572
+ vWorldDirection = transformDirection( position, modelMatrix );
2573
+ #include <begin_vertex>
2574
+ #include <project_vertex>
2575
+ gl_Position.z = gl_Position.w;
2576
+ }`,Rm=`uniform samplerCube tCube;
2577
+ uniform float tFlip;
2578
+ uniform float opacity;
2579
+ varying vec3 vWorldDirection;
2580
+ void main() {
2581
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2582
+ gl_FragColor = texColor;
2583
+ gl_FragColor.a *= opacity;
2584
+ #include <tonemapping_fragment>
2585
+ #include <colorspace_fragment>
2586
+ }`,Cm=`#include <common>
2587
+ #include <batching_pars_vertex>
2588
+ #include <uv_pars_vertex>
2589
+ #include <displacementmap_pars_vertex>
2590
+ #include <morphtarget_pars_vertex>
2591
+ #include <skinning_pars_vertex>
2592
+ #include <logdepthbuf_pars_vertex>
2593
+ #include <clipping_planes_pars_vertex>
2594
+ varying vec2 vHighPrecisionZW;
2595
+ void main() {
2596
+ #include <uv_vertex>
2597
+ #include <batching_vertex>
2598
+ #include <skinbase_vertex>
2599
+ #include <morphinstance_vertex>
2600
+ #ifdef USE_DISPLACEMENTMAP
2601
+ #include <beginnormal_vertex>
2602
+ #include <morphnormal_vertex>
2603
+ #include <skinnormal_vertex>
2604
+ #endif
2605
+ #include <begin_vertex>
2606
+ #include <morphtarget_vertex>
2607
+ #include <skinning_vertex>
2608
+ #include <displacementmap_vertex>
2609
+ #include <project_vertex>
2610
+ #include <logdepthbuf_vertex>
2611
+ #include <clipping_planes_vertex>
2612
+ vHighPrecisionZW = gl_Position.zw;
2613
+ }`,Pm=`#if DEPTH_PACKING == 3200
2614
+ uniform float opacity;
2615
+ #endif
2616
+ #include <common>
2617
+ #include <packing>
2618
+ #include <uv_pars_fragment>
2619
+ #include <map_pars_fragment>
2620
+ #include <alphamap_pars_fragment>
2621
+ #include <alphatest_pars_fragment>
2622
+ #include <alphahash_pars_fragment>
2623
+ #include <logdepthbuf_pars_fragment>
2624
+ #include <clipping_planes_pars_fragment>
2625
+ varying vec2 vHighPrecisionZW;
2626
+ void main() {
2627
+ vec4 diffuseColor = vec4( 1.0 );
2628
+ #include <clipping_planes_fragment>
2629
+ #if DEPTH_PACKING == 3200
2630
+ diffuseColor.a = opacity;
2631
+ #endif
2632
+ #include <map_fragment>
2633
+ #include <alphamap_fragment>
2634
+ #include <alphatest_fragment>
2635
+ #include <alphahash_fragment>
2636
+ #include <logdepthbuf_fragment>
2637
+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2638
+ #if DEPTH_PACKING == 3200
2639
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2640
+ #elif DEPTH_PACKING == 3201
2641
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2642
+ #elif DEPTH_PACKING == 3202
2643
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2644
+ #elif DEPTH_PACKING == 3203
2645
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2646
+ #endif
2647
+ }`,Lm=`#define DISTANCE
2648
+ varying vec3 vWorldPosition;
2649
+ #include <common>
2650
+ #include <batching_pars_vertex>
2651
+ #include <uv_pars_vertex>
2652
+ #include <displacementmap_pars_vertex>
2653
+ #include <morphtarget_pars_vertex>
2654
+ #include <skinning_pars_vertex>
2655
+ #include <clipping_planes_pars_vertex>
2656
+ void main() {
2657
+ #include <uv_vertex>
2658
+ #include <batching_vertex>
2659
+ #include <skinbase_vertex>
2660
+ #include <morphinstance_vertex>
2661
+ #ifdef USE_DISPLACEMENTMAP
2662
+ #include <beginnormal_vertex>
2663
+ #include <morphnormal_vertex>
2664
+ #include <skinnormal_vertex>
2665
+ #endif
2666
+ #include <begin_vertex>
2667
+ #include <morphtarget_vertex>
2668
+ #include <skinning_vertex>
2669
+ #include <displacementmap_vertex>
2670
+ #include <project_vertex>
2671
+ #include <worldpos_vertex>
2672
+ #include <clipping_planes_vertex>
2673
+ vWorldPosition = worldPosition.xyz;
2674
+ }`,Dm=`#define DISTANCE
2675
+ uniform vec3 referencePosition;
2676
+ uniform float nearDistance;
2677
+ uniform float farDistance;
2678
+ varying vec3 vWorldPosition;
2679
+ #include <common>
2680
+ #include <packing>
2681
+ #include <uv_pars_fragment>
2682
+ #include <map_pars_fragment>
2683
+ #include <alphamap_pars_fragment>
2684
+ #include <alphatest_pars_fragment>
2685
+ #include <alphahash_pars_fragment>
2686
+ #include <clipping_planes_pars_fragment>
2687
+ void main () {
2688
+ vec4 diffuseColor = vec4( 1.0 );
2689
+ #include <clipping_planes_fragment>
2690
+ #include <map_fragment>
2691
+ #include <alphamap_fragment>
2692
+ #include <alphatest_fragment>
2693
+ #include <alphahash_fragment>
2694
+ float dist = length( vWorldPosition - referencePosition );
2695
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2696
+ dist = saturate( dist );
2697
+ gl_FragColor = packDepthToRGBA( dist );
2698
+ }`,Um=`varying vec3 vWorldDirection;
2699
+ #include <common>
2700
+ void main() {
2701
+ vWorldDirection = transformDirection( position, modelMatrix );
2702
+ #include <begin_vertex>
2703
+ #include <project_vertex>
2704
+ }`,Im=`uniform sampler2D tEquirect;
2705
+ varying vec3 vWorldDirection;
2706
+ #include <common>
2707
+ void main() {
2708
+ vec3 direction = normalize( vWorldDirection );
2709
+ vec2 sampleUV = equirectUv( direction );
2710
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2711
+ #include <tonemapping_fragment>
2712
+ #include <colorspace_fragment>
2713
+ }`,Nm=`uniform float scale;
2714
+ attribute float lineDistance;
2715
+ varying float vLineDistance;
2716
+ #include <common>
2717
+ #include <uv_pars_vertex>
2718
+ #include <color_pars_vertex>
2719
+ #include <fog_pars_vertex>
2720
+ #include <morphtarget_pars_vertex>
2721
+ #include <logdepthbuf_pars_vertex>
2722
+ #include <clipping_planes_pars_vertex>
2723
+ void main() {
2724
+ vLineDistance = scale * lineDistance;
2725
+ #include <uv_vertex>
2726
+ #include <color_vertex>
2727
+ #include <morphinstance_vertex>
2728
+ #include <morphcolor_vertex>
2729
+ #include <begin_vertex>
2730
+ #include <morphtarget_vertex>
2731
+ #include <project_vertex>
2732
+ #include <logdepthbuf_vertex>
2733
+ #include <clipping_planes_vertex>
2734
+ #include <fog_vertex>
2735
+ }`,Fm=`uniform vec3 diffuse;
2736
+ uniform float opacity;
2737
+ uniform float dashSize;
2738
+ uniform float totalSize;
2739
+ varying float vLineDistance;
2740
+ #include <common>
2741
+ #include <color_pars_fragment>
2742
+ #include <uv_pars_fragment>
2743
+ #include <map_pars_fragment>
2744
+ #include <fog_pars_fragment>
2745
+ #include <logdepthbuf_pars_fragment>
2746
+ #include <clipping_planes_pars_fragment>
2747
+ void main() {
2748
+ vec4 diffuseColor = vec4( diffuse, opacity );
2749
+ #include <clipping_planes_fragment>
2750
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2751
+ discard;
2752
+ }
2753
+ vec3 outgoingLight = vec3( 0.0 );
2754
+ #include <logdepthbuf_fragment>
2755
+ #include <map_fragment>
2756
+ #include <color_fragment>
2757
+ outgoingLight = diffuseColor.rgb;
2758
+ #include <opaque_fragment>
2759
+ #include <tonemapping_fragment>
2760
+ #include <colorspace_fragment>
2761
+ #include <fog_fragment>
2762
+ #include <premultiplied_alpha_fragment>
2763
+ }`,Om=`#include <common>
2764
+ #include <batching_pars_vertex>
2765
+ #include <uv_pars_vertex>
2766
+ #include <envmap_pars_vertex>
2767
+ #include <color_pars_vertex>
2768
+ #include <fog_pars_vertex>
2769
+ #include <morphtarget_pars_vertex>
2770
+ #include <skinning_pars_vertex>
2771
+ #include <logdepthbuf_pars_vertex>
2772
+ #include <clipping_planes_pars_vertex>
2773
+ void main() {
2774
+ #include <uv_vertex>
2775
+ #include <color_vertex>
2776
+ #include <morphinstance_vertex>
2777
+ #include <morphcolor_vertex>
2778
+ #include <batching_vertex>
2779
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2780
+ #include <beginnormal_vertex>
2781
+ #include <morphnormal_vertex>
2782
+ #include <skinbase_vertex>
2783
+ #include <skinnormal_vertex>
2784
+ #include <defaultnormal_vertex>
2785
+ #endif
2786
+ #include <begin_vertex>
2787
+ #include <morphtarget_vertex>
2788
+ #include <skinning_vertex>
2789
+ #include <project_vertex>
2790
+ #include <logdepthbuf_vertex>
2791
+ #include <clipping_planes_vertex>
2792
+ #include <worldpos_vertex>
2793
+ #include <envmap_vertex>
2794
+ #include <fog_vertex>
2795
+ }`,Bm=`uniform vec3 diffuse;
2796
+ uniform float opacity;
2797
+ #ifndef FLAT_SHADED
2798
+ varying vec3 vNormal;
2799
+ #endif
2800
+ #include <common>
2801
+ #include <dithering_pars_fragment>
2802
+ #include <color_pars_fragment>
2803
+ #include <uv_pars_fragment>
2804
+ #include <map_pars_fragment>
2805
+ #include <alphamap_pars_fragment>
2806
+ #include <alphatest_pars_fragment>
2807
+ #include <alphahash_pars_fragment>
2808
+ #include <aomap_pars_fragment>
2809
+ #include <lightmap_pars_fragment>
2810
+ #include <envmap_common_pars_fragment>
2811
+ #include <envmap_pars_fragment>
2812
+ #include <fog_pars_fragment>
2813
+ #include <specularmap_pars_fragment>
2814
+ #include <logdepthbuf_pars_fragment>
2815
+ #include <clipping_planes_pars_fragment>
2816
+ void main() {
2817
+ vec4 diffuseColor = vec4( diffuse, opacity );
2818
+ #include <clipping_planes_fragment>
2819
+ #include <logdepthbuf_fragment>
2820
+ #include <map_fragment>
2821
+ #include <color_fragment>
2822
+ #include <alphamap_fragment>
2823
+ #include <alphatest_fragment>
2824
+ #include <alphahash_fragment>
2825
+ #include <specularmap_fragment>
2826
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2827
+ #ifdef USE_LIGHTMAP
2828
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2829
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2830
+ #else
2831
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2832
+ #endif
2833
+ #include <aomap_fragment>
2834
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2835
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2836
+ #include <envmap_fragment>
2837
+ #include <opaque_fragment>
2838
+ #include <tonemapping_fragment>
2839
+ #include <colorspace_fragment>
2840
+ #include <fog_fragment>
2841
+ #include <premultiplied_alpha_fragment>
2842
+ #include <dithering_fragment>
2843
+ }`,zm=`#define LAMBERT
2844
+ varying vec3 vViewPosition;
2845
+ #include <common>
2846
+ #include <batching_pars_vertex>
2847
+ #include <uv_pars_vertex>
2848
+ #include <displacementmap_pars_vertex>
2849
+ #include <envmap_pars_vertex>
2850
+ #include <color_pars_vertex>
2851
+ #include <fog_pars_vertex>
2852
+ #include <normal_pars_vertex>
2853
+ #include <morphtarget_pars_vertex>
2854
+ #include <skinning_pars_vertex>
2855
+ #include <shadowmap_pars_vertex>
2856
+ #include <logdepthbuf_pars_vertex>
2857
+ #include <clipping_planes_pars_vertex>
2858
+ void main() {
2859
+ #include <uv_vertex>
2860
+ #include <color_vertex>
2861
+ #include <morphinstance_vertex>
2862
+ #include <morphcolor_vertex>
2863
+ #include <batching_vertex>
2864
+ #include <beginnormal_vertex>
2865
+ #include <morphnormal_vertex>
2866
+ #include <skinbase_vertex>
2867
+ #include <skinnormal_vertex>
2868
+ #include <defaultnormal_vertex>
2869
+ #include <normal_vertex>
2870
+ #include <begin_vertex>
2871
+ #include <morphtarget_vertex>
2872
+ #include <skinning_vertex>
2873
+ #include <displacementmap_vertex>
2874
+ #include <project_vertex>
2875
+ #include <logdepthbuf_vertex>
2876
+ #include <clipping_planes_vertex>
2877
+ vViewPosition = - mvPosition.xyz;
2878
+ #include <worldpos_vertex>
2879
+ #include <envmap_vertex>
2880
+ #include <shadowmap_vertex>
2881
+ #include <fog_vertex>
2882
+ }`,Hm=`#define LAMBERT
2883
+ uniform vec3 diffuse;
2884
+ uniform vec3 emissive;
2885
+ uniform float opacity;
2886
+ #include <common>
2887
+ #include <packing>
2888
+ #include <dithering_pars_fragment>
2889
+ #include <color_pars_fragment>
2890
+ #include <uv_pars_fragment>
2891
+ #include <map_pars_fragment>
2892
+ #include <alphamap_pars_fragment>
2893
+ #include <alphatest_pars_fragment>
2894
+ #include <alphahash_pars_fragment>
2895
+ #include <aomap_pars_fragment>
2896
+ #include <lightmap_pars_fragment>
2897
+ #include <emissivemap_pars_fragment>
2898
+ #include <envmap_common_pars_fragment>
2899
+ #include <envmap_pars_fragment>
2900
+ #include <fog_pars_fragment>
2901
+ #include <bsdfs>
2902
+ #include <lights_pars_begin>
2903
+ #include <normal_pars_fragment>
2904
+ #include <lights_lambert_pars_fragment>
2905
+ #include <shadowmap_pars_fragment>
2906
+ #include <bumpmap_pars_fragment>
2907
+ #include <normalmap_pars_fragment>
2908
+ #include <specularmap_pars_fragment>
2909
+ #include <logdepthbuf_pars_fragment>
2910
+ #include <clipping_planes_pars_fragment>
2911
+ void main() {
2912
+ vec4 diffuseColor = vec4( diffuse, opacity );
2913
+ #include <clipping_planes_fragment>
2914
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2915
+ vec3 totalEmissiveRadiance = emissive;
2916
+ #include <logdepthbuf_fragment>
2917
+ #include <map_fragment>
2918
+ #include <color_fragment>
2919
+ #include <alphamap_fragment>
2920
+ #include <alphatest_fragment>
2921
+ #include <alphahash_fragment>
2922
+ #include <specularmap_fragment>
2923
+ #include <normal_fragment_begin>
2924
+ #include <normal_fragment_maps>
2925
+ #include <emissivemap_fragment>
2926
+ #include <lights_lambert_fragment>
2927
+ #include <lights_fragment_begin>
2928
+ #include <lights_fragment_maps>
2929
+ #include <lights_fragment_end>
2930
+ #include <aomap_fragment>
2931
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2932
+ #include <envmap_fragment>
2933
+ #include <opaque_fragment>
2934
+ #include <tonemapping_fragment>
2935
+ #include <colorspace_fragment>
2936
+ #include <fog_fragment>
2937
+ #include <premultiplied_alpha_fragment>
2938
+ #include <dithering_fragment>
2939
+ }`,km=`#define MATCAP
2940
+ varying vec3 vViewPosition;
2941
+ #include <common>
2942
+ #include <batching_pars_vertex>
2943
+ #include <uv_pars_vertex>
2944
+ #include <color_pars_vertex>
2945
+ #include <displacementmap_pars_vertex>
2946
+ #include <fog_pars_vertex>
2947
+ #include <normal_pars_vertex>
2948
+ #include <morphtarget_pars_vertex>
2949
+ #include <skinning_pars_vertex>
2950
+ #include <logdepthbuf_pars_vertex>
2951
+ #include <clipping_planes_pars_vertex>
2952
+ void main() {
2953
+ #include <uv_vertex>
2954
+ #include <color_vertex>
2955
+ #include <morphinstance_vertex>
2956
+ #include <morphcolor_vertex>
2957
+ #include <batching_vertex>
2958
+ #include <beginnormal_vertex>
2959
+ #include <morphnormal_vertex>
2960
+ #include <skinbase_vertex>
2961
+ #include <skinnormal_vertex>
2962
+ #include <defaultnormal_vertex>
2963
+ #include <normal_vertex>
2964
+ #include <begin_vertex>
2965
+ #include <morphtarget_vertex>
2966
+ #include <skinning_vertex>
2967
+ #include <displacementmap_vertex>
2968
+ #include <project_vertex>
2969
+ #include <logdepthbuf_vertex>
2970
+ #include <clipping_planes_vertex>
2971
+ #include <fog_vertex>
2972
+ vViewPosition = - mvPosition.xyz;
2973
+ }`,Gm=`#define MATCAP
2974
+ uniform vec3 diffuse;
2975
+ uniform float opacity;
2976
+ uniform sampler2D matcap;
2977
+ varying vec3 vViewPosition;
2978
+ #include <common>
2979
+ #include <dithering_pars_fragment>
2980
+ #include <color_pars_fragment>
2981
+ #include <uv_pars_fragment>
2982
+ #include <map_pars_fragment>
2983
+ #include <alphamap_pars_fragment>
2984
+ #include <alphatest_pars_fragment>
2985
+ #include <alphahash_pars_fragment>
2986
+ #include <fog_pars_fragment>
2987
+ #include <normal_pars_fragment>
2988
+ #include <bumpmap_pars_fragment>
2989
+ #include <normalmap_pars_fragment>
2990
+ #include <logdepthbuf_pars_fragment>
2991
+ #include <clipping_planes_pars_fragment>
2992
+ void main() {
2993
+ vec4 diffuseColor = vec4( diffuse, opacity );
2994
+ #include <clipping_planes_fragment>
2995
+ #include <logdepthbuf_fragment>
2996
+ #include <map_fragment>
2997
+ #include <color_fragment>
2998
+ #include <alphamap_fragment>
2999
+ #include <alphatest_fragment>
3000
+ #include <alphahash_fragment>
3001
+ #include <normal_fragment_begin>
3002
+ #include <normal_fragment_maps>
3003
+ vec3 viewDir = normalize( vViewPosition );
3004
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3005
+ vec3 y = cross( viewDir, x );
3006
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3007
+ #ifdef USE_MATCAP
3008
+ vec4 matcapColor = texture2D( matcap, uv );
3009
+ #else
3010
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3011
+ #endif
3012
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3013
+ #include <opaque_fragment>
3014
+ #include <tonemapping_fragment>
3015
+ #include <colorspace_fragment>
3016
+ #include <fog_fragment>
3017
+ #include <premultiplied_alpha_fragment>
3018
+ #include <dithering_fragment>
3019
+ }`,Vm=`#define NORMAL
3020
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3021
+ varying vec3 vViewPosition;
3022
+ #endif
3023
+ #include <common>
3024
+ #include <batching_pars_vertex>
3025
+ #include <uv_pars_vertex>
3026
+ #include <displacementmap_pars_vertex>
3027
+ #include <normal_pars_vertex>
3028
+ #include <morphtarget_pars_vertex>
3029
+ #include <skinning_pars_vertex>
3030
+ #include <logdepthbuf_pars_vertex>
3031
+ #include <clipping_planes_pars_vertex>
3032
+ void main() {
3033
+ #include <uv_vertex>
3034
+ #include <batching_vertex>
3035
+ #include <beginnormal_vertex>
3036
+ #include <morphinstance_vertex>
3037
+ #include <morphnormal_vertex>
3038
+ #include <skinbase_vertex>
3039
+ #include <skinnormal_vertex>
3040
+ #include <defaultnormal_vertex>
3041
+ #include <normal_vertex>
3042
+ #include <begin_vertex>
3043
+ #include <morphtarget_vertex>
3044
+ #include <skinning_vertex>
3045
+ #include <displacementmap_vertex>
3046
+ #include <project_vertex>
3047
+ #include <logdepthbuf_vertex>
3048
+ #include <clipping_planes_vertex>
3049
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3050
+ vViewPosition = - mvPosition.xyz;
3051
+ #endif
3052
+ }`,Wm=`#define NORMAL
3053
+ uniform float opacity;
3054
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3055
+ varying vec3 vViewPosition;
3056
+ #endif
3057
+ #include <packing>
3058
+ #include <uv_pars_fragment>
3059
+ #include <normal_pars_fragment>
3060
+ #include <bumpmap_pars_fragment>
3061
+ #include <normalmap_pars_fragment>
3062
+ #include <logdepthbuf_pars_fragment>
3063
+ #include <clipping_planes_pars_fragment>
3064
+ void main() {
3065
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3066
+ #include <clipping_planes_fragment>
3067
+ #include <logdepthbuf_fragment>
3068
+ #include <normal_fragment_begin>
3069
+ #include <normal_fragment_maps>
3070
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3071
+ #ifdef OPAQUE
3072
+ gl_FragColor.a = 1.0;
3073
+ #endif
3074
+ }`,Xm=`#define PHONG
3075
+ varying vec3 vViewPosition;
3076
+ #include <common>
3077
+ #include <batching_pars_vertex>
3078
+ #include <uv_pars_vertex>
3079
+ #include <displacementmap_pars_vertex>
3080
+ #include <envmap_pars_vertex>
3081
+ #include <color_pars_vertex>
3082
+ #include <fog_pars_vertex>
3083
+ #include <normal_pars_vertex>
3084
+ #include <morphtarget_pars_vertex>
3085
+ #include <skinning_pars_vertex>
3086
+ #include <shadowmap_pars_vertex>
3087
+ #include <logdepthbuf_pars_vertex>
3088
+ #include <clipping_planes_pars_vertex>
3089
+ void main() {
3090
+ #include <uv_vertex>
3091
+ #include <color_vertex>
3092
+ #include <morphcolor_vertex>
3093
+ #include <batching_vertex>
3094
+ #include <beginnormal_vertex>
3095
+ #include <morphinstance_vertex>
3096
+ #include <morphnormal_vertex>
3097
+ #include <skinbase_vertex>
3098
+ #include <skinnormal_vertex>
3099
+ #include <defaultnormal_vertex>
3100
+ #include <normal_vertex>
3101
+ #include <begin_vertex>
3102
+ #include <morphtarget_vertex>
3103
+ #include <skinning_vertex>
3104
+ #include <displacementmap_vertex>
3105
+ #include <project_vertex>
3106
+ #include <logdepthbuf_vertex>
3107
+ #include <clipping_planes_vertex>
3108
+ vViewPosition = - mvPosition.xyz;
3109
+ #include <worldpos_vertex>
3110
+ #include <envmap_vertex>
3111
+ #include <shadowmap_vertex>
3112
+ #include <fog_vertex>
3113
+ }`,qm=`#define PHONG
3114
+ uniform vec3 diffuse;
3115
+ uniform vec3 emissive;
3116
+ uniform vec3 specular;
3117
+ uniform float shininess;
3118
+ uniform float opacity;
3119
+ #include <common>
3120
+ #include <packing>
3121
+ #include <dithering_pars_fragment>
3122
+ #include <color_pars_fragment>
3123
+ #include <uv_pars_fragment>
3124
+ #include <map_pars_fragment>
3125
+ #include <alphamap_pars_fragment>
3126
+ #include <alphatest_pars_fragment>
3127
+ #include <alphahash_pars_fragment>
3128
+ #include <aomap_pars_fragment>
3129
+ #include <lightmap_pars_fragment>
3130
+ #include <emissivemap_pars_fragment>
3131
+ #include <envmap_common_pars_fragment>
3132
+ #include <envmap_pars_fragment>
3133
+ #include <fog_pars_fragment>
3134
+ #include <bsdfs>
3135
+ #include <lights_pars_begin>
3136
+ #include <normal_pars_fragment>
3137
+ #include <lights_phong_pars_fragment>
3138
+ #include <shadowmap_pars_fragment>
3139
+ #include <bumpmap_pars_fragment>
3140
+ #include <normalmap_pars_fragment>
3141
+ #include <specularmap_pars_fragment>
3142
+ #include <logdepthbuf_pars_fragment>
3143
+ #include <clipping_planes_pars_fragment>
3144
+ void main() {
3145
+ vec4 diffuseColor = vec4( diffuse, opacity );
3146
+ #include <clipping_planes_fragment>
3147
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3148
+ vec3 totalEmissiveRadiance = emissive;
3149
+ #include <logdepthbuf_fragment>
3150
+ #include <map_fragment>
3151
+ #include <color_fragment>
3152
+ #include <alphamap_fragment>
3153
+ #include <alphatest_fragment>
3154
+ #include <alphahash_fragment>
3155
+ #include <specularmap_fragment>
3156
+ #include <normal_fragment_begin>
3157
+ #include <normal_fragment_maps>
3158
+ #include <emissivemap_fragment>
3159
+ #include <lights_phong_fragment>
3160
+ #include <lights_fragment_begin>
3161
+ #include <lights_fragment_maps>
3162
+ #include <lights_fragment_end>
3163
+ #include <aomap_fragment>
3164
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3165
+ #include <envmap_fragment>
3166
+ #include <opaque_fragment>
3167
+ #include <tonemapping_fragment>
3168
+ #include <colorspace_fragment>
3169
+ #include <fog_fragment>
3170
+ #include <premultiplied_alpha_fragment>
3171
+ #include <dithering_fragment>
3172
+ }`,Ym=`#define STANDARD
3173
+ varying vec3 vViewPosition;
3174
+ #ifdef USE_TRANSMISSION
3175
+ varying vec3 vWorldPosition;
3176
+ #endif
3177
+ #include <common>
3178
+ #include <batching_pars_vertex>
3179
+ #include <uv_pars_vertex>
3180
+ #include <displacementmap_pars_vertex>
3181
+ #include <color_pars_vertex>
3182
+ #include <fog_pars_vertex>
3183
+ #include <normal_pars_vertex>
3184
+ #include <morphtarget_pars_vertex>
3185
+ #include <skinning_pars_vertex>
3186
+ #include <shadowmap_pars_vertex>
3187
+ #include <logdepthbuf_pars_vertex>
3188
+ #include <clipping_planes_pars_vertex>
3189
+ void main() {
3190
+ #include <uv_vertex>
3191
+ #include <color_vertex>
3192
+ #include <morphinstance_vertex>
3193
+ #include <morphcolor_vertex>
3194
+ #include <batching_vertex>
3195
+ #include <beginnormal_vertex>
3196
+ #include <morphnormal_vertex>
3197
+ #include <skinbase_vertex>
3198
+ #include <skinnormal_vertex>
3199
+ #include <defaultnormal_vertex>
3200
+ #include <normal_vertex>
3201
+ #include <begin_vertex>
3202
+ #include <morphtarget_vertex>
3203
+ #include <skinning_vertex>
3204
+ #include <displacementmap_vertex>
3205
+ #include <project_vertex>
3206
+ #include <logdepthbuf_vertex>
3207
+ #include <clipping_planes_vertex>
3208
+ vViewPosition = - mvPosition.xyz;
3209
+ #include <worldpos_vertex>
3210
+ #include <shadowmap_vertex>
3211
+ #include <fog_vertex>
3212
+ #ifdef USE_TRANSMISSION
3213
+ vWorldPosition = worldPosition.xyz;
3214
+ #endif
3215
+ }`,Zm=`#define STANDARD
3216
+ #ifdef PHYSICAL
3217
+ #define IOR
3218
+ #define USE_SPECULAR
3219
+ #endif
3220
+ uniform vec3 diffuse;
3221
+ uniform vec3 emissive;
3222
+ uniform float roughness;
3223
+ uniform float metalness;
3224
+ uniform float opacity;
3225
+ #ifdef IOR
3226
+ uniform float ior;
3227
+ #endif
3228
+ #ifdef USE_SPECULAR
3229
+ uniform float specularIntensity;
3230
+ uniform vec3 specularColor;
3231
+ #ifdef USE_SPECULAR_COLORMAP
3232
+ uniform sampler2D specularColorMap;
3233
+ #endif
3234
+ #ifdef USE_SPECULAR_INTENSITYMAP
3235
+ uniform sampler2D specularIntensityMap;
3236
+ #endif
3237
+ #endif
3238
+ #ifdef USE_CLEARCOAT
3239
+ uniform float clearcoat;
3240
+ uniform float clearcoatRoughness;
3241
+ #endif
3242
+ #ifdef USE_DISPERSION
3243
+ uniform float dispersion;
3244
+ #endif
3245
+ #ifdef USE_IRIDESCENCE
3246
+ uniform float iridescence;
3247
+ uniform float iridescenceIOR;
3248
+ uniform float iridescenceThicknessMinimum;
3249
+ uniform float iridescenceThicknessMaximum;
3250
+ #endif
3251
+ #ifdef USE_SHEEN
3252
+ uniform vec3 sheenColor;
3253
+ uniform float sheenRoughness;
3254
+ #ifdef USE_SHEEN_COLORMAP
3255
+ uniform sampler2D sheenColorMap;
3256
+ #endif
3257
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3258
+ uniform sampler2D sheenRoughnessMap;
3259
+ #endif
3260
+ #endif
3261
+ #ifdef USE_ANISOTROPY
3262
+ uniform vec2 anisotropyVector;
3263
+ #ifdef USE_ANISOTROPYMAP
3264
+ uniform sampler2D anisotropyMap;
3265
+ #endif
3266
+ #endif
3267
+ varying vec3 vViewPosition;
3268
+ #include <common>
3269
+ #include <packing>
3270
+ #include <dithering_pars_fragment>
3271
+ #include <color_pars_fragment>
3272
+ #include <uv_pars_fragment>
3273
+ #include <map_pars_fragment>
3274
+ #include <alphamap_pars_fragment>
3275
+ #include <alphatest_pars_fragment>
3276
+ #include <alphahash_pars_fragment>
3277
+ #include <aomap_pars_fragment>
3278
+ #include <lightmap_pars_fragment>
3279
+ #include <emissivemap_pars_fragment>
3280
+ #include <iridescence_fragment>
3281
+ #include <cube_uv_reflection_fragment>
3282
+ #include <envmap_common_pars_fragment>
3283
+ #include <envmap_physical_pars_fragment>
3284
+ #include <fog_pars_fragment>
3285
+ #include <lights_pars_begin>
3286
+ #include <normal_pars_fragment>
3287
+ #include <lights_physical_pars_fragment>
3288
+ #include <transmission_pars_fragment>
3289
+ #include <shadowmap_pars_fragment>
3290
+ #include <bumpmap_pars_fragment>
3291
+ #include <normalmap_pars_fragment>
3292
+ #include <clearcoat_pars_fragment>
3293
+ #include <iridescence_pars_fragment>
3294
+ #include <roughnessmap_pars_fragment>
3295
+ #include <metalnessmap_pars_fragment>
3296
+ #include <logdepthbuf_pars_fragment>
3297
+ #include <clipping_planes_pars_fragment>
3298
+ void main() {
3299
+ vec4 diffuseColor = vec4( diffuse, opacity );
3300
+ #include <clipping_planes_fragment>
3301
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3302
+ vec3 totalEmissiveRadiance = emissive;
3303
+ #include <logdepthbuf_fragment>
3304
+ #include <map_fragment>
3305
+ #include <color_fragment>
3306
+ #include <alphamap_fragment>
3307
+ #include <alphatest_fragment>
3308
+ #include <alphahash_fragment>
3309
+ #include <roughnessmap_fragment>
3310
+ #include <metalnessmap_fragment>
3311
+ #include <normal_fragment_begin>
3312
+ #include <normal_fragment_maps>
3313
+ #include <clearcoat_normal_fragment_begin>
3314
+ #include <clearcoat_normal_fragment_maps>
3315
+ #include <emissivemap_fragment>
3316
+ #include <lights_physical_fragment>
3317
+ #include <lights_fragment_begin>
3318
+ #include <lights_fragment_maps>
3319
+ #include <lights_fragment_end>
3320
+ #include <aomap_fragment>
3321
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3322
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3323
+ #include <transmission_fragment>
3324
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3325
+ #ifdef USE_SHEEN
3326
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3327
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3328
+ #endif
3329
+ #ifdef USE_CLEARCOAT
3330
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3331
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3332
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3333
+ #endif
3334
+ #include <opaque_fragment>
3335
+ #include <tonemapping_fragment>
3336
+ #include <colorspace_fragment>
3337
+ #include <fog_fragment>
3338
+ #include <premultiplied_alpha_fragment>
3339
+ #include <dithering_fragment>
3340
+ }`,Jm=`#define TOON
3341
+ varying vec3 vViewPosition;
3342
+ #include <common>
3343
+ #include <batching_pars_vertex>
3344
+ #include <uv_pars_vertex>
3345
+ #include <displacementmap_pars_vertex>
3346
+ #include <color_pars_vertex>
3347
+ #include <fog_pars_vertex>
3348
+ #include <normal_pars_vertex>
3349
+ #include <morphtarget_pars_vertex>
3350
+ #include <skinning_pars_vertex>
3351
+ #include <shadowmap_pars_vertex>
3352
+ #include <logdepthbuf_pars_vertex>
3353
+ #include <clipping_planes_pars_vertex>
3354
+ void main() {
3355
+ #include <uv_vertex>
3356
+ #include <color_vertex>
3357
+ #include <morphinstance_vertex>
3358
+ #include <morphcolor_vertex>
3359
+ #include <batching_vertex>
3360
+ #include <beginnormal_vertex>
3361
+ #include <morphnormal_vertex>
3362
+ #include <skinbase_vertex>
3363
+ #include <skinnormal_vertex>
3364
+ #include <defaultnormal_vertex>
3365
+ #include <normal_vertex>
3366
+ #include <begin_vertex>
3367
+ #include <morphtarget_vertex>
3368
+ #include <skinning_vertex>
3369
+ #include <displacementmap_vertex>
3370
+ #include <project_vertex>
3371
+ #include <logdepthbuf_vertex>
3372
+ #include <clipping_planes_vertex>
3373
+ vViewPosition = - mvPosition.xyz;
3374
+ #include <worldpos_vertex>
3375
+ #include <shadowmap_vertex>
3376
+ #include <fog_vertex>
3377
+ }`,Km=`#define TOON
3378
+ uniform vec3 diffuse;
3379
+ uniform vec3 emissive;
3380
+ uniform float opacity;
3381
+ #include <common>
3382
+ #include <packing>
3383
+ #include <dithering_pars_fragment>
3384
+ #include <color_pars_fragment>
3385
+ #include <uv_pars_fragment>
3386
+ #include <map_pars_fragment>
3387
+ #include <alphamap_pars_fragment>
3388
+ #include <alphatest_pars_fragment>
3389
+ #include <alphahash_pars_fragment>
3390
+ #include <aomap_pars_fragment>
3391
+ #include <lightmap_pars_fragment>
3392
+ #include <emissivemap_pars_fragment>
3393
+ #include <gradientmap_pars_fragment>
3394
+ #include <fog_pars_fragment>
3395
+ #include <bsdfs>
3396
+ #include <lights_pars_begin>
3397
+ #include <normal_pars_fragment>
3398
+ #include <lights_toon_pars_fragment>
3399
+ #include <shadowmap_pars_fragment>
3400
+ #include <bumpmap_pars_fragment>
3401
+ #include <normalmap_pars_fragment>
3402
+ #include <logdepthbuf_pars_fragment>
3403
+ #include <clipping_planes_pars_fragment>
3404
+ void main() {
3405
+ vec4 diffuseColor = vec4( diffuse, opacity );
3406
+ #include <clipping_planes_fragment>
3407
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3408
+ vec3 totalEmissiveRadiance = emissive;
3409
+ #include <logdepthbuf_fragment>
3410
+ #include <map_fragment>
3411
+ #include <color_fragment>
3412
+ #include <alphamap_fragment>
3413
+ #include <alphatest_fragment>
3414
+ #include <alphahash_fragment>
3415
+ #include <normal_fragment_begin>
3416
+ #include <normal_fragment_maps>
3417
+ #include <emissivemap_fragment>
3418
+ #include <lights_toon_fragment>
3419
+ #include <lights_fragment_begin>
3420
+ #include <lights_fragment_maps>
3421
+ #include <lights_fragment_end>
3422
+ #include <aomap_fragment>
3423
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3424
+ #include <opaque_fragment>
3425
+ #include <tonemapping_fragment>
3426
+ #include <colorspace_fragment>
3427
+ #include <fog_fragment>
3428
+ #include <premultiplied_alpha_fragment>
3429
+ #include <dithering_fragment>
3430
+ }`,jm=`uniform float size;
3431
+ uniform float scale;
3432
+ #include <common>
3433
+ #include <color_pars_vertex>
3434
+ #include <fog_pars_vertex>
3435
+ #include <morphtarget_pars_vertex>
3436
+ #include <logdepthbuf_pars_vertex>
3437
+ #include <clipping_planes_pars_vertex>
3438
+ #ifdef USE_POINTS_UV
3439
+ varying vec2 vUv;
3440
+ uniform mat3 uvTransform;
3441
+ #endif
3442
+ void main() {
3443
+ #ifdef USE_POINTS_UV
3444
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3445
+ #endif
3446
+ #include <color_vertex>
3447
+ #include <morphinstance_vertex>
3448
+ #include <morphcolor_vertex>
3449
+ #include <begin_vertex>
3450
+ #include <morphtarget_vertex>
3451
+ #include <project_vertex>
3452
+ gl_PointSize = size;
3453
+ #ifdef USE_SIZEATTENUATION
3454
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3455
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3456
+ #endif
3457
+ #include <logdepthbuf_vertex>
3458
+ #include <clipping_planes_vertex>
3459
+ #include <worldpos_vertex>
3460
+ #include <fog_vertex>
3461
+ }`,$m=`uniform vec3 diffuse;
3462
+ uniform float opacity;
3463
+ #include <common>
3464
+ #include <color_pars_fragment>
3465
+ #include <map_particle_pars_fragment>
3466
+ #include <alphatest_pars_fragment>
3467
+ #include <alphahash_pars_fragment>
3468
+ #include <fog_pars_fragment>
3469
+ #include <logdepthbuf_pars_fragment>
3470
+ #include <clipping_planes_pars_fragment>
3471
+ void main() {
3472
+ vec4 diffuseColor = vec4( diffuse, opacity );
3473
+ #include <clipping_planes_fragment>
3474
+ vec3 outgoingLight = vec3( 0.0 );
3475
+ #include <logdepthbuf_fragment>
3476
+ #include <map_particle_fragment>
3477
+ #include <color_fragment>
3478
+ #include <alphatest_fragment>
3479
+ #include <alphahash_fragment>
3480
+ outgoingLight = diffuseColor.rgb;
3481
+ #include <opaque_fragment>
3482
+ #include <tonemapping_fragment>
3483
+ #include <colorspace_fragment>
3484
+ #include <fog_fragment>
3485
+ #include <premultiplied_alpha_fragment>
3486
+ }`,Qm=`#include <common>
3487
+ #include <batching_pars_vertex>
3488
+ #include <fog_pars_vertex>
3489
+ #include <morphtarget_pars_vertex>
3490
+ #include <skinning_pars_vertex>
3491
+ #include <logdepthbuf_pars_vertex>
3492
+ #include <shadowmap_pars_vertex>
3493
+ void main() {
3494
+ #include <batching_vertex>
3495
+ #include <beginnormal_vertex>
3496
+ #include <morphinstance_vertex>
3497
+ #include <morphnormal_vertex>
3498
+ #include <skinbase_vertex>
3499
+ #include <skinnormal_vertex>
3500
+ #include <defaultnormal_vertex>
3501
+ #include <begin_vertex>
3502
+ #include <morphtarget_vertex>
3503
+ #include <skinning_vertex>
3504
+ #include <project_vertex>
3505
+ #include <logdepthbuf_vertex>
3506
+ #include <worldpos_vertex>
3507
+ #include <shadowmap_vertex>
3508
+ #include <fog_vertex>
3509
+ }`,tg=`uniform vec3 color;
3510
+ uniform float opacity;
3511
+ #include <common>
3512
+ #include <packing>
3513
+ #include <fog_pars_fragment>
3514
+ #include <bsdfs>
3515
+ #include <lights_pars_begin>
3516
+ #include <logdepthbuf_pars_fragment>
3517
+ #include <shadowmap_pars_fragment>
3518
+ #include <shadowmask_pars_fragment>
3519
+ void main() {
3520
+ #include <logdepthbuf_fragment>
3521
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3522
+ #include <tonemapping_fragment>
3523
+ #include <colorspace_fragment>
3524
+ #include <fog_fragment>
3525
+ }`,eg=`uniform float rotation;
3526
+ uniform vec2 center;
3527
+ #include <common>
3528
+ #include <uv_pars_vertex>
3529
+ #include <fog_pars_vertex>
3530
+ #include <logdepthbuf_pars_vertex>
3531
+ #include <clipping_planes_pars_vertex>
3532
+ void main() {
3533
+ #include <uv_vertex>
3534
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3535
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3536
+ #ifndef USE_SIZEATTENUATION
3537
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3538
+ if ( isPerspective ) scale *= - mvPosition.z;
3539
+ #endif
3540
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3541
+ vec2 rotatedPosition;
3542
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3543
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3544
+ mvPosition.xy += rotatedPosition;
3545
+ gl_Position = projectionMatrix * mvPosition;
3546
+ #include <logdepthbuf_vertex>
3547
+ #include <clipping_planes_vertex>
3548
+ #include <fog_vertex>
3549
+ }`,ng=`uniform vec3 diffuse;
3550
+ uniform float opacity;
3551
+ #include <common>
3552
+ #include <uv_pars_fragment>
3553
+ #include <map_pars_fragment>
3554
+ #include <alphamap_pars_fragment>
3555
+ #include <alphatest_pars_fragment>
3556
+ #include <alphahash_pars_fragment>
3557
+ #include <fog_pars_fragment>
3558
+ #include <logdepthbuf_pars_fragment>
3559
+ #include <clipping_planes_pars_fragment>
3560
+ void main() {
3561
+ vec4 diffuseColor = vec4( diffuse, opacity );
3562
+ #include <clipping_planes_fragment>
3563
+ vec3 outgoingLight = vec3( 0.0 );
3564
+ #include <logdepthbuf_fragment>
3565
+ #include <map_fragment>
3566
+ #include <alphamap_fragment>
3567
+ #include <alphatest_fragment>
3568
+ #include <alphahash_fragment>
3569
+ outgoingLight = diffuseColor.rgb;
3570
+ #include <opaque_fragment>
3571
+ #include <tonemapping_fragment>
3572
+ #include <colorspace_fragment>
3573
+ #include <fog_fragment>
3574
+ }`,kt={alphahash_fragment:Td,alphahash_pars_fragment:Ad,alphamap_fragment:bd,alphamap_pars_fragment:wd,alphatest_fragment:Rd,alphatest_pars_fragment:Cd,aomap_fragment:Pd,aomap_pars_fragment:Ld,batching_pars_vertex:Dd,batching_vertex:Ud,begin_vertex:Id,beginnormal_vertex:Nd,bsdfs:Fd,iridescence_fragment:Od,bumpmap_pars_fragment:Bd,clipping_planes_fragment:zd,clipping_planes_pars_fragment:Hd,clipping_planes_pars_vertex:kd,clipping_planes_vertex:Gd,color_fragment:Vd,color_pars_fragment:Wd,color_pars_vertex:Xd,color_vertex:qd,common:Yd,cube_uv_reflection_fragment:Zd,defaultnormal_vertex:Jd,displacementmap_pars_vertex:Kd,displacementmap_vertex:jd,emissivemap_fragment:$d,emissivemap_pars_fragment:Qd,colorspace_fragment:tp,colorspace_pars_fragment:ep,envmap_fragment:np,envmap_common_pars_fragment:ip,envmap_pars_fragment:rp,envmap_pars_vertex:sp,envmap_physical_pars_fragment:gp,envmap_vertex:op,fog_vertex:ap,fog_pars_vertex:cp,fog_fragment:lp,fog_pars_fragment:up,gradientmap_pars_fragment:hp,lightmap_pars_fragment:fp,lights_lambert_fragment:dp,lights_lambert_pars_fragment:pp,lights_pars_begin:mp,lights_toon_fragment:_p,lights_toon_pars_fragment:vp,lights_phong_fragment:xp,lights_phong_pars_fragment:Mp,lights_physical_fragment:Sp,lights_physical_pars_fragment:yp,lights_fragment_begin:Ep,lights_fragment_maps:Tp,lights_fragment_end:Ap,logdepthbuf_fragment:bp,logdepthbuf_pars_fragment:wp,logdepthbuf_pars_vertex:Rp,logdepthbuf_vertex:Cp,map_fragment:Pp,map_pars_fragment:Lp,map_particle_fragment:Dp,map_particle_pars_fragment:Up,metalnessmap_fragment:Ip,metalnessmap_pars_fragment:Np,morphinstance_vertex:Fp,morphcolor_vertex:Op,morphnormal_vertex:Bp,morphtarget_pars_vertex:zp,morphtarget_vertex:Hp,normal_fragment_begin:kp,normal_fragment_maps:Gp,normal_pars_fragment:Vp,normal_pars_vertex:Wp,normal_vertex:Xp,normalmap_pars_fragment:qp,clearcoat_normal_fragment_begin:Yp,clearcoat_normal_fragment_maps:Zp,clearcoat_pars_fragment:Jp,iridescence_pars_fragment:Kp,opaque_fragment:jp,packing:$p,premultiplied_alpha_fragment:Qp,project_vertex:tm,dithering_fragment:em,dithering_pars_fragment:nm,roughnessmap_fragment:im,roughnessmap_pars_fragment:rm,shadowmap_pars_fragment:sm,shadowmap_pars_vertex:om,shadowmap_vertex:am,shadowmask_pars_fragment:cm,skinbase_vertex:lm,skinning_pars_vertex:um,skinning_vertex:hm,skinnormal_vertex:fm,specularmap_fragment:dm,specularmap_pars_fragment:pm,tonemapping_fragment:mm,tonemapping_pars_fragment:gm,transmission_fragment:_m,transmission_pars_fragment:vm,uv_pars_fragment:xm,uv_pars_vertex:Mm,uv_vertex:Sm,worldpos_vertex:ym,background_vert:Em,background_frag:Tm,backgroundCube_vert:Am,backgroundCube_frag:bm,cube_vert:wm,cube_frag:Rm,depth_vert:Cm,depth_frag:Pm,distanceRGBA_vert:Lm,distanceRGBA_frag:Dm,equirect_vert:Um,equirect_frag:Im,linedashed_vert:Nm,linedashed_frag:Fm,meshbasic_vert:Om,meshbasic_frag:Bm,meshlambert_vert:zm,meshlambert_frag:Hm,meshmatcap_vert:km,meshmatcap_frag:Gm,meshnormal_vert:Vm,meshnormal_frag:Wm,meshphong_vert:Xm,meshphong_frag:qm,meshphysical_vert:Ym,meshphysical_frag:Zm,meshtoon_vert:Jm,meshtoon_frag:Km,points_vert:jm,points_frag:$m,shadow_vert:Qm,shadow_frag:tg,sprite_vert:eg,sprite_frag:ng},lt={common:{diffuse:{value:new Wt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new zt}},envmap:{envMap:{value:null},envMapRotation:{value:new zt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new zt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new zt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new zt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new zt},normalScale:{value:new at(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new zt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new zt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new zt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new zt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Wt(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 Wt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0},uvTransform:{value:new zt}},sprite:{diffuse:{value:new Wt(16777215)},opacity:{value:1},center:{value:new at(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}}},Ye={basic:{uniforms:Ae([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.fog]),vertexShader:kt.meshbasic_vert,fragmentShader:kt.meshbasic_frag},lambert:{uniforms:Ae([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new Wt(0)}}]),vertexShader:kt.meshlambert_vert,fragmentShader:kt.meshlambert_frag},phong:{uniforms:Ae([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new Wt(0)},specular:{value:new Wt(1118481)},shininess:{value:30}}]),vertexShader:kt.meshphong_vert,fragmentShader:kt.meshphong_frag},standard:{uniforms:Ae([lt.common,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.roughnessmap,lt.metalnessmap,lt.fog,lt.lights,{emissive:{value:new Wt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:kt.meshphysical_vert,fragmentShader:kt.meshphysical_frag},toon:{uniforms:Ae([lt.common,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.gradientmap,lt.fog,lt.lights,{emissive:{value:new Wt(0)}}]),vertexShader:kt.meshtoon_vert,fragmentShader:kt.meshtoon_frag},matcap:{uniforms:Ae([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,{matcap:{value:null}}]),vertexShader:kt.meshmatcap_vert,fragmentShader:kt.meshmatcap_frag},points:{uniforms:Ae([lt.points,lt.fog]),vertexShader:kt.points_vert,fragmentShader:kt.points_frag},dashed:{uniforms:Ae([lt.common,lt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kt.linedashed_vert,fragmentShader:kt.linedashed_frag},depth:{uniforms:Ae([lt.common,lt.displacementmap]),vertexShader:kt.depth_vert,fragmentShader:kt.depth_frag},normal:{uniforms:Ae([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,{opacity:{value:1}}]),vertexShader:kt.meshnormal_vert,fragmentShader:kt.meshnormal_frag},sprite:{uniforms:Ae([lt.sprite,lt.fog]),vertexShader:kt.sprite_vert,fragmentShader:kt.sprite_frag},background:{uniforms:{uvTransform:{value:new zt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:kt.background_vert,fragmentShader:kt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new zt}},vertexShader:kt.backgroundCube_vert,fragmentShader:kt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kt.cube_vert,fragmentShader:kt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kt.equirect_vert,fragmentShader:kt.equirect_frag},distanceRGBA:{uniforms:Ae([lt.common,lt.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kt.distanceRGBA_vert,fragmentShader:kt.distanceRGBA_frag},shadow:{uniforms:Ae([lt.lights,lt.fog,{color:{value:new Wt(0)},opacity:{value:1}}]),vertexShader:kt.shadow_vert,fragmentShader:kt.shadow_frag}};Ye.physical={uniforms:Ae([Ye.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new zt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new zt},clearcoatNormalScale:{value:new at(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new zt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new zt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new zt},sheen:{value:0},sheenColor:{value:new Wt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new zt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new zt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new zt},transmissionSamplerSize:{value:new at},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new zt},attenuationDistance:{value:0},attenuationColor:{value:new Wt(0)},specularColor:{value:new Wt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new zt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new zt},anisotropyVector:{value:new at},anisotropyMap:{value:null},anisotropyMapTransform:{value:new zt}}]),vertexShader:kt.meshphysical_vert,fragmentShader:kt.meshphysical_frag};const Dr={r:0,b:0,g:0},In=new $e,ig=new re;function rg(i,t,e,n,r,s,o){const a=new Wt(0);let c=s===!0?0:1,l,u,h=null,f=0,d=null;function g(T){let S=T.isScene===!0?T.background:null;return S&&S.isTexture&&(S=(T.backgroundBlurriness>0?e:t).get(S)),S}function v(T){let S=!1;const L=g(T);L===null?p(a,c):L&&L.isColor&&(p(L,1),S=!0);const C=i.xr.getEnvironmentBlendMode();C==="additive"?n.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||S)&&(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(T,S){const L=g(S);L&&(L.isCubeTexture||L.mapping===Jr)?(u===void 0&&(u=new le(new Zn(1,1,1),new wn({name:"BackgroundCubeMaterial",uniforms:Li(Ye.backgroundCube.uniforms),vertexShader:Ye.backgroundCube.vertexShader,fragmentShader:Ye.backgroundCube.fragmentShader,side:Ce,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(C,R,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),In.copy(S.backgroundRotation),In.x*=-1,In.y*=-1,In.z*=-1,L.isCubeTexture&&L.isRenderTargetTexture===!1&&(In.y*=-1,In.z*=-1),u.material.uniforms.envMap.value=L,u.material.uniforms.flipEnvMap.value=L.isCubeTexture&&L.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(ig.makeRotationFromEuler(In)),u.material.toneMapped=Kt.getTransfer(L.colorSpace)!==te,(h!==L||f!==L.version||d!==i.toneMapping)&&(u.material.needsUpdate=!0,h=L,f=L.version,d=i.toneMapping),u.layers.enableAll(),T.unshift(u,u.geometry,u.material,0,0,null)):L&&L.isTexture&&(l===void 0&&(l=new le(new ar(2,2),new wn({name:"BackgroundMaterial",uniforms:Li(Ye.background.uniforms),vertexShader:Ye.background.vertexShader,fragmentShader:Ye.background.fragmentShader,side:bn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=L,l.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,l.material.toneMapped=Kt.getTransfer(L.colorSpace)!==te,L.matrixAutoUpdate===!0&&L.updateMatrix(),l.material.uniforms.uvTransform.value.copy(L.matrix),(h!==L||f!==L.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=L,f=L.version,d=i.toneMapping),l.layers.enableAll(),T.unshift(l,l.geometry,l.material,0,0,null))}function p(T,S){T.getRGB(Dr,nu(i)),n.buffers.color.setClear(Dr.r,Dr.g,Dr.b,S,o)}function b(){u!==void 0&&(u.geometry.dispose(),u.material.dispose()),l!==void 0&&(l.geometry.dispose(),l.material.dispose())}return{getClearColor:function(){return a},setClearColor:function(T,S=1){a.set(T),c=S,p(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(T){c=T,p(a,c)},render:v,addToRenderList:m,dispose:b}}function sg(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=f(null);let s=r,o=!1;function a(M,w,H,O,V){let X=!1;const G=h(O,H,w);s!==G&&(s=G,l(s.object)),X=d(M,O,H,V),X&&g(M,O,H,V),V!==null&&t.update(V,i.ELEMENT_ARRAY_BUFFER),(X||o)&&(o=!1,S(M,w,H,O),V!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(V).buffer))}function c(){return i.createVertexArray()}function l(M){return i.bindVertexArray(M)}function u(M){return i.deleteVertexArray(M)}function h(M,w,H){const O=H.wireframe===!0;let V=n[M.id];V===void 0&&(V={},n[M.id]=V);let X=V[w.id];X===void 0&&(X={},V[w.id]=X);let G=X[O];return G===void 0&&(G=f(c()),X[O]=G),G}function f(M){const w=[],H=[],O=[];for(let V=0;V<e;V++)w[V]=0,H[V]=0,O[V]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:w,enabledAttributes:H,attributeDivisors:O,object:M,attributes:{},index:null}}function d(M,w,H,O){const V=s.attributes,X=w.attributes;let G=0;const K=H.getAttributes();for(const k in K)if(K[k].location>=0){const pt=V[k];let Mt=X[k];if(Mt===void 0&&(k==="instanceMatrix"&&M.instanceMatrix&&(Mt=M.instanceMatrix),k==="instanceColor"&&M.instanceColor&&(Mt=M.instanceColor)),pt===void 0||pt.attribute!==Mt||Mt&&pt.data!==Mt.data)return!0;G++}return s.attributesNum!==G||s.index!==O}function g(M,w,H,O){const V={},X=w.attributes;let G=0;const K=H.getAttributes();for(const k in K)if(K[k].location>=0){let pt=X[k];pt===void 0&&(k==="instanceMatrix"&&M.instanceMatrix&&(pt=M.instanceMatrix),k==="instanceColor"&&M.instanceColor&&(pt=M.instanceColor));const Mt={};Mt.attribute=pt,pt&&pt.data&&(Mt.data=pt.data),V[k]=Mt,G++}s.attributes=V,s.attributesNum=G,s.index=O}function v(){const M=s.newAttributes;for(let w=0,H=M.length;w<H;w++)M[w]=0}function m(M){p(M,0)}function p(M,w){const H=s.newAttributes,O=s.enabledAttributes,V=s.attributeDivisors;H[M]=1,O[M]===0&&(i.enableVertexAttribArray(M),O[M]=1),V[M]!==w&&(i.vertexAttribDivisor(M,w),V[M]=w)}function b(){const M=s.newAttributes,w=s.enabledAttributes;for(let H=0,O=w.length;H<O;H++)w[H]!==M[H]&&(i.disableVertexAttribArray(H),w[H]=0)}function T(M,w,H,O,V,X,G){G===!0?i.vertexAttribIPointer(M,w,H,V,X):i.vertexAttribPointer(M,w,H,O,V,X)}function S(M,w,H,O){v();const V=O.attributes,X=H.getAttributes(),G=w.defaultAttributeValues;for(const K in X){const k=X[K];if(k.location>=0){let ct=V[K];if(ct===void 0&&(K==="instanceMatrix"&&M.instanceMatrix&&(ct=M.instanceMatrix),K==="instanceColor"&&M.instanceColor&&(ct=M.instanceColor)),ct!==void 0){const pt=ct.normalized,Mt=ct.itemSize,Ft=t.get(ct);if(Ft===void 0)continue;const Zt=Ft.buffer,Y=Ft.type,st=Ft.bytesPerElement,Q=Y===i.INT||Y===i.UNSIGNED_INT||ct.gpuType===Na;if(ct.isInterleavedBufferAttribute){const j=ct.data,ut=j.stride,vt=ct.offset;if(j.isInstancedInterleavedBuffer){for(let Rt=0;Rt<k.locationSize;Rt++)p(k.location+Rt,j.meshPerAttribute);M.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let Rt=0;Rt<k.locationSize;Rt++)m(k.location+Rt);i.bindBuffer(i.ARRAY_BUFFER,Zt);for(let Rt=0;Rt<k.locationSize;Rt++)T(k.location+Rt,Mt/k.locationSize,Y,pt,ut*st,(vt+Mt/k.locationSize*Rt)*st,Q)}else{if(ct.isInstancedBufferAttribute){for(let j=0;j<k.locationSize;j++)p(k.location+j,ct.meshPerAttribute);M.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ct.meshPerAttribute*ct.count)}else for(let j=0;j<k.locationSize;j++)m(k.location+j);i.bindBuffer(i.ARRAY_BUFFER,Zt);for(let j=0;j<k.locationSize;j++)T(k.location+j,Mt/k.locationSize,Y,pt,Mt*st,Mt/k.locationSize*j*st,Q)}}else if(G!==void 0){const pt=G[K];if(pt!==void 0)switch(pt.length){case 2:i.vertexAttrib2fv(k.location,pt);break;case 3:i.vertexAttrib3fv(k.location,pt);break;case 4:i.vertexAttrib4fv(k.location,pt);break;default:i.vertexAttrib1fv(k.location,pt)}}}}b()}function L(){D();for(const M in n){const w=n[M];for(const H in w){const O=w[H];for(const V in O)u(O[V].object),delete O[V];delete w[H]}delete n[M]}}function C(M){if(n[M.id]===void 0)return;const w=n[M.id];for(const H in w){const O=w[H];for(const V in O)u(O[V].object),delete O[V];delete w[H]}delete n[M.id]}function R(M){for(const w in n){const H=n[w];if(H[M.id]===void 0)continue;const O=H[M.id];for(const V in O)u(O[V].object),delete O[V];delete H[M.id]}}function D(){y(),o=!0,s!==r&&(s=r,l(s.object))}function y(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:D,resetDefaultState:y,dispose:L,releaseStatesOfGeometry:C,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:m,disableUnusedAttributes:b}}function og(i,t,e){let n;function r(l){n=l}function s(l,u){i.drawArrays(n,l,u),e.update(u,n,1)}function o(l,u,h){h!==0&&(i.drawArraysInstanced(n,l,u,h),e.update(u,n,h))}function a(l,u,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let d=0;for(let g=0;g<h;g++)d+=u[g];e.update(d,n,1)}function c(l,u,h,f){if(h===0)return;const d=t.get("WEBGL_multi_draw");if(d===null)for(let g=0;g<l.length;g++)o(l[g],u[g],f[g]);else{d.multiDrawArraysInstancedWEBGL(n,l,0,u,0,f,0,h);let g=0;for(let v=0;v<h;v++)g+=u[v]*f[v];e.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function ag(i,t,e,n){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");r=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(R){return!(R!==We&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(R){const D=R===ir&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==fn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==ln&&!D)}function c(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const h=e.logarithmicDepthBuffer===!0,f=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),L=g>0,C=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reverseDepthBuffer:f,maxTextures:d,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:T,maxFragmentUniforms:S,vertexTextures:L,maxSamples:C}}function cg(i){const t=this;let e=null,n=0,r=!1,s=!1;const o=new xn,a=new zt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){const d=h.length!==0||f||n!==0||r;return r=f,n=h.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){e=u(h,f,0)},this.setState=function(h,f,d){const g=h.clippingPlanes,v=h.clipIntersection,m=h.clipShadows,p=i.get(h);if(!r||g===null||g.length===0||s&&!m)s?u(null):l();else{const b=s?0:n,T=b*4;let S=p.clippingState||null;c.value=S,S=u(g,f,T,d);for(let L=0;L!==T;++L)S[L]=e[L];p.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(h,f,d,g){const v=h!==null?h.length:0;let m=null;if(v!==0){if(m=c.value,g!==!0||m===null){const p=d+v*4,b=f.matrixWorldInverse;a.getNormalMatrix(b),(m===null||m.length<p)&&(m=new Float32Array(p));for(let T=0,S=d;T!==v;++T,S+=4)o.copy(h[T]).applyMatrix4(b,a),o.normal.toArray(m,S),m[S+3]=o.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}}function lg(i){let t=new WeakMap;function e(o,a){return a===js?o.mapping=Ai:a===$s&&(o.mapping=bi),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===js||a===$s)if(t.has(o)){const c=t.get(o).texture;return e(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new bf(c.height);return l.fromEquirectangularTexture(i,o),t.set(o,l),o.addEventListener("dispose",r),e(l.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const c=t.get(a);c!==void 0&&(t.delete(a),c.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}const vi=4,il=[.125,.215,.35,.446,.526,.582],Bn=20,Ls=new mu,rl=new Wt;let Ds=null,Us=0,Is=0,Ns=!1;const Fn=(1+Math.sqrt(5))/2,di=1/Fn,sl=[new P(-Fn,di,0),new P(Fn,di,0),new P(-di,0,Fn),new P(di,0,Fn),new P(0,Fn,-di),new P(0,Fn,di),new P(-1,1,-1),new P(1,1,-1),new P(-1,1,1),new P(1,1,1)];class ol{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,r=100){Ds=this._renderer.getRenderTarget(),Us=this._renderer.getActiveCubeFace(),Is=this._renderer.getActiveMipmapLevel(),Ns=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,r,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ll(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=cl(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Ds,Us,Is),this._renderer.xr.enabled=Ns,t.scissorTest=!1,Ur(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Ai||t.mapping===bi?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Ds=this._renderer.getRenderTarget(),Us=this._renderer.getActiveCubeFace(),Is=this._renderer.getActiveMipmapLevel(),Ns=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Je,minFilter:Je,generateMipmaps:!1,type:ir,format:We,colorSpace:Pi,depthBuffer:!1},r=al(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=al(t,e,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=ug(s)),this._blurMaterial=hg(s,t,e)}return r}_compileMaterial(t){const e=new le(this._lodPlanes[0],t);this._renderer.compile(e,Ls)}_sceneToCubeUV(t,e,n,r){const a=new Ie(90,1,e,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,f=u.toneMapping;u.getClearColor(rl),u.toneMapping=Tn,u.autoClear=!1;const d=new Vn({name:"PMREM.Background",side:Ce,depthWrite:!1,depthTest:!1}),g=new le(new Zn,d);let v=!1;const m=t.background;m?m.isColor&&(d.color.copy(m),t.background=null,v=!0):(d.color.copy(rl),v=!0);for(let p=0;p<6;p++){const b=p%3;b===0?(a.up.set(0,c[p],0),a.lookAt(l[p],0,0)):b===1?(a.up.set(0,0,c[p]),a.lookAt(0,l[p],0)):(a.up.set(0,c[p],0),a.lookAt(0,0,l[p]));const T=this._cubeSize;Ur(r,b*T,p>2?T:0,T,T),u.setRenderTarget(r),v&&u.render(g,a),u.render(t,a)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=f,u.autoClear=h,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===Ai||t.mapping===bi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ll()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=cl());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new le(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=t;const c=this._cubeSize;Ur(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(o,Ls)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=sl[(r-s-1)%sl.length];this._blur(t,s-1,s,o,a)}e.autoClear=n}_blur(t,e,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,r,"latitudinal",s),this._halfBlur(o,t,n,n,r,"longitudinal",s)}_halfBlur(t,e,n,r,s,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new le(this._lodPlanes[r],l),f=l.uniforms,d=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Bn-1),v=s/g,m=isFinite(s)?1+Math.floor(u*v):Bn;m>Bn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Bn}`);const p=[];let b=0;for(let R=0;R<Bn;++R){const D=R/v,y=Math.exp(-D*D/2);p.push(y),R===0?b+=y:R<m&&(b+=2*y)}for(let R=0;R<p.length;R++)p[R]=p[R]/b;f.envMap.value=t.texture,f.samples.value=m,f.weights.value=p,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);const{_lodMax:T}=this;f.dTheta.value=g,f.mipInt.value=T-n;const S=this._sizeLods[r],L=3*S*(r>T-vi?r-T+vi:0),C=4*(this._cubeSize-S);Ur(e,L,C,3*S,2*S),c.setRenderTarget(e),c.render(h,Ls)}}function ug(i){const t=[],e=[],n=[];let r=i;const s=i-vi+1+il.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);e.push(a);let c=1/a;o>i-vi?c=il[o-i+vi-1]:o===0&&(c=0),n.push(c);const l=1/(a-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,g=6,v=3,m=2,p=1,b=new Float32Array(v*g*d),T=new Float32Array(m*g*d),S=new Float32Array(p*g*d);for(let C=0;C<d;C++){const R=C%3*2/3-1,D=C>2?0:-1,y=[R,D,0,R+2/3,D,0,R+2/3,D+1,0,R,D,0,R+2/3,D+1,0,R,D+1,0];b.set(y,v*g*C),T.set(f,m*g*C);const M=[C,C,C,C,C,C];S.set(M,p*g*C)}const L=new Pe;L.setAttribute("position",new je(b,v)),L.setAttribute("uv",new je(T,m)),L.setAttribute("faceIndex",new je(S,p)),t.push(L),r>vi&&r--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function al(i,t,e){const n=new Yn(i,t,e);return n.texture.mapping=Jr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ur(i,t,e,n,r){i.viewport.set(t,e,n,r),i.scissor.set(t,e,n,r)}function hg(i,t,e){const n=new Float32Array(Bn),r=new P(0,1,0);return new wn({name:"SphericalGaussianBlur",defines:{n:Bn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,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:nc(),fragmentShader:`
3575
+
3576
+ precision mediump float;
3577
+ precision mediump int;
3578
+
3579
+ varying vec3 vOutputDirection;
3580
+
3581
+ uniform sampler2D envMap;
3582
+ uniform int samples;
3583
+ uniform float weights[ n ];
3584
+ uniform bool latitudinal;
3585
+ uniform float dTheta;
3586
+ uniform float mipInt;
3587
+ uniform vec3 poleAxis;
3588
+
3589
+ #define ENVMAP_TYPE_CUBE_UV
3590
+ #include <cube_uv_reflection_fragment>
3591
+
3592
+ vec3 getSample( float theta, vec3 axis ) {
3593
+
3594
+ float cosTheta = cos( theta );
3595
+ // Rodrigues' axis-angle rotation
3596
+ vec3 sampleDirection = vOutputDirection * cosTheta
3597
+ + cross( axis, vOutputDirection ) * sin( theta )
3598
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3599
+
3600
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3601
+
3602
+ }
3603
+
3604
+ void main() {
3605
+
3606
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3607
+
3608
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3609
+
3610
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3611
+
3612
+ }
3613
+
3614
+ axis = normalize( axis );
3615
+
3616
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3617
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3618
+
3619
+ for ( int i = 1; i < n; i++ ) {
3620
+
3621
+ if ( i >= samples ) {
3622
+
3623
+ break;
3624
+
3625
+ }
3626
+
3627
+ float theta = dTheta * float( i );
3628
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3629
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3630
+
3631
+ }
3632
+
3633
+ }
3634
+ `,blending:En,depthTest:!1,depthWrite:!1})}function cl(){return new wn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:nc(),fragmentShader:`
3635
+
3636
+ precision mediump float;
3637
+ precision mediump int;
3638
+
3639
+ varying vec3 vOutputDirection;
3640
+
3641
+ uniform sampler2D envMap;
3642
+
3643
+ #include <common>
3644
+
3645
+ void main() {
3646
+
3647
+ vec3 outputDirection = normalize( vOutputDirection );
3648
+ vec2 uv = equirectUv( outputDirection );
3649
+
3650
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3651
+
3652
+ }
3653
+ `,blending:En,depthTest:!1,depthWrite:!1})}function ll(){return new wn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:nc(),fragmentShader:`
3654
+
3655
+ precision mediump float;
3656
+ precision mediump int;
3657
+
3658
+ uniform float flipEnvMap;
3659
+
3660
+ varying vec3 vOutputDirection;
3661
+
3662
+ uniform samplerCube envMap;
3663
+
3664
+ void main() {
3665
+
3666
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3667
+
3668
+ }
3669
+ `,blending:En,depthTest:!1,depthWrite:!1})}function nc(){return`
3670
+
3671
+ precision mediump float;
3672
+ precision mediump int;
3673
+
3674
+ attribute float faceIndex;
3675
+
3676
+ varying vec3 vOutputDirection;
3677
+
3678
+ // RH coordinate system; PMREM face-indexing convention
3679
+ vec3 getDirection( vec2 uv, float face ) {
3680
+
3681
+ uv = 2.0 * uv - 1.0;
3682
+
3683
+ vec3 direction = vec3( uv, 1.0 );
3684
+
3685
+ if ( face == 0.0 ) {
3686
+
3687
+ direction = direction.zyx; // ( 1, v, u ) pos x
3688
+
3689
+ } else if ( face == 1.0 ) {
3690
+
3691
+ direction = direction.xzy;
3692
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3693
+
3694
+ } else if ( face == 2.0 ) {
3695
+
3696
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3697
+
3698
+ } else if ( face == 3.0 ) {
3699
+
3700
+ direction = direction.zyx;
3701
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3702
+
3703
+ } else if ( face == 4.0 ) {
3704
+
3705
+ direction = direction.xzy;
3706
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3707
+
3708
+ } else if ( face == 5.0 ) {
3709
+
3710
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3711
+
3712
+ }
3713
+
3714
+ return direction;
3715
+
3716
+ }
3717
+
3718
+ void main() {
3719
+
3720
+ vOutputDirection = getDirection( uv, faceIndex );
3721
+ gl_Position = vec4( position, 1.0 );
3722
+
3723
+ }
3724
+ `}function fg(i){let t=new WeakMap,e=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===js||c===$s,u=c===Ai||c===bi;if(l||u){let h=t.get(a);const f=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return e===null&&(e=new ol(i)),h=l?e.fromEquirectangular(a,h):e.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),h.texture;if(h!==void 0)return h.texture;{const d=a.image;return l&&d&&d.height>0||u&&d&&r(d)?(e===null&&(e=new ol(i)),h=l?e.fromEquirectangular(a):e.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function r(a){let c=0;const l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){const c=a.target;c.removeEventListener("dispose",s);const l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:o}}function dg(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return t[n]=r,r}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const r=e(n);return r===null&&mi("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function pg(i,t,e,n){const r={},s=new WeakMap;function o(h){const f=h.target;f.index!==null&&t.remove(f.index);for(const g in f.attributes)t.remove(f.attributes[g]);f.removeEventListener("dispose",o),delete r[f.id];const d=s.get(f);d&&(t.remove(d),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}function a(h,f){return r[f.id]===!0||(f.addEventListener("dispose",o),r[f.id]=!0,e.memory.geometries++),f}function c(h){const f=h.attributes;for(const d in f)t.update(f[d],i.ARRAY_BUFFER)}function l(h){const f=[],d=h.index,g=h.attributes.position;let v=0;if(d!==null){const b=d.array;v=d.version;for(let T=0,S=b.length;T<S;T+=3){const L=b[T+0],C=b[T+1],R=b[T+2];f.push(L,C,C,R,R,L)}}else if(g!==void 0){const b=g.array;v=g.version;for(let T=0,S=b.length/3-1;T<S;T+=3){const L=T+0,C=T+1,R=T+2;f.push(L,C,C,R,R,L)}}else return;const m=new(Jl(f)?eu:tu)(f,1);m.version=v;const p=s.get(h);p&&t.remove(p),s.set(h,m)}function u(h){const f=s.get(h);if(f){const d=h.index;d!==null&&f.version<d.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function mg(i,t,e){let n;function r(f){n=f}let s,o;function a(f){s=f.type,o=f.bytesPerElement}function c(f,d){i.drawElements(n,d,s,f*o),e.update(d,n,1)}function l(f,d,g){g!==0&&(i.drawElementsInstanced(n,d,s,f*o,g),e.update(d,n,g))}function u(f,d,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,s,f,0,g);let m=0;for(let p=0;p<g;p++)m+=d[p];e.update(m,n,1)}function h(f,d,g,v){if(g===0)return;const m=t.get("WEBGL_multi_draw");if(m===null)for(let p=0;p<f.length;p++)l(f[p]/o,d[p],v[p]);else{m.multiDrawElementsInstancedWEBGL(n,d,0,s,f,0,v,0,g);let p=0;for(let b=0;b<g;b++)p+=d[b]*v[b];e.update(p,n,1)}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function gg(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(e.calls++,o){case i.TRIANGLES:e.triangles+=a*(s/3);break;case i.LINES:e.lines+=a*(s/2);break;case i.LINE_STRIP:e.lines+=a*(s-1);break;case i.LINE_LOOP:e.lines+=a*s;break;case i.POINTS:e.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:r,update:n}}function _g(i,t,e){const n=new WeakMap,r=new ee;function s(o,a,c){const l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0;let f=n.get(a);if(f===void 0||f.count!==h){let M=function(){D.dispose(),n.delete(a),a.removeEventListener("dispose",M)};var d=M;f!==void 0&&f.texture.dispose();const g=a.morphAttributes.position!==void 0,v=a.morphAttributes.normal!==void 0,m=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],b=a.morphAttributes.normal||[],T=a.morphAttributes.color||[];let S=0;g===!0&&(S=1),v===!0&&(S=2),m===!0&&(S=3);let L=a.attributes.position.count*S,C=1;L>t.maxTextureSize&&(C=Math.ceil(L/t.maxTextureSize),L=t.maxTextureSize);const R=new Float32Array(L*C*4*h),D=new jl(R,L,C,h);D.type=ln,D.needsUpdate=!0;const y=S*4;for(let w=0;w<h;w++){const H=p[w],O=b[w],V=T[w],X=L*C*4*w;for(let G=0;G<H.count;G++){const K=G*y;g===!0&&(r.fromBufferAttribute(H,G),R[X+K+0]=r.x,R[X+K+1]=r.y,R[X+K+2]=r.z,R[X+K+3]=0),v===!0&&(r.fromBufferAttribute(O,G),R[X+K+4]=r.x,R[X+K+5]=r.y,R[X+K+6]=r.z,R[X+K+7]=0),m===!0&&(r.fromBufferAttribute(V,G),R[X+K+8]=r.x,R[X+K+9]=r.y,R[X+K+10]=r.z,R[X+K+11]=V.itemSize===4?r.w:1)}}f={count:h,texture:D,size:new at(L,C)},n.set(a,f),a.addEventListener("dispose",M)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,e);else{let g=0;for(let m=0;m<l.length;m++)g+=l[m];const v=a.morphTargetsRelative?1:1-g;c.getUniforms().setValue(i,"morphTargetBaseInfluence",v),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",f.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:s}}function vg(i,t,e,n){let r=new WeakMap;function s(c){const l=n.render.frame,u=c.geometry,h=t.get(c,u);if(r.get(h)!==l&&(t.update(h),r.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==l&&(f.update(),r.set(f,l))}return h}function o(){r=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:s,dispose:o}}const _u=new ye,ul=new ou(1,1),vu=new jl,xu=new uf,Mu=new ru,hl=[],fl=[],dl=new Float32Array(16),pl=new Float32Array(9),ml=new Float32Array(4);function Ui(i,t,e){const n=i[0];if(n<=0||n>0)return i;const r=t*e;let s=hl[r];if(s===void 0&&(s=new Float32Array(r),hl[r]=s),t!==0){n.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(s,a)}return s}function fe(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function de(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function jr(i,t){let e=fl[t];e===void 0&&(e=new Int32Array(t),fl[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function xg(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Mg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(fe(e,t))return;i.uniform2fv(this.addr,t),de(e,t)}}function Sg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(fe(e,t))return;i.uniform3fv(this.addr,t),de(e,t)}}function yg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(fe(e,t))return;i.uniform4fv(this.addr,t),de(e,t)}}function Eg(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(fe(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),de(e,t)}else{if(fe(e,n))return;ml.set(n),i.uniformMatrix2fv(this.addr,!1,ml),de(e,n)}}function Tg(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(fe(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),de(e,t)}else{if(fe(e,n))return;pl.set(n),i.uniformMatrix3fv(this.addr,!1,pl),de(e,n)}}function Ag(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(fe(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),de(e,t)}else{if(fe(e,n))return;dl.set(n),i.uniformMatrix4fv(this.addr,!1,dl),de(e,n)}}function bg(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function wg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(fe(e,t))return;i.uniform2iv(this.addr,t),de(e,t)}}function Rg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(fe(e,t))return;i.uniform3iv(this.addr,t),de(e,t)}}function Cg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(fe(e,t))return;i.uniform4iv(this.addr,t),de(e,t)}}function Pg(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Lg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(fe(e,t))return;i.uniform2uiv(this.addr,t),de(e,t)}}function Dg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(fe(e,t))return;i.uniform3uiv(this.addr,t),de(e,t)}}function Ug(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(fe(e,t))return;i.uniform4uiv(this.addr,t),de(e,t)}}function Ig(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(ul.compareFunction=Zl,s=ul):s=_u,e.setTexture2D(t||s,r)}function Ng(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture3D(t||xu,r)}function Fg(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTextureCube(t||Mu,r)}function Og(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture2DArray(t||vu,r)}function Bg(i){switch(i){case 5126:return xg;case 35664:return Mg;case 35665:return Sg;case 35666:return yg;case 35674:return Eg;case 35675:return Tg;case 35676:return Ag;case 5124:case 35670:return bg;case 35667:case 35671:return wg;case 35668:case 35672:return Rg;case 35669:case 35673:return Cg;case 5125:return Pg;case 36294:return Lg;case 36295:return Dg;case 36296:return Ug;case 35678:case 36198:case 36298:case 36306:case 35682:return Ig;case 35679:case 36299:case 36307:return Ng;case 35680:case 36300:case 36308:case 36293:return Fg;case 36289:case 36303:case 36311:case 36292:return Og}}function zg(i,t){i.uniform1fv(this.addr,t)}function Hg(i,t){const e=Ui(t,this.size,2);i.uniform2fv(this.addr,e)}function kg(i,t){const e=Ui(t,this.size,3);i.uniform3fv(this.addr,e)}function Gg(i,t){const e=Ui(t,this.size,4);i.uniform4fv(this.addr,e)}function Vg(i,t){const e=Ui(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Wg(i,t){const e=Ui(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Xg(i,t){const e=Ui(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function qg(i,t){i.uniform1iv(this.addr,t)}function Yg(i,t){i.uniform2iv(this.addr,t)}function Zg(i,t){i.uniform3iv(this.addr,t)}function Jg(i,t){i.uniform4iv(this.addr,t)}function Kg(i,t){i.uniform1uiv(this.addr,t)}function jg(i,t){i.uniform2uiv(this.addr,t)}function $g(i,t){i.uniform3uiv(this.addr,t)}function Qg(i,t){i.uniform4uiv(this.addr,t)}function t_(i,t,e){const n=this.cache,r=t.length,s=jr(e,r);fe(n,s)||(i.uniform1iv(this.addr,s),de(n,s));for(let o=0;o!==r;++o)e.setTexture2D(t[o]||_u,s[o])}function e_(i,t,e){const n=this.cache,r=t.length,s=jr(e,r);fe(n,s)||(i.uniform1iv(this.addr,s),de(n,s));for(let o=0;o!==r;++o)e.setTexture3D(t[o]||xu,s[o])}function n_(i,t,e){const n=this.cache,r=t.length,s=jr(e,r);fe(n,s)||(i.uniform1iv(this.addr,s),de(n,s));for(let o=0;o!==r;++o)e.setTextureCube(t[o]||Mu,s[o])}function i_(i,t,e){const n=this.cache,r=t.length,s=jr(e,r);fe(n,s)||(i.uniform1iv(this.addr,s),de(n,s));for(let o=0;o!==r;++o)e.setTexture2DArray(t[o]||vu,s[o])}function r_(i){switch(i){case 5126:return zg;case 35664:return Hg;case 35665:return kg;case 35666:return Gg;case 35674:return Vg;case 35675:return Wg;case 35676:return Xg;case 5124:case 35670:return qg;case 35667:case 35671:return Yg;case 35668:case 35672:return Zg;case 35669:case 35673:return Jg;case 5125:return Kg;case 36294:return jg;case 36295:return $g;case 36296:return Qg;case 35678:case 36198:case 36298:case 36306:case 35682:return t_;case 35679:case 36299:case 36307:return e_;case 35680:case 36300:case 36308:case 36293:return n_;case 36289:case 36303:case 36311:case 36292:return i_}}class s_{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Bg(e.type)}}class o_{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=r_(e.type)}}class a_{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const a=r[s];a.setValue(t,e[a.id],n)}}}const Fs=/(\w+)(\])?(\[|\.)?/g;function gl(i,t){i.seq.push(t),i.map[t.id]=t}function c_(i,t,e){const n=i.name,r=n.length;for(Fs.lastIndex=0;;){const s=Fs.exec(n),o=Fs.lastIndex;let a=s[1];const c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){gl(e,l===void 0?new s_(a,i,t):new o_(a,i,t));break}else{let h=e.map[a];h===void 0&&(h=new a_(a),gl(e,h)),e=h}}}class Hr{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=t.getActiveUniform(e,r),o=t.getUniformLocation(e,s.name);c_(s,o,this)}}setValue(t,e,n,r){const s=this.map[e];s!==void 0&&s.setValue(t,n,r)}setOptional(t,e,n){const r=e[n];r!==void 0&&this.setValue(t,n,r)}static upload(t,e,n,r){for(let s=0,o=e.length;s!==o;++s){const a=e[s],c=n[a.id];c.needsUpdate!==!1&&a.setValue(t,c.value,r)}}static seqWithValue(t,e){const n=[];for(let r=0,s=t.length;r!==s;++r){const o=t[r];o.id in e&&n.push(o)}return n}}function _l(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const l_=37297;let u_=0;function h_(i,t){const e=i.split(`
3725
+ `),n=[],r=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let o=r;o<s;o++){const a=o+1;n.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return n.join(`
3726
+ `)}const vl=new zt;function f_(i){Kt._getMatrix(vl,Kt.workingColorSpace,i);const t=`mat3( ${vl.elements.map(e=>e.toFixed(4))} )`;switch(Kt.getTransfer(i)){case Vr:return[t,"LinearTransferOETF"];case te:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function xl(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),r=i.getShaderInfoLog(t).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const o=parseInt(s[1]);return e.toUpperCase()+`
3727
+
3728
+ `+r+`
3729
+
3730
+ `+h_(i.getShaderSource(t),o)}else return r}function d_(i,t){const e=f_(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
3731
+ `)}function p_(i,t){let e;switch(t){case Mh:e="Linear";break;case Sh:e="Reinhard";break;case yh:e="Cineon";break;case Nl:e="ACESFilmic";break;case Th:e="AgX";break;case Ah:e="Neutral";break;case Eh:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const Ir=new P;function m_(){Kt.getLuminanceCoefficients(Ir);const i=Ir.x.toFixed(4),t=Ir.y.toFixed(4),e=Ir.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3732
+ `)}function g_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Vi).join(`
3733
+ `)}function __(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3734
+ `)}function v_(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(t,r),o=s.name;let a=1;s.type===i.FLOAT_MAT2&&(a=2),s.type===i.FLOAT_MAT3&&(a=3),s.type===i.FLOAT_MAT4&&(a=4),e[o]={type:s.type,location:i.getAttribLocation(t,o),locationSize:a}}return e}function Vi(i){return i!==""}function Ml(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Sl(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const x_=/^[ \t]*#include +<([\w\d./]+)>/gm;function Lo(i){return i.replace(x_,S_)}const M_=new Map;function S_(i,t){let e=kt[t];if(e===void 0){const n=M_.get(t);if(n!==void 0)e=kt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Lo(e)}const y_=/#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 yl(i){return i.replace(y_,E_)}function E_(i,t,e,n){let r="";for(let s=parseInt(t);s<parseInt(e);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function El(i){let t=`precision ${i.precision} float;
3735
+ precision ${i.precision} int;
3736
+ precision ${i.precision} sampler2D;
3737
+ precision ${i.precision} samplerCube;
3738
+ precision ${i.precision} sampler3D;
3739
+ precision ${i.precision} sampler2DArray;
3740
+ precision ${i.precision} sampler2DShadow;
3741
+ precision ${i.precision} samplerCubeShadow;
3742
+ precision ${i.precision} sampler2DArrayShadow;
3743
+ precision ${i.precision} isampler2D;
3744
+ precision ${i.precision} isampler3D;
3745
+ precision ${i.precision} isamplerCube;
3746
+ precision ${i.precision} isampler2DArray;
3747
+ precision ${i.precision} usampler2D;
3748
+ precision ${i.precision} usampler3D;
3749
+ precision ${i.precision} usamplerCube;
3750
+ precision ${i.precision} usampler2DArray;
3751
+ `;return i.precision==="highp"?t+=`
3752
+ #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
3753
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
3754
+ #define LOW_PRECISION`),t}function T_(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Dl?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===Ul?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===an&&(t="SHADOWMAP_TYPE_VSM"),t}function A_(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Ai:case bi:t="ENVMAP_TYPE_CUBE";break;case Jr:t="ENVMAP_TYPE_CUBE_UV";break}return t}function b_(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case bi:t="ENVMAP_MODE_REFRACTION";break}return t}function w_(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Il:t="ENVMAP_BLENDING_MULTIPLY";break;case vh:t="ENVMAP_BLENDING_MIX";break;case xh:t="ENVMAP_BLENDING_ADD";break}return t}function R_(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function C_(i,t,e,n){const r=i.getContext(),s=e.defines;let o=e.vertexShader,a=e.fragmentShader;const c=T_(e),l=A_(e),u=b_(e),h=w_(e),f=R_(e),d=g_(e),g=__(s),v=r.createProgram();let m,p,b=e.glslVersion?"#version "+e.glslVersion+`
3755
+ `:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Vi).join(`
3756
+ `),m.length>0&&(m+=`
3757
+ `),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Vi).join(`
3758
+ `),p.length>0&&(p+=`
3759
+ `)):(m=[El(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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",`
3760
+ `].filter(Vi).join(`
3761
+ `),p=[El(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+u:"",e.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Tn?"#define TONE_MAPPING":"",e.toneMapping!==Tn?kt.tonemapping_pars_fragment:"",e.toneMapping!==Tn?p_("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",kt.colorspace_pars_fragment,d_("linearToOutputTexel",e.outputColorSpace),m_(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3762
+ `].filter(Vi).join(`
3763
+ `)),o=Lo(o),o=Ml(o,e),o=Sl(o,e),a=Lo(a),a=Ml(a,e),a=Sl(a,e),o=yl(o),a=yl(a),e.isRawShaderMaterial!==!0&&(b=`#version 300 es
3764
+ `,m=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3765
+ `)+`
3766
+ `+m,p=["#define varying in",e.glslVersion===Ac?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Ac?"":"#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(`
3767
+ `)+`
3768
+ `+p);const T=b+m+o,S=b+p+a,L=_l(r,r.VERTEX_SHADER,T),C=_l(r,r.FRAGMENT_SHADER,S);r.attachShader(v,L),r.attachShader(v,C),e.index0AttributeName!==void 0?r.bindAttribLocation(v,0,e.index0AttributeName):e.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function R(w){if(i.debug.checkShaderErrors){const H=r.getProgramInfoLog(v).trim(),O=r.getShaderInfoLog(L).trim(),V=r.getShaderInfoLog(C).trim();let X=!0,G=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if(X=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,v,L,C);else{const K=xl(r,L,"vertex"),k=xl(r,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
3769
+
3770
+ Material Name: `+w.name+`
3771
+ Material Type: `+w.type+`
3772
+
3773
+ Program Info Log: `+H+`
3774
+ `+K+`
3775
+ `+k)}else H!==""?console.warn("THREE.WebGLProgram: Program Info Log:",H):(O===""||V==="")&&(G=!1);G&&(w.diagnostics={runnable:X,programLog:H,vertexShader:{log:O,prefix:m},fragmentShader:{log:V,prefix:p}})}r.deleteShader(L),r.deleteShader(C),D=new Hr(r,v),y=v_(r,v)}let D;this.getUniforms=function(){return D===void 0&&R(this),D};let y;this.getAttributes=function(){return y===void 0&&R(this),y};let M=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,l_)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=u_++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=L,this.fragmentShader=C,this}let P_=0;class L_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,r=this._getShaderStage(e),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new D_(t),e.set(t,n)),n}}class D_{constructor(t){this.id=P_++,this.code=t,this.usedTimes=0}}function U_(i,t,e,n,r,s,o){const a=new Va,c=new L_,l=new Set,u=[],h=r.logarithmicDepthBuffer,f=r.vertexTextures;let d=r.precision;const g={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 v(y){return l.add(y),y===0?"uv":`uv${y}`}function m(y,M,w,H,O){const V=H.fog,X=O.geometry,G=y.isMeshStandardMaterial?H.environment:null,K=(y.isMeshStandardMaterial?e:t).get(y.envMap||G),k=K&&K.mapping===Jr?K.image.height:null,ct=g[y.type];y.precision!==null&&(d=r.getMaxPrecision(y.precision),d!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",d,"instead."));const pt=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Mt=pt!==void 0?pt.length:0;let Ft=0;X.morphAttributes.position!==void 0&&(Ft=1),X.morphAttributes.normal!==void 0&&(Ft=2),X.morphAttributes.color!==void 0&&(Ft=3);let Zt,Y,st,Q;if(ct){const Qt=Ye[ct];Zt=Qt.vertexShader,Y=Qt.fragmentShader}else Zt=y.vertexShader,Y=y.fragmentShader,c.update(y),st=c.getVertexShaderID(y),Q=c.getFragmentShaderID(y);const j=i.getRenderTarget(),ut=i.state.buffers.depth.getReversed(),vt=O.isInstancedMesh===!0,Rt=O.isBatchedMesh===!0,Vt=!!y.map,J=!!y.matcap,et=!!K,A=!!y.aoMap,bt=!!y.lightMap,nt=!!y.bumpMap,St=!!y.normalMap,ot=!!y.displacementMap,Dt=!!y.emissiveMap,mt=!!y.metalnessMap,E=!!y.roughnessMap,_=y.anisotropy>0,F=y.clearcoat>0,q=y.dispersion>0,tt=y.iridescence>0,Z=y.sheen>0,wt=y.transmission>0,ht=_&&!!y.anisotropyMap,xt=F&&!!y.clearcoatMap,Xt=F&&!!y.clearcoatNormalMap,rt=F&&!!y.clearcoatRoughnessMap,Et=tt&&!!y.iridescenceMap,Lt=tt&&!!y.iridescenceThicknessMap,Ut=Z&&!!y.sheenColorMap,Tt=Z&&!!y.sheenRoughnessMap,qt=!!y.specularMap,Ht=!!y.specularColorMap,ie=!!y.specularIntensityMap,U=wt&&!!y.transmissionMap,ft=wt&&!!y.thicknessMap,W=!!y.gradientMap,$=!!y.alphaMap,_t=y.alphaTest>0,gt=!!y.alphaHash,Bt=!!y.extensions;let ae=Tn;y.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(ae=i.toneMapping);const xe={shaderID:ct,shaderType:y.type,shaderName:y.name,vertexShader:Zt,fragmentShader:Y,defines:y.defines,customVertexShaderID:st,customFragmentShaderID:Q,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:d,batching:Rt,batchingColor:Rt&&O._colorsTexture!==null,instancing:vt,instancingColor:vt&&O.instanceColor!==null,instancingMorph:vt&&O.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:j===null?i.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Pi,alphaToCoverage:!!y.alphaToCoverage,map:Vt,matcap:J,envMap:et,envMapMode:et&&K.mapping,envMapCubeUVHeight:k,aoMap:A,lightMap:bt,bumpMap:nt,normalMap:St,displacementMap:f&&ot,emissiveMap:Dt,normalMapObjectSpace:St&&y.normalMapType===Ch,normalMapTangentSpace:St&&y.normalMapType===Yl,metalnessMap:mt,roughnessMap:E,anisotropy:_,anisotropyMap:ht,clearcoat:F,clearcoatMap:xt,clearcoatNormalMap:Xt,clearcoatRoughnessMap:rt,dispersion:q,iridescence:tt,iridescenceMap:Et,iridescenceThicknessMap:Lt,sheen:Z,sheenColorMap:Ut,sheenRoughnessMap:Tt,specularMap:qt,specularColorMap:Ht,specularIntensityMap:ie,transmission:wt,transmissionMap:U,thicknessMap:ft,gradientMap:W,opaque:y.transparent===!1&&y.blending===Mi&&y.alphaToCoverage===!1,alphaMap:$,alphaTest:_t,alphaHash:gt,combine:y.combine,mapUv:Vt&&v(y.map.channel),aoMapUv:A&&v(y.aoMap.channel),lightMapUv:bt&&v(y.lightMap.channel),bumpMapUv:nt&&v(y.bumpMap.channel),normalMapUv:St&&v(y.normalMap.channel),displacementMapUv:ot&&v(y.displacementMap.channel),emissiveMapUv:Dt&&v(y.emissiveMap.channel),metalnessMapUv:mt&&v(y.metalnessMap.channel),roughnessMapUv:E&&v(y.roughnessMap.channel),anisotropyMapUv:ht&&v(y.anisotropyMap.channel),clearcoatMapUv:xt&&v(y.clearcoatMap.channel),clearcoatNormalMapUv:Xt&&v(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&v(y.clearcoatRoughnessMap.channel),iridescenceMapUv:Et&&v(y.iridescenceMap.channel),iridescenceThicknessMapUv:Lt&&v(y.iridescenceThicknessMap.channel),sheenColorMapUv:Ut&&v(y.sheenColorMap.channel),sheenRoughnessMapUv:Tt&&v(y.sheenRoughnessMap.channel),specularMapUv:qt&&v(y.specularMap.channel),specularColorMapUv:Ht&&v(y.specularColorMap.channel),specularIntensityMapUv:ie&&v(y.specularIntensityMap.channel),transmissionMapUv:U&&v(y.transmissionMap.channel),thicknessMapUv:ft&&v(y.thicknessMap.channel),alphaMapUv:$&&v(y.alphaMap.channel),vertexTangents:!!X.attributes.tangent&&(St||_),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!X.attributes.uv&&(Vt||$),fog:!!V,useFog:y.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:ut,skinning:O.isSkinnedMesh===!0,morphTargets:X.morphAttributes.position!==void 0,morphNormals:X.morphAttributes.normal!==void 0,morphColors:X.morphAttributes.color!==void 0,morphTargetsCount:Mt,morphTextureStride:Ft,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:o.numPlanes,numClipIntersection:o.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&w.length>0,shadowMapType:i.shadowMap.type,toneMapping:ae,decodeVideoTexture:Vt&&y.map.isVideoTexture===!0&&Kt.getTransfer(y.map.colorSpace)===te,decodeVideoTextureEmissive:Dt&&y.emissiveMap.isVideoTexture===!0&&Kt.getTransfer(y.emissiveMap.colorSpace)===te,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===Ze,flipSided:y.side===Ce,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:Bt&&y.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Bt&&y.extensions.multiDraw===!0||Rt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return xe.vertexUv1s=l.has(1),xe.vertexUv2s=l.has(2),xe.vertexUv3s=l.has(3),l.clear(),xe}function p(y){const M=[];if(y.shaderID?M.push(y.shaderID):(M.push(y.customVertexShaderID),M.push(y.customFragmentShaderID)),y.defines!==void 0)for(const w in y.defines)M.push(w),M.push(y.defines[w]);return y.isRawShaderMaterial===!1&&(b(M,y),T(M,y),M.push(i.outputColorSpace)),M.push(y.customProgramCacheKey),M.join()}function b(y,M){y.push(M.precision),y.push(M.outputColorSpace),y.push(M.envMapMode),y.push(M.envMapCubeUVHeight),y.push(M.mapUv),y.push(M.alphaMapUv),y.push(M.lightMapUv),y.push(M.aoMapUv),y.push(M.bumpMapUv),y.push(M.normalMapUv),y.push(M.displacementMapUv),y.push(M.emissiveMapUv),y.push(M.metalnessMapUv),y.push(M.roughnessMapUv),y.push(M.anisotropyMapUv),y.push(M.clearcoatMapUv),y.push(M.clearcoatNormalMapUv),y.push(M.clearcoatRoughnessMapUv),y.push(M.iridescenceMapUv),y.push(M.iridescenceThicknessMapUv),y.push(M.sheenColorMapUv),y.push(M.sheenRoughnessMapUv),y.push(M.specularMapUv),y.push(M.specularColorMapUv),y.push(M.specularIntensityMapUv),y.push(M.transmissionMapUv),y.push(M.thicknessMapUv),y.push(M.combine),y.push(M.fogExp2),y.push(M.sizeAttenuation),y.push(M.morphTargetsCount),y.push(M.morphAttributeCount),y.push(M.numDirLights),y.push(M.numPointLights),y.push(M.numSpotLights),y.push(M.numSpotLightMaps),y.push(M.numHemiLights),y.push(M.numRectAreaLights),y.push(M.numDirLightShadows),y.push(M.numPointLightShadows),y.push(M.numSpotLightShadows),y.push(M.numSpotLightShadowsWithMaps),y.push(M.numLightProbes),y.push(M.shadowMapType),y.push(M.toneMapping),y.push(M.numClippingPlanes),y.push(M.numClipIntersection),y.push(M.depthPacking)}function T(y,M){a.disableAll(),M.supportsVertexTextures&&a.enable(0),M.instancing&&a.enable(1),M.instancingColor&&a.enable(2),M.instancingMorph&&a.enable(3),M.matcap&&a.enable(4),M.envMap&&a.enable(5),M.normalMapObjectSpace&&a.enable(6),M.normalMapTangentSpace&&a.enable(7),M.clearcoat&&a.enable(8),M.iridescence&&a.enable(9),M.alphaTest&&a.enable(10),M.vertexColors&&a.enable(11),M.vertexAlphas&&a.enable(12),M.vertexUv1s&&a.enable(13),M.vertexUv2s&&a.enable(14),M.vertexUv3s&&a.enable(15),M.vertexTangents&&a.enable(16),M.anisotropy&&a.enable(17),M.alphaHash&&a.enable(18),M.batching&&a.enable(19),M.dispersion&&a.enable(20),M.batchingColor&&a.enable(21),y.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.reverseDepthBuffer&&a.enable(4),M.skinning&&a.enable(5),M.morphTargets&&a.enable(6),M.morphNormals&&a.enable(7),M.morphColors&&a.enable(8),M.premultipliedAlpha&&a.enable(9),M.shadowMapEnabled&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.transmission&&a.enable(15),M.sheen&&a.enable(16),M.opaque&&a.enable(17),M.pointsUvs&&a.enable(18),M.decodeVideoTexture&&a.enable(19),M.decodeVideoTextureEmissive&&a.enable(20),M.alphaToCoverage&&a.enable(21),y.push(a.mask)}function S(y){const M=g[y.type];let w;if(M){const H=Ye[M];w=yf.clone(H.uniforms)}else w=y.uniforms;return w}function L(y,M){let w;for(let H=0,O=u.length;H<O;H++){const V=u[H];if(V.cacheKey===M){w=V,++w.usedTimes;break}}return w===void 0&&(w=new C_(i,M,y,s),u.push(w)),w}function C(y){if(--y.usedTimes===0){const M=u.indexOf(y);u[M]=u[u.length-1],u.pop(),y.destroy()}}function R(y){c.remove(y)}function D(){c.dispose()}return{getParameters:m,getProgramCacheKey:p,getUniforms:S,acquireProgram:L,releaseProgram:C,releaseShaderCache:R,programs:u,dispose:D}}function I_(){let i=new WeakMap;function t(o){return i.has(o)}function e(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,c){i.get(o)[a]=c}function s(){i=new WeakMap}return{has:t,get:e,remove:n,update:r,dispose:s}}function N_(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function Tl(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Al(){const i=[];let t=0;const e=[],n=[],r=[];function s(){t=0,e.length=0,n.length=0,r.length=0}function o(h,f,d,g,v,m){let p=i[t];return p===void 0?(p={id:h.id,object:h,geometry:f,material:d,groupOrder:g,renderOrder:h.renderOrder,z:v,group:m},i[t]=p):(p.id=h.id,p.object=h,p.geometry=f,p.material=d,p.groupOrder=g,p.renderOrder=h.renderOrder,p.z=v,p.group=m),t++,p}function a(h,f,d,g,v,m){const p=o(h,f,d,g,v,m);d.transmission>0?n.push(p):d.transparent===!0?r.push(p):e.push(p)}function c(h,f,d,g,v,m){const p=o(h,f,d,g,v,m);d.transmission>0?n.unshift(p):d.transparent===!0?r.unshift(p):e.unshift(p)}function l(h,f){e.length>1&&e.sort(h||N_),n.length>1&&n.sort(f||Tl),r.length>1&&r.sort(f||Tl)}function u(){for(let h=t,f=i.length;h<f;h++){const d=i[h];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:e,transmissive:n,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function F_(){let i=new WeakMap;function t(n,r){const s=i.get(n);let o;return s===void 0?(o=new Al,i.set(n,[o])):r>=s.length?(o=new Al,s.push(o)):o=s[r],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function O_(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new Wt};break;case"SpotLight":e={position:new P,direction:new P,color:new Wt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new Wt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new Wt,groundColor:new Wt};break;case"RectAreaLight":e={color:new Wt,position:new P,halfWidth:new P,halfHeight:new P};break}return i[t.id]=e,e}}}function B_(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new at,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let z_=0;function H_(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function k_(i){const t=new O_,e=B_(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new P);const r=new P,s=new re,o=new re;function a(l){let u=0,h=0,f=0;for(let y=0;y<9;y++)n.probe[y].set(0,0,0);let d=0,g=0,v=0,m=0,p=0,b=0,T=0,S=0,L=0,C=0,R=0;l.sort(H_);for(let y=0,M=l.length;y<M;y++){const w=l[y],H=w.color,O=w.intensity,V=w.distance,X=w.shadow&&w.shadow.map?w.shadow.map.texture:null;if(w.isAmbientLight)u+=H.r*O,h+=H.g*O,f+=H.b*O;else if(w.isLightProbe){for(let G=0;G<9;G++)n.probe[G].addScaledVector(w.sh.coefficients[G],O);R++}else if(w.isDirectionalLight){const G=t.get(w);if(G.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){const K=w.shadow,k=e.get(w);k.shadowIntensity=K.intensity,k.shadowBias=K.bias,k.shadowNormalBias=K.normalBias,k.shadowRadius=K.radius,k.shadowMapSize=K.mapSize,n.directionalShadow[d]=k,n.directionalShadowMap[d]=X,n.directionalShadowMatrix[d]=w.shadow.matrix,b++}n.directional[d]=G,d++}else if(w.isSpotLight){const G=t.get(w);G.position.setFromMatrixPosition(w.matrixWorld),G.color.copy(H).multiplyScalar(O),G.distance=V,G.coneCos=Math.cos(w.angle),G.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),G.decay=w.decay,n.spot[v]=G;const K=w.shadow;if(w.map&&(n.spotLightMap[L]=w.map,L++,K.updateMatrices(w),w.castShadow&&C++),n.spotLightMatrix[v]=K.matrix,w.castShadow){const k=e.get(w);k.shadowIntensity=K.intensity,k.shadowBias=K.bias,k.shadowNormalBias=K.normalBias,k.shadowRadius=K.radius,k.shadowMapSize=K.mapSize,n.spotShadow[v]=k,n.spotShadowMap[v]=X,S++}v++}else if(w.isRectAreaLight){const G=t.get(w);G.color.copy(H).multiplyScalar(O),G.halfWidth.set(w.width*.5,0,0),G.halfHeight.set(0,w.height*.5,0),n.rectArea[m]=G,m++}else if(w.isPointLight){const G=t.get(w);if(G.color.copy(w.color).multiplyScalar(w.intensity),G.distance=w.distance,G.decay=w.decay,w.castShadow){const K=w.shadow,k=e.get(w);k.shadowIntensity=K.intensity,k.shadowBias=K.bias,k.shadowNormalBias=K.normalBias,k.shadowRadius=K.radius,k.shadowMapSize=K.mapSize,k.shadowCameraNear=K.camera.near,k.shadowCameraFar=K.camera.far,n.pointShadow[g]=k,n.pointShadowMap[g]=X,n.pointShadowMatrix[g]=w.shadow.matrix,T++}n.point[g]=G,g++}else if(w.isHemisphereLight){const G=t.get(w);G.skyColor.copy(w.color).multiplyScalar(O),G.groundColor.copy(w.groundColor).multiplyScalar(O),n.hemi[p]=G,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=lt.LTC_FLOAT_1,n.rectAreaLTC2=lt.LTC_FLOAT_2):(n.rectAreaLTC1=lt.LTC_HALF_1,n.rectAreaLTC2=lt.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=f;const D=n.hash;(D.directionalLength!==d||D.pointLength!==g||D.spotLength!==v||D.rectAreaLength!==m||D.hemiLength!==p||D.numDirectionalShadows!==b||D.numPointShadows!==T||D.numSpotShadows!==S||D.numSpotMaps!==L||D.numLightProbes!==R)&&(n.directional.length=d,n.spot.length=v,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=S+L-C,n.spotLightMap.length=L,n.numSpotLightShadowsWithMaps=C,n.numLightProbes=R,D.directionalLength=d,D.pointLength=g,D.spotLength=v,D.rectAreaLength=m,D.hemiLength=p,D.numDirectionalShadows=b,D.numPointShadows=T,D.numSpotShadows=S,D.numSpotMaps=L,D.numLightProbes=R,n.version=z_++)}function c(l,u){let h=0,f=0,d=0,g=0,v=0;const m=u.matrixWorldInverse;for(let p=0,b=l.length;p<b;p++){const T=l[p];if(T.isDirectionalLight){const S=n.directional[h];S.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),h++}else if(T.isSpotLight){const S=n.spot[d];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),d++}else if(T.isRectAreaLight){const S=n.rectArea[g];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),o.identity(),s.copy(T.matrixWorld),s.premultiply(m),o.extractRotation(s),S.halfWidth.set(T.width*.5,0,0),S.halfHeight.set(0,T.height*.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),g++}else if(T.isPointLight){const S=n.point[f];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),f++}else if(T.isHemisphereLight){const S=n.hemi[v];S.direction.setFromMatrixPosition(T.matrixWorld),S.direction.transformDirection(m),v++}}}return{setup:a,setupView:c,state:n}}function bl(i){const t=new k_(i),e=[],n=[];function r(u){l.camera=u,e.length=0,n.length=0}function s(u){e.push(u)}function o(u){n.push(u)}function a(){t.setup(e)}function c(u){t.setupView(e,u)}const l={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function G_(i){let t=new WeakMap;function e(r,s=0){const o=t.get(r);let a;return o===void 0?(a=new bl(i),t.set(r,[a])):s>=o.length?(a=new bl(i),o.push(a)):a=o[s],a}function n(){t=new WeakMap}return{get:e,dispose:n}}const V_=`void main() {
3776
+ gl_Position = vec4( position, 1.0 );
3777
+ }`,W_=`uniform sampler2D shadow_pass;
3778
+ uniform vec2 resolution;
3779
+ uniform float radius;
3780
+ #include <packing>
3781
+ void main() {
3782
+ const float samples = float( VSM_SAMPLES );
3783
+ float mean = 0.0;
3784
+ float squared_mean = 0.0;
3785
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3786
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3787
+ for ( float i = 0.0; i < samples; i ++ ) {
3788
+ float uvOffset = uvStart + i * uvStride;
3789
+ #ifdef HORIZONTAL_PASS
3790
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3791
+ mean += distribution.x;
3792
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3793
+ #else
3794
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3795
+ mean += depth;
3796
+ squared_mean += depth * depth;
3797
+ #endif
3798
+ }
3799
+ mean = mean / samples;
3800
+ squared_mean = squared_mean / samples;
3801
+ float std_dev = sqrt( squared_mean - mean * mean );
3802
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3803
+ }`;function X_(i,t,e){let n=new Xa;const r=new at,s=new at,o=new ee,a=new ld({depthPacking:Rh}),c=new ud,l={},u=e.maxTextureSize,h={[bn]:Ce,[Ce]:bn,[Ze]:Ze},f=new wn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new at},radius:{value:4}},vertexShader:V_,fragmentShader:W_}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const g=new Pe;g.setAttribute("position",new je(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new le(g,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Dl;let p=this.type;this.render=function(C,R,D){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||C.length===0)return;const y=i.getRenderTarget(),M=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),H=i.state;H.setBlending(En),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const O=p!==an&&this.type===an,V=p===an&&this.type!==an;for(let X=0,G=C.length;X<G;X++){const K=C[X],k=K.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);const ct=k.getFrameExtents();if(r.multiply(ct),s.copy(k.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ct.x),r.x=s.x*ct.x,k.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ct.y),r.y=s.y*ct.y,k.mapSize.y=s.y)),k.map===null||O===!0||V===!0){const Mt=this.type!==an?{minFilter:Xe,magFilter:Xe}:{};k.map!==null&&k.map.dispose(),k.map=new Yn(r.x,r.y,Mt),k.map.texture.name=K.name+".shadowMap",k.camera.updateProjectionMatrix()}i.setRenderTarget(k.map),i.clear();const pt=k.getViewportCount();for(let Mt=0;Mt<pt;Mt++){const Ft=k.getViewport(Mt);o.set(s.x*Ft.x,s.y*Ft.y,s.x*Ft.z,s.y*Ft.w),H.viewport(o),k.updateMatrices(K,Mt),n=k.getFrustum(),S(R,D,k.camera,K,this.type)}k.isPointLightShadow!==!0&&this.type===an&&b(k,D),k.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(y,M,w)};function b(C,R){const D=t.update(v);f.defines.VSM_SAMPLES!==C.blurSamples&&(f.defines.VSM_SAMPLES=C.blurSamples,d.defines.VSM_SAMPLES=C.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new Yn(r.x,r.y)),f.uniforms.shadow_pass.value=C.map.texture,f.uniforms.resolution.value=C.mapSize,f.uniforms.radius.value=C.radius,i.setRenderTarget(C.mapPass),i.clear(),i.renderBufferDirect(R,null,D,f,v,null),d.uniforms.shadow_pass.value=C.mapPass.texture,d.uniforms.resolution.value=C.mapSize,d.uniforms.radius.value=C.radius,i.setRenderTarget(C.map),i.clear(),i.renderBufferDirect(R,null,D,d,v,null)}function T(C,R,D,y){let M=null;const w=D.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(w!==void 0)M=w;else if(M=D.isPointLight===!0?c:a,i.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0){const H=M.uuid,O=R.uuid;let V=l[H];V===void 0&&(V={},l[H]=V);let X=V[O];X===void 0&&(X=M.clone(),V[O]=X,R.addEventListener("dispose",L)),M=X}if(M.visible=R.visible,M.wireframe=R.wireframe,y===an?M.side=R.shadowSide!==null?R.shadowSide:R.side:M.side=R.shadowSide!==null?R.shadowSide:h[R.side],M.alphaMap=R.alphaMap,M.alphaTest=R.alphaTest,M.map=R.map,M.clipShadows=R.clipShadows,M.clippingPlanes=R.clippingPlanes,M.clipIntersection=R.clipIntersection,M.displacementMap=R.displacementMap,M.displacementScale=R.displacementScale,M.displacementBias=R.displacementBias,M.wireframeLinewidth=R.wireframeLinewidth,M.linewidth=R.linewidth,D.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const H=i.properties.get(M);H.light=D}return M}function S(C,R,D,y,M){if(C.visible===!1)return;if(C.layers.test(R.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&M===an)&&(!C.frustumCulled||n.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,C.matrixWorld);const O=t.update(C),V=C.material;if(Array.isArray(V)){const X=O.groups;for(let G=0,K=X.length;G<K;G++){const k=X[G],ct=V[k.materialIndex];if(ct&&ct.visible){const pt=T(C,ct,y,M);C.onBeforeShadow(i,C,R,D,O,pt,k),i.renderBufferDirect(D,null,O,pt,C,k),C.onAfterShadow(i,C,R,D,O,pt,k)}}}else if(V.visible){const X=T(C,V,y,M);C.onBeforeShadow(i,C,R,D,O,X,null),i.renderBufferDirect(D,null,O,X,C,null),C.onAfterShadow(i,C,R,D,O,X,null)}}const H=C.children;for(let O=0,V=H.length;O<V;O++)S(H[O],R,D,y,M)}function L(C){C.target.removeEventListener("dispose",L);for(const D in l){const y=l[D],M=C.target.uuid;M in y&&(y[M].dispose(),delete y[M])}}}const q_={[Ws]:Xs,[qs]:Js,[Ys]:Ks,[Ti]:Zs,[Xs]:Ws,[Js]:qs,[Ks]:Ys,[Zs]:Ti};function Y_(i,t){function e(){let U=!1;const ft=new ee;let W=null;const $=new ee(0,0,0,0);return{setMask:function(_t){W!==_t&&!U&&(i.colorMask(_t,_t,_t,_t),W=_t)},setLocked:function(_t){U=_t},setClear:function(_t,gt,Bt,ae,xe){xe===!0&&(_t*=ae,gt*=ae,Bt*=ae),ft.set(_t,gt,Bt,ae),$.equals(ft)===!1&&(i.clearColor(_t,gt,Bt,ae),$.copy(ft))},reset:function(){U=!1,W=null,$.set(-1,0,0,0)}}}function n(){let U=!1,ft=!1,W=null,$=null,_t=null;return{setReversed:function(gt){if(ft!==gt){const Bt=t.get("EXT_clip_control");ft?Bt.clipControlEXT(Bt.LOWER_LEFT_EXT,Bt.ZERO_TO_ONE_EXT):Bt.clipControlEXT(Bt.LOWER_LEFT_EXT,Bt.NEGATIVE_ONE_TO_ONE_EXT);const ae=_t;_t=null,this.setClear(ae)}ft=gt},getReversed:function(){return ft},setTest:function(gt){gt?j(i.DEPTH_TEST):ut(i.DEPTH_TEST)},setMask:function(gt){W!==gt&&!U&&(i.depthMask(gt),W=gt)},setFunc:function(gt){if(ft&&(gt=q_[gt]),$!==gt){switch(gt){case Ws:i.depthFunc(i.NEVER);break;case Xs:i.depthFunc(i.ALWAYS);break;case qs:i.depthFunc(i.LESS);break;case Ti:i.depthFunc(i.LEQUAL);break;case Ys:i.depthFunc(i.EQUAL);break;case Zs:i.depthFunc(i.GEQUAL);break;case Js:i.depthFunc(i.GREATER);break;case Ks:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}$=gt}},setLocked:function(gt){U=gt},setClear:function(gt){_t!==gt&&(ft&&(gt=1-gt),i.clearDepth(gt),_t=gt)},reset:function(){U=!1,W=null,$=null,_t=null,ft=!1}}}function r(){let U=!1,ft=null,W=null,$=null,_t=null,gt=null,Bt=null,ae=null,xe=null;return{setTest:function(Qt){U||(Qt?j(i.STENCIL_TEST):ut(i.STENCIL_TEST))},setMask:function(Qt){ft!==Qt&&!U&&(i.stencilMask(Qt),ft=Qt)},setFunc:function(Qt,Be,tn){(W!==Qt||$!==Be||_t!==tn)&&(i.stencilFunc(Qt,Be,tn),W=Qt,$=Be,_t=tn)},setOp:function(Qt,Be,tn){(gt!==Qt||Bt!==Be||ae!==tn)&&(i.stencilOp(Qt,Be,tn),gt=Qt,Bt=Be,ae=tn)},setLocked:function(Qt){U=Qt},setClear:function(Qt){xe!==Qt&&(i.clearStencil(Qt),xe=Qt)},reset:function(){U=!1,ft=null,W=null,$=null,_t=null,gt=null,Bt=null,ae=null,xe=null}}}const s=new e,o=new n,a=new r,c=new WeakMap,l=new WeakMap;let u={},h={},f=new WeakMap,d=[],g=null,v=!1,m=null,p=null,b=null,T=null,S=null,L=null,C=null,R=new Wt(0,0,0),D=0,y=!1,M=null,w=null,H=null,O=null,V=null;const X=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,K=0;const k=i.getParameter(i.VERSION);k.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(k)[1]),G=K>=1):k.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),G=K>=2);let ct=null,pt={};const Mt=i.getParameter(i.SCISSOR_BOX),Ft=i.getParameter(i.VIEWPORT),Zt=new ee().fromArray(Mt),Y=new ee().fromArray(Ft);function st(U,ft,W,$){const _t=new Uint8Array(4),gt=i.createTexture();i.bindTexture(U,gt),i.texParameteri(U,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(U,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Bt=0;Bt<W;Bt++)U===i.TEXTURE_3D||U===i.TEXTURE_2D_ARRAY?i.texImage3D(ft,0,i.RGBA,1,1,$,0,i.RGBA,i.UNSIGNED_BYTE,_t):i.texImage2D(ft+Bt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,_t);return gt}const Q={};Q[i.TEXTURE_2D]=st(i.TEXTURE_2D,i.TEXTURE_2D,1),Q[i.TEXTURE_CUBE_MAP]=st(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Q[i.TEXTURE_2D_ARRAY]=st(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Q[i.TEXTURE_3D]=st(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),j(i.DEPTH_TEST),o.setFunc(Ti),nt(!1),St(xc),j(i.CULL_FACE),A(En);function j(U){u[U]!==!0&&(i.enable(U),u[U]=!0)}function ut(U){u[U]!==!1&&(i.disable(U),u[U]=!1)}function vt(U,ft){return h[U]!==ft?(i.bindFramebuffer(U,ft),h[U]=ft,U===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=ft),U===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=ft),!0):!1}function Rt(U,ft){let W=d,$=!1;if(U){W=f.get(ft),W===void 0&&(W=[],f.set(ft,W));const _t=U.textures;if(W.length!==_t.length||W[0]!==i.COLOR_ATTACHMENT0){for(let gt=0,Bt=_t.length;gt<Bt;gt++)W[gt]=i.COLOR_ATTACHMENT0+gt;W.length=_t.length,$=!0}}else W[0]!==i.BACK&&(W[0]=i.BACK,$=!0);$&&i.drawBuffers(W)}function Vt(U){return g!==U?(i.useProgram(U),g=U,!0):!1}const J={[On]:i.FUNC_ADD,[eh]:i.FUNC_SUBTRACT,[nh]:i.FUNC_REVERSE_SUBTRACT};J[ih]=i.MIN,J[rh]=i.MAX;const et={[sh]:i.ZERO,[oh]:i.ONE,[ah]:i.SRC_COLOR,[Gs]:i.SRC_ALPHA,[dh]:i.SRC_ALPHA_SATURATE,[hh]:i.DST_COLOR,[lh]:i.DST_ALPHA,[ch]:i.ONE_MINUS_SRC_COLOR,[Vs]:i.ONE_MINUS_SRC_ALPHA,[fh]:i.ONE_MINUS_DST_COLOR,[uh]:i.ONE_MINUS_DST_ALPHA,[ph]:i.CONSTANT_COLOR,[mh]:i.ONE_MINUS_CONSTANT_COLOR,[gh]:i.CONSTANT_ALPHA,[_h]:i.ONE_MINUS_CONSTANT_ALPHA};function A(U,ft,W,$,_t,gt,Bt,ae,xe,Qt){if(U===En){v===!0&&(ut(i.BLEND),v=!1);return}if(v===!1&&(j(i.BLEND),v=!0),U!==th){if(U!==m||Qt!==y){if((p!==On||S!==On)&&(i.blendEquation(i.FUNC_ADD),p=On,S=On),Qt)switch(U){case Mi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mc:i.blendFunc(i.ONE,i.ONE);break;case Sc:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case yc:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case Mi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mc:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Sc:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case yc:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}b=null,T=null,L=null,C=null,R.set(0,0,0),D=0,m=U,y=Qt}return}_t=_t||ft,gt=gt||W,Bt=Bt||$,(ft!==p||_t!==S)&&(i.blendEquationSeparate(J[ft],J[_t]),p=ft,S=_t),(W!==b||$!==T||gt!==L||Bt!==C)&&(i.blendFuncSeparate(et[W],et[$],et[gt],et[Bt]),b=W,T=$,L=gt,C=Bt),(ae.equals(R)===!1||xe!==D)&&(i.blendColor(ae.r,ae.g,ae.b,xe),R.copy(ae),D=xe),m=U,y=!1}function bt(U,ft){U.side===Ze?ut(i.CULL_FACE):j(i.CULL_FACE);let W=U.side===Ce;ft&&(W=!W),nt(W),U.blending===Mi&&U.transparent===!1?A(En):A(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),o.setFunc(U.depthFunc),o.setTest(U.depthTest),o.setMask(U.depthWrite),s.setMask(U.colorWrite);const $=U.stencilWrite;a.setTest($),$&&(a.setMask(U.stencilWriteMask),a.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),a.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),Dt(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?j(i.SAMPLE_ALPHA_TO_COVERAGE):ut(i.SAMPLE_ALPHA_TO_COVERAGE)}function nt(U){M!==U&&(U?i.frontFace(i.CW):i.frontFace(i.CCW),M=U)}function St(U){U!==$u?(j(i.CULL_FACE),U!==w&&(U===xc?i.cullFace(i.BACK):U===Qu?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ut(i.CULL_FACE),w=U}function ot(U){U!==H&&(G&&i.lineWidth(U),H=U)}function Dt(U,ft,W){U?(j(i.POLYGON_OFFSET_FILL),(O!==ft||V!==W)&&(i.polygonOffset(ft,W),O=ft,V=W)):ut(i.POLYGON_OFFSET_FILL)}function mt(U){U?j(i.SCISSOR_TEST):ut(i.SCISSOR_TEST)}function E(U){U===void 0&&(U=i.TEXTURE0+X-1),ct!==U&&(i.activeTexture(U),ct=U)}function _(U,ft,W){W===void 0&&(ct===null?W=i.TEXTURE0+X-1:W=ct);let $=pt[W];$===void 0&&($={type:void 0,texture:void 0},pt[W]=$),($.type!==U||$.texture!==ft)&&(ct!==W&&(i.activeTexture(W),ct=W),i.bindTexture(U,ft||Q[U]),$.type=U,$.texture=ft)}function F(){const U=pt[ct];U!==void 0&&U.type!==void 0&&(i.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function q(){try{i.compressedTexImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function tt(){try{i.compressedTexImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Z(){try{i.texSubImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function wt(){try{i.texSubImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ht(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function xt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Xt(){try{i.texStorage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function rt(){try{i.texStorage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Et(){try{i.texImage2D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Lt(){try{i.texImage3D.apply(i,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ut(U){Zt.equals(U)===!1&&(i.scissor(U.x,U.y,U.z,U.w),Zt.copy(U))}function Tt(U){Y.equals(U)===!1&&(i.viewport(U.x,U.y,U.z,U.w),Y.copy(U))}function qt(U,ft){let W=l.get(ft);W===void 0&&(W=new WeakMap,l.set(ft,W));let $=W.get(U);$===void 0&&($=i.getUniformBlockIndex(ft,U.name),W.set(U,$))}function Ht(U,ft){const $=l.get(ft).get(U);c.get(ft)!==$&&(i.uniformBlockBinding(ft,$,U.__bindingPointIndex),c.set(ft,$))}function ie(){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),o.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),u={},ct=null,pt={},h={},f=new WeakMap,d=[],g=null,v=!1,m=null,p=null,b=null,T=null,S=null,L=null,C=null,R=new Wt(0,0,0),D=0,y=!1,M=null,w=null,H=null,O=null,V=null,Zt.set(0,0,i.canvas.width,i.canvas.height),Y.set(0,0,i.canvas.width,i.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:j,disable:ut,bindFramebuffer:vt,drawBuffers:Rt,useProgram:Vt,setBlending:A,setMaterial:bt,setFlipSided:nt,setCullFace:St,setLineWidth:ot,setPolygonOffset:Dt,setScissorTest:mt,activeTexture:E,bindTexture:_,unbindTexture:F,compressedTexImage2D:q,compressedTexImage3D:tt,texImage2D:Et,texImage3D:Lt,updateUBOMapping:qt,uniformBlockBinding:Ht,texStorage2D:Xt,texStorage3D:rt,texSubImage2D:Z,texSubImage3D:wt,compressedTexSubImage2D:ht,compressedTexSubImage3D:xt,scissor:Ut,viewport:Tt,reset:ie}}function Z_(i,t,e,n,r,s,o){const a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new at,u=new WeakMap;let h;const f=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(E,_){return d?new OffscreenCanvas(E,_):$i("canvas")}function v(E,_,F){let q=1;const tt=mt(E);if((tt.width>F||tt.height>F)&&(q=F/Math.max(tt.width,tt.height)),q<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const Z=Math.floor(q*tt.width),wt=Math.floor(q*tt.height);h===void 0&&(h=g(Z,wt));const ht=_?g(Z,wt):h;return ht.width=Z,ht.height=wt,ht.getContext("2d").drawImage(E,0,0,Z,wt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+tt.width+"x"+tt.height+") to ("+Z+"x"+wt+")."),ht}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+tt.width+"x"+tt.height+")."),E;return E}function m(E){return E.generateMipmaps}function p(E){i.generateMipmap(E)}function b(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function T(E,_,F,q,tt=!1){if(E!==null){if(i[E]!==void 0)return i[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let Z=_;if(_===i.RED&&(F===i.FLOAT&&(Z=i.R32F),F===i.HALF_FLOAT&&(Z=i.R16F),F===i.UNSIGNED_BYTE&&(Z=i.R8)),_===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.R8UI),F===i.UNSIGNED_SHORT&&(Z=i.R16UI),F===i.UNSIGNED_INT&&(Z=i.R32UI),F===i.BYTE&&(Z=i.R8I),F===i.SHORT&&(Z=i.R16I),F===i.INT&&(Z=i.R32I)),_===i.RG&&(F===i.FLOAT&&(Z=i.RG32F),F===i.HALF_FLOAT&&(Z=i.RG16F),F===i.UNSIGNED_BYTE&&(Z=i.RG8)),_===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RG8UI),F===i.UNSIGNED_SHORT&&(Z=i.RG16UI),F===i.UNSIGNED_INT&&(Z=i.RG32UI),F===i.BYTE&&(Z=i.RG8I),F===i.SHORT&&(Z=i.RG16I),F===i.INT&&(Z=i.RG32I)),_===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RGB8UI),F===i.UNSIGNED_SHORT&&(Z=i.RGB16UI),F===i.UNSIGNED_INT&&(Z=i.RGB32UI),F===i.BYTE&&(Z=i.RGB8I),F===i.SHORT&&(Z=i.RGB16I),F===i.INT&&(Z=i.RGB32I)),_===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(Z=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(Z=i.RGBA16UI),F===i.UNSIGNED_INT&&(Z=i.RGBA32UI),F===i.BYTE&&(Z=i.RGBA8I),F===i.SHORT&&(Z=i.RGBA16I),F===i.INT&&(Z=i.RGBA32I)),_===i.RGB&&F===i.UNSIGNED_INT_5_9_9_9_REV&&(Z=i.RGB9_E5),_===i.RGBA){const wt=tt?Vr:Kt.getTransfer(q);F===i.FLOAT&&(Z=i.RGBA32F),F===i.HALF_FLOAT&&(Z=i.RGBA16F),F===i.UNSIGNED_BYTE&&(Z=wt===te?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT_4_4_4_4&&(Z=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(Z=i.RGB5_A1)}return(Z===i.R16F||Z===i.R32F||Z===i.RG16F||Z===i.RG32F||Z===i.RGBA16F||Z===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function S(E,_){let F;return E?_===null||_===qn||_===Ri?F=i.DEPTH24_STENCIL8:_===ln?F=i.DEPTH32F_STENCIL8:_===Ki&&(F=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===qn||_===Ri?F=i.DEPTH_COMPONENT24:_===ln?F=i.DEPTH_COMPONENT32F:_===Ki&&(F=i.DEPTH_COMPONENT16),F}function L(E,_){return m(E)===!0||E.isFramebufferTexture&&E.minFilter!==Xe&&E.minFilter!==Je?Math.log2(Math.max(_.width,_.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?_.mipmaps.length:1}function C(E){const _=E.target;_.removeEventListener("dispose",C),D(_),_.isVideoTexture&&u.delete(_)}function R(E){const _=E.target;_.removeEventListener("dispose",R),M(_)}function D(E){const _=n.get(E);if(_.__webglInit===void 0)return;const F=E.source,q=f.get(F);if(q){const tt=q[_.__cacheKey];tt.usedTimes--,tt.usedTimes===0&&y(E),Object.keys(q).length===0&&f.delete(F)}n.remove(E)}function y(E){const _=n.get(E);i.deleteTexture(_.__webglTexture);const F=E.source,q=f.get(F);delete q[_.__cacheKey],o.memory.textures--}function M(E){const _=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let q=0;q<6;q++){if(Array.isArray(_.__webglFramebuffer[q]))for(let tt=0;tt<_.__webglFramebuffer[q].length;tt++)i.deleteFramebuffer(_.__webglFramebuffer[q][tt]);else i.deleteFramebuffer(_.__webglFramebuffer[q]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[q])}else{if(Array.isArray(_.__webglFramebuffer))for(let q=0;q<_.__webglFramebuffer.length;q++)i.deleteFramebuffer(_.__webglFramebuffer[q]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let q=0;q<_.__webglColorRenderbuffer.length;q++)_.__webglColorRenderbuffer[q]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[q]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const F=E.textures;for(let q=0,tt=F.length;q<tt;q++){const Z=n.get(F[q]);Z.__webglTexture&&(i.deleteTexture(Z.__webglTexture),o.memory.textures--),n.remove(F[q])}n.remove(E)}let w=0;function H(){w=0}function O(){const E=w;return E>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.maxTextures),w+=1,E}function V(E){const _=[];return _.push(E.wrapS),_.push(E.wrapT),_.push(E.wrapR||0),_.push(E.magFilter),_.push(E.minFilter),_.push(E.anisotropy),_.push(E.internalFormat),_.push(E.format),_.push(E.type),_.push(E.generateMipmaps),_.push(E.premultiplyAlpha),_.push(E.flipY),_.push(E.unpackAlignment),_.push(E.colorSpace),_.join()}function X(E,_){const F=n.get(E);if(E.isVideoTexture&&ot(E),E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){const q=E.image;if(q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Y(F,E,_);return}}e.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+_)}function G(E,_){const F=n.get(E);if(E.version>0&&F.__version!==E.version){Y(F,E,_);return}e.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+_)}function K(E,_){const F=n.get(E);if(E.version>0&&F.__version!==E.version){Y(F,E,_);return}e.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+_)}function k(E,_){const F=n.get(E);if(E.version>0&&F.__version!==E.version){st(F,E,_);return}e.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+_)}const ct={[wi]:i.REPEAT,[kn]:i.CLAMP_TO_EDGE,[Qs]:i.MIRRORED_REPEAT},pt={[Xe]:i.NEAREST,[bh]:i.NEAREST_MIPMAP_NEAREST,[hr]:i.NEAREST_MIPMAP_LINEAR,[Je]:i.LINEAR,[ss]:i.LINEAR_MIPMAP_NEAREST,[Gn]:i.LINEAR_MIPMAP_LINEAR},Mt={[Ph]:i.NEVER,[Fh]:i.ALWAYS,[Lh]:i.LESS,[Zl]:i.LEQUAL,[Dh]:i.EQUAL,[Nh]:i.GEQUAL,[Uh]:i.GREATER,[Ih]:i.NOTEQUAL};function Ft(E,_){if(_.type===ln&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===Je||_.magFilter===ss||_.magFilter===hr||_.magFilter===Gn||_.minFilter===Je||_.minFilter===ss||_.minFilter===hr||_.minFilter===Gn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,ct[_.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,ct[_.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,ct[_.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,pt[_.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,pt[_.minFilter]),_.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,Mt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Xe||_.minFilter!==hr&&_.minFilter!==Gn||_.type===ln&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");i.texParameterf(E,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Zt(E,_){let F=!1;E.__webglInit===void 0&&(E.__webglInit=!0,_.addEventListener("dispose",C));const q=_.source;let tt=f.get(q);tt===void 0&&(tt={},f.set(q,tt));const Z=V(_);if(Z!==E.__cacheKey){tt[Z]===void 0&&(tt[Z]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,F=!0),tt[Z].usedTimes++;const wt=tt[E.__cacheKey];wt!==void 0&&(tt[E.__cacheKey].usedTimes--,wt.usedTimes===0&&y(_)),E.__cacheKey=Z,E.__webglTexture=tt[Z].texture}return F}function Y(E,_,F){let q=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(q=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(q=i.TEXTURE_3D);const tt=Zt(E,_),Z=_.source;e.bindTexture(q,E.__webglTexture,i.TEXTURE0+F);const wt=n.get(Z);if(Z.version!==wt.__version||tt===!0){e.activeTexture(i.TEXTURE0+F);const ht=Kt.getPrimaries(Kt.workingColorSpace),xt=_.colorSpace===Mn?null:Kt.getPrimaries(_.colorSpace),Xt=_.colorSpace===Mn||ht===xt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xt);let rt=v(_.image,!1,r.maxTextureSize);rt=Dt(_,rt);const Et=s.convert(_.format,_.colorSpace),Lt=s.convert(_.type);let Ut=T(_.internalFormat,Et,Lt,_.colorSpace,_.isVideoTexture);Ft(q,_);let Tt;const qt=_.mipmaps,Ht=_.isVideoTexture!==!0,ie=wt.__version===void 0||tt===!0,U=Z.dataReady,ft=L(_,rt);if(_.isDepthTexture)Ut=S(_.format===Ci,_.type),ie&&(Ht?e.texStorage2D(i.TEXTURE_2D,1,Ut,rt.width,rt.height):e.texImage2D(i.TEXTURE_2D,0,Ut,rt.width,rt.height,0,Et,Lt,null));else if(_.isDataTexture)if(qt.length>0){Ht&&ie&&e.texStorage2D(i.TEXTURE_2D,ft,Ut,qt[0].width,qt[0].height);for(let W=0,$=qt.length;W<$;W++)Tt=qt[W],Ht?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,Tt.width,Tt.height,Et,Lt,Tt.data):e.texImage2D(i.TEXTURE_2D,W,Ut,Tt.width,Tt.height,0,Et,Lt,Tt.data);_.generateMipmaps=!1}else Ht?(ie&&e.texStorage2D(i.TEXTURE_2D,ft,Ut,rt.width,rt.height),U&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,rt.width,rt.height,Et,Lt,rt.data)):e.texImage2D(i.TEXTURE_2D,0,Ut,rt.width,rt.height,0,Et,Lt,rt.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){Ht&&ie&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ft,Ut,qt[0].width,qt[0].height,rt.depth);for(let W=0,$=qt.length;W<$;W++)if(Tt=qt[W],_.format!==We)if(Et!==null)if(Ht){if(U)if(_.layerUpdates.size>0){const _t=nl(Tt.width,Tt.height,_.format,_.type);for(const gt of _.layerUpdates){const Bt=Tt.data.subarray(gt*_t/Tt.data.BYTES_PER_ELEMENT,(gt+1)*_t/Tt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,gt,Tt.width,Tt.height,1,Et,Bt)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,0,Tt.width,Tt.height,rt.depth,Et,Tt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,W,Ut,Tt.width,Tt.height,rt.depth,0,Tt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ht?U&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,W,0,0,0,Tt.width,Tt.height,rt.depth,Et,Lt,Tt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,W,Ut,Tt.width,Tt.height,rt.depth,0,Et,Lt,Tt.data)}else{Ht&&ie&&e.texStorage2D(i.TEXTURE_2D,ft,Ut,qt[0].width,qt[0].height);for(let W=0,$=qt.length;W<$;W++)Tt=qt[W],_.format!==We?Et!==null?Ht?U&&e.compressedTexSubImage2D(i.TEXTURE_2D,W,0,0,Tt.width,Tt.height,Et,Tt.data):e.compressedTexImage2D(i.TEXTURE_2D,W,Ut,Tt.width,Tt.height,0,Tt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ht?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,Tt.width,Tt.height,Et,Lt,Tt.data):e.texImage2D(i.TEXTURE_2D,W,Ut,Tt.width,Tt.height,0,Et,Lt,Tt.data)}else if(_.isDataArrayTexture)if(Ht){if(ie&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ft,Ut,rt.width,rt.height,rt.depth),U)if(_.layerUpdates.size>0){const W=nl(rt.width,rt.height,_.format,_.type);for(const $ of _.layerUpdates){const _t=rt.data.subarray($*W/rt.data.BYTES_PER_ELEMENT,($+1)*W/rt.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,$,rt.width,rt.height,1,Et,Lt,_t)}_.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,rt.width,rt.height,rt.depth,Et,Lt,rt.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Ut,rt.width,rt.height,rt.depth,0,Et,Lt,rt.data);else if(_.isData3DTexture)Ht?(ie&&e.texStorage3D(i.TEXTURE_3D,ft,Ut,rt.width,rt.height,rt.depth),U&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,rt.width,rt.height,rt.depth,Et,Lt,rt.data)):e.texImage3D(i.TEXTURE_3D,0,Ut,rt.width,rt.height,rt.depth,0,Et,Lt,rt.data);else if(_.isFramebufferTexture){if(ie)if(Ht)e.texStorage2D(i.TEXTURE_2D,ft,Ut,rt.width,rt.height);else{let W=rt.width,$=rt.height;for(let _t=0;_t<ft;_t++)e.texImage2D(i.TEXTURE_2D,_t,Ut,W,$,0,Et,Lt,null),W>>=1,$>>=1}}else if(qt.length>0){if(Ht&&ie){const W=mt(qt[0]);e.texStorage2D(i.TEXTURE_2D,ft,Ut,W.width,W.height)}for(let W=0,$=qt.length;W<$;W++)Tt=qt[W],Ht?U&&e.texSubImage2D(i.TEXTURE_2D,W,0,0,Et,Lt,Tt):e.texImage2D(i.TEXTURE_2D,W,Ut,Et,Lt,Tt);_.generateMipmaps=!1}else if(Ht){if(ie){const W=mt(rt);e.texStorage2D(i.TEXTURE_2D,ft,Ut,W.width,W.height)}U&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,Et,Lt,rt)}else e.texImage2D(i.TEXTURE_2D,0,Ut,Et,Lt,rt);m(_)&&p(q),wt.__version=Z.version,_.onUpdate&&_.onUpdate(_)}E.__version=_.version}function st(E,_,F){if(_.image.length!==6)return;const q=Zt(E,_),tt=_.source;e.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+F);const Z=n.get(tt);if(tt.version!==Z.__version||q===!0){e.activeTexture(i.TEXTURE0+F);const wt=Kt.getPrimaries(Kt.workingColorSpace),ht=_.colorSpace===Mn?null:Kt.getPrimaries(_.colorSpace),xt=_.colorSpace===Mn||wt===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,xt);const Xt=_.isCompressedTexture||_.image[0].isCompressedTexture,rt=_.image[0]&&_.image[0].isDataTexture,Et=[];for(let $=0;$<6;$++)!Xt&&!rt?Et[$]=v(_.image[$],!0,r.maxCubemapSize):Et[$]=rt?_.image[$].image:_.image[$],Et[$]=Dt(_,Et[$]);const Lt=Et[0],Ut=s.convert(_.format,_.colorSpace),Tt=s.convert(_.type),qt=T(_.internalFormat,Ut,Tt,_.colorSpace),Ht=_.isVideoTexture!==!0,ie=Z.__version===void 0||q===!0,U=tt.dataReady;let ft=L(_,Lt);Ft(i.TEXTURE_CUBE_MAP,_);let W;if(Xt){Ht&&ie&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ft,qt,Lt.width,Lt.height);for(let $=0;$<6;$++){W=Et[$].mipmaps;for(let _t=0;_t<W.length;_t++){const gt=W[_t];_.format!==We?Ut!==null?Ht?U&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t,0,0,gt.width,gt.height,Ut,gt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t,qt,gt.width,gt.height,0,gt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t,0,0,gt.width,gt.height,Ut,Tt,gt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t,qt,gt.width,gt.height,0,Ut,Tt,gt.data)}}}else{if(W=_.mipmaps,Ht&&ie){W.length>0&&ft++;const $=mt(Et[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ft,qt,$.width,$.height)}for(let $=0;$<6;$++)if(rt){Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,Et[$].width,Et[$].height,Ut,Tt,Et[$].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,qt,Et[$].width,Et[$].height,0,Ut,Tt,Et[$].data);for(let _t=0;_t<W.length;_t++){const Bt=W[_t].image[$].image;Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t+1,0,0,Bt.width,Bt.height,Ut,Tt,Bt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t+1,qt,Bt.width,Bt.height,0,Ut,Tt,Bt.data)}}else{Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,0,0,Ut,Tt,Et[$]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,qt,Ut,Tt,Et[$]);for(let _t=0;_t<W.length;_t++){const gt=W[_t];Ht?U&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t+1,0,0,Ut,Tt,gt.image[$]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+$,_t+1,qt,Ut,Tt,gt.image[$])}}}m(_)&&p(i.TEXTURE_CUBE_MAP),Z.__version=tt.version,_.onUpdate&&_.onUpdate(_)}E.__version=_.version}function Q(E,_,F,q,tt,Z){const wt=s.convert(F.format,F.colorSpace),ht=s.convert(F.type),xt=T(F.internalFormat,wt,ht,F.colorSpace),Xt=n.get(_),rt=n.get(F);if(rt.__renderTarget=_,!Xt.__hasExternalTextures){const Et=Math.max(1,_.width>>Z),Lt=Math.max(1,_.height>>Z);tt===i.TEXTURE_3D||tt===i.TEXTURE_2D_ARRAY?e.texImage3D(tt,Z,xt,Et,Lt,_.depth,0,wt,ht,null):e.texImage2D(tt,Z,xt,Et,Lt,0,wt,ht,null)}e.bindFramebuffer(i.FRAMEBUFFER,E),St(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,q,tt,rt.__webglTexture,0,nt(_)):(tt===i.TEXTURE_2D||tt>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&tt<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,q,tt,rt.__webglTexture,Z),e.bindFramebuffer(i.FRAMEBUFFER,null)}function j(E,_,F){if(i.bindRenderbuffer(i.RENDERBUFFER,E),_.depthBuffer){const q=_.depthTexture,tt=q&&q.isDepthTexture?q.type:null,Z=S(_.stencilBuffer,tt),wt=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ht=nt(_);St(_)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ht,Z,_.width,_.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,ht,Z,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,Z,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,wt,i.RENDERBUFFER,E)}else{const q=_.textures;for(let tt=0;tt<q.length;tt++){const Z=q[tt],wt=s.convert(Z.format,Z.colorSpace),ht=s.convert(Z.type),xt=T(Z.internalFormat,wt,ht,Z.colorSpace),Xt=nt(_);F&&St(_)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Xt,xt,_.width,_.height):St(_)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Xt,xt,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,xt,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ut(E,_){if(_&&_.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,E),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const q=n.get(_.depthTexture);q.__renderTarget=_,(!q.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),X(_.depthTexture,0);const tt=q.__webglTexture,Z=nt(_);if(_.depthTexture.format===Si)St(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,tt,0,Z):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,tt,0);else if(_.depthTexture.format===Ci)St(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,tt,0,Z):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,tt,0);else throw new Error("Unknown depthTexture format")}function vt(E){const _=n.get(E),F=E.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==E.depthTexture){const q=E.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),q){const tt=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,q.removeEventListener("dispose",tt)};q.addEventListener("dispose",tt),_.__depthDisposeCallback=tt}_.__boundDepthTexture=q}if(E.depthTexture&&!_.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");ut(_.__webglFramebuffer,E)}else if(F){_.__webglDepthbuffer=[];for(let q=0;q<6;q++)if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[q]),_.__webglDepthbuffer[q]===void 0)_.__webglDepthbuffer[q]=i.createRenderbuffer(),j(_.__webglDepthbuffer[q],E,!1);else{const tt=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Z=_.__webglDepthbuffer[q];i.bindRenderbuffer(i.RENDERBUFFER,Z),i.framebufferRenderbuffer(i.FRAMEBUFFER,tt,i.RENDERBUFFER,Z)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),j(_.__webglDepthbuffer,E,!1);else{const q=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,tt=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,tt),i.framebufferRenderbuffer(i.FRAMEBUFFER,q,i.RENDERBUFFER,tt)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Rt(E,_,F){const q=n.get(E);_!==void 0&&Q(q.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&vt(E)}function Vt(E){const _=E.texture,F=n.get(E),q=n.get(_);E.addEventListener("dispose",R);const tt=E.textures,Z=E.isWebGLCubeRenderTarget===!0,wt=tt.length>1;if(wt||(q.__webglTexture===void 0&&(q.__webglTexture=i.createTexture()),q.__version=_.version,o.memory.textures++),Z){F.__webglFramebuffer=[];for(let ht=0;ht<6;ht++)if(_.mipmaps&&_.mipmaps.length>0){F.__webglFramebuffer[ht]=[];for(let xt=0;xt<_.mipmaps.length;xt++)F.__webglFramebuffer[ht][xt]=i.createFramebuffer()}else F.__webglFramebuffer[ht]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){F.__webglFramebuffer=[];for(let ht=0;ht<_.mipmaps.length;ht++)F.__webglFramebuffer[ht]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(wt)for(let ht=0,xt=tt.length;ht<xt;ht++){const Xt=n.get(tt[ht]);Xt.__webglTexture===void 0&&(Xt.__webglTexture=i.createTexture(),o.memory.textures++)}if(E.samples>0&&St(E)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let ht=0;ht<tt.length;ht++){const xt=tt[ht];F.__webglColorRenderbuffer[ht]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[ht]);const Xt=s.convert(xt.format,xt.colorSpace),rt=s.convert(xt.type),Et=T(xt.internalFormat,Xt,rt,xt.colorSpace,E.isXRRenderTarget===!0),Lt=nt(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,Lt,Et,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.RENDERBUFFER,F.__webglColorRenderbuffer[ht])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),j(F.__webglDepthRenderbuffer,E,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Z){e.bindTexture(i.TEXTURE_CUBE_MAP,q.__webglTexture),Ft(i.TEXTURE_CUBE_MAP,_);for(let ht=0;ht<6;ht++)if(_.mipmaps&&_.mipmaps.length>0)for(let xt=0;xt<_.mipmaps.length;xt++)Q(F.__webglFramebuffer[ht][xt],E,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,xt);else Q(F.__webglFramebuffer[ht],E,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ht,0);m(_)&&p(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(wt){for(let ht=0,xt=tt.length;ht<xt;ht++){const Xt=tt[ht],rt=n.get(Xt);e.bindTexture(i.TEXTURE_2D,rt.__webglTexture),Ft(i.TEXTURE_2D,Xt),Q(F.__webglFramebuffer,E,Xt,i.COLOR_ATTACHMENT0+ht,i.TEXTURE_2D,0),m(Xt)&&p(i.TEXTURE_2D)}e.unbindTexture()}else{let ht=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(ht=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(ht,q.__webglTexture),Ft(ht,_),_.mipmaps&&_.mipmaps.length>0)for(let xt=0;xt<_.mipmaps.length;xt++)Q(F.__webglFramebuffer[xt],E,_,i.COLOR_ATTACHMENT0,ht,xt);else Q(F.__webglFramebuffer,E,_,i.COLOR_ATTACHMENT0,ht,0);m(_)&&p(ht),e.unbindTexture()}E.depthBuffer&&vt(E)}function J(E){const _=E.textures;for(let F=0,q=_.length;F<q;F++){const tt=_[F];if(m(tt)){const Z=b(E),wt=n.get(tt).__webglTexture;e.bindTexture(Z,wt),p(Z),e.unbindTexture()}}}const et=[],A=[];function bt(E){if(E.samples>0){if(St(E)===!1){const _=E.textures,F=E.width,q=E.height;let tt=i.COLOR_BUFFER_BIT;const Z=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,wt=n.get(E),ht=_.length>1;if(ht)for(let xt=0;xt<_.length;xt++)e.bindFramebuffer(i.FRAMEBUFFER,wt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,wt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,wt.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,wt.__webglFramebuffer);for(let xt=0;xt<_.length;xt++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(tt|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(tt|=i.STENCIL_BUFFER_BIT)),ht){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,wt.__webglColorRenderbuffer[xt]);const Xt=n.get(_[xt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Xt,0)}i.blitFramebuffer(0,0,F,q,0,0,F,q,tt,i.NEAREST),c===!0&&(et.length=0,A.length=0,et.push(i.COLOR_ATTACHMENT0+xt),E.depthBuffer&&E.resolveDepthBuffer===!1&&(et.push(Z),A.push(Z),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,A)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,et))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ht)for(let xt=0;xt<_.length;xt++){e.bindFramebuffer(i.FRAMEBUFFER,wt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.RENDERBUFFER,wt.__webglColorRenderbuffer[xt]);const Xt=n.get(_[xt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,wt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.TEXTURE_2D,Xt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,wt.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&c){const _=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function nt(E){return Math.min(r.maxSamples,E.samples)}function St(E){const _=n.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function ot(E){const _=o.render.frame;u.get(E)!==_&&(u.set(E,_),E.update())}function Dt(E,_){const F=E.colorSpace,q=E.format,tt=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||F!==Pi&&F!==Mn&&(Kt.getTransfer(F)===te?(q!==We||tt!==fn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),_}function mt(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=O,this.resetTextureUnits=H,this.setTexture2D=X,this.setTexture2DArray=G,this.setTexture3D=K,this.setTextureCube=k,this.rebindTextures=Rt,this.setupRenderTarget=Vt,this.updateRenderTargetMipmap=J,this.updateMultisampleRenderTarget=bt,this.setupDepthRenderbuffer=vt,this.setupFrameBufferTexture=Q,this.useMultisampledRTT=St}function J_(i,t){function e(n,r=Mn){let s;const o=Kt.getTransfer(r);if(n===fn)return i.UNSIGNED_BYTE;if(n===Fa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Oa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===zl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Ol)return i.BYTE;if(n===Bl)return i.SHORT;if(n===Ki)return i.UNSIGNED_SHORT;if(n===Na)return i.INT;if(n===qn)return i.UNSIGNED_INT;if(n===ln)return i.FLOAT;if(n===ir)return i.HALF_FLOAT;if(n===Hl)return i.ALPHA;if(n===kl)return i.RGB;if(n===We)return i.RGBA;if(n===Gl)return i.LUMINANCE;if(n===Vl)return i.LUMINANCE_ALPHA;if(n===Si)return i.DEPTH_COMPONENT;if(n===Ci)return i.DEPTH_STENCIL;if(n===Wl)return i.RED;if(n===Ba)return i.RED_INTEGER;if(n===Xl)return i.RG;if(n===za)return i.RG_INTEGER;if(n===Ha)return i.RGBA_INTEGER;if(n===Nr||n===Fr||n===Or||n===Br)if(o===te)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Nr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Fr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Or)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Br)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Nr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Fr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Or)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Br)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===to||n===eo||n===no||n===io)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===to)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===eo)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===no)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===io)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ro||n===so||n===oo)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ro||n===so)return o===te?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===oo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ao||n===co||n===lo||n===uo||n===ho||n===fo||n===po||n===mo||n===go||n===_o||n===vo||n===xo||n===Mo||n===So)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===ao)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===co)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===lo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===uo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ho)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===po)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===mo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===go)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===_o)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===vo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===xo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Mo)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===So)return o===te?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===zr||n===yo||n===Eo)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===zr)return o===te?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===yo)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Eo)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===ql||n===To||n===Ao||n===bo)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===zr)return s.COMPRESSED_RED_RGTC1_EXT;if(n===To)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ao)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===bo)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ri?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const K_={type:"move"};class Os{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Wn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Wn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){o=!0;for(const v of t.hand.values()){const m=e.getJointPose(v,n),p=this._getHandJoint(l,v);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,g=.005;l.inputState.pinching&&f>d+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&f<=d-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(K_)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Wn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const j_=`
3804
+ void main() {
3805
+
3806
+ gl_Position = vec4( position, 1.0 );
3807
+
3808
+ }`,$_=`
3809
+ uniform sampler2DArray depthColor;
3810
+ uniform float depthWidth;
3811
+ uniform float depthHeight;
3812
+
3813
+ void main() {
3814
+
3815
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3816
+
3817
+ if ( coord.x >= 1.0 ) {
3818
+
3819
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3820
+
3821
+ } else {
3822
+
3823
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3824
+
3825
+ }
3826
+
3827
+ }`;class Q_{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const r=new ye,s=t.properties.get(r);s.__webglTexture=e.texture,(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new wn({vertexShader:j_,fragmentShader:$_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new le(new ar(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class tv extends Di{constructor(t,e){super();const n=this;let r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,d=null,g=null;const v=new Q_,m=e.getContextAttributes();let p=null,b=null;const T=[],S=[],L=new at;let C=null;const R=new Ie;R.viewport=new ee;const D=new Ie;D.viewport=new ee;const y=[R,D],M=new Md;let w=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let st=T[Y];return st===void 0&&(st=new Os,T[Y]=st),st.getTargetRaySpace()},this.getControllerGrip=function(Y){let st=T[Y];return st===void 0&&(st=new Os,T[Y]=st),st.getGripSpace()},this.getHand=function(Y){let st=T[Y];return st===void 0&&(st=new Os,T[Y]=st),st.getHandSpace()};function O(Y){const st=S.indexOf(Y.inputSource);if(st===-1)return;const Q=T[st];Q!==void 0&&(Q.update(Y.inputSource,Y.frame,l||o),Q.dispatchEvent({type:Y.type,data:Y.inputSource}))}function V(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",V),r.removeEventListener("inputsourceschange",X);for(let Y=0;Y<T.length;Y++){const st=S[Y];st!==null&&(S[Y]=null,T[Y].disconnect(st))}w=null,H=null,v.reset(),t.setRenderTarget(p),d=null,f=null,h=null,r=null,b=null,Zt.stop(),n.isPresenting=!1,t.setPixelRatio(C),t.setSize(L.width,L.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){a=Y,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(p=t.getRenderTarget(),r.addEventListener("select",O),r.addEventListener("selectstart",O),r.addEventListener("selectend",O),r.addEventListener("squeeze",O),r.addEventListener("squeezestart",O),r.addEventListener("squeezeend",O),r.addEventListener("end",V),r.addEventListener("inputsourceschange",X),m.xrCompatible!==!0&&await e.makeXRCompatible(),C=t.getPixelRatio(),t.getSize(L),r.enabledFeatures!==void 0&&r.enabledFeatures.includes("layers")){let Q=null,j=null,ut=null;m.depth&&(ut=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,Q=m.stencil?Ci:Si,j=m.stencil?Ri:qn);const vt={colorFormat:e.RGBA8,depthFormat:ut,scaleFactor:s};h=new XRWebGLBinding(r,e),f=h.createProjectionLayer(vt),r.updateRenderState({layers:[f]}),t.setPixelRatio(1),t.setSize(f.textureWidth,f.textureHeight,!1),b=new Yn(f.textureWidth,f.textureHeight,{format:We,type:fn,depthTexture:new ou(f.textureWidth,f.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,Q),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1})}else{const Q={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,e,Q),r.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),b=new Yn(d.framebufferWidth,d.framebufferHeight,{format:We,type:fn,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}b.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),Zt.setContext(r),Zt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function X(Y){for(let st=0;st<Y.removed.length;st++){const Q=Y.removed[st],j=S.indexOf(Q);j>=0&&(S[j]=null,T[j].disconnect(Q))}for(let st=0;st<Y.added.length;st++){const Q=Y.added[st];let j=S.indexOf(Q);if(j===-1){for(let vt=0;vt<T.length;vt++)if(vt>=S.length){S.push(Q),j=vt;break}else if(S[vt]===null){S[vt]=Q,j=vt;break}if(j===-1)break}const ut=T[j];ut&&ut.connect(Q)}}const G=new P,K=new P;function k(Y,st,Q){G.setFromMatrixPosition(st.matrixWorld),K.setFromMatrixPosition(Q.matrixWorld);const j=G.distanceTo(K),ut=st.projectionMatrix.elements,vt=Q.projectionMatrix.elements,Rt=ut[14]/(ut[10]-1),Vt=ut[14]/(ut[10]+1),J=(ut[9]+1)/ut[5],et=(ut[9]-1)/ut[5],A=(ut[8]-1)/ut[0],bt=(vt[8]+1)/vt[0],nt=Rt*A,St=Rt*bt,ot=j/(-A+bt),Dt=ot*-A;if(st.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Dt),Y.translateZ(ot),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),ut[10]===-1)Y.projectionMatrix.copy(st.projectionMatrix),Y.projectionMatrixInverse.copy(st.projectionMatrixInverse);else{const mt=Rt+ot,E=Vt+ot,_=nt-Dt,F=St+(j-Dt),q=J*Vt/E*mt,tt=et*Vt/E*mt;Y.projectionMatrix.makePerspective(_,F,q,tt,mt,E),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ct(Y,st){st===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(st.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let st=Y.near,Q=Y.far;v.texture!==null&&(v.depthNear>0&&(st=v.depthNear),v.depthFar>0&&(Q=v.depthFar)),M.near=D.near=R.near=st,M.far=D.far=R.far=Q,(w!==M.near||H!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),w=M.near,H=M.far),R.layers.mask=Y.layers.mask|2,D.layers.mask=Y.layers.mask|4,M.layers.mask=R.layers.mask|D.layers.mask;const j=Y.parent,ut=M.cameras;ct(M,j);for(let vt=0;vt<ut.length;vt++)ct(ut[vt],j);ut.length===2?k(M,R,D):M.projectionMatrix.copy(R.projectionMatrix),pt(Y,M,j)};function pt(Y,st,Q){Q===null?Y.matrix.copy(st.matrixWorld):(Y.matrix.copy(Q.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(st.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(st.projectionMatrix),Y.projectionMatrixInverse.copy(st.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=ji*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(f===null&&d===null))return c},this.setFoveation=function(Y){c=Y,f!==null&&(f.fixedFoveation=Y),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=Y)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let Mt=null;function Ft(Y,st){if(u=st.getViewerPose(l||o),g=st,u!==null){const Q=u.views;d!==null&&(t.setRenderTargetFramebuffer(b,d.framebuffer),t.setRenderTarget(b));let j=!1;Q.length!==M.cameras.length&&(M.cameras.length=0,j=!0);for(let vt=0;vt<Q.length;vt++){const Rt=Q[vt];let Vt=null;if(d!==null)Vt=d.getViewport(Rt);else{const et=h.getViewSubImage(f,Rt);Vt=et.viewport,vt===0&&(t.setRenderTargetTextures(b,et.colorTexture,f.ignoreDepthValues?void 0:et.depthStencilTexture),t.setRenderTarget(b))}let J=y[vt];J===void 0&&(J=new Ie,J.layers.enable(vt),J.viewport=new ee,y[vt]=J),J.matrix.fromArray(Rt.transform.matrix),J.matrix.decompose(J.position,J.quaternion,J.scale),J.projectionMatrix.fromArray(Rt.projectionMatrix),J.projectionMatrixInverse.copy(J.projectionMatrix).invert(),J.viewport.set(Vt.x,Vt.y,Vt.width,Vt.height),vt===0&&(M.matrix.copy(J.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),j===!0&&M.cameras.push(J)}const ut=r.enabledFeatures;if(ut&&ut.includes("depth-sensing")){const vt=h.getDepthInformation(Q[0]);vt&&vt.isValid&&vt.texture&&v.init(t,vt,r.renderState)}}for(let Q=0;Q<T.length;Q++){const j=S[Q],ut=T[Q];j!==null&&ut!==void 0&&ut.update(j,st,l||o)}Mt&&Mt(Y,st),st.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:st}),g=null}const Zt=new gu;Zt.setAnimationLoop(Ft),this.setAnimationLoop=function(Y){Mt=Y},this.dispose=function(){}}}const Nn=new $e,ev=new re;function nv(i,t){function e(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,nu(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function r(m,p,b,T,S){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(m,p):p.isMeshToonMaterial?(s(m,p),h(m,p)):p.isMeshPhongMaterial?(s(m,p),u(m,p)):p.isMeshStandardMaterial?(s(m,p),f(m,p),p.isMeshPhysicalMaterial&&d(m,p,S)):p.isMeshMatcapMaterial?(s(m,p),g(m,p)):p.isMeshDepthMaterial?s(m,p):p.isMeshDistanceMaterial?(s(m,p),v(m,p)):p.isMeshNormalMaterial?s(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?c(m,p,b,T):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,e(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Ce&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,e(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Ce&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,e(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,e(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const b=t.get(p),T=b.envMap,S=b.envMapRotation;T&&(m.envMap.value=T,Nn.copy(S),Nn.x*=-1,Nn.y*=-1,Nn.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Nn.y*=-1,Nn.z*=-1),m.envMapRotation.value.setFromMatrix4(ev.makeRotationFromEuler(Nn)),m.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,b,T){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=T*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function h(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function f(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function d(m,p,b){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ce&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function v(m,p){const b=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function iv(i,t,e,n){let r={},s={},o=[];const a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(b,T){const S=T.program;n.uniformBlockBinding(b,S)}function l(b,T){let S=r[b.id];S===void 0&&(g(b),S=u(b),r[b.id]=S,b.addEventListener("dispose",m));const L=T.program;n.updateUBOMapping(b,L);const C=t.render.frame;s[b.id]!==C&&(f(b),s[b.id]=C)}function u(b){const T=h();b.__bindingPointIndex=T;const S=i.createBuffer(),L=b.__size,C=b.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,L,C),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,S),S}function h(){for(let b=0;b<a;b++)if(o.indexOf(b)===-1)return o.push(b),b;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(b){const T=r[b.id],S=b.uniforms,L=b.__cache;i.bindBuffer(i.UNIFORM_BUFFER,T);for(let C=0,R=S.length;C<R;C++){const D=Array.isArray(S[C])?S[C]:[S[C]];for(let y=0,M=D.length;y<M;y++){const w=D[y];if(d(w,C,y,L)===!0){const H=w.__offset,O=Array.isArray(w.value)?w.value:[w.value];let V=0;for(let X=0;X<O.length;X++){const G=O[X],K=v(G);typeof G=="number"||typeof G=="boolean"?(w.__data[0]=G,i.bufferSubData(i.UNIFORM_BUFFER,H+V,w.__data)):G.isMatrix3?(w.__data[0]=G.elements[0],w.__data[1]=G.elements[1],w.__data[2]=G.elements[2],w.__data[3]=0,w.__data[4]=G.elements[3],w.__data[5]=G.elements[4],w.__data[6]=G.elements[5],w.__data[7]=0,w.__data[8]=G.elements[6],w.__data[9]=G.elements[7],w.__data[10]=G.elements[8],w.__data[11]=0):(G.toArray(w.__data,V),V+=K.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,H,w.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function d(b,T,S,L){const C=b.value,R=T+"_"+S;if(L[R]===void 0)return typeof C=="number"||typeof C=="boolean"?L[R]=C:L[R]=C.clone(),!0;{const D=L[R];if(typeof C=="number"||typeof C=="boolean"){if(D!==C)return L[R]=C,!0}else if(D.equals(C)===!1)return D.copy(C),!0}return!1}function g(b){const T=b.uniforms;let S=0;const L=16;for(let R=0,D=T.length;R<D;R++){const y=Array.isArray(T[R])?T[R]:[T[R]];for(let M=0,w=y.length;M<w;M++){const H=y[M],O=Array.isArray(H.value)?H.value:[H.value];for(let V=0,X=O.length;V<X;V++){const G=O[V],K=v(G),k=S%L,ct=k%K.boundary,pt=k+ct;S+=ct,pt!==0&&L-pt<K.storage&&(S+=L-pt),H.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=S,S+=K.storage}}}const C=S%L;return C>0&&(S+=L-C),b.__size=S,b.__cache={},this}function v(b){const T={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(T.boundary=4,T.storage=4):b.isVector2?(T.boundary=8,T.storage=8):b.isVector3||b.isColor?(T.boundary=16,T.storage=12):b.isVector4?(T.boundary=16,T.storage=16):b.isMatrix3?(T.boundary=48,T.storage=48):b.isMatrix4?(T.boundary=64,T.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),T}function m(b){const T=b.target;T.removeEventListener("dispose",m);const S=o.indexOf(T.__bindingPointIndex);o.splice(S,1),i.deleteBuffer(r[T.id]),delete r[T.id],delete s[T.id]}function p(){for(const b in r)i.deleteBuffer(r[b]);o=[],r={},s={}}return{bind:c,update:l,dispose:p}}class rv{constructor(t={}){const{canvas:e=tf(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:f=!1}=t;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=o;const g=new Uint32Array(4),v=new Int32Array(4);let m=null,p=null;const b=[],T=[];this.domElement=e,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._outputColorSpace=we,this.toneMapping=Tn,this.toneMappingExposure=1;const S=this;let L=!1,C=0,R=0,D=null,y=-1,M=null;const w=new ee,H=new ee;let O=null;const V=new Wt(0);let X=0,G=e.width,K=e.height,k=1,ct=null,pt=null;const Mt=new ee(0,0,G,K),Ft=new ee(0,0,G,K);let Zt=!1;const Y=new Xa;let st=!1,Q=!1;this.transmissionResolutionScale=1;const j=new re,ut=new re,vt=new P,Rt=new ee,Vt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let J=!1;function et(){return D===null?k:1}let A=n;function bt(x,I){return e.getContext(x,I)}try{const x={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ia}`),e.addEventListener("webglcontextlost",$,!1),e.addEventListener("webglcontextrestored",_t,!1),e.addEventListener("webglcontextcreationerror",gt,!1),A===null){const I="webgl2";if(A=bt(I,x),A===null)throw bt(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(x){throw console.error("THREE.WebGLRenderer: "+x.message),x}let nt,St,ot,Dt,mt,E,_,F,q,tt,Z,wt,ht,xt,Xt,rt,Et,Lt,Ut,Tt,qt,Ht,ie,U;function ft(){nt=new dg(A),nt.init(),Ht=new J_(A,nt),St=new ag(A,nt,t,Ht),ot=new Y_(A,nt),St.reverseDepthBuffer&&f&&ot.buffers.depth.setReversed(!0),Dt=new gg(A),mt=new I_,E=new Z_(A,nt,ot,mt,St,Ht,Dt),_=new lg(S),F=new fg(S),q=new Ed(A),ie=new sg(A,q),tt=new pg(A,q,Dt,ie),Z=new vg(A,tt,q,Dt),Ut=new _g(A,St,E),rt=new cg(mt),wt=new U_(S,_,F,nt,St,ie,rt),ht=new nv(S,mt),xt=new F_,Xt=new G_(nt),Lt=new rg(S,_,F,ot,Z,d,c),Et=new X_(S,Z,St),U=new iv(A,Dt,St,ot),Tt=new og(A,nt,Dt),qt=new mg(A,nt,Dt),Dt.programs=wt.programs,S.capabilities=St,S.extensions=nt,S.properties=mt,S.renderLists=xt,S.shadowMap=Et,S.state=ot,S.info=Dt}ft();const W=new tv(S,A);this.xr=W,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){const x=nt.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=nt.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(x){x!==void 0&&(k=x,this.setSize(G,K,!1))},this.getSize=function(x){return x.set(G,K)},this.setSize=function(x,I,B=!0){if(W.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=x,K=I,e.width=Math.floor(x*k),e.height=Math.floor(I*k),B===!0&&(e.style.width=x+"px",e.style.height=I+"px"),this.setViewport(0,0,x,I)},this.getDrawingBufferSize=function(x){return x.set(G*k,K*k).floor()},this.setDrawingBufferSize=function(x,I,B){G=x,K=I,k=B,e.width=Math.floor(x*B),e.height=Math.floor(I*B),this.setViewport(0,0,x,I)},this.getCurrentViewport=function(x){return x.copy(w)},this.getViewport=function(x){return x.copy(Mt)},this.setViewport=function(x,I,B,z){x.isVector4?Mt.set(x.x,x.y,x.z,x.w):Mt.set(x,I,B,z),ot.viewport(w.copy(Mt).multiplyScalar(k).round())},this.getScissor=function(x){return x.copy(Ft)},this.setScissor=function(x,I,B,z){x.isVector4?Ft.set(x.x,x.y,x.z,x.w):Ft.set(x,I,B,z),ot.scissor(H.copy(Ft).multiplyScalar(k).round())},this.getScissorTest=function(){return Zt},this.setScissorTest=function(x){ot.setScissorTest(Zt=x)},this.setOpaqueSort=function(x){ct=x},this.setTransparentSort=function(x){pt=x},this.getClearColor=function(x){return x.copy(Lt.getClearColor())},this.setClearColor=function(){Lt.setClearColor.apply(Lt,arguments)},this.getClearAlpha=function(){return Lt.getClearAlpha()},this.setClearAlpha=function(){Lt.setClearAlpha.apply(Lt,arguments)},this.clear=function(x=!0,I=!0,B=!0){let z=0;if(x){let N=!1;if(D!==null){const it=D.texture.format;N=it===Ha||it===za||it===Ba}if(N){const it=D.texture.type,dt=it===fn||it===qn||it===Ki||it===Ri||it===Fa||it===Oa,yt=Lt.getClearColor(),At=Lt.getClearAlpha(),It=yt.r,Ot=yt.g,Ct=yt.b;dt?(g[0]=It,g[1]=Ot,g[2]=Ct,g[3]=At,A.clearBufferuiv(A.COLOR,0,g)):(v[0]=It,v[1]=Ot,v[2]=Ct,v[3]=At,A.clearBufferiv(A.COLOR,0,v))}else z|=A.COLOR_BUFFER_BIT}I&&(z|=A.DEPTH_BUFFER_BIT),B&&(z|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(z)},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(){e.removeEventListener("webglcontextlost",$,!1),e.removeEventListener("webglcontextrestored",_t,!1),e.removeEventListener("webglcontextcreationerror",gt,!1),Lt.dispose(),xt.dispose(),Xt.dispose(),mt.dispose(),_.dispose(),F.dispose(),Z.dispose(),ie.dispose(),U.dispose(),wt.dispose(),W.dispose(),W.removeEventListener("sessionstart",hc),W.removeEventListener("sessionend",fc),Rn.stop()};function $(x){x.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),L=!0}function _t(){console.log("THREE.WebGLRenderer: Context Restored."),L=!1;const x=Dt.autoReset,I=Et.enabled,B=Et.autoUpdate,z=Et.needsUpdate,N=Et.type;ft(),Dt.autoReset=x,Et.enabled=I,Et.autoUpdate=B,Et.needsUpdate=z,Et.type=N}function gt(x){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function Bt(x){const I=x.target;I.removeEventListener("dispose",Bt),ae(I)}function ae(x){xe(x),mt.remove(x)}function xe(x){const I=mt.get(x).programs;I!==void 0&&(I.forEach(function(B){wt.releaseProgram(B)}),x.isShaderMaterial&&wt.releaseShaderCache(x))}this.renderBufferDirect=function(x,I,B,z,N,it){I===null&&(I=Vt);const dt=N.isMesh&&N.matrixWorld.determinant()<0,yt=Ou(x,I,B,z,N);ot.setMaterial(z,dt);let At=B.index,It=1;if(z.wireframe===!0){if(At=tt.getWireframeAttribute(B),At===void 0)return;It=2}const Ot=B.drawRange,Ct=B.attributes.position;let Yt=Ot.start*It,jt=(Ot.start+Ot.count)*It;it!==null&&(Yt=Math.max(Yt,it.start*It),jt=Math.min(jt,(it.start+it.count)*It)),At!==null?(Yt=Math.max(Yt,0),jt=Math.min(jt,At.count)):Ct!=null&&(Yt=Math.max(Yt,0),jt=Math.min(jt,Ct.count));const ue=jt-Yt;if(ue<0||ue===1/0)return;ie.setup(N,z,yt,B,At);let ce,Jt=Tt;if(At!==null&&(ce=q.get(At),Jt=qt,Jt.setIndex(ce)),N.isMesh)z.wireframe===!0?(ot.setLineWidth(z.wireframeLinewidth*et()),Jt.setMode(A.LINES)):Jt.setMode(A.TRIANGLES);else if(N.isLine){let Pt=z.linewidth;Pt===void 0&&(Pt=1),ot.setLineWidth(Pt*et()),N.isLineSegments?Jt.setMode(A.LINES):N.isLineLoop?Jt.setMode(A.LINE_LOOP):Jt.setMode(A.LINE_STRIP)}else N.isPoints?Jt.setMode(A.POINTS):N.isSprite&&Jt.setMode(A.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)Jt.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(nt.get("WEBGL_multi_draw"))Jt.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const Pt=N._multiDrawStarts,_e=N._multiDrawCounts,$t=N._multiDrawCount,ze=At?q.get(At).bytesPerElement:1,Qn=mt.get(z).currentProgram.getUniforms();for(let Le=0;Le<$t;Le++)Qn.setValue(A,"_gl_DrawID",Le),Jt.render(Pt[Le]/ze,_e[Le])}else if(N.isInstancedMesh)Jt.renderInstances(Yt,ue,N.count);else if(B.isInstancedBufferGeometry){const Pt=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,_e=Math.min(B.instanceCount,Pt);Jt.renderInstances(Yt,ue,_e)}else Jt.render(Yt,ue)};function Qt(x,I,B){x.transparent===!0&&x.side===Ze&&x.forceSinglePass===!1?(x.side=Ce,x.needsUpdate=!0,lr(x,I,B),x.side=bn,x.needsUpdate=!0,lr(x,I,B),x.side=Ze):lr(x,I,B)}this.compile=function(x,I,B=null){B===null&&(B=x),p=Xt.get(B),p.init(I),T.push(p),B.traverseVisible(function(N){N.isLight&&N.layers.test(I.layers)&&(p.pushLight(N),N.castShadow&&p.pushShadow(N))}),x!==B&&x.traverseVisible(function(N){N.isLight&&N.layers.test(I.layers)&&(p.pushLight(N),N.castShadow&&p.pushShadow(N))}),p.setupLights();const z=new Set;return x.traverse(function(N){if(!(N.isMesh||N.isPoints||N.isLine||N.isSprite))return;const it=N.material;if(it)if(Array.isArray(it))for(let dt=0;dt<it.length;dt++){const yt=it[dt];Qt(yt,B,N),z.add(yt)}else Qt(it,B,N),z.add(it)}),T.pop(),p=null,z},this.compileAsync=function(x,I,B=null){const z=this.compile(x,I,B);return new Promise(N=>{function it(){if(z.forEach(function(dt){mt.get(dt).currentProgram.isReady()&&z.delete(dt)}),z.size===0){N(x);return}setTimeout(it,10)}nt.get("KHR_parallel_shader_compile")!==null?it():setTimeout(it,10)})};let Be=null;function tn(x){Be&&Be(x)}function hc(){Rn.stop()}function fc(){Rn.start()}const Rn=new gu;Rn.setAnimationLoop(tn),typeof self<"u"&&Rn.setContext(self),this.setAnimationLoop=function(x){Be=x,W.setAnimationLoop(x),x===null?Rn.stop():Rn.start()},W.addEventListener("sessionstart",hc),W.addEventListener("sessionend",fc),this.render=function(x,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),W.enabled===!0&&W.isPresenting===!0&&(W.cameraAutoUpdate===!0&&W.updateCamera(I),I=W.getCamera()),x.isScene===!0&&x.onBeforeRender(S,x,I,D),p=Xt.get(x,T.length),p.init(I),T.push(p),ut.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),Y.setFromProjectionMatrix(ut),Q=this.localClippingEnabled,st=rt.init(this.clippingPlanes,Q),m=xt.get(x,b.length),m.init(),b.push(m),W.enabled===!0&&W.isPresenting===!0){const it=S.xr.getDepthSensingMesh();it!==null&&is(it,I,-1/0,S.sortObjects)}is(x,I,0,S.sortObjects),m.finish(),S.sortObjects===!0&&m.sort(ct,pt),J=W.enabled===!1||W.isPresenting===!1||W.hasDepthSensing()===!1,J&&Lt.addToRenderList(m,x),this.info.render.frame++,st===!0&&rt.beginShadows();const B=p.state.shadowsArray;Et.render(B,x,I),st===!0&&rt.endShadows(),this.info.autoReset===!0&&this.info.reset();const z=m.opaque,N=m.transmissive;if(p.setupLights(),I.isArrayCamera){const it=I.cameras;if(N.length>0)for(let dt=0,yt=it.length;dt<yt;dt++){const At=it[dt];pc(z,N,x,At)}J&&Lt.render(x);for(let dt=0,yt=it.length;dt<yt;dt++){const At=it[dt];dc(m,x,At,At.viewport)}}else N.length>0&&pc(z,N,x,I),J&&Lt.render(x),dc(m,x,I);D!==null&&R===0&&(E.updateMultisampleRenderTarget(D),E.updateRenderTargetMipmap(D)),x.isScene===!0&&x.onAfterRender(S,x,I),ie.resetDefaultState(),y=-1,M=null,T.pop(),T.length>0?(p=T[T.length-1],st===!0&&rt.setGlobalState(S.clippingPlanes,p.state.camera)):p=null,b.pop(),b.length>0?m=b[b.length-1]:m=null};function is(x,I,B,z){if(x.visible===!1)return;if(x.layers.test(I.layers)){if(x.isGroup)B=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(I);else if(x.isLight)p.pushLight(x),x.castShadow&&p.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Y.intersectsSprite(x)){z&&Rt.setFromMatrixPosition(x.matrixWorld).applyMatrix4(ut);const dt=Z.update(x),yt=x.material;yt.visible&&m.push(x,dt,yt,B,Rt.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Y.intersectsObject(x))){const dt=Z.update(x),yt=x.material;if(z&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),Rt.copy(x.boundingSphere.center)):(dt.boundingSphere===null&&dt.computeBoundingSphere(),Rt.copy(dt.boundingSphere.center)),Rt.applyMatrix4(x.matrixWorld).applyMatrix4(ut)),Array.isArray(yt)){const At=dt.groups;for(let It=0,Ot=At.length;It<Ot;It++){const Ct=At[It],Yt=yt[Ct.materialIndex];Yt&&Yt.visible&&m.push(x,dt,Yt,B,Rt.z,Ct)}}else yt.visible&&m.push(x,dt,yt,B,Rt.z,null)}}const it=x.children;for(let dt=0,yt=it.length;dt<yt;dt++)is(it[dt],I,B,z)}function dc(x,I,B,z){const N=x.opaque,it=x.transmissive,dt=x.transparent;p.setupLightsView(B),st===!0&&rt.setGlobalState(S.clippingPlanes,B),z&&ot.viewport(w.copy(z)),N.length>0&&cr(N,I,B),it.length>0&&cr(it,I,B),dt.length>0&&cr(dt,I,B),ot.buffers.depth.setTest(!0),ot.buffers.depth.setMask(!0),ot.buffers.color.setMask(!0),ot.setPolygonOffset(!1)}function pc(x,I,B,z){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[z.id]===void 0&&(p.state.transmissionRenderTarget[z.id]=new Yn(1,1,{generateMipmaps:!0,type:nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float")?ir:fn,minFilter:Gn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Kt.workingColorSpace}));const it=p.state.transmissionRenderTarget[z.id],dt=z.viewport||w;it.setSize(dt.z*S.transmissionResolutionScale,dt.w*S.transmissionResolutionScale);const yt=S.getRenderTarget();S.setRenderTarget(it),S.getClearColor(V),X=S.getClearAlpha(),X<1&&S.setClearColor(16777215,.5),S.clear(),J&&Lt.render(B);const At=S.toneMapping;S.toneMapping=Tn;const It=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),p.setupLightsView(z),st===!0&&rt.setGlobalState(S.clippingPlanes,z),cr(x,B,z),E.updateMultisampleRenderTarget(it),E.updateRenderTargetMipmap(it),nt.has("WEBGL_multisampled_render_to_texture")===!1){let Ot=!1;for(let Ct=0,Yt=I.length;Ct<Yt;Ct++){const jt=I[Ct],ue=jt.object,ce=jt.geometry,Jt=jt.material,Pt=jt.group;if(Jt.side===Ze&&ue.layers.test(z.layers)){const _e=Jt.side;Jt.side=Ce,Jt.needsUpdate=!0,mc(ue,B,z,ce,Jt,Pt),Jt.side=_e,Jt.needsUpdate=!0,Ot=!0}}Ot===!0&&(E.updateMultisampleRenderTarget(it),E.updateRenderTargetMipmap(it))}S.setRenderTarget(yt),S.setClearColor(V,X),It!==void 0&&(z.viewport=It),S.toneMapping=At}function cr(x,I,B){const z=I.isScene===!0?I.overrideMaterial:null;for(let N=0,it=x.length;N<it;N++){const dt=x[N],yt=dt.object,At=dt.geometry,It=z===null?dt.material:z,Ot=dt.group;yt.layers.test(B.layers)&&mc(yt,I,B,At,It,Ot)}}function mc(x,I,B,z,N,it){x.onBeforeRender(S,I,B,z,N,it),x.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),N.onBeforeRender(S,I,B,z,x,it),N.transparent===!0&&N.side===Ze&&N.forceSinglePass===!1?(N.side=Ce,N.needsUpdate=!0,S.renderBufferDirect(B,I,z,N,x,it),N.side=bn,N.needsUpdate=!0,S.renderBufferDirect(B,I,z,N,x,it),N.side=Ze):S.renderBufferDirect(B,I,z,N,x,it),x.onAfterRender(S,I,B,z,N,it)}function lr(x,I,B){I.isScene!==!0&&(I=Vt);const z=mt.get(x),N=p.state.lights,it=p.state.shadowsArray,dt=N.state.version,yt=wt.getParameters(x,N.state,it,I,B),At=wt.getProgramCacheKey(yt);let It=z.programs;z.environment=x.isMeshStandardMaterial?I.environment:null,z.fog=I.fog,z.envMap=(x.isMeshStandardMaterial?F:_).get(x.envMap||z.environment),z.envMapRotation=z.environment!==null&&x.envMap===null?I.environmentRotation:x.envMapRotation,It===void 0&&(x.addEventListener("dispose",Bt),It=new Map,z.programs=It);let Ot=It.get(At);if(Ot!==void 0){if(z.currentProgram===Ot&&z.lightsStateVersion===dt)return _c(x,yt),Ot}else yt.uniforms=wt.getUniforms(x),x.onBeforeCompile(yt,S),Ot=wt.acquireProgram(yt,At),It.set(At,Ot),z.uniforms=yt.uniforms;const Ct=z.uniforms;return(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)&&(Ct.clippingPlanes=rt.uniform),_c(x,yt),z.needsLights=zu(x),z.lightsStateVersion=dt,z.needsLights&&(Ct.ambientLightColor.value=N.state.ambient,Ct.lightProbe.value=N.state.probe,Ct.directionalLights.value=N.state.directional,Ct.directionalLightShadows.value=N.state.directionalShadow,Ct.spotLights.value=N.state.spot,Ct.spotLightShadows.value=N.state.spotShadow,Ct.rectAreaLights.value=N.state.rectArea,Ct.ltc_1.value=N.state.rectAreaLTC1,Ct.ltc_2.value=N.state.rectAreaLTC2,Ct.pointLights.value=N.state.point,Ct.pointLightShadows.value=N.state.pointShadow,Ct.hemisphereLights.value=N.state.hemi,Ct.directionalShadowMap.value=N.state.directionalShadowMap,Ct.directionalShadowMatrix.value=N.state.directionalShadowMatrix,Ct.spotShadowMap.value=N.state.spotShadowMap,Ct.spotLightMatrix.value=N.state.spotLightMatrix,Ct.spotLightMap.value=N.state.spotLightMap,Ct.pointShadowMap.value=N.state.pointShadowMap,Ct.pointShadowMatrix.value=N.state.pointShadowMatrix),z.currentProgram=Ot,z.uniformsList=null,Ot}function gc(x){if(x.uniformsList===null){const I=x.currentProgram.getUniforms();x.uniformsList=Hr.seqWithValue(I.seq,x.uniforms)}return x.uniformsList}function _c(x,I){const B=mt.get(x);B.outputColorSpace=I.outputColorSpace,B.batching=I.batching,B.batchingColor=I.batchingColor,B.instancing=I.instancing,B.instancingColor=I.instancingColor,B.instancingMorph=I.instancingMorph,B.skinning=I.skinning,B.morphTargets=I.morphTargets,B.morphNormals=I.morphNormals,B.morphColors=I.morphColors,B.morphTargetsCount=I.morphTargetsCount,B.numClippingPlanes=I.numClippingPlanes,B.numIntersection=I.numClipIntersection,B.vertexAlphas=I.vertexAlphas,B.vertexTangents=I.vertexTangents,B.toneMapping=I.toneMapping}function Ou(x,I,B,z,N){I.isScene!==!0&&(I=Vt),E.resetTextureUnits();const it=I.fog,dt=z.isMeshStandardMaterial?I.environment:null,yt=D===null?S.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Pi,At=(z.isMeshStandardMaterial?F:_).get(z.envMap||dt),It=z.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Ot=!!B.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Ct=!!B.morphAttributes.position,Yt=!!B.morphAttributes.normal,jt=!!B.morphAttributes.color;let ue=Tn;z.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(ue=S.toneMapping);const ce=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,Jt=ce!==void 0?ce.length:0,Pt=mt.get(z),_e=p.state.lights;if(st===!0&&(Q===!0||x!==M)){const Ee=x===M&&z.id===y;rt.setState(z,x,Ee)}let $t=!1;z.version===Pt.__version?(Pt.needsLights&&Pt.lightsStateVersion!==_e.state.version||Pt.outputColorSpace!==yt||N.isBatchedMesh&&Pt.batching===!1||!N.isBatchedMesh&&Pt.batching===!0||N.isBatchedMesh&&Pt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Pt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Pt.instancing===!1||!N.isInstancedMesh&&Pt.instancing===!0||N.isSkinnedMesh&&Pt.skinning===!1||!N.isSkinnedMesh&&Pt.skinning===!0||N.isInstancedMesh&&Pt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Pt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Pt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Pt.instancingMorph===!1&&N.morphTexture!==null||Pt.envMap!==At||z.fog===!0&&Pt.fog!==it||Pt.numClippingPlanes!==void 0&&(Pt.numClippingPlanes!==rt.numPlanes||Pt.numIntersection!==rt.numIntersection)||Pt.vertexAlphas!==It||Pt.vertexTangents!==Ot||Pt.morphTargets!==Ct||Pt.morphNormals!==Yt||Pt.morphColors!==jt||Pt.toneMapping!==ue||Pt.morphTargetsCount!==Jt)&&($t=!0):($t=!0,Pt.__version=z.version);let ze=Pt.currentProgram;$t===!0&&(ze=lr(z,I,N));let Qn=!1,Le=!1,Oi=!1;const se=ze.getUniforms(),Ne=Pt.uniforms;if(ot.useProgram(ze.program)&&(Qn=!0,Le=!0,Oi=!0),z.id!==y&&(y=z.id,Le=!0),Qn||M!==x){ot.buffers.depth.getReversed()?(j.copy(x.projectionMatrix),nf(j),rf(j),se.setValue(A,"projectionMatrix",j)):se.setValue(A,"projectionMatrix",x.projectionMatrix),se.setValue(A,"viewMatrix",x.matrixWorldInverse);const be=se.map.cameraPosition;be!==void 0&&be.setValue(A,vt.setFromMatrixPosition(x.matrixWorld)),St.logarithmicDepthBuffer&&se.setValue(A,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&se.setValue(A,"isOrthographic",x.isOrthographicCamera===!0),M!==x&&(M=x,Le=!0,Oi=!0)}if(N.isSkinnedMesh){se.setOptional(A,N,"bindMatrix"),se.setOptional(A,N,"bindMatrixInverse");const Ee=N.skeleton;Ee&&(Ee.boneTexture===null&&Ee.computeBoneTexture(),se.setValue(A,"boneTexture",Ee.boneTexture,E))}N.isBatchedMesh&&(se.setOptional(A,N,"batchingTexture"),se.setValue(A,"batchingTexture",N._matricesTexture,E),se.setOptional(A,N,"batchingIdTexture"),se.setValue(A,"batchingIdTexture",N._indirectTexture,E),se.setOptional(A,N,"batchingColorTexture"),N._colorsTexture!==null&&se.setValue(A,"batchingColorTexture",N._colorsTexture,E));const Fe=B.morphAttributes;if((Fe.position!==void 0||Fe.normal!==void 0||Fe.color!==void 0)&&Ut.update(N,B,ze),(Le||Pt.receiveShadow!==N.receiveShadow)&&(Pt.receiveShadow=N.receiveShadow,se.setValue(A,"receiveShadow",N.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(Ne.envMap.value=At,Ne.flipEnvMap.value=At.isCubeTexture&&At.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&I.environment!==null&&(Ne.envMapIntensity.value=I.environmentIntensity),Le&&(se.setValue(A,"toneMappingExposure",S.toneMappingExposure),Pt.needsLights&&Bu(Ne,Oi),it&&z.fog===!0&&ht.refreshFogUniforms(Ne,it),ht.refreshMaterialUniforms(Ne,z,k,K,p.state.transmissionRenderTarget[x.id]),Hr.upload(A,gc(Pt),Ne,E)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Hr.upload(A,gc(Pt),Ne,E),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&se.setValue(A,"center",N.center),se.setValue(A,"modelViewMatrix",N.modelViewMatrix),se.setValue(A,"normalMatrix",N.normalMatrix),se.setValue(A,"modelMatrix",N.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){const Ee=z.uniformsGroups;for(let be=0,rs=Ee.length;be<rs;be++){const Cn=Ee[be];U.update(Cn,ze),U.bind(Cn,ze)}}return ze}function Bu(x,I){x.ambientLightColor.needsUpdate=I,x.lightProbe.needsUpdate=I,x.directionalLights.needsUpdate=I,x.directionalLightShadows.needsUpdate=I,x.pointLights.needsUpdate=I,x.pointLightShadows.needsUpdate=I,x.spotLights.needsUpdate=I,x.spotLightShadows.needsUpdate=I,x.rectAreaLights.needsUpdate=I,x.hemisphereLights.needsUpdate=I}function zu(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return C},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(x,I,B){mt.get(x.texture).__webglTexture=I,mt.get(x.depthTexture).__webglTexture=B;const z=mt.get(x);z.__hasExternalTextures=!0,z.__autoAllocateDepthBuffer=B===void 0,z.__autoAllocateDepthBuffer||nt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),z.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(x,I){const B=mt.get(x);B.__webglFramebuffer=I,B.__useDefaultFramebuffer=I===void 0};const Hu=A.createFramebuffer();this.setRenderTarget=function(x,I=0,B=0){D=x,C=I,R=B;let z=!0,N=null,it=!1,dt=!1;if(x){const At=mt.get(x);if(At.__useDefaultFramebuffer!==void 0)ot.bindFramebuffer(A.FRAMEBUFFER,null),z=!1;else if(At.__webglFramebuffer===void 0)E.setupRenderTarget(x);else if(At.__hasExternalTextures)E.rebindTextures(x,mt.get(x.texture).__webglTexture,mt.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){const Ct=x.depthTexture;if(At.__boundDepthTexture!==Ct){if(Ct!==null&&mt.has(Ct)&&(x.width!==Ct.image.width||x.height!==Ct.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");E.setupDepthRenderbuffer(x)}}const It=x.texture;(It.isData3DTexture||It.isDataArrayTexture||It.isCompressedArrayTexture)&&(dt=!0);const Ot=mt.get(x).__webglFramebuffer;x.isWebGLCubeRenderTarget?(Array.isArray(Ot[I])?N=Ot[I][B]:N=Ot[I],it=!0):x.samples>0&&E.useMultisampledRTT(x)===!1?N=mt.get(x).__webglMultisampledFramebuffer:Array.isArray(Ot)?N=Ot[B]:N=Ot,w.copy(x.viewport),H.copy(x.scissor),O=x.scissorTest}else w.copy(Mt).multiplyScalar(k).floor(),H.copy(Ft).multiplyScalar(k).floor(),O=Zt;if(B!==0&&(N=Hu),ot.bindFramebuffer(A.FRAMEBUFFER,N)&&z&&ot.drawBuffers(x,N),ot.viewport(w),ot.scissor(H),ot.setScissorTest(O),it){const At=mt.get(x.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+I,At.__webglTexture,B)}else if(dt){const At=mt.get(x.texture),It=I;A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,At.__webglTexture,B,It)}else if(x!==null&&B!==0){const At=mt.get(x.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,At.__webglTexture,B)}y=-1},this.readRenderTargetPixels=function(x,I,B,z,N,it,dt){if(!(x&&x.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let yt=mt.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&dt!==void 0&&(yt=yt[dt]),yt){ot.bindFramebuffer(A.FRAMEBUFFER,yt);try{const At=x.texture,It=At.format,Ot=At.type;if(!St.textureFormatReadable(It)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!St.textureTypeReadable(Ot)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=x.width-z&&B>=0&&B<=x.height-N&&A.readPixels(I,B,z,N,Ht.convert(It),Ht.convert(Ot),it)}finally{const At=D!==null?mt.get(D).__webglFramebuffer:null;ot.bindFramebuffer(A.FRAMEBUFFER,At)}}},this.readRenderTargetPixelsAsync=async function(x,I,B,z,N,it,dt){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let yt=mt.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&dt!==void 0&&(yt=yt[dt]),yt){const At=x.texture,It=At.format,Ot=At.type;if(!St.textureFormatReadable(It))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!St.textureTypeReadable(Ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(I>=0&&I<=x.width-z&&B>=0&&B<=x.height-N){ot.bindFramebuffer(A.FRAMEBUFFER,yt);const Ct=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,Ct),A.bufferData(A.PIXEL_PACK_BUFFER,it.byteLength,A.STREAM_READ),A.readPixels(I,B,z,N,Ht.convert(It),Ht.convert(Ot),0);const Yt=D!==null?mt.get(D).__webglFramebuffer:null;ot.bindFramebuffer(A.FRAMEBUFFER,Yt);const jt=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await ef(A,jt,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,Ct),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,it),A.deleteBuffer(Ct),A.deleteSync(jt),it}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(x,I=null,B=0){x.isTexture!==!0&&(mi("WebGLRenderer: copyFramebufferToTexture function signature has changed."),I=arguments[0]||null,x=arguments[1]);const z=Math.pow(2,-B),N=Math.floor(x.image.width*z),it=Math.floor(x.image.height*z),dt=I!==null?I.x:0,yt=I!==null?I.y:0;E.setTexture2D(x,0),A.copyTexSubImage2D(A.TEXTURE_2D,B,0,0,dt,yt,N,it),ot.unbindTexture()};const ku=A.createFramebuffer(),Gu=A.createFramebuffer();this.copyTextureToTexture=function(x,I,B=null,z=null,N=0,it=null){x.isTexture!==!0&&(mi("WebGLRenderer: copyTextureToTexture function signature has changed."),z=arguments[0]||null,x=arguments[1],I=arguments[2],it=arguments[3]||0,B=null),it===null&&(N!==0?(mi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),it=N,N=0):it=0);let dt,yt,At,It,Ot,Ct,Yt,jt,ue;const ce=x.isCompressedTexture?x.mipmaps[it]:x.image;if(B!==null)dt=B.max.x-B.min.x,yt=B.max.y-B.min.y,At=B.isBox3?B.max.z-B.min.z:1,It=B.min.x,Ot=B.min.y,Ct=B.isBox3?B.min.z:0;else{const Fe=Math.pow(2,-N);dt=Math.floor(ce.width*Fe),yt=Math.floor(ce.height*Fe),x.isDataArrayTexture?At=ce.depth:x.isData3DTexture?At=Math.floor(ce.depth*Fe):At=1,It=0,Ot=0,Ct=0}z!==null?(Yt=z.x,jt=z.y,ue=z.z):(Yt=0,jt=0,ue=0);const Jt=Ht.convert(I.format),Pt=Ht.convert(I.type);let _e;I.isData3DTexture?(E.setTexture3D(I,0),_e=A.TEXTURE_3D):I.isDataArrayTexture||I.isCompressedArrayTexture?(E.setTexture2DArray(I,0),_e=A.TEXTURE_2D_ARRAY):(E.setTexture2D(I,0),_e=A.TEXTURE_2D),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,I.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,I.unpackAlignment);const $t=A.getParameter(A.UNPACK_ROW_LENGTH),ze=A.getParameter(A.UNPACK_IMAGE_HEIGHT),Qn=A.getParameter(A.UNPACK_SKIP_PIXELS),Le=A.getParameter(A.UNPACK_SKIP_ROWS),Oi=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,ce.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,ce.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,It),A.pixelStorei(A.UNPACK_SKIP_ROWS,Ot),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Ct);const se=x.isDataArrayTexture||x.isData3DTexture,Ne=I.isDataArrayTexture||I.isData3DTexture;if(x.isDepthTexture){const Fe=mt.get(x),Ee=mt.get(I),be=mt.get(Fe.__renderTarget),rs=mt.get(Ee.__renderTarget);ot.bindFramebuffer(A.READ_FRAMEBUFFER,be.__webglFramebuffer),ot.bindFramebuffer(A.DRAW_FRAMEBUFFER,rs.__webglFramebuffer);for(let Cn=0;Cn<At;Cn++)se&&(A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,mt.get(x).__webglTexture,N,Ct+Cn),A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,mt.get(I).__webglTexture,it,ue+Cn)),A.blitFramebuffer(It,Ot,dt,yt,Yt,jt,dt,yt,A.DEPTH_BUFFER_BIT,A.NEAREST);ot.bindFramebuffer(A.READ_FRAMEBUFFER,null),ot.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else if(N!==0||x.isRenderTargetTexture||mt.has(x)){const Fe=mt.get(x),Ee=mt.get(I);ot.bindFramebuffer(A.READ_FRAMEBUFFER,ku),ot.bindFramebuffer(A.DRAW_FRAMEBUFFER,Gu);for(let be=0;be<At;be++)se?A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Fe.__webglTexture,N,Ct+be):A.framebufferTexture2D(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Fe.__webglTexture,N),Ne?A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Ee.__webglTexture,it,ue+be):A.framebufferTexture2D(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Ee.__webglTexture,it),N!==0?A.blitFramebuffer(It,Ot,dt,yt,Yt,jt,dt,yt,A.COLOR_BUFFER_BIT,A.NEAREST):Ne?A.copyTexSubImage3D(_e,it,Yt,jt,ue+be,It,Ot,dt,yt):A.copyTexSubImage2D(_e,it,Yt,jt,It,Ot,dt,yt);ot.bindFramebuffer(A.READ_FRAMEBUFFER,null),ot.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else Ne?x.isDataTexture||x.isData3DTexture?A.texSubImage3D(_e,it,Yt,jt,ue,dt,yt,At,Jt,Pt,ce.data):I.isCompressedArrayTexture?A.compressedTexSubImage3D(_e,it,Yt,jt,ue,dt,yt,At,Jt,ce.data):A.texSubImage3D(_e,it,Yt,jt,ue,dt,yt,At,Jt,Pt,ce):x.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,it,Yt,jt,dt,yt,Jt,Pt,ce.data):x.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,it,Yt,jt,ce.width,ce.height,Jt,ce.data):A.texSubImage2D(A.TEXTURE_2D,it,Yt,jt,dt,yt,Jt,Pt,ce);A.pixelStorei(A.UNPACK_ROW_LENGTH,$t),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,ze),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Qn),A.pixelStorei(A.UNPACK_SKIP_ROWS,Le),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Oi),it===0&&I.generateMipmaps&&A.generateMipmap(_e),ot.unbindTexture()},this.copyTextureToTexture3D=function(x,I,B=null,z=null,N=0){return x.isTexture!==!0&&(mi("WebGLRenderer: copyTextureToTexture3D function signature has changed."),B=arguments[0]||null,z=arguments[1]||null,x=arguments[2],I=arguments[3],N=arguments[4]||0),mi('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(x,I,B,z,N)},this.initRenderTarget=function(x){mt.get(x).__webglFramebuffer===void 0&&E.setupRenderTarget(x)},this.initTexture=function(x){x.isCubeTexture?E.setTextureCube(x,0):x.isData3DTexture?E.setTexture3D(x,0):x.isDataArrayTexture||x.isCompressedArrayTexture?E.setTexture2DArray(x,0):E.setTexture2D(x,0),ot.unbindTexture()},this.resetState=function(){C=0,R=0,D=null,ot.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return un}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=Kt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Kt._getUnpackColorSpace()}}const Xn=ge-1,ic=16.25,cn=.72,Yr=.42,Zr=cn+.41*Yr,wl=Zr+.25;function zn(i,t){return{x:t-Xn/2,z:i-Xn/2}}function sv(){const i=document.createElement("canvas");i.width=i.height=256;const t=i.getContext("2d");t.fillStyle="#141a22",t.fillRect(0,0,256,256);for(let n=0;n<1700;n++){const r=20+Math.floor(Math.random()*20);t.fillStyle=`rgba(${r+6}, ${r+10}, ${r+15}, .16)`,t.fillRect(Math.random()*256,Math.random()*256,1,1)}const e=new su(i);return e.wrapS=e.wrapT=wi,e.repeat.set(7,7),e}function ov(){const i=new pd,t=i.load("images/wood.jpg"),e=i.load("images/wood_normal.jpg");return t.colorSpace=we,t.wrapS=t.wrapT=wi,e.wrapS=e.wrapT=wi,t.repeat.set(1.6,1.6),e.repeat.set(1.6,1.6),t.center.set(.5,.5),e.center.set(.5,.5),t.rotation=Math.PI/2,e.rotation=Math.PI/2,t.anisotropy=4,e.anisotropy=4,{color:t,normal:e}}function av(){const i=document.createElement("canvas");i.width=i.height=128;const t=i.getContext("2d"),e=t.createRadialGradient(64,64,8,64,64,64);return e.addColorStop(0,"rgba(13, 13, 13, 0.56)"),e.addColorStop(.5,"rgba(13, 13, 13, 0.46)"),e.addColorStop(.82,"rgba(13, 13, 13, 0.2)"),e.addColorStop(1,"rgba(13, 13, 13, 0)"),t.fillStyle=e,t.fillRect(0,0,128,128),new su(i)}function Su(i=ic){const t=new Ja,e=i/2,n=.35;return t.moveTo(-e+n,-e),t.lineTo(e-n,-e),t.quadraticCurveTo(e,-e,e,-e+n),t.lineTo(e,e-n),t.quadraticCurveTo(e,e,e-n,e),t.lineTo(-e+n,e),t.quadraticCurveTo(-e,e,-e,e-n),t.lineTo(-e,-e+n),t.quadraticCurveTo(-e,-e,-e+n,-e),t}function cv(){const i=Su(),t=new Ka(i,{depth:.68,bevelEnabled:!0,bevelThickness:.12,bevelSize:.1,bevelSegments:4});return t.rotateX(-Math.PI/2),t}function lv(){const i=ic-.2,t=new ja(Su(i)),e=t.getAttribute("position"),n=[];for(let r=0;r<e.count;r++)n.push((e.getX(r)+i/2)/i,(e.getY(r)+i/2)/i);return t.setAttribute("uv",new ne(n,2)),t.rotateX(-Math.PI/2),t}function uv(){const i=new Wn,t=new Vn({color:2166792}),e=new Zn(Xn,.018,.038),n=new Zn(.038,.018,Xn);for(let r=0;r<ge;r++){const s=r-Xn/2,o=new le(e,t);o.position.set(0,cn+.012,s),i.add(o);const a=new le(n,t);a.position.set(s,cn+.012,0),i.add(a)}return i}function hv(){const i=new rv({antialias:!0,powerPreference:"high-performance"});i.setPixelRatio(Math.min(window.devicePixelRatio,2)),i.outputColorSpace=we,i.toneMapping=Nl,i.toneMappingExposure=1.12,i.shadowMap.enabled=!0,i.shadowMap.type=Ul,document.getElementById("app").prepend(i.domElement);const t=new wf;t.background=new Wt("#0e131a"),t.fog=new Wa("#0e131a",30,65);const e=new Ie(38,1,.1,100);t.add(e);const n=new le(new ar(80,80),new gi({map:sv(),color:10134444,roughness:.96}));n.rotation.x=-Math.PI/2,n.position.y=-.46,n.receiveShadow=!0,t.add(n);const r=new le(cv(),new gi({color:7225887,roughness:.5,metalness:.02}));r.position.y=-.1,r.castShadow=!1,r.receiveShadow=!0,t.add(r);const s=ov(),o=new le(lv(),new gi({map:s.color,normalMap:s.normal,normalScale:new at(.7,.7),color:16777215,roughness:.5,side:Ze})),a=o.material;a.onBeforeCompile=Q=>{Q.fragmentShader=Q.fragmentShader.replace("#include <map_fragment>",`#include <map_fragment>
3828
+ float woodLuminance = dot(diffuseColor.rgb, vec3(0.2126, 0.7152, 0.0722));
3829
+ diffuseColor.rgb = mix(vec3(woodLuminance), diffuseColor.rgb, 0.72);
3830
+ diffuseColor.rgb *= vec3(0.96, 1.0, 1.03);`)},o.position.y=cn,o.receiveShadow=!0,t.add(o);const c=uv();t.add(c);const l=new Vn({color:3810326});for(const[Q,j]of[[3,3],[3,11],[7,7],[11,3],[11,11]]){const ut=new le(new Xr(.11,16),l),vt=zn(Q,j);ut.rotation.x=-Math.PI/2,ut.position.set(vt.x,cn+.02,vt.z),t.add(ut)}const u=new Jc({color:1053979,roughness:.18,clearcoat:.8,clearcoatRoughness:.1}),h=new Jc({color:15985368,roughness:.24,clearcoat:.65,clearcoatRoughness:.16}),f=new $a(.41,28,18),d=new Xr(.44,32),g=new Vn({map:av(),transparent:!0,opacity:.95,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1}),v=[],m=[],p=new Wn,b=new Vn({color:16777215,transparent:!0,opacity:.86,depthTest:!1}),T=new le(new qr(.43,.47,32),b);T.rotation.x=-Math.PI/2,p.add(T),p.position.y=cn+.025,p.renderOrder=4,t.add(p);const S=new le(new qr(.14,.2,32),new Vn({color:14703941,transparent:!0,opacity:.95,depthTest:!1}));S.rotation.x=-Math.PI/2,S.position.y=cn+.035,S.renderOrder=5,S.visible=!1,t.add(S);const L=new Wn,C=new le(new Za(.055,.055,1,18),new gi({color:16777215,emissive:16777215,emissiveIntensity:1.5,roughness:.3}));L.add(C),L.visible=!1,t.add(L);const R=[];for(let Q=0;Q<5;Q++){const j=new le(new Qa(.48,.026,8,32),new gi({color:16777215,emissive:16777215,emissiveIntensity:1.5}));j.rotation.x=-Math.PI/2,j.visible=!1,t.add(j),R.push(j)}const D=new xd(16771010,2.2);D.position.set(-5,20,5),D.castShadow=!0,D.shadow.mapSize.set(1024,1024),D.shadow.camera.left=-15,D.shadow.camera.right=15,D.shadow.camera.top=15,D.shadow.camera.bottom=-15,D.shadow.bias=-.001,D.shadow.normalBias=.02,t.add(D),t.add(new md(14083056,2037523,.65));const y=new _d(6200266,18,35,2);y.position.set(7,8,-11),t.add(y);const M=new Sd,w=new at,H=new xn(new P(0,1,0),-cn),O=new P;let V=0,X=.45,G=20;const K=new P,k=()=>{const Q=X<.001,j=Math.sin(X)*G;e.up.set(0,Q?0:1,Q?-1:0),e.position.set(K.x+Math.sin(V)*j,K.y+(Q?G:Math.cos(X)*G),K.z+Math.cos(V)*j),e.lookAt(K)},ct=(Q,j)=>{V-=Q*.008,X=Hn(X-j*.006,0,1.15),k()},pt=(Q,j)=>{const ut=new P().setFromMatrixColumn(e.matrixWorld,0);ut.y=0,ut.normalize();const vt=new P;e.getWorldDirection(vt),vt.y=0,vt.lengthSq()>1e-4?vt.normalize():vt.set(0,0,-1);const Rt=G*.0012;K.addScaledVector(ut,-Q*Rt),K.addScaledVector(vt,j*Rt),k()},Mt=()=>{const Q=window.innerWidth,j=window.innerHeight;i.setSize(Q,j),i.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.aspect=Q/j;const ut=Q/j;G=ic/2/Math.tan(Qh.degToRad(e.fov)/2)*Math.max(1,1/ut)*1.12,k(),e.updateProjectionMatrix()},Ft=(Q,j)=>{if(w.x=Q/window.innerWidth*2-1,w.y=-(j/window.innerHeight)*2+1,M.setFromCamera(w,e),!M.ray.intersectPlane(H,O))return null;const ut=Math.round(O.x+Xn/2),vt=Math.round(O.z+Xn/2);return vt<0||vt>=ge||ut<0||ut>=ge?null:{row:vt,column:ut}},Zt=(Q,j,ut,vt)=>{const{x:Rt,z:Vt}=zn(j,ut),J=new le(d,g);J.rotation.x=-Math.PI/2,J.position.set(Rt+.09,cn+.006,Vt-.09),J.renderOrder=1,t.add(J),m.push(J);const et=new le(f,Q===Ke?u:h);return et.position.set(Rt,Zr+(vt?1.1:0),Vt),et.scale.set(1,Yr,1),et.castShadow=!0,et.receiveShadow=!0,et.userData.dropStart=vt?performance.now():0,t.add(et),v.push(et),et},Y=()=>{for(const Q of v)t.remove(Q);for(const Q of m)t.remove(Q);v.length=0,m.length=0,S.visible=!1,L.visible=!1;for(const Q of R)Q.visible=!1},st=Q=>{if(Q.length<2)return;const j=zn(Q[0][0],Q[0][1]),ut=zn(Q[Q.length-1][0],Q[Q.length-1][1]),vt=ut.x-j.x,Rt=ut.z-j.z,Vt=Math.hypot(vt,Rt);L.position.set((j.x+ut.x)/2,wl,(j.z+ut.z)/2),C.scale.set(1,.001,1),L.userData.winStart=performance.now(),L.userData.winLength=Vt+.55,C.quaternion.setFromUnitVectors(new P(0,1,0),new P(vt,0,Rt).normalize()),L.visible=!0,Q.slice(0,5).forEach(([J,et],A)=>{const bt=zn(J,et);R[A].position.set(bt.x,wl,bt.z),R[A].scale.setScalar(.001),R[A].visible=!0})};return Mt(),{renderer:i,scene:t,camera:e,cursor:p,lastMark:S,winGroup:L,winBar:C,winRings:R,addStone:Zt,clearStones:Y,updateWinLine:st,pickCell:Ft,orbit:ct,pan:pt,resize:Mt}}function fv(i,t){const e=1+Math.sin(t*.005)*.055;if(i.cursor.scale.set(e,1,e),i.winGroup.visible){const n=i.winGroup.userData.winStart;if(n){const s=Hn((t-n)/1e3,0,1),o=1-Math.pow(1-s,3),a=i.winGroup.userData.winLength;i.winBar.scale.y=a*o,i.winRings.forEach((c,l)=>{const u=Hn((s-l*.08)*4,0,1);c.scale.setScalar(Hn(u,.001,1))}),s>=1&&(i.winGroup.userData.winStart=0)}const r=1.2+Math.sin(t*.006)*.55;i.winBar.material.emissiveIntensity=r;for(const s of i.winRings)s.material.emissiveIntensity=r}if(i.lastMark.visible){const n=1+Math.sin(t*.007)*.1;i.lastMark.scale.set(n,n,1)}for(const n of i.scene.children){const r=n.userData.dropStart;if(!r)continue;const s=Hn((t-r)/320,0,1),o=1-Math.pow(1-s,3);n.position.y=Zr+1.1*(1-o),n.scale.y=Yr+Math.sin(s*Math.PI)*.06,s>=1&&(n.userData.dropStart=0,n.position.y=Zr,n.scale.y=Yr)}}var Do={exports:{}},Uo={exports:{}},Io={exports:{}},No={exports:{}},Fo={exports:{}},Oo={exports:{}},Bo={exports:{}},zo={exports:{}},Ho={exports:{}},ko={exports:{}};(function(i,t){var e=Object.prototype.toString;t=function(n){return e.call(n)},i.exports=t})(ko,ko.exports);var jn=ko.exports;(function(i,t){var e=jn;t=function(n){return e(n)==="[object Number]"},i.exports=t})(Ho,Ho.exports);var yu=Ho.exports,Go={exports:{}};(function(i,t){var e=jn;t=function(n){var r=e(n);return r==="[object Function]"||r==="[object GeneratorFunction]"||r==="[object AsyncFunction]"},i.exports=t})(Go,Go.exports);var Ii=Go.exports;(function(i,t){var e=yu,n=Ii,r=Math.pow(2,53)-1;t=function(s){if(!s)return!1;var o=s.length;return e(o)&&o>=0&&o<=r&&!n(s)},i.exports=t})(zo,zo.exports);var $r=zo.exports,Vo={exports:{}},Wo={exports:{}};(function(i,t){var e=Object.prototype.hasOwnProperty;t=function(n,r){return e.call(n,r)},i.exports=t})(Wo,Wo.exports);var rc=Wo.exports;(function(i,t){var e=rc;Object.keys?t=Object.keys:t=function(n){var r=[];for(var s in n)e(n,s)&&r.push(s);return r},i.exports=t})(Vo,Vo.exports);var $n=Vo.exports,Xo={exports:{}};(function(i,t){var e=nr;t=function(n,r,s){if(e(r))return n;switch(s??3){case 1:return function(o){return n.call(r,o)};case 3:return function(o,a,c){return n.call(r,o,a,c)};case 4:return function(o,a,c,l){return n.call(r,o,a,c,l)}}return function(){return n.apply(r,arguments)}},i.exports=t})(Xo,Xo.exports);var Eu=Xo.exports;(function(i,t){var e=$r,n=$n,r=Eu;t=function(s,o,a){o=r(o,a);var c,l;if(e(s))for(c=0,l=s.length;c<l;c++)o(s[c],c,s);else{var u=n(s);for(c=0,l=u.length;c<l;c++)o(s[u[c]],u[c],s)}return s},i.exports=t})(Bo,Bo.exports);var Qr=Bo.exports;(function(i,t){var e=nr,n=Qr;t=function(r,s){return function(o){return n(arguments,function(a,c){if(c!==0){var l=r(a);n(l,function(u){(!s||e(o[u]))&&(o[u]=a[u])})}}),o}},i.exports=t})(Oo,Oo.exports);var sc=Oo.exports,qo={exports:{}},Yo={exports:{}},Zo={exports:{}};(function(i,t){t=function(e){var n=typeof e;return!!e&&(n==="function"||n==="object")},i.exports=t})(Zo,Zo.exports);var Ni=Zo.exports;(function(i,t){var e=Ni,n=Ii,r=Object.getPrototypeOf,s={}.constructor;t=function(o){if(e(o)){if(r)return r(o);var a=o.__proto__;if(a||a===null)return a;if(n(o.constructor))return o.constructor.prototype;if(o instanceof s)return s.prototype}},i.exports=t})(Yo,Yo.exports);var dv=Yo.exports,Jo={exports:{}},Ko={exports:{}},jo={exports:{}},$o={exports:{}};(function(i,t){var e=jn;Array.isArray?t=Array.isArray:t=function(n){return e(n)==="[object Array]"},i.exports=t})($o,$o.exports);var Fi=$o.exports,Qo={exports:{}},ta={exports:{}};(function(i,t){var e=$n,n=sc;t=n(e),i.exports=t})(ta,ta.exports);var pv=ta.exports,ea={exports:{}};(function(i,t){var e=$n;t=function(n,r){var s=e(r),o=s.length;if(n==null)return!o;n=Object(n);for(var a=0;a<o;a++){var c=s[a];if(r[c]!==n[c]||!(c in n))return!1}return!0},i.exports=t})(ea,ea.exports);var mv=ea.exports;(function(i,t){var e=pv,n=mv;t=function(r){return r=e({},r),function(s){return n(s,r)}},i.exports=t})(Qo,Qo.exports);var gv=Qo.exports,na={exports:{}};(function(i,t){t=function(e){return e},i.exports=t})(na,na.exports);var _v=na.exports,ia={exports:{}},ra={exports:{}},sa={exports:{}};(function(i,t){var e=rc,n=Fi;t=function(o,a){if(n(o))return o;if(a&&e(a,o))return[o];var c=[];return o.replace(r,function(l,u,h,f){c.push(h?f.replace(s,"$1"):u||l)}),c};var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g;i.exports=t})(sa,sa.exports);var vv=sa.exports;(function(i,t){var e=nr,n=vv;t=function(r,s){s=n(s,r);var o;for(o=s.shift();!e(o);){if(r=r[o],r==null)return;o=s.shift()}return r},i.exports=t})(ra,ra.exports);var Tu=ra.exports;(function(i,t){var e=Fi,n=Tu;t=function(s){return e(s)?function(o){return n(o,s)}:r(s)};function r(s){return function(o){return o==null?void 0:o[s]}}i.exports=t})(ia,ia.exports);var xv=ia.exports;(function(i,t){var e=Ii,n=Ni,r=Fi,s=Eu,o=gv,a=_v,c=xv;t=function(l,u,h){return l==null?a:e(l)?s(l,u,h):n(l)&&!r(l)?o(l):c(l)},i.exports=t})(jo,jo.exports);var Au=jo.exports;(function(i,t){var e=Au,n=Qr;t=function(r,s,o){var a=[];return s=e(s,o),n(r,function(c,l,u){s(c,l,u)&&a.push(c)}),a},i.exports=t})(Ko,Ko.exports);var Mv=Ko.exports;(function(i,t){var e=Mv;t=function(r,s){return s=s||n,e(r,function(o,a,c){for(var l=c.length;++a<l;)if(s(o,c[a]))return!1;return!0})};function n(r,s){return r===s}i.exports=t})(Jo,Jo.exports);var Sv=Jo.exports;(function(i,t){var e=$n,n=dv,r=Sv,s=Object.getOwnPropertyNames,o=Object.getOwnPropertySymbols;t=function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=c.prototype,u=l===void 0?!0:l,h=c.unenumerable,f=h===void 0?!1:h,d=c.symbol,g=d===void 0?!1:d,v=[];if((f||g)&&s){var m=e;f&&s&&(m=s);do v=v.concat(m(a)),g&&o&&(v=v.concat(o(a)));while(u&&(a=n(a))&&a!==Object.prototype);v=r(v)}else if(u)for(var p in a)v.push(p);else v=e(a);return v},i.exports=t})(qo,qo.exports);var bu=qo.exports;(function(i,t){var e=sc,n=bu;t=e(n),i.exports=t})(Fo,Fo.exports);var wu=Fo.exports,oa={exports:{}},aa={exports:{}};(function(i,t){var e=Au,n=$n,r=$r;t=function(s,o,a){o=e(o,a);for(var c=!r(s)&&n(s),l=(c||s).length,u=Array(l),h=0;h<l;h++){var f=c?c[h]:h;u[h]=o(s[f],f,s)}return u},i.exports=t})(aa,aa.exports);var yv=aa.exports,ca={exports:{}};(function(i,t){var e=jn;t=function(n){return e(n)==="[object String]"},i.exports=t})(ca,ca.exports);var oc=ca.exports;(function(i,t){var e=$r,n=yv,r=Fi,s=oc;t=function(o){return o?r(o)?o:e(o)&&!s(o)?n(o):[o]:[]},i.exports=t})(oa,oa.exports);var ac=oa.exports,la={exports:{}},ua={exports:{}};(function(i,t){var e=Ni;t=function(r){if(!e(r))return{};if(n)return n(r);function s(){}return s.prototype=r,new s};var n=Object.create;i.exports=t})(ua,ua.exports);var Ev=ua.exports;(function(i,t){var e=Ev;t=function(n,r){n.prototype=e(r.prototype)},i.exports=t})(la,la.exports);var Tv=la.exports,ha={exports:{}};(function(i,t){var e=Ii;t=typeof wx<"u"&&e(wx.openLocation),i.exports=t})(ha,ha.exports);var Av=ha.exports;(function(i,t){var e=wu,n=ac,r=Tv,s=Tu,o=Av;t=function(l,u){return c.extend(l,u)};function a(l,u,h){h=h||{};var f=u.className||s(u,"initialize.name")||"";delete u.className;var d=function(){var g=n(arguments);return this.initialize?this.initialize.apply(this,g)||this:this};if(!o)try{d=new Function("toArr","return function "+f+"(){var args = toArr(arguments);return this.initialize ? this.initialize.apply(this, args) || this : this;};")(n)}catch{}return r(d,l),d.prototype.constructor=d,d.extend=function(g,v){return a(d,g,v)},d.inherits=function(g){r(d,g)},d.methods=function(g){return e(d.prototype,g),d},d.statics=function(g){return e(d,g),d},d.methods(u).statics(h),d}var c=t.Base=a(Object,{className:"Base",callSuper:function(l,u,h){var f=l.prototype[u];return f.apply(this,h)},toString:function(){return this.constructor.name}});i.exports=t})(No,No.exports);var bv=No.exports,fa={exports:{}};(function(i,t){t=function(e,n,r){var s=e.length;n==null?n=0:n<0?n=Math.max(s+n,0):n=Math.min(n,s),r==null?r=s:r<0?r=Math.max(s+r,0):r=Math.min(r,s);for(var o=[];n<r;)o.push(e[n++]);return o},i.exports=t})(fa,fa.exports);var wv=fa.exports,da={exports:{}},pa={exports:{}},ma={exports:{}};(function(i,t){t=function(e,n){return n=n==null?e.length-1:+n,function(){var r=Math.max(arguments.length-n,0),s=new Array(r),o;for(o=0;o<r;o++)s[o]=arguments[o+n];switch(n){case 0:return e.call(this,s);case 1:return e.call(this,arguments[0],s);case 2:return e.call(this,arguments[0],arguments[1],s)}var a=new Array(n+1);for(o=0;o<n;o++)a[o]=arguments[o];return a[n]=s,e.apply(this,a)}},i.exports=t})(ma,ma.exports);var Rv=ma.exports;(function(i,t){var e=Rv,n=ac;t=e(function(r,s){return function(){var o=[];return o=o.concat(s),o=o.concat(n(arguments)),r.apply(this,o)}}),i.exports=t})(pa,pa.exports);var Cv=pa.exports,ga={exports:{}};(function(i,t){t=function(e,n){var r;return function(){return--e>0&&(r=n.apply(this,arguments)),e<=1&&(n=null),r}},i.exports=t})(ga,ga.exports);var Pv=ga.exports;(function(i,t){var e=Cv,n=Pv;t=e(n,2),i.exports=t})(da,da.exports);var Lv=da.exports,_a={exports:{}};(function(i,t){var e=Ni,n=Fi,r=wu;t=function(s){return e(s)?n(s)?s.slice():r({},s):s},i.exports=t})(_a,_a.exports);var Dv=_a.exports;(function(i,t){var e=bv,n=rc,r=Qr,s=wv,o=Lv,a=Dv;t=e({initialize:function(){this._events=this._events||{}},on:function(c,l){return this._events[c]=this._events[c]||[],this._events[c].push(l),this},off:function(c,l){var u=this._events;if(n(u,c)){var h=u[c].indexOf(l);return h>-1&&u[c].splice(h,1),this}},once:function(c,l){return this.on(c,o(l)),this},emit:function(c){var l=this;if(n(this._events,c)){var u=s(arguments,1),h=a(this._events[c]);return r(h,function(f){return f.apply(l,u)},this),this}},removeAllListeners:function(c){return c?delete this._events[c]:this._events={},this}},{mixin:function(c){r(["on","off","once","emit","removeAllListeners"],function(l){c[l]=t.prototype[l]}),c._events=c._events||{}}}),i.exports=t})(Io,Io.exports);var Uv=Io.exports;(function(i,t){var e=Uv,n=oc,r=Ni,s=Qr,o=ac;t=e.extend({initialize:function(c){this.callSuper(e,"initialize",arguments),this._data=c||{},this.save(this._data)},set:function(a,c){var l;n(a)?(l={},l[a]=c):r(a)&&(l=a);var u=this;s(l,function(h,f){var d=u._data[f];u._data[f]=h,u.emit("change",f,h,d)}),this.save(this._data)},get:function(a){var c=this._data;if(n(a))return c[a];var l={};return s(a,function(u){l[u]=c[u]}),l},remove:function(a){a=o(a);var c=this._data;s(a,function(l){delete c[l]}),this.save(c)},clear:function(){this._data={},this.save(this._data)},each:function(a){s(this._data,a)},save:function(a){this._data=a}}),i.exports=t})(Uo,Uo.exports);var Iv=Uo.exports,va={exports:{}},xa={exports:{}};(function(i,t){var e=$n;t={getItem:function(c){return(r[c]?n[c]:this[c])||null},setItem:function(c,l){r[c]?n[c]=l:this[c]=l},removeItem:function(c){r[c]?delete n[c]:delete this[c]},key:function(c){var l=s();return c>=0&&c<l.length?l[c]:null},clear:function(){for(var c=o(),l=0,u;u=c[l];l++)delete this[u];c=a();for(var h=0,f;f=c[h];h++)delete n[f]}},Object.defineProperty(t,"length",{enumerable:!1,configurable:!0,get:function(){return s().length}});var n={},r={getItem:1,setItem:1,removeItem:1,key:1,clear:1,length:1};function s(){return o().concat(a())}function o(){return e(t).filter(function(c){return!r[c]})}function a(){return e(n)}i.exports=t})(xa,xa.exports);var Nv=xa.exports;(function(i,t){var e=Nv;t=function(n){n=n||"local";var r;switch(n){case"local":r=window.localStorage;break;case"session":r=window.sessionStorage;break}try{var s="test-localStorage-"+Date.now();r.setItem(s,s);var o=r.getItem(s);if(r.removeItem(s),o!==s)throw new Error}catch{return e}return r},i.exports=t})(va,va.exports);var Fv=va.exports,Ma={exports:{}},Sa={exports:{}};(function(i,t){var e=jn;t=function(n){return e(n)==="[object Arguments]"},i.exports=t})(Sa,Sa.exports);var Ov=Sa.exports;(function(i,t){var e=$r,n=Fi,r=oc,s=Ov,o=$n;t=function(a){return a==null?!0:e(a)&&(n(a)||r(a)||s(a))?a.length===0:o(a).length===0},i.exports=t})(Ma,Ma.exports);var Bv=Ma.exports,ya={exports:{}},Ea={exports:{}},Ta={exports:{}};(function(i,t){var e=yu;t=function(n){return e(n)&&n!==+n},i.exports=t})(Ta,Ta.exports);var zv=Ta.exports,Aa={exports:{}},ba={exports:{}};(function(i,t){t=function(e){return e==null?"":e.toString()},i.exports=t})(ba,ba.exports);var Ru=ba.exports;(function(i,t){var e=Ru;t=function(n){return e(n).toLocaleLowerCase()},i.exports=t})(Aa,Aa.exports);var Hv=Aa.exports,wa={exports:{}};(function(i,t){var e=Ii;t=function(n){return n==null?!1:n._isBuffer?!0:n.constructor&&e(n.constructor.isBuffer)&&n.constructor.isBuffer(n)},i.exports=t})(wa,wa.exports);var kv=wa.exports;(function(i,t){var e=jn,n=zv,r=Hv,s=kv;t=function(a){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,l;return a===null&&(l="Null"),a===void 0&&(l="Undefined"),n(a)&&(l="NaN"),s(a)&&(l="Buffer"),l||(l=e(a).match(o),l&&(l=l[1])),l?c?r(l):l:""};var o=/^\[object\s+(.*?)]$/;i.exports=t})(Ea,Ea.exports);var Gv=Ea.exports,Ra={exports:{}};(function(i,t){t=function(e){return e.length<1?e:e[0].toUpperCase()+e.slice(1)},i.exports=t})(Ra,Ra.exports);var Vv=Ra.exports,Ca={exports:{}};(function(i,t){var e=jn;t=function(n){return e(n)==="[object RegExp]"},i.exports=t})(Ca,Ca.exports);var Wv=Ca.exports;(function(i,t){var e=Gv,n=Vv,r=Ru,s=nr,o=Ii,a=Wv;t=function(l,u){return JSON.stringify(l,c(),u)};function c(){var l=[],u=[];return function(h,f){if(l.length>0){var d=l.indexOf(this);d>-1?(l.splice(d+1),u.splice(d,1/0,h)):(l.push(this),u.push(h));var g=l.indexOf(f);g>-1&&(l[0]===f?f="[Circular ~]":f="[Circular ~."+u.slice(0,g).join(".")+"]")}else l.push(f);return a(f)||o(f)?f="["+n(e(f))+" "+r(f)+"]":s(f)&&(f=null),f}}i.exports=t})(ya,ya.exports);var Xv=ya.exports,Pa={exports:{}};(function(i,t){var e=sc,n=bu;t=e(n,!0),i.exports=t})(Pa,Pa.exports);var qv=Pa.exports;(function(i,t){var e=Iv,n=Fv,r=Bv,s=Xv,o=qv,a=Ni,c=n("local");t=e.extend({initialize:function(u,h){this._name=u,h=h||{};var f=c.getItem(u);try{f=JSON.parse(f)}catch{f={}}a(f)||(f={}),h=o(f,h),this.callSuper(e,"initialize",[h])},save:function(l){if(r(l))return c.removeItem(this._name);c.setItem(this._name,s(l))}}),i.exports=t})(Do,Do.exports);var Yv=Do.exports;const Zv=Rl(Yv),Jv="tinker-gomoku",ts=new Zv(Jv);function Kv(i){return i==="pvp"||i==="pve"}function jv(i){return i==="easy"||i==="normal"||i==="hard"}function $v(){const i=ts.get("mode");return Kv(i)?i:"pvp"}function Qv(i){ts.set("mode",i)}function t0(){const i=ts.get("difficulty");return jv(i)?i:"normal"}function e0(i){ts.set("difficulty",i)}const Cu={en:{mode:"MODE",local:"LOCAL 2P",computer:"VS CPU",difficulty:"DIFFICULTY",easy:"EASY",normal:"NORMAL",hard:"HARD",start:"START MATCH",playAgain:"PLAY AGAIN",changeMode:"CHANGE MODE",sound:"Sound",soundOff:"Sound off",menu:"Menu",black:"Black to move",white:"White to move",cpuThinking:"Computer is thinking",yourMove:"Your move · Black",blackWins:"Black wins",whiteWins:"White wins",draw:"A quiet draw",full:"The board is full. No line prevailed."},"zh-CN":{mode:"模式",local:"本地双人",computer:"电脑对战",difficulty:"难度",easy:"简单",normal:"普通",hard:"困难",start:"开始对局",playAgain:"再来一局",changeMode:"更换模式",sound:"声音",soundOff:"声音已关",menu:"菜单",black:"黑棋回合",white:"白棋回合",cpuThinking:"电脑思考中",yourMove:"你的回合 · 黑棋",blackWins:"黑棋获胜",whiteWins:"白棋获胜",draw:"和棋",full:"棋盘已满,双方未能连成五子。"}};async function n0(){if(typeof tinker<"u")try{return await tinker.getLanguage()==="zh-CN"?"zh-CN":"en"}catch{}return navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en"}function i0(){return{menu:document.getElementById("menu"),result:document.getElementById("result"),turnPill:document.getElementById("turnPill"),turnStone:document.getElementById("turnStone"),turnText:document.getElementById("turnText"),resultTitle:document.getElementById("resultTitle"),resultText:document.getElementById("resultText"),soundButton:document.querySelector("#soundButton"),menuButton:document.querySelector("#menuButton"),difficultySetting:document.getElementById("difficultySetting"),startButton:document.querySelector("#startButton"),againButton:document.querySelector("#againButton"),resultMenuButton:document.querySelector("#resultMenuButton")}}function r0(i,t){i.menu.classList.toggle("hidden",!t),i.result.classList.add("hidden")}function cc(i,t){document.querySelectorAll("[data-mode]").forEach(e=>{e.classList.toggle("selected",e.dataset.mode===t)}),i.difficultySetting.classList.toggle("disabled",t!=="pve")}function Pu(i){document.querySelectorAll("[data-difficulty]").forEach(t=>{t.classList.toggle("selected",t.dataset.difficulty===i)})}function Lu(i,t,e){const n=t.phase==="thinking";let r=t.turn===Ke?e.black:e.white;t.mode==="pve"&&(r=n?e.cpuThinking:t.turn===Ke?e.yourMove:e.cpuThinking),i.turnText.textContent=r,i.turnStone.className=`turn-stone ${t.turn===Ke?"black":"white"}`,i.turnPill.classList.toggle("thinking",n)}function s0(i,t,e,n){const r=Cu[e];document.documentElement.lang=e,document.querySelectorAll("[data-i18n]").forEach(s=>{const o=s.dataset.i18n;r[o]&&(s.textContent=r[o])}),i.soundButton.setAttribute("aria-label",t.sound?r.sound:r.soundOff),i.soundButton.setAttribute("aria-pressed",String(t.sound)),i.soundButton.classList.toggle("muted",!t.sound),i.menuButton.textContent=r.menu,n(r)}const me=hv(),Ei=new qu,Re=i0(),Nt=Ku($v(),t0());let lc="en";const Du=()=>Cu[lc];let Zi,Ji,xi=0;function Uu(){Zi!==void 0&&(window.clearTimeout(Zi),Zi=void 0),Ji!==void 0&&(window.clearTimeout(Ji),Ji=void 0)}const Iu=()=>s0(Re,Nt,lc,i=>Lu(Re,Nt,i)),es=()=>Lu(Re,Nt,Du()),uc=i=>r0(Re,i);function ns(i,t){Nt.cursor.row=Hn(i,0,ge-1),Nt.cursor.column=Hn(t,0,ge-1);const e=zn(Nt.cursor.row,Nt.cursor.column);me.cursor.position.x=e.x,me.cursor.position.z=e.z}function o0(){Uu(),xi++,Nt.board=Da(),Nt.turn=Ke,Nt.phase="play",ns(7,7),me.clearStones(),uc(!1),es(),Ei.unlock()}function a0(){Uu(),xi++,Nt.phase="menu",Nt.board=Da(),me.clearStones(),uc(!0),es()}function La(i){const t=Du();Nt.phase="over",me.cursor.visible=!1,Re.result.classList.remove("hidden"),i===0?(Re.resultText.hidden=!1,Re.resultTitle.textContent=t.draw,Re.resultText.textContent=t.full):(Re.resultText.hidden=!0,Re.resultTitle.textContent=i===Ke?t.blackWins:t.whiteWins),es()}function Nu(i,t){if(Nt.phase!=="play"||Nt.board[yn(i,t)]!==qe)return;const e=Nt.turn;Nt.board[yn(i,t)]=e,me.addStone(e,i,t,!0);const n=zn(i,t);me.lastMark.position.set(n.x,me.cursor.position.y+.04,n.z),me.lastMark.visible=!0,Ei.unlock(),Ei.play();const r=Zu(Nt.board,i,t);if(r){me.updateWinLine(r),Nt.phase="over";const s=xi;Ji=window.setTimeout(()=>{Ji=void 0,Nt.phase==="over"&&xi===s&&La(e)},2e3);return}if(Yu(Nt.board)){La(0);return}if(Nt.turn=Ua(e),Nt.mode==="pve"&&Nt.turn!==Ke){Nt.phase="thinking";const s=xi;Zi=window.setTimeout(()=>{Zi=void 0,xi===s&&c0()},380)}es()}function c0(){if(Nt.phase!=="thinking")return;const i=Ju(Nt.board,Cl,Nt.difficulty);if(!i){La(0);return}ns(i.row,i.column),Nt.phase="play",Nu(i.row,i.column)}function l0(i,t){Nt.phase!=="play"&&Nt.phase!=="thinking"||ns(Nt.cursor.row+i,Nt.cursor.column+t)}const u0=ju(me,Re,{getPhase:()=>Nt.phase,getCursor:()=>Nt.cursor,setCursor:ns,moveCursor:l0,placeStone:(i,t)=>Nu(i,t),startMatch:o0,openMenu:a0,setMode:i=>{Nt.mode=i,Qv(i),cc(Re,i)},setDifficulty:i=>{Nt.difficulty=i,e0(i),Pu(i)},toggleSound:()=>{Nt.sound=!Nt.sound,Ei.setEnabled(Nt.sound),Ei.unlock(),Iu()},unlockAudio:()=>Ei.unlock()});function Fu(i){requestAnimationFrame(Fu),u0.pollGamepad();const t=Nt.phase==="play"||Nt.phase==="thinking";me.cursor.visible=t,fv(me,i),me.renderer.render(me.scene,me.camera)}window.addEventListener("resize",me.resize);n0().then(i=>{lc=i,cc(Re,Nt.mode),Iu()});uc(!0);cc(Re,Nt.mode);Pu(Nt.difficulty);me.cursor.visible=!1;requestAnimationFrame(Fu);