(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(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"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function ew(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var tw={exports:{}},Pp={},nw={exports:{}},Tt={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var of=Symbol.for("react.element"),F2=Symbol.for("react.portal"),z2=Symbol.for("react.fragment"),B2=Symbol.for("react.strict_mode"),k2=Symbol.for("react.profiler"),H2=Symbol.for("react.provider"),V2=Symbol.for("react.context"),G2=Symbol.for("react.forward_ref"),W2=Symbol.for("react.suspense"),X2=Symbol.for("react.memo"),Y2=Symbol.for("react.lazy"),ZS=Symbol.iterator;function j2(n){return n===null||typeof n!="object"?null:(n=ZS&&n[ZS]||n["@@iterator"],typeof n=="function"?n:null)}var iw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},rw=Object.assign,sw={};function $l(n,e,t){this.props=n,this.context=e,this.refs=sw,this.updater=t||iw}$l.prototype.isReactComponent={};$l.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,e,"setState")};$l.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function ow(){}ow.prototype=$l.prototype;function Uy(n,e,t){this.props=n,this.context=e,this.refs=sw,this.updater=t||iw}var Ny=Uy.prototype=new ow;Ny.constructor=Uy;rw(Ny,$l.prototype);Ny.isPureReactComponent=!0;var KS=Array.isArray,aw=Object.prototype.hasOwnProperty,Dy={current:null},lw={key:!0,ref:!0,__self:!0,__source:!0};function uw(n,e,t){var i,r={},s=null,o=null;if(e!=null)for(i in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)aw.call(e,i)&&!lw.hasOwnProperty(i)&&(r[i]=e[i]);var a=arguments.length-2;if(a===1)r.children=t;else if(1>>1,se=z[J];if(0>>1;Jr(Se,V))Cer(Te,Se)?(z[J]=Te,z[Ce]=V,J=Ce):(z[J]=Se,z[ue]=V,J=ue);else if(Cer(Te,V))z[J]=Te,z[Ce]=V,J=Ce;else break e}}return G}function r(z,G){var V=z.sortIndex-G.sortIndex;return V!==0?V:z.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var c=[],f=[],h=1,d=null,m=3,v=!1,_=!1,E=!1,M=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(z){for(var G=t(f);G!==null;){if(G.callback===null)i(f);else if(G.startTime<=z)i(f),G.sortIndex=G.expirationTime,e(c,G);else break;G=t(f)}}function T(z){if(E=!1,S(z),!_)if(t(c)!==null)_=!0,$(L);else{var G=t(f);G!==null&&ce(T,G.startTime-z)}}function L(z,G){_=!1,E&&(E=!1,g(D),D=-1),v=!0;var V=m;try{for(S(G),d=t(c);d!==null&&(!(d.expirationTime>G)||z&&!B());){var J=d.callback;if(typeof J=="function"){d.callback=null,m=d.priorityLevel;var se=J(d.expirationTime<=G);G=n.unstable_now(),typeof se=="function"?d.callback=se:d===t(c)&&i(c),S(G)}else i(c);d=t(c)}if(d!==null)var K=!0;else{var ue=t(f);ue!==null&&ce(T,ue.startTime-G),K=!1}return K}finally{d=null,m=V,v=!1}}var R=!1,P=null,D=-1,C=5,b=-1;function B(){return!(n.unstable_now()-bz||125J?(z.sortIndex=V,e(f,z),t(c)===null&&z===t(f)&&(E?(g(D),D=-1):E=!0,ce(T,V-J))):(z.sortIndex=se,e(c,z),_||v||(_=!0,$(L))),z},n.unstable_shouldYield=B,n.unstable_wrapCallback=function(z){var G=m;return function(){var V=m;m=G;try{return z.apply(this,arguments)}finally{m=V}}}})(pw);dw.exports=pw;var rb=dw.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var sb=we,Qi=rb;function ye(n){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+n,t=1;t"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Zv=Object.prototype.hasOwnProperty,ob=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,JS={},$S={};function ab(n){return Zv.call($S,n)?!0:Zv.call(JS,n)?!1:ob.test(n)?$S[n]=!0:(JS[n]=!0,!1)}function lb(n,e,t,i){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return i?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function ub(n,e,t,i){if(e===null||typeof e>"u"||lb(n,e,t,i))return!0;if(i)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Ei(n,e,t,i,r,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Qn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){Qn[n]=new Ei(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];Qn[e]=new Ei(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){Qn[n]=new Ei(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){Qn[n]=new Ei(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){Qn[n]=new Ei(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){Qn[n]=new Ei(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){Qn[n]=new Ei(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){Qn[n]=new Ei(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){Qn[n]=new Ei(n,5,!1,n.toLowerCase(),null,!1,!1)});var Fy=/[\-:]([a-z])/g;function zy(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(Fy,zy);Qn[e]=new Ei(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(Fy,zy);Qn[e]=new Ei(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(Fy,zy);Qn[e]=new Ei(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){Qn[n]=new Ei(n,1,!1,n.toLowerCase(),null,!1,!1)});Qn.xlinkHref=new Ei("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){Qn[n]=new Ei(n,1,!1,n.toLowerCase(),null,!0,!0)});function By(n,e,t,i){var r=Qn.hasOwnProperty(e)?Qn[e]:null;(r!==null?r.type!==0:i||!(2a||r[o]!==s[a]){var c=` `+r[o].replace(" at new "," at ");return n.displayName&&c.includes("")&&(c=c.replace("",n.displayName)),c}while(1<=o&&0<=a);break}}}finally{Lg=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?$u(n):""}function cb(n){switch(n.tag){case 5:return $u(n.type);case 16:return $u("Lazy");case 13:return $u("Suspense");case 19:return $u("SuspenseList");case 0:case 2:case 15:return n=Ig(n.type,!1),n;case 11:return n=Ig(n.type.render,!1),n;case 1:return n=Ig(n.type,!0),n;default:return""}}function $v(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case gl:return"Fragment";case ml:return"Portal";case Kv:return"Profiler";case ky:return"StrictMode";case Qv:return"Suspense";case Jv:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case vw:return(n.displayName||"Context")+".Consumer";case gw:return(n._context.displayName||"Context")+".Provider";case Hy:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Vy:return e=n.displayName||null,e!==null?e:$v(n.type)||"Memo";case Zs:e=n._payload,n=n._init;try{return $v(n(e))}catch{}}return null}function fb(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return $v(e);case 8:return e===ky?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function mo(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function _w(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function hb(n){var e=_w(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),i=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var r=t.get,s=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return r.call(this)},set:function(o){i=""+o,s.call(this,o)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return i},setValue:function(o){i=""+o},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function Sh(n){n._valueTracker||(n._valueTracker=hb(n))}function xw(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),i="";return n&&(i=_w(n)?n.checked?"true":"false":n.value),n=i,n!==t?(e.setValue(n),!0):!1}function Jd(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function e0(n,e){var t=e.checked;return ln({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function tM(n,e){var t=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;t=mo(e.value!=null?e.value:t),n._wrapperState={initialChecked:i,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Sw(n,e){e=e.checked,e!=null&&By(n,"checked",e,!1)}function t0(n,e){Sw(n,e);var t=mo(e.value),i=e.type;if(t!=null)i==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(i==="submit"||i==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?n0(n,e.type,t):e.hasOwnProperty("defaultValue")&&n0(n,e.type,mo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function nM(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var i=e.type;if(!(i!=="submit"&&i!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function n0(n,e,t){(e!=="number"||Jd(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var ec=Array.isArray;function Ul(n,e,t,i){if(n=n.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=Mh.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function Sc(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var rc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},db=["Webkit","ms","Moz","O"];Object.keys(rc).forEach(function(n){db.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),rc[e]=rc[n]})});function Tw(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||rc.hasOwnProperty(n)&&rc[n]?(""+e).trim():e+"px"}function Aw(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var i=t.indexOf("--")===0,r=Tw(t,e[t],i);t==="float"&&(t="cssFloat"),i?n.setProperty(t,r):n[t]=r}}var pb=ln({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function s0(n,e){if(e){if(pb[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(ye(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(ye(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(ye(61))}if(e.style!=null&&typeof e.style!="object")throw Error(ye(62))}}function o0(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var a0=null;function Gy(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var l0=null,Nl=null,Dl=null;function sM(n){if(n=uf(n)){if(typeof l0!="function")throw Error(ye(280));var e=n.stateNode;e&&(e=Dp(e),l0(n.stateNode,n.type,e))}}function Cw(n){Nl?Dl?Dl.push(n):Dl=[n]:Nl=n}function Rw(){if(Nl){var n=Nl,e=Dl;if(Dl=Nl=null,sM(n),e)for(n=0;n>>=0,n===0?32:31-(Tb(n)/Ab|0)|0}var Eh=64,wh=4194304;function tc(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function np(n,e){var t=n.pendingLanes;if(t===0)return 0;var i=0,r=n.suspendedLanes,s=n.pingedLanes,o=t&268435455;if(o!==0){var a=o&~r;a!==0?i=tc(a):(s&=o,s!==0&&(i=tc(s)))}else o=t&~r,o!==0?i=tc(o):s!==0&&(i=tc(s));if(i===0)return 0;if(e!==0&&e!==i&&!(e&r)&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(i&4&&(i|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=i;0t;t++)e.push(n);return e}function af(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-Ur(e),n[e]=t}function Pb(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var i=n.eventTimes;for(n=n.expirationTimes;0=oc),pM=" ",mM=!1;function qw(n,e){switch(n){case"keyup":return rP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zw(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var vl=!1;function oP(n,e){switch(n){case"compositionend":return Zw(e);case"keypress":return e.which!==32?null:(mM=!0,pM);case"textInput":return n=e.data,n===pM&&mM?null:n;default:return null}}function aP(n,e){if(vl)return n==="compositionend"||!Qy&&qw(n,e)?(n=Yw(),Dd=qy=to=null,vl=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=i}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=_M(t)}}function $w(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?$w(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function eT(){for(var n=window,e=Jd();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=Jd(n.document)}return e}function Jy(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function gP(n){var e=eT(),t=n.focusedElem,i=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&$w(t.ownerDocument.documentElement,t)){if(i!==null&&Jy(t)){if(e=i.start,n=i.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var r=t.textContent.length,s=Math.min(i.start,r);i=i.end===void 0?s:Math.min(i.end,r),!n.extend&&s>i&&(r=i,i=s,s=r),r=xM(t,s);var o=xM(t,i);r&&o&&(n.rangeCount!==1||n.anchorNode!==r.node||n.anchorOffset!==r.offset||n.focusNode!==o.node||n.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),n.removeAllRanges(),s>i?(n.addRange(e),n.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,yl=null,p0=null,lc=null,m0=!1;function SM(n,e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;m0||yl==null||yl!==Jd(i)||(i=yl,"selectionStart"in i&&Jy(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),lc&&Cc(lc,i)||(lc=i,i=sp(p0,"onSelect"),0Sl||(n.current=S0[Sl],S0[Sl]=null,Sl--)}function Yt(n,e){Sl++,S0[Sl]=n.current,n.current=e}var go={},hi=Mo(go),Ni=Mo(!1),da=go;function Hl(n,e){var t=n.type.contextTypes;if(!t)return go;var i=n.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===e)return i.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in t)r[s]=e[s];return i&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=r),r}function Di(n){return n=n.childContextTypes,n!=null}function ap(){Qt(Ni),Qt(hi)}function RM(n,e,t){if(hi.current!==go)throw Error(ye(168));Yt(hi,e),Yt(Ni,t)}function uT(n,e,t){var i=n.stateNode;if(e=e.childContextTypes,typeof i.getChildContext!="function")return t;i=i.getChildContext();for(var r in i)if(!(r in e))throw Error(ye(108,fb(n)||"Unknown",r));return ln({},t,i)}function lp(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||go,da=hi.current,Yt(hi,n),Yt(Ni,Ni.current),!0}function bM(n,e,t){var i=n.stateNode;if(!i)throw Error(ye(169));t?(n=uT(n,e,da),i.__reactInternalMemoizedMergedChildContext=n,Qt(Ni),Qt(hi),Yt(hi,n)):Qt(Ni),Yt(Ni,t)}var gs=null,Op=!1,Yg=!1;function cT(n){gs===null?gs=[n]:gs.push(n)}function RP(n){Op=!0,cT(n)}function Eo(){if(!Yg&&gs!==null){Yg=!0;var n=0,e=kt;try{var t=gs;for(kt=1;n>=o,r-=o,ys=1<<32-Ur(e)+r|t<D?(C=P,P=null):C=P.sibling;var b=m(g,P,S[D],T);if(b===null){P===null&&(P=C);break}n&&P&&b.alternate===null&&e(g,P),x=s(b,x,D),R===null?L=b:R.sibling=b,R=b,P=C}if(D===S.length)return t(g,P),en&&qo(g,D),L;if(P===null){for(;DD?(C=P,P=null):C=P.sibling;var B=m(g,P,b.value,T);if(B===null){P===null&&(P=C);break}n&&P&&B.alternate===null&&e(g,P),x=s(B,x,D),R===null?L=B:R.sibling=B,R=B,P=C}if(b.done)return t(g,P),en&&qo(g,D),L;if(P===null){for(;!b.done;D++,b=S.next())b=d(g,b.value,T),b!==null&&(x=s(b,x,D),R===null?L=b:R.sibling=b,R=b);return en&&qo(g,D),L}for(P=i(g,P);!b.done;D++,b=S.next())b=v(P,g,D,b.value,T),b!==null&&(n&&b.alternate!==null&&P.delete(b.key===null?D:b.key),x=s(b,x,D),R===null?L=b:R.sibling=b,R=b);return n&&P.forEach(function(j){return e(g,j)}),en&&qo(g,D),L}function M(g,x,S,T){if(typeof S=="object"&&S!==null&&S.type===gl&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case xh:e:{for(var L=S.key,R=x;R!==null;){if(R.key===L){if(L=S.type,L===gl){if(R.tag===7){t(g,R.sibling),x=r(R,S.props.children),x.return=g,g=x;break e}}else if(R.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===Zs&&IM(L)===R.type){t(g,R.sibling),x=r(R,S.props),x.ref=Du(g,R,S),x.return=g,g=x;break e}t(g,R);break}else e(g,R);R=R.sibling}S.type===gl?(x=la(S.props.children,g.mode,T,S.key),x.return=g,g=x):(T=Gd(S.type,S.key,S.props,null,g.mode,T),T.ref=Du(g,x,S),T.return=g,g=T)}return o(g);case ml:e:{for(R=S.key;x!==null;){if(x.key===R)if(x.tag===4&&x.stateNode.containerInfo===S.containerInfo&&x.stateNode.implementation===S.implementation){t(g,x.sibling),x=r(x,S.children||[]),x.return=g,g=x;break e}else{t(g,x);break}else e(g,x);x=x.sibling}x=ev(S,g.mode,T),x.return=g,g=x}return o(g);case Zs:return R=S._init,M(g,x,R(S._payload),T)}if(ec(S))return _(g,x,S,T);if(Pu(S))return E(g,x,S,T);Lh(g,S)}return typeof S=="string"&&S!==""||typeof S=="number"?(S=""+S,x!==null&&x.tag===6?(t(g,x.sibling),x=r(x,S),x.return=g,g=x):(t(g,x),x=$g(S,g.mode,T),x.return=g,g=x),o(g)):t(g,x)}return M}var Gl=pT(!0),mT=pT(!1),fp=Mo(null),hp=null,wl=null,n_=null;function i_(){n_=wl=hp=null}function r_(n){var e=fp.current;Qt(fp),n._currentValue=e}function w0(n,e,t){for(;n!==null;){var i=n.alternate;if((n.childLanes&e)!==e?(n.childLanes|=e,i!==null&&(i.childLanes|=e)):i!==null&&(i.childLanes&e)!==e&&(i.childLanes|=e),n===t)break;n=n.return}}function Fl(n,e){hp=n,n_=wl=null,n=n.dependencies,n!==null&&n.firstContext!==null&&(n.lanes&e&&(Ui=!0),n.firstContext=null)}function vr(n){var e=n._currentValue;if(n_!==n)if(n={context:n,memoizedValue:e,next:null},wl===null){if(hp===null)throw Error(ye(308));wl=n,hp.dependencies={lanes:0,firstContext:n}}else wl=wl.next=n;return e}var ta=null;function s_(n){ta===null?ta=[n]:ta.push(n)}function gT(n,e,t,i){var r=e.interleaved;return r===null?(t.next=t,s_(e)):(t.next=r.next,r.next=t),e.interleaved=t,As(n,i)}function As(n,e){n.lanes|=e;var t=n.alternate;for(t!==null&&(t.lanes|=e),t=n,n=n.return;n!==null;)n.childLanes|=e,t=n.alternate,t!==null&&(t.childLanes|=e),t=n,n=n.return;return t.tag===3?t.stateNode:null}var Ks=!1;function o_(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function vT(n,e){n=n.updateQueue,e.updateQueue===n&&(e.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function Ss(n,e){return{eventTime:n,lane:e,tag:0,payload:null,callback:null,next:null}}function ao(n,e,t){var i=n.updateQueue;if(i===null)return null;if(i=i.shared,bt&2){var r=i.pending;return r===null?e.next=e:(e.next=r.next,r.next=e),i.pending=e,As(n,t)}return r=i.interleaved,r===null?(e.next=e,s_(i)):(e.next=r.next,r.next=e),i.interleaved=e,As(n,t)}function Fd(n,e,t){if(e=e.updateQueue,e!==null&&(e=e.shared,(t&4194240)!==0)){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,Xy(n,t)}}function UM(n,e){var t=n.updateQueue,i=n.alternate;if(i!==null&&(i=i.updateQueue,t===i)){var r=null,s=null;if(t=t.firstBaseUpdate,t!==null){do{var o={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};s===null?r=s=o:s=s.next=o,t=t.next}while(t!==null);s===null?r=s=e:s=s.next=e}else r=s=e;t={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:i.shared,effects:i.effects},n.updateQueue=t;return}n=t.lastBaseUpdate,n===null?t.firstBaseUpdate=e:n.next=e,t.lastBaseUpdate=e}function dp(n,e,t,i){var r=n.updateQueue;Ks=!1;var s=r.firstBaseUpdate,o=r.lastBaseUpdate,a=r.shared.pending;if(a!==null){r.shared.pending=null;var c=a,f=c.next;c.next=null,o===null?s=f:o.next=f,o=c;var h=n.alternate;h!==null&&(h=h.updateQueue,a=h.lastBaseUpdate,a!==o&&(a===null?h.firstBaseUpdate=f:a.next=f,h.lastBaseUpdate=c))}if(s!==null){var d=r.baseState;o=0,h=f=c=null,a=s;do{var m=a.lane,v=a.eventTime;if((i&m)===m){h!==null&&(h=h.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var _=n,E=a;switch(m=e,v=t,E.tag){case 1:if(_=E.payload,typeof _=="function"){d=_.call(v,d,m);break e}d=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=E.payload,m=typeof _=="function"?_.call(v,d,m):_,m==null)break e;d=ln({},d,m);break e;case 2:Ks=!0}}a.callback!==null&&a.lane!==0&&(n.flags|=64,m=r.effects,m===null?r.effects=[a]:m.push(a))}else v={eventTime:v,lane:m,tag:a.tag,payload:a.payload,callback:a.callback,next:null},h===null?(f=h=v,c=d):h=h.next=v,o|=m;if(a=a.next,a===null){if(a=r.shared.pending,a===null)break;m=a,a=m.next,m.next=null,r.lastBaseUpdate=m,r.shared.pending=null}}while(!0);if(h===null&&(c=d),r.baseState=c,r.firstBaseUpdate=f,r.lastBaseUpdate=h,e=r.shared.interleaved,e!==null){r=e;do o|=r.lane,r=r.next;while(r!==e)}else s===null&&(r.shared.lanes=0);ga|=o,n.lanes=o,n.memoizedState=d}}function NM(n,e,t){if(n=e.effects,e.effects=null,n!==null)for(e=0;et?t:4,n(!0);var i=qg.transition;qg.transition={};try{n(!1),e()}finally{kt=t,qg.transition=i}}function NT(){return yr().memoizedState}function IP(n,e,t){var i=uo(n);if(t={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null},DT(n))OT(e,t);else if(t=gT(n,e,t,i),t!==null){var r=xi();Nr(t,n,i,r),FT(t,e,i)}}function UP(n,e,t){var i=uo(n),r={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null};if(DT(n))OT(e,r);else{var s=n.alternate;if(n.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,t);if(r.hasEagerState=!0,r.eagerState=a,Or(a,o)){var c=e.interleaved;c===null?(r.next=r,s_(e)):(r.next=c.next,c.next=r),e.interleaved=r;return}}catch{}finally{}t=gT(n,e,r,i),t!==null&&(r=xi(),Nr(t,n,i,r),FT(t,e,i))}}function DT(n){var e=n.alternate;return n===on||e!==null&&e===on}function OT(n,e){uc=mp=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function FT(n,e,t){if(t&4194240){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,Xy(n,t)}}var gp={readContext:vr,useCallback:ni,useContext:ni,useEffect:ni,useImperativeHandle:ni,useInsertionEffect:ni,useLayoutEffect:ni,useMemo:ni,useReducer:ni,useRef:ni,useState:ni,useDebugValue:ni,useDeferredValue:ni,useTransition:ni,useMutableSource:ni,useSyncExternalStore:ni,useId:ni,unstable_isNewReconciler:!1},NP={readContext:vr,useCallback:function(n,e){return Zr().memoizedState=[n,e===void 0?null:e],n},useContext:vr,useEffect:OM,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,Bd(4194308,4,bT.bind(null,e,n),t)},useLayoutEffect:function(n,e){return Bd(4194308,4,n,e)},useInsertionEffect:function(n,e){return Bd(4,2,n,e)},useMemo:function(n,e){var t=Zr();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var i=Zr();return e=t!==void 0?t(e):e,i.memoizedState=i.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},i.queue=n,n=n.dispatch=IP.bind(null,on,n),[i.memoizedState,n]},useRef:function(n){var e=Zr();return n={current:n},e.memoizedState=n},useState:DM,useDebugValue:p_,useDeferredValue:function(n){return Zr().memoizedState=n},useTransition:function(){var n=DM(!1),e=n[0];return n=LP.bind(null,n[1]),Zr().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var i=on,r=Zr();if(en){if(t===void 0)throw Error(ye(407));t=t()}else{if(t=e(),Vn===null)throw Error(ye(349));ma&30||ST(i,e,t)}r.memoizedState=t;var s={value:t,getSnapshot:e};return r.queue=s,OM(ET.bind(null,i,s,n),[n]),i.flags|=2048,Dc(9,MT.bind(null,i,s,t,e),void 0,null),t},useId:function(){var n=Zr(),e=Vn.identifierPrefix;if(en){var t=_s,i=ys;t=(i&~(1<<32-Ur(i)-1)).toString(32)+t,e=":"+e+"R"+t,t=Uc++,0<\/script>",n=n.removeChild(n.firstChild)):typeof i.is=="string"?n=o.createElement(t,{is:i.is}):(n=o.createElement(t),t==="select"&&(o=n,i.multiple?o.multiple=!0:i.size&&(o.size=i.size))):n=o.createElementNS(n,t),n[Kr]=e,n[Pc]=i,jT(n,e,!1,!1),e.stateNode=n;e:{switch(o=o0(t,i),t){case"dialog":qt("cancel",n),qt("close",n),r=i;break;case"iframe":case"object":case"embed":qt("load",n),r=i;break;case"video":case"audio":for(r=0;rYl&&(e.flags|=128,i=!0,Ou(s,!1),e.lanes=4194304)}else{if(!i)if(n=pp(o),n!==null){if(e.flags|=128,i=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ou(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!en)return ii(e),null}else 2*yn()-s.renderingStartTime>Yl&&t!==1073741824&&(e.flags|=128,i=!0,Ou(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(t=s.last,t!==null?t.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=yn(),e.sibling=null,t=rn.current,Yt(rn,i?t&1|2:t&1),e):(ii(e),null);case 22:case 23:return x_(),i=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?ji&1073741824&&(ii(e),e.subtreeFlags&6&&(e.flags|=8192)):ii(e),null;case 24:return null;case 25:return null}throw Error(ye(156,e.tag))}function VP(n,e){switch(e_(e),e.tag){case 1:return Di(e.type)&&ap(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return Wl(),Qt(Ni),Qt(hi),u_(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return l_(e),null;case 13:if(Qt(rn),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(ye(340));Vl()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return Qt(rn),null;case 4:return Wl(),null;case 10:return r_(e.type._context),null;case 22:case 23:return x_(),null;case 24:return null;default:return null}}var Uh=!1,ai=!1,GP=typeof WeakSet=="function"?WeakSet:Set,Oe=null;function Tl(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(i){hn(n,e,i)}else t.current=null}function U0(n,e,t){try{t()}catch(i){hn(n,e,i)}}var jM=!1;function WP(n,e){if(g0=ip,n=eT(),Jy(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var i=t.getSelection&&t.getSelection();if(i&&i.rangeCount!==0){t=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var o=0,a=-1,c=-1,f=0,h=0,d=n,m=null;t:for(;;){for(var v;d!==t||r!==0&&d.nodeType!==3||(a=o+r),d!==s||i!==0&&d.nodeType!==3||(c=o+i),d.nodeType===3&&(o+=d.nodeValue.length),(v=d.firstChild)!==null;)m=d,d=v;for(;;){if(d===n)break t;if(m===t&&++f===r&&(a=o),m===s&&++h===i&&(c=o),(v=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=v}t=a===-1||c===-1?null:{start:a,end:c}}else t=null}t=t||{start:0,end:0}}else t=null;for(v0={focusedElem:n,selectionRange:t},ip=!1,Oe=e;Oe!==null;)if(e=Oe,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,Oe=n;else for(;Oe!==null;){e=Oe;try{var _=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var E=_.memoizedProps,M=_.memoizedState,g=e.stateNode,x=g.getSnapshotBeforeUpdate(e.elementType===e.type?E:Cr(e.type,E),M);g.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var S=e.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ye(163))}}catch(T){hn(e,e.return,T)}if(n=e.sibling,n!==null){n.return=e.return,Oe=n;break}Oe=e.return}return _=jM,jM=!1,_}function cc(n,e,t){var i=e.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var r=i=i.next;do{if((r.tag&n)===n){var s=r.destroy;r.destroy=void 0,s!==void 0&&U0(e,t,s)}r=r.next}while(r!==i)}}function Bp(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var i=t.create;t.destroy=i()}t=t.next}while(t!==e)}}function N0(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function KT(n){var e=n.alternate;e!==null&&(n.alternate=null,KT(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Kr],delete e[Pc],delete e[x0],delete e[AP],delete e[CP])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function QT(n){return n.tag===5||n.tag===3||n.tag===4}function qM(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||QT(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function D0(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=op));else if(i!==4&&(n=n.child,n!==null))for(D0(n,e,t),n=n.sibling;n!==null;)D0(n,e,t),n=n.sibling}function O0(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(i!==4&&(n=n.child,n!==null))for(O0(n,e,t),n=n.sibling;n!==null;)O0(n,e,t),n=n.sibling}var Zn=null,br=!1;function ks(n,e,t){for(t=t.child;t!==null;)JT(n,e,t),t=t.sibling}function JT(n,e,t){if(Jr&&typeof Jr.onCommitFiberUnmount=="function")try{Jr.onCommitFiberUnmount(Lp,t)}catch{}switch(t.tag){case 5:ai||Tl(t,e);case 6:var i=Zn,r=br;Zn=null,ks(n,e,t),Zn=i,br=r,Zn!==null&&(br?(n=Zn,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):Zn.removeChild(t.stateNode));break;case 18:Zn!==null&&(br?(n=Zn,t=t.stateNode,n.nodeType===8?Xg(n.parentNode,t):n.nodeType===1&&Xg(n,t),Tc(n)):Xg(Zn,t.stateNode));break;case 4:i=Zn,r=br,Zn=t.stateNode.containerInfo,br=!0,ks(n,e,t),Zn=i,br=r;break;case 0:case 11:case 14:case 15:if(!ai&&(i=t.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){r=i=i.next;do{var s=r,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&U0(t,e,o),r=r.next}while(r!==i)}ks(n,e,t);break;case 1:if(!ai&&(Tl(t,e),i=t.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=t.memoizedProps,i.state=t.memoizedState,i.componentWillUnmount()}catch(a){hn(t,e,a)}ks(n,e,t);break;case 21:ks(n,e,t);break;case 22:t.mode&1?(ai=(i=ai)||t.memoizedState!==null,ks(n,e,t),ai=i):ks(n,e,t);break;default:ks(n,e,t)}}function ZM(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new GP),e.forEach(function(i){var r=$P.bind(null,n,i);t.has(i)||(t.add(i),i.then(r,r))})}}function Er(n,e){var t=e.deletions;if(t!==null)for(var i=0;ir&&(r=o),i&=~s}if(i=r,i=yn()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*YP(i/1960))-i,10n?16:n,no===null)var i=!1;else{if(n=no,no=null,_p=0,bt&6)throw Error(ye(331));var r=bt;for(bt|=4,Oe=n.current;Oe!==null;){var s=Oe,o=s.child;if(Oe.flags&16){var a=s.deletions;if(a!==null){for(var c=0;cyn()-y_?aa(n,0):v_|=t),Oi(n,e)}function oA(n,e){e===0&&(n.mode&1?(e=wh,wh<<=1,!(wh&130023424)&&(wh=4194304)):e=1);var t=xi();n=As(n,e),n!==null&&(af(n,e,t),Oi(n,t))}function JP(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),oA(n,t)}function $P(n,e){var t=0;switch(n.tag){case 13:var i=n.stateNode,r=n.memoizedState;r!==null&&(t=r.retryLane);break;case 19:i=n.stateNode;break;default:throw Error(ye(314))}i!==null&&i.delete(e),oA(n,t)}var aA;aA=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Ni.current)Ui=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return Ui=!1,kP(n,e,t);Ui=!!(n.flags&131072)}else Ui=!1,en&&e.flags&1048576&&fT(e,cp,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;kd(n,e),n=e.pendingProps;var r=Hl(e,hi.current);Fl(e,t),r=f_(null,e,i,n,r,t);var s=h_();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Di(i)?(s=!0,lp(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,o_(e),r.updater=zp,e.stateNode=r,r._reactInternals=e,A0(e,i,n,t),e=b0(null,e,i,!0,s,t)):(e.tag=0,en&&s&&$y(e),vi(null,e,r,t),e=e.child),e;case 16:i=e.elementType;e:{switch(kd(n,e),n=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=tL(i),n=Cr(i,n),r){case 0:e=R0(null,e,i,n,t);break e;case 1:e=WM(null,e,i,n,t);break e;case 11:e=VM(null,e,i,n,t);break e;case 14:e=GM(null,e,i,Cr(i.type,n),t);break e}throw Error(ye(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Cr(i,r),R0(n,e,i,r,t);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Cr(i,r),WM(n,e,i,r,t);case 3:e:{if(WT(e),n===null)throw Error(ye(387));i=e.pendingProps,s=e.memoizedState,r=s.element,vT(n,e),dp(e,i,null,t);var o=e.memoizedState;if(i=o.element,s.isDehydrated)if(s={element:i,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){r=Xl(Error(ye(423)),e),e=XM(n,e,i,t,r);break e}else if(i!==r){r=Xl(Error(ye(424)),e),e=XM(n,e,i,t,r);break e}else for(qi=oo(e.stateNode.containerInfo.firstChild),Zi=e,en=!0,Pr=null,t=mT(e,null,i,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(Vl(),i===r){e=Cs(n,e,t);break e}vi(n,e,i,t)}e=e.child}return e;case 5:return yT(e),n===null&&E0(e),i=e.type,r=e.pendingProps,s=n!==null?n.memoizedProps:null,o=r.children,y0(i,r)?o=null:s!==null&&y0(i,s)&&(e.flags|=32),GT(n,e),vi(n,e,o,t),e.child;case 6:return n===null&&E0(e),null;case 13:return XT(n,e,t);case 4:return a_(e,e.stateNode.containerInfo),i=e.pendingProps,n===null?e.child=Gl(e,null,i,t):vi(n,e,i,t),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Cr(i,r),VM(n,e,i,r,t);case 7:return vi(n,e,e.pendingProps,t),e.child;case 8:return vi(n,e,e.pendingProps.children,t),e.child;case 12:return vi(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(i=e.type._context,r=e.pendingProps,s=e.memoizedProps,o=r.value,Yt(fp,i._currentValue),i._currentValue=o,s!==null)if(Or(s.value,o)){if(s.children===r.children&&!Ni.current){e=Cs(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var c=a.firstContext;c!==null;){if(c.context===i){if(s.tag===1){c=Ss(-1,t&-t),c.tag=2;var f=s.updateQueue;if(f!==null){f=f.shared;var h=f.pending;h===null?c.next=c:(c.next=h.next,h.next=c),f.pending=c}}s.lanes|=t,c=s.alternate,c!==null&&(c.lanes|=t),w0(s.return,t,e),a.lanes|=t;break}c=c.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(ye(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),w0(o,t,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}vi(n,e,r.children,t),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,Fl(e,t),r=vr(r),i=i(r),e.flags|=1,vi(n,e,i,t),e.child;case 14:return i=e.type,r=Cr(i,e.pendingProps),r=Cr(i.type,r),GM(n,e,i,r,t);case 15:return HT(n,e,e.type,e.pendingProps,t);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Cr(i,r),kd(n,e),e.tag=1,Di(i)?(n=!0,lp(e)):n=!1,Fl(e,t),zT(e,i,r),A0(e,i,r,t),b0(null,e,i,!0,n,t);case 19:return YT(n,e,t);case 22:return VT(n,e,t)}throw Error(ye(156,e.tag))};function lA(n,e){return Dw(n,e)}function eL(n,e,t,i){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function pr(n,e,t,i){return new eL(n,e,t,i)}function M_(n){return n=n.prototype,!(!n||!n.isReactComponent)}function tL(n){if(typeof n=="function")return M_(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Hy)return 11;if(n===Vy)return 14}return 2}function co(n,e){var t=n.alternate;return t===null?(t=pr(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function Gd(n,e,t,i,r,s){var o=2;if(i=n,typeof n=="function")M_(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case gl:return la(t.children,r,s,e);case ky:o=8,r|=8;break;case Kv:return n=pr(12,t,e,r|2),n.elementType=Kv,n.lanes=s,n;case Qv:return n=pr(13,t,e,r),n.elementType=Qv,n.lanes=s,n;case Jv:return n=pr(19,t,e,r),n.elementType=Jv,n.lanes=s,n;case yw:return Hp(t,r,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case gw:o=10;break e;case vw:o=9;break e;case Hy:o=11;break e;case Vy:o=14;break e;case Zs:o=16,i=null;break e}throw Error(ye(130,n==null?n:typeof n,""))}return e=pr(o,t,e,r),e.elementType=n,e.type=i,e.lanes=s,e}function la(n,e,t,i){return n=pr(7,n,i,e),n.lanes=t,n}function Hp(n,e,t,i){return n=pr(22,n,i,e),n.elementType=yw,n.lanes=t,n.stateNode={isHidden:!1},n}function $g(n,e,t){return n=pr(6,n,null,e),n.lanes=t,n}function ev(n,e,t){return e=pr(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function nL(n,e,t,i,r){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ng(0),this.expirationTimes=Ng(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ng(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function E_(n,e,t,i,r,s,o,a,c){return n=new nL(n,e,t,a,c),e===1?(e=1,s===!0&&(e|=8)):e=0,s=pr(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:i,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},o_(s),n}function iL(n,e,t){var i=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(hA)}catch(n){console.error(n)}}hA(),hw.exports=Ji;var lL=hw.exports,i1=lL;qv.createRoot=i1.createRoot,qv.hydrateRoot=i1.hydrateRoot;/** * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT */const nu="160",uL={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},cL={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dA=0,H0=1,pA=2,fL=3,mA=0,Yp=1,dc=2,Rr=3,ts=0,bn=1,yi=2,hL=2,ci=0,ua=1,Mp=2,V0=3,G0=4,gA=5,eo=100,vA=101,yA=102,W0=103,X0=104,_A=200,xA=201,SA=202,MA=203,Ep=204,wp=205,EA=206,wA=207,TA=208,AA=209,CA=210,RA=211,bA=212,PA=213,LA=214,IA=0,UA=1,NA=2,Fc=3,DA=4,OA=5,FA=6,zA=7,ff=0,BA=1,kA=2,Dr=0,HA=1,VA=2,GA=3,C_=4,WA=5,XA=6,Y0="attached",YA="detached",jp=300,Rs=301,vo=302,zc=303,Bc=304,iu=306,jl=1e3,li=1001,kc=1002,Xt=1003,Tp=1004,dL=1004,pc=1005,pL=1005,Kt=1006,R_=1007,mL=1007,yo=1008,gL=1008,Pn=1009,jA=1010,qA=1011,qp=1012,b_=1013,Qr=1014,mr=1015,ya=1016,P_=1017,L_=1018,Ms=1020,ZA=1021,Hn=1023,KA=1024,QA=1025,fo=1026,_o=1027,Zp=1028,I_=1029,U_=1030,N_=1031,D_=1033,Wd=33776,Xd=33777,Yd=33778,jd=33779,j0=35840,q0=35841,Z0=35842,K0=35843,O_=36196,Q0=37492,J0=37496,$0=37808,ey=37809,ty=37810,ny=37811,iy=37812,ry=37813,sy=37814,oy=37815,ay=37816,ly=37817,uy=37818,cy=37819,fy=37820,hy=37821,qd=36492,dy=36494,py=36495,JA=36283,my=36284,gy=36285,vy=36286,$A=2200,eC=2201,tC=2202,Hc=2300,Vc=2301,Zd=2302,ia=2400,ra=2401,Gc=2402,Kp=2500,F_=2501,vL=0,yL=1,_L=2,z_=3e3,ho=3001,wo=3200,nC=3201,To=0,iC=1,_i="",At="srgb",_r="srgb-linear",Qp="display-p3",hf="display-p3-linear",Wc="linear",Wt="srgb",Xc="rec709",Yc="p3",xL=0,Ko=7680,SL=7681,ML=7682,EL=7683,wL=34055,TL=34056,AL=5386,CL=512,RL=513,bL=514,PL=515,LL=516,IL=517,UL=518,yy=519,rC=512,sC=513,oC=514,B_=515,aC=516,lC=517,uC=518,cC=519,jc=35044,NL=35048,DL=35040,OL=35045,FL=35049,zL=35041,BL=35046,kL=35050,HL=35042,VL="100",_y="300 es",Ap=1035,Ir=2e3,ql=2001;class xr{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,o=r.length;s>8&255]+ri[n>>16&255]+ri[n>>24&255]+"-"+ri[e&255]+ri[e>>8&255]+"-"+ri[e>>16&15|64]+ri[e>>24&255]+"-"+ri[t&63|128]+ri[t>>8&255]+"-"+ri[t>>16&255]+ri[t>>24&255]+ri[i&255]+ri[i>>8&255]+ri[i>>16&255]+ri[i>>24&255]).toLowerCase()}function dn(n,e,t){return Math.max(e,Math.min(t,n))}function k_(n,e){return(n%e+e)%e}function GL(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function WL(n,e,t){return n!==e?(t-n)/(e-n):0}function mc(n,e,t){return(1-t)*n+t*e}function XL(n,e,t,i){return mc(n,e,1-Math.exp(-t*i))}function YL(n,e=1){return e-Math.abs(k_(n,e*2)-e)}function jL(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function qL(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function ZL(n,e){return n+Math.floor(Math.random()*(e-n+1))}function KL(n,e){return n+Math.random()*(e-n)}function QL(n){return n*(.5-Math.random())}function JL(n){n!==void 0&&(r1=n);let e=r1+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function $L(n){return n*ca}function e3(n){return n*Zl}function xy(n){return(n&n-1)===0&&n!==0}function t3(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Cp(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function n3(n,e,t,i,r){const s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),f=s((e+i)/2),h=o((e+i)/2),d=s((e-i)/2),m=o((e-i)/2),v=s((i-e)/2),_=o((i-e)/2);switch(r){case"XYX":n.set(a*h,c*d,c*m,a*f);break;case"YZY":n.set(c*m,a*h,c*d,a*f);break;case"ZXZ":n.set(c*d,c*m,a*h,a*f);break;case"XZX":n.set(a*h,c*_,c*v,a*f);break;case"YXY":n.set(c*v,a*h,c*_,a*f);break;case"ZYZ":n.set(c*_,c*v,a*h,a*f);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ii(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function mt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const i3={DEG2RAD:ca,RAD2DEG:Zl,generateUUID:Ki,clamp:dn,euclideanModulo:k_,mapLinear:GL,inverseLerp:WL,lerp:mc,damp:XL,pingpong:YL,smoothstep:jL,smootherstep:qL,randInt:ZL,randFloat:KL,randFloatSpread:QL,seededRandom:JL,degToRad:$L,radToDeg:e3,isPowerOfTwo:xy,ceilPowerOfTwo:t3,floorPowerOfTwo:Cp,setQuaternionFromProperEuler:n3,normalize:mt,denormalize:Ii};class oe{constructor(e=0,t=0){oe.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(dn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class xt{constructor(e,t,i,r,s,o,a,c,f){xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,f)}set(e,t,i,r,s,o,a,c,f){const h=this.elements;return h[0]=e,h[1]=r,h[2]=a,h[3]=t,h[4]=s,h[5]=c,h[6]=i,h[7]=o,h[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],c=i[6],f=i[1],h=i[4],d=i[7],m=i[2],v=i[5],_=i[8],E=r[0],M=r[3],g=r[6],x=r[1],S=r[4],T=r[7],L=r[2],R=r[5],P=r[8];return s[0]=o*E+a*x+c*L,s[3]=o*M+a*S+c*R,s[6]=o*g+a*T+c*P,s[1]=f*E+h*x+d*L,s[4]=f*M+h*S+d*R,s[7]=f*g+h*T+d*P,s[2]=m*E+v*x+_*L,s[5]=m*M+v*S+_*R,s[8]=m*g+v*T+_*P,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],f=e[7],h=e[8];return t*o*h-t*a*f-i*s*h+i*a*c+r*s*f-r*o*c}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],f=e[7],h=e[8],d=h*o-a*f,m=a*c-h*s,v=f*s-o*c,_=t*d+i*m+r*v;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const E=1/_;return e[0]=d*E,e[1]=(r*f-h*i)*E,e[2]=(a*i-r*o)*E,e[3]=m*E,e[4]=(h*t-r*c)*E,e[5]=(r*s-a*t)*E,e[6]=v*E,e[7]=(i*c-f*t)*E,e[8]=(o*t-i*s)*E,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){const c=Math.cos(s),f=Math.sin(s);return this.set(i*c,i*f,-i*(c*o+f*a)+o+e,-r*f,r*c,-r*(-f*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(tv.makeScale(e,t)),this}rotate(e){return this.premultiply(tv.makeRotation(-e)),this}translate(e,t){return this.premultiply(tv.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const tv=new xt;function fC(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const r3={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Cl(n,e){return new r3[n](e)}function qc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function hC(){const n=qc("canvas");return n.style.display="block",n}const s1={};function gc(n){n in s1||(s1[n]=!0,console.warn(n))}const o1=new xt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),a1=new xt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Oh={[_r]:{transfer:Wc,primaries:Xc,toReference:n=>n,fromReference:n=>n},[At]:{transfer:Wt,primaries:Xc,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[hf]:{transfer:Wc,primaries:Yc,toReference:n=>n.applyMatrix3(a1),fromReference:n=>n.applyMatrix3(o1)},[Qp]:{transfer:Wt,primaries:Yc,toReference:n=>n.convertSRGBToLinear().applyMatrix3(a1),fromReference:n=>n.applyMatrix3(o1).convertLinearToSRGB()}},s3=new Set([_r,hf]),Bt={enabled:!0,_workingColorSpace:_r,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!s3.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=Oh[e].toReference,r=Oh[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Oh[n].primaries},getTransfer:function(n){return n===_i?Wc:Oh[n].transfer}};function Bl(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function nv(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Wa;class H_{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Wa===void 0&&(Wa=qc("canvas")),Wa.width=e.width,Wa.height=e.height;const i=Wa.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Wa}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=qc("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==jp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case jl:e.x=e.x-Math.floor(e.x);break;case li:e.x=e.x<0?0:1;break;case kc:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case jl:e.y=e.y-Math.floor(e.y);break;case li:e.y=e.y<0?0:1;break;case kc:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return gc("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===At?ho:z_}set encoding(e){gc("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===ho?At:_i}}an.DEFAULT_IMAGE=null;an.DEFAULT_MAPPING=jp;an.DEFAULT_ANISOTROPY=1;class Ot{constructor(e=0,t=0,i=0,r=1){Ot.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const c=e.elements,f=c[0],h=c[4],d=c[8],m=c[1],v=c[5],_=c[9],E=c[2],M=c[6],g=c[10];if(Math.abs(h-m)<.01&&Math.abs(d-E)<.01&&Math.abs(_-M)<.01){if(Math.abs(h+m)<.1&&Math.abs(d+E)<.1&&Math.abs(_+M)<.1&&Math.abs(f+v+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const S=(f+1)/2,T=(v+1)/2,L=(g+1)/2,R=(h+m)/4,P=(d+E)/4,D=(_+M)/4;return S>T&&S>L?S<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(S),r=R/i,s=P/i):T>L?T<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(T),i=R/r,s=D/r):L<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(L),i=P/s,r=D/s),this.set(i,r,s,t),this}let x=Math.sqrt((M-_)*(M-_)+(d-E)*(d-E)+(m-h)*(m-h));return Math.abs(x)<.001&&(x=1),this.x=(M-_)/x,this.y=(d-E)/x,this.z=(m-h)/x,this.w=Math.acos((f+v+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class dC extends xr{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ot(0,0,e,t),this.scissorTest=!1,this.viewport=new Ot(0,0,e,t);const r={width:e,height:t,depth:1};i.encoding!==void 0&&(gc("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===ho?At:_i),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Kt,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new an(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new sa(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class _n extends dC{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class Jp extends an{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class l3 extends _n{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Jp(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class V_ extends an{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Xt,this.minFilter=Xt,this.wrapR=li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class u3 extends _n{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new V_(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class c3 extends _n{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let o=0;o=0?1:-1,S=1-g*g;if(S>Number.EPSILON){const L=Math.sqrt(S),R=Math.atan2(L,g*x);M=Math.sin(M*R)/L,a=Math.sin(a*R)/L}const T=a*x;if(c=c*M+m*T,f=f*M+v*T,h=h*M+_*T,d=d*M+E*T,M===1-a){const L=1/Math.sqrt(c*c+f*f+h*h+d*d);c*=L,f*=L,h*=L,d*=L}}e[t]=c,e[t+1]=f,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){const a=i[r],c=i[r+1],f=i[r+2],h=i[r+3],d=s[o],m=s[o+1],v=s[o+2],_=s[o+3];return e[t]=a*_+h*d+c*v-f*m,e[t+1]=c*_+h*m+f*d-a*v,e[t+2]=f*_+h*v+a*m-c*d,e[t+3]=h*_-a*d-c*m-f*v,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,f=a(i/2),h=a(r/2),d=a(s/2),m=c(i/2),v=c(r/2),_=c(s/2);switch(o){case"XYZ":this._x=m*h*d+f*v*_,this._y=f*v*d-m*h*_,this._z=f*h*_+m*v*d,this._w=f*h*d-m*v*_;break;case"YXZ":this._x=m*h*d+f*v*_,this._y=f*v*d-m*h*_,this._z=f*h*_-m*v*d,this._w=f*h*d+m*v*_;break;case"ZXY":this._x=m*h*d-f*v*_,this._y=f*v*d+m*h*_,this._z=f*h*_+m*v*d,this._w=f*h*d-m*v*_;break;case"ZYX":this._x=m*h*d-f*v*_,this._y=f*v*d+m*h*_,this._z=f*h*_-m*v*d,this._w=f*h*d+m*v*_;break;case"YZX":this._x=m*h*d+f*v*_,this._y=f*v*d+m*h*_,this._z=f*h*_-m*v*d,this._w=f*h*d-m*v*_;break;case"XZY":this._x=m*h*d-f*v*_,this._y=f*v*d-m*h*_,this._z=f*h*_+m*v*d,this._w=f*h*d+m*v*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],f=t[2],h=t[6],d=t[10],m=i+a+d;if(m>0){const v=.5/Math.sqrt(m+1);this._w=.25/v,this._x=(h-c)*v,this._y=(s-f)*v,this._z=(o-r)*v}else if(i>a&&i>d){const v=2*Math.sqrt(1+i-a-d);this._w=(h-c)/v,this._x=.25*v,this._y=(r+o)/v,this._z=(s+f)/v}else if(a>d){const v=2*Math.sqrt(1+a-i-d);this._w=(s-f)/v,this._x=(r+o)/v,this._y=.25*v,this._z=(c+h)/v}else{const v=2*Math.sqrt(1+d-i-a);this._w=(o-r)/v,this._x=(s+f)/v,this._y=(c+h)/v,this._z=.25*v}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(dn(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,f=t._z,h=t._w;return this._x=i*h+o*a+r*f-s*c,this._y=r*h+o*c+s*a-i*f,this._z=s*h+o*f+i*c-r*a,this._w=o*h-i*a-r*c-s*f,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,o=this._w;let a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const v=1-t;return this._w=v*o+t*this._w,this._x=v*i+t*this._x,this._y=v*r+t*this._y,this._z=v*s+t*this._z,this.normalize(),this}const f=Math.sqrt(c),h=Math.atan2(f,a),d=Math.sin((1-t)*h)/f,m=Math.sin(t*h)/f;return this._w=o*d+this._w*m,this._x=i*d+this._x*m,this._y=r*d+this._y*m,this._z=s*d+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(s),i*Math.cos(s),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class O{constructor(e=0,t=0,i=0){O.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(l1.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(l1.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,f=2*(o*r-a*i),h=2*(a*t-s*r),d=2*(s*i-o*t);return this.x=t+c*f+o*d-a*h,this.y=i+c*h+a*f-s*d,this.z=r+c*d+s*h-o*f,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return rv.copy(this).projectOnVector(e),this.sub(rv)}reflect(e){return this.sub(rv.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(dn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const rv=new O,l1=new Fi;class Si{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,wr),wr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(zu),zh.subVectors(this.max,zu),Xa.subVectors(e.a,zu),Ya.subVectors(e.b,zu),ja.subVectors(e.c,zu),Hs.subVectors(Ya,Xa),Vs.subVectors(ja,Ya),zo.subVectors(Xa,ja);let t=[0,-Hs.z,Hs.y,0,-Vs.z,Vs.y,0,-zo.z,zo.y,Hs.z,0,-Hs.x,Vs.z,0,-Vs.x,zo.z,0,-zo.x,-Hs.y,Hs.x,0,-Vs.y,Vs.x,0,-zo.y,zo.x,0];return!sv(t,Xa,Ya,ja,zh)||(t=[1,0,0,0,1,0,0,0,1],!sv(t,Xa,Ya,ja,zh))?!1:(Bh.crossVectors(Hs,Vs),t=[Bh.x,Bh.y,Bh.z],sv(t,Xa,Ya,ja,zh))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,wr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(wr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(us[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),us[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),us[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),us[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),us[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),us[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),us[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),us[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(us),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const us=[new O,new O,new O,new O,new O,new O,new O,new O],wr=new O,Fh=new Si,Xa=new O,Ya=new O,ja=new O,Hs=new O,Vs=new O,zo=new O,zu=new O,zh=new O,Bh=new O,Bo=new O;function sv(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Bo.fromArray(n,s);const a=r.x*Math.abs(Bo.x)+r.y*Math.abs(Bo.y)+r.z*Math.abs(Bo.z),c=e.dot(Bo),f=t.dot(Bo),h=i.dot(Bo);if(Math.max(-Math.max(c,f,h),Math.min(c,f,h))>a)return!1}return!0}const f3=new Si,Bu=new O,ov=new O;class fi{constructor(e=new O,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):f3.setFromPoints(e).getCenter(i);let r=0;for(let s=0,o=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Bu.subVectors(e,this.center);const t=Bu.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Bu,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ov.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Bu.copy(e.center).add(ov)),this.expandByPoint(Bu.copy(e.center).sub(ov))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const cs=new O,av=new O,kh=new O,Gs=new O,lv=new O,Hh=new O,uv=new O;class ru{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,cs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=cs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(cs.copy(this.origin).addScaledVector(this.direction,t),cs.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){av.copy(e).add(t).multiplyScalar(.5),kh.copy(t).sub(e).normalize(),Gs.copy(this.origin).sub(av);const s=e.distanceTo(t)*.5,o=-this.direction.dot(kh),a=Gs.dot(this.direction),c=-Gs.dot(kh),f=Gs.lengthSq(),h=Math.abs(1-o*o);let d,m,v,_;if(h>0)if(d=o*c-a,m=o*a-c,_=s*h,d>=0)if(m>=-_)if(m<=_){const E=1/h;d*=E,m*=E,v=d*(d+o*m+2*a)+m*(o*d+m+2*c)+f}else m=s,d=Math.max(0,-(o*m+a)),v=-d*d+m*(m+2*c)+f;else m=-s,d=Math.max(0,-(o*m+a)),v=-d*d+m*(m+2*c)+f;else m<=-_?(d=Math.max(0,-(-o*s+a)),m=d>0?-s:Math.min(Math.max(-s,-c),s),v=-d*d+m*(m+2*c)+f):m<=_?(d=0,m=Math.min(Math.max(-s,-c),s),v=m*(m+2*c)+f):(d=Math.max(0,-(o*s+a)),m=d>0?s:Math.min(Math.max(-s,-c),s),v=-d*d+m*(m+2*c)+f);else m=o>0?-s:s,d=Math.max(0,-(o*m+a)),v=-d*d+m*(m+2*c)+f;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(av).addScaledVector(kh,m),v}intersectSphere(e,t){cs.subVectors(e.center,this.origin);const i=cs.dot(this.direction),r=cs.dot(cs)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,c;const f=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,m=this.origin;return f>=0?(i=(e.min.x-m.x)*f,r=(e.max.x-m.x)*f):(i=(e.max.x-m.x)*f,r=(e.min.x-m.x)*f),h>=0?(s=(e.min.y-m.y)*h,o=(e.max.y-m.y)*h):(s=(e.max.y-m.y)*h,o=(e.min.y-m.y)*h),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o=0?(a=(e.min.z-m.z)*d,c=(e.max.z-m.z)*d):(a=(e.max.z-m.z)*d,c=(e.min.z-m.z)*d),i>c||a>r)||((a>i||i!==i)&&(i=a),(c=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,cs)!==null}intersectTriangle(e,t,i,r,s){lv.subVectors(t,e),Hh.subVectors(i,e),uv.crossVectors(lv,Hh);let o=this.direction.dot(uv),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Gs.subVectors(this.origin,e);const c=a*this.direction.dot(Hh.crossVectors(Gs,Hh));if(c<0)return null;const f=a*this.direction.dot(lv.cross(Gs));if(f<0||c+f>o)return null;const h=-a*Gs.dot(uv);return h<0?null:this.at(h/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class it{constructor(e,t,i,r,s,o,a,c,f,h,d,m,v,_,E,M){it.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,o,a,c,f,h,d,m,v,_,E,M)}set(e,t,i,r,s,o,a,c,f,h,d,m,v,_,E,M){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=s,g[5]=o,g[9]=a,g[13]=c,g[2]=f,g[6]=h,g[10]=d,g[14]=m,g[3]=v,g[7]=_,g[11]=E,g[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 it().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/qa.setFromMatrixColumn(e,0).length(),s=1/qa.setFromMatrixColumn(e,1).length(),o=1/qa.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),f=Math.sin(r),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const m=o*h,v=o*d,_=a*h,E=a*d;t[0]=c*h,t[4]=-c*d,t[8]=f,t[1]=v+_*f,t[5]=m-E*f,t[9]=-a*c,t[2]=E-m*f,t[6]=_+v*f,t[10]=o*c}else if(e.order==="YXZ"){const m=c*h,v=c*d,_=f*h,E=f*d;t[0]=m+E*a,t[4]=_*a-v,t[8]=o*f,t[1]=o*d,t[5]=o*h,t[9]=-a,t[2]=v*a-_,t[6]=E+m*a,t[10]=o*c}else if(e.order==="ZXY"){const m=c*h,v=c*d,_=f*h,E=f*d;t[0]=m-E*a,t[4]=-o*d,t[8]=_+v*a,t[1]=v+_*a,t[5]=o*h,t[9]=E-m*a,t[2]=-o*f,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const m=o*h,v=o*d,_=a*h,E=a*d;t[0]=c*h,t[4]=_*f-v,t[8]=m*f+E,t[1]=c*d,t[5]=E*f+m,t[9]=v*f-_,t[2]=-f,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const m=o*c,v=o*f,_=a*c,E=a*f;t[0]=c*h,t[4]=E-m*d,t[8]=_*d+v,t[1]=d,t[5]=o*h,t[9]=-a*h,t[2]=-f*h,t[6]=v*d+_,t[10]=m-E*d}else if(e.order==="XZY"){const m=o*c,v=o*f,_=a*c,E=a*f;t[0]=c*h,t[4]=-d,t[8]=f*h,t[1]=m*d+E,t[5]=o*h,t[9]=v*d-_,t[2]=_*d-v,t[6]=a*h,t[10]=E*d+m}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(h3,e,d3)}lookAt(e,t,i){const r=this.elements;return Xi.subVectors(e,t),Xi.lengthSq()===0&&(Xi.z=1),Xi.normalize(),Ws.crossVectors(i,Xi),Ws.lengthSq()===0&&(Math.abs(i.z)===1?Xi.x+=1e-4:Xi.z+=1e-4,Xi.normalize(),Ws.crossVectors(i,Xi)),Ws.normalize(),Vh.crossVectors(Xi,Ws),r[0]=Ws.x,r[4]=Vh.x,r[8]=Xi.x,r[1]=Ws.y,r[5]=Vh.y,r[9]=Xi.y,r[2]=Ws.z,r[6]=Vh.z,r[10]=Xi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],c=i[8],f=i[12],h=i[1],d=i[5],m=i[9],v=i[13],_=i[2],E=i[6],M=i[10],g=i[14],x=i[3],S=i[7],T=i[11],L=i[15],R=r[0],P=r[4],D=r[8],C=r[12],b=r[1],B=r[5],j=r[9],le=r[13],H=r[2],Z=r[6],$=r[10],ce=r[14],z=r[3],G=r[7],V=r[11],J=r[15];return s[0]=o*R+a*b+c*H+f*z,s[4]=o*P+a*B+c*Z+f*G,s[8]=o*D+a*j+c*$+f*V,s[12]=o*C+a*le+c*ce+f*J,s[1]=h*R+d*b+m*H+v*z,s[5]=h*P+d*B+m*Z+v*G,s[9]=h*D+d*j+m*$+v*V,s[13]=h*C+d*le+m*ce+v*J,s[2]=_*R+E*b+M*H+g*z,s[6]=_*P+E*B+M*Z+g*G,s[10]=_*D+E*j+M*$+g*V,s[14]=_*C+E*le+M*ce+g*J,s[3]=x*R+S*b+T*H+L*z,s[7]=x*P+S*B+T*Z+L*G,s[11]=x*D+S*j+T*$+L*V,s[15]=x*C+S*le+T*ce+L*J,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],f=e[13],h=e[2],d=e[6],m=e[10],v=e[14],_=e[3],E=e[7],M=e[11],g=e[15];return _*(+s*c*d-r*f*d-s*a*m+i*f*m+r*a*v-i*c*v)+E*(+t*c*v-t*f*m+s*o*m-r*o*v+r*f*h-s*c*h)+M*(+t*f*d-t*a*v-s*o*d+i*o*v+s*a*h-i*f*h)+g*(-r*a*h-t*c*d+t*a*m+r*o*d-i*o*m+i*c*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],f=e[7],h=e[8],d=e[9],m=e[10],v=e[11],_=e[12],E=e[13],M=e[14],g=e[15],x=d*M*f-E*m*f+E*c*v-a*M*v-d*c*g+a*m*g,S=_*m*f-h*M*f-_*c*v+o*M*v+h*c*g-o*m*g,T=h*E*f-_*d*f+_*a*v-o*E*v-h*a*g+o*d*g,L=_*d*c-h*E*c-_*a*m+o*E*m+h*a*M-o*d*M,R=t*x+i*S+r*T+s*L;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/R;return e[0]=x*P,e[1]=(E*m*s-d*M*s-E*r*v+i*M*v+d*r*g-i*m*g)*P,e[2]=(a*M*s-E*c*s+E*r*f-i*M*f-a*r*g+i*c*g)*P,e[3]=(d*c*s-a*m*s-d*r*f+i*m*f+a*r*v-i*c*v)*P,e[4]=S*P,e[5]=(h*M*s-_*m*s+_*r*v-t*M*v-h*r*g+t*m*g)*P,e[6]=(_*c*s-o*M*s-_*r*f+t*M*f+o*r*g-t*c*g)*P,e[7]=(o*m*s-h*c*s+h*r*f-t*m*f-o*r*v+t*c*v)*P,e[8]=T*P,e[9]=(_*d*s-h*E*s-_*i*v+t*E*v+h*i*g-t*d*g)*P,e[10]=(o*E*s-_*a*s+_*i*f-t*E*f-o*i*g+t*a*g)*P,e[11]=(h*a*s-o*d*s-h*i*f+t*d*f+o*i*v-t*a*v)*P,e[12]=L*P,e[13]=(h*E*r-_*d*r+_*i*m-t*E*m-h*i*M+t*d*M)*P,e[14]=(_*a*r-o*E*r-_*i*c+t*E*c+o*i*M-t*a*M)*P,e[15]=(o*d*r-h*a*r+h*i*c-t*d*c-o*i*m+t*a*m)*P,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,c=e.z,f=s*o,h=s*a;return this.set(f*o+i,f*a-r*c,f*c+r*a,0,f*a+r*c,h*a+i,h*c-r*o,0,f*c-r*a,h*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,f=s+s,h=o+o,d=a+a,m=s*f,v=s*h,_=s*d,E=o*h,M=o*d,g=a*d,x=c*f,S=c*h,T=c*d,L=i.x,R=i.y,P=i.z;return r[0]=(1-(E+g))*L,r[1]=(v+T)*L,r[2]=(_-S)*L,r[3]=0,r[4]=(v-T)*R,r[5]=(1-(m+g))*R,r[6]=(M+x)*R,r[7]=0,r[8]=(_+S)*P,r[9]=(M-x)*P,r[10]=(1-(m+E))*P,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let s=qa.set(r[0],r[1],r[2]).length();const o=qa.set(r[4],r[5],r[6]).length(),a=qa.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Tr.copy(this);const f=1/s,h=1/o,d=1/a;return Tr.elements[0]*=f,Tr.elements[1]*=f,Tr.elements[2]*=f,Tr.elements[4]*=h,Tr.elements[5]*=h,Tr.elements[6]*=h,Tr.elements[8]*=d,Tr.elements[9]*=d,Tr.elements[10]*=d,t.setFromRotationMatrix(Tr),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=Ir){const c=this.elements,f=2*s/(t-e),h=2*s/(i-r),d=(t+e)/(t-e),m=(i+r)/(i-r);let v,_;if(a===Ir)v=-(o+s)/(o-s),_=-2*o*s/(o-s);else if(a===ql)v=-o/(o-s),_=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=f,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=v,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=Ir){const c=this.elements,f=1/(t-e),h=1/(i-r),d=1/(o-s),m=(t+e)*f,v=(i+r)*h;let _,E;if(a===Ir)_=(o+s)*d,E=-2*d;else if(a===ql)_=s*d,E=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*f,c[4]=0,c[8]=0,c[12]=-m,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-v,c[2]=0,c[6]=0,c[10]=E,c[14]=-_,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const qa=new O,Tr=new it,h3=new O(0,0,0),d3=new O(1,1,1),Ws=new O,Vh=new O,Xi=new O,u1=new it,c1=new Fi;class df{constructor(e=0,t=0,i=0,r=df.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],f=r[5],h=r[9],d=r[2],m=r[6],v=r[10];switch(t){case"XYZ":this._y=Math.asin(dn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,v),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(m,f),this._z=0);break;case"YXZ":this._x=Math.asin(-dn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,v),this._z=Math.atan2(c,f)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(dn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-d,v),this._z=Math.atan2(-o,f)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-dn(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(m,v),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,f));break;case"YZX":this._z=Math.asin(dn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,f),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,v));break;case"XZY":this._z=Math.asin(-dn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,f),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,v),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return u1.makeRotationFromQuaternion(e),this.setFromRotationMatrix(u1,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return c1.setFromEuler(this),this.setFromQuaternion(c1,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}df.DEFAULT_ORDER="XYZ";class fa{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),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(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let f=0,h=c.length;f0){r.children=[];for(let a=0;a0){r.animations=[];for(let a=0;a0&&(i.geometries=a),c.length>0&&(i.materials=c),f.length>0&&(i.textures=f),h.length>0&&(i.images=h),d.length>0&&(i.shapes=d),m.length>0&&(i.skeletons=m),v.length>0&&(i.animations=v),_.length>0&&(i.nodes=_)}return i.object=r,i;function o(a){const c=[];for(const f in a){const h=a[f];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Ar.subVectors(r,t),hs.subVectors(i,t),cv.subVectors(e,t);const o=Ar.dot(Ar),a=Ar.dot(hs),c=Ar.dot(cv),f=hs.dot(hs),h=hs.dot(cv),d=o*f-a*a;if(d===0)return s.set(0,0,0),null;const m=1/d,v=(f*c-a*h)*m,_=(o*h-a*c)*m;return s.set(1-v-_,_,v)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,ds)===null?!1:ds.x>=0&&ds.y>=0&&ds.x+ds.y<=1}static getUV(e,t,i,r,s,o,a,c){return Wh===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Wh=!0),this.getInterpolation(e,t,i,r,s,o,a,c)}static getInterpolation(e,t,i,r,s,o,a,c){return this.getBarycoord(e,t,i,r,ds)===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,ds.x),c.addScaledVector(o,ds.y),c.addScaledVector(a,ds.z),c)}static isFrontFacing(e,t,i,r){return Ar.subVectors(i,t),hs.subVectors(e,t),Ar.cross(hs).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Ar.subVectors(this.c,this.b),hs.subVectors(this.a,this.b),Ar.cross(hs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Li.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Li.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,s){return Wh===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Wh=!0),Li.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}getInterpolation(e,t,i,r,s){return Li.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return Li.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Li.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let o,a;Ka.subVectors(r,i),Qa.subVectors(s,i),fv.subVectors(e,i);const c=Ka.dot(fv),f=Qa.dot(fv);if(c<=0&&f<=0)return t.copy(i);hv.subVectors(e,r);const h=Ka.dot(hv),d=Qa.dot(hv);if(h>=0&&d<=h)return t.copy(r);const m=c*d-h*f;if(m<=0&&c>=0&&h<=0)return o=c/(c-h),t.copy(i).addScaledVector(Ka,o);dv.subVectors(e,s);const v=Ka.dot(dv),_=Qa.dot(dv);if(_>=0&&v<=_)return t.copy(s);const E=v*f-c*_;if(E<=0&&f>=0&&_<=0)return a=f/(f-_),t.copy(i).addScaledVector(Qa,a);const M=h*_-v*d;if(M<=0&&d-h>=0&&v-_>=0)return m1.subVectors(s,r),a=(d-h)/(d-h+(v-_)),t.copy(r).addScaledVector(m1,a);const g=1/(M+E+m);return o=E*g,a=m*g,t.copy(i).addScaledVector(Ka,o).addScaledVector(Qa,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const pC={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},Xs={h:0,s:0,l:0},Xh={h:0,s:0,l:0};function pv(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Ue{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=At){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Bt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=Bt.workingColorSpace){return this.r=e,this.g=t,this.b=i,Bt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=Bt.workingColorSpace){if(e=k_(e,1),t=dn(t,0,1),i=dn(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,o=2*i-s;this.r=pv(o,s,e+1/3),this.g=pv(o,s,e),this.b=pv(o,s,e-1/3)}return Bt.toWorkingColorSpace(this,r),this}setStyle(e,t=At){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){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 i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){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,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=At){const i=pC[e.toLowerCase()];return i!==void 0?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Bl(e.r),this.g=Bl(e.g),this.b=Bl(e.b),this}copyLinearToSRGB(e){return this.r=nv(e.r),this.g=nv(e.g),this.b=nv(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=At){return Bt.fromWorkingColorSpace(si.copy(this),e),Math.round(dn(si.r*255,0,255))*65536+Math.round(dn(si.g*255,0,255))*256+Math.round(dn(si.b*255,0,255))}getHexString(e=At){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Bt.workingColorSpace){Bt.fromWorkingColorSpace(si.copy(this),t);const i=si.r,r=si.g,s=si.b,o=Math.max(i,r,s),a=Math.min(i,r,s);let c,f;const h=(a+o)/2;if(a===o)c=0,f=0;else{const d=o-a;switch(f=h<=.5?d/(o+a):d/(2-o-a),o){case i:c=(r-s)/d+(r0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==ua&&(i.blending=this.blending),this.side!==ts&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Ep&&(i.blendSrc=this.blendSrc),this.blendDst!==wp&&(i.blendDst=this.blendDst),this.blendEquation!==eo&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Fc&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==yy&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ko&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ko&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ko&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.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(t){const s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ao extends Wn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ue(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.combine=ff,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const vs=x3();function x3(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){const f=c-127;f<-27?(i[c]=0,i[c|256]=32768,r[c]=24,r[c|256]=24):f<-14?(i[c]=1024>>-f-14,i[c|256]=1024>>-f-14|32768,r[c]=-f-1,r[c|256]=-f-1):f<=15?(i[c]=f+15<<10,i[c|256]=f+15<<10|32768,r[c]=13,r[c|256]=13):f<128?(i[c]=31744,i[c|256]=64512,r[c]=24,r[c|256]=24):(i[c]=31744,i[c|256]=64512,r[c]=13,r[c|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let f=c<<13,h=0;for(;!(f&8388608);)f<<=1,h-=8388608;f&=-8388609,h+=947912704,s[c]=f|h}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function bi(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=dn(n,-65504,65504),vs.floatView[0]=n;const e=vs.uint32View[0],t=e>>23&511;return vs.baseTable[t]+((e&8388607)>>vs.shiftTable[t])}function ic(n){const e=n>>10;return vs.uint32View[0]=vs.mantissaTable[vs.offsetTable[e]+(n&1023)]+vs.exponentTable[e],vs.floatView[0]}const S3={toHalfFloat:bi,fromHalfFloat:ic},Mn=new O,Yh=new oe;class Ft{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=jc,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=mr,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const f in c)c[f]!==void 0&&(e[f]=c[f]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const f=i[c];e.data.attributes[c]=f.toJSON(e.data)}const r={};let s=!1;for(const c in this.morphAttributes){const f=this.morphAttributes[c],h=[];for(let d=0,m=f.length;d0&&(r[c]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const f in r){const h=r[f];this.setAttribute(f,h.clone(t))}const s=e.morphAttributes;for(const f in s){const h=[],d=s[f];for(let m=0,v=d.length;m0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s(e.far-e.near)**2))&&(g1.copy(s).invert(),ko.copy(e.ray).applyMatrix4(g1),!(i.boundingBox!==null&&ko.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,ko)))}_computeIntersections(e,t,i){let r;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,f=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,m=s.groups,v=s.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,E=m.length;_t.far?null:{distance:f,point:$h.clone(),object:n}}function ed(n,e,t,i,r,s,o,a,c,f){n.getVertexPosition(a,$a),n.getVertexPosition(c,el),n.getVertexPosition(f,tl);const h=P3(n,e,t,i,$a,el,tl,Jh);if(h){r&&(Zh.fromBufferAttribute(r,a),Kh.fromBufferAttribute(r,c),Qh.fromBufferAttribute(r,f),h.uv=Li.getInterpolation(Jh,$a,el,tl,Zh,Kh,Qh,new oe)),s&&(Zh.fromBufferAttribute(s,a),Kh.fromBufferAttribute(s,c),Qh.fromBufferAttribute(s,f),h.uv1=Li.getInterpolation(Jh,$a,el,tl,Zh,Kh,Qh,new oe),h.uv2=h.uv1),o&&(y1.fromBufferAttribute(o,a),_1.fromBufferAttribute(o,c),x1.fromBufferAttribute(o,f),h.normal=Li.getInterpolation(Jh,$a,el,tl,y1,_1,x1,new O),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a,b:c,c:f,normal:new O,materialIndex:0};Li.getNormal($a,el,tl,d.normal),h.face=d}return h}class Ea extends vt{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const c=[],f=[],h=[],d=[];let m=0,v=0;_("z","y","x",-1,-1,i,t,e,o,s,0),_("z","y","x",1,-1,i,t,-e,o,s,1),_("x","z","y",1,1,e,i,t,r,o,2),_("x","z","y",1,-1,e,i,-t,r,o,3),_("x","y","z",1,-1,e,t,i,r,s,4),_("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new He(f,3)),this.setAttribute("normal",new He(h,3)),this.setAttribute("uv",new He(d,2));function _(E,M,g,x,S,T,L,R,P,D,C){const b=T/P,B=L/D,j=T/2,le=L/2,H=R/2,Z=P+1,$=D+1;let ce=0,z=0;const G=new O;for(let V=0;V<$;V++){const J=V*B-le;for(let se=0;se0?1:-1,h.push(G.x,G.y,G.z),d.push(se/P),d.push(1-V/D),ce+=1}}for(let V=0;V0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class su extends Dt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new it,this.projectionMatrix=new it,this.projectionMatrixInverse=new it,this.coordinateSystem=Ir}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Cn extends su{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Zl*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ca*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Zl*2*Math.atan(Math.tan(ca*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,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 e=this.near;let t=e*Math.tan(ca*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,f=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*i/f,r*=o.width/c,i*=o.height/f}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const nl=-90,il=1;class vC extends Dt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Cn(nl,il,e,t);r.layers=this.layers,this.add(r);const s=new Cn(nl,il,e,t);s.layers=this.layers,this.add(s);const o=new Cn(nl,il,e,t);o.layers=this.layers,this.add(o);const a=new Cn(nl,il,e,t);a.layers=this.layers,this.add(a);const c=new Cn(nl,il,e,t);c.layers=this.layers,this.add(c);const f=new Cn(nl,il,e,t);f.layers=this.layers,this.add(f)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,c]=t;for(const f of t)this.remove(f);if(e===Ir)i.up.set(0,1,0),i.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(e===ql)i.up.set(0,-1,0),i.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: "+e);for(const f of t)this.add(f),f.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,c,f,h]=this.children,d=e.getRenderTarget(),m=e.getActiveCubeFace(),v=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const E=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,o),e.setRenderTarget(i,2,r),e.render(t,a),e.setRenderTarget(i,3,r),e.render(t,c),e.setRenderTarget(i,4,r),e.render(t,f),i.texture.generateMipmaps=E,e.setRenderTarget(i,5,r),e.render(t,h),e.setRenderTarget(d,m,v),e.xr.enabled=_,i.texture.needsPMREMUpdate=!0}}class pf extends an{constructor(e,t,i,r,s,o,a,c,f,h){e=e!==void 0?e:[],t=t!==void 0?t:Rs,super(e,t,i,r,s,o,a,c,f,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class yC extends _n{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];t.encoding!==void 0&&(gc("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===ho?At:_i),this.texture=new pf(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Kt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},r=new Ea(5,5,5),s=new Gn({name:"CubemapFromEquirect",uniforms:Kl(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:bn,blending:ci});s.uniforms.tEquirect.value=t;const o=new wn(r,s),a=t.minFilter;return t.minFilter===yo&&(t.minFilter=Kt),new vC(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,r){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,r);e.setRenderTarget(s)}}const vv=new O,N3=new O,D3=new xt;class Qs{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=vv.subVectors(i,t).cross(N3.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(vv),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||D3.getNormalMatrix(e),r=this.coplanarPoint(vv).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ho=new fi,td=new O;class mf{constructor(e=new Qs,t=new Qs,i=new Qs,r=new Qs,s=new Qs,o=new Qs){this.planes=[e,t,i,r,s,o]}set(e,t,i,r,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Ir){const i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],f=r[4],h=r[5],d=r[6],m=r[7],v=r[8],_=r[9],E=r[10],M=r[11],g=r[12],x=r[13],S=r[14],T=r[15];if(i[0].setComponents(c-s,m-f,M-v,T-g).normalize(),i[1].setComponents(c+s,m+f,M+v,T+g).normalize(),i[2].setComponents(c+o,m+h,M+_,T+x).normalize(),i[3].setComponents(c-o,m-h,M-_,T-x).normalize(),i[4].setComponents(c-a,m-d,M-E,T-S).normalize(),t===Ir)i[5].setComponents(c+a,m+d,M+E,T+S).normalize();else if(t===ql)i[5].setComponents(a,d,E,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ho.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ho.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ho)}intersectsSprite(e){return Ho.center.set(0,0,0),Ho.radius=.7071067811865476,Ho.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ho)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)0?e.max.x:e.min.x,td.y=r.normal.y>0?e.max.y:e.min.y,td.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(td)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function _C(){let n=null,e=!1,t=null,i=null;function r(s,o){t(s,o),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function O3(n,e){const t=e.isWebGL2,i=new WeakMap;function r(f,h){const d=f.array,m=f.usage,v=d.byteLength,_=n.createBuffer();n.bindBuffer(h,_),n.bufferData(h,d,m),f.onUploadCallback();let E;if(d instanceof Float32Array)E=n.FLOAT;else if(d instanceof Uint16Array)if(f.isFloat16BufferAttribute)if(t)E=n.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else E=n.UNSIGNED_SHORT;else if(d instanceof Int16Array)E=n.SHORT;else if(d instanceof Uint32Array)E=n.UNSIGNED_INT;else if(d instanceof Int32Array)E=n.INT;else if(d instanceof Int8Array)E=n.BYTE;else if(d instanceof Uint8Array)E=n.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)E=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:_,type:E,bytesPerElement:d.BYTES_PER_ELEMENT,version:f.version,size:v}}function s(f,h,d){const m=h.array,v=h._updateRange,_=h.updateRanges;if(n.bindBuffer(d,f),v.count===-1&&_.length===0&&n.bufferSubData(d,0,m),_.length!==0){for(let E=0,M=_.length;E 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif`,$3=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,eI=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,tI=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,nI=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,iI=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,rI=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,sI=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,oI=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float luminance( const in vec3 rgb ) { const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); return dot( weights, rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,aI=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,lI=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif #ifdef USE_BATCHING mat3 bm = mat3( batchingMatrix ); transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); transformedNormal = bm * transformedNormal; #ifdef USE_TANGENT transformedTangent = bm * transformedTangent; #endif #endif #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); transformedNormal = im * transformedNormal; #ifdef USE_TANGENT transformedTangent = im * transformedTangent; #endif #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,uI=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,cI=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,fI=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,hI=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,dI="gl_FragColor = linearToOutputTexel( gl_FragColor );",pI=` const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( vec3( 0.8224621, 0.177538, 0.0 ), vec3( 0.0331941, 0.9668058, 0.0 ), vec3( 0.0170827, 0.0723974, 0.9105199 ) ); const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( vec3( 1.2249401, - 0.2249404, 0.0 ), vec3( - 0.0420569, 1.0420571, 0.0 ), vec3( - 0.0196376, - 0.0786361, 1.0982735 ) ); vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); } vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); } vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferOETF( in vec4 value ) { 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 ); } vec4 LinearToLinear( in vec4 value ) { return value; } vec4 LinearTosRGB( in vec4 value ) { return sRGBTransferOETF( value ); }`,mI=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,gI=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,vI=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,yI=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,_I=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,xI=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,SI=`#ifdef USE_FOG varying float vFogDepth; #endif`,MI=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,EI=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,wI=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,TI=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,AI=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,CI=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,RI=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; 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 ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } 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 ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,bI=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; #endif vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { #if defined ( LEGACY_LIGHTS ) if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #else float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #endif } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = pointLight.position - geometryPosition; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = spotLight.position - geometryPosition; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,PI=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,LI=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,II=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; 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 ) { vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } 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 ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,UI=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,NI=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; 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 ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; } 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 ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,DI=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,OI=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY 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 ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE 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 ) { #else 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 ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 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 ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif 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 ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } 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 ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } 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) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,FI=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,zI=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,BI=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,kI=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,HI=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,VI=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,GI=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,WI=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; #endif`,XI=`#ifdef USE_MAP uniform sampler2D map; #endif`,YI=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,jI=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,qI=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,ZI=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,KI=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,QI=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif #endif`,JI=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #else #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif #endif`,$I=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif #endif`,eU=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`,tU=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,nU=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,iU=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,rU=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,sU=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`,oU=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,aU=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,lU=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`,uU=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,cU=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,fU=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec2 packDepthToRG( in highp float v ) { return packDepthToRGBA( v ).yx; } float unpackRGToDepth( const in highp vec2 v ) { return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); } vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,hU=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,dU=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,pU=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,mU=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,gU=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,vU=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,yU=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); 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 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,_U=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,xU=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,SU=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,MU=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,EU=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; mat4 getBoneMatrix( const in float i ) { int size = textureSize( boneTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif`,wU=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,TU=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,AU=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,CU=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,RU=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,bU=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 OptimizedCineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) ); const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) ); vec3 agxDefaultContrastApprox( vec3 x ) { vec3 x2 = x * x; vec3 x4 = x2 * x2; return + 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232; } vec3 AgXToneMapping( vec3 color ) { const mat3 AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) ); const mat3 AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) ); const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; color *= toneMappingExposure; color = AgXInsetMatrix * color; color = max( color, 1e-10 ); color = log2( color ); color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); color = clamp( color, 0.0, 1.0 ); color = agxDefaultContrastApprox( color ); color = AgXOutsetMatrix * color; color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); color = LINEAR_REC2020_TO_LINEAR_SRGB * color; return color; } vec3 CustomToneMapping( vec3 color ) { return color; }`,PU=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,LU=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`,IU=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,UU=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,NU=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`,DU=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const OU=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,FU=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE 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 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,zU=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,BU=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,kU=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,HU=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,VU=`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,GU=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif }`,WU=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,XU=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,YU=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,jU=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,qU=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include }`,ZU=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,KU=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,QU=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,JU=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,$U=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,eN=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,tN=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,nN=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,iN=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,rN=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,sN=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,oN=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,aN=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,lN=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,uN=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,cN=`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,fN=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,hN=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,dN=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,pN=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,mN=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,pt={alphahash_fragment:F3,alphahash_pars_fragment:z3,alphamap_fragment:B3,alphamap_pars_fragment:k3,alphatest_fragment:H3,alphatest_pars_fragment:V3,aomap_fragment:G3,aomap_pars_fragment:W3,batching_pars_vertex:X3,batching_vertex:Y3,begin_vertex:j3,beginnormal_vertex:q3,bsdfs:Z3,iridescence_fragment:K3,bumpmap_pars_fragment:Q3,clipping_planes_fragment:J3,clipping_planes_pars_fragment:$3,clipping_planes_pars_vertex:eI,clipping_planes_vertex:tI,color_fragment:nI,color_pars_fragment:iI,color_pars_vertex:rI,color_vertex:sI,common:oI,cube_uv_reflection_fragment:aI,defaultnormal_vertex:lI,displacementmap_pars_vertex:uI,displacementmap_vertex:cI,emissivemap_fragment:fI,emissivemap_pars_fragment:hI,colorspace_fragment:dI,colorspace_pars_fragment:pI,envmap_fragment:mI,envmap_common_pars_fragment:gI,envmap_pars_fragment:vI,envmap_pars_vertex:yI,envmap_physical_pars_fragment:PI,envmap_vertex:_I,fog_vertex:xI,fog_pars_vertex:SI,fog_fragment:MI,fog_pars_fragment:EI,gradientmap_pars_fragment:wI,lightmap_fragment:TI,lightmap_pars_fragment:AI,lights_lambert_fragment:CI,lights_lambert_pars_fragment:RI,lights_pars_begin:bI,lights_toon_fragment:LI,lights_toon_pars_fragment:II,lights_phong_fragment:UI,lights_phong_pars_fragment:NI,lights_physical_fragment:DI,lights_physical_pars_fragment:OI,lights_fragment_begin:FI,lights_fragment_maps:zI,lights_fragment_end:BI,logdepthbuf_fragment:kI,logdepthbuf_pars_fragment:HI,logdepthbuf_pars_vertex:VI,logdepthbuf_vertex:GI,map_fragment:WI,map_pars_fragment:XI,map_particle_fragment:YI,map_particle_pars_fragment:jI,metalnessmap_fragment:qI,metalnessmap_pars_fragment:ZI,morphcolor_vertex:KI,morphnormal_vertex:QI,morphtarget_pars_vertex:JI,morphtarget_vertex:$I,normal_fragment_begin:eU,normal_fragment_maps:tU,normal_pars_fragment:nU,normal_pars_vertex:iU,normal_vertex:rU,normalmap_pars_fragment:sU,clearcoat_normal_fragment_begin:oU,clearcoat_normal_fragment_maps:aU,clearcoat_pars_fragment:lU,iridescence_pars_fragment:uU,opaque_fragment:cU,packing:fU,premultiplied_alpha_fragment:hU,project_vertex:dU,dithering_fragment:pU,dithering_pars_fragment:mU,roughnessmap_fragment:gU,roughnessmap_pars_fragment:vU,shadowmap_pars_fragment:yU,shadowmap_pars_vertex:_U,shadowmap_vertex:xU,shadowmask_pars_fragment:SU,skinbase_vertex:MU,skinning_pars_vertex:EU,skinning_vertex:wU,skinnormal_vertex:TU,specularmap_fragment:AU,specularmap_pars_fragment:CU,tonemapping_fragment:RU,tonemapping_pars_fragment:bU,transmission_fragment:PU,transmission_pars_fragment:LU,uv_pars_fragment:IU,uv_pars_vertex:UU,uv_vertex:NU,worldpos_vertex:DU,background_vert:OU,background_frag:FU,backgroundCube_vert:zU,backgroundCube_frag:BU,cube_vert:kU,cube_frag:HU,depth_vert:VU,depth_frag:GU,distanceRGBA_vert:WU,distanceRGBA_frag:XU,equirect_vert:YU,equirect_frag:jU,linedashed_vert:qU,linedashed_frag:ZU,meshbasic_vert:KU,meshbasic_frag:QU,meshlambert_vert:JU,meshlambert_frag:$U,meshmatcap_vert:eN,meshmatcap_frag:tN,meshnormal_vert:nN,meshnormal_frag:iN,meshphong_vert:rN,meshphong_frag:sN,meshphysical_vert:oN,meshphysical_frag:aN,meshtoon_vert:lN,meshtoon_frag:uN,points_vert:cN,points_frag:fN,shadow_vert:hN,shadow_frag:dN,sprite_vert:pN,sprite_frag:mN},Ee={common:{diffuse:{value:new Ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xt}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xt},normalScale:{value:new oe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ue(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 Ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0},uvTransform:{value:new xt}},sprite:{diffuse:{value:new Ue(16777215)},opacity:{value:1},center:{value:new oe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}}},Lr={basic:{uniforms:gi([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.fog]),vertexShader:pt.meshbasic_vert,fragmentShader:pt.meshbasic_frag},lambert:{uniforms:gi([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ue(0)}}]),vertexShader:pt.meshlambert_vert,fragmentShader:pt.meshlambert_frag},phong:{uniforms:gi([Ee.common,Ee.specularmap,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,Ee.lights,{emissive:{value:new Ue(0)},specular:{value:new Ue(1118481)},shininess:{value:30}}]),vertexShader:pt.meshphong_vert,fragmentShader:pt.meshphong_frag},standard:{uniforms:gi([Ee.common,Ee.envmap,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.roughnessmap,Ee.metalnessmap,Ee.fog,Ee.lights,{emissive:{value:new Ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:pt.meshphysical_vert,fragmentShader:pt.meshphysical_frag},toon:{uniforms:gi([Ee.common,Ee.aomap,Ee.lightmap,Ee.emissivemap,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.gradientmap,Ee.fog,Ee.lights,{emissive:{value:new Ue(0)}}]),vertexShader:pt.meshtoon_vert,fragmentShader:pt.meshtoon_frag},matcap:{uniforms:gi([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,Ee.fog,{matcap:{value:null}}]),vertexShader:pt.meshmatcap_vert,fragmentShader:pt.meshmatcap_frag},points:{uniforms:gi([Ee.points,Ee.fog]),vertexShader:pt.points_vert,fragmentShader:pt.points_frag},dashed:{uniforms:gi([Ee.common,Ee.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:pt.linedashed_vert,fragmentShader:pt.linedashed_frag},depth:{uniforms:gi([Ee.common,Ee.displacementmap]),vertexShader:pt.depth_vert,fragmentShader:pt.depth_frag},normal:{uniforms:gi([Ee.common,Ee.bumpmap,Ee.normalmap,Ee.displacementmap,{opacity:{value:1}}]),vertexShader:pt.meshnormal_vert,fragmentShader:pt.meshnormal_frag},sprite:{uniforms:gi([Ee.sprite,Ee.fog]),vertexShader:pt.sprite_vert,fragmentShader:pt.sprite_frag},background:{uniforms:{uvTransform:{value:new xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:pt.background_vert,fragmentShader:pt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:pt.backgroundCube_vert,fragmentShader:pt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:pt.cube_vert,fragmentShader:pt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:pt.equirect_vert,fragmentShader:pt.equirect_frag},distanceRGBA:{uniforms:gi([Ee.common,Ee.displacementmap,{referencePosition:{value:new O},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:pt.distanceRGBA_vert,fragmentShader:pt.distanceRGBA_frag},shadow:{uniforms:gi([Ee.lights,Ee.fog,{color:{value:new Ue(0)},opacity:{value:1}}]),vertexShader:pt.shadow_vert,fragmentShader:pt.shadow_frag}};Lr.physical={uniforms:gi([Lr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xt},clearcoatNormalScale:{value:new oe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xt},sheen:{value:0},sheenColor:{value:new Ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xt},transmissionSamplerSize:{value:new oe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xt},attenuationDistance:{value:0},attenuationColor:{value:new Ue(0)},specularColor:{value:new Ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xt},anisotropyVector:{value:new oe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xt}}]),vertexShader:pt.meshphysical_vert,fragmentShader:pt.meshphysical_frag};const nd={r:0,b:0,g:0};function gN(n,e,t,i,r,s,o){const a=new Ue(0);let c=s===!0?0:1,f,h,d=null,m=0,v=null;function _(M,g){let x=!1,S=g.isScene===!0?g.background:null;S&&S.isTexture&&(S=(g.backgroundBlurriness>0?t:e).get(S)),S===null?E(a,c):S&&S.isColor&&(E(S,1),x=!0);const T=n.xr.getEnvironmentBlendMode();T==="additive"?i.buffers.color.setClear(0,0,0,1,o):T==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||x)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),S&&(S.isCubeTexture||S.mapping===iu)?(h===void 0&&(h=new wn(new Ea(1,1,1),new Gn({name:"BackgroundCubeMaterial",uniforms:Kl(Lr.backgroundCube.uniforms),vertexShader:Lr.backgroundCube.vertexShader,fragmentShader:Lr.backgroundCube.fragmentShader,side:bn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(L,R,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),h.material.uniforms.envMap.value=S,h.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,h.material.toneMapped=Bt.getTransfer(S.colorSpace)!==Wt,(d!==S||m!==S.version||v!==n.toneMapping)&&(h.material.needsUpdate=!0,d=S,m=S.version,v=n.toneMapping),h.layers.enableAll(),M.unshift(h,h.geometry,h.material,0,0,null)):S&&S.isTexture&&(f===void 0&&(f=new wn(new gf(2,2),new Gn({name:"BackgroundMaterial",uniforms:Kl(Lr.background.uniforms),vertexShader:Lr.background.vertexShader,fragmentShader:Lr.background.fragmentShader,side:ts,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),Object.defineProperty(f.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(f)),f.material.uniforms.t2D.value=S,f.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,f.material.toneMapped=Bt.getTransfer(S.colorSpace)!==Wt,S.matrixAutoUpdate===!0&&S.updateMatrix(),f.material.uniforms.uvTransform.value.copy(S.matrix),(d!==S||m!==S.version||v!==n.toneMapping)&&(f.material.needsUpdate=!0,d=S,m=S.version,v=n.toneMapping),f.layers.enableAll(),M.unshift(f,f.geometry,f.material,0,0,null))}function E(M,g){M.getRGB(nd,mC(n)),i.buffers.color.setClear(nd.r,nd.g,nd.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(M,g=1){a.set(M),c=g,E(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,E(a,c)},render:_}}function vN(n,e,t,i){const r=n.getParameter(n.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||s!==null,a={},c=M(null);let f=c,h=!1;function d(H,Z,$,ce,z){let G=!1;if(o){const V=E(ce,$,Z);f!==V&&(f=V,v(f.object)),G=g(H,ce,$,z),G&&x(H,ce,$,z)}else{const V=Z.wireframe===!0;(f.geometry!==ce.id||f.program!==$.id||f.wireframe!==V)&&(f.geometry=ce.id,f.program=$.id,f.wireframe=V,G=!0)}z!==null&&t.update(z,n.ELEMENT_ARRAY_BUFFER),(G||h)&&(h=!1,D(H,Z,$,ce),z!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.get(z).buffer))}function m(){return i.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function v(H){return i.isWebGL2?n.bindVertexArray(H):s.bindVertexArrayOES(H)}function _(H){return i.isWebGL2?n.deleteVertexArray(H):s.deleteVertexArrayOES(H)}function E(H,Z,$){const ce=$.wireframe===!0;let z=a[H.id];z===void 0&&(z={},a[H.id]=z);let G=z[Z.id];G===void 0&&(G={},z[Z.id]=G);let V=G[ce];return V===void 0&&(V=M(m()),G[ce]=V),V}function M(H){const Z=[],$=[],ce=[];for(let z=0;z=0){const ue=z[se];let Se=G[se];if(Se===void 0&&(se==="instanceMatrix"&&H.instanceMatrix&&(Se=H.instanceMatrix),se==="instanceColor"&&H.instanceColor&&(Se=H.instanceColor)),ue===void 0||ue.attribute!==Se||Se&&ue.data!==Se.data)return!0;V++}return f.attributesNum!==V||f.index!==ce}function x(H,Z,$,ce){const z={},G=Z.attributes;let V=0;const J=$.getAttributes();for(const se in J)if(J[se].location>=0){let ue=G[se];ue===void 0&&(se==="instanceMatrix"&&H.instanceMatrix&&(ue=H.instanceMatrix),se==="instanceColor"&&H.instanceColor&&(ue=H.instanceColor));const Se={};Se.attribute=ue,ue&&ue.data&&(Se.data=ue.data),z[se]=Se,V++}f.attributes=z,f.attributesNum=V,f.index=ce}function S(){const H=f.newAttributes;for(let Z=0,$=H.length;Z<$;Z++)H[Z]=0}function T(H){L(H,0)}function L(H,Z){const $=f.newAttributes,ce=f.enabledAttributes,z=f.attributeDivisors;$[H]=1,ce[H]===0&&(n.enableVertexAttribArray(H),ce[H]=1),z[H]!==Z&&((i.isWebGL2?n:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](H,Z),z[H]=Z)}function R(){const H=f.newAttributes,Z=f.enabledAttributes;for(let $=0,ce=Z.length;$=0){let K=z[J];if(K===void 0&&(J==="instanceMatrix"&&H.instanceMatrix&&(K=H.instanceMatrix),J==="instanceColor"&&H.instanceColor&&(K=H.instanceColor)),K!==void 0){const ue=K.normalized,Se=K.itemSize,Ce=t.get(K);if(Ce===void 0)continue;const Te=Ce.buffer,nt=Ce.type,rt=Ce.bytesPerElement,ke=i.isWebGL2===!0&&(nt===n.INT||nt===n.UNSIGNED_INT||K.gpuType===b_);if(K.isInterleavedBufferAttribute){const je=K.data,k=je.stride,ve=K.offset;if(je.isInstancedInterleavedBuffer){for(let he=0;he0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";P="mediump"}return P==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&n.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const c=s(a);c!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",c,"instead."),a=c);const f=o||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,d=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=n.getParameter(n.MAX_TEXTURE_SIZE),_=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),E=n.getParameter(n.MAX_VERTEX_ATTRIBS),M=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),g=n.getParameter(n.MAX_VARYING_VECTORS),x=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),S=m>0,T=o||e.has("OES_texture_float"),L=S&&T,R=o?n.getParameter(n.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:f,getMaxAnisotropy:r,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:_,maxAttributes:E,maxVertexUniforms:M,maxVaryings:g,maxFragmentUniforms:x,vertexTextures:S,floatFragmentTextures:T,floatVertexTextures:L,maxSamples:R}}function xN(n){const e=this;let t=null,i=0,r=!1,s=!1;const o=new Qs,a=new xt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,m){const v=d.length!==0||m||i!==0||r;return r=m,i=d.length,v},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,m){t=h(d,m,0)},this.setState=function(d,m,v){const _=d.clippingPlanes,E=d.clipIntersection,M=d.clipShadows,g=n.get(d);if(!r||_===null||_.length===0||s&&!M)s?h(null):f();else{const x=s?0:i,S=x*4;let T=g.clippingState||null;c.value=T,T=h(_,m,S,v);for(let L=0;L!==S;++L)T[L]=t[L];g.clippingState=T,this.numIntersection=E?this.numPlanes:0,this.numPlanes+=x}};function f(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(d,m,v,_){const E=d!==null?d.length:0;let M=null;if(E!==0){if(M=c.value,_!==!0||M===null){const g=v+E*4,x=m.matrixWorldInverse;a.getNormalMatrix(x),(M===null||M.length0){const f=new yC(c.height/2);return f.fromEquirectangularTexture(n,o),e.set(o,f),o.addEventListener("dispose",r),t(f.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class vf extends su{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,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=e,this.view.fullHeight=t,this.view.offsetX=i,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 e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,o=i+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){const f=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=f*this.view.offsetX,o=s+f*this.view.width,a-=h*this.view.offsetY,c=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Rl=4,S1=[.125,.215,.35,.446,.526,.582],Jo=20,yv=new vf,M1=new Ue;let _v=null,xv=0,Sv=0;const Qo=(1+Math.sqrt(5))/2,rl=1/Qo,E1=[new O(1,1,1),new O(-1,1,1),new O(1,1,-1),new O(-1,1,-1),new O(0,Qo,rl),new O(0,Qo,-rl),new O(rl,0,Qo),new O(-rl,0,Qo),new O(Qo,rl,0),new O(-Qo,rl,0)];class Sy{constructor(e){this._renderer=e,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(e,t=0,i=.1,r=100){_v=this._renderer.getRenderTarget(),xv=this._renderer.getActiveCubeFace(),Sv=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=A1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=T1(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?S:0,S,S),h.setRenderTarget(r),E&&h.render(_,a),h.render(e,a)}_.geometry.dispose(),_.material.dispose(),h.toneMapping=m,h.autoClear=d,e.background=M}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Rs||e.mapping===vo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=A1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=T1());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new wn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const c=this._cubeSize;id(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(o,yv)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;rJo&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${M} samples when the maximum is set to ${Jo}`);const g=[];let x=0;for(let P=0;PS-Rl?r-S+Rl:0),R=4*(this._cubeSize-T);id(t,L,R,3*T,2*T),c.setRenderTarget(t),c.render(d,yv)}}function MN(n){const e=[],t=[],i=[];let r=n;const s=n-Rl+1+S1.length;for(let o=0;on-Rl?c=S1[o-n+Rl-1]:o===0&&(c=0),i.push(c);const f=1/(a-2),h=-f,d=1+f,m=[h,h,d,h,d,d,h,h,d,d,h,d],v=6,_=6,E=3,M=2,g=1,x=new Float32Array(E*_*v),S=new Float32Array(M*_*v),T=new Float32Array(g*_*v);for(let R=0;R2?0:-1,C=[P,D,0,P+2/3,D,0,P+2/3,D+1,0,P,D,0,P+2/3,D+1,0,P,D+1,0];x.set(C,E*_*R),S.set(m,M*_*R);const b=[R,R,R,R,R,R];T.set(b,g*_*R)}const L=new vt;L.setAttribute("position",new Ft(x,E)),L.setAttribute("uv",new Ft(S,M)),L.setAttribute("faceIndex",new Ft(T,g)),e.push(L),r>Rl&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function w1(n,e,t){const i=new _n(n,e,t);return i.texture.mapping=iu,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function id(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function EN(n,e,t){const i=new Float32Array(Jo),r=new O(0,1,0);return new Gn({name:"SphericalGaussianBlur",defines:{n:Jo,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:X_(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:ci,depthTest:!1,depthWrite:!1})}function T1(){return new Gn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:X_(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:ci,depthTest:!1,depthWrite:!1})}function A1(){return new Gn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:X_(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:ci,depthTest:!1,depthWrite:!1})}function X_(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function wN(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const c=a.mapping,f=c===zc||c===Bc,h=c===Rs||c===vo;if(f||h)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let d=e.get(a);return t===null&&(t=new Sy(n)),d=f?t.fromEquirectangular(a,d):t.fromCubemap(a,d),e.set(a,d),d.texture}else{if(e.has(a))return e.get(a).texture;{const d=a.image;if(f&&d&&d.height>0||h&&d&&r(d)){t===null&&(t=new Sy(n));const m=f?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,m),a.addEventListener("dispose",s),m.texture}else return null}}}return a}function r(a){let c=0;const f=6;for(let h=0;he.maxTextureSize&&(B=Math.ceil(b/e.maxTextureSize),b=e.maxTextureSize);const j=new Float32Array(b*B*4*E),le=new Jp(j,b,B,E);le.type=mr,le.needsUpdate=!0;const H=C*4;for(let $=0;$0)return n;const r=e*t;let s=C1[r];if(s===void 0&&(s=new Float32Array(r),C1[r]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,n[o].toArray(s,a)}return s}function Ln(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t":" "} ${a}: ${t[o]}`)}return i.join(` `)}function AD(n){const e=Bt.getPrimaries(Bt.workingColorSpace),t=Bt.getPrimaries(n);let i;switch(e===t?i="":e===Yc&&t===Xc?i="LinearDisplayP3ToLinearSRGB":e===Xc&&t===Yc&&(i="LinearSRGBToLinearDisplayP3"),n){case _r:case hf:return[i,"LinearTransferOETF"];case At:case Qp:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function N1(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const o=parseInt(s[1]);return t.toUpperCase()+` `+r+` `+TD(n.getShaderSource(e),o)}else return r}function CD(n,e){const t=AD(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function RD(n,e){let t;switch(e){case HA:t="Linear";break;case VA:t="Reinhard";break;case GA:t="OptimizedCineon";break;case C_:t="ACESFilmic";break;case XA:t="AgX";break;case WA:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function bD(n){return[n.extensionDerivatives||n.envMapCubeUVHeight||n.bumpMap||n.normalMapTangentSpace||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(bl).join(` `)}function PD(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(bl).join(` `)}function LD(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function ID(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function My(n){return n.replace(UD,DD)}const ND=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function DD(n,e){let t=pt[e];if(t===void 0){const i=ND.get(e);if(i!==void 0)t=pt[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return My(t)}const OD=/#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 F1(n){return n.replace(OD,FD)}function FD(n,e,t,i){let r="";for(let s=parseInt(e);s0&&(g+=` `),x=[v,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,E].filter(bl).join(` `),x.length>0&&(x+=` `)):(g=[z1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,E,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","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","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(bl).join(` `),x=[v,z1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,E,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Dr?"#define TONE_MAPPING":"",t.toneMapping!==Dr?pt.tonemapping_pars_fragment:"",t.toneMapping!==Dr?RD("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",pt.colorspace_pars_fragment,CD("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(bl).join(` `)),o=My(o),o=D1(o,t),o=O1(o,t),a=My(a),a=D1(a,t),a=O1(a,t),o=F1(o),a=F1(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(S=`#version 300 es `,g=[_,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+g,x=["precision mediump sampler2DArray;","#define varying in",t.glslVersion===_y?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===_y?"":"#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(` `)+` `+x);const T=S+g+o,L=S+x+a,R=U1(r,r.VERTEX_SHADER,T),P=U1(r,r.FRAGMENT_SHADER,L);r.attachShader(M,R),r.attachShader(M,P),t.index0AttributeName!==void 0?r.bindAttribLocation(M,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(M,0,"position"),r.linkProgram(M);function D(j){if(n.debug.checkShaderErrors){const le=r.getProgramInfoLog(M).trim(),H=r.getShaderInfoLog(R).trim(),Z=r.getShaderInfoLog(P).trim();let $=!0,ce=!0;if(r.getProgramParameter(M,r.LINK_STATUS)===!1)if($=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,M,R,P);else{const z=N1(r,R,"vertex"),G=N1(r,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(M,r.VALIDATE_STATUS)+` Program Info Log: `+le+` `+z+` `+G)}else le!==""?console.warn("THREE.WebGLProgram: Program Info Log:",le):(H===""||Z==="")&&(ce=!1);ce&&(j.diagnostics={runnable:$,programLog:le,vertexShader:{log:H,prefix:g},fragmentShader:{log:Z,prefix:x}})}r.deleteShader(R),r.deleteShader(P),C=new Kd(r,M),b=ID(r,M)}let C;this.getUniforms=function(){return C===void 0&&D(this),C};let b;this.getAttributes=function(){return b===void 0&&D(this),b};let B=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return B===!1&&(B=r.getProgramParameter(M,ED)),B},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(M),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=wD++,this.cacheKey=e,this.usedTimes=1,this.program=M,this.vertexShader=R,this.fragmentShader=P,this}let WD=0;class XD{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new YD(e),t.set(e,i)),i}}class YD{constructor(e){this.id=WD++,this.code=e,this.usedTimes=0}}function jD(n,e,t,i,r,s,o){const a=new fa,c=new XD,f=[],h=r.isWebGL2,d=r.logarithmicDepthBuffer,m=r.vertexTextures;let v=r.precision;const _={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 E(C){return C===0?"uv":`uv${C}`}function M(C,b,B,j,le){const H=j.fog,Z=le.geometry,$=C.isMeshStandardMaterial?j.environment:null,ce=(C.isMeshStandardMaterial?t:e).get(C.envMap||$),z=ce&&ce.mapping===iu?ce.image.height:null,G=_[C.type];C.precision!==null&&(v=r.getMaxPrecision(C.precision),v!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",v,"instead."));const V=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,J=V!==void 0?V.length:0;let se=0;Z.morphAttributes.position!==void 0&&(se=1),Z.morphAttributes.normal!==void 0&&(se=2),Z.morphAttributes.color!==void 0&&(se=3);let K,ue,Se,Ce;if(G){const Un=Lr[G];K=Un.vertexShader,ue=Un.fragmentShader}else K=C.vertexShader,ue=C.fragmentShader,c.update(C),Se=c.getVertexShaderID(C),Ce=c.getFragmentShaderID(C);const Te=n.getRenderTarget(),nt=le.isInstancedMesh===!0,rt=le.isBatchedMesh===!0,ke=!!C.map,je=!!C.matcap,k=!!ce,ve=!!C.aoMap,he=!!C.lightMap,_e=!!C.bumpMap,fe=!!C.normalMap,Ye=!!C.displacementMap,Ie=!!C.emissiveMap,U=!!C.metalnessMap,I=!!C.roughnessMap,Q=C.anisotropy>0,ge=C.clearcoat>0,pe=C.iridescence>0,de=C.sheen>0,Ve=C.transmission>0,Ae=Q&&!!C.anisotropyMap,De=ge&&!!C.clearcoatMap,Qe=ge&&!!C.clearcoatNormalMap,ct=ge&&!!C.clearcoatRoughnessMap,me=pe&&!!C.iridescenceMap,Ct=pe&&!!C.iridescenceThicknessMap,St=de&&!!C.sheenColorMap,ot=de&&!!C.sheenRoughnessMap,qe=!!C.specularMap,Be=!!C.specularColorMap,dt=!!C.specularIntensityMap,Pt=Ve&&!!C.transmissionMap,Jt=Ve&&!!C.thicknessMap,yt=!!C.gradientMap,Me=!!C.alphaMap,W=C.alphaTest>0,Re=!!C.alphaHash,be=!!C.extensions,$e=!!Z.attributes.uv1,Ze=!!Z.attributes.uv2,Ht=!!Z.attributes.uv3;let zt=Dr;return C.toneMapped&&(Te===null||Te.isXRRenderTarget===!0)&&(zt=n.toneMapping),{isWebGL2:h,shaderID:G,shaderType:C.type,shaderName:C.name,vertexShader:K,fragmentShader:ue,defines:C.defines,customVertexShaderID:Se,customFragmentShaderID:Ce,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:v,batching:rt,instancing:nt,instancingColor:nt&&le.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:Te===null?n.outputColorSpace:Te.isXRRenderTarget===!0?Te.texture.colorSpace:_r,map:ke,matcap:je,envMap:k,envMapMode:k&&ce.mapping,envMapCubeUVHeight:z,aoMap:ve,lightMap:he,bumpMap:_e,normalMap:fe,displacementMap:m&&Ye,emissiveMap:Ie,normalMapObjectSpace:fe&&C.normalMapType===iC,normalMapTangentSpace:fe&&C.normalMapType===To,metalnessMap:U,roughnessMap:I,anisotropy:Q,anisotropyMap:Ae,clearcoat:ge,clearcoatMap:De,clearcoatNormalMap:Qe,clearcoatRoughnessMap:ct,iridescence:pe,iridescenceMap:me,iridescenceThicknessMap:Ct,sheen:de,sheenColorMap:St,sheenRoughnessMap:ot,specularMap:qe,specularColorMap:Be,specularIntensityMap:dt,transmission:Ve,transmissionMap:Pt,thicknessMap:Jt,gradientMap:yt,opaque:C.transparent===!1&&C.blending===ua,alphaMap:Me,alphaTest:W,alphaHash:Re,combine:C.combine,mapUv:ke&&E(C.map.channel),aoMapUv:ve&&E(C.aoMap.channel),lightMapUv:he&&E(C.lightMap.channel),bumpMapUv:_e&&E(C.bumpMap.channel),normalMapUv:fe&&E(C.normalMap.channel),displacementMapUv:Ye&&E(C.displacementMap.channel),emissiveMapUv:Ie&&E(C.emissiveMap.channel),metalnessMapUv:U&&E(C.metalnessMap.channel),roughnessMapUv:I&&E(C.roughnessMap.channel),anisotropyMapUv:Ae&&E(C.anisotropyMap.channel),clearcoatMapUv:De&&E(C.clearcoatMap.channel),clearcoatNormalMapUv:Qe&&E(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ct&&E(C.clearcoatRoughnessMap.channel),iridescenceMapUv:me&&E(C.iridescenceMap.channel),iridescenceThicknessMapUv:Ct&&E(C.iridescenceThicknessMap.channel),sheenColorMapUv:St&&E(C.sheenColorMap.channel),sheenRoughnessMapUv:ot&&E(C.sheenRoughnessMap.channel),specularMapUv:qe&&E(C.specularMap.channel),specularColorMapUv:Be&&E(C.specularColorMap.channel),specularIntensityMapUv:dt&&E(C.specularIntensityMap.channel),transmissionMapUv:Pt&&E(C.transmissionMap.channel),thicknessMapUv:Jt&&E(C.thicknessMap.channel),alphaMapUv:Me&&E(C.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(fe||Q),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,vertexUv1s:$e,vertexUv2s:Ze,vertexUv3s:Ht,pointsUvs:le.isPoints===!0&&!!Z.attributes.uv&&(ke||Me),fog:!!H,useFog:C.fog===!0,fogExp2:H&&H.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:le.isSkinnedMesh===!0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:J,morphTextureStride:se,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:n.shadowMap.enabled&&B.length>0,shadowMapType:n.shadowMap.type,toneMapping:zt,useLegacyLights:n._useLegacyLights,decodeVideoTexture:ke&&C.map.isVideoTexture===!0&&Bt.getTransfer(C.map.colorSpace)===Wt,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===yi,flipSided:C.side===bn,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:be&&C.extensions.derivatives===!0,extensionFragDepth:be&&C.extensions.fragDepth===!0,extensionDrawBuffers:be&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:be&&C.extensions.shaderTextureLOD===!0,extensionClipCullDistance:be&&C.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()}}function g(C){const b=[];if(C.shaderID?b.push(C.shaderID):(b.push(C.customVertexShaderID),b.push(C.customFragmentShaderID)),C.defines!==void 0)for(const B in C.defines)b.push(B),b.push(C.defines[B]);return C.isRawShaderMaterial===!1&&(x(b,C),S(b,C),b.push(n.outputColorSpace)),b.push(C.customProgramCacheKey),b.join()}function x(C,b){C.push(b.precision),C.push(b.outputColorSpace),C.push(b.envMapMode),C.push(b.envMapCubeUVHeight),C.push(b.mapUv),C.push(b.alphaMapUv),C.push(b.lightMapUv),C.push(b.aoMapUv),C.push(b.bumpMapUv),C.push(b.normalMapUv),C.push(b.displacementMapUv),C.push(b.emissiveMapUv),C.push(b.metalnessMapUv),C.push(b.roughnessMapUv),C.push(b.anisotropyMapUv),C.push(b.clearcoatMapUv),C.push(b.clearcoatNormalMapUv),C.push(b.clearcoatRoughnessMapUv),C.push(b.iridescenceMapUv),C.push(b.iridescenceThicknessMapUv),C.push(b.sheenColorMapUv),C.push(b.sheenRoughnessMapUv),C.push(b.specularMapUv),C.push(b.specularColorMapUv),C.push(b.specularIntensityMapUv),C.push(b.transmissionMapUv),C.push(b.thicknessMapUv),C.push(b.combine),C.push(b.fogExp2),C.push(b.sizeAttenuation),C.push(b.morphTargetsCount),C.push(b.morphAttributeCount),C.push(b.numDirLights),C.push(b.numPointLights),C.push(b.numSpotLights),C.push(b.numSpotLightMaps),C.push(b.numHemiLights),C.push(b.numRectAreaLights),C.push(b.numDirLightShadows),C.push(b.numPointLightShadows),C.push(b.numSpotLightShadows),C.push(b.numSpotLightShadowsWithMaps),C.push(b.numLightProbes),C.push(b.shadowMapType),C.push(b.toneMapping),C.push(b.numClippingPlanes),C.push(b.numClipIntersection),C.push(b.depthPacking)}function S(C,b){a.disableAll(),b.isWebGL2&&a.enable(0),b.supportsVertexTextures&&a.enable(1),b.instancing&&a.enable(2),b.instancingColor&&a.enable(3),b.matcap&&a.enable(4),b.envMap&&a.enable(5),b.normalMapObjectSpace&&a.enable(6),b.normalMapTangentSpace&&a.enable(7),b.clearcoat&&a.enable(8),b.iridescence&&a.enable(9),b.alphaTest&&a.enable(10),b.vertexColors&&a.enable(11),b.vertexAlphas&&a.enable(12),b.vertexUv1s&&a.enable(13),b.vertexUv2s&&a.enable(14),b.vertexUv3s&&a.enable(15),b.vertexTangents&&a.enable(16),b.anisotropy&&a.enable(17),b.alphaHash&&a.enable(18),b.batching&&a.enable(19),C.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.skinning&&a.enable(4),b.morphTargets&&a.enable(5),b.morphNormals&&a.enable(6),b.morphColors&&a.enable(7),b.premultipliedAlpha&&a.enable(8),b.shadowMapEnabled&&a.enable(9),b.useLegacyLights&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),C.push(a.mask)}function T(C){const b=_[C.type];let B;if(b){const j=Lr[b];B=gC.clone(j.uniforms)}else B=C.uniforms;return B}function L(C,b){let B;for(let j=0,le=f.length;j0?i.push(g):v.transparent===!0?r.push(g):t.push(g)}function c(d,m,v,_,E,M){const g=o(d,m,v,_,E,M);v.transmission>0?i.unshift(g):v.transparent===!0?r.unshift(g):t.unshift(g)}function f(d,m){t.length>1&&t.sort(d||ZD),i.length>1&&i.sort(m||B1),r.length>1&&r.sort(m||B1)}function h(){for(let d=e,m=n.length;d=s.length?(o=new k1,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function QD(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new O,color:new Ue};break;case"SpotLight":t={position:new O,direction:new O,color:new Ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new O,color:new Ue,distance:0,decay:0};break;case"HemisphereLight":t={direction:new O,skyColor:new Ue,groundColor:new Ue};break;case"RectAreaLight":t={color:new Ue,position:new O,halfWidth:new O,halfHeight:new O};break}return n[e.id]=t,t}}}function JD(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new oe,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let $D=0;function eO(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function tO(n,e){const t=new QD,i=JD(),r={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 h=0;h<9;h++)r.probe.push(new O);const s=new O,o=new it,a=new it;function c(h,d){let m=0,v=0,_=0;for(let j=0;j<9;j++)r.probe[j].set(0,0,0);let E=0,M=0,g=0,x=0,S=0,T=0,L=0,R=0,P=0,D=0,C=0;h.sort(eO);const b=d===!0?Math.PI:1;for(let j=0,le=h.length;j0&&(e.isWebGL2?n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ee.LTC_FLOAT_1,r.rectAreaLTC2=Ee.LTC_FLOAT_2):(r.rectAreaLTC1=Ee.LTC_HALF_1,r.rectAreaLTC2=Ee.LTC_HALF_2):n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ee.LTC_FLOAT_1,r.rectAreaLTC2=Ee.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=Ee.LTC_HALF_1,r.rectAreaLTC2=Ee.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=m,r.ambient[1]=v,r.ambient[2]=_;const B=r.hash;(B.directionalLength!==E||B.pointLength!==M||B.spotLength!==g||B.rectAreaLength!==x||B.hemiLength!==S||B.numDirectionalShadows!==T||B.numPointShadows!==L||B.numSpotShadows!==R||B.numSpotMaps!==P||B.numLightProbes!==C)&&(r.directional.length=E,r.spot.length=g,r.rectArea.length=x,r.point.length=M,r.hemi.length=S,r.directionalShadow.length=T,r.directionalShadowMap.length=T,r.pointShadow.length=L,r.pointShadowMap.length=L,r.spotShadow.length=R,r.spotShadowMap.length=R,r.directionalShadowMatrix.length=T,r.pointShadowMatrix.length=L,r.spotLightMatrix.length=R+P-D,r.spotLightMap.length=P,r.numSpotLightShadowsWithMaps=D,r.numLightProbes=C,B.directionalLength=E,B.pointLength=M,B.spotLength=g,B.rectAreaLength=x,B.hemiLength=S,B.numDirectionalShadows=T,B.numPointShadows=L,B.numSpotShadows=R,B.numSpotMaps=P,B.numLightProbes=C,r.version=$D++)}function f(h,d){let m=0,v=0,_=0,E=0,M=0;const g=d.matrixWorldInverse;for(let x=0,S=h.length;x=a.length?(c=new H1(n,e),a.push(c)):c=a[o],c}function r(){t=new WeakMap}return{get:i,dispose:r}}class Y_ extends Wn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=wo,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class j_ extends Wn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const iO=`void main() { gl_Position = vec4( position, 1.0 ); }`,rO=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function sO(n,e,t){let i=new mf;const r=new oe,s=new oe,o=new Ot,a=new Y_({depthPacking:nC}),c=new j_,f={},h=t.maxTextureSize,d={[ts]:bn,[bn]:ts,[yi]:yi},m=new Gn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new oe},radius:{value:4}},vertexShader:iO,fragmentShader:rO}),v=m.clone();v.defines.HORIZONTAL_PASS=1;const _=new vt;_.setAttribute("position",new Ft(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const E=new wn(_,m),M=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Yp;let g=this.type;this.render=function(R,P,D){if(M.enabled===!1||M.autoUpdate===!1&&M.needsUpdate===!1||R.length===0)return;const C=n.getRenderTarget(),b=n.getActiveCubeFace(),B=n.getActiveMipmapLevel(),j=n.state;j.setBlending(ci),j.buffers.color.setClear(1,1,1,1),j.buffers.depth.setTest(!0),j.setScissorTest(!1);const le=g!==Rr&&this.type===Rr,H=g===Rr&&this.type!==Rr;for(let Z=0,$=R.length;Z<$;Z++){const ce=R[Z],z=ce.shadow;if(z===void 0){console.warn("THREE.WebGLShadowMap:",ce,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;r.copy(z.mapSize);const G=z.getFrameExtents();if(r.multiply(G),s.copy(z.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/G.x),r.x=s.x*G.x,z.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/G.y),r.y=s.y*G.y,z.mapSize.y=s.y)),z.map===null||le===!0||H===!0){const J=this.type!==Rr?{minFilter:Xt,magFilter:Xt}:{};z.map!==null&&z.map.dispose(),z.map=new _n(r.x,r.y,J),z.map.texture.name=ce.name+".shadowMap",z.camera.updateProjectionMatrix()}n.setRenderTarget(z.map),n.clear();const V=z.getViewportCount();for(let J=0;J0||P.map&&P.alphaTest>0){const j=b.uuid,le=P.uuid;let H=f[j];H===void 0&&(H={},f[j]=H);let Z=H[le];Z===void 0&&(Z=b.clone(),H[le]=Z,P.addEventListener("dispose",L)),b=Z}if(b.visible=P.visible,b.wireframe=P.wireframe,C===Rr?b.side=P.shadowSide!==null?P.shadowSide:P.side:b.side=P.shadowSide!==null?P.shadowSide:d[P.side],b.alphaMap=P.alphaMap,b.alphaTest=P.alphaTest,b.map=P.map,b.clipShadows=P.clipShadows,b.clippingPlanes=P.clippingPlanes,b.clipIntersection=P.clipIntersection,b.displacementMap=P.displacementMap,b.displacementScale=P.displacementScale,b.displacementBias=P.displacementBias,b.wireframeLinewidth=P.wireframeLinewidth,b.linewidth=P.linewidth,D.isPointLight===!0&&b.isMeshDistanceMaterial===!0){const j=n.properties.get(b);j.light=D}return b}function T(R,P,D,C,b){if(R.visible===!1)return;if(R.layers.test(P.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&b===Rr)&&(!R.frustumCulled||i.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,R.matrixWorld);const le=e.update(R),H=R.material;if(Array.isArray(H)){const Z=le.groups;for(let $=0,ce=Z.length;$=1):V.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),z=G>=2);let J=null,se={};const K=n.getParameter(n.SCISSOR_BOX),ue=n.getParameter(n.VIEWPORT),Se=new Ot().fromArray(K),Ce=new Ot().fromArray(ue);function Te(W,Re,be,$e){const Ze=new Uint8Array(4),Ht=n.createTexture();n.bindTexture(W,Ht),n.texParameteri(W,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(W,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let zt=0;zt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new WeakMap;let d;const m=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(U,I){return v?new OffscreenCanvas(U,I):qc("canvas")}function E(U,I,Q,ge){let pe=1;if((U.width>ge||U.height>ge)&&(pe=ge/Math.max(U.width,U.height)),pe<1||I===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const de=I?Cp:Math.floor,Ve=de(pe*U.width),Ae=de(pe*U.height);d===void 0&&(d=_(Ve,Ae));const De=Q?_(Ve,Ae):d;return De.width=Ve,De.height=Ae,De.getContext("2d").drawImage(U,0,0,Ve,Ae),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+Ve+"x"+Ae+")."),De}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function M(U){return xy(U.width)&&xy(U.height)}function g(U){return a?!1:U.wrapS!==li||U.wrapT!==li||U.minFilter!==Xt&&U.minFilter!==Kt}function x(U,I){return U.generateMipmaps&&I&&U.minFilter!==Xt&&U.minFilter!==Kt}function S(U){n.generateMipmap(U)}function T(U,I,Q,ge,pe=!1){if(a===!1)return I;if(U!==null){if(n[U]!==void 0)return n[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let de=I;if(I===n.RED&&(Q===n.FLOAT&&(de=n.R32F),Q===n.HALF_FLOAT&&(de=n.R16F),Q===n.UNSIGNED_BYTE&&(de=n.R8)),I===n.RED_INTEGER&&(Q===n.UNSIGNED_BYTE&&(de=n.R8UI),Q===n.UNSIGNED_SHORT&&(de=n.R16UI),Q===n.UNSIGNED_INT&&(de=n.R32UI),Q===n.BYTE&&(de=n.R8I),Q===n.SHORT&&(de=n.R16I),Q===n.INT&&(de=n.R32I)),I===n.RG&&(Q===n.FLOAT&&(de=n.RG32F),Q===n.HALF_FLOAT&&(de=n.RG16F),Q===n.UNSIGNED_BYTE&&(de=n.RG8)),I===n.RGBA){const Ve=pe?Wc:Bt.getTransfer(ge);Q===n.FLOAT&&(de=n.RGBA32F),Q===n.HALF_FLOAT&&(de=n.RGBA16F),Q===n.UNSIGNED_BYTE&&(de=Ve===Wt?n.SRGB8_ALPHA8:n.RGBA8),Q===n.UNSIGNED_SHORT_4_4_4_4&&(de=n.RGBA4),Q===n.UNSIGNED_SHORT_5_5_5_1&&(de=n.RGB5_A1)}return(de===n.R16F||de===n.R32F||de===n.RG16F||de===n.RG32F||de===n.RGBA16F||de===n.RGBA32F)&&e.get("EXT_color_buffer_float"),de}function L(U,I,Q){return x(U,Q)===!0||U.isFramebufferTexture&&U.minFilter!==Xt&&U.minFilter!==Kt?Math.log2(Math.max(I.width,I.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?I.mipmaps.length:1}function R(U){return U===Xt||U===Tp||U===pc?n.NEAREST:n.LINEAR}function P(U){const I=U.target;I.removeEventListener("dispose",P),C(I),I.isVideoTexture&&h.delete(I)}function D(U){const I=U.target;I.removeEventListener("dispose",D),B(I)}function C(U){const I=i.get(U);if(I.__webglInit===void 0)return;const Q=U.source,ge=m.get(Q);if(ge){const pe=ge[I.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&b(U),Object.keys(ge).length===0&&m.delete(Q)}i.remove(U)}function b(U){const I=i.get(U);n.deleteTexture(I.__webglTexture);const Q=U.source,ge=m.get(Q);delete ge[I.__cacheKey],o.memory.textures--}function B(U){const I=U.texture,Q=i.get(U),ge=i.get(I);if(ge.__webglTexture!==void 0&&(n.deleteTexture(ge.__webglTexture),o.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++){if(Array.isArray(Q.__webglFramebuffer[pe]))for(let de=0;de=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+r.maxTextures),j+=1,U}function Z(U){const I=[];return I.push(U.wrapS),I.push(U.wrapT),I.push(U.wrapR||0),I.push(U.magFilter),I.push(U.minFilter),I.push(U.anisotropy),I.push(U.internalFormat),I.push(U.format),I.push(U.type),I.push(U.generateMipmaps),I.push(U.premultiplyAlpha),I.push(U.flipY),I.push(U.unpackAlignment),I.push(U.colorSpace),I.join()}function $(U,I){const Q=i.get(U);if(U.isVideoTexture&&Ye(U),U.isRenderTargetTexture===!1&&U.version>0&&Q.__version!==U.version){const ge=U.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Se(Q,U,I);return}}t.bindTexture(n.TEXTURE_2D,Q.__webglTexture,n.TEXTURE0+I)}function ce(U,I){const Q=i.get(U);if(U.version>0&&Q.__version!==U.version){Se(Q,U,I);return}t.bindTexture(n.TEXTURE_2D_ARRAY,Q.__webglTexture,n.TEXTURE0+I)}function z(U,I){const Q=i.get(U);if(U.version>0&&Q.__version!==U.version){Se(Q,U,I);return}t.bindTexture(n.TEXTURE_3D,Q.__webglTexture,n.TEXTURE0+I)}function G(U,I){const Q=i.get(U);if(U.version>0&&Q.__version!==U.version){Ce(Q,U,I);return}t.bindTexture(n.TEXTURE_CUBE_MAP,Q.__webglTexture,n.TEXTURE0+I)}const V={[jl]:n.REPEAT,[li]:n.CLAMP_TO_EDGE,[kc]:n.MIRRORED_REPEAT},J={[Xt]:n.NEAREST,[Tp]:n.NEAREST_MIPMAP_NEAREST,[pc]:n.NEAREST_MIPMAP_LINEAR,[Kt]:n.LINEAR,[R_]:n.LINEAR_MIPMAP_NEAREST,[yo]:n.LINEAR_MIPMAP_LINEAR},se={[rC]:n.NEVER,[cC]:n.ALWAYS,[sC]:n.LESS,[B_]:n.LEQUAL,[oC]:n.EQUAL,[uC]:n.GEQUAL,[aC]:n.GREATER,[lC]:n.NOTEQUAL};function K(U,I,Q){if(Q?(n.texParameteri(U,n.TEXTURE_WRAP_S,V[I.wrapS]),n.texParameteri(U,n.TEXTURE_WRAP_T,V[I.wrapT]),(U===n.TEXTURE_3D||U===n.TEXTURE_2D_ARRAY)&&n.texParameteri(U,n.TEXTURE_WRAP_R,V[I.wrapR]),n.texParameteri(U,n.TEXTURE_MAG_FILTER,J[I.magFilter]),n.texParameteri(U,n.TEXTURE_MIN_FILTER,J[I.minFilter])):(n.texParameteri(U,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(U,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),(U===n.TEXTURE_3D||U===n.TEXTURE_2D_ARRAY)&&n.texParameteri(U,n.TEXTURE_WRAP_R,n.CLAMP_TO_EDGE),(I.wrapS!==li||I.wrapT!==li)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(U,n.TEXTURE_MAG_FILTER,R(I.magFilter)),n.texParameteri(U,n.TEXTURE_MIN_FILTER,R(I.minFilter)),I.minFilter!==Xt&&I.minFilter!==Kt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),I.compareFunction&&(n.texParameteri(U,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(U,n.TEXTURE_COMPARE_FUNC,se[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ge=e.get("EXT_texture_filter_anisotropic");if(I.magFilter===Xt||I.minFilter!==pc&&I.minFilter!==yo||I.type===mr&&e.has("OES_texture_float_linear")===!1||a===!1&&I.type===ya&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||i.get(I).__currentAnisotropy)&&(n.texParameterf(U,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,r.getMaxAnisotropy())),i.get(I).__currentAnisotropy=I.anisotropy)}}function ue(U,I){let Q=!1;U.__webglInit===void 0&&(U.__webglInit=!0,I.addEventListener("dispose",P));const ge=I.source;let pe=m.get(ge);pe===void 0&&(pe={},m.set(ge,pe));const de=Z(I);if(de!==U.__cacheKey){pe[de]===void 0&&(pe[de]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,Q=!0),pe[de].usedTimes++;const Ve=pe[U.__cacheKey];Ve!==void 0&&(pe[U.__cacheKey].usedTimes--,Ve.usedTimes===0&&b(I)),U.__cacheKey=de,U.__webglTexture=pe[de].texture}return Q}function Se(U,I,Q){let ge=n.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ge=n.TEXTURE_2D_ARRAY),I.isData3DTexture&&(ge=n.TEXTURE_3D);const pe=ue(U,I),de=I.source;t.bindTexture(ge,U.__webglTexture,n.TEXTURE0+Q);const Ve=i.get(de);if(de.version!==Ve.__version||pe===!0){t.activeTexture(n.TEXTURE0+Q);const Ae=Bt.getPrimaries(Bt.workingColorSpace),De=I.colorSpace===_i?null:Bt.getPrimaries(I.colorSpace),Qe=I.colorSpace===_i||Ae===De?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,I.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,I.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Qe);const ct=g(I)&&M(I.image)===!1;let me=E(I.image,ct,!1,r.maxTextureSize);me=Ie(I,me);const Ct=M(me)||a,St=s.convert(I.format,I.colorSpace);let ot=s.convert(I.type),qe=T(I.internalFormat,St,ot,I.colorSpace,I.isVideoTexture);K(ge,I,Ct);let Be;const dt=I.mipmaps,Pt=a&&I.isVideoTexture!==!0&&qe!==O_,Jt=Ve.__version===void 0||pe===!0,yt=L(I,me,Ct);if(I.isDepthTexture)qe=n.DEPTH_COMPONENT,a?I.type===mr?qe=n.DEPTH_COMPONENT32F:I.type===Qr?qe=n.DEPTH_COMPONENT24:I.type===Ms?qe=n.DEPTH24_STENCIL8:qe=n.DEPTH_COMPONENT16:I.type===mr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===fo&&qe===n.DEPTH_COMPONENT&&I.type!==qp&&I.type!==Qr&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Qr,ot=s.convert(I.type)),I.format===_o&&qe===n.DEPTH_COMPONENT&&(qe=n.DEPTH_STENCIL,I.type!==Ms&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Ms,ot=s.convert(I.type))),Jt&&(Pt?t.texStorage2D(n.TEXTURE_2D,1,qe,me.width,me.height):t.texImage2D(n.TEXTURE_2D,0,qe,me.width,me.height,0,St,ot,null));else if(I.isDataTexture)if(dt.length>0&&Ct){Pt&&Jt&&t.texStorage2D(n.TEXTURE_2D,yt,qe,dt[0].width,dt[0].height);for(let Me=0,W=dt.length;Me>=1,W>>=1}}else if(dt.length>0&&Ct){Pt&&Jt&&t.texStorage2D(n.TEXTURE_2D,yt,qe,dt[0].width,dt[0].height);for(let Me=0,W=dt.length;Me0&&Jt++,t.texStorage2D(n.TEXTURE_CUBE_MAP,Jt,Be,me[0].width,me[0].height));for(let Me=0;Me<6;Me++)if(ct){dt?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,me[Me].width,me[Me].height,ot,qe,me[Me].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,Be,me[Me].width,me[Me].height,0,ot,qe,me[Me].data);for(let W=0;W>de),me=Math.max(1,I.height>>de);pe===n.TEXTURE_3D||pe===n.TEXTURE_2D_ARRAY?t.texImage3D(pe,de,De,ct,me,I.depth,0,Ve,Ae,null):t.texImage2D(pe,de,De,ct,me,0,Ve,Ae,null)}t.bindFramebuffer(n.FRAMEBUFFER,U),fe(I)?c.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ge,pe,i.get(Q).__webglTexture,0,_e(I)):(pe===n.TEXTURE_2D||pe>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&pe<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ge,pe,i.get(Q).__webglTexture,de),t.bindFramebuffer(n.FRAMEBUFFER,null)}function nt(U,I,Q){if(n.bindRenderbuffer(n.RENDERBUFFER,U),I.depthBuffer&&!I.stencilBuffer){let ge=a===!0?n.DEPTH_COMPONENT24:n.DEPTH_COMPONENT16;if(Q||fe(I)){const pe=I.depthTexture;pe&&pe.isDepthTexture&&(pe.type===mr?ge=n.DEPTH_COMPONENT32F:pe.type===Qr&&(ge=n.DEPTH_COMPONENT24));const de=_e(I);fe(I)?c.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,de,ge,I.width,I.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,de,ge,I.width,I.height)}else n.renderbufferStorage(n.RENDERBUFFER,ge,I.width,I.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,U)}else if(I.depthBuffer&&I.stencilBuffer){const ge=_e(I);Q&&fe(I)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ge,n.DEPTH24_STENCIL8,I.width,I.height):fe(I)?c.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ge,n.DEPTH24_STENCIL8,I.width,I.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,I.width,I.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,U)}else{const ge=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let pe=0;pe0){Q.__webglFramebuffer[Ae]=[];for(let De=0;De0){Q.__webglFramebuffer=[];for(let Ae=0;Ae0&&fe(U)===!1){const Ae=de?I:[I];Q.__webglMultisampledFramebuffer=n.createFramebuffer(),Q.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,Q.__webglMultisampledFramebuffer);for(let De=0;De0)for(let De=0;De0)for(let De=0;De0&&fe(U)===!1){const I=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],Q=U.width,ge=U.height;let pe=n.COLOR_BUFFER_BIT;const de=[],Ve=U.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ae=i.get(U),De=U.isWebGLMultipleRenderTargets===!0;if(De)for(let Qe=0;Qe0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Ye(U){const I=o.render.frame;h.get(U)!==I&&(h.set(U,I),U.update())}function Ie(U,I){const Q=U.colorSpace,ge=U.format,pe=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===Ap||Q!==_r&&Q!==_i&&(Bt.getTransfer(Q)===Wt?a===!1?e.has("EXT_sRGB")===!0&&ge===Hn?(U.format=Ap,U.minFilter=Kt,U.generateMipmaps=!1):I=H_.sRGBToLinear(I):(ge!==Hn||pe!==Pn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Q)),I}this.allocateTextureUnit=H,this.resetTextureUnits=le,this.setTexture2D=$,this.setTexture2DArray=ce,this.setTexture3D=z,this.setTextureCube=G,this.rebindTextures=je,this.setupRenderTarget=k,this.updateRenderTargetMipmap=ve,this.updateMultisampleRenderTarget=he,this.setupDepthRenderbuffer=ke,this.setupFrameBufferTexture=Te,this.useMultisampledRTT=fe}function TC(n,e,t){const i=t.isWebGL2;function r(s,o=_i){let a;const c=Bt.getTransfer(o);if(s===Pn)return n.UNSIGNED_BYTE;if(s===P_)return n.UNSIGNED_SHORT_4_4_4_4;if(s===L_)return n.UNSIGNED_SHORT_5_5_5_1;if(s===jA)return n.BYTE;if(s===qA)return n.SHORT;if(s===qp)return n.UNSIGNED_SHORT;if(s===b_)return n.INT;if(s===Qr)return n.UNSIGNED_INT;if(s===mr)return n.FLOAT;if(s===ya)return i?n.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===ZA)return n.ALPHA;if(s===Hn)return n.RGBA;if(s===KA)return n.LUMINANCE;if(s===QA)return n.LUMINANCE_ALPHA;if(s===fo)return n.DEPTH_COMPONENT;if(s===_o)return n.DEPTH_STENCIL;if(s===Ap)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Zp)return n.RED;if(s===I_)return n.RED_INTEGER;if(s===U_)return n.RG;if(s===N_)return n.RG_INTEGER;if(s===D_)return n.RGBA_INTEGER;if(s===Wd||s===Xd||s===Yd||s===jd)if(c===Wt)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Wd)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Xd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Yd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===jd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Wd)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Xd)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Yd)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===jd)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===j0||s===q0||s===Z0||s===K0)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===j0)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===q0)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Z0)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===K0)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===O_)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Q0||s===J0)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Q0)return c===Wt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===J0)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===$0||s===ey||s===ty||s===ny||s===iy||s===ry||s===sy||s===oy||s===ay||s===ly||s===uy||s===cy||s===fy||s===hy)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===$0)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===ey)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===ty)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ny)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===iy)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===ry)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===sy)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===oy)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===ay)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===ly)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===uy)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===cy)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===fy)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===hy)return c===Wt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===qd||s===dy||s===py)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===qd)return c===Wt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===dy)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===py)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===JA||s===my||s===gy||s===vy)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===qd)return a.COMPRESSED_RED_RGTC1_EXT;if(s===my)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===gy)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===vy)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Ms?i?n.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:r}}class AC extends Cn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Pl extends Dt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const lO={type:"move"};class Ev{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Pl,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 Pl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new O,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new O),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Pl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new O,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new O),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null;const a=this._targetRay,c=this._grip,f=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(f&&e.hand){o=!0;for(const E of e.hand.values()){const M=t.getJointPose(E,i),g=this._getHandJoint(f,E);M!==null&&(g.matrix.fromArray(M.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=M.radius),g.visible=M!==null}const h=f.joints["index-finger-tip"],d=f.joints["thumb-tip"],m=h.position.distanceTo(d.position),v=.02,_=.005;f.inputState.pinching&&m>v+_?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!f.inputState.pinching&&m<=v-_&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),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=t.getPose(e.targetRaySpace,i),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(lO)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),f!==null&&(f.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Pl;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class uO extends xr{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",c=1,f=null,h=null,d=null,m=null,v=null,_=null;const E=t.getContextAttributes();let M=null,g=null;const x=[],S=[],T=new oe;let L=null;const R=new Cn;R.layers.enable(1),R.viewport=new Ot;const P=new Cn;P.layers.enable(2),P.viewport=new Ot;const D=[R,P],C=new AC;C.layers.enable(1),C.layers.enable(2);let b=null,B=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let ue=x[K];return ue===void 0&&(ue=new Ev,x[K]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(K){let ue=x[K];return ue===void 0&&(ue=new Ev,x[K]=ue),ue.getGripSpace()},this.getHand=function(K){let ue=x[K];return ue===void 0&&(ue=new Ev,x[K]=ue),ue.getHandSpace()};function j(K){const ue=S.indexOf(K.inputSource);if(ue===-1)return;const Se=x[ue];Se!==void 0&&(Se.update(K.inputSource,K.frame,f||o),Se.dispatchEvent({type:K.type,data:K.inputSource}))}function le(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",le),r.removeEventListener("inputsourceschange",H);for(let K=0;K=0&&(S[Ce]=null,x[Ce].disconnect(Se))}for(let ue=0;ue=S.length){S.push(Se),Ce=nt;break}else if(S[nt]===null){S[nt]=Se,Ce=nt;break}if(Ce===-1)break}const Te=x[Ce];Te&&Te.connect(Se)}}const Z=new O,$=new O;function ce(K,ue,Se){Z.setFromMatrixPosition(ue.matrixWorld),$.setFromMatrixPosition(Se.matrixWorld);const Ce=Z.distanceTo($),Te=ue.projectionMatrix.elements,nt=Se.projectionMatrix.elements,rt=Te[14]/(Te[10]-1),ke=Te[14]/(Te[10]+1),je=(Te[9]+1)/Te[5],k=(Te[9]-1)/Te[5],ve=(Te[8]-1)/Te[0],he=(nt[8]+1)/nt[0],_e=rt*ve,fe=rt*he,Ye=Ce/(-ve+he),Ie=Ye*-ve;ue.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Ie),K.translateZ(Ye),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert();const U=rt+Ye,I=ke+Ye,Q=_e-Ie,ge=fe+(Ce-Ie),pe=je*ke/I*U,de=k*ke/I*U;K.projectionMatrix.makePerspective(Q,ge,pe,de,U,I),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}function z(K,ue){ue===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(ue.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(r===null)return;C.near=P.near=R.near=K.near,C.far=P.far=R.far=K.far,(b!==C.near||B!==C.far)&&(r.updateRenderState({depthNear:C.near,depthFar:C.far}),b=C.near,B=C.far);const ue=K.parent,Se=C.cameras;z(C,ue);for(let Ce=0;Ce0&&(M.alphaTest.value=g.alphaTest);const x=e.get(g).envMap;if(x&&(M.envMap.value=x,M.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,M.reflectivity.value=g.reflectivity,M.ior.value=g.ior,M.refractionRatio.value=g.refractionRatio),g.lightMap){M.lightMap.value=g.lightMap;const S=n._useLegacyLights===!0?Math.PI:1;M.lightMapIntensity.value=g.lightMapIntensity*S,t(g.lightMap,M.lightMapTransform)}g.aoMap&&(M.aoMap.value=g.aoMap,M.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,M.aoMapTransform))}function o(M,g){M.diffuse.value.copy(g.color),M.opacity.value=g.opacity,g.map&&(M.map.value=g.map,t(g.map,M.mapTransform))}function a(M,g){M.dashSize.value=g.dashSize,M.totalSize.value=g.dashSize+g.gapSize,M.scale.value=g.scale}function c(M,g,x,S){M.diffuse.value.copy(g.color),M.opacity.value=g.opacity,M.size.value=g.size*x,M.scale.value=S*.5,g.map&&(M.map.value=g.map,t(g.map,M.uvTransform)),g.alphaMap&&(M.alphaMap.value=g.alphaMap,t(g.alphaMap,M.alphaMapTransform)),g.alphaTest>0&&(M.alphaTest.value=g.alphaTest)}function f(M,g){M.diffuse.value.copy(g.color),M.opacity.value=g.opacity,M.rotation.value=g.rotation,g.map&&(M.map.value=g.map,t(g.map,M.mapTransform)),g.alphaMap&&(M.alphaMap.value=g.alphaMap,t(g.alphaMap,M.alphaMapTransform)),g.alphaTest>0&&(M.alphaTest.value=g.alphaTest)}function h(M,g){M.specular.value.copy(g.specular),M.shininess.value=Math.max(g.shininess,1e-4)}function d(M,g){g.gradientMap&&(M.gradientMap.value=g.gradientMap)}function m(M,g){M.metalness.value=g.metalness,g.metalnessMap&&(M.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,M.metalnessMapTransform)),M.roughness.value=g.roughness,g.roughnessMap&&(M.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,M.roughnessMapTransform)),e.get(g).envMap&&(M.envMapIntensity.value=g.envMapIntensity)}function v(M,g,x){M.ior.value=g.ior,g.sheen>0&&(M.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),M.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(M.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,M.sheenColorMapTransform)),g.sheenRoughnessMap&&(M.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,M.sheenRoughnessMapTransform))),g.clearcoat>0&&(M.clearcoat.value=g.clearcoat,M.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(M.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,M.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(M.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,M.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(M.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,M.clearcoatNormalMapTransform),M.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===bn&&M.clearcoatNormalScale.value.negate())),g.iridescence>0&&(M.iridescence.value=g.iridescence,M.iridescenceIOR.value=g.iridescenceIOR,M.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],M.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(M.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,M.iridescenceMapTransform)),g.iridescenceThicknessMap&&(M.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,M.iridescenceThicknessMapTransform))),g.transmission>0&&(M.transmission.value=g.transmission,M.transmissionSamplerMap.value=x.texture,M.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(M.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,M.transmissionMapTransform)),M.thickness.value=g.thickness,g.thicknessMap&&(M.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,M.thicknessMapTransform)),M.attenuationDistance.value=g.attenuationDistance,M.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(M.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(M.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,M.anisotropyMapTransform))),M.specularIntensity.value=g.specularIntensity,M.specularColor.value.copy(g.specularColor),g.specularColorMap&&(M.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,M.specularColorMapTransform)),g.specularIntensityMap&&(M.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,M.specularIntensityMapTransform))}function _(M,g){g.matcap&&(M.matcap.value=g.matcap)}function E(M,g){const x=e.get(g).light;M.referencePosition.value.setFromMatrixPosition(x.matrixWorld),M.nearDistance.value=x.shadow.camera.near,M.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function fO(n,e,t,i){let r={},s={},o=[];const a=t.isWebGL2?n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(x,S){const T=S.program;i.uniformBlockBinding(x,T)}function f(x,S){let T=r[x.id];T===void 0&&(_(x),T=h(x),r[x.id]=T,x.addEventListener("dispose",M));const L=S.program;i.updateUBOMapping(x,L);const R=e.render.frame;s[x.id]!==R&&(m(x),s[x.id]=R)}function h(x){const S=d();x.__bindingPointIndex=S;const T=n.createBuffer(),L=x.__size,R=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,T),n.bufferData(n.UNIFORM_BUFFER,L,R),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,S,T),T}function d(){for(let x=0;x0&&(T+=L-R),x.__size=T,x.__cache={},this}function E(x){const S={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(S.boundary=4,S.storage=4):x.isVector2?(S.boundary=8,S.storage=8):x.isVector3||x.isColor?(S.boundary=16,S.storage=12):x.isVector4?(S.boundary=16,S.storage=16):x.isMatrix3?(S.boundary=48,S.storage=48):x.isMatrix4?(S.boundary=64,S.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),S}function M(x){const S=x.target;S.removeEventListener("dispose",M);const T=o.indexOf(S.__bindingPointIndex);o.splice(T,1),n.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function g(){for(const x in r)n.deleteBuffer(r[x]);o=[],r={},s={}}return{bind:c,update:f,dispose:g}}class q_{constructor(e={}){const{canvas:t=hC(),context:i=null,depth:r=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:f=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let m;i!==null?m=i.getContextAttributes().alpha:m=o;const v=new Uint32Array(4),_=new Int32Array(4);let E=null,M=null;const g=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=At,this._useLegacyLights=!1,this.toneMapping=Dr,this.toneMappingExposure=1;const S=this;let T=!1,L=0,R=0,P=null,D=-1,C=null;const b=new Ot,B=new Ot;let j=null;const le=new Ue(0);let H=0,Z=t.width,$=t.height,ce=1,z=null,G=null;const V=new Ot(0,0,Z,$),J=new Ot(0,0,Z,$);let se=!1;const K=new mf;let ue=!1,Se=!1,Ce=null;const Te=new it,nt=new oe,rt=new O,ke={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function je(){return P===null?ce:1}let k=i;function ve(N,q){for(let ne=0;ne{function Ne(){if(ie.forEach(function(We){Ie.get(We).currentProgram.isReady()&&ie.delete(We)}),ie.size===0){te(N);return}setTimeout(Ne,10)}he.get("KHR_parallel_shader_compile")!==null?Ne():setTimeout(Ne,10)})};let zt=null;function pn(N){zt&&zt(N)}function Un(){Xn.stop()}function Vt(){Xn.start()}const Xn=new _C;Xn.setAnimationLoop(pn),typeof self<"u"&&Xn.setContext(self),this.setAnimationLoop=function(N){zt=N,yt.setAnimationLoop(N),N===null?Xn.stop():Xn.start()},yt.addEventListener("sessionstart",Un),yt.addEventListener("sessionend",Vt),this.render=function(N,q){if(q!==void 0&&q.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),q.parent===null&&q.matrixWorldAutoUpdate===!0&&q.updateMatrixWorld(),yt.enabled===!0&&yt.isPresenting===!0&&(yt.cameraAutoUpdate===!0&&yt.updateCamera(q),q=yt.getCamera()),N.isScene===!0&&N.onBeforeRender(S,N,q,P),M=Qe.get(N,x.length),M.init(),x.push(M),Te.multiplyMatrices(q.projectionMatrix,q.matrixWorldInverse),K.setFromProjectionMatrix(Te),Se=this.localClippingEnabled,ue=ct.init(this.clippingPlanes,Se),E=De.get(N,g.length),E.init(),g.push(E),er(N,q,0,S.sortObjects),E.finish(),S.sortObjects===!0&&E.sort(z,G),this.info.render.frame++,ue===!0&&ct.beginShadows();const ne=M.state.shadowsArray;if(me.render(ne,N,q),ue===!0&&ct.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ct.render(E,N),M.setupLights(S._useLegacyLights),q.isArrayCamera){const ie=q.cameras;for(let te=0,Ne=ie.length;te0?M=x[x.length-1]:M=null,g.pop(),g.length>0?E=g[g.length-1]:E=null};function er(N,q,ne,ie){if(N.visible===!1)return;if(N.layers.test(q.layers)){if(N.isGroup)ne=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(q);else if(N.isLight)M.pushLight(N),N.castShadow&&M.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||K.intersectsSprite(N)){ie&&rt.setFromMatrixPosition(N.matrixWorld).applyMatrix4(Te);const We=de.update(N),Je=N.material;Je.visible&&E.push(N,We,Je,ne,rt.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(!N.frustumCulled||K.intersectsObject(N))){const We=de.update(N),Je=N.material;if(ie&&(N.boundingSphere!==void 0?(N.boundingSphere===null&&N.computeBoundingSphere(),rt.copy(N.boundingSphere.center)):(We.boundingSphere===null&&We.computeBoundingSphere(),rt.copy(We.boundingSphere.center)),rt.applyMatrix4(N.matrixWorld).applyMatrix4(Te)),Array.isArray(Je)){const et=We.groups;for(let at=0,st=et.length;at0&&cu(te,Ne,q,ne),ie&&fe.viewport(b.copy(ie)),te.length>0&&Ca(te,q,ne),Ne.length>0&&Ca(Ne,q,ne),We.length>0&&Ca(We,q,ne),fe.buffers.depth.setTest(!0),fe.buffers.depth.setMask(!0),fe.buffers.color.setMask(!0),fe.setPolygonOffset(!1)}function cu(N,q,ne,ie){if((ne.isScene===!0?ne.overrideMaterial:null)!==null)return;const Ne=_e.isWebGL2;Ce===null&&(Ce=new _n(1,1,{generateMipmaps:!0,type:he.has("EXT_color_buffer_half_float")?ya:Pn,minFilter:yo,samples:Ne?4:0})),S.getDrawingBufferSize(nt),Ne?Ce.setSize(nt.x,nt.y):Ce.setSize(Cp(nt.x),Cp(nt.y));const We=S.getRenderTarget();S.setRenderTarget(Ce),S.getClearColor(le),H=S.getClearAlpha(),H<1&&S.setClearColor(16777215,.5),S.clear();const Je=S.toneMapping;S.toneMapping=Dr,Ca(N,ne,ie),U.updateMultisampleRenderTarget(Ce),U.updateRenderTargetMipmap(Ce);let et=!1;for(let at=0,st=q.length;at0),lt=!!ne.morphAttributes.position,tn=!!ne.morphAttributes.normal,Yn=!!ne.morphAttributes.color;let jt=Dr;ie.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(jt=S.toneMapping);const Nn=ne.morphAttributes.position||ne.morphAttributes.normal||ne.morphAttributes.color,tt=Nn!==void 0?Nn.length:0,Fe=Ie.get(ie),tr=M.state.lights;if(ue===!0&&(Se===!0||N!==C)){const jn=N===C&&ie.id===D;ct.setState(ie,N,jn)}let Mt=!1;ie.version===Fe.__version?(Fe.needsLights&&Fe.lightsStateVersion!==tr.state.version||Fe.outputColorSpace!==Je||te.isBatchedMesh&&Fe.batching===!1||!te.isBatchedMesh&&Fe.batching===!0||te.isInstancedMesh&&Fe.instancing===!1||!te.isInstancedMesh&&Fe.instancing===!0||te.isSkinnedMesh&&Fe.skinning===!1||!te.isSkinnedMesh&&Fe.skinning===!0||te.isInstancedMesh&&Fe.instancingColor===!0&&te.instanceColor===null||te.isInstancedMesh&&Fe.instancingColor===!1&&te.instanceColor!==null||Fe.envMap!==et||ie.fog===!0&&Fe.fog!==Ne||Fe.numClippingPlanes!==void 0&&(Fe.numClippingPlanes!==ct.numPlanes||Fe.numIntersection!==ct.numIntersection)||Fe.vertexAlphas!==at||Fe.vertexTangents!==st||Fe.morphTargets!==lt||Fe.morphNormals!==tn||Fe.morphColors!==Yn||Fe.toneMapping!==jt||_e.isWebGL2===!0&&Fe.morphTargetsCount!==tt)&&(Mt=!0):(Mt=!0,Fe.__version=ie.version);let un=Fe.currentProgram;Mt===!0&&(un=Ra(ie,q,te));let Br=!1,nr=!1,Dn=!1;const mn=un.getUniforms(),kr=Fe.uniforms;if(fe.useProgram(un.program)&&(Br=!0,nr=!0,Dn=!0),ie.id!==D&&(D=ie.id,nr=!0),Br||C!==N){mn.setValue(k,"projectionMatrix",N.projectionMatrix),mn.setValue(k,"viewMatrix",N.matrixWorldInverse);const jn=mn.map.cameraPosition;jn!==void 0&&jn.setValue(k,rt.setFromMatrixPosition(N.matrixWorld)),_e.logarithmicDepthBuffer&&mn.setValue(k,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),(ie.isMeshPhongMaterial||ie.isMeshToonMaterial||ie.isMeshLambertMaterial||ie.isMeshBasicMaterial||ie.isMeshStandardMaterial||ie.isShaderMaterial)&&mn.setValue(k,"isOrthographic",N.isOrthographicCamera===!0),C!==N&&(C=N,nr=!0,Dn=!0)}if(te.isSkinnedMesh){mn.setOptional(k,te,"bindMatrix"),mn.setOptional(k,te,"bindMatrixInverse");const jn=te.skeleton;jn&&(_e.floatVertexTextures?(jn.boneTexture===null&&jn.computeBoneTexture(),mn.setValue(k,"boneTexture",jn.boneTexture,U)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}te.isBatchedMesh&&(mn.setOptional(k,te,"batchingTexture"),mn.setValue(k,"batchingTexture",te._matricesTexture,U));const ba=ne.morphAttributes;if((ba.position!==void 0||ba.normal!==void 0||ba.color!==void 0&&_e.isWebGL2===!0)&&St.update(te,ne,un),(nr||Fe.receiveShadow!==te.receiveShadow)&&(Fe.receiveShadow=te.receiveShadow,mn.setValue(k,"receiveShadow",te.receiveShadow)),ie.isMeshGouraudMaterial&&ie.envMap!==null&&(kr.envMap.value=et,kr.flipEnvMap.value=et.isCubeTexture&&et.isRenderTargetTexture===!1?-1:1),nr&&(mn.setValue(k,"toneMappingExposure",S.toneMappingExposure),Fe.needsLights&&Em(kr,Dn),Ne&&ie.fog===!0&&Ae.refreshFogUniforms(kr,Ne),Ae.refreshMaterialUniforms(kr,ie,ce,$,Ce),Kd.upload(k,wf(Fe),kr,U)),ie.isShaderMaterial&&ie.uniformsNeedUpdate===!0&&(Kd.upload(k,wf(Fe),kr,U),ie.uniformsNeedUpdate=!1),ie.isSpriteMaterial&&mn.setValue(k,"center",te.center),mn.setValue(k,"modelViewMatrix",te.modelViewMatrix),mn.setValue(k,"normalMatrix",te.normalMatrix),mn.setValue(k,"modelMatrix",te.matrixWorld),ie.isShaderMaterial||ie.isRawShaderMaterial){const jn=ie.uniformsGroups;for(let Pa=0,ki=jn.length;Pa0&&U.useMultisampledRTT(N)===!1?te=Ie.get(N).__webglMultisampledFramebuffer:Array.isArray(st)?te=st[ne]:te=st,b.copy(N.viewport),B.copy(N.scissor),j=N.scissorTest}else b.copy(V).multiplyScalar(ce).floor(),B.copy(J).multiplyScalar(ce).floor(),j=se;if(fe.bindFramebuffer(k.FRAMEBUFFER,te)&&_e.drawBuffers&&ie&&fe.drawBuffers(N,te),fe.viewport(b),fe.scissor(B),fe.setScissorTest(j),Ne){const et=Ie.get(N.texture);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_CUBE_MAP_POSITIVE_X+q,et.__webglTexture,ne)}else if(We){const et=Ie.get(N.texture),at=q||0;k.framebufferTextureLayer(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,et.__webglTexture,ne||0,at)}D=-1},this.readRenderTargetPixels=function(N,q,ne,ie,te,Ne,We){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Je=Ie.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&We!==void 0&&(Je=Je[We]),Je){fe.bindFramebuffer(k.FRAMEBUFFER,Je);try{const et=N.texture,at=et.format,st=et.type;if(at!==Hn&&Be.convert(at)!==k.getParameter(k.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const lt=st===ya&&(he.has("EXT_color_buffer_half_float")||_e.isWebGL2&&he.has("EXT_color_buffer_float"));if(st!==Pn&&Be.convert(st)!==k.getParameter(k.IMPLEMENTATION_COLOR_READ_TYPE)&&!(st===mr&&(_e.isWebGL2||he.has("OES_texture_float")||he.has("WEBGL_color_buffer_float")))&&!lt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}q>=0&&q<=N.width-ie&&ne>=0&&ne<=N.height-te&&k.readPixels(q,ne,ie,te,Be.convert(at),Be.convert(st),Ne)}finally{const et=P!==null?Ie.get(P).__webglFramebuffer:null;fe.bindFramebuffer(k.FRAMEBUFFER,et)}}},this.copyFramebufferToTexture=function(N,q,ne=0){const ie=Math.pow(2,-ne),te=Math.floor(q.image.width*ie),Ne=Math.floor(q.image.height*ie);U.setTexture2D(q,0),k.copyTexSubImage2D(k.TEXTURE_2D,ne,0,0,N.x,N.y,te,Ne),fe.unbindTexture()},this.copyTextureToTexture=function(N,q,ne,ie=0){const te=q.image.width,Ne=q.image.height,We=Be.convert(ne.format),Je=Be.convert(ne.type);U.setTexture2D(ne,0),k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,ne.flipY),k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ne.premultiplyAlpha),k.pixelStorei(k.UNPACK_ALIGNMENT,ne.unpackAlignment),q.isDataTexture?k.texSubImage2D(k.TEXTURE_2D,ie,N.x,N.y,te,Ne,We,Je,q.image.data):q.isCompressedTexture?k.compressedTexSubImage2D(k.TEXTURE_2D,ie,N.x,N.y,q.mipmaps[0].width,q.mipmaps[0].height,We,q.mipmaps[0].data):k.texSubImage2D(k.TEXTURE_2D,ie,N.x,N.y,We,Je,q.image),ie===0&&ne.generateMipmaps&&k.generateMipmap(k.TEXTURE_2D),fe.unbindTexture()},this.copyTextureToTexture3D=function(N,q,ne,ie,te=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ne=N.max.x-N.min.x+1,We=N.max.y-N.min.y+1,Je=N.max.z-N.min.z+1,et=Be.convert(ie.format),at=Be.convert(ie.type);let st;if(ie.isData3DTexture)U.setTexture3D(ie,0),st=k.TEXTURE_3D;else if(ie.isDataArrayTexture||ie.isCompressedArrayTexture)U.setTexture2DArray(ie,0),st=k.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,ie.flipY),k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ie.premultiplyAlpha),k.pixelStorei(k.UNPACK_ALIGNMENT,ie.unpackAlignment);const lt=k.getParameter(k.UNPACK_ROW_LENGTH),tn=k.getParameter(k.UNPACK_IMAGE_HEIGHT),Yn=k.getParameter(k.UNPACK_SKIP_PIXELS),jt=k.getParameter(k.UNPACK_SKIP_ROWS),Nn=k.getParameter(k.UNPACK_SKIP_IMAGES),tt=ne.isCompressedTexture?ne.mipmaps[te]:ne.image;k.pixelStorei(k.UNPACK_ROW_LENGTH,tt.width),k.pixelStorei(k.UNPACK_IMAGE_HEIGHT,tt.height),k.pixelStorei(k.UNPACK_SKIP_PIXELS,N.min.x),k.pixelStorei(k.UNPACK_SKIP_ROWS,N.min.y),k.pixelStorei(k.UNPACK_SKIP_IMAGES,N.min.z),ne.isDataTexture||ne.isData3DTexture?k.texSubImage3D(st,te,q.x,q.y,q.z,Ne,We,Je,et,at,tt.data):ne.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),k.compressedTexSubImage3D(st,te,q.x,q.y,q.z,Ne,We,Je,et,tt.data)):k.texSubImage3D(st,te,q.x,q.y,q.z,Ne,We,Je,et,at,tt),k.pixelStorei(k.UNPACK_ROW_LENGTH,lt),k.pixelStorei(k.UNPACK_IMAGE_HEIGHT,tn),k.pixelStorei(k.UNPACK_SKIP_PIXELS,Yn),k.pixelStorei(k.UNPACK_SKIP_ROWS,jt),k.pixelStorei(k.UNPACK_SKIP_IMAGES,Nn),te===0&&ie.generateMipmaps&&k.generateMipmap(st),fe.unbindTexture()},this.initTexture=function(N){N.isCubeTexture?U.setTextureCube(N,0):N.isData3DTexture?U.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?U.setTexture2DArray(N,0):U.setTexture2D(N,0),fe.unbindTexture()},this.resetState=function(){L=0,R=0,P=null,fe.reset(),dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ir}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Qp?"display-p3":"srgb",t.unpackColorSpace=Bt.workingColorSpace===hf?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===At?ho:z_}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===ho?At:_r}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class CC extends q_{}CC.prototype.isWebGL1Renderer=!0;class yf{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ue(e),this.density=t}clone(){return new yf(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class tm{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ue(e),this.near=t,this.far=i}clone(){return new tm(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Zc extends Dt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class nm{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=jc,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Ki()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;re.far||t.push({distance:c,point:Vu.clone(),uv:Li.getInterpolation(Vu,rd,Wu,sd,V1,wv,G1,new oe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function od(n,e,t,i,r,s){ll.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Gu.x=s*ll.x-r*ll.y,Gu.y=r*ll.x+s*ll.y):Gu.copy(ll),n.copy(e),n.x+=Gu.x,n.y+=Gu.y,n.applyMatrix4(RC)}const ad=new O,W1=new O;class PC extends Dt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i0){let i,r;for(i=1,r=t.length;i0){ad.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(ad);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){ad.setFromMatrixPosition(e.matrixWorld),W1.setFromMatrixPosition(this.matrixWorld);const i=ad.distanceTo(W1)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r=i.length&&i.push({start:-1,count:-1,z:-1});const s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}}const cl="batchId",Ys=new it,$1=new it,yO=new it,eE=new it,Cv=new mf,cd=new Si,Vo=new fi,ju=new O,Rv=new vO,oi=new wn,fd=[];function _O(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new Ft(a,1))}const o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(cl,new Ft(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(cl))throw new Error(`BatchedMesh: Geometry cannot use attribute "${cl}"`);const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(i===cl)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Si);const e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const f=e.getIndex(),h=f!==null;if(h&&(i===-1?r.indexCount=f.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const d=this._visibility,m=this._active,v=this._matricesTexture,_=this._matricesTexture.image.data;d.push(!0),m.push(!0);const E=this._geometryCount;this._geometryCount++,yO.toArray(_,E*16),v.needsUpdate=!0,o.push(r),a.push({start:h?r.indexStart:r.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Si,sphereInitialized:!1,sphere:new fi});const M=this.geometry.getAttribute(cl);for(let g=0;g=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=a.vertexStart,f=a.vertexCount;for(const v in i.attributes){if(v===cl)continue;const _=t.getAttribute(v),E=i.getAttribute(v);_O(_,E,c);const M=_.itemSize;for(let g=_.count,x=f;g=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(this._active[e]===!1)return this;const r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();const a=o.index,c=o.attributes.position,f=this._drawRanges[e];for(let h=f.start,d=f.start+f.count;h=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){const i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){const i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;oi.material=this.material,oi.geometry.index=c.index,oi.geometry.attributes=c.attributes,oi.geometry.boundingBox===null&&(oi.geometry.boundingBox=new Si),oi.geometry.boundingSphere===null&&(oi.geometry.boundingSphere=new fi);for(let f=0;f({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,f=this._multiDrawStarts,h=this._multiDrawCounts,d=this._drawRanges,m=this.perObjectFrustumCulled;m&&(eE.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),Cv.setFromProjectionMatrix(eE,e.isWebGPURenderer?ql:Ir));let v=0;if(this.sortObjects){$1.copy(this.matrixWorld).invert(),ju.setFromMatrixPosition(i.matrixWorld).applyMatrix4($1);for(let M=0,g=c.length;Mc)continue;m.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(m);De.far||t.push({distance:D,point:d.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const g=Math.max(0,o.start),x=Math.min(M.count,o.start+o.count);for(let S=g,T=x-1;Sc)continue;m.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(m);Re.far||t.push({distance:R,point:d.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:f,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}class xO extends an{constructor(e,t,i,r,s,o,a,c,f){super(e,t,i,r,s,o,a,c,f),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Kt,this.magFilter=s!==void 0?s:Kt,this.generateMipmaps=!1;const h=this;function d(){h.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class SO extends an{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Xt,this.minFilter=Xt,this.generateMipmaps=!1,this.needsUpdate=!0}}class rm extends an{constructor(e,t,i,r,s,o,a,c,f,h,d,m){super(null,o,a,c,f,h,r,s,d,m),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class MO extends rm{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=li}}class EO extends rm{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Rs),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class wO extends an{constructor(e,t,i,r,s,o,a,c,f){super(e,t,i,r,s,o,a,c,f),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Fr{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let o;t?o=t:o=e*i[s-1];let a=0,c=s-1,f;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),f=i[r]-o,f<0)a=r+1;else if(f>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);const h=i[r],m=i[r+1]-h,v=(o-h)/m;return(r+v)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new oe:new O);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new O,r=[],s=[],o=[],a=new O,c=new it;for(let v=0;v<=e;v++){const _=v/e;r[v]=this.getTangentAt(_,new O)}s[0]=new O,o[0]=new O;let f=Number.MAX_VALUE;const h=Math.abs(r[0].x),d=Math.abs(r[0].y),m=Math.abs(r[0].z);h<=f&&(f=h,i.set(1,0,0)),d<=f&&(f=d,i.set(0,1,0)),m<=f&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let v=1;v<=e;v++){if(s[v]=s[v-1].clone(),o[v]=o[v-1].clone(),a.crossVectors(r[v-1],r[v]),a.length()>Number.EPSILON){a.normalize();const _=Math.acos(dn(r[v-1].dot(r[v]),-1,1));s[v].applyMatrix4(c.makeRotationAxis(a,_))}o[v].crossVectors(r[v],s[v])}if(t===!0){let v=Math.acos(dn(s[0].dot(s[e]),-1,1));v/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(v=-v);for(let _=1;_<=e;_++)s[_].applyMatrix4(c.makeRotationAxis(r[_],v*_)),o[_].crossVectors(r[_],s[_])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class sm extends Fr{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t){const i=t||new oe,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let f,h;this.closed||a>0?f=r[(a-1)%s]:(md.subVectors(r[0],r[1]).add(r[0]),f=md);const d=r[a%s],m=r[(a+1)%s];if(this.closed||a+2r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return i.set(lE(a,c.x,f.x,h.x,d.x),lE(a,c.y,f.y,h.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const o=r[s]-i,a=this.curves[s],c=a.getLength(),f=c===0?0:1-o/c;return a.getPointAt(f,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.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 e=[];let t=0;for(let i=0,r=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=f.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(f);const h=f.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class _f extends vt{constructor(e=[new oe(0,-.5),new oe(.5,0),new oe(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=dn(r,0,Math.PI*2);const s=[],o=[],a=[],c=[],f=[],h=1/t,d=new O,m=new oe,v=new O,_=new O,E=new O;let M=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:M=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,v.x=g*1,v.y=-M,v.z=g*0,E.copy(v),v.normalize(),c.push(v.x,v.y,v.z);break;case e.length-1:c.push(E.x,E.y,E.z);break;default:M=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,v.x=g*1,v.y=-M,v.z=g*0,_.copy(v),v.x+=E.x,v.y+=E.y,v.z+=E.z,v.normalize(),c.push(v.x,v.y,v.z),E.copy(_)}for(let x=0;x<=t;x++){const S=i+x*h*r,T=Math.sin(S),L=Math.cos(S);for(let R=0;R<=e.length-1;R++){d.x=e[R].x*T,d.y=e[R].y,d.z=e[R].x*L,o.push(d.x,d.y,d.z),m.x=x/t,m.y=R/(e.length-1),a.push(m.x,m.y);const P=c[3*R+0]*T,D=c[3*R+1],C=c[3*R+0]*L;f.push(P,D,C)}}for(let x=0;x0&&S(!0),t>0&&S(!1)),this.setIndex(h),this.setAttribute("position",new He(d,3)),this.setAttribute("normal",new He(m,3)),this.setAttribute("uv",new He(v,2));function x(){const T=new O,L=new O;let R=0;const P=(t-e)/i;for(let D=0;D<=s;D++){const C=[],b=D/s,B=b*(t-e)+e;for(let j=0;j<=r;j++){const le=j/r,H=le*c+a,Z=Math.sin(H),$=Math.cos(H);L.x=B*Z,L.y=-b*i+M,L.z=B*$,d.push(L.x,L.y,L.z),T.set(Z,P,$).normalize(),m.push(T.x,T.y,T.z),v.push(le,1-b),C.push(_++)}E.push(C)}for(let D=0;D.9&&P<.1&&(S<.2&&(o[x+0]+=1),T<.2&&(o[x+2]+=1),L<.2&&(o[x+4]+=1))}}function m(x){s.push(x.x,x.y,x.z)}function v(x,S){const T=x*3;S.x=e[T+0],S.y=e[T+1],S.z=e[T+2]}function _(){const x=new O,S=new O,T=new O,L=new O,R=new oe,P=new oe,D=new oe;for(let C=0,b=0;C80*t){a=f=n[0],c=h=n[1];for(let _=t;_f&&(f=d),m>h&&(h=m);v=Math.max(f-a,h-c),v=v!==0?32767/v:0}return Qc(s,o,t,a,c,v,0),o}};function VC(n,e,t,i,r){let s,o;if(r===qO(n,e,t,i)>0)for(s=e;s=e;s-=i)o=uE(s,n[s],n[s+1],o);return o&&cm(o,o.next)&&($c(o),o=o.next),o}function xa(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(cm(t,t.next)||sn(t.prev,t,t.next)===0)){if($c(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Qc(n,e,t,i,r,s,o){if(!n)return;!o&&s&&VO(n,i,r,s);let a=n,c,f;for(;n.prev!==n.next;){if(c=n.prev,f=n.next,s?NO(n,i,r,s):UO(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(f.i/t|0),$c(n),n=f.next,a=f.next;continue}if(n=f,n===a){o?o===1?(n=DO(xa(n),e,t),Qc(n,e,t,i,r,s,2)):o===2&&OO(n,e,t,i,r,s):Qc(xa(n),e,t,i,r,s,1);break}}}function UO(n){const e=n.prev,t=n,i=n.next;if(sn(e,t,i)>=0)return!1;const r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,f=i.y,h=rs?r>o?r:o:s>o?s:o,v=a>c?a>f?a:f:c>f?c:f;let _=i.next;for(;_!==e;){if(_.x>=h&&_.x<=m&&_.y>=d&&_.y<=v&&Ll(r,a,s,c,o,f,_.x,_.y)&&sn(_.prev,_,_.next)>=0)return!1;_=_.next}return!0}function NO(n,e,t,i){const r=n.prev,s=n,o=n.next;if(sn(r,s,o)>=0)return!1;const a=r.x,c=s.x,f=o.x,h=r.y,d=s.y,m=o.y,v=ac?a>f?a:f:c>f?c:f,M=h>d?h>m?h:m:d>m?d:m,g=wy(v,_,e,t,i),x=wy(E,M,e,t,i);let S=n.prevZ,T=n.nextZ;for(;S&&S.z>=g&&T&&T.z<=x;){if(S.x>=v&&S.x<=E&&S.y>=_&&S.y<=M&&S!==r&&S!==o&&Ll(a,h,c,d,f,m,S.x,S.y)&&sn(S.prev,S,S.next)>=0||(S=S.prevZ,T.x>=v&&T.x<=E&&T.y>=_&&T.y<=M&&T!==r&&T!==o&&Ll(a,h,c,d,f,m,T.x,T.y)&&sn(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;S&&S.z>=g;){if(S.x>=v&&S.x<=E&&S.y>=_&&S.y<=M&&S!==r&&S!==o&&Ll(a,h,c,d,f,m,S.x,S.y)&&sn(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;T&&T.z<=x;){if(T.x>=v&&T.x<=E&&T.y>=_&&T.y<=M&&T!==r&&T!==o&&Ll(a,h,c,d,f,m,T.x,T.y)&&sn(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function DO(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!cm(r,s)&&GC(r,i,i.next,s)&&Jc(r,s)&&Jc(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),$c(i),$c(i.next),i=n=s),i=i.next}while(i!==n);return xa(i)}function OO(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&XO(o,a)){let c=WC(o,a);o=xa(o,o.next),c=xa(c,c.next),Qc(o,e,t,i,r,s,0),Qc(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function FO(n,e,t,i){const r=[];let s,o,a,c,f;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){const m=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(m<=s&&m>i&&(i=m,r=t.x=t.x&&t.x>=c&&s!==t.x&&Ll(or.x||t.x===r.x&&HO(r,t)))&&(r=t,h=d)),t=t.next;while(t!==a);return r}function HO(n,e){return sn(n.prev,n,e.prev)<0&&sn(e.next,n,n.next)<0}function VO(n,e,t,i){let r=n;do r.z===0&&(r.z=wy(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,GO(r)}function GO(n){let e,t,i,r,s,o,a,c,f=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,f*=2}while(o>1);return n}function wy(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function WO(n){let e=n,t=n;do(e.x=(n-o)*(s-a)&&(n-o)*(i-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(i-a)}function XO(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!YO(n,e)&&(Jc(n,e)&&Jc(e,n)&&jO(n,e)&&(sn(n.prev,n,e.prev)||sn(n,e.prev,e))||cm(n,e)&&sn(n.prev,n,n.next)>0&&sn(e.prev,e,e.next)>0)}function sn(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function cm(n,e){return n.x===e.x&&n.y===e.y}function GC(n,e,t,i){const r=xd(sn(n,e,t)),s=xd(sn(n,e,i)),o=xd(sn(t,i,n)),a=xd(sn(t,i,e));return!!(r!==s&&o!==a||r===0&&_d(n,t,e)||s===0&&_d(n,i,e)||o===0&&_d(t,n,i)||a===0&&_d(t,e,i))}function _d(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function xd(n){return n>0?1:n<0?-1:0}function YO(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&GC(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Jc(n,e){return sn(n.prev,n,n.next)<0?sn(n,e,n.next)>=0&&sn(n,n.prev,e)>=0:sn(n,e,n.prev)<0||sn(n,n.next,e)<0}function jO(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function WC(n,e){const t=new Ty(n.i,n.x,n.y),i=new Ty(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function uE(n,e,t,i){const r=new Ty(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function $c(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Ty(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qO(n,e,t,i){let r=0;for(let s=e,o=t-i;s2&&n[e-1].equals(n[0])&&n.pop()}function fE(n,e){for(let t=0;tNumber.EPSILON){const de=Math.sqrt(ge),Ve=Math.sqrt(I*I+Q*Q),Ae=ve.x-U/de,De=ve.y+Ie/de,Qe=he.x-Q/Ve,ct=he.y+I/Ve,me=((Qe-Ae)*Q-(ct-De)*I)/(Ie*Q-U*I);_e=Ae+Ie*me-k.x,fe=De+U*me-k.y;const Ct=_e*_e+fe*fe;if(Ct<=2)return new oe(_e,fe);Ye=Math.sqrt(Ct/2)}else{let de=!1;Ie>Number.EPSILON?I>Number.EPSILON&&(de=!0):Ie<-Number.EPSILON?I<-Number.EPSILON&&(de=!0):Math.sign(U)===Math.sign(Q)&&(de=!0),de?(_e=-U,fe=Ie,Ye=Math.sqrt(ge)):(_e=Ie,fe=U,Ye=Math.sqrt(ge/2))}return new oe(_e/Ye,fe/Ye)}const G=[];for(let k=0,ve=H.length,he=ve-1,_e=k+1;k=0;k--){const ve=k/M,he=v*Math.cos(ve*Math.PI/2),_e=_*Math.sin(ve*Math.PI/2)+E;for(let fe=0,Ye=H.length;fe=0;){const _e=he;let fe=he-1;fe<0&&(fe=k.length-1);for(let Ye=0,Ie=h+M*2;Ye0)&&v.push(S,T,R),(g!==i-1||c0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class ZC extends Wn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ue(16777215),this.specular=new Ue(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=To,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ff,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class KC extends Wn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ue(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=To,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class sx extends Wn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=To,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class QC extends Wn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=To,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ff,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class JC extends Wn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ue(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=To,this.normalScale=new oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class $C extends wi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function oa(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function eR(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function tR(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Ay(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=n[a+c]}return r}function ox(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}function JO(n,e,t,i,r=30){const s=n.clone();s.name=e;const o=[];for(let c=0;c=i)){d.push(f.times[v]);for(let E=0;Es.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c=a.times[_]){const g=_*d+h,x=g+d-h;E=a.values.slice(g,x)}else{const g=a.createInterpolant(),x=h,S=d-h;g.evaluate(s),E=g.resultBuffer.slice(x,S)}c==="quaternion"&&new Fi().fromArray(E).normalize().conjugate().toArray(E);const M=f.times.length;for(let g=0;g=s)){const a=t[1];e=s)break t}o=i,i=0;break n}break e}for(;i>>1;et;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&eR(r))for(let a=0,c=r.length;a!==c;++a){const f=r[a];if(isNaN(f)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,f),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Zd,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*i,c=o*i,f=0;f!==i;++f)t[c+f]=t[a+f];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}zr.prototype.TimeBufferType=Float32Array;zr.prototype.ValueBufferType=Float32Array;zr.prototype.DefaultInterpolation=Vc;class wa extends zr{}wa.prototype.ValueTypeName="bool";wa.prototype.ValueBufferType=Array;wa.prototype.DefaultInterpolation=Hc;wa.prototype.InterpolantFactoryMethodLinear=void 0;wa.prototype.InterpolantFactoryMethodSmooth=void 0;class lx extends zr{}lx.prototype.ValueTypeName="color";class ef extends zr{}ef.prototype.ValueTypeName="number";class rR extends Mf{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(r-t);let f=e*a;for(let h=f+a;f!==h;f+=4)Fi.slerpFlat(s,0,o,f-a,o,f,c);return s}}class lu extends zr{InterpolantFactoryMethodLinear(e){return new rR(this.times,this.values,this.getValueSize(),e)}}lu.prototype.ValueTypeName="quaternion";lu.prototype.DefaultInterpolation=Vc;lu.prototype.InterpolantFactoryMethodSmooth=void 0;class Ta extends zr{}Ta.prototype.ValueTypeName="string";Ta.prototype.ValueBufferType=Array;Ta.prototype.DefaultInterpolation=Hc;Ta.prototype.InterpolantFactoryMethodLinear=void 0;Ta.prototype.InterpolantFactoryMethodSmooth=void 0;class tf extends zr{}tf.prototype.ValueTypeName="vector";class nf{constructor(e,t=-1,i,r=Kp){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Ki(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(nF(i[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(zr.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let a=0;a1){const d=h[1];let m=r[d];m||(r[d]=m=[]),m.push(f)}}const o=[];for(const a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(d,m,v,_,E){if(v.length!==0){const M=[],g=[];ox(v,M,g,_),M.length!==0&&E.push(new d(m,M,g))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const f=e.hierarchy||[];for(let d=0;d{t&&t(s),this.manager.itemEnd(e)},0),s;if(ps[e]!==void 0){ps[e].push({onLoad:t,onProgress:i,onError:r});return}ps[e]=[],ps[e].push({onLoad:t,onProgress:i,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(f=>{if(f.status===200||f.status===0){if(f.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||f.body===void 0||f.body.getReader===void 0)return f;const h=ps[e],d=f.body.getReader(),m=f.headers.get("Content-Length")||f.headers.get("X-File-Size"),v=m?parseInt(m):0,_=v!==0;let E=0;const M=new ReadableStream({start(g){x();function x(){d.read().then(({done:S,value:T})=>{if(S)g.close();else{E+=T.byteLength;const L=new ProgressEvent("progress",{lengthComputable:_,loaded:E,total:v});for(let R=0,P=h.length;R{switch(c){case"arraybuffer":return f.arrayBuffer();case"blob":return f.blob();case"document":return f.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return f.json();default:if(a===void 0)return f.text();{const d=/charset="?([^;"\s]*)"?/i.exec(a),m=d&&d[1]?d[1].toLowerCase():void 0,v=new TextDecoder(m);return f.arrayBuffer().then(_=>v.decode(_))}}}).then(f=>{xs.add(e,f);const h=ps[e];delete ps[e];for(let d=0,m=h.length;d{const h=ps[e];if(h===void 0)throw this.manager.itemError(e),f;delete ps[e];for(let d=0,m=h.length;d{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class rF extends zi{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new Ue().setHex(o.value);break;case"v2":r.uniforms[s].value=new oe().fromArray(o.value);break;case"v3":r.uniforms[s].value=new O().fromArray(o.value);break;case"v4":r.uniforms[s].value=new Ot().fromArray(o.value);break;case"m3":r.uniforms[s].value=new xt().fromArray(o.value);break;case"m4":r.uniforms[s].value=new it().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new oe().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new oe().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:YC,SpriteMaterial:Z_,RawShaderMaterial:jC,ShaderMaterial:Gn,PointsMaterial:Q_,MeshPhysicalMaterial:qC,MeshStandardMaterial:rx,MeshPhongMaterial:ZC,MeshToonMaterial:KC,MeshNormalMaterial:sx,MeshLambertMaterial:QC,MeshDepthMaterial:Y_,MeshDistanceMaterial:j_,MeshBasicMaterial:Ao,MeshMatcapMaterial:JC,LineDashedMaterial:$C,LineBasicMaterial:wi,Material:Wn};return new t[e]}}class Cy{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i0){const c=new ux(t);s=new rf(c),s.setCrossOrigin(this.crossOrigin);for(let f=0,h=e.length;f0){r=new rf(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o{const M=new Si;M.min.fromArray(E.boxMin),M.max.fromArray(E.boxMax);const g=new fi;return g.radius=E.sphereRadius,g.center.fromArray(E.sphereCenter),{boxInitialized:E.boxInitialized,box:M,sphereInitialized:E.sphereInitialized,sphere:g}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=f(e.matricesTexture.uuid);break;case"LOD":o=new PC;break;case"Line":o=new xo(a(e.geometry),c(e.material));break;case"LineLoop":o=new NC(a(e.geometry),c(e.material));break;case"LineSegments":o=new ns(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new DC(a(e.geometry),c(e.material));break;case"Sprite":o=new bC(c(e.material));break;case"Group":o=new Pl;break;case"Bone":o=new K_;break;default:o=new Dt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const m=e.children;for(let v=0;v"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=xs.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(f=>{t&&t(f),s.manager.itemEnd(e)}).catch(f=>{r&&r(f)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const c=fetch(e,a).then(function(f){return f.blob()}).then(function(f){return createImageBitmap(f,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(f){return xs.add(e,f),t&&t(f),s.manager.itemEnd(e),f}).catch(function(f){r&&r(f),xs.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});xs.add(e,c),s.manager.itemStart(e)}}let Sd;class fx{static getContext(){return Sd===void 0&&(Sd=new(window.AudioContext||window.webkitAudioContext)),Sd}static setContext(e){Sd=e}}class mF extends zi{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new bs(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{const f=c.slice(0);fx.getContext().decodeAudioData(f,function(d){t(d)}).catch(a)}catch(f){a(f)}},i,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}}const _E=new it,xE=new it,Go=new it;class gF{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Cn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Cn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Go.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(ca*t.fov*.5)/t.zoom;let a,c;xE.elements[12]=-r,_E.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,Go.elements[0]=2*t.near/(c-a),Go.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Go),a=-o*t.aspect-s,c=o*t.aspect-s,Go.elements[0]=2*t.near/(c-a),Go.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Go)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(xE),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(_E)}}class hx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=SE(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=SE();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function SE(){return(typeof performance>"u"?Date:performance).now()}const Wo=new O,ME=new Fi,vF=new O,Xo=new O;class yF extends Dt{constructor(){super(),this.type="AudioListener",this.context=fx.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new hx}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Wo,ME,vF),Xo.set(0,0,-1).applyQuaternion(ME),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Wo.x,r),t.positionY.linearRampToValueAtTime(Wo.y,r),t.positionZ.linearRampToValueAtTime(Wo.z,r),t.forwardX.linearRampToValueAtTime(Xo.x,r),t.forwardY.linearRampToValueAtTime(Xo.y,r),t.forwardZ.linearRampToValueAtTime(Xo.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(Wo.x,Wo.y,Wo.z),t.setOrientation(Xo.x,Xo.y,Xo.z,i.x,i.y,i.z)}}class gR extends Dt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let c=t,f=t+t;c!==f;++c)if(i[c]!==i[c+t]){a.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Fi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const o=this._workIndex*s;Fi.multiplyQuaternionsFlat(e,o,e,t,e,i),Fi.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){const o=1-r;for(let a=0;a!==s;++a){const c=t+a;e[c]=e[c]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[i+o]*r}}}const dx="\\[\\]\\.:\\/",MF=new RegExp("["+dx+"]","g"),px="[^"+dx+"]",EF="[^"+dx.replace("\\.","")+"]",wF=/((?:WC+[\/:])*)/.source.replace("WC",px),TF=/(WCOD+)?/.source.replace("WCOD",EF),AF=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",px),CF=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",px),RF=new RegExp("^"+wF+TF+AF+CF+"$"),bF=["material","materials","bones","map"];class PF{constructor(e,t,i){const r=i||Rt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Rt{constructor(e,t,i){this.path=t,this.parsedPath=i||Rt.parseTrackName(t),this.node=Rt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Rt.Composite(e,t,i):new Rt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(MF,"")}static parseTrackName(e){const t=RF.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);bF.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let o=0;o=s){const d=s++,m=e[d];t[m.uuid]=h,e[h]=m,t[f]=d,e[d]=c;for(let v=0,_=r;v!==_;++v){const E=i[v],M=E[d],g=E[h];E[h]=M,E[d]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){const f=arguments[a],h=f.uuid,d=t[h];if(d!==void 0)if(delete t[h],d0&&(t[v.uuid]=d),e[d]=v,e.pop();for(let _=0,E=r;_!==E;++_){const M=i[_];M[d]=M[m],M.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const o=this._paths,a=this._parsedPaths,c=this._objects,f=c.length,h=this.nCachedObjects_,d=new Array(f);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let m=h,v=c.length;m!==v;++m){const _=c[m];d[m]=new Rt(_,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],f=e[a];t[f]=i,o[i]=c,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}}class yR{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,o=s.length,a=new Array(o),c={endingStart:ia,endingEnd:ia};for(let f=0;f!==o;++f){const h=s[f].createInterpolant(null);a[f]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=eC,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const c=a.parameterPositions,f=a.sampleValues;return c[0]=s,c[1]=s+i,f[0]=e/o,f[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const c=(e-s)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const c=this._interpolants,f=this._propertyBindings;switch(this.blendMode){case F_:for(let h=0,d=c.length;h!==d;++h)c[h].evaluate(o),f[h].accumulateAdditive(a);break;case Kp:default:for(let h=0,d=c.length;h!==d;++h)c[h].evaluate(o),f[h].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const o=i===tC;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===$A){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){const a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const f=e<0;this._setEndings(f,!f,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=ra,r.endingEnd=ra):(e?r.endingStart=this.zeroSlopeAtStart?ra:ia:r.endingStart=Gc,t?r.endingEnd=this.zeroSlopeAtEnd?ra:ia:r.endingEnd=Gc)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=i,this}}const IF=new Float32Array(1);class UF extends xr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=i.uuid,f=this._bindingsByRootAndName;let h=f[c];h===void 0&&(h={},f[c]=h);for(let d=0;d!==s;++d){const m=r[d],v=m.name;let _=h[v];if(_!==void 0)++_.referenceCount,o[d]=_;else{if(_=o[d],_!==void 0){_._cacheIndex===null&&(++_.referenceCount,this._addInactiveBinding(_,c,v));continue}const E=t&&t._propertyBindings[d].binding.parsedPath;_=new vR(Rt.create(i,v,E),m.ValueTypeName,m.getValueSize()),++_.referenceCount,this._addInactiveBinding(_,c,v),o[d]=_}a[d].resultBuffer=_.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let f=0;f!==i;++f)t[f]._update(r,e,s,o);const a=this._bindings,c=this._nActiveBindings;for(let f=0;f!==c;++f)a[f].apply(o);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,TE).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const AE=new O,Md=new O;class HF{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){AE.subVectors(e,this.start),Md.subVectors(this.end,this.start);const i=Md.dot(Md);let s=Md.dot(AE)/i;return t&&(s=dn(s,0,1)),s}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const CE=new O;class VF extends Dt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new vt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o1)for(let d=0;d.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{IE.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(IE,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class tz extends ns{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new vt;r.setAttribute("position",new He(t,3)),r.setAttribute("color",new He(i,3));const s=new wi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new Ue,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class nz{constructor(){this.type="ShapePath",this.color=new Ue,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Kc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let S=0,T=g.length;SNumber.EPSILON){if(b<0&&(P=x[R],C=-C,D=x[L],b=-b),g.yD.y)continue;if(g.y===P.y){if(g.x===P.x)return!0}else{const B=b*(g.x-P.x)-C*(g.y-P.y);if(B===0)return!0;if(B<0)continue;T=!T}}else{if(g.y!==P.y)continue;if(D.x<=g.x&&g.x<=P.x||P.x<=g.x&&g.x<=D.x)return!0}}return T}const r=es.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c;const f=[];if(s.length===1)return a=s[0],c=new ha,c.curves=a.curves,f.push(c),f;let h=!r(s[0].getPoints());h=e?!h:h;const d=[],m=[];let v=[],_=0,E;m[_]=void 0,v[_]=[];for(let g=0,x=s.length;g1){let g=!1,x=0;for(let S=0,T=m.length;S0&&g===!1&&(v=d)}let M;for(let g=0,x=m.length;g{const d=typeof f=="function"?f(e):f;if(d!==e){const m=e;e=h?d:Object.assign({},e,d),t.forEach(v=>v(e,m))}},r=()=>e,s=(f,h=r,d=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let m=h(e);function v(){const _=h(e);if(!d(m,_)){const E=m;f(m=_,E)}}return t.add(v),()=>t.delete(v)},c={setState:i,getState:r,subscribe:(f,h,d)=>h||d?s(f,h,d):(t.add(f),()=>t.delete(f)),destroy:()=>t.clear()};return e=n(i,r,c),c}const sz=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),UE=sz?we.useEffect:we.useLayoutEffect;function oz(n){const e=typeof n=="function"?rz(n):n,t=(i=e.getState,r=Object.is)=>{const[,s]=we.useReducer(M=>M+1,0),o=e.getState(),a=we.useRef(o),c=we.useRef(i),f=we.useRef(r),h=we.useRef(!1),d=we.useRef();d.current===void 0&&(d.current=i(o));let m,v=!1;(a.current!==o||c.current!==i||f.current!==r||h.current)&&(m=i(o),v=!r(d.current,m)),UE(()=>{v&&(d.current=m),a.current=o,c.current=i,f.current=r,h.current=!1});const _=we.useRef(o);UE(()=>{const M=()=>{try{const x=e.getState(),S=c.current(x);f.current(d.current,S)||(a.current=x,d.current=S,s())}catch{h.current=!0,s()}},g=e.subscribe(M);return e.getState()!==_.current&&M(),g},[]);const E=v?m:d.current;return we.useDebugValue(E),E};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const i=[t,e];return{next(){const r=i.length<=0;return{value:i.shift(),done:r}}}},t}var MR={exports:{}},ER={exports:{}},wR={};/** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */(function(n){function e(z,G){var V=z.length;z.push(G);e:for(;0>>1,se=z[J];if(0>>1;Jr(Se,V))Cer(Te,Se)?(z[J]=Te,z[Ce]=V,J=Ce):(z[J]=Se,z[ue]=V,J=ue);else if(Cer(Te,V))z[J]=Te,z[Ce]=V,J=Ce;else break e}}return G}function r(z,G){var V=z.sortIndex-G.sortIndex;return V!==0?V:z.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var c=[],f=[],h=1,d=null,m=3,v=!1,_=!1,E=!1,M=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(z){for(var G=t(f);G!==null;){if(G.callback===null)i(f);else if(G.startTime<=z)i(f),G.sortIndex=G.expirationTime,e(c,G);else break;G=t(f)}}function T(z){if(E=!1,S(z),!_)if(t(c)!==null)_=!0,$(L);else{var G=t(f);G!==null&&ce(T,G.startTime-z)}}function L(z,G){_=!1,E&&(E=!1,g(D),D=-1),v=!0;var V=m;try{for(S(G),d=t(c);d!==null&&(!(d.expirationTime>G)||z&&!B());){var J=d.callback;if(typeof J=="function"){d.callback=null,m=d.priorityLevel;var se=J(d.expirationTime<=G);G=n.unstable_now(),typeof se=="function"?d.callback=se:d===t(c)&&i(c),S(G)}else i(c);d=t(c)}if(d!==null)var K=!0;else{var ue=t(f);ue!==null&&ce(T,ue.startTime-G),K=!1}return K}finally{d=null,m=V,v=!1}}var R=!1,P=null,D=-1,C=5,b=-1;function B(){return!(n.unstable_now()-bz||125J?(z.sortIndex=V,e(f,z),t(c)===null&&z===t(f)&&(E?(g(D),D=-1):E=!0,ce(T,V-J))):(z.sortIndex=se,e(c,z),_||v||(_=!0,$(L))),z},n.unstable_shouldYield=B,n.unstable_wrapCallback=function(z){var G=m;return function(){var V=m;m=G;try{return z.apply(this,arguments)}finally{m=V}}}})(wR);ER.exports=wR;var by=ER.exports;/** * @license React * react-reconciler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var az=function(e){var t={},i=we,r=by,s=Object.assign;function o(l){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+l,p=1;pX||w[F]!==A[X]){var ae=` `+w[F].replace(" at new "," at ");return l.displayName&&ae.includes("")&&(ae=ae.replace("",l.displayName)),ae}while(1<=F&&0<=X);break}}}finally{st=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?at(l):""}var tn=Object.prototype.hasOwnProperty,Yn=[],jt=-1;function Nn(l){return{current:l}}function tt(l){0>jt||(l.current=Yn[jt],Yn[jt]=null,jt--)}function Fe(l,u){jt++,Yn[jt]=l.current,l.current=u}var tr={},Mt=Nn(tr),un=Nn(!1),Br=tr;function nr(l,u){var p=l.type.contextTypes;if(!p)return tr;var y=l.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===u)return y.__reactInternalMemoizedMaskedChildContext;var w={},A;for(A in p)w[A]=u[A];return y&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=u,l.__reactInternalMemoizedMaskedChildContext=w),w}function Dn(l){return l=l.childContextTypes,l!=null}function mn(){tt(un),tt(Mt)}function kr(l,u,p){if(Mt.current!==tr)throw Error(o(168));Fe(Mt,u),Fe(un,p)}function ba(l,u,p){var y=l.stateNode;if(u=u.childContextTypes,typeof y.getChildContext!="function")return p;y=y.getChildContext();for(var w in y)if(!(w in u))throw Error(o(108,D(l)||"Unknown",w));return s({},p,y)}function jn(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||tr,Br=Mt.current,Fe(Mt,l),Fe(un,un.current),!0}function Pa(l,u,p){var y=l.stateNode;if(!y)throw Error(o(169));p?(l=ba(l,u,Br),y.__reactInternalMemoizedMergedChildContext=l,tt(un),tt(Mt),Fe(Mt,l)):tt(un),Fe(un,p)}var ki=Math.clz32?Math.clz32:qR,Af=Math.log,jR=Math.LN2;function qR(l){return l>>>=0,l===0?32:31-(Af(l)/jR|0)|0}var Cf=64,Rf=4194304;function fu(l){switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function bf(l,u){var p=l.pendingLanes;if(p===0)return 0;var y=0,w=l.suspendedLanes,A=l.pingedLanes,F=p&268435455;if(F!==0){var X=F&~w;X!==0?y=fu(X):(A&=F,A!==0&&(y=fu(A)))}else F=p&~w,F!==0?y=fu(F):A!==0&&(y=fu(A));if(y===0)return 0;if(u!==0&&u!==y&&!(u&w)&&(w=y&-y,A=u&-u,w>=A||w===16&&(A&4194240)!==0))return u;if(y&4&&(y|=p&16),u=l.entangledLanes,u!==0)for(l=l.entanglements,u&=y;0p;p++)u.push(l);return u}function hu(l,u,p){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-ki(u),l[u]=p}function QR(l,u){var p=l.pendingLanes&~u;l.pendingLanes=u,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=u,l.mutableReadLanes&=u,l.entangledLanes&=u,u=l.entanglements;var y=l.eventTimes;for(l=l.expirationTimes;0>=F,w-=F,ss=1<<32-ki(u)+w|p<It?(zn=ht,ht=null):zn=ht.sibling;var Ut=Ke(ee,ht,re[It],Le);if(Ut===null){ht===null&&(ht=zn);break}l&&ht&&Ut.alternate===null&&u(ee,ht),Y=A(Ut,Y,It),_t===null?Ge=Ut:_t.sibling=Ut,_t=Ut,ht=zn}if(It===re.length)return p(ee,ht),$t&&Po(ee,It),Ge;if(ht===null){for(;ItIt?(zn=ht,ht=null):zn=ht.sibling;var Bs=Ke(ee,ht,Ut.value,Le);if(Bs===null){ht===null&&(ht=zn);break}l&&ht&&Bs.alternate===null&&u(ee,ht),Y=A(Bs,Y,It),_t===null?Ge=Bs:_t.sibling=Bs,_t=Bs,ht=zn}if(Ut.done)return p(ee,ht),$t&&Po(ee,It),Ge;if(ht===null){for(;!Ut.done;It++,Ut=re.next())Ut=ft(ee,Ut.value,Le),Ut!==null&&(Y=A(Ut,Y,It),_t===null?Ge=Ut:_t.sibling=Ut,_t=Ut);return $t&&Po(ee,It),Ge}for(ht=y(ee,ht);!Ut.done;It++,Ut=re.next())Ut=Gt(ht,ee,It,Ut.value,Le),Ut!==null&&(l&&Ut.alternate!==null&&ht.delete(Ut.key===null?It:Ut.key),Y=A(Ut,Y,It),_t===null?Ge=Ut:_t.sibling=Ut,_t=Ut);return l&&ht.forEach(function(O2){return u(ee,O2)}),$t&&Po(ee,It),Ge}function cr(ee,Y,re,Le){if(typeof re=="object"&&re!==null&&re.type===h&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case c:e:{for(var Ge=re.key,_t=Y;_t!==null;){if(_t.key===Ge){if(Ge=re.type,Ge===h){if(_t.tag===7){p(ee,_t.sibling),Y=w(_t,re.props.children),Y.return=ee,ee=Y;break e}}else if(_t.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===S&&Ux(Ge)===_t.type){p(ee,_t.sibling),Y=w(_t,re.props),Y.ref=mu(ee,_t,re),Y.return=ee,ee=Y;break e}p(ee,_t);break}else u(ee,_t);_t=_t.sibling}re.type===h?(Y=Fo(re.props.children,ee.mode,Le,re.key),Y.return=ee,ee=Y):(Le=vh(re.type,re.key,re.props,null,ee.mode,Le),Le.ref=mu(ee,Y,re),Le.return=ee,ee=Le)}return F(ee);case f:e:{for(_t=re.key;Y!==null;){if(Y.key===_t)if(Y.tag===4&&Y.stateNode.containerInfo===re.containerInfo&&Y.stateNode.implementation===re.implementation){p(ee,Y.sibling),Y=w(Y,re.children||[]),Y.return=ee,ee=Y;break e}else{p(ee,Y);break}else u(ee,Y);Y=Y.sibling}Y=Cg(re,ee.mode,Le),Y.return=ee,ee=Y}return F(ee);case S:return _t=re._init,cr(ee,Y,_t(re._payload),Le)}if(Z(re))return Xe(ee,Y,re,Le);if(R(re))return ti(ee,Y,re,Le);kf(ee,re)}return typeof re=="string"&&re!==""||typeof re=="number"?(re=""+re,Y!==null&&Y.tag===6?(p(ee,Y.sibling),Y=w(Y,re),Y.return=ee,ee=Y):(p(ee,Y),Y=Ag(re,ee.mode,Le),Y.return=ee,ee=Y),F(ee)):p(ee,Y)}return cr}var Oa=Nx(!0),Dx=Nx(!1),gu={},or=Nn(gu),vu=Nn(gu),Fa=Nn(gu);function Xr(l){if(l===gu)throw Error(o(174));return l}function Wm(l,u){Fe(Fa,u),Fe(vu,l),Fe(or,gu),l=ce(u),tt(or),Fe(or,l)}function za(){tt(or),tt(vu),tt(Fa)}function Ox(l){var u=Xr(Fa.current),p=Xr(or.current);u=z(p,l.type,u),p!==u&&(Fe(vu,l),Fe(or,u))}function Xm(l){vu.current===l&&(tt(or),tt(vu))}var nn=Nn(0);function Hf(l){for(var u=l;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||uu(p)||cu(p)))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if(u.flags&128)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var Ym=[];function jm(){for(var l=0;lp?p:4,l(!0);var y=ar.transition;ar.transition={};try{l(!1),u()}finally{Lt=p,ar.transition=y}}function Kx(){return Yr().memoizedState}function u2(l,u,p){var y=Os(l);p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},Qx(l)?Jx(u,p):($x(l,u,p),p=pi(),l=lr(l,y,p),l!==null&&eS(l,u,y))}function c2(l,u,p){var y=Os(l),w={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(Qx(l))Jx(u,w);else{$x(l,u,w);var A=l.alternate;if(l.lanes===0&&(A===null||A.lanes===0)&&(A=u.lastRenderedReducer,A!==null))try{var F=u.lastRenderedState,X=A(F,p);if(w.hasEagerState=!0,w.eagerState=X,Vr(X,F))return}catch{}finally{}p=pi(),l=lr(l,y,p),l!==null&&eS(l,u,y)}}function Qx(l){var u=l.alternate;return l===cn||u!==null&&u===cn}function Jx(l,u){yu=Gf=!0;var p=l.pending;p===null?u.next=u:(u.next=p.next,p.next=u),l.pending=u}function $x(l,u,p){xn!==null&&l.mode&1&&!(Et&2)?(l=u.interleaved,l===null?(p.next=p,Wr===null?Wr=[u]:Wr.push(u)):(p.next=l.next,l.next=p),u.interleaved=p):(l=u.pending,l===null?p.next=p:(p.next=l.next,l.next=p),u.pending=p)}function eS(l,u,p){if(p&4194240){var y=u.lanes;y&=l.pendingLanes,p|=y,u.lanes=p,Cm(l,p)}}var qf={readContext:ir,useCallback:$n,useContext:$n,useEffect:$n,useImperativeHandle:$n,useInsertionEffect:$n,useLayoutEffect:$n,useMemo:$n,useReducer:$n,useRef:$n,useState:$n,useDebugValue:$n,useDeferredValue:$n,useTransition:$n,useMutableSource:$n,useSyncExternalStore:$n,useId:$n,unstable_isNewReconciler:!1},f2={readContext:ir,useCallback:function(l,u){return as().memoizedState=[l,u===void 0?null:u],l},useContext:ir,useEffect:Jm,useImperativeHandle:function(l,u,p){return p=p!=null?p.concat([l]):null,Yf(4194308,4,Yx.bind(null,u,l),p)},useLayoutEffect:function(l,u){return Yf(4194308,4,l,u)},useInsertionEffect:function(l,u){return Yf(4,2,l,u)},useMemo:function(l,u){var p=as();return u=u===void 0?null:u,l=l(),p.memoizedState=[l,u],l},useReducer:function(l,u,p){var y=as();return u=p!==void 0?p(u):u,y.memoizedState=y.baseState=u,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:u},y.queue=l,l=l.dispatch=u2.bind(null,cn,l),[y.memoizedState,l]},useRef:function(l){var u=as();return l={current:l},u.memoizedState=l},useState:Qm,useDebugValue:$m,useDeferredValue:function(l){var u=Qm(l),p=u[0],y=u[1];return Jm(function(){var w=ar.transition;ar.transition={};try{y(l)}finally{ar.transition=w}},[l]),p},useTransition:function(){var l=Qm(!1),u=l[0];return l=l2.bind(null,l[1]),as().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,p){var y=cn,w=as();if($t){if(p===void 0)throw Error(o(407));p=p()}else{if(p=u(),xn===null)throw Error(o(349));Ba&30||Bx(y,u,p)}w.memoizedState=p;var A={value:p,getSnapshot:u};return w.queue=A,Jm(Hx.bind(null,y,A,l),[l]),y.flags|=2048,xu(9,kx.bind(null,y,A,p,u),void 0,null),p},useId:function(){var l=as(),u=xn.identifierPrefix;if($t){var p=os,y=ss;p=(y&~(1<<32-ki(y)-1)).toString(32)+p,u=":"+u+"R"+p,p=_u++,0yg&&(u.flags|=128,y=!0,wu(w,!1),u.lanes=4194304)}else{if(!y)if(l=Hf(A),l!==null){if(u.flags|=128,y=!0,l=l.updateQueue,l!==null&&(u.updateQueue=l,u.flags|=4),wu(w,!0),w.tail===null&&w.tailMode==="hidden"&&!A.alternate&&!$t)return ei(u),null}else 2*On()-w.renderingStartTime>yg&&p!==1073741824&&(u.flags|=128,y=!0,wu(w,!1),u.lanes=4194304);w.isBackwards?(A.sibling=u.child,u.child=A):(l=w.last,l!==null?l.sibling=A:u.child=A,w.last=A)}return w.tail!==null?(u=w.tail,w.rendering=u,w.tail=u.sibling,w.renderingStartTime=On(),u.sibling=null,l=nn.current,Fe(nn,y?l&1|2:l&1),u):(ei(u),null);case 22:case 23:return Eg(),y=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(u.flags|=8192),y&&u.mode&1?Wi&1073741824&&(ei(u),je&&u.subtreeFlags&6&&(u.flags|=8192)):ei(u),null;case 24:return null;case 25:return null}throw Error(o(156,u.tag))}var g2=a.ReactCurrentOwner,Gi=!1;function di(l,u,p,y){u.child=l===null?Dx(u,null,p,y):Oa(u,l.child,p,y)}function lS(l,u,p,y,w){p=p.render;var A=u.ref;return Ia(u,w),y=Zm(l,u,p,y,A,w),p=Km(),l!==null&&!Gi?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~w,ls(l,u,w)):($t&&p&&Bm(u),u.flags|=1,di(l,u,y,w),u.child)}function uS(l,u,p,y,w){if(l===null){var A=p.type;return typeof A=="function"&&!Tg(A)&&A.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(u.tag=15,u.type=A,cS(l,u,A,y,w)):(l=vh(p.type,null,y,u,u.mode,w),l.ref=u.ref,l.return=u,u.child=l)}if(A=l.child,!(l.lanes&w)){var F=A.memoizedProps;if(p=p.compare,p=p!==null?p:If,p(F,y)&&l.ref===u.ref)return ls(l,u,w)}return u.flags|=1,l=zs(A,y),l.ref=u.ref,l.return=u,u.child=l}function cS(l,u,p,y,w){if(l!==null&&If(l.memoizedProps,y)&&l.ref===u.ref)if(Gi=!1,(l.lanes&w)!==0)l.flags&131072&&(Gi=!0);else return u.lanes=l.lanes,ls(l,u,w);return ng(l,u,p,y,w)}function fS(l,u,p){var y=u.pendingProps,w=y.children,A=l!==null?l.memoizedState:null;if(y.mode==="hidden")if(!(u.mode&1))u.memoizedState={baseLanes:0,cachePool:null},Fe(ka,Wi),Wi|=p;else if(p&1073741824)u.memoizedState={baseLanes:0,cachePool:null},y=A!==null?A.baseLanes:p,Fe(ka,Wi),Wi|=y;else return l=A!==null?A.baseLanes|p:p,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:l,cachePool:null},u.updateQueue=null,Fe(ka,Wi),Wi|=l,null;else A!==null?(y=A.baseLanes|p,u.memoizedState=null):y=p,Fe(ka,Wi),Wi|=y;return di(l,u,w,p),u.child}function hS(l,u){var p=u.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(u.flags|=512,u.flags|=2097152)}function ng(l,u,p,y,w){var A=Dn(p)?Br:Mt.current;return A=nr(u,A),Ia(u,w),p=Zm(l,u,p,y,A,w),y=Km(),l!==null&&!Gi?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~w,ls(l,u,w)):($t&&y&&Bm(u),u.flags|=1,di(l,u,p,w),u.child)}function dS(l,u,p,y,w){if(Dn(p)){var A=!0;jn(u)}else A=!1;if(Ia(u,w),u.stateNode===null)l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2),Cx(u,p,y),zm(u,p,y,w),y=!0;else if(l===null){var F=u.stateNode,X=u.memoizedProps;F.props=X;var ae=F.context,xe=p.contextType;typeof xe=="object"&&xe!==null?xe=ir(xe):(xe=Dn(p)?Br:Mt.current,xe=nr(u,xe));var ze=p.getDerivedStateFromProps,ft=typeof ze=="function"||typeof F.getSnapshotBeforeUpdate=="function";ft||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(X!==y||ae!==xe)&&Rx(u,F,y,xe),Is=!1;var Ke=u.memoizedState;F.state=Ke,Of(u,y,F,w),ae=u.memoizedState,X!==y||Ke!==ae||un.current||Is?(typeof ze=="function"&&(Fm(u,p,ze,y),ae=u.memoizedState),(X=Is||Ax(u,p,X,y,Ke,ae,xe))?(ft||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount()),typeof F.componentDidMount=="function"&&(u.flags|=4194308)):(typeof F.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=y,u.memoizedState=ae),F.props=y,F.state=ae,F.context=xe,y=X):(typeof F.componentDidMount=="function"&&(u.flags|=4194308),y=!1)}else{F=u.stateNode,Mx(l,u),X=u.memoizedProps,xe=u.type===u.elementType?X:Sr(u.type,X),F.props=xe,ft=u.pendingProps,Ke=F.context,ae=p.contextType,typeof ae=="object"&&ae!==null?ae=ir(ae):(ae=Dn(p)?Br:Mt.current,ae=nr(u,ae));var Gt=p.getDerivedStateFromProps;(ze=typeof Gt=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(X!==ft||Ke!==ae)&&Rx(u,F,y,ae),Is=!1,Ke=u.memoizedState,F.state=Ke,Of(u,y,F,w);var Xe=u.memoizedState;X!==ft||Ke!==Xe||un.current||Is?(typeof Gt=="function"&&(Fm(u,p,Gt,y),Xe=u.memoizedState),(xe=Is||Ax(u,p,xe,y,Ke,Xe,ae)||!1)?(ze||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(y,Xe,ae),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(y,Xe,ae)),typeof F.componentDidUpdate=="function"&&(u.flags|=4),typeof F.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof F.componentDidUpdate!="function"||X===l.memoizedProps&&Ke===l.memoizedState||(u.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||X===l.memoizedProps&&Ke===l.memoizedState||(u.flags|=1024),u.memoizedProps=y,u.memoizedState=Xe),F.props=y,F.state=Xe,F.context=ae,y=xe):(typeof F.componentDidUpdate!="function"||X===l.memoizedProps&&Ke===l.memoizedState||(u.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||X===l.memoizedProps&&Ke===l.memoizedState||(u.flags|=1024),y=!1)}return ig(l,u,p,y,A,w)}function ig(l,u,p,y,w,A){hS(l,u);var F=(u.flags&128)!==0;if(!y&&!F)return w&&Pa(u,p,!1),ls(l,u,A);y=u.stateNode,g2.current=u;var X=F&&typeof p.getDerivedStateFromError!="function"?null:y.render();return u.flags|=1,l!==null&&F?(u.child=Oa(u,l.child,null,A),u.child=Oa(u,null,X,A)):di(l,u,X,A),u.memoizedState=y.state,w&&Pa(u,p,!0),u.child}function pS(l){var u=l.stateNode;u.pendingContext?kr(l,u.pendingContext,u.pendingContext!==u.context):u.context&&kr(l,u.context,!1),Wm(l,u.containerInfo)}function mS(l,u,p,y,w){return Da(),Gm(w),u.flags|=256,di(l,u,p,y),u.child}var Qf={dehydrated:null,treeContext:null,retryLane:0};function Jf(l){return{baseLanes:l,cachePool:null}}function gS(l,u,p){var y=u.pendingProps,w=nn.current,A=!1,F=(u.flags&128)!==0,X;if((X=F)||(X=l!==null&&l.memoizedState===null?!1:(w&2)!==0),X?(A=!0,u.flags&=-129):(l===null||l.memoizedState!==null)&&(w|=1),Fe(nn,w&1),l===null)return Vm(u),l=u.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?(u.mode&1?cu(l)?u.lanes=8:u.lanes=1073741824:u.lanes=1,null):(w=y.children,l=y.fallback,A?(y=u.mode,A=u.child,w={mode:"hidden",children:w},!(y&1)&&A!==null?(A.childLanes=0,A.pendingProps=w):A=yh(w,y,0,null),l=Fo(l,y,p,null),A.return=u,l.return=u,A.sibling=l,u.child=A,u.child.memoizedState=Jf(p),u.memoizedState=Qf,l):rg(u,w));if(w=l.memoizedState,w!==null){if(X=w.dehydrated,X!==null){if(F)return u.flags&256?(u.flags&=-257,$f(l,u,p,Error(o(422)))):u.memoizedState!==null?(u.child=l.child,u.flags|=128,null):(A=y.fallback,w=u.mode,y=yh({mode:"visible",children:y.children},w,0,null),A=Fo(A,w,p,null),A.flags|=2,y.return=u,A.return=u,y.sibling=A,u.child=y,u.mode&1&&Oa(u,l.child,null,p),u.child.memoizedState=Jf(p),u.memoizedState=Qf,A);if(!(u.mode&1))u=$f(l,u,p,null);else if(cu(X))u=$f(l,u,p,Error(o(419)));else if(y=(p&l.childLanes)!==0,Gi||y){if(y=xn,y!==null){switch(p&-p){case 4:A=2;break;case 16:A=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:A=32;break;case 536870912:A=268435456;break;default:A=0}y=A&(y.suspendedLanes|p)?0:A,y!==0&&y!==w.retryLane&&(w.retryLane=y,lr(l,y,-1))}wg(),u=$f(l,u,p,Error(o(421)))}else uu(X)?(u.flags|=128,u.child=l.child,u=b2.bind(null,l),Ca(X,u),u=null):(p=w.treeContext,ve&&(Vi=Tf(X),Hi=u,$t=!0,Mr=null,du=!1,p!==null&&(rr[sr++]=ss,rr[sr++]=os,rr[sr++]=bo,ss=p.id,os=p.overflow,bo=u)),u=rg(u,u.pendingProps.children),u.flags|=4096);return u}return A?(y=yS(l,u,y.children,y.fallback,p),A=u.child,w=l.child.memoizedState,A.memoizedState=w===null?Jf(p):{baseLanes:w.baseLanes|p,cachePool:null},A.childLanes=l.childLanes&~p,u.memoizedState=Qf,y):(p=vS(l,u,y.children,p),u.memoizedState=null,p)}return A?(y=yS(l,u,y.children,y.fallback,p),A=u.child,w=l.child.memoizedState,A.memoizedState=w===null?Jf(p):{baseLanes:w.baseLanes|p,cachePool:null},A.childLanes=l.childLanes&~p,u.memoizedState=Qf,y):(p=vS(l,u,y.children,p),u.memoizedState=null,p)}function rg(l,u){return u=yh({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function vS(l,u,p,y){var w=l.child;return l=w.sibling,p=zs(w,{mode:"visible",children:p}),!(u.mode&1)&&(p.lanes=y),p.return=u,p.sibling=null,l!==null&&(y=u.deletions,y===null?(u.deletions=[l],u.flags|=16):y.push(l)),u.child=p}function yS(l,u,p,y,w){var A=u.mode;l=l.child;var F=l.sibling,X={mode:"hidden",children:p};return!(A&1)&&u.child!==l?(p=u.child,p.childLanes=0,p.pendingProps=X,u.deletions=null):(p=zs(l,X),p.subtreeFlags=l.subtreeFlags&14680064),F!==null?y=zs(F,y):(y=Fo(y,A,w,null),y.flags|=2),y.return=u,p.return=u,p.sibling=y,u.child=p,y}function $f(l,u,p,y){return y!==null&&Gm(y),Oa(u,l.child,null,p),l=rg(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function _S(l,u,p){l.lanes|=u;var y=l.alternate;y!==null&&(y.lanes|=u),Dm(l.return,u,p)}function sg(l,u,p,y,w){var A=l.memoizedState;A===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:w}:(A.isBackwards=u,A.rendering=null,A.renderingStartTime=0,A.last=y,A.tail=p,A.tailMode=w)}function xS(l,u,p){var y=u.pendingProps,w=y.revealOrder,A=y.tail;if(di(l,u,y.children,p),y=nn.current,y&2)y=y&1|2,u.flags|=128;else{if(l!==null&&l.flags&128)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&_S(l,p,u);else if(l.tag===19)_S(l,p,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}y&=1}if(Fe(nn,y),!(u.mode&1))u.memoizedState=null;else switch(w){case"forwards":for(p=u.child,w=null;p!==null;)l=p.alternate,l!==null&&Hf(l)===null&&(w=p),p=p.sibling;p=w,p===null?(w=u.child,u.child=null):(w=p.sibling,p.sibling=null),sg(u,!1,w,p,A);break;case"backwards":for(p=null,w=u.child,u.child=null;w!==null;){if(l=w.alternate,l!==null&&Hf(l)===null){u.child=w;break}l=w.sibling,w.sibling=p,p=w,w=l}sg(u,!0,p,null,A);break;case"together":sg(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function ls(l,u,p){if(l!==null&&(u.dependencies=l.dependencies),Ha|=u.lanes,!(p&u.childLanes))return null;if(l!==null&&u.child!==l.child)throw Error(o(153));if(u.child!==null){for(l=u.child,p=zs(l,l.pendingProps),u.child=p,p.return=u;l.sibling!==null;)l=l.sibling,p=p.sibling=zs(l,l.pendingProps),p.return=u;p.sibling=null}return u.child}function v2(l,u,p){switch(u.tag){case 3:pS(u),Da();break;case 5:Ox(u);break;case 1:Dn(u.type)&&jn(u);break;case 4:Wm(u,u.stateNode.containerInfo);break;case 10:Sx(u,u.type._context,u.memoizedProps.value);break;case 13:var y=u.memoizedState;if(y!==null)return y.dehydrated!==null?(Fe(nn,nn.current&1),u.flags|=128,null):p&u.child.childLanes?gS(l,u,p):(Fe(nn,nn.current&1),l=ls(l,u,p),l!==null?l.sibling:null);Fe(nn,nn.current&1);break;case 19:if(y=(p&u.childLanes)!==0,l.flags&128){if(y)return xS(l,u,p);u.flags|=128}var w=u.memoizedState;if(w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),Fe(nn,nn.current),y)break;return null;case 22:case 23:return u.lanes=0,fS(l,u,p)}return ls(l,u,p)}function y2(l,u){switch(km(u),u.tag){case 1:return Dn(u.type)&&mn(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return za(),tt(un),tt(Mt),jm(),l=u.flags,l&65536&&!(l&128)?(u.flags=l&-65537|128,u):null;case 5:return Xm(u),null;case 13:if(tt(nn),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(o(340));Da()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return tt(nn),null;case 4:return za(),null;case 10:return Nm(u.type._context),null;case 22:case 23:return Eg(),null;case 24:return null;default:return null}}var eh=!1,Io=!1,_2=typeof WeakSet=="function"?WeakSet:Set,Pe=null;function th(l,u){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){Ci(l,u,y)}else p.current=null}function og(l,u,p){try{p()}catch(y){Ci(l,u,y)}}var SS=!1;function x2(l,u){for(G(l.containerInfo),Pe=u;Pe!==null;)if(l=Pe,u=l.child,(l.subtreeFlags&1028)!==0&&u!==null)u.return=l,Pe=u;else for(;Pe!==null;){l=Pe;try{var p=l.alternate;if(l.flags&1024)switch(l.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var y=p.memoizedProps,w=p.memoizedState,A=l.stateNode,F=A.getSnapshotBeforeUpdate(l.elementType===l.type?y:Sr(l.type,y),w);A.__reactInternalSnapshotBeforeUpdate=F}break;case 3:je&&Re(l.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(X){Ci(l,l.return,X)}if(u=l.sibling,u!==null){u.return=l.return,Pe=u;break}Pe=l.return}return p=SS,SS=!1,p}function Uo(l,u,p){var y=u.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var w=y=y.next;do{if((w.tag&l)===l){var A=w.destroy;w.destroy=void 0,A!==void 0&&og(u,p,A)}w=w.next}while(w!==y)}}function Tu(l,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var p=u=u.next;do{if((p.tag&l)===l){var y=p.create;p.destroy=y()}p=p.next}while(p!==u)}}function ag(l){var u=l.ref;if(u!==null){var p=l.stateNode;switch(l.tag){case 5:l=$(p);break;default:l=p}typeof u=="function"?u(l):u.current=l}}function MS(l,u,p){if(Hr&&typeof Hr.onCommitFiberUnmount=="function")try{Hr.onCommitFiberUnmount(Pf,u)}catch{}switch(u.tag){case 0:case 11:case 14:case 15:if(l=u.updateQueue,l!==null&&(l=l.lastEffect,l!==null)){var y=l=l.next;do{var w=y,A=w.destroy;w=w.tag,A!==void 0&&(w&2||w&4)&&og(u,p,A),y=y.next}while(y!==l)}break;case 1:if(th(u,p),l=u.stateNode,typeof l.componentWillUnmount=="function")try{l.props=u.memoizedProps,l.state=u.memoizedState,l.componentWillUnmount()}catch(F){Ci(u,p,F)}break;case 5:th(u,p);break;case 4:je?RS(l,u,p):k&&k&&(u=u.stateNode.containerInfo,p=$e(u),zt(u,p))}}function ES(l,u,p){for(var y=u;;)if(MS(l,y,p),y.child===null||je&&y.tag===4){if(y===u)break;for(;y.sibling===null;){if(y.return===null||y.return===u)return;y=y.return}y.sibling.return=y.return,y=y.sibling}else y.child.return=y,y=y.child}function wS(l){var u=l.alternate;u!==null&&(l.alternate=null,wS(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&Ye(u)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function TS(l){return l.tag===5||l.tag===3||l.tag===4}function AS(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||TS(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function CS(l){if(je){e:{for(var u=l.return;u!==null;){if(TS(u))break e;u=u.return}throw Error(o(160))}var p=u;switch(p.tag){case 5:u=p.stateNode,p.flags&32&&(Pt(u),p.flags&=-33),p=AS(l),ug(l,p,u);break;case 3:case 4:u=p.stateNode.containerInfo,p=AS(l),lg(l,p,u);break;default:throw Error(o(161))}}}function lg(l,u,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,u?qe(p,l,u):ct(p,l);else if(y!==4&&(l=l.child,l!==null))for(lg(l,u,p),l=l.sibling;l!==null;)lg(l,u,p),l=l.sibling}function ug(l,u,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,u?ot(p,l,u):Qe(p,l);else if(y!==4&&(l=l.child,l!==null))for(ug(l,u,p),l=l.sibling;l!==null;)ug(l,u,p),l=l.sibling}function RS(l,u,p){for(var y=u,w=!1,A,F;;){if(!w){w=y.return;e:for(;;){if(w===null)throw Error(o(160));switch(A=w.stateNode,w.tag){case 5:F=!1;break e;case 3:A=A.containerInfo,F=!0;break e;case 4:A=A.containerInfo,F=!0;break e}w=w.return}w=!0}if(y.tag===5||y.tag===6)ES(l,y,p),F?dt(A,y.stateNode):Be(A,y.stateNode);else if(y.tag===18)F?te(A,y.stateNode):ie(A,y.stateNode);else if(y.tag===4){if(y.child!==null){A=y.stateNode.containerInfo,F=!0,y.child.return=y,y=y.child;continue}}else if(MS(l,y,p),y.child!==null){y.child.return=y,y=y.child;continue}if(y===u)break;for(;y.sibling===null;){if(y.return===null||y.return===u)return;y=y.return,y.tag===4&&(w=!1)}y.sibling.return=y.return,y=y.sibling}}function cg(l,u){if(je){switch(u.tag){case 0:case 11:case 14:case 15:Uo(3,u,u.return),Tu(3,u),Uo(5,u,u.return);return;case 1:return;case 5:var p=u.stateNode;if(p!=null){var y=u.memoizedProps;l=l!==null?l.memoizedProps:y;var w=u.type,A=u.updateQueue;u.updateQueue=null,A!==null&&St(p,A,w,l,y,u)}return;case 6:if(u.stateNode===null)throw Error(o(162));p=u.memoizedProps,me(u.stateNode,l!==null?l.memoizedProps:p,p);return;case 3:ve&&l!==null&&l.memoizedState.isDehydrated&&q(u.stateNode.containerInfo);return;case 12:return;case 13:nh(u);return;case 19:nh(u);return;case 17:return}throw Error(o(163))}switch(u.tag){case 0:case 11:case 14:case 15:Uo(3,u,u.return),Tu(3,u),Uo(5,u,u.return);return;case 12:return;case 13:nh(u);return;case 19:nh(u);return;case 3:ve&&l!==null&&l.memoizedState.isDehydrated&&q(u.stateNode.containerInfo);break;case 22:case 23:return}e:if(k){switch(u.tag){case 1:case 5:case 6:break e;case 3:case 4:u=u.stateNode,zt(u.containerInfo,u.pendingChildren);break e}throw Error(o(163))}}function nh(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new _2),u.forEach(function(y){var w=P2.bind(null,l,y);p.has(y)||(p.add(y),y.then(w,w))})}}function S2(l,u){for(Pe=u;Pe!==null;){u=Pe;var p=u.deletions;if(p!==null)for(var y=0;y";case rh:return":has("+(dg(l)||"")+")";case sh:return'[role="'+l.value+'"]';case ah:return'"'+l.value+'"';case oh:return'[data-testname="'+l.value+'"]';default:throw Error(o(365))}}function US(l,u){var p=[];l=[l,0];for(var y=0;yw&&(w=F),y&=~A}if(y=w,y=On()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*E2(y/1960))-y,10l?16:l,Ds===null)var y=!1;else{if(l=Ds,Ds=null,hh=0,Et&6)throw Error(o(331));var w=Et;for(Et|=4,Pe=l.current;Pe!==null;){var A=Pe,F=A.child;if(Pe.flags&16){var X=A.deletions;if(X!==null){for(var ae=0;aeOn()-vg?No(l,0):gg|=p),Ai(l,u)}function VS(l,u){u===0&&(l.mode&1?(u=Rf,Rf<<=1,!(Rf&130023424)&&(Rf=4194304)):u=1);var p=pi();l=mh(l,u),l!==null&&(hu(l,u,p),Ai(l,p))}function b2(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),VS(l,p)}function P2(l,u){var p=0;switch(l.tag){case 13:var y=l.stateNode,w=l.memoizedState;w!==null&&(p=w.retryLane);break;case 19:y=l.stateNode;break;default:throw Error(o(314))}y!==null&&y.delete(u),VS(l,p)}var GS;GS=function(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps||un.current)Gi=!0;else{if(!(l.lanes&p)&&!(u.flags&128))return Gi=!1,v2(l,u,p);Gi=!!(l.flags&131072)}else Gi=!1,$t&&u.flags&1048576&&bx(u,Bf,u.index);switch(u.lanes=0,u.tag){case 2:var y=u.type;l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2),l=u.pendingProps;var w=nr(u,Mt.current);Ia(u,p),w=Zm(null,u,y,l,w,p);var A=Km();return u.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,Dn(y)?(A=!0,jn(u)):A=!1,u.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,Om(u),w.updater=Ff,u.stateNode=w,w._reactInternals=u,zm(u,y,l,p),u=ig(null,u,y,!0,A,p)):(u.tag=0,$t&&A&&Bm(u),di(null,u,w,p),u=u.child),u;case 16:y=u.elementType;e:{switch(l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2),l=u.pendingProps,w=y._init,y=w(y._payload),u.type=y,w=u.tag=I2(y),l=Sr(y,l),w){case 0:u=ng(null,u,y,l,p);break e;case 1:u=dS(null,u,y,l,p);break e;case 11:u=lS(null,u,y,l,p);break e;case 14:u=uS(null,u,y,Sr(y.type,l),p);break e}throw Error(o(306,y,""))}return u;case 0:return y=u.type,w=u.pendingProps,w=u.elementType===y?w:Sr(y,w),ng(l,u,y,w,p);case 1:return y=u.type,w=u.pendingProps,w=u.elementType===y?w:Sr(y,w),dS(l,u,y,w,p);case 3:e:{if(pS(u),l===null)throw Error(o(387));y=u.pendingProps,A=u.memoizedState,w=A.element,Mx(l,u),Of(u,y,null,p);var F=u.memoizedState;if(y=F.element,ve&&A.isDehydrated)if(A={element:y,isDehydrated:!1,cache:F.cache,transitions:F.transitions},u.updateQueue.baseState=A,u.memoizedState=A,u.flags&256){w=Error(o(423)),u=mS(l,u,y,p,w);break e}else if(y!==w){w=Error(o(424)),u=mS(l,u,y,p,w);break e}else for(ve&&(Vi=wf(u.stateNode.containerInfo),Hi=u,$t=!0,Mr=null,du=!1),p=Dx(u,null,y,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Da(),y===w){u=ls(l,u,p);break e}di(l,u,y,p)}u=u.child}return u;case 5:return Ox(u),l===null&&Vm(u),y=u.type,w=u.pendingProps,A=l!==null?l.memoizedProps:null,F=w.children,Se(y,w)?F=null:A!==null&&Se(y,A)&&(u.flags|=32),hS(l,u),di(l,u,F,p),u.child;case 6:return l===null&&Vm(u),null;case 13:return gS(l,u,p);case 4:return Wm(u,u.stateNode.containerInfo),y=u.pendingProps,l===null?u.child=Oa(u,null,y,p):di(l,u,y,p),u.child;case 11:return y=u.type,w=u.pendingProps,w=u.elementType===y?w:Sr(y,w),lS(l,u,y,w,p);case 7:return di(l,u,u.pendingProps,p),u.child;case 8:return di(l,u,u.pendingProps.children,p),u.child;case 12:return di(l,u,u.pendingProps.children,p),u.child;case 10:e:{if(y=u.type._context,w=u.pendingProps,A=u.memoizedProps,F=w.value,Sx(u,y,F),A!==null)if(Vr(A.value,F)){if(A.children===w.children&&!un.current){u=ls(l,u,p);break e}}else for(A=u.child,A!==null&&(A.return=u);A!==null;){var X=A.dependencies;if(X!==null){F=A.child;for(var ae=X.firstContext;ae!==null;){if(ae.context===y){if(A.tag===1){ae=rs(-1,p&-p),ae.tag=2;var xe=A.updateQueue;if(xe!==null){xe=xe.shared;var ze=xe.pending;ze===null?ae.next=ae:(ae.next=ze.next,ze.next=ae),xe.pending=ae}}A.lanes|=p,ae=A.alternate,ae!==null&&(ae.lanes|=p),Dm(A.return,p,u),X.lanes|=p;break}ae=ae.next}}else if(A.tag===10)F=A.type===u.type?null:A.child;else if(A.tag===18){if(F=A.return,F===null)throw Error(o(341));F.lanes|=p,X=F.alternate,X!==null&&(X.lanes|=p),Dm(F,p,u),F=A.sibling}else F=A.child;if(F!==null)F.return=A;else for(F=A;F!==null;){if(F===u){F=null;break}if(A=F.sibling,A!==null){A.return=F.return,F=A;break}F=F.return}A=F}di(l,u,w.children,p),u=u.child}return u;case 9:return w=u.type,y=u.pendingProps.children,Ia(u,p),w=ir(w),y=y(w),u.flags|=1,di(l,u,y,p),u.child;case 14:return y=u.type,w=Sr(y,u.pendingProps),w=Sr(y.type,w),uS(l,u,y,w,p);case 15:return cS(l,u,u.type,u.pendingProps,p);case 17:return y=u.type,w=u.pendingProps,w=u.elementType===y?w:Sr(y,w),l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2),u.tag=1,Dn(y)?(l=!0,jn(u)):l=!1,Ia(u,p),Cx(u,y,w),zm(u,y,w,p),ig(null,u,y,!0,l,p);case 19:return xS(l,u,p);case 22:return fS(l,u,p)}throw Error(o(156,u.tag))};function WS(l,u){return Rm(l,u)}function L2(l,u,p,y){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ur(l,u,p,y){return new L2(l,u,p,y)}function Tg(l){return l=l.prototype,!(!l||!l.isReactComponent)}function I2(l){if(typeof l=="function")return Tg(l)?1:0;if(l!=null){if(l=l.$$typeof,l===E)return 11;if(l===x)return 14}return 2}function zs(l,u){var p=l.alternate;return p===null?(p=ur(l.tag,u,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=u,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,u=l.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function vh(l,u,p,y,w,A){var F=2;if(y=l,typeof l=="function")Tg(l)&&(F=1);else if(typeof l=="string")F=5;else e:switch(l){case h:return Fo(p.children,w,A,u);case d:F=8,w|=8;break;case m:return l=ur(12,p,u,w|2),l.elementType=m,l.lanes=A,l;case M:return l=ur(13,p,u,w),l.elementType=M,l.lanes=A,l;case g:return l=ur(19,p,u,w),l.elementType=g,l.lanes=A,l;case T:return yh(p,w,A,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case v:F=10;break e;case _:F=9;break e;case E:F=11;break e;case x:F=14;break e;case S:F=16,y=null;break e}throw Error(o(130,l==null?l:typeof l,""))}return u=ur(F,p,u,w),u.elementType=l,u.type=y,u.lanes=A,u}function Fo(l,u,p,y){return l=ur(7,l,y,u),l.lanes=p,l}function yh(l,u,p,y){return l=ur(22,l,y,u),l.elementType=T,l.lanes=p,l.stateNode={},l}function Ag(l,u,p){return l=ur(6,l,null,u),l.lanes=p,l}function Cg(l,u,p){return u=ur(4,l.children!==null?l.children:[],l.key,u),u.lanes=p,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function U2(l,u,p,y,w){this.tag=u,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=rt,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Am(0),this.expirationTimes=Am(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Am(0),this.identifierPrefix=y,this.onRecoverableError=w,ve&&(this.mutableSourceEagerHydrationData=null)}function XS(l,u,p,y,w,A,F,X,ae){return l=new U2(l,u,p,X,ae),u===1?(u=1,A===!0&&(u|=8)):u=0,A=ur(3,null,null,u),l.current=A,A.stateNode=l,A.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null},Om(A),l}function YS(l){if(!l)return tr;l=l._reactInternals;e:{if(C(l)!==l||l.tag!==1)throw Error(o(170));var u=l;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(Dn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(o(171))}if(l.tag===1){var p=l.type;if(Dn(p))return ba(l,p,u)}return u}function jS(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(o(188)):(l=Object.keys(l).join(","),Error(o(268,l)));return l=j(u),l===null?null:l.stateNode}function qS(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p=xe&&A>=ft&&w<=ze&&F<=Ke){l.splice(u,1);break}else if(y!==xe||p.width!==ae.width||KeF){if(!(A!==ft||p.height!==ae.height||zew)){xe>y&&(ae.width+=xe-y,ae.x=y),zeA&&(ae.height+=ft-A,ae.y=A),Kep&&(p=F)),F ")+` No matching component was found for: `)+l.join(" > ")}return null},t.getPublicRootInstance=function(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return $(l.child.stateNode);default:return l.child.stateNode}},t.injectIntoDevTools=function(l){if(l={bundleType:l.bundleType,version:l.version,rendererPackageName:l.rendererPackageName,rendererConfig:l.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:a.ReactCurrentDispatcher,findHostInstanceByFiber:N2,findFiberByHostInstance:l.findFiberByHostInstance||D2,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")l=!1;else{var u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(u.isDisabled||!u.supportsFiber)l=!0;else{try{Pf=u.inject(l),Hr=u}catch{}l=!!u.checkDCE}}return l},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(l,u,p,y){if(!I)throw Error(o(363));l=pg(l,u);var w=De(l,p,y).disconnect;return{disconnect:function(){w()}}},t.registerMutableSourceForHydration=function(l,u){var p=u._getVersion;p=p(u._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[u,p]:l.mutableSourceEagerHydrationData.push(u,p)},t.runWithPriority=function(l,u){var p=Lt;try{return Lt=l,u()}finally{Lt=p}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(l,u,p,y){var w=u.current,A=pi(),F=Os(w);return p=YS(p),u.context===null?u.context=p:u.pendingContext=p,u=rs(A,F),u.payload={element:l},y=y===void 0?null:y,y!==null&&(u.callback=y),Us(w,u),l=lr(w,F,A),l!==null&&Df(l,w,F),F},t};MR.exports=az;var lz=MR.exports;const uz=ew(lz),mx={},TR=n=>void Object.assign(mx,n);function cz(n,e){function t(h,{args:d=[],attach:m,...v},_){let E=`${h[0].toUpperCase()}${h.slice(1)}`,M;if(h==="primitive"){if(v.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const g=v.object;M=dl(g,{type:h,root:_,attach:m,primitive:!0})}else{const g=mx[E];if(!g)throw new Error(`R3F: ${E} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(d))throw new Error("R3F: The args prop must be an array!");M=dl(new g(...d),{type:h,root:_,attach:m,memoizedProps:{args:d}})}return M.__r3f.attach===void 0&&(M.isBufferGeometry?M.__r3f.attach="geometry":M.isMaterial&&(M.__r3f.attach="material")),E!=="inject"&&kv(M,v),M}function i(h,d){let m=!1;if(d){var v,_;(v=d.__r3f)!=null&&v.attach?Bv(h,d,d.__r3f.attach):d.isObject3D&&h.isObject3D&&(h.add(d),m=!0),m||(_=h.__r3f)==null||_.objects.push(d),d.__r3f||dl(d,{}),d.__r3f.parent=h,Ly(d),pl(d)}}function r(h,d,m){let v=!1;if(d){var _,E;if((_=d.__r3f)!=null&&_.attach)Bv(h,d,d.__r3f.attach);else if(d.isObject3D&&h.isObject3D){d.parent=h,d.dispatchEvent({type:"added"}),h.dispatchEvent({type:"childadded",child:d});const M=h.children.filter(x=>x!==d),g=M.indexOf(m);h.children=[...M.slice(0,g),d,...M.slice(g)],v=!0}v||(E=h.__r3f)==null||E.objects.push(d),d.__r3f||dl(d,{}),d.__r3f.parent=h,Ly(d),pl(d)}}function s(h,d,m=!1){h&&[...h].forEach(v=>o(d,v,m))}function o(h,d,m){if(d){var v,_,E;if(d.__r3f&&(d.__r3f.parent=null),(v=h.__r3f)!=null&&v.objects&&(h.__r3f.objects=h.__r3f.objects.filter(T=>T!==d)),(_=d.__r3f)!=null&&_.attach)zE(h,d,d.__r3f.attach);else if(d.isObject3D&&h.isObject3D){var M;h.remove(d),(M=d.__r3f)!=null&&M.root&&vz(Qd(d),d)}const x=(E=d.__r3f)==null?void 0:E.primitive,S=!x&&(m===void 0?d.dispose!==null:m);if(!x){var g;s((g=d.__r3f)==null?void 0:g.objects,d,S),s(d.children,d,S)}if(delete d.__r3f,S&&d.dispose&&d.type!=="Scene"){const T=()=>{try{d.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?by.unstable_scheduleCallback(by.unstable_IdlePriority,T):T()}pl(h)}}function a(h,d,m,v){var _;const E=(_=h.__r3f)==null?void 0:_.parent;if(!E)return;const M=t(d,m,h.__r3f.root);if(h.children){for(const g of h.children)g.__r3f&&i(M,g);h.children=h.children.filter(g=>!g.__r3f)}h.__r3f.objects.forEach(g=>i(M,g)),h.__r3f.objects=[],h.__r3f.autoRemovedBeforeAppend||o(E,h),M.parent&&(M.__r3f.autoRemovedBeforeAppend=!0),i(E,M),M.raycast&&M.__r3f.eventCount&&Qd(M).getState().internal.interaction.push(M),[v,v.alternate].forEach(g=>{g!==null&&(g.stateNode=M,g.ref&&(typeof g.ref=="function"?g.ref(M):g.ref.current=M))})}const c=()=>{};return{reconciler:uz({createInstance:t,removeChild:o,appendChild:i,appendInitialChild:i,insertBefore:r,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(h,d)=>{if(!d)return;const m=h.getState().scene;m.__r3f&&(m.__r3f.root=h,i(m,d))},removeChildFromContainer:(h,d)=>{d&&o(h.getState().scene,d)},insertInContainerBefore:(h,d,m)=>{if(!d||!m)return;const v=h.getState().scene;v.__r3f&&r(v,d,m)},getRootHostContext:()=>null,getChildHostContext:h=>h,finalizeInitialChildren(h){var d;return!!((d=h==null?void 0:h.__r3f)!=null?d:{}).handlers},prepareUpdate(h,d,m,v){var _;if(((_=h==null?void 0:h.__r3f)!=null?_:{}).primitive&&v.object&&v.object!==h)return[!0];{const{args:M=[],children:g,...x}=v,{args:S=[],children:T,...L}=m;if(!Array.isArray(M))throw new Error("R3F: the args prop must be an array!");if(M.some((P,D)=>P!==S[D]))return[!0];const R=IR(h,x,L,!0);return R.changes.length?[!1,R]:null}},commitUpdate(h,[d,m],v,_,E,M){d?a(h,v,E,M):kv(h,m)},commitMount(h,d,m,v){var _;const E=(_=h.__r3f)!=null?_:{};h.raycast&&E.handlers&&E.eventCount&&Qd(h).getState().internal.interaction.push(h)},getPublicInstance:h=>h,prepareForCommit:()=>null,preparePortalMount:h=>dl(h.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(h){var d;const{attach:m,parent:v}=(d=h.__r3f)!=null?d:{};m&&v&&zE(v,h,m),h.isObject3D&&(h.visible=!1),pl(h)},unhideInstance(h,d){var m;const{attach:v,parent:_}=(m=h.__r3f)!=null?m:{};v&&_&&Bv(_,h,v),(h.isObject3D&&d.visible==null||d.visible)&&(h.visible=!0),pl(h)},createTextInstance:c,hideTextInstance:c,unhideTextInstance:c,getCurrentEventPriority:()=>e?e():Il.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&Zt.fun(performance.now)?performance.now:Zt.fun(Date.now)?Date.now:()=>0,scheduleTimeout:Zt.fun(setTimeout)?setTimeout:void 0,cancelTimeout:Zt.fun(clearTimeout)?clearTimeout:void 0}),applyProps:kv}}var NE,DE;const zv=n=>"colorSpace"in n||"outputColorSpace"in n,AR=()=>{var n;return(n=mx.ColorManagement)!=null?n:null},CR=n=>n&&n.isOrthographicCamera,fz=n=>n&&n.hasOwnProperty("current"),Ef=typeof window<"u"&&((NE=window.document)!=null&&NE.createElement||((DE=window.navigator)==null?void 0:DE.product)==="ReactNative")?we.useLayoutEffect:we.useEffect;function RR(n){const e=we.useRef(n);return Ef(()=>void(e.current=n),[n]),e}function hz({set:n}){return Ef(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}class bR extends we.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}bR.getDerivedStateFromError=()=>({error:!0});const PR="__default",OE=new Map,dz=n=>n&&!!n.memoized&&!!n.changes;function LR(n){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(n)?Math.min(Math.max(n[0],t),n[1]):n}const Zu=n=>{var e;return(e=n.__r3f)==null?void 0:e.root.getState()};function Qd(n){let e=n.__r3f.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const Zt={obj:n=>n===Object(n)&&!Zt.arr(n)&&typeof n!="function",fun:n=>typeof n=="function",str:n=>typeof n=="string",num:n=>typeof n=="number",boo:n=>typeof n=="boolean",und:n=>n===void 0,arr:n=>Array.isArray(n),equ(n,e,{arrays:t="shallow",objects:i="reference",strict:r=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(Zt.str(n)||Zt.num(n)||Zt.boo(n))return n===e;const s=Zt.obj(n);if(s&&i==="reference")return n===e;const o=Zt.arr(n);if(o&&t==="reference")return n===e;if((o||s)&&n===e)return!0;let a;for(a in n)if(!(a in e))return!1;if(s&&t==="shallow"&&i==="shallow"){for(a in r?e:n)if(!Zt.equ(n[a],e[a],{strict:r,objects:"reference"}))return!1}else for(a in r?e:n)if(n[a]!==e[a])return!1;if(Zt.und(a)){if(o&&n.length===0&&e.length===0||s&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function pz(n){n.dispose&&n.type!=="Scene"&&n.dispose();for(const e in n)e.dispose==null||e.dispose(),delete n[e]}function dl(n,e){const t=n;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},n}function Py(n,e){let t=n;if(e.includes("-")){const i=e.split("-"),r=i.pop();return t=i.reduce((s,o)=>s[o],n),{target:t,key:r}}else return{target:t,key:e}}const FE=/-\d+$/;function Bv(n,e,t){if(Zt.str(t)){if(FE.test(t)){const s=t.replace(FE,""),{target:o,key:a}=Py(n,s);Array.isArray(o[a])||(o[a]=[])}const{target:i,key:r}=Py(n,t);e.__r3f.previousAttach=i[r],i[r]=e}else e.__r3f.previousAttach=t(n,e)}function zE(n,e,t){var i,r;if(Zt.str(t)){const{target:s,key:o}=Py(n,t),a=e.__r3f.previousAttach;a===void 0?delete s[o]:s[o]=a}else(i=e.__r3f)==null||i.previousAttach==null||i.previousAttach(n,e);(r=e.__r3f)==null||delete r.previousAttach}function IR(n,{children:e,key:t,ref:i,...r},{children:s,key:o,ref:a,...c}={},f=!1){const h=n.__r3f,d=Object.entries(r),m=[];if(f){const _=Object.keys(c);for(let E=0;E<_.length;E++)r.hasOwnProperty(_[E])||d.unshift([_[E],PR+"remove"])}d.forEach(([_,E])=>{var M;if((M=n.__r3f)!=null&&M.primitive&&_==="object"||Zt.equ(E,c[_]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(_))return m.push([_,E,!0,[]]);let g=[];_.includes("-")&&(g=_.split("-")),m.push([_,E,!1,g]);for(const x in r){const S=r[x];x.startsWith(`${_}-`)&&m.push([x,S,!1,x.split("-")])}});const v={...r};return h!=null&&h.memoizedProps&&h!=null&&h.memoizedProps.args&&(v.args=h.memoizedProps.args),h!=null&&h.memoizedProps&&h!=null&&h.memoizedProps.attach&&(v.attach=h.memoizedProps.attach),{memoized:v,changes:m}}function kv(n,e){var t;const i=n.__r3f,r=i==null?void 0:i.root,s=r==null||r.getState==null?void 0:r.getState(),{memoized:o,changes:a}=dz(e)?e:IR(n,e),c=i==null?void 0:i.eventCount;n.__r3f&&(n.__r3f.memoizedProps=o);for(let m=0;mS[T],n),!(x&&x.set))){const[S,...T]=M.reverse();g=T.reverse().reduce((L,R)=>L[R],n),v=S}if(_===PR+"remove")if(g.constructor){let S=OE.get(g.constructor);S||(S=new g.constructor,OE.set(g.constructor,S)),_=S[v]}else _=0;if(E&&i)_?i.handlers[v]=_:delete i.handlers[v],i.eventCount=Object.keys(i.handlers).length;else if(x&&x.set&&(x.copy||x instanceof fa)){if(Array.isArray(_))x.fromArray?x.fromArray(_):x.set(..._);else if(x.copy&&_&&_.constructor&&x.constructor===_.constructor)x.copy(_);else if(_!==void 0){var f;const S=(f=x)==null?void 0:f.isColor;!S&&x.setScalar?x.setScalar(_):x instanceof fa&&_ instanceof fa?x.mask=_.mask:x.set(_),!AR()&&s&&!s.linear&&S&&x.convertSRGBToLinear()}}else{var h;if(g[v]=_,(h=g[v])!=null&&h.isTexture&&g[v].format===Hn&&g[v].type===Pn&&s){const S=g[v];zv(S)&&zv(s.gl)?S.colorSpace=s.gl.outputColorSpace:S.encoding=s.gl.outputEncoding}}pl(n)}if(i&&i.parent&&n.raycast&&c!==i.eventCount){const m=Qd(n).getState().internal,v=m.interaction.indexOf(n);v>-1&&m.interaction.splice(v,1),i.eventCount&&m.interaction.push(n)}return!(a.length===1&&a[0][0]==="onUpdate")&&a.length&&(t=n.__r3f)!=null&&t.parent&&Ly(n),n}function pl(n){var e,t;const i=(e=n.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();i&&i.internal.frames===0&&i.invalidate()}function Ly(n){n.onUpdate==null||n.onUpdate(n)}function mz(n,e){n.manual||(CR(n)?(n.left=e.width/-2,n.right=e.width/2,n.top=e.height/2,n.bottom=e.height/-2):n.aspect=e.width/e.height,n.updateProjectionMatrix(),n.updateMatrixWorld())}function Rd(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function gz(){var n;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return Il.DefaultEventPriority;switch((n=e.event)==null?void 0:n.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Il.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Il.ContinuousEventPriority;default:return Il.DefaultEventPriority}}function UR(n,e,t,i){const r=t.get(e);r&&(t.delete(e),t.size===0&&(n.delete(i),r.target.releasePointerCapture(i)))}function vz(n,e){const{internal:t}=n.getState();t.interaction=t.interaction.filter(i=>i!==e),t.initialHits=t.initialHits.filter(i=>i!==e),t.hovered.forEach((i,r)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(r)}),t.capturedMap.forEach((i,r)=>{UR(t.capturedMap,e,i,r)})}function yz(n){function e(c){const{internal:f}=n.getState(),h=c.offsetX-f.initialClick[0],d=c.offsetY-f.initialClick[1];return Math.round(Math.sqrt(h*h+d*d))}function t(c){return c.filter(f=>["Move","Over","Enter","Out","Leave"].some(h=>{var d;return(d=f.__r3f)==null?void 0:d.handlers["onPointer"+h]}))}function i(c,f){const h=n.getState(),d=new Set,m=[],v=f?f(h.internal.interaction):h.internal.interaction;for(let g=0;g{const S=Zu(g.object),T=Zu(x.object);return!S||!T?g.distance-x.distance:T.events.priority-S.events.priority||g.distance-x.distance}).filter(g=>{const x=Rd(g);return d.has(x)?!1:(d.add(x),!0)});h.events.filter&&(E=h.events.filter(E,h));for(const g of E){let x=g.object;for(;x;){var M;(M=x.__r3f)!=null&&M.eventCount&&m.push({...g,eventObject:x}),x=x.parent}}if("pointerId"in c&&h.internal.capturedMap.has(c.pointerId))for(let g of h.internal.capturedMap.get(c.pointerId).values())d.has(Rd(g.intersection))||m.push(g.intersection);return m}function r(c,f,h,d){const m=n.getState();if(c.length){const v={stopped:!1};for(const _ of c){const E=Zu(_.object)||m,{raycaster:M,pointer:g,camera:x,internal:S}=E,T=new O(g.x,g.y,0).unproject(x),L=b=>{var B,j;return(B=(j=S.capturedMap.get(b))==null?void 0:j.has(_.eventObject))!=null?B:!1},R=b=>{const B={intersection:_,target:f.target};S.capturedMap.has(b)?S.capturedMap.get(b).set(_.eventObject,B):S.capturedMap.set(b,new Map([[_.eventObject,B]])),f.target.setPointerCapture(b)},P=b=>{const B=S.capturedMap.get(b);B&&UR(S.capturedMap,_.eventObject,B,b)};let D={};for(let b in f){let B=f[b];typeof B!="function"&&(D[b]=B)}let C={..._,...D,pointer:g,intersections:c,stopped:v.stopped,delta:h,unprojectedPoint:T,ray:M.ray,camera:x,stopPropagation(){const b="pointerId"in f&&S.capturedMap.get(f.pointerId);if((!b||b.has(_.eventObject))&&(C.stopped=v.stopped=!0,S.hovered.size&&Array.from(S.hovered.values()).find(B=>B.eventObject===_.eventObject))){const B=c.slice(0,c.indexOf(_));s([...B,_])}},target:{hasPointerCapture:L,setPointerCapture:R,releasePointerCapture:P},currentTarget:{hasPointerCapture:L,setPointerCapture:R,releasePointerCapture:P},nativeEvent:f};if(d(C),v.stopped===!0)break}}return c}function s(c){const{internal:f}=n.getState();for(const h of f.hovered.values())if(!c.length||!c.find(d=>d.object===h.object&&d.index===h.index&&d.instanceId===h.instanceId)){const m=h.eventObject.__r3f,v=m==null?void 0:m.handlers;if(f.hovered.delete(Rd(h)),m!=null&&m.eventCount){const _={...h,intersections:c};v.onPointerOut==null||v.onPointerOut(_),v.onPointerLeave==null||v.onPointerLeave(_)}}}function o(c,f){for(let h=0;hs([]);case"onLostPointerCapture":return f=>{const{internal:h}=n.getState();"pointerId"in f&&h.capturedMap.has(f.pointerId)&&requestAnimationFrame(()=>{h.capturedMap.has(f.pointerId)&&(h.capturedMap.delete(f.pointerId),s([]))})}}return function(h){const{onPointerMissed:d,internal:m}=n.getState();m.lastEvent.current=h;const v=c==="onPointerMove",_=c==="onClick"||c==="onContextMenu"||c==="onDoubleClick",M=i(h,v?t:void 0),g=_?e(h):0;c==="onPointerDown"&&(m.initialClick=[h.offsetX,h.offsetY],m.initialHits=M.map(S=>S.eventObject)),_&&!M.length&&g<=2&&(o(h,m.interaction),d&&d(h)),v&&s(M);function x(S){const T=S.eventObject,L=T.__r3f,R=L==null?void 0:L.handlers;if(L!=null&&L.eventCount)if(v){if(R.onPointerOver||R.onPointerEnter||R.onPointerOut||R.onPointerLeave){const P=Rd(S),D=m.hovered.get(P);D?D.stopped&&S.stopPropagation():(m.hovered.set(P,S),R.onPointerOver==null||R.onPointerOver(S),R.onPointerEnter==null||R.onPointerEnter(S))}R.onPointerMove==null||R.onPointerMove(S)}else{const P=R[c];P?(!_||m.initialHits.includes(T))&&(o(h,m.interaction.filter(D=>!m.initialHits.includes(D))),P(S)):_&&m.initialHits.includes(T)&&o(h,m.interaction.filter(D=>!m.initialHits.includes(D)))}}r(M,h,g,x)}}return{handlePointer:a}}const NR=n=>!!(n!=null&&n.render),DR=we.createContext(null),_z=(n,e)=>{const t=oz((a,c)=>{const f=new O,h=new O,d=new O;function m(g=c().camera,x=h,S=c().size){const{width:T,height:L,top:R,left:P}=S,D=T/L;x.isVector3?d.copy(x):d.set(...x);const C=g.getWorldPosition(f).distanceTo(d);if(CR(g))return{width:T/g.zoom,height:L/g.zoom,top:R,left:P,factor:1,distance:C,aspect:D};{const b=g.fov*Math.PI/180,B=2*Math.tan(b/2)*C,j=B*(T/L);return{width:j,height:B,top:R,left:P,factor:T/j,distance:C,aspect:D}}}let v;const _=g=>a(x=>({performance:{...x.performance,current:g}})),E=new oe;return{set:a,get:c,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(g=1)=>n(c(),g),advance:(g,x)=>e(g,x,c()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new hx,pointer:E,mouse:E,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const g=c();v&&clearTimeout(v),g.performance.current!==g.performance.min&&_(g.performance.min),v=setTimeout(()=>_(c().performance.max),g.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:m},setEvents:g=>a(x=>({...x,events:{...x.events,...g}})),setSize:(g,x,S,T,L)=>{const R=c().camera,P={width:g,height:x,top:T||0,left:L||0,updateStyle:S};a(D=>({size:P,viewport:{...D.viewport,...m(R,h,P)}}))},setDpr:g=>a(x=>{const S=LR(g);return{viewport:{...x.viewport,dpr:S,initialDpr:x.viewport.initialDpr||S}}}),setFrameloop:(g="always")=>{const x=c().clock;x.stop(),x.elapsedTime=0,g!=="never"&&(x.start(),x.elapsedTime=0),a(()=>({frameloop:g}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:we.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(g,x,S)=>{const T=c().internal;return T.priority=T.priority+(x>0?1:0),T.subscribers.push({ref:g,priority:x,store:S}),T.subscribers=T.subscribers.sort((L,R)=>L.priority-R.priority),()=>{const L=c().internal;L!=null&&L.subscribers&&(L.priority=L.priority-(x>0?1:0),L.subscribers=L.subscribers.filter(R=>R.ref!==g))}}}}}),i=t.getState();let r=i.size,s=i.viewport.dpr,o=i.camera;return t.subscribe(()=>{const{camera:a,size:c,viewport:f,gl:h,set:d}=t.getState();if(c.width!==r.width||c.height!==r.height||f.dpr!==s){var m;r=c,s=f.dpr,mz(a,c),h.setPixelRatio(f.dpr);const v=(m=c.updateStyle)!=null?m:typeof HTMLCanvasElement<"u"&&h.domElement instanceof HTMLCanvasElement;h.setSize(c.width,c.height,v)}a!==o&&(o=a,d(v=>({viewport:{...v.viewport,...v.viewport.getCurrentViewport(a)}})))}),t.subscribe(a=>n(a)),t};let bd,xz=new Set,Sz=new Set,Mz=new Set;function Hv(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function Ku(n,e){switch(n){case"before":return Hv(xz,e);case"after":return Hv(Sz,e);case"tail":return Hv(Mz,e)}}let Vv,Gv;function Wv(n,e,t){let i=e.clock.getDelta();for(e.frameloop==="never"&&typeof n=="number"&&(i=n-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=n),Vv=e.internal.subscribers,bd=0;bd0)&&!((h=s.gl.xr)!=null&&h.isPresenting)&&(i+=Wv(f,s))}if(t=!1,Ku("after",f),i===0)return Ku("tail",f),e=!1,cancelAnimationFrame(r)}function a(f,h=1){var d;if(!f)return n.forEach(m=>a(m.store.getState(),h));(d=f.gl.xr)!=null&&d.isPresenting||!f.internal.active||f.frameloop==="never"||(h>1?f.internal.frames=Math.min(60,f.internal.frames+h):t?f.internal.frames=2:f.internal.frames=1,e||(e=!0,requestAnimationFrame(o)))}function c(f,h=!0,d,m){if(h&&Ku("before",f),d)Wv(f,d,m);else for(const v of n.values())Wv(f,v.store.getState());h&&Ku("after",f)}return{loop:o,invalidate:a,advance:c}}function OR(){const n=we.useContext(DR);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function xm(n=t=>t,e){return OR()(n,e)}function Sm(n,e=0){const t=OR(),i=t.getState().internal.subscribe,r=RR(n);return Ef(()=>i(r,e,t),[e,i,t]),null}const Jl=new Map,{invalidate:BE,advance:kE}=Ez(Jl),{reconciler:bp,applyProps:fl}=cz(Jl,gz),hl={objects:"shallow",strict:!1},wz=(n,e)=>{const t=typeof n=="function"?n(e):n;return NR(t)?t:new q_({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...n})};function Tz(n,e){const t=typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement;if(e){const{width:i,height:r,top:s,left:o,updateStyle:a=t}=e;return{width:i,height:r,top:s,left:o,updateStyle:a}}else if(typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:i,height:r,top:s,left:o}=n.parentElement.getBoundingClientRect();return{width:i,height:r,top:s,left:o,updateStyle:t}}else if(typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height,top:0,left:0,updateStyle:t};return{width:0,height:0,top:0,left:0}}function Az(n){const e=Jl.get(n),t=e==null?void 0:e.fiber,i=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const r=typeof reportError=="function"?reportError:console.error,s=i||_z(BE,kE),o=t||bp.createContainer(s,Il.ConcurrentRoot,null,!1,null,"",r,null);e||Jl.set(n,{fiber:o,store:s});let a,c=!1,f;return{configure(h={}){let{gl:d,size:m,scene:v,events:_,onCreated:E,shadows:M=!1,linear:g=!1,flat:x=!1,legacy:S=!1,orthographic:T=!1,frameloop:L="always",dpr:R=[1,2],performance:P,raycaster:D,camera:C,onPointerMissed:b}=h,B=s.getState(),j=B.gl;B.gl||B.set({gl:j=wz(d,n)});let le=B.raycaster;le||B.set({raycaster:le=new _R});const{params:H,...Z}=D||{};if(Zt.equ(Z,le,hl)||fl(le,{...Z}),Zt.equ(H,le.params,hl)||fl(le,{params:{...le.params,...H}}),!B.camera||B.camera===f&&!Zt.equ(f,C,hl)){f=C;const V=C instanceof su,J=V?C:T?new vf(0,0,0,0,.1,1e3):new Cn(75,0,.1,1e3);V||(J.position.z=5,C&&(fl(J,C),("aspect"in C||"left"in C||"right"in C||"bottom"in C||"top"in C)&&(J.manual=!0,J.updateProjectionMatrix())),!B.camera&&!(C!=null&&C.rotation)&&J.lookAt(0,0,0)),B.set({camera:J}),le.camera=J}if(!B.scene){let V;v!=null&&v.isScene?V=v:(V=new Zc,v&&fl(V,v)),B.set({scene:dl(V)})}if(!B.xr){var $;const V=(K,ue)=>{const Se=s.getState();Se.frameloop!=="never"&&kE(K,!0,Se,ue)},J=()=>{const K=s.getState();K.gl.xr.enabled=K.gl.xr.isPresenting,K.gl.xr.setAnimationLoop(K.gl.xr.isPresenting?V:null),K.gl.xr.isPresenting||BE(K)},se={connect(){const K=s.getState().gl;K.xr.addEventListener("sessionstart",J),K.xr.addEventListener("sessionend",J)},disconnect(){const K=s.getState().gl;K.xr.removeEventListener("sessionstart",J),K.xr.removeEventListener("sessionend",J)}};typeof(($=j.xr)==null?void 0:$.addEventListener)=="function"&&se.connect(),B.set({xr:se})}if(j.shadowMap){const V=j.shadowMap.enabled,J=j.shadowMap.type;if(j.shadowMap.enabled=!!M,Zt.boo(M))j.shadowMap.type=dc;else if(Zt.str(M)){var ce;const se={basic:mA,percentage:Yp,soft:dc,variance:Rr};j.shadowMap.type=(ce=se[M])!=null?ce:dc}else Zt.obj(M)&&Object.assign(j.shadowMap,M);(V!==j.shadowMap.enabled||J!==j.shadowMap.type)&&(j.shadowMap.needsUpdate=!0)}const z=AR();z&&("enabled"in z?z.enabled=!S:"legacyMode"in z&&(z.legacyMode=S)),c||fl(j,{outputEncoding:g?3e3:3001,toneMapping:x?Dr:C_}),B.legacy!==S&&B.set(()=>({legacy:S})),B.linear!==g&&B.set(()=>({linear:g})),B.flat!==x&&B.set(()=>({flat:x})),d&&!Zt.fun(d)&&!NR(d)&&!Zt.equ(d,j,hl)&&fl(j,d),_&&!B.events.handlers&&B.set({events:_(s)});const G=Tz(n,m);return Zt.equ(G,B.size,hl)||B.setSize(G.width,G.height,G.updateStyle,G.top,G.left),R&&B.viewport.dpr!==LR(R)&&B.setDpr(R),B.frameloop!==L&&B.setFrameloop(L),B.onPointerMissed||B.set({onPointerMissed:b}),P&&!Zt.equ(P,B.performance,hl)&&B.set(V=>({performance:{...V.performance,...P}})),a=E,c=!0,this},render(h){return c||this.configure(),bp.updateContainer(ut.jsx(Cz,{store:s,children:h,onCreated:a,rootElement:n}),o,null,()=>{}),s},unmount(){FR(n)}}}function Cz({store:n,children:e,onCreated:t,rootElement:i}){return Ef(()=>{const r=n.getState();r.set(s=>({internal:{...s.internal,active:!0}})),t&&t(r),n.getState().events.connected||r.events.connect==null||r.events.connect(i)},[]),ut.jsx(DR.Provider,{value:n,children:e})}function FR(n,e){const t=Jl.get(n),i=t==null?void 0:t.fiber;if(i){const r=t==null?void 0:t.store.getState();r&&(r.internal.active=!1),bp.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{var s,o,a,c;r.events.disconnect==null||r.events.disconnect(),(s=r.gl)==null||(o=s.renderLists)==null||o.dispose==null||o.dispose(),(a=r.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(c=r.gl)!=null&&c.xr&&r.xr.disconnect(),pz(r),Jl.delete(n)}catch{}},500)})}}bp.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:we.version});const Xv={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function Rz(n){const{handlePointer:e}=yz(n);return{priority:1,enabled:!0,compute(t,i,r){i.pointer.set(t.offsetX/i.size.width*2-1,-(t.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(Xv).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:r}=n.getState();(t=r.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{var i;const{set:r,events:s}=n.getState();s.disconnect==null||s.disconnect(),r(o=>({events:{...o.events,connected:t}})),Object.entries((i=s.handlers)!=null?i:[]).forEach(([o,a])=>{const[c,f]=Xv[o];t.addEventListener(c,a,{passive:f})})},disconnect:()=>{const{set:t,events:i}=n.getState();if(i.connected){var r;Object.entries((r=i.handlers)!=null?r:[]).forEach(([s,o])=>{if(i&&i.connected instanceof HTMLElement){const[a]=Xv[s];i.connected.removeEventListener(a,o)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}function HE(n,e){let t;return(...i)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...i),e)}}function bz({debounce:n,scroll:e,polyfill:t,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const r=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!r)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,o]=we.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),a=we.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s,orientationHandler:null}),c=n?typeof n=="number"?n:n.scroll:null,f=n?typeof n=="number"?n:n.resize:null,h=we.useRef(!1);we.useEffect(()=>(h.current=!0,()=>void(h.current=!1)));const[d,m,v]=we.useMemo(()=>{const g=()=>{if(!a.current.element)return;const{left:x,top:S,width:T,height:L,bottom:R,right:P,x:D,y:C}=a.current.element.getBoundingClientRect(),b={left:x,top:S,width:T,height:L,bottom:R,right:P,x:D,y:C};a.current.element instanceof HTMLElement&&i&&(b.height=a.current.element.offsetHeight,b.width=a.current.element.offsetWidth),Object.freeze(b),h.current&&!Uz(a.current.lastBounds,b)&&o(a.current.lastBounds=b)};return[g,f?HE(g,f):g,c?HE(g,c):g]},[o,i,c,f]);function _(){a.current.scrollContainers&&(a.current.scrollContainers.forEach(g=>g.removeEventListener("scroll",v,!0)),a.current.scrollContainers=null),a.current.resizeObserver&&(a.current.resizeObserver.disconnect(),a.current.resizeObserver=null),a.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",a.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",a.current.orientationHandler))}function E(){a.current.element&&(a.current.resizeObserver=new r(v),a.current.resizeObserver.observe(a.current.element),e&&a.current.scrollContainers&&a.current.scrollContainers.forEach(g=>g.addEventListener("scroll",v,{capture:!0,passive:!0})),a.current.orientationHandler=()=>{v()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",a.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",a.current.orientationHandler))}const M=g=>{!g||g===a.current.element||(_(),a.current.element=g,a.current.scrollContainers=zR(g),E())};return Lz(v,!!e),Pz(m),we.useEffect(()=>{_(),E()},[e,v,m]),we.useEffect(()=>_,[]),[M,s,d]}function Pz(n){we.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[n])}function Lz(n,e){we.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[n,e])}function zR(n){const e=[];if(!n||n===document.body)return e;const{overflow:t,overflowX:i,overflowY:r}=window.getComputedStyle(n);return[t,i,r].some(s=>s==="auto"||s==="scroll")&&e.push(n),[...e,...zR(n.parentElement)]}const Iz=["x","y","top","bottom","left","right","width","height"],Uz=(n,e)=>Iz.every(t=>n[t]===e[t]);var Nz=Object.defineProperty,Dz=Object.defineProperties,Oz=Object.getOwnPropertyDescriptors,VE=Object.getOwnPropertySymbols,Fz=Object.prototype.hasOwnProperty,zz=Object.prototype.propertyIsEnumerable,GE=(n,e,t)=>e in n?Nz(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,WE=(n,e)=>{for(var t in e||(e={}))Fz.call(e,t)&&GE(n,t,e[t]);if(VE)for(var t of VE(e))zz.call(e,t)&&GE(n,t,e[t]);return n},Bz=(n,e)=>Dz(n,Oz(e)),XE,YE;typeof window<"u"&&((XE=window.document)!=null&&XE.createElement||((YE=window.navigator)==null?void 0:YE.product)==="ReactNative")?we.useLayoutEffect:we.useEffect;function BR(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=n.child;for(;i;){const r=BR(i,e,t);if(r)return r;i=i.sibling}}function kR(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const jE=console.error;console.error=function(){const n=[...arguments].join("");if(n!=null&&n.startsWith("Warning:")&&n.includes("useContext")){console.error=jE;return}return jE.apply(this,arguments)};const gx=kR(we.createContext(null));class HR extends we.Component{render(){return we.createElement(gx.Provider,{value:this._reactInternals},this.props.children)}}function kz(){const n=we.useContext(gx);if(n===null)throw new Error("its-fine: useFiber must be called within a !");const e=we.useId();return we.useMemo(()=>{for(const i of[n,n==null?void 0:n.alternate]){if(!i)continue;const r=BR(i,!1,s=>{let o=s.memoizedState;for(;o;){if(o.memoizedState===e)return!0;o=o.next}});if(r)return r}},[n,e])}function Hz(){const n=kz(),[e]=we.useState(()=>new Map);e.clear();let t=n;for(;t;){if(t.type&&typeof t.type=="object"){const r=t.type._context===void 0&&t.type.Provider===t.type?t.type:t.type._context;r&&r!==gx&&!e.has(r)&&e.set(r,we.useContext(kR(r)))}t=t.return}return e}function Vz(){const n=Hz();return we.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>we.createElement(e,null,we.createElement(t.Provider,Bz(WE({},i),{value:n.get(t)}))),e=>we.createElement(HR,WE({},e))),[n])}const Gz=we.forwardRef(function({children:e,fallback:t,resize:i,style:r,gl:s,events:o=Rz,eventSource:a,eventPrefix:c,shadows:f,linear:h,flat:d,legacy:m,orthographic:v,frameloop:_,dpr:E,performance:M,raycaster:g,camera:x,scene:S,onPointerMissed:T,onCreated:L,...R},P){we.useMemo(()=>TR(iz),[]);const D=Vz(),[C,b]=bz({scroll:!0,debounce:{scroll:50,resize:0},...i}),B=we.useRef(null),j=we.useRef(null);we.useImperativeHandle(P,()=>B.current);const le=RR(T),[H,Z]=we.useState(!1),[$,ce]=we.useState(!1);if(H)throw H;if($)throw $;const z=we.useRef(null);Ef(()=>{const V=B.current;b.width>0&&b.height>0&&V&&(z.current||(z.current=Az(V)),z.current.configure({gl:s,events:o,shadows:f,linear:h,flat:d,legacy:m,orthographic:v,frameloop:_,dpr:E,performance:M,raycaster:g,camera:x,scene:S,size:b,onPointerMissed:(...J)=>le.current==null?void 0:le.current(...J),onCreated:J=>{J.events.connect==null||J.events.connect(a?fz(a)?a.current:a:j.current),c&&J.setEvents({compute:(se,K)=>{const ue=se[c+"X"],Se=se[c+"Y"];K.pointer.set(ue/K.size.width*2-1,-(Se/K.size.height)*2+1),K.raycaster.setFromCamera(K.pointer,K.camera)}}),L==null||L(J)}}),z.current.render(ut.jsx(D,{children:ut.jsx(bR,{set:ce,children:ut.jsx(we.Suspense,{fallback:ut.jsx(hz,{set:Z}),children:e??null})})})))}),we.useEffect(()=>{const V=B.current;if(V)return()=>FR(V)},[]);const G=a?"none":"auto";return ut.jsx("div",{ref:j,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:G,...r},...R,children:ut.jsx("div",{ref:C,style:{width:"100%",height:"100%"},children:ut.jsx("canvas",{ref:B,style:{display:"block"},children:t})})})}),Wz=we.forwardRef(function(e,t){return ut.jsx(HR,{children:ut.jsx(Gz,{...e,ref:t})})});/** * postprocessing v6.37.3 build Sun Apr 27 2025 * https://github.com/pmndrs/postprocessing * Copyright 2015-2025 Raoul van Rüschen * @license Zlib */var Yv=1/1e3,Xz=1e3,Yz=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(n){typeof document<"u"&&document.hidden!==void 0&&(n?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=n)}get delta(){return this._delta*Yv}get fixedDelta(){return this._fixedDelta*Yv}set fixedDelta(n){this._fixedDelta=n*Xz}get elapsed(){return this._elapsed*Yv}update(n){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(n!==void 0?n:performance.now())-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(n){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},jz=(()=>{const n=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]),t=new vt;return t.setAttribute("position",new Ft(n,3)),t.setAttribute("uv",new Ft(e,2)),t})(),Bi=class Iy{static get fullscreenGeometry(){return jz}constructor(e="Pass",t=new Zc,i=new su){this.name=e,this.renderer=null,this.scene=t,this.camera=i,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){const t=this.fullscreenMaterial;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(e){let t=this.screen;t!==null?t.material=e:(t=new wn(Iy.fullscreenGeometry,e),t.frustumCulled=!1,this.scene===null&&(this.scene=new Zc),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=wo){}render(e,t,i,r,s){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,i){}dispose(){for(const e of Object.keys(this)){const t=this[e];(t instanceof _n||t instanceof Wn||t instanceof an||t instanceof Iy)&&this[e].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},qz=class extends Bi{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(n,e,t,i,r){const s=n.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},Zz=`#include #include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel; #include #include }`,VR="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",GR=class extends Gn{constructor(){super({name:"CopyMaterial",uniforms:{inputBuffer:new gt(null),opacity:new gt(1)},blending:ci,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:Zz,vertexShader:VR})}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}getOpacity(n){return this.uniforms.opacity.value}setOpacity(n){this.uniforms.opacity.value=n}},Kz=class extends Bi{constructor(n,e=!0){super("CopyPass"),this.fullscreenMaterial=new GR,this.needsSwap=!1,this.renderTarget=n,n===void 0&&(this.renderTarget=new _n(1,1,{minFilter:Kt,magFilter:Kt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=e}get resize(){return this.autoResize}set resize(n){this.autoResize=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(n){this.autoResize=n}render(n,e,t,i,r){this.fullscreenMaterial.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){this.autoResize&&this.renderTarget.setSize(n,e)}initialize(n,e,t){t!==void 0&&(this.renderTarget.texture.type=t,t!==Pn?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":n!==null&&n.outputColorSpace===At&&(this.renderTarget.texture.colorSpace=At))}},qE=new Ue,WR=class extends Bi{constructor(n=!0,e=!0,t=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=n,this.depth=e,this.stencil=t,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(n,e,t){this.color=n,this.depth=e,this.stencil=t}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(n){this.overrideClearColor=n}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(n){this.overrideClearAlpha=n}render(n,e,t,i,r){const s=this.overrideClearColor,o=this.overrideClearAlpha,a=n.getClearAlpha(),c=s!==null,f=o>=0;c?(n.getClearColor(qE),n.setClearColor(s,f?o:a)):f&&n.setClearAlpha(o),n.setRenderTarget(this.renderToScreen?null:e),n.clear(this.color,this.depth,this.stencil),c?n.setClearColor(qE,a):f&&n.setClearAlpha(a)}},Qz=class extends Bi{constructor(n,e){super("MaskPass",n,e),this.needsSwap=!1,this.clearPass=new WR(!1,!1,!0),this.inverse=!1}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get inverted(){return this.inverse}set inverted(n){this.inverse=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(n){this.inverted=n}render(n,e,t,i,r){const s=n.getContext(),o=n.state.buffers,a=this.scene,c=this.camera,f=this.clearPass,h=this.inverted?0:1,d=1-h;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.stencil.setFunc(s.ALWAYS,h,4294967295),o.stencil.setClear(d),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?f.render(n,null):(f.render(n,e),f.render(n,t))),this.renderToScreen?(n.setRenderTarget(null),n.render(a,c)):(n.setRenderTarget(e),n.render(a,c),n.setRenderTarget(t),n.render(a,c)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(s.EQUAL,1,4294967295),o.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.stencil.setLocked(!0)}},Jz=class{constructor(e=null,{depthBuffer:t=!0,stencilBuffer:i=!1,multisampling:r=0,frameBufferType:s}={}){this.renderer=null,this.inputBuffer=this.createBuffer(t,i,s,r),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new Kz,this.depthTexture=null,this.passes=[],this.timer=new Yz,this.autoRenderToScreen=!0,this.setRenderer(e)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(e){const t=this.inputBuffer,i=this.multisampling;i>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e,this.inputBuffer.dispose(),this.outputBuffer.dispose()):i!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(e){if(this.renderer=e,e!==null){const t=e.getSize(new oe),i=e.getContext().getContextAttributes().alpha,r=this.inputBuffer.texture.type;r===Pn&&e.outputColorSpace===At&&(this.inputBuffer.texture.colorSpace=At,this.outputBuffer.texture.colorSpace=At,this.inputBuffer.dispose(),this.outputBuffer.dispose()),e.autoClear=!1,this.setSize(t.width,t.height);for(const s of this.passes)s.initialize(e,i,r)}}replaceRenderer(e,t=!0){const i=this.renderer,r=i.domElement.parentNode;return this.setRenderer(e),t&&r!==null&&(r.removeChild(i.domElement),r.appendChild(e.domElement)),i}createDepthTexture(){const e=this.depthTexture=new $p;return this.inputBuffer.depthTexture=e,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(e.format=_o,e.type=Ms):e.type=Qr,e}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(const e of this.passes)e.setDepthTexture(null)}}createBuffer(e,t,i,r){const s=this.renderer,o=s===null?new oe:s.getDrawingBufferSize(new oe),a={minFilter:Kt,magFilter:Kt,stencilBuffer:t,depthBuffer:e,type:i},c=new _n(o.width,o.height,a);return r>0&&(c.ignoreDepthForMultisampleCopy=!1,c.samples=r),i===Pn&&s!==null&&s.outputColorSpace===At&&(c.texture.colorSpace=At),c.texture.name="EffectComposer.Buffer",c.texture.generateMipmaps=!1,c}setMainScene(e){for(const t of this.passes)t.mainScene=e}setMainCamera(e){for(const t of this.passes)t.mainCamera=e}addPass(e,t){const i=this.passes,r=this.renderer,s=r.getDrawingBufferSize(new oe),o=r.getContext().getContextAttributes().alpha,a=this.inputBuffer.texture.type;if(e.setRenderer(r),e.setSize(s.width,s.height),e.initialize(r,o,a),this.autoRenderToScreen&&(i.length>0&&(i[i.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),t!==void 0?i.splice(t,0,e):i.push(e),this.autoRenderToScreen&&(i[i.length-1].renderToScreen=!0),e.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){const c=this.createDepthTexture();for(e of i)e.setDepthTexture(c)}else e.setDepthTexture(this.depthTexture)}removePass(e){const t=this.passes,i=t.indexOf(e);if(i!==-1&&t.splice(i,1).length>0){if(this.depthTexture!==null){const o=(c,f)=>c||f.needsDepthTexture;t.reduce(o,!1)||(e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&i===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){const e=this.passes;this.deleteDepthTexture(),e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){const t=this.renderer,i=this.copyPass;let r=this.inputBuffer,s=this.outputBuffer,o=!1,a,c,f;e===void 0&&(this.timer.update(),e=this.timer.getDelta());for(const h of this.passes)h.enabled&&(h.render(t,r,s,e,o),h.needsSwap&&(o&&(i.renderToScreen=h.renderToScreen,a=t.getContext(),c=t.state.buffers.stencil,c.setFunc(a.NOTEQUAL,1,4294967295),i.render(t,r,s,e,o),c.setFunc(a.EQUAL,1,4294967295)),f=r,r=s,s=f),h instanceof Qz?o=!0:h instanceof qz&&(o=!1))}setSize(e,t,i){const r=this.renderer,s=r.getSize(new oe);(e===void 0||t===void 0)&&(e=s.width,t=s.height),(s.width!==e||s.height!==t)&&r.setSize(e,t,i);const o=r.getDrawingBufferSize(new oe);this.inputBuffer.setSize(o.width,o.height),this.outputBuffer.setSize(o.width,o.height);for(const a of this.passes)a.setSize(o.width,o.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(const e of this.passes)e.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),Bi.fullscreenGeometry.dispose()}},Es={NONE:0,DEPTH:1,CONVOLUTION:2},Nt={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"},$z=class{constructor(){this.shaderParts=new Map([[Nt.FRAGMENT_HEAD,null],[Nt.FRAGMENT_MAIN_UV,null],[Nt.FRAGMENT_MAIN_IMAGE,null],[Nt.VERTEX_HEAD,null],[Nt.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=Es.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=_r}},jv=!1,ZE=class{constructor(n=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(n),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case yi:t=this.materialsFlatShadedDoubleSide;break;case bn:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case yi:t=this.materialsDoubleSide;break;case bn:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(n){if(!(n instanceof Gn))return n.clone();const e=n.uniforms,t=new Map;for(const r in e){const s=e[r].value;s.isRenderTargetTexture&&(e[r].value=null,t.set(r,s))}const i=n.clone();for(const r of t)e[r[0]].value=r[1],i.uniforms[r[0]].value=r[1];return i}setMaterial(n){if(this.disposeMaterials(),this.material=n,n!==null){const e=this.materials=[this.cloneMaterial(n),this.cloneMaterial(n),this.cloneMaterial(n)];for(const t of e)t.uniforms=Object.assign({},n.uniforms),t.side=ts;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=bn,i}),this.materialsDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=yi,i}),this.materialsFlatShaded=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i}),this.materialsFlatShadedBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=bn,i}),this.materialsFlatShadedDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=yi,i})}}render(n,e,t){const i=n.shadowMap.enabled;if(n.shadowMap.enabled=!1,jv){const r=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),n.render(e,t);for(const s of r)s[0].material=s[1];this.meshCount!==r.size&&r.clear()}else{const r=e.overrideMaterial;e.overrideMaterial=this.material,n.render(e,t),e.overrideMaterial=r}n.shadowMap.enabled=i}disposeMaterials(){if(this.material!==null){const n=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(const e of n)e.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return jv}static set workaroundEnabled(n){jv=n}},qs=-1,ui=class extends xr{constructor(n,e=qs,t=qs,i=1){super(),this.resizable=n,this.baseSize=new oe(1,1),this.preferredSize=new oe(e,t),this.target=this.preferredSize,this.s=i,this.effectiveSize=new oe,this.addEventListener("change",()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){const n=this.baseSize,e=this.preferredSize,t=this.effectiveSize,i=this.scale;e.width!==qs?t.width=e.width:e.height!==qs?t.width=Math.round(e.height*(n.width/Math.max(n.height,1))):t.width=Math.round(n.width*i),e.height!==qs?t.height=e.height:e.width!==qs?t.height=Math.round(e.width/Math.max(n.width/Math.max(n.height,1),1)):t.height=Math.round(n.height*i)}get width(){return this.effectiveSize.width}set width(n){this.preferredWidth=n}get height(){return this.effectiveSize.height}set height(n){this.preferredHeight=n}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(n){this.s!==n&&(this.s=n,this.preferredSize.setScalar(qs),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getScale(){return this.scale}setScale(n){this.scale=n}get baseWidth(){return this.baseSize.width}set baseWidth(n){this.baseSize.width!==n&&(this.baseSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseWidth(){return this.baseWidth}setBaseWidth(n){this.baseWidth=n}get baseHeight(){return this.baseSize.height}set baseHeight(n){this.baseSize.height!==n&&(this.baseSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(n){this.baseHeight=n}setBaseSize(n,e){(this.baseSize.width!==n||this.baseSize.height!==e)&&(this.baseSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(n){this.preferredSize.width!==n&&(this.preferredSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(n){this.preferredWidth=n}get preferredHeight(){return this.preferredSize.height}set preferredHeight(n){this.preferredSize.height!==n&&(this.preferredSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(n){this.preferredHeight=n}setPreferredSize(n,e){(this.preferredSize.width!==n||this.preferredSize.height!==e)&&(this.preferredSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(n){this.s=n.scale,this.baseSize.set(n.baseWidth,n.baseHeight),this.preferredSize.set(n.preferredWidth,n.preferredHeight),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return qs}},wt={ADD:0,ALPHA:1,AVERAGE:2,COLOR:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,DIVIDE:8,DST:9,EXCLUSION:10,HARD_LIGHT:11,HARD_MIX:12,HUE:13,INVERT:14,INVERT_RGB:15,LIGHTEN:16,LINEAR_BURN:17,LINEAR_DODGE:18,LINEAR_LIGHT:19,LUMINOSITY:20,MULTIPLY:21,NEGATION:22,NORMAL:23,OVERLAY:24,PIN_LIGHT:25,REFLECT:26,SATURATION:27,SCREEN:28,SOFT_LIGHT:29,SRC:30,SUBTRACT:31,VIVID_LIGHT:32},eB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,x+y,opacity);}",tB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,min(y.a,opacity));}",nB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,(x+y)*0.5,opacity);}",iB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.rg,xHSL.b));return vec4(mix(x.rgb,z,opacity),y.a);}",rB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=mix(step(0.0,y)*(1.0-min(vec4(1.0),(1.0-x)/y)),vec4(1.0),step(1.0,x));return mix(x,z,opacity);}",sB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=step(0.0,x)*mix(min(vec4(1.0),x/max(1.0-y,1e-9)),vec4(1.0),step(1.0,y));return mix(x,z,opacity);}",oB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,min(x,y),opacity);}",aB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,abs(x-y),opacity);}",lB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,x/max(y,1e-12),opacity);}",uB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,(x+y-2.0*x*y),opacity);}",cB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 a=min(x,1.0),b=min(y,1.0);vec4 z=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,y));return mix(x,z,opacity);}",fB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,step(1.0,x+y),opacity);}",hB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(yHSL.r,xHSL.gb));return vec4(mix(x.rgb,z,opacity),y.a);}",dB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,1.0-y,opacity);}",pB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y*(1.0-x),opacity);}",mB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,max(x,y),opacity);}",gB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,clamp(y+x-1.0,0.0,1.0),opacity);}",vB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,min(x+y,1.0),opacity);}",yB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,clamp(2.0*y+x-1.0,0.0,1.0),opacity);}",_B="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.rg,yHSL.b));return vec4(mix(x.rgb,z,opacity),y.a);}",xB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,x*y,opacity);}",SB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,1.0-abs(1.0-x-y),opacity);}",MB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,opacity);}",EB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=mix(2.0*y*x,1.0-2.0*(1.0-y)*(1.0-x),step(0.5,x));return mix(x,z,opacity);}",wB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 y2=2.0*y;vec4 z=mix(mix(y2,x,step(0.5*x,y)),max(vec4(0.0),y2-1.0),step(x,(y2-1.0)));return mix(x,z,opacity);}",TB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=mix(min(x*x/max(1.0-y,1e-12),1.0),y,step(1.0,y));return mix(x,z,opacity);}",AB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 xHSL=RGBToHSL(x.rgb);vec3 yHSL=RGBToHSL(y.rgb);vec3 z=HSLToRGB(vec3(xHSL.r,yHSL.g,xHSL.b));return vec4(mix(x.rgb,z,opacity),y.a);}",CB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,x+y-min(x*y,1.0),opacity);}",RB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 y2=2.0*y;vec4 w=step(0.5,y);vec4 z=mix(x-(1.0-y2)*x*(1.0-x),mix(x+(y2-1.0)*(sqrt(x)-x),x+(y2-1.0)*x*((16.0*x-12.0)*x+3.0),w*(1.0-step(0.25,x))),w);return mix(x,z,opacity);}",bB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y;}",PB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,max(x+y-1.0,0.0),opacity);}",LB="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=mix(max(1.0-min((1.0-x)/(2.0*y),1.0),0.0),min(x/(2.0*(1.0-y)),1.0),step(0.5,y));return mix(x,z,opacity);}",IB=new Map([[wt.ADD,eB],[wt.ALPHA,tB],[wt.AVERAGE,nB],[wt.COLOR,iB],[wt.COLOR_BURN,rB],[wt.COLOR_DODGE,sB],[wt.DARKEN,oB],[wt.DIFFERENCE,aB],[wt.DIVIDE,lB],[wt.DST,null],[wt.EXCLUSION,uB],[wt.HARD_LIGHT,cB],[wt.HARD_MIX,fB],[wt.HUE,hB],[wt.INVERT,dB],[wt.INVERT_RGB,pB],[wt.LIGHTEN,mB],[wt.LINEAR_BURN,gB],[wt.LINEAR_DODGE,vB],[wt.LINEAR_LIGHT,yB],[wt.LUMINOSITY,_B],[wt.MULTIPLY,xB],[wt.NEGATION,SB],[wt.NORMAL,MB],[wt.OVERLAY,EB],[wt.PIN_LIGHT,wB],[wt.REFLECT,TB],[wt.SATURATION,AB],[wt.SCREEN,CB],[wt.SOFT_LIGHT,RB],[wt.SRC,bB],[wt.SUBTRACT,PB],[wt.VIVID_LIGHT,LB]]),UB=class extends xr{constructor(n,e=1){super(),this._blendFunction=n,this.opacity=new gt(e)}getOpacity(){return this.opacity.value}setOpacity(n){this.opacity.value=n}get blendFunction(){return this._blendFunction}set blendFunction(n){this._blendFunction=n,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(n){this.blendFunction=n}getShaderCode(){return IB.get(this.blendFunction)}},sf=class extends xr{constructor(n,e,{attributes:t=Es.NONE,blendFunction:i=wt.NORMAL,defines:r=new Map,uniforms:s=new Map,extensions:o=null,vertexShader:a=null}={}){super(),this.name=n,this.renderer=null,this.attributes=t,this.fragmentShader=e,this.vertexShader=a,this.defines=r,this.uniforms=s,this.extensions=o,this.blendMode=new UB(i),this.blendMode.addEventListener("change",c=>this.setChanged()),this._inputColorSpace=_r,this._outputColorSpace=_i}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(n){this._inputColorSpace=n,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(n){this._outputColorSpace=n,this.setChanged()}set mainScene(n){}set mainCamera(n){}getName(){return this.name}setRenderer(n){this.renderer=n}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(n){this.attributes=n,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(n){this.fragmentShader=n,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(n){this.vertexShader=n,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(n,e=wo){}update(n,e,t){}setSize(n,e){}initialize(n,e,t){}dispose(){for(const n of Object.keys(this)){const e=this[n];(e instanceof _n||e instanceof Wn||e instanceof an||e instanceof Bi)&&this[n].dispose()}}},vx={MEDIUM:2,LARGE:3},NB=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25; #include }`,DB="uniform vec4 texelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize.xy*vec2(kernel)+texelSize.zw)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}",OB=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],FB=class extends Gn{constructor(n=new Ot){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new gt(null),texelSize:new gt(new Ot),scale:new gt(1),kernel:new gt(0)},blending:ci,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:NB,vertexShader:DB}),this.setTexelSize(n.x,n.y),this.kernelSize=vx.MEDIUM}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.inputBuffer=n}get kernelSequence(){return OB[this.kernelSize]}get scale(){return this.uniforms.scale.value}set scale(n){this.uniforms.scale.value=n}getScale(){return this.uniforms.scale.value}setScale(n){this.uniforms.scale.value=n}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(n){this.uniforms.kernel.value=n}setKernel(n){this.kernel=n}setTexelSize(n,e){this.uniforms.texelSize.value.set(n,e,n*.5,e*.5)}setSize(n,e){const t=1/n,i=1/e;this.uniforms.texelSize.value.set(t,i,t*.5,i*.5)}},zB=class extends Bi{constructor({kernelSize:n=vx.MEDIUM,resolutionScale:e=.5,width:t=ui.AUTO_SIZE,height:i=ui.AUTO_SIZE,resolutionX:r=t,resolutionY:s=i}={}){super("KawaseBlurPass"),this.renderTargetA=new _n(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";const o=this.resolution=new ui(this,r,s,e);o.addEventListener("change",a=>this.setSize(o.baseWidth,o.baseHeight)),this._blurMaterial=new FB,this._blurMaterial.kernelSize=n,this.copyMaterial=new GR}getResolution(){return this.resolution}get blurMaterial(){return this._blurMaterial}set blurMaterial(n){this._blurMaterial=n}get dithering(){return this.copyMaterial.dithering}set dithering(n){this.copyMaterial.dithering=n}get kernelSize(){return this.blurMaterial.kernelSize}set kernelSize(n){this.blurMaterial.kernelSize=n}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get scale(){return this.blurMaterial.scale}set scale(n){this.blurMaterial.scale=n}getScale(){return this.blurMaterial.scale}setScale(n){this.blurMaterial.scale=n}getKernelSize(){return this.kernelSize}setKernelSize(n){this.kernelSize=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,e,t,i,r){const s=this.scene,o=this.camera,a=this.renderTargetA,c=this.renderTargetB,f=this.blurMaterial,h=f.kernelSequence;let d=e;this.fullscreenMaterial=f;for(let m=0,v=h.length;m #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef RANGE uniform vec2 range; #elif defined(THRESHOLD) uniform float threshold;uniform float smoothing; #endif varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb); #ifdef RANGE float low=step(range.x,l);float high=step(l,range.y);l*=low*high; #elif defined(THRESHOLD) l=smoothstep(threshold,threshold+smoothing,l)*l; #endif #ifdef COLOR gl_FragColor=vec4(texel.rgb*clamp(l,0.0,1.0),l); #else gl_FragColor=vec4(l); #endif }`,kB=class extends Gn{constructor(n=!1,e=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:nu.replace(/\D+/g,"")},uniforms:{inputBuffer:new gt(null),threshold:new gt(0),smoothing:new gt(1),range:new gt(null)},blending:ci,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:BB,vertexShader:VR}),this.colorOutput=n,this.luminanceRange=e}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get threshold(){return this.uniforms.threshold.value}set threshold(n){this.smoothing>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=n}getThreshold(){return this.threshold}setThreshold(n){this.threshold=n}get smoothing(){return this.uniforms.smoothing.value}set smoothing(n){this.threshold>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=n}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(n){this.smoothing=n}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(n){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(n){n?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(n){return this.colorOutput}setColorOutputEnabled(n){this.colorOutput=n}get useRange(){return this.luminanceRange!==null}set useRange(n){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(n){n!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=n,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(n){this.luminanceRange=n}},HB=class extends Bi{constructor({renderTarget:n,luminanceRange:e,colorOutput:t,resolutionScale:i=1,width:r=ui.AUTO_SIZE,height:s=ui.AUTO_SIZE,resolutionX:o=r,resolutionY:a=s}={}){super("LuminancePass"),this.fullscreenMaterial=new kB(t,e),this.needsSwap=!1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new _n(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target");const c=this.resolution=new ui(this,o,a,i);c.addEventListener("change",f=>this.setSize(c.baseWidth,c.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(n,e,t,i,r){const s=this.fullscreenMaterial;s.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}initialize(n,e,t){t!==void 0&&t!==Pn&&(this.renderTarget.texture.type=t,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},VB=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #define WEIGHT_INNER 0.125 #define WEIGHT_OUTER 0.0555555 varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;float clampToBorder(const in vec2 uv){return float(uv.s>=0.0&&uv.s<=1.0&&uv.t>=0.0&&uv.t<=1.0);}void main(){vec4 c=vec4(0.0);vec4 w=WEIGHT_INNER*vec4(clampToBorder(vUv00),clampToBorder(vUv01),clampToBorder(vUv02),clampToBorder(vUv03));c+=w.x*texture2D(inputBuffer,vUv00);c+=w.y*texture2D(inputBuffer,vUv01);c+=w.z*texture2D(inputBuffer,vUv02);c+=w.w*texture2D(inputBuffer,vUv03);w=WEIGHT_OUTER*vec4(clampToBorder(vUv04),clampToBorder(vUv05),clampToBorder(vUv06),clampToBorder(vUv07));c+=w.x*texture2D(inputBuffer,vUv04);c+=w.y*texture2D(inputBuffer,vUv05);c+=w.z*texture2D(inputBuffer,vUv06);c+=w.w*texture2D(inputBuffer,vUv07);w=WEIGHT_OUTER*vec4(clampToBorder(vUv08),clampToBorder(vUv09),clampToBorder(vUv10),clampToBorder(vUv11));c+=w.x*texture2D(inputBuffer,vUv08);c+=w.y*texture2D(inputBuffer,vUv09);c+=w.z*texture2D(inputBuffer,vUv10);c+=w.w*texture2D(inputBuffer,vUv11);c+=WEIGHT_OUTER*texture2D(inputBuffer,vUv);gl_FragColor=c; #include }`,GB="uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;void main(){vUv=position.xy*0.5+0.5;vUv00=vUv+texelSize*vec2(-1.0,1.0);vUv01=vUv+texelSize*vec2(1.0,1.0);vUv02=vUv+texelSize*vec2(-1.0,-1.0);vUv03=vUv+texelSize*vec2(1.0,-1.0);vUv04=vUv+texelSize*vec2(-2.0,2.0);vUv05=vUv+texelSize*vec2(0.0,2.0);vUv06=vUv+texelSize*vec2(2.0,2.0);vUv07=vUv+texelSize*vec2(-2.0,0.0);vUv08=vUv+texelSize*vec2(2.0,0.0);vUv09=vUv+texelSize*vec2(-2.0,-2.0);vUv10=vUv+texelSize*vec2(0.0,-2.0);vUv11=vUv+texelSize*vec2(2.0,-2.0);gl_Position=vec4(position.xy,1.0,1.0);}",WB=class extends Gn{constructor(){super({name:"DownsamplingMaterial",uniforms:{inputBuffer:new gt(null),texelSize:new gt(new oe)},blending:ci,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:VB,vertexShader:GB})}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setSize(n,e){this.uniforms.texelSize.value.set(1/n,1/e)}},XB=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer;uniform mediump sampler2D supportBuffer; #else uniform lowp sampler2D inputBuffer;uniform lowp sampler2D supportBuffer; #endif uniform float radius;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vec4 c=vec4(0.0);c+=texture2D(inputBuffer,vUv0)*0.0625;c+=texture2D(inputBuffer,vUv1)*0.125;c+=texture2D(inputBuffer,vUv2)*0.0625;c+=texture2D(inputBuffer,vUv3)*0.125;c+=texture2D(inputBuffer,vUv)*0.25;c+=texture2D(inputBuffer,vUv4)*0.125;c+=texture2D(inputBuffer,vUv5)*0.0625;c+=texture2D(inputBuffer,vUv6)*0.125;c+=texture2D(inputBuffer,vUv7)*0.0625;vec4 baseColor=texture2D(supportBuffer,vUv);gl_FragColor=mix(baseColor,c,radius); #include }`,YB="uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,1.0);vUv1=vUv+texelSize*vec2(0.0,1.0);vUv2=vUv+texelSize*vec2(1.0,1.0);vUv3=vUv+texelSize*vec2(-1.0,0.0);vUv4=vUv+texelSize*vec2(1.0,0.0);vUv5=vUv+texelSize*vec2(-1.0,-1.0);vUv6=vUv+texelSize*vec2(0.0,-1.0);vUv7=vUv+texelSize*vec2(1.0,-1.0);gl_Position=vec4(position.xy,1.0,1.0);}",jB=class extends Gn{constructor(){super({name:"UpsamplingMaterial",uniforms:{inputBuffer:new gt(null),supportBuffer:new gt(null),texelSize:new gt(new oe),radius:new gt(.85)},blending:ci,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:XB,vertexShader:YB})}set inputBuffer(n){this.uniforms.inputBuffer.value=n}set supportBuffer(n){this.uniforms.supportBuffer.value=n}get radius(){return this.uniforms.radius.value}set radius(n){this.uniforms.radius.value=n}setSize(n,e){this.uniforms.texelSize.value.set(1/n,1/e)}},qB=class extends Bi{constructor(){super("MipmapBlurPass"),this.needsSwap=!1,this.renderTarget=new _n(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="Upsampling.Mipmap0",this.downsamplingMipmaps=[],this.upsamplingMipmaps=[],this.downsamplingMaterial=new WB,this.upsamplingMaterial=new jB,this.resolution=new oe}get texture(){return this.renderTarget.texture}get levels(){return this.downsamplingMipmaps.length}set levels(n){if(this.levels!==n){const e=this.renderTarget;this.dispose(),this.downsamplingMipmaps=[],this.upsamplingMipmaps=[];for(let t=0;t=0;--m){const v=h[m];c.setSize(d.width,d.height),c.inputBuffer=d.texture,c.supportBuffer=f[m].texture,n.setRenderTarget(v),n.render(s,o),d=v}}setSize(n,e){const t=this.resolution;t.set(n,e);let i=t.width,r=t.height;for(let s=0,o=this.downsamplingMipmaps.length;sthis.setSize(v.baseWidth,v.baseHeight))}get texture(){return this.mipmapBlurPass.enabled?this.mipmapBlurPass.texture:this.renderTarget.texture}getTexture(){return this.texture}getResolution(){return this.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get dithering(){return this.blurPass.dithering}set dithering(n){this.blurPass.dithering=n}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(n){this.blurPass.kernelSize=n}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(n){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(n){this.uniforms.get("intensity").value=n}getIntensity(){return this.intensity}setIntensity(n){this.intensity=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}update(n,e,t){const i=this.renderTarget,r=this.luminancePass;r.enabled?(r.render(n,e),this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(n,r.renderTarget):this.blurPass.render(n,r.renderTarget,i)):this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(n,e):this.blurPass.render(n,e,i)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height),this.blurPass.resolution.copy(t),this.luminancePass.setSize(n,e),this.mipmapBlurPass.setSize(n,e)}initialize(n,e,t){this.blurPass.initialize(n,e,t),this.luminancePass.initialize(n,e,t),this.mipmapBlurPass.initialize(n,e,t),t!==void 0&&(this.renderTarget.texture.type=t,n!==null&&n.outputColorSpace===At&&(this.renderTarget.texture.colorSpace=At))}},$o={DISABLED:0,SPORADIC:1,CONSTANT_MILD:2,CONSTANT_WILD:3};function QB(n,e,t){const i=new Map([[Zp,1],[U_,2],[Hn,4]]);let r;if(i.has(e)||console.error("Invalid noise texture format"),t===Pn){r=new Uint8Array(n*i.get(e));for(let s=0,o=r.length;sdistortion.x-columns*random){float sx=clamp(ceil(seeds.x),0.0,1.0);uv.y=sx*(1.0-(uv.y+distortion.y))+(1.0-sx)*distortion.y;}if(uv.xdistortion.y-columns*random){float sy=clamp(ceil(seeds.y),0.0,1.0);uv.x=sy*distortion.x+(1.0-sy)*(1.0-(uv.x+distortion.x));}vec2 normal=texture2D(perturbationMap,uv*random*random).rg;uv+=normal*seeds*(random*0.2);}}",Pd="Glitch.Generated";function Ri(n,e){return n+Math.random()*(e-n)}var $B=class extends sf{constructor({chromaticAberrationOffset:n=null,delay:e=new oe(1.5,3.5),duration:t=new oe(.6,1),strength:i=new oe(.3,1),columns:r=.05,ratio:s=.85,perturbationMap:o=null,dtSize:a=64}={}){if(super("GlitchEffect",JB,{uniforms:new Map([["perturbationMap",new gt(null)],["columns",new gt(r)],["active",new gt(!1)],["random",new gt(1)],["seeds",new gt(new oe)],["distortion",new gt(new oe)]])}),o===null){const c=new KE(a,a,Hn);c.name=Pd,this.perturbationMap=c}else this.perturbationMap=o;this.time=0,this.distortion=this.uniforms.get("distortion").value,this.delay=e,this.duration=t,this.breakPoint=new oe(Ri(this.delay.x,this.delay.y),Ri(this.duration.x,this.duration.y)),this.strength=i,this.mode=$o.SPORADIC,this.ratio=s,this.chromaticAberrationOffset=n}get seeds(){return this.uniforms.get("seeds").value}get active(){return this.uniforms.get("active").value}isActive(){return this.active}get minDelay(){return this.delay.x}set minDelay(n){this.delay.x=n}getMinDelay(){return this.delay.x}setMinDelay(n){this.delay.x=n}get maxDelay(){return this.delay.y}set maxDelay(n){this.delay.y=n}getMaxDelay(){return this.delay.y}setMaxDelay(n){this.delay.y=n}get minDuration(){return this.duration.x}set minDuration(n){this.duration.x=n}getMinDuration(){return this.duration.x}setMinDuration(n){this.duration.x=n}get maxDuration(){return this.duration.y}set maxDuration(n){this.duration.y=n}getMaxDuration(){return this.duration.y}setMaxDuration(n){this.duration.y=n}get minStrength(){return this.strength.x}set minStrength(n){this.strength.x=n}getMinStrength(){return this.strength.x}setMinStrength(n){this.strength.x=n}get maxStrength(){return this.strength.y}set maxStrength(n){this.strength.y=n}getMaxStrength(){return this.strength.y}setMaxStrength(n){this.strength.y=n}getMode(){return this.mode}setMode(n){this.mode=n}getGlitchRatio(){return 1-this.ratio}setGlitchRatio(n){this.ratio=Math.min(Math.max(1-n,0),1)}get columns(){return this.uniforms.get("columns").value}set columns(n){this.uniforms.get("columns").value=n}getGlitchColumns(){return this.columns}setGlitchColumns(n){this.columns=n}getChromaticAberrationOffset(){return this.chromaticAberrationOffset}setChromaticAberrationOffset(n){this.chromaticAberrationOffset=n}get perturbationMap(){return this.uniforms.get("perturbationMap").value}set perturbationMap(n){const e=this.perturbationMap;e!==null&&e.name===Pd&&e.dispose(),n.minFilter=n.magFilter=Xt,n.wrapS=n.wrapT=jl,n.generateMipmaps=!1,this.uniforms.get("perturbationMap").value=n}getPerturbationMap(){return this.perturbationMap}setPerturbationMap(n){this.perturbationMap=n}generatePerturbationMap(n=64){const e=new KE(n,n,Hn);return e.name=Pd,e}update(n,e,t){const i=this.mode,r=this.breakPoint,s=this.chromaticAberrationOffset,o=this.strength;let a=this.time,c=!1,f=0,h=0,d;i!==$o.DISABLED&&(i===$o.SPORADIC&&(a+=t,d=a>r.x,a>=r.x+r.y&&(r.set(Ri(this.delay.x,this.delay.y),Ri(this.duration.x,this.duration.y)),a=0)),f=Math.random(),this.uniforms.get("random").value=f,d&&f>this.ratio||i===$o.CONSTANT_WILD?(c=!0,f*=o.y*.03,h=Ri(-Math.PI,Math.PI),this.seeds.set(Ri(-o.y,o.y),Ri(-o.y,o.y)),this.distortion.set(Ri(0,1),Ri(0,1))):(d||i===$o.CONSTANT_MILD)&&(c=!0,f*=o.x*.03,h=Ri(-Math.PI,Math.PI),this.seeds.set(Ri(-o.x,o.x),Ri(-o.x,o.x)),this.distortion.set(Ri(0,1),Ri(0,1))),this.time=a),s!==null&&(c?s.set(Math.cos(h),Math.sin(h)).multiplyScalar(f):s.set(0,0)),this.uniforms.get("active").value=c}dispose(){const n=this.perturbationMap;n!==null&&n.name===Pd&&n.dispose()}},XR=class extends Bi{constructor(n,e,t=null){super("RenderPass",n,e),this.needsSwap=!1,this.clearPass=new WR,this.overrideMaterialManager=t===null?null:new ZE(t),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get renderToScreen(){return super.renderToScreen}set renderToScreen(n){super.renderToScreen=n,this.clearPass.renderToScreen=n}get overrideMaterial(){const n=this.overrideMaterialManager;return n!==null?n.material:null}set overrideMaterial(n){const e=this.overrideMaterialManager;n!==null?e!==null?e.setMaterial(n):this.overrideMaterialManager=new ZE(n):e!==null&&(e.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(n){this.overrideMaterial=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getSelection(){return this.selection}setSelection(n){this.selection=n}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(n){this.ignoreBackground=n}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(n){this.skipShadowMapUpdate=n}getClearPass(){return this.clearPass}render(n,e,t,i,r){const s=this.scene,o=this.camera,a=this.selection,c=o.layers.mask,f=s.background,h=n.shadowMap.autoUpdate,d=this.renderToScreen?null:e;a!==null&&o.layers.set(a.getLayer()),this.skipShadowMapUpdate&&(n.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(s.background=null),this.clearPass.enabled&&this.clearPass.render(n,e),n.setRenderTarget(d),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(n,s,o):n.render(s,o),o.layers.mask=c,s.background=f,n.shadowMap.autoUpdate=h}},Qu={DEFAULT:0,ESKIL:1},ek=`#include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif #ifdef DOWNSAMPLE_NORMALS uniform lowp sampler2D normalBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]this.setSize(a.baseWidth,a.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(n,e=wo){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e}render(n,e,t,i,r){n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height),this.fullscreenMaterial.setSize(n,e)}initialize(n,e,t){const i=n.getContext();if(!(i.getExtension("EXT_color_buffer_float")||i.getExtension("EXT_color_buffer_half_float")))throw new Error("Rendering to float texture is not supported.")}},rk=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb; #if VIGNETTE_TECHNIQUE == 0 float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset)); #else vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord)); #endif outputColor=vec4(color,inputColor.a);}`,sk=class extends sf{constructor({blendFunction:n,eskil:e=!1,technique:t=e?Qu.ESKIL:Qu.DEFAULT,offset:i=.5,darkness:r=.5}={}){super("VignetteEffect",rk,{blendFunction:n,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new gt(i)],["darkness",new gt(r)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(n){this.technique!==n&&(this.defines.set("VIGNETTE_TECHNIQUE",n.toFixed(0)),this.setChanged())}get eskil(){return this.technique===Qu.ESKIL}set eskil(n){this.technique=n?Qu.ESKIL:Qu.DEFAULT}getTechnique(){return this.technique}setTechnique(n){this.technique=n}get offset(){return this.uniforms.get("offset").value}set offset(n){this.uniforms.get("offset").value=n}getOffset(){return this.offset}setOffset(n){this.offset=n}get darkness(){return this.uniforms.get("darkness").value}set darkness(n){this.uniforms.get("darkness").value=n}getDarkness(){return this.darkness}setDarkness(n){this.darkness=n}},ok=`#include #include #include #define packFloatToRGBA(v) packDepthToRGBA(v) #define unpackRGBAToFloat(v) unpackRGBAToDepth(v) #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #if DEPTH_PACKING == 3201 uniform lowp sampler2D depthBuffer; #elif defined(GL_FRAGMENT_PRECISION_HIGH) uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const in vec4 value){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);}float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }float getViewZ(const in float depth){ #ifdef PERSPECTIVE_CAMERA return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); #else return orthographicDepthToViewZ(depth,cameraNear,cameraFar); #endif }vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0; #ifdef ENCODE_OUTPUT #include #endif #include }`,ak="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEAD void main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORT gl_Position=vec4(position.xy,1.0,1.0);}",lk=class extends Gn{constructor(n,e,t,i,r=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:nu.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new gt(null),depthBuffer:new gt(null),resolution:new gt(new oe),texelSize:new gt(new oe),cameraNear:new gt(.3),cameraFar:new gt(1e3),aspect:new gt(1),time:new gt(0)},blending:ci,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:r}),n&&this.setShaderParts(n),e&&this.setDefines(e),t&&this.setUniforms(t),this.copyCameraSettings(i)}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){this.uniforms.depthBuffer.value=n}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,e=wo){this.depthBuffer=n,this.depthPacking=e}setShaderData(n){this.setShaderParts(n.shaderParts),this.setDefines(n.defines),this.setUniforms(n.uniforms),this.setExtensions(n.extensions)}setShaderParts(n){return this.fragmentShader=ok.replace(Nt.FRAGMENT_HEAD,n.get(Nt.FRAGMENT_HEAD)||"").replace(Nt.FRAGMENT_MAIN_UV,n.get(Nt.FRAGMENT_MAIN_UV)||"").replace(Nt.FRAGMENT_MAIN_IMAGE,n.get(Nt.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=ak.replace(Nt.VERTEX_HEAD,n.get(Nt.VERTEX_HEAD)||"").replace(Nt.VERTEX_MAIN_SUPPORT,n.get(Nt.VERTEX_MAIN_SUPPORT)||""),this.needsUpdate=!0,this}setDefines(n){for(const e of n.entries())this.defines[e[0]]=e[1];return this.needsUpdate=!0,this}setUniforms(n){for(const e of n.entries())this.uniforms[e[0]]=e[1];return this}setExtensions(n){this.extensions={};for(const e of n)this.extensions[e]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(n){this.encodeOutput!==n&&(n?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(n){return this.encodeOutput}setOutputEncodingEnabled(n){this.encodeOutput=n}get time(){return this.uniforms.time.value}set time(n){this.uniforms.time.value=n}setDeltaTime(n){this.uniforms.time.value+=n}adoptCameraSettings(n){this.copyCameraSettings(n)}copyCameraSettings(n){n&&(this.uniforms.cameraNear.value=n.near,this.uniforms.cameraFar.value=n.far,n instanceof Cn?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(n,e){const t=this.uniforms;t.resolution.value.set(n,e),t.texelSize.value.set(1/n,1/e),t.aspect.value=n/e}static get Section(){return Nt}};function QE(n,e,t){for(const i of e){const r="$1"+n+i.charAt(0).toUpperCase()+i.slice(1),s=new RegExp("([^\\.])(\\b"+i+"\\b)","g");for(const o of t.entries())o[1]!==null&&t.set(o[0],o[1].replace(s,r))}}function uk(n,e,t){let i=e.getFragmentShader(),r=e.getVertexShader();const s=i!==void 0&&/mainImage/.test(i),o=i!==void 0&&/mainUv/.test(i);if(t.attributes|=e.getAttributes(),i===void 0)throw new Error(`Missing fragment shader (${e.name})`);if(o&&t.attributes&Es.CONVOLUTION)throw new Error(`Effects that transform UVs are incompatible with convolution effects (${e.name})`);if(!s&&!o)throw new Error(`Could not find mainImage or mainUv function (${e.name})`);{const a=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,c=t.shaderParts;let f=c.get(Nt.FRAGMENT_HEAD)||"",h=c.get(Nt.FRAGMENT_MAIN_UV)||"",d=c.get(Nt.FRAGMENT_MAIN_IMAGE)||"",m=c.get(Nt.VERTEX_HEAD)||"",v=c.get(Nt.VERTEX_MAIN_SUPPORT)||"";const _=new Set,E=new Set;if(o&&(h+=` ${n}MainUv(UV); `,t.uvTransformation=!0),r!==null&&/mainSupport/.test(r)){const x=/mainSupport *\([\w\s]*?uv\s*?\)/.test(r);v+=` ${n}MainSupport(`,v+=x?`vUv); `:`); `;for(const S of r.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(const T of S[1].split(/\s*,\s*/))t.varyings.add(T),_.add(T),E.add(T);for(const S of r.matchAll(a))E.add(S[1])}for(const x of i.matchAll(a))E.add(x[1]);for(const x of e.defines.keys())E.add(x.replace(/\([\w\s,]*\)/g,""));for(const x of e.uniforms.keys())E.add(x);E.delete("while"),E.delete("for"),E.delete("if"),e.uniforms.forEach((x,S)=>t.uniforms.set(n+S.charAt(0).toUpperCase()+S.slice(1),x)),e.defines.forEach((x,S)=>t.defines.set(n+S.charAt(0).toUpperCase()+S.slice(1),x));const M=new Map([["fragment",i],["vertex",r]]);QE(n,E,t.defines),QE(n,E,M),i=M.get("fragment"),r=M.get("vertex");const g=e.blendMode;if(t.blendModes.set(g.blendFunction,g),s){e.inputColorSpace!==null&&e.inputColorSpace!==t.colorSpace&&(d+=e.inputColorSpace===At?`color0 = sRGBTransferOETF(color0); `:`color0 = sRGBToLinear(color0); `),e.outputColorSpace!==_i?t.colorSpace=e.outputColorSpace:e.inputColorSpace!==null&&(t.colorSpace=e.inputColorSpace);const x=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;d+=`${n}MainImage(color0, UV, `,t.attributes&Es.DEPTH&&x.test(i)&&(d+="depth, ",t.readDepth=!0),d+=`color1); `;const S=n+"BlendOpacity";t.uniforms.set(S,g.opacity),d+=`color0 = blend${g.blendFunction}(color0, color1, ${S}); `,f+=`uniform float ${S}; `}if(f+=i+` `,r!==null&&(m+=r+` `),c.set(Nt.FRAGMENT_HEAD,f),c.set(Nt.FRAGMENT_MAIN_UV,h),c.set(Nt.FRAGMENT_MAIN_IMAGE,d),c.set(Nt.VERTEX_HEAD,m),c.set(Nt.VERTEX_MAIN_SUPPORT,v),e.extensions!==null)for(const x of e.extensions)t.extensions.add(x)}}var ck=class extends Bi{constructor(n,...e){super("EffectPass"),this.fullscreenMaterial=new lk(null,null,null,n),this.listener=t=>this.handleEvent(t),this.effects=[],this.setEffects(e),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,this.timeScale=1}set mainScene(n){for(const e of this.effects)e.mainScene=n}set mainCamera(n){this.fullscreenMaterial.copyCameraSettings(n);for(const e of this.effects)e.mainCamera=n}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(n){this.fullscreenMaterial.encodeOutput=n}get dithering(){return this.fullscreenMaterial.dithering}set dithering(n){const e=this.fullscreenMaterial;e.dithering=n,e.needsUpdate=!0}setEffects(n){for(const e of this.effects)e.removeEventListener("change",this.listener);this.effects=n.sort((e,t)=>t.attributes-e.attributes);for(const e of this.effects)e.addEventListener("change",this.listener)}updateMaterial(){const n=new $z;let e=0;for(const o of this.effects)if(o.blendMode.blendFunction===wt.DST)n.attributes|=o.getAttributes()&Es.DEPTH;else{if(n.attributes&o.getAttributes()&Es.CONVOLUTION)throw new Error(`Convolution effects cannot be merged (${o.name})`);uk("e"+e++,o,n)}let t=n.shaderParts.get(Nt.FRAGMENT_HEAD),i=n.shaderParts.get(Nt.FRAGMENT_MAIN_IMAGE),r=n.shaderParts.get(Nt.FRAGMENT_MAIN_UV);const s=/\bblend\b/g;for(const o of n.blendModes.values())t+=o.getShaderCode().replace(s,`blend${o.blendFunction}`)+` `;n.attributes&Es.DEPTH?(n.readDepth&&(i=`float depth = readDepth(UV); `+i),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,n.colorSpace===At&&(i+=`color0 = sRGBToLinear(color0); `),n.uvTransformation?(r=`vec2 transformedUv = vUv; `+r,n.defines.set("UV","transformedUv")):n.defines.set("UV","vUv"),n.shaderParts.set(Nt.FRAGMENT_HEAD,t),n.shaderParts.set(Nt.FRAGMENT_MAIN_IMAGE,i),n.shaderParts.set(Nt.FRAGMENT_MAIN_UV,r);for(const[o,a]of n.shaderParts)a!==null&&n.shaderParts.set(o,a.trim().replace(/^#/,` #`));this.skipRendering=e===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(n)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(n,e=wo){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e;for(const t of this.effects)t.setDepthTexture(n,e)}render(n,e,t,i,r){for(const s of this.effects)s.update(n,e,i);if(!this.skipRendering||this.renderToScreen){const s=this.fullscreenMaterial;s.inputBuffer=e.texture,s.time+=i*this.timeScale,n.setRenderTarget(this.renderToScreen?null:t),n.render(this.scene,this.camera)}}setSize(n,e){this.fullscreenMaterial.setSize(n,e);for(const t of this.effects)t.setSize(n,e)}initialize(n,e,t){this.renderer=n;for(const i of this.effects)i.initialize(n,e,t);this.updateMaterial(),t!==void 0&&t!==Pn&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const n of this.effects)n.removeEventListener("change",this.listener),n.dispose()}handleEvent(n){switch(n.type){case"change":this.recompile();break}}},fk=class extends Bi{constructor(n,e,{renderTarget:t,resolutionScale:i=1,width:r=ui.AUTO_SIZE,height:s=ui.AUTO_SIZE,resolutionX:o=r,resolutionY:a=s}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new XR(n,e,new sx);const c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;const f=c.getClearPass();f.overrideClearColor=new Ue(7829503),f.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new _n(1,1,{minFilter:Xt,magFilter:Xt}),this.renderTarget.texture.name="NormalPass.Target");const h=this.resolution=new ui(this,o,a,i);h.addEventListener("change",d=>this.setSize(h.baseWidth,h.baseHeight))}set mainScene(n){this.renderPass.mainScene=n}set mainCamera(n){this.renderPass.mainCamera=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,e,t,i,r){const s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(n,s,s)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}};let Ju;function hk(){var n;if(Ju!==void 0)return Ju;try{let e;const t=document.createElement("canvas");return Ju=!!(window.WebGL2RenderingContext&&(e=t.getContext("webgl2"))),e&&((n=e.getExtension("WEBGL_lose_context"))==null||n.loseContext()),Ju}catch{return Ju=!1}}const dk=we.createContext(null),JE=n=>(n.getAttributes()&Es.CONVOLUTION)===Es.CONVOLUTION,pk=_c.memo(we.forwardRef(({children:n,camera:e,scene:t,resolutionScale:i,enabled:r=!0,renderPriority:s=1,autoClear:o=!0,depthBuffer:a,enableNormalPass:c,stencilBuffer:f,multisampling:h=8,frameBufferType:d=ya},m)=>{const{gl:v,scene:_,camera:E,size:M}=xm(),g=t||_,x=e||E,[S,T,L]=we.useMemo(()=>{const D=hk(),C=new Jz(v,{depthBuffer:a,stencilBuffer:f,multisampling:h>0&&D?h:0,frameBufferType:d});C.addPass(new XR(g,x));let b=null,B=null;return c&&(B=new fk(g,x),B.enabled=!1,C.addPass(B),i!==void 0&&D&&(b=new ik({normalBuffer:B.texture,resolutionScale:i}),b.enabled=!1,C.addPass(b))),[C,B,b]},[x,v,a,f,h,d,g,c,i]);we.useEffect(()=>S==null?void 0:S.setSize(M.width,M.height),[S,M]),Sm((D,C)=>{if(r){const b=v.autoClear;v.autoClear=o,f&&!o&&v.clearStencil(),S.render(C),v.autoClear=b}},r?s:0);const R=we.useRef(null);we.useLayoutEffect(()=>{var D;const C=[],b=(D=R.current)==null?void 0:D.__r3f;if(b&&S){const B=b.objects;for(let j=0;j{for(const B of C)S==null||S.removePass(B);T&&(T.enabled=!1),L&&(L.enabled=!1)}},[S,n,x,T,L]),we.useEffect(()=>{const D=v.toneMapping;return v.toneMapping=Dr,()=>{v.toneMapping=D}},[v]);const P=we.useMemo(()=>({composer:S,normalPass:T,downSamplingPass:L,resolutionScale:i,camera:x,scene:g}),[S,T,L,i,x,g]);return we.useImperativeHandle(m,()=>S,[S]),ut.jsx(dk.Provider,{value:P,children:ut.jsx("group",{ref:R,children:n})})}));let mk=0;const $E=new WeakMap,YR=(n,e)=>_c.forwardRef(function({blendFunction:i=e==null?void 0:e.blendFunction,opacity:r=e==null?void 0:e.opacity,...s},o){let a=$E.get(n);if(!a){const h=`@react-three/postprocessing/${n.name}-${mk++}`;TR({[h]:n}),$E.set(n,a=h)}const c=xm(h=>h.camera),f=_c.useMemo(()=>{var h,d;return[...(h=e==null?void 0:e.args)!=null?h:[],...(d=s.args)!=null?d:[{...e,...s}]]},[JSON.stringify(s)]);return ut.jsx(a,{camera:c,"blendMode-blendFunction":i,"blendMode-opacity-value":r,...s,ref:o,args:f})}),Ld=(n,e)=>{const t=n[e];return _c.useMemo(()=>typeof t=="number"?new oe(t,t):t?new oe(...t):new oe,[t])},gk=YR(KB,{blendFunction:wt.ADD}),vk=we.forwardRef(function({active:e=!0,...t},i){const r=xm(h=>h.invalidate),s=Ld(t,"delay"),o=Ld(t,"duration"),a=Ld(t,"strength"),c=Ld(t,"chromaticAberrationOffset"),f=we.useMemo(()=>new $B({...t,delay:s,duration:o,strength:a,chromaticAberrationOffset:c}),[s,o,t,a,c]);return we.useLayoutEffect(()=>{f.mode=e?t.mode||$o.SPORADIC:$o.DISABLED,r()},[e,f,r,t.mode]),we.useEffect(()=>()=>{var h;(h=f.dispose)==null||h.call(f)},[f]),ut.jsx("primitive",{ref:i,object:f,dispose:null})}),yk=YR(sk);function _k({position:n,color:e}){const t=we.useRef(),i=we.useRef(n),r=we.useRef({x:Math.random()*.02-.01,y:Math.random()*.02-.01,z:Math.random()*.02-.01});return Sm(({clock:s})=>{if(t.current){t.current.rotation.x+=r.current.x,t.current.rotation.y+=r.current.y,t.current.rotation.z+=r.current.z;const o=s.getElapsedTime();t.current.position.x=i.current[0]+Math.sin(o*.5)*.5,t.current.position.y=i.current[1]+Math.cos(o*.3)*.5,t.current.position.z=i.current[2]+Math.sin(o*.4)*.5;const a=1+Math.sin(o*2)*.1;t.current.scale.set(a,a,a)}}),ut.jsxs("mesh",{ref:t,position:n,children:[ut.jsx("icosahedronGeometry",{args:[1,1]}),ut.jsx("meshPhongMaterial",{color:e,shininess:100,transparent:!0,opacity:.7,side:yi})]})}function xk(){const n=Array.from({length:50},()=>({position:[(Math.random()-.5)*40,(Math.random()-.5)*40,(Math.random()-.5)*40],color:new Ue().setHSL(Math.random(),.7,.5)}));return ut.jsx(ut.Fragment,{children:n.map((e,t)=>ut.jsx(_k,{position:e.position,color:e.color},t))})}function Sk(){const n=we.useRef(),e=5e3,t=we.useRef(Float32Array.from({length:e*3},()=>(Math.random()-.5)*50)),i=we.useRef(Float32Array.from({length:e*3},()=>Math.random()*.5+.5));return Sm(({clock:r})=>{if(n.current){n.current.rotation.y+=5e-4,n.current.material.opacity=.4+.2*Math.sin(r.getElapsedTime()*2),n.current.material.size=.12+.05*Math.sin(r.getElapsedTime()*3);const s=n.current.geometry.attributes.position.array;for(let o=0;o{n.fog=new yf(1118495,.002);const r=new window.Audio("/assets/music/ambient.mp3");r.loop=!0,r.volume=.5,t.current=r;const s=()=>{r.play(),window.removeEventListener("click",s)};window.addEventListener("click",s);const o=a=>{i.current.x=a.clientX/window.innerWidth*2-1,i.current.y=-(a.clientY/window.innerHeight)*2+1};return window.addEventListener("mousemove",o),()=>{r.pause(),window.removeEventListener("click",s),window.removeEventListener("mousemove",o)}},[n]),Sm(()=>{e.position.x+=(i.current.x*8-e.position.x)*.04,e.position.y+=(i.current.y*4-e.position.y)*.04,e.lookAt(0,0,0)}),ut.jsxs(ut.Fragment,{children:[ut.jsx("ambientLight",{intensity:.5}),ut.jsx("pointLight",{position:[10,10,10],intensity:1,color:16742399}),ut.jsx("pointLight",{position:[-10,-10,-10],intensity:.5,color:7864319}),ut.jsx(Sk,{}),ut.jsx(xk,{}),ut.jsxs(pk,{children:[ut.jsx(gk,{intensity:1.5,luminanceThreshold:.1,luminanceSmoothing:.9}),ut.jsx(yk,{eskil:!1,offset:.2,darkness:1.1}),ut.jsx(vk,{delay:[1.5,3.5],duration:[.3,.6],strength:[.01,.02],active:!1})]})]})}function Ek(){return ut.jsxs("div",{className:"canvas-container",children:[ut.jsx(Wz,{camera:{position:[0,0,15],fov:75},dpr:window.devicePixelRatio,children:ut.jsx(Mk,{})}),ut.jsxs("footer",{className:"dreamy-footer",children:["©2025 Pejman Ebrahimi — All rights reserved.",ut.jsx("span",{className:"footer-message",children:"| Crafted for dreamers. Experience the impossible."})]})]})}qv.createRoot(document.getElementById("root")).render(ut.jsx(_c.StrictMode,{children:ut.jsx(Ek,{})}));