(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 Yy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Fw={exports:{}},Cm={},Ow={exports:{}},Ht={};/** * @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 qh=Symbol.for("react.element"),IP=Symbol.for("react.portal"),LP=Symbol.for("react.fragment"),DP=Symbol.for("react.strict_mode"),UP=Symbol.for("react.profiler"),FP=Symbol.for("react.provider"),OP=Symbol.for("react.context"),NP=Symbol.for("react.forward_ref"),kP=Symbol.for("react.suspense"),zP=Symbol.for("react.memo"),HP=Symbol.for("react.lazy"),SE=Symbol.iterator;function GP(n){return n===null||typeof n!="object"?null:(n=SE&&n[SE]||n["@@iterator"],typeof n=="function"?n:null)}var Nw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},kw=Object.assign,zw={};function Kc(n,e,t){this.props=n,this.context=e,this.refs=zw,this.updater=t||Nw}Kc.prototype.isReactComponent={};Kc.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")};Kc.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function Hw(){}Hw.prototype=Kc.prototype;function Ky(n,e,t){this.props=n,this.context=e,this.refs=zw,this.updater=t||Nw}var Zy=Ky.prototype=new Hw;Zy.constructor=Ky;kw(Zy,Kc.prototype);Zy.isPureReactComponent=!0;var EE=Array.isArray,Gw=Object.prototype.hasOwnProperty,Qy={current:null},Vw={key:!0,ref:!0,__self:!0,__source:!0};function Ww(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)Gw.call(e,i)&&!Vw.hasOwnProperty(i)&&(r[i]=e[i]);var a=arguments.length-2;if(a===1)r.children=t;else if(1>>1,ue=H[re];if(0>>1;rer(Pe,Y))Mer(Ue,Pe)?(H[re]=Ue,H[Me]=Y,re=Me):(H[re]=Pe,H[_e]=Y,re=_e);else if(Mer(Ue,Y))H[re]=Ue,H[Me]=Y,re=Me;else break e}}return Q}function r(H,Q){var Y=H.sortIndex-Q.sortIndex;return Y!==0?Y:H.id-Q.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 l=[],h=[],f=1,d=null,p=3,g=!1,_=!1,S=!1,y=typeof setTimeout=="function"?setTimeout:null,m=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 A(H){for(var Q=t(h);Q!==null;){if(Q.callback===null)i(h);else if(Q.startTime<=H)i(h),Q.sortIndex=Q.expirationTime,e(l,Q);else break;Q=t(h)}}function M(H){if(S=!1,A(H),!_)if(t(l)!==null)_=!0,ie(C);else{var Q=t(h);Q!==null&&fe(M,Q.startTime-H)}}function C(H,Q){_=!1,S&&(S=!1,m(D),D=-1),g=!0;var Y=p;try{for(A(Q),d=t(l);d!==null&&(!(d.expirationTime>Q)||H&&!O());){var re=d.callback;if(typeof re=="function"){d.callback=null,p=d.priorityLevel;var ue=re(d.expirationTime<=Q);Q=n.unstable_now(),typeof ue=="function"?d.callback=ue:d===t(l)&&i(l),A(Q)}else i(l);d=t(l)}if(d!==null)var se=!0;else{var _e=t(h);_e!==null&&fe(M,_e.startTime-Q),se=!1}return se}finally{d=null,p=Y,g=!1}}var T=!1,R=null,D=-1,b=5,I=-1;function O(){return!(n.unstable_now()-IH||125re?(H.sortIndex=Y,e(h,H),t(l)===null&&H===t(h)&&(S?(m(D),D=-1):S=!0,fe(M,Y-re))):(H.sortIndex=ue,e(l,H),_||g||(_=!0,ie(C))),H},n.unstable_shouldYield=O,n.unstable_wrapCallback=function(H){var Q=p;return function(){var Y=p;p=Q;try{return H.apply(this,arguments)}finally{p=Y}}}})(Kw);Yw.exports=Kw;var $P=Yw.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 Zw=ee,gr=$P;function Ie(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"),r_=Object.prototype.hasOwnProperty,eI=/^[: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]*$/,wE={},TE={};function tI(n){return r_.call(TE,n)?!0:r_.call(wE,n)?!1:eI.test(n)?TE[n]=!0:(wE[n]=!0,!1)}function nI(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 iI(n,e,t,i){if(e===null||typeof e>"u"||nI(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 Hi(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 mi={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){mi[n]=new Hi(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];mi[e]=new Hi(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){mi[n]=new Hi(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){mi[n]=new Hi(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){mi[n]=new Hi(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){mi[n]=new Hi(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){mi[n]=new Hi(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){mi[n]=new Hi(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){mi[n]=new Hi(n,5,!1,n.toLowerCase(),null,!1,!1)});var qy=/[\-:]([a-z])/g;function $y(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(qy,$y);mi[e]=new Hi(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(qy,$y);mi[e]=new Hi(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(qy,$y);mi[e]=new Hi(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){mi[n]=new Hi(n,1,!1,n.toLowerCase(),null,!1,!1)});mi.xlinkHref=new Hi("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){mi[n]=new Hi(n,1,!1,n.toLowerCase(),null,!0,!0)});function ex(n,e,t,i){var r=mi.hasOwnProperty(e)?mi[e]:null;(r!==null?r.type!==0:i||!(2a||r[o]!==s[a]){var l=` `+r[o].replace(" at new "," at ");return n.displayName&&l.includes("")&&(l=l.replace("",n.displayName)),l}while(1<=o&&0<=a);break}}}finally{Tv=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?$u(n):""}function rI(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=Cv(n.type,!1),n;case 11:return n=Cv(n.type.render,!1),n;case 1:return n=Cv(n.type,!0),n;default:return""}}function l_(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 sc:return"Fragment";case rc:return"Portal";case s_:return"Profiler";case tx:return"StrictMode";case o_:return"Suspense";case a_:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case qw:return(n.displayName||"Context")+".Consumer";case jw:return(n._context.displayName||"Context")+".Provider";case nx:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case ix:return e=n.displayName||null,e!==null?e:l_(n.type)||"Memo";case Ro:e=n._payload,n=n._init;try{return l_(n(e))}catch{}}return null}function sI(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 l_(e);case 8:return e===tx?"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 Zo(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function eT(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function oI(n){var e=eT(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 dd(n){n._valueTracker||(n._valueTracker=oI(n))}function tT(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),i="";return n&&(i=eT(n)?n.checked?"true":"false":n.value),n=i,n!==t?(e.setValue(n),!0):!1}function Qp(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 c_(n,e){var t=e.checked;return bn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function RE(n,e){var t=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;t=Zo(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 nT(n,e){e=e.checked,e!=null&&ex(n,"checked",e,!1)}function u_(n,e){nT(n,e);var t=Zo(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")?h_(n,e.type,t):e.hasOwnProperty("defaultValue")&&h_(n,e.type,Zo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function bE(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 h_(n,e,t){(e!=="number"||Qp(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var eh=Array.isArray;function Ac(n,e,t,i){if(n=n.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=pd.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function xh(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var rh={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},aI=["Webkit","ms","Moz","O"];Object.keys(rh).forEach(function(n){aI.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),rh[e]=rh[n]})});function oT(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||rh.hasOwnProperty(n)&&rh[n]?(""+e).trim():e+"px"}function aT(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var i=t.indexOf("--")===0,r=oT(t,e[t],i);t==="float"&&(t="cssFloat"),i?n.setProperty(t,r):n[t]=r}}var lI=bn({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 p_(n,e){if(e){if(lI[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Ie(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Ie(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Ie(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Ie(62))}}function m_(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 g_=null;function rx(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var v_=null,Sc=null,Ec=null;function IE(n){if(n=tf(n)){if(typeof v_!="function")throw Error(Ie(280));var e=n.stateNode;e&&(e=Im(e),v_(n.stateNode,n.type,e))}}function lT(n){Sc?Ec?Ec.push(n):Ec=[n]:Sc=n}function cT(){if(Sc){var n=Sc,e=Ec;if(Ec=Sc=null,IE(n),e)for(n=0;n>>=0,n===0?32:31-(yI(n)/xI|0)|0}var md=64,gd=4194304;function th(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 em(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=th(a):(s&=o,s!==0&&(i=th(s)))}else o=t&~r,o!==0?i=th(o):s!==0&&(i=th(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 $h(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-ns(e),n[e]=t}function MI(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=oh),HE=" ",GE=!1;function bT(n,e){switch(n){case"keyup":return qI.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function BT(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var oc=!1;function eL(n,e){switch(n){case"compositionend":return BT(e);case"keypress":return e.which!==32?null:(GE=!0,HE);case"textInput":return n=e.data,n===HE&&GE?null:n;default:return null}}function tL(n,e){if(oc)return n==="compositionend"||!fx&&bT(n,e)?(n=CT(),Ip=cx=Uo=null,oc=!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=JE(t)}}function DT(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?DT(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function UT(){for(var n=window,e=Qp();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=Qp(n.document)}return e}function dx(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 uL(n){var e=UT(),t=n.focusedElem,i=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&DT(t.ownerDocument.documentElement,t)){if(i!==null&&dx(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=YE(t,s);var o=YE(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,ac=null,E_=null,lh=null,M_=!1;function KE(n,e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;M_||ac==null||ac!==Qp(i)||(i=ac,"selectionStart"in i&&dx(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}),lh&&Th(lh,i)||(lh=i,i=im(E_,"onSelect"),0uc||(n.current=B_[uc],B_[uc]=null,uc--)}function dn(n,e){uc++,B_[uc]=n.current,n.current=e}var Qo={},Ri=na(Qo),$i=na(!1),$a=Qo;function Pc(n,e){var t=n.type.contextTypes;if(!t)return Qo;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 er(n){return n=n.childContextTypes,n!=null}function sm(){vn($i),vn(Ri)}function tM(n,e,t){if(Ri.current!==Qo)throw Error(Ie(168));dn(Ri,e),dn($i,t)}function WT(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(Ie(108,sI(n)||"Unknown",r));return bn({},t,i)}function om(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Qo,$a=Ri.current,dn(Ri,n),dn($i,$i.current),!0}function nM(n,e,t){var i=n.stateNode;if(!i)throw Error(Ie(169));t?(n=WT(n,e,$a),i.__reactInternalMemoizedMergedChildContext=n,vn($i),vn(Ri),dn(Ri,n)):vn($i),dn($i,t)}var Js=null,Lm=!1,Hv=!1;function XT(n){Js===null?Js=[n]:Js.push(n)}function SL(n){Lm=!0,XT(n)}function ia(){if(!Hv&&Js!==null){Hv=!0;var n=0,e=an;try{var t=Js;for(an=1;n>=o,r-=o,Ks=1<<32-ns(e)+r|t<D?(b=R,R=null):b=R.sibling;var I=p(m,R,A[D],M);if(I===null){R===null&&(R=b);break}n&&R&&I.alternate===null&&e(m,R),x=s(I,x,D),T===null?C=I:T.sibling=I,T=I,R=b}if(D===A.length)return t(m,R),Sn&&Pa(m,D),C;if(R===null){for(;DD?(b=R,R=null):b=R.sibling;var O=p(m,R,I.value,M);if(O===null){R===null&&(R=b);break}n&&R&&O.alternate===null&&e(m,R),x=s(O,x,D),T===null?C=O:T.sibling=O,T=O,R=b}if(I.done)return t(m,R),Sn&&Pa(m,D),C;if(R===null){for(;!I.done;D++,I=A.next())I=d(m,I.value,M),I!==null&&(x=s(I,x,D),T===null?C=I:T.sibling=I,T=I);return Sn&&Pa(m,D),C}for(R=i(m,R);!I.done;D++,I=A.next())I=g(R,m,D,I.value,M),I!==null&&(n&&I.alternate!==null&&R.delete(I.key===null?D:I.key),x=s(I,x,D),T===null?C=I:T.sibling=I,T=I);return n&&R.forEach(function(j){return e(m,j)}),Sn&&Pa(m,D),C}function y(m,x,A,M){if(typeof A=="object"&&A!==null&&A.type===sc&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case fd:e:{for(var C=A.key,T=x;T!==null;){if(T.key===C){if(C=A.type,C===sc){if(T.tag===7){t(m,T.sibling),x=r(T,A.props.children),x.return=m,m=x;break e}}else if(T.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Ro&&cM(C)===T.type){t(m,T.sibling),x=r(T,A.props),x.ref=Bu(m,T,A),x.return=m,m=x;break e}t(m,T);break}else e(m,T);T=T.sibling}A.type===sc?(x=Ja(A.props.children,m.mode,M,A.key),x.return=m,m=x):(M=zp(A.type,A.key,A.props,null,m.mode,M),M.ref=Bu(m,x,A),M.return=m,m=M)}return o(m);case rc:e:{for(T=A.key;x!==null;){if(x.key===T)if(x.tag===4&&x.stateNode.containerInfo===A.containerInfo&&x.stateNode.implementation===A.implementation){t(m,x.sibling),x=r(x,A.children||[]),x.return=m,m=x;break e}else{t(m,x);break}else e(m,x);x=x.sibling}x=Zv(A,m.mode,M),x.return=m,m=x}return o(m);case Ro:return T=A._init,y(m,x,T(A._payload),M)}if(eh(A))return _(m,x,A,M);if(wu(A))return S(m,x,A,M);Ed(m,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,x!==null&&x.tag===6?(t(m,x.sibling),x=r(x,A),x.return=m,m=x):(t(m,x),x=Kv(A,m.mode,M),x.return=m,m=x),o(m)):t(m,x)}return y}var Lc=$T(!0),eC=$T(!1),nf={},Es=na(nf),Bh=na(nf),Ph=na(nf);function Na(n){if(n===nf)throw Error(Ie(174));return n}function Sx(n,e){switch(dn(Ph,e),dn(Bh,n),dn(Es,nf),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:d_(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=d_(e,n)}vn(Es),dn(Es,e)}function Dc(){vn(Es),vn(Bh),vn(Ph)}function tC(n){Na(Ph.current);var e=Na(Es.current),t=d_(e,n.type);e!==t&&(dn(Bh,n),dn(Es,t))}function Ex(n){Bh.current===n&&(vn(Es),vn(Bh))}var Tn=na(0);function fm(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var Gv=[];function Mx(){for(var n=0;nt?t:4,n(!0);var i=Vv.transition;Vv.transition={};try{n(!1),e()}finally{an=t,Vv.transition=i}}function vC(){return Hr().memoizedState}function TL(n,e,t){var i=Wo(n);if(t={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null},_C(n))yC(e,t);else if(t=ZT(n,e,t,i),t!==null){var r=Oi();is(t,n,i,r),xC(t,e,i)}}function CL(n,e,t){var i=Wo(n),r={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null};if(_C(n))yC(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,rs(a,o)){var l=e.interleaved;l===null?(r.next=r,xx(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}t=ZT(n,e,r,i),t!==null&&(r=Oi(),is(t,n,i,r),xC(t,e,i))}}function _C(n){var e=n.alternate;return n===Rn||e!==null&&e===Rn}function yC(n,e){ch=dm=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function xC(n,e,t){if(t&4194240){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,ox(n,t)}}var pm={readContext:zr,useCallback:xi,useContext:xi,useEffect:xi,useImperativeHandle:xi,useInsertionEffect:xi,useLayoutEffect:xi,useMemo:xi,useReducer:xi,useRef:xi,useState:xi,useDebugValue:xi,useDeferredValue:xi,useTransition:xi,useMutableSource:xi,useSyncExternalStore:xi,useId:xi,unstable_isNewReconciler:!1},RL={readContext:zr,useCallback:function(n,e){return xs().memoizedState=[n,e===void 0?null:e],n},useContext:zr,useEffect:hM,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,Fp(4194308,4,fC.bind(null,e,n),t)},useLayoutEffect:function(n,e){return Fp(4194308,4,n,e)},useInsertionEffect:function(n,e){return Fp(4,2,n,e)},useMemo:function(n,e){var t=xs();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var i=xs();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=TL.bind(null,Rn,n),[i.memoizedState,n]},useRef:function(n){var e=xs();return n={current:n},e.memoizedState=n},useState:uM,useDebugValue:bx,useDeferredValue:function(n){return xs().memoizedState=n},useTransition:function(){var n=uM(!1),e=n[0];return n=wL.bind(null,n[1]),xs().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var i=Rn,r=xs();if(Sn){if(t===void 0)throw Error(Ie(407));t=t()}else{if(t=e(),ci===null)throw Error(Ie(349));tl&30||rC(i,e,t)}r.memoizedState=t;var s={value:t,getSnapshot:e};return r.queue=s,hM(oC.bind(null,i,s,n),[n]),i.flags|=2048,Dh(9,sC.bind(null,i,s,t,e),void 0,null),t},useId:function(){var n=xs(),e=ci.identifierPrefix;if(Sn){var t=Zs,i=Ks;t=(i&~(1<<32-ns(i)-1)).toString(32)+t,e=":"+e+"R"+t,t=Ih++,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[As]=e,n[bh]=i,bC(n,e,!1,!1),e.stateNode=n;e:{switch(o=m_(t,i),t){case"dialog":pn("cancel",n),pn("close",n),r=i;break;case"iframe":case"object":case"embed":pn("load",n),r=i;break;case"video":case"audio":for(r=0;rFc&&(e.flags|=128,i=!0,Pu(s,!1),e.lanes=4194304)}else{if(!i)if(n=fm(o),n!==null){if(e.flags|=128,i=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Pu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Sn)return Ai(e),null}else 2*Nn()-s.renderingStartTime>Fc&&t!==1073741824&&(e.flags|=128,i=!0,Pu(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=Nn(),e.sibling=null,t=Tn.current,dn(Tn,i?t&1|2:t&1),e):(Ai(e),null);case 22:case 23:return Ux(),i=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?cr&1073741824&&(Ai(e),e.subtreeFlags&6&&(e.flags|=8192)):Ai(e),null;case 24:return null;case 25:return null}throw Error(Ie(156,e.tag))}function FL(n,e){switch(mx(e),e.tag){case 1:return er(e.type)&&sm(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return Dc(),vn($i),vn(Ri),Mx(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Ex(e),null;case 13:if(vn(Tn),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(Ie(340));Ic()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return vn(Tn),null;case 4:return Dc(),null;case 10:return yx(e.type._context),null;case 22:case 23:return Ux(),null;case 24:return null;default:return null}}var wd=!1,wi=!1,OL=typeof WeakSet=="function"?WeakSet:Set,je=null;function pc(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(i){Ln(n,e,i)}else t.current=null}function G_(n,e,t){try{t()}catch(i){Ln(n,e,i)}}var xM=!1;function NL(n,e){if(w_=tm,n=UT(),dx(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,l=-1,h=0,f=0,d=n,p=null;t:for(;;){for(var g;d!==t||r!==0&&d.nodeType!==3||(a=o+r),d!==s||i!==0&&d.nodeType!==3||(l=o+i),d.nodeType===3&&(o+=d.nodeValue.length),(g=d.firstChild)!==null;)p=d,d=g;for(;;){if(d===n)break t;if(p===t&&++h===r&&(a=o),p===s&&++f===i&&(l=o),(g=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=g}t=a===-1||l===-1?null:{start:a,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(T_={focusedElem:n,selectionRange:t},tm=!1,je=e;je!==null;)if(e=je,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,je=n;else for(;je!==null;){e=je;try{var _=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var S=_.memoizedProps,y=_.memoizedState,m=e.stateNode,x=m.getSnapshotBeforeUpdate(e.elementType===e.type?S:Qr(e.type,S),y);m.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var A=e.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ie(163))}}catch(M){Ln(e,e.return,M)}if(n=e.sibling,n!==null){n.return=e.return,je=n;break}je=e.return}return _=xM,xM=!1,_}function uh(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&&G_(e,t,s)}r=r.next}while(r!==i)}}function Fm(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 V_(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 IC(n){var e=n.alternate;e!==null&&(n.alternate=null,IC(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[As],delete e[bh],delete e[b_],delete e[xL],delete e[AL])),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 LC(n){return n.tag===5||n.tag===3||n.tag===4}function AM(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||LC(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 W_(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=rm));else if(i!==4&&(n=n.child,n!==null))for(W_(n,e,t),n=n.sibling;n!==null;)W_(n,e,t),n=n.sibling}function X_(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(X_(n,e,t),n=n.sibling;n!==null;)X_(n,e,t),n=n.sibling}var hi=null,qr=!1;function vo(n,e,t){for(t=t.child;t!==null;)DC(n,e,t),t=t.sibling}function DC(n,e,t){if(Ss&&typeof Ss.onCommitFiberUnmount=="function")try{Ss.onCommitFiberUnmount(Rm,t)}catch{}switch(t.tag){case 5:wi||pc(t,e);case 6:var i=hi,r=qr;hi=null,vo(n,e,t),hi=i,qr=r,hi!==null&&(qr?(n=hi,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):hi.removeChild(t.stateNode));break;case 18:hi!==null&&(qr?(n=hi,t=t.stateNode,n.nodeType===8?zv(n.parentNode,t):n.nodeType===1&&zv(n,t),Mh(n)):zv(hi,t.stateNode));break;case 4:i=hi,r=qr,hi=t.stateNode.containerInfo,qr=!0,vo(n,e,t),hi=i,qr=r;break;case 0:case 11:case 14:case 15:if(!wi&&(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)&&G_(t,e,o),r=r.next}while(r!==i)}vo(n,e,t);break;case 1:if(!wi&&(pc(t,e),i=t.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=t.memoizedProps,i.state=t.memoizedState,i.componentWillUnmount()}catch(a){Ln(t,e,a)}vo(n,e,t);break;case 21:vo(n,e,t);break;case 22:t.mode&1?(wi=(i=wi)||t.memoizedState!==null,vo(n,e,t),wi=i):vo(n,e,t);break;default:vo(n,e,t)}}function SM(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new OL),e.forEach(function(i){var r=YL.bind(null,n,i);t.has(i)||(t.add(i),i.then(r,r))})}}function Wr(n,e){var t=e.deletions;if(t!==null)for(var i=0;ir&&(r=o),i&=~s}if(i=r,i=Nn()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*zL(i/1960))-i,10n?16:n,Fo===null)var i=!1;else{if(n=Fo,Fo=null,vm=0,Kt&6)throw Error(Ie(331));var r=Kt;for(Kt|=4,je=n.current;je!==null;){var s=je,o=s.child;if(je.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lNn()-Lx?Xa(n,0):Ix|=t),tr(n,e)}function GC(n,e){e===0&&(n.mode&1?(e=gd,gd<<=1,!(gd&130023424)&&(gd=4194304)):e=1);var t=Oi();n=io(n,e),n!==null&&($h(n,e,t),tr(n,t))}function JL(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),GC(n,t)}function YL(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(Ie(314))}i!==null&&i.delete(e),GC(n,t)}var VC;VC=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||$i.current)qi=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return qi=!1,DL(n,e,t);qi=!!(n.flags&131072)}else qi=!1,Sn&&e.flags&1048576&&JT(e,lm,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;Op(n,e),n=e.pendingProps;var r=Pc(e,Ri.current);wc(e,t),r=Tx(null,e,i,n,r,t);var s=Cx();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,er(i)?(s=!0,om(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,Ax(e),r.updater=Dm,e.stateNode=r,r._reactInternals=e,U_(e,i,n,t),e=N_(null,e,i,!0,s,t)):(e.tag=0,Sn&&s&&px(e),Fi(null,e,r,t),e=e.child),e;case 16:i=e.elementType;e:{switch(Op(n,e),n=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=ZL(i),n=Qr(i,n),r){case 0:e=O_(null,e,i,n,t);break e;case 1:e=vM(null,e,i,n,t);break e;case 11:e=mM(null,e,i,n,t);break e;case 14:e=gM(null,e,i,Qr(i.type,n),t);break e}throw Error(Ie(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Qr(i,r),O_(n,e,i,r,t);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Qr(i,r),vM(n,e,i,r,t);case 3:e:{if(TC(e),n===null)throw Error(Ie(387));i=e.pendingProps,s=e.memoizedState,r=s.element,QT(n,e),hm(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=Uc(Error(Ie(423)),e),e=_M(n,e,i,t,r);break e}else if(i!==r){r=Uc(Error(Ie(424)),e),e=_M(n,e,i,t,r);break e}else for(hr=Ho(e.stateNode.containerInfo.firstChild),pr=e,Sn=!0,$r=null,t=eC(e,null,i,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(Ic(),i===r){e=ro(n,e,t);break e}Fi(n,e,i,t)}e=e.child}return e;case 5:return tC(e),n===null&&I_(e),i=e.type,r=e.pendingProps,s=n!==null?n.memoizedProps:null,o=r.children,C_(i,r)?o=null:s!==null&&C_(i,s)&&(e.flags|=32),wC(n,e),Fi(n,e,o,t),e.child;case 6:return n===null&&I_(e),null;case 13:return CC(n,e,t);case 4:return Sx(e,e.stateNode.containerInfo),i=e.pendingProps,n===null?e.child=Lc(e,null,i,t):Fi(n,e,i,t),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Qr(i,r),mM(n,e,i,r,t);case 7:return Fi(n,e,e.pendingProps,t),e.child;case 8:return Fi(n,e,e.pendingProps.children,t),e.child;case 12:return Fi(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,dn(cm,i._currentValue),i._currentValue=o,s!==null)if(rs(s.value,o)){if(s.children===r.children&&!$i.current){e=ro(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 l=a.firstContext;l!==null;){if(l.context===i){if(s.tag===1){l=$s(-1,t&-t),l.tag=2;var h=s.updateQueue;if(h!==null){h=h.shared;var f=h.pending;f===null?l.next=l:(l.next=f.next,f.next=l),h.pending=l}}s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),L_(s.return,t,e),a.lanes|=t;break}l=l.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(Ie(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),L_(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}Fi(n,e,r.children,t),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,wc(e,t),r=zr(r),i=i(r),e.flags|=1,Fi(n,e,i,t),e.child;case 14:return i=e.type,r=Qr(i,e.pendingProps),r=Qr(i.type,r),gM(n,e,i,r,t);case 15:return EC(n,e,e.type,e.pendingProps,t);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Qr(i,r),Op(n,e),e.tag=1,er(i)?(n=!0,om(e)):n=!1,wc(e,t),qT(e,i,r),U_(e,i,r,t),N_(null,e,i,!0,n,t);case 19:return RC(n,e,t);case 22:return MC(n,e,t)}throw Error(Ie(156,e.tag))};function WC(n,e){return gT(n,e)}function KL(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 Nr(n,e,t,i){return new KL(n,e,t,i)}function Ox(n){return n=n.prototype,!(!n||!n.isReactComponent)}function ZL(n){if(typeof n=="function")return Ox(n)?1:0;if(n!=null){if(n=n.$$typeof,n===nx)return 11;if(n===ix)return 14}return 2}function Xo(n,e){var t=n.alternate;return t===null?(t=Nr(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 zp(n,e,t,i,r,s){var o=2;if(i=n,typeof n=="function")Ox(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case sc:return Ja(t.children,r,s,e);case tx:o=8,r|=8;break;case s_:return n=Nr(12,t,e,r|2),n.elementType=s_,n.lanes=s,n;case o_:return n=Nr(13,t,e,r),n.elementType=o_,n.lanes=s,n;case a_:return n=Nr(19,t,e,r),n.elementType=a_,n.lanes=s,n;case $w:return Nm(t,r,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case jw:o=10;break e;case qw:o=9;break e;case nx:o=11;break e;case ix:o=14;break e;case Ro:o=16,i=null;break e}throw Error(Ie(130,n==null?n:typeof n,""))}return e=Nr(o,t,e,r),e.elementType=n,e.type=i,e.lanes=s,e}function Ja(n,e,t,i){return n=Nr(7,n,i,e),n.lanes=t,n}function Nm(n,e,t,i){return n=Nr(22,n,i,e),n.elementType=$w,n.lanes=t,n.stateNode={isHidden:!1},n}function Kv(n,e,t){return n=Nr(6,n,null,e),n.lanes=t,n}function Zv(n,e,t){return e=Nr(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function QL(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=bv(0),this.expirationTimes=bv(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=bv(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Nx(n,e,t,i,r,s,o,a,l){return n=new QL(n,e,t,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Nr(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:i,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ax(s),n}function jL(n,e,t){var i=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(KC)}catch(n){console.error(n)}}KC(),Jw.exports=_r;var n2=Jw.exports,BM=n2;i_.createRoot=BM.createRoot,i_.hydrateRoot=BM.hydrateRoot;/** * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT */const cl="160",i2={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},r2={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ZC=0,Q_=1,QC=2,s2=3,jC=0,Vm=1,dh=2,jr=3,Rs=0,Ni=1,Fr=2,o2=2,eo=0,Ya=1,j_=2,q_=3,$_=4,qC=5,Do=100,$C=101,eR=102,ey=103,ty=104,tR=200,nR=201,iR=202,rR=203,xm=204,Am=205,sR=206,oR=207,aR=208,lR=209,cR=210,uR=211,hR=212,fR=213,dR=214,pR=0,mR=1,gR=2,Fh=3,vR=4,_R=5,yR=6,xR=7,rf=0,AR=1,SR=2,Ms=0,ER=1,MR=2,wR=3,Gx=4,TR=5,CR=6,ny="attached",RR="detached",Wm=300,bs=301,jo=302,Oc=303,Oh=304,jc=306,qo=1e3,fi=1001,Nc=1002,An=1003,Nh=1004,a2=1004,Cc=1005,l2=1005,cn=1006,Xm=1007,c2=1007,Bs=1008,u2=1008,ws=1009,bR=1010,BR=1011,Jm=1012,Vx=1013,Qs=1014,di=1015,Ci=1016,Wx=1017,Xx=1018,Jo=1020,PR=1021,Ti=1023,IR=1024,LR=1025,Yo=1026,rl=1027,Jx=1028,Yx=1029,DR=1030,Kx=1031,Zx=1033,Hp=33776,Gp=33777,Vp=33778,Wp=33779,iy=35840,ry=35841,sy=35842,oy=35843,Qx=36196,ay=37492,ly=37496,cy=37808,uy=37809,hy=37810,fy=37811,dy=37812,py=37813,my=37814,gy=37815,vy=37816,_y=37817,yy=37818,xy=37819,Ay=37820,Sy=37821,Xp=36492,Ey=36494,My=36495,UR=36283,wy=36284,Ty=36285,Cy=36286,FR=2200,OR=2201,NR=2202,kc=2300,sl=2301,Jp=2302,ka=2400,za=2401,kh=2402,Ym=2500,jx=2501,kR=0,qx=1,Sm=2,$x=3e3,Ko=3001,zR=3200,HR=3201,ra=0,GR=1,ur="",Qn="srgb",Ps="srgb-linear",Km="display-p3",sf="display-p3-linear",zh="linear",fn="srgb",Hh="rec709",Gh="p3",h2=0,La=7680,f2=7681,d2=7682,p2=7683,m2=34055,g2=34056,v2=5386,_2=512,y2=513,x2=514,A2=515,S2=516,E2=517,M2=518,Ry=519,VR=512,WR=513,XR=514,eA=515,JR=516,YR=517,KR=518,ZR=519,Vh=35044,w2=35048,T2=35040,C2=35045,R2=35049,b2=35041,B2=35046,P2=35050,I2=35042,L2="100",by="300 es",Em=1035,ts=2e3,zc=2001;let ao=class{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]+Si[n>>16&255]+Si[n>>24&255]+"-"+Si[e&255]+Si[e>>8&255]+"-"+Si[e>>16&15|64]+Si[e>>24&255]+"-"+Si[t&63|128]+Si[t>>8&255]+"-"+Si[t>>16&255]+Si[t>>24&255]+Si[i&255]+Si[i>>8&255]+Si[i>>16&255]+Si[i>>24&255]).toLowerCase()}function Dn(n,e,t){return Math.max(e,Math.min(t,n))}function tA(n,e){return(n%e+e)%e}function D2(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function U2(n,e,t){return n!==e?(t-n)/(e-n):0}function ph(n,e,t){return(1-t)*n+t*e}function F2(n,e,t,i){return ph(n,e,1-Math.exp(-t*i))}function O2(n,e=1){return e-Math.abs(tA(n,e*2)-e)}function N2(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function k2(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function z2(n,e){return n+Math.floor(Math.random()*(e-n+1))}function H2(n,e){return n+Math.random()*(e-n)}function G2(n){return n*(.5-Math.random())}function V2(n){n!==void 0&&(PM=n);let e=PM+=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 W2(n){return n*Ka}function X2(n){return n*Hc}function By(n){return(n&n-1)===0&&n!==0}function J2(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Mm(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Y2(n,e,t,i,r){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),h=s((e+i)/2),f=o((e+i)/2),d=s((e-i)/2),p=o((e-i)/2),g=s((i-e)/2),_=o((i-e)/2);switch(r){case"XYX":n.set(a*f,l*d,l*p,a*h);break;case"YZY":n.set(l*p,a*f,l*d,a*h);break;case"ZXZ":n.set(l*d,l*p,a*f,a*h);break;case"XZX":n.set(a*f,l*_,l*g,a*h);break;case"YXY":n.set(l*g,a*f,l*_,a*h);break;case"ZYZ":n.set(l*_,l*g,a*f,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ji(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 Dt(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 Za={DEG2RAD:Ka,RAD2DEG:Hc,generateUUID:mr,clamp:Dn,euclideanModulo:tA,mapLinear:D2,inverseLerp:U2,lerp:ph,damp:F2,pingpong:O2,smoothstep:N2,smootherstep:k2,randInt:z2,randFloat:H2,randFloatSpread:G2,seededRandom:V2,degToRad:W2,radToDeg:X2,isPowerOfTwo:By,ceilPowerOfTwo:J2,floorPowerOfTwo:Mm,setQuaternionFromProperEuler:Y2,normalize:Dt,denormalize:ji};class Se{constructor(e=0,t=0){Se.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 Ft{constructor(e,t,i,r,s,o,a,l,h){Ft.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,l,h)}set(e,t,i,r,s,o,a,l,h){const f=this.elements;return f[0]=e,f[1]=r,f[2]=a,f[3]=t,f[4]=s,f[5]=l,f[6]=i,f[7]=o,f[8]=h,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],l=i[6],h=i[1],f=i[4],d=i[7],p=i[2],g=i[5],_=i[8],S=r[0],y=r[3],m=r[6],x=r[1],A=r[4],M=r[7],C=r[2],T=r[5],R=r[8];return s[0]=o*S+a*x+l*C,s[3]=o*y+a*A+l*T,s[6]=o*m+a*M+l*R,s[1]=h*S+f*x+d*C,s[4]=h*y+f*A+d*T,s[7]=h*m+f*M+d*R,s[2]=p*S+g*x+_*C,s[5]=p*y+g*A+_*T,s[8]=p*m+g*M+_*R,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],l=e[6],h=e[7],f=e[8];return t*o*f-t*a*h-i*s*f+i*a*l+r*s*h-r*o*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],h=e[7],f=e[8],d=f*o-a*h,p=a*l-f*s,g=h*s-o*l,_=t*d+i*p+r*g;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/_;return e[0]=d*S,e[1]=(r*h-f*i)*S,e[2]=(a*i-r*o)*S,e[3]=p*S,e[4]=(f*t-r*l)*S,e[5]=(r*s-a*t)*S,e[6]=g*S,e[7]=(i*l-h*t)*S,e[8]=(o*t-i*s)*S,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){const l=Math.cos(s),h=Math.sin(s);return this.set(i*l,i*h,-i*(l*o+h*a)+o+e,-r*h,r*l,-r*(-h*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Qv.makeScale(e,t)),this}rotate(e){return this.premultiply(Qv.makeRotation(-e)),this}translate(e,t){return this.premultiply(Qv.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 Qv=new Ft;function QR(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const K2={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function gc(n,e){return new K2[n](e)}function Wh(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function jR(){const n=Wh("canvas");return n.style.display="block",n}const IM={};function mh(n){n in IM||(IM[n]=!0,console.warn(n))}const LM=new Ft().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),DM=new Ft().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Rd={[Ps]:{transfer:zh,primaries:Hh,toReference:n=>n,fromReference:n=>n},[Qn]:{transfer:fn,primaries:Hh,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[sf]:{transfer:zh,primaries:Gh,toReference:n=>n.applyMatrix3(DM),fromReference:n=>n.applyMatrix3(LM)},[Km]:{transfer:fn,primaries:Gh,toReference:n=>n.convertSRGBToLinear().applyMatrix3(DM),fromReference:n=>n.applyMatrix3(LM).convertLinearToSRGB()}},Z2=new Set([Ps,sf]),on={enabled:!0,_workingColorSpace:Ps,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!Z2.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=Rd[e].toReference,r=Rd[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 Rd[n].primaries},getTransfer:function(n){return n===ur?zh:Rd[n].transfer}};function Rc(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function jv(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Rl;class nA{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Rl===void 0&&(Rl=Wh("canvas")),Rl.width=e.width,Rl.height=e.height;const i=Rl.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Rl}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=Wh("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!==Wm)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case qo:e.x=e.x-Math.floor(e.x);break;case fi:e.x=e.x<0?0:1;break;case Nc: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 qo:e.y=e.y-Math.floor(e.y);break;case fi:e.y=e.y<0?0:1;break;case Nc: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 mh("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Qn?Ko:$x}set encoding(e){mh("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ko?Qn:ur}}_n.DEFAULT_IMAGE=null;_n.DEFAULT_MAPPING=Wm;_n.DEFAULT_ANISOTROPY=1;class rn{constructor(e=0,t=0,i=0,r=1){rn.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 l=e.elements,h=l[0],f=l[4],d=l[8],p=l[1],g=l[5],_=l[9],S=l[2],y=l[6],m=l[10];if(Math.abs(f-p)<.01&&Math.abs(d-S)<.01&&Math.abs(_-y)<.01){if(Math.abs(f+p)<.1&&Math.abs(d+S)<.1&&Math.abs(_+y)<.1&&Math.abs(h+g+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(h+1)/2,M=(g+1)/2,C=(m+1)/2,T=(f+p)/4,R=(d+S)/4,D=(_+y)/4;return A>M&&A>C?A<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(A),r=T/i,s=R/i):M>C?M<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(M),i=T/r,s=D/r):C<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(C),i=R/s,r=D/s),this.set(i,r,s,t),this}let x=Math.sqrt((y-_)*(y-_)+(d-S)*(d-S)+(p-f)*(p-f));return Math.abs(x)<.001&&(x=1),this.x=(y-_)/x,this.y=(d-S)/x,this.z=(p-f)/x,this.w=Math.acos((h+g+m-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 qR extends ao{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new rn(0,0,e,t),this.scissorTest=!1,this.viewport=new rn(0,0,e,t);const r={width:e,height:t,depth:1};i.encoding!==void 0&&(mh("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Ko?Qn:ur),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:cn,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new _n(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 Ha(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 ki extends qR{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class Zm extends _n{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=An,this.minFilter=An,this.wrapR=fi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class q2 extends ki{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Zm(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class iA extends _n{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=An,this.minFilter=An,this.wrapR=fi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class $2 extends ki{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new iA(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class eD extends ki{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,A=1-m*m;if(A>Number.EPSILON){const C=Math.sqrt(A),T=Math.atan2(C,m*x);y=Math.sin(y*T)/C,a=Math.sin(a*T)/C}const M=a*x;if(l=l*y+p*M,h=h*y+g*M,f=f*y+_*M,d=d*y+S*M,y===1-a){const C=1/Math.sqrt(l*l+h*h+f*f+d*d);l*=C,h*=C,f*=C,d*=C}}e[t]=l,e[t+1]=h,e[t+2]=f,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){const a=i[r],l=i[r+1],h=i[r+2],f=i[r+3],d=s[o],p=s[o+1],g=s[o+2],_=s[o+3];return e[t]=a*_+f*d+l*g-h*p,e[t+1]=l*_+f*p+h*d-a*g,e[t+2]=h*_+f*g+a*p-l*d,e[t+3]=f*_-a*d-l*p-h*g,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,l=Math.sin,h=a(i/2),f=a(r/2),d=a(s/2),p=l(i/2),g=l(r/2),_=l(s/2);switch(o){case"XYZ":this._x=p*f*d+h*g*_,this._y=h*g*d-p*f*_,this._z=h*f*_+p*g*d,this._w=h*f*d-p*g*_;break;case"YXZ":this._x=p*f*d+h*g*_,this._y=h*g*d-p*f*_,this._z=h*f*_-p*g*d,this._w=h*f*d+p*g*_;break;case"ZXY":this._x=p*f*d-h*g*_,this._y=h*g*d+p*f*_,this._z=h*f*_+p*g*d,this._w=h*f*d-p*g*_;break;case"ZYX":this._x=p*f*d-h*g*_,this._y=h*g*d+p*f*_,this._z=h*f*_-p*g*d,this._w=h*f*d+p*g*_;break;case"YZX":this._x=p*f*d+h*g*_,this._y=h*g*d+p*f*_,this._z=h*f*_-p*g*d,this._w=h*f*d-p*g*_;break;case"XZY":this._x=p*f*d-h*g*_,this._y=h*g*d-p*f*_,this._z=h*f*_+p*g*d,this._w=h*f*d+p*g*_;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],l=t[9],h=t[2],f=t[6],d=t[10],p=i+a+d;if(p>0){const g=.5/Math.sqrt(p+1);this._w=.25/g,this._x=(f-l)*g,this._y=(s-h)*g,this._z=(o-r)*g}else if(i>a&&i>d){const g=2*Math.sqrt(1+i-a-d);this._w=(f-l)/g,this._x=.25*g,this._y=(r+o)/g,this._z=(s+h)/g}else if(a>d){const g=2*Math.sqrt(1+a-i-d);this._w=(s-h)/g,this._x=(r+o)/g,this._y=.25*g,this._z=(l+f)/g}else{const g=2*Math.sqrt(1+d-i-a);this._w=(o-r)/g,this._x=(s+h)/g,this._y=(l+f)/g,this._z=.25*g}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,l=t._y,h=t._z,f=t._w;return this._x=i*f+o*a+r*h-s*l,this._y=r*f+o*l+s*a-i*h,this._z=s*f+o*h+i*l-r*a,this._w=o*f-i*a-r*l-s*h,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 l=1-a*a;if(l<=Number.EPSILON){const g=1-t;return this._w=g*o+t*this._w,this._x=g*i+t*this._x,this._y=g*r+t*this._y,this._z=g*s+t*this._z,this.normalize(),this}const h=Math.sqrt(l),f=Math.atan2(h,a),d=Math.sin((1-t)*f)/h,p=Math.sin(t*f)/h;return this._w=o*d+this._w*p,this._x=i*d+this._x*p,this._y=r*d+this._y*p,this._z=s*d+this._z*p,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 k{constructor(e=0,t=0,i=0){k.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(UM.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(UM.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,l=e.w,h=2*(o*r-a*i),f=2*(a*t-s*r),d=2*(s*i-o*t);return this.x=t+l*h+o*d-a*f,this.y=i+l*f+a*h-s*d,this.z=r+l*d+s*f-o*h,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,l=t.z;return this.x=r*l-s*a,this.y=s*o-i*l,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 $v.copy(this).projectOnVector(e),this.sub($v)}reflect(e){return this.sub($v.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 $v=new k,UM=new Xn;class $n{constructor(e=new k(1/0,1/0,1/0),t=new k(-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,Xr),Xr.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(Lu),Bd.subVectors(this.max,Lu),bl.subVectors(e.a,Lu),Bl.subVectors(e.b,Lu),Pl.subVectors(e.c,Lu),_o.subVectors(Bl,bl),yo.subVectors(Pl,Bl),_a.subVectors(bl,Pl);let t=[0,-_o.z,_o.y,0,-yo.z,yo.y,0,-_a.z,_a.y,_o.z,0,-_o.x,yo.z,0,-yo.x,_a.z,0,-_a.x,-_o.y,_o.x,0,-yo.y,yo.x,0,-_a.y,_a.x,0];return!e0(t,bl,Bl,Pl,Bd)||(t=[1,0,0,0,1,0,0,0,1],!e0(t,bl,Bl,Pl,Bd))?!1:(Pd.crossVectors(_o,yo),t=[Pd.x,Pd.y,Pd.z],e0(t,bl,Bl,Pl,Bd))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xr).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:(ks[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ks[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ks[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ks[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ks[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ks[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ks[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ks[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ks),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 ks=[new k,new k,new k,new k,new k,new k,new k,new k],Xr=new k,bd=new $n,bl=new k,Bl=new k,Pl=new k,_o=new k,yo=new k,_a=new k,Lu=new k,Bd=new k,Pd=new k,ya=new k;function e0(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){ya.fromArray(n,s);const a=r.x*Math.abs(ya.x)+r.y*Math.abs(ya.y)+r.z*Math.abs(ya.z),l=e.dot(ya),h=t.dot(ya),f=i.dot(ya);if(Math.max(-Math.max(l,h,f),Math.min(l,h,f))>a)return!1}return!0}const tD=new $n,Du=new k,t0=new k;class ei{constructor(e=new k,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):tD.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;Du.subVectors(e,this.center);const t=Du.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Du,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):(t0.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Du.copy(e.center).add(t0)),this.expandByPoint(Du.copy(e.center).sub(t0))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const zs=new k,n0=new k,Id=new k,xo=new k,i0=new k,Ld=new k,r0=new k;class qc{constructor(e=new k,t=new k(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,zs)),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=zs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(zs.copy(this.origin).addScaledVector(this.direction,t),zs.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){n0.copy(e).add(t).multiplyScalar(.5),Id.copy(t).sub(e).normalize(),xo.copy(this.origin).sub(n0);const s=e.distanceTo(t)*.5,o=-this.direction.dot(Id),a=xo.dot(this.direction),l=-xo.dot(Id),h=xo.lengthSq(),f=Math.abs(1-o*o);let d,p,g,_;if(f>0)if(d=o*l-a,p=o*a-l,_=s*f,d>=0)if(p>=-_)if(p<=_){const S=1/f;d*=S,p*=S,g=d*(d+o*p+2*a)+p*(o*d+p+2*l)+h}else p=s,d=Math.max(0,-(o*p+a)),g=-d*d+p*(p+2*l)+h;else p=-s,d=Math.max(0,-(o*p+a)),g=-d*d+p*(p+2*l)+h;else p<=-_?(d=Math.max(0,-(-o*s+a)),p=d>0?-s:Math.min(Math.max(-s,-l),s),g=-d*d+p*(p+2*l)+h):p<=_?(d=0,p=Math.min(Math.max(-s,-l),s),g=p*(p+2*l)+h):(d=Math.max(0,-(o*s+a)),p=d>0?s:Math.min(Math.max(-s,-l),s),g=-d*d+p*(p+2*l)+h);else p=o>0?-s:s,d=Math.max(0,-(o*p+a)),g=-d*d+p*(p+2*l)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(n0).addScaledVector(Id,p),g}intersectSphere(e,t){zs.subVectors(e.center,this.origin);const i=zs.dot(this.direction),r=zs.dot(zs)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=i-o,l=i+o;return l<0?null:a<0?this.at(l,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,l;const h=1/this.direction.x,f=1/this.direction.y,d=1/this.direction.z,p=this.origin;return h>=0?(i=(e.min.x-p.x)*h,r=(e.max.x-p.x)*h):(i=(e.max.x-p.x)*h,r=(e.min.x-p.x)*h),f>=0?(s=(e.min.y-p.y)*f,o=(e.max.y-p.y)*f):(s=(e.max.y-p.y)*f,o=(e.min.y-p.y)*f),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o=0?(a=(e.min.z-p.z)*d,l=(e.max.z-p.z)*d):(a=(e.max.z-p.z)*d,l=(e.min.z-p.z)*d),i>l||a>r)||((a>i||i!==i)&&(i=a),(l=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,zs)!==null}intersectTriangle(e,t,i,r,s){i0.subVectors(t,e),Ld.subVectors(i,e),r0.crossVectors(i0,Ld);let o=this.direction.dot(r0),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;xo.subVectors(this.origin,e);const l=a*this.direction.dot(Ld.crossVectors(xo,Ld));if(l<0)return null;const h=a*this.direction.dot(i0.cross(xo));if(h<0||l+h>o)return null;const f=-a*xo.dot(r0);return f<0?null:this.at(f/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 lt{constructor(e,t,i,r,s,o,a,l,h,f,d,p,g,_,S,y){lt.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,l,h,f,d,p,g,_,S,y)}set(e,t,i,r,s,o,a,l,h,f,d,p,g,_,S,y){const m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=s,m[5]=o,m[9]=a,m[13]=l,m[2]=h,m[6]=f,m[10]=d,m[14]=p,m[3]=g,m[7]=_,m[11]=S,m[15]=y,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 lt().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/Il.setFromMatrixColumn(e,0).length(),s=1/Il.setFromMatrixColumn(e,1).length(),o=1/Il.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),l=Math.cos(r),h=Math.sin(r),f=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const p=o*f,g=o*d,_=a*f,S=a*d;t[0]=l*f,t[4]=-l*d,t[8]=h,t[1]=g+_*h,t[5]=p-S*h,t[9]=-a*l,t[2]=S-p*h,t[6]=_+g*h,t[10]=o*l}else if(e.order==="YXZ"){const p=l*f,g=l*d,_=h*f,S=h*d;t[0]=p+S*a,t[4]=_*a-g,t[8]=o*h,t[1]=o*d,t[5]=o*f,t[9]=-a,t[2]=g*a-_,t[6]=S+p*a,t[10]=o*l}else if(e.order==="ZXY"){const p=l*f,g=l*d,_=h*f,S=h*d;t[0]=p-S*a,t[4]=-o*d,t[8]=_+g*a,t[1]=g+_*a,t[5]=o*f,t[9]=S-p*a,t[2]=-o*h,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const p=o*f,g=o*d,_=a*f,S=a*d;t[0]=l*f,t[4]=_*h-g,t[8]=p*h+S,t[1]=l*d,t[5]=S*h+p,t[9]=g*h-_,t[2]=-h,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const p=o*l,g=o*h,_=a*l,S=a*h;t[0]=l*f,t[4]=S-p*d,t[8]=_*d+g,t[1]=d,t[5]=o*f,t[9]=-a*f,t[2]=-h*f,t[6]=g*d+_,t[10]=p-S*d}else if(e.order==="XZY"){const p=o*l,g=o*h,_=a*l,S=a*h;t[0]=l*f,t[4]=-d,t[8]=h*f,t[1]=p*d+S,t[5]=o*f,t[9]=g*d-_,t[2]=_*d-g,t[6]=a*f,t[10]=S*d+p}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(nD,e,iD)}lookAt(e,t,i){const r=this.elements;return ar.subVectors(e,t),ar.lengthSq()===0&&(ar.z=1),ar.normalize(),Ao.crossVectors(i,ar),Ao.lengthSq()===0&&(Math.abs(i.z)===1?ar.x+=1e-4:ar.z+=1e-4,ar.normalize(),Ao.crossVectors(i,ar)),Ao.normalize(),Dd.crossVectors(ar,Ao),r[0]=Ao.x,r[4]=Dd.x,r[8]=ar.x,r[1]=Ao.y,r[5]=Dd.y,r[9]=ar.y,r[2]=Ao.z,r[6]=Dd.z,r[10]=ar.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],l=i[8],h=i[12],f=i[1],d=i[5],p=i[9],g=i[13],_=i[2],S=i[6],y=i[10],m=i[14],x=i[3],A=i[7],M=i[11],C=i[15],T=r[0],R=r[4],D=r[8],b=r[12],I=r[1],O=r[5],j=r[9],ae=r[13],W=r[2],$=r[6],ie=r[10],fe=r[14],H=r[3],Q=r[7],Y=r[11],re=r[15];return s[0]=o*T+a*I+l*W+h*H,s[4]=o*R+a*O+l*$+h*Q,s[8]=o*D+a*j+l*ie+h*Y,s[12]=o*b+a*ae+l*fe+h*re,s[1]=f*T+d*I+p*W+g*H,s[5]=f*R+d*O+p*$+g*Q,s[9]=f*D+d*j+p*ie+g*Y,s[13]=f*b+d*ae+p*fe+g*re,s[2]=_*T+S*I+y*W+m*H,s[6]=_*R+S*O+y*$+m*Q,s[10]=_*D+S*j+y*ie+m*Y,s[14]=_*b+S*ae+y*fe+m*re,s[3]=x*T+A*I+M*W+C*H,s[7]=x*R+A*O+M*$+C*Q,s[11]=x*D+A*j+M*ie+C*Y,s[15]=x*b+A*ae+M*fe+C*re,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],l=e[9],h=e[13],f=e[2],d=e[6],p=e[10],g=e[14],_=e[3],S=e[7],y=e[11],m=e[15];return _*(+s*l*d-r*h*d-s*a*p+i*h*p+r*a*g-i*l*g)+S*(+t*l*g-t*h*p+s*o*p-r*o*g+r*h*f-s*l*f)+y*(+t*h*d-t*a*g-s*o*d+i*o*g+s*a*f-i*h*f)+m*(-r*a*f-t*l*d+t*a*p+r*o*d-i*o*p+i*l*f)}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],l=e[6],h=e[7],f=e[8],d=e[9],p=e[10],g=e[11],_=e[12],S=e[13],y=e[14],m=e[15],x=d*y*h-S*p*h+S*l*g-a*y*g-d*l*m+a*p*m,A=_*p*h-f*y*h-_*l*g+o*y*g+f*l*m-o*p*m,M=f*S*h-_*d*h+_*a*g-o*S*g-f*a*m+o*d*m,C=_*d*l-f*S*l-_*a*p+o*S*p+f*a*y-o*d*y,T=t*x+i*A+r*M+s*C;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/T;return e[0]=x*R,e[1]=(S*p*s-d*y*s-S*r*g+i*y*g+d*r*m-i*p*m)*R,e[2]=(a*y*s-S*l*s+S*r*h-i*y*h-a*r*m+i*l*m)*R,e[3]=(d*l*s-a*p*s-d*r*h+i*p*h+a*r*g-i*l*g)*R,e[4]=A*R,e[5]=(f*y*s-_*p*s+_*r*g-t*y*g-f*r*m+t*p*m)*R,e[6]=(_*l*s-o*y*s-_*r*h+t*y*h+o*r*m-t*l*m)*R,e[7]=(o*p*s-f*l*s+f*r*h-t*p*h-o*r*g+t*l*g)*R,e[8]=M*R,e[9]=(_*d*s-f*S*s-_*i*g+t*S*g+f*i*m-t*d*m)*R,e[10]=(o*S*s-_*a*s+_*i*h-t*S*h-o*i*m+t*a*m)*R,e[11]=(f*a*s-o*d*s-f*i*h+t*d*h+o*i*g-t*a*g)*R,e[12]=C*R,e[13]=(f*S*r-_*d*r+_*i*p-t*S*p-f*i*y+t*d*y)*R,e[14]=(_*a*r-o*S*r-_*i*l+t*S*l+o*i*y-t*a*y)*R,e[15]=(o*d*r-f*a*r+f*i*l-t*d*l-o*i*p+t*a*p)*R,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,l=e.z,h=s*o,f=s*a;return this.set(h*o+i,h*a-r*l,h*l+r*a,0,h*a+r*l,f*a+i,f*l-r*o,0,h*l-r*a,f*l+r*o,s*l*l+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,l=t._w,h=s+s,f=o+o,d=a+a,p=s*h,g=s*f,_=s*d,S=o*f,y=o*d,m=a*d,x=l*h,A=l*f,M=l*d,C=i.x,T=i.y,R=i.z;return r[0]=(1-(S+m))*C,r[1]=(g+M)*C,r[2]=(_-A)*C,r[3]=0,r[4]=(g-M)*T,r[5]=(1-(p+m))*T,r[6]=(y+x)*T,r[7]=0,r[8]=(_+A)*R,r[9]=(y-x)*R,r[10]=(1-(p+S))*R,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=Il.set(r[0],r[1],r[2]).length();const o=Il.set(r[4],r[5],r[6]).length(),a=Il.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],Jr.copy(this);const h=1/s,f=1/o,d=1/a;return Jr.elements[0]*=h,Jr.elements[1]*=h,Jr.elements[2]*=h,Jr.elements[4]*=f,Jr.elements[5]*=f,Jr.elements[6]*=f,Jr.elements[8]*=d,Jr.elements[9]*=d,Jr.elements[10]*=d,t.setFromRotationMatrix(Jr),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o,a=ts){const l=this.elements,h=2*s/(t-e),f=2*s/(i-r),d=(t+e)/(t-e),p=(i+r)/(i-r);let g,_;if(a===ts)g=-(o+s)/(o-s),_=-2*o*s/(o-s);else if(a===zc)g=-o/(o-s),_=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=f,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,s,o,a=ts){const l=this.elements,h=1/(t-e),f=1/(i-r),d=1/(o-s),p=(t+e)*h,g=(i+r)*f;let _,S;if(a===ts)_=(o+s)*d,S=-2*d;else if(a===zc)_=s*d,S=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-p,l[1]=0,l[5]=2*f,l[9]=0,l[13]=-g,l[2]=0,l[6]=0,l[10]=S,l[14]=-_,l[3]=0,l[7]=0,l[11]=0,l[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 Il=new k,Jr=new lt,nD=new k(0,0,0),iD=new k(1,1,1),Ao=new k,Dd=new k,ar=new k,FM=new lt,OM=new Xn;class of{constructor(e=0,t=0,i=0,r=of.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],l=r[1],h=r[5],f=r[9],d=r[2],p=r[6],g=r[10];switch(t){case"XYZ":this._y=Math.asin(Dn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-f,g),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Dn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(a,g),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Dn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-d,g),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Dn(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(p,g),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin(Dn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-f,h),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,g));break;case"XZY":this._z=Math.asin(-Dn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,h),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-f,g),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 FM.makeRotationFromQuaternion(e),this.setFromRotationMatrix(FM,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return OM.setFromEuler(this),this.setFromQuaternion(OM,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}}of.DEFAULT_ORDER="XYZ";class Qa{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,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let h=0,f=l.length;h0){r.children=[];for(let a=0;a0){r.animations=[];for(let a=0;a0&&(i.geometries=a),l.length>0&&(i.materials=l),h.length>0&&(i.textures=h),f.length>0&&(i.images=f),d.length>0&&(i.shapes=d),p.length>0&&(i.skeletons=p),g.length>0&&(i.animations=g),_.length>0&&(i.nodes=_)}return i.object=r,i;function o(a){const l=[];for(const h in a){const f=a[h];delete f.metadata,l.push(f)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){Yr.subVectors(r,t),Gs.subVectors(i,t),s0.subVectors(e,t);const o=Yr.dot(Yr),a=Yr.dot(Gs),l=Yr.dot(s0),h=Gs.dot(Gs),f=Gs.dot(s0),d=o*h-a*a;if(d===0)return s.set(0,0,0),null;const p=1/d,g=(h*l-a*f)*p,_=(o*f-a*l)*p;return s.set(1-g-_,_,g)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Vs)===null?!1:Vs.x>=0&&Vs.y>=0&&Vs.x+Vs.y<=1}static getUV(e,t,i,r,s,o,a,l){return Fd===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Fd=!0),this.getInterpolation(e,t,i,r,s,o,a,l)}static getInterpolation(e,t,i,r,s,o,a,l){return this.getBarycoord(e,t,i,r,Vs)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Vs.x),l.addScaledVector(o,Vs.y),l.addScaledVector(a,Vs.z),l)}static isFrontFacing(e,t,i,r){return Yr.subVectors(i,t),Gs.subVectors(e,t),Yr.cross(Gs).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 Yr.subVectors(this.c,this.b),Gs.subVectors(this.a,this.b),Yr.cross(Gs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Qi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Qi.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,s){return Fd===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Fd=!0),Qi.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}getInterpolation(e,t,i,r,s){return Qi.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return Qi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Qi.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;Dl.subVectors(r,i),Ul.subVectors(s,i),o0.subVectors(e,i);const l=Dl.dot(o0),h=Ul.dot(o0);if(l<=0&&h<=0)return t.copy(i);a0.subVectors(e,r);const f=Dl.dot(a0),d=Ul.dot(a0);if(f>=0&&d<=f)return t.copy(r);const p=l*d-f*h;if(p<=0&&l>=0&&f<=0)return o=l/(l-f),t.copy(i).addScaledVector(Dl,o);l0.subVectors(e,s);const g=Dl.dot(l0),_=Ul.dot(l0);if(_>=0&&g<=_)return t.copy(s);const S=g*h-l*_;if(S<=0&&h>=0&&_<=0)return a=h/(h-_),t.copy(i).addScaledVector(Ul,a);const y=f*_-g*d;if(y<=0&&d-f>=0&&g-_>=0)return GM.subVectors(s,r),a=(d-f)/(d-f+(g-_)),t.copy(r).addScaledVector(GM,a);const m=1/(y+S+p);return o=S*m,a=p*m,t.copy(i).addScaledVector(Dl,o).addScaledVector(Ul,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const $R={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},So={h:0,s:0,l:0},Od={h:0,s:0,l:0};function c0(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 Ne{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=Qn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,on.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=on.workingColorSpace){return this.r=e,this.g=t,this.b=i,on.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=on.workingColorSpace){if(e=tA(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=c0(o,s,e+1/3),this.g=c0(o,s,e),this.b=c0(o,s,e-1/3)}return on.toWorkingColorSpace(this,r),this}setStyle(e,t=Qn){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=Qn){const i=$R[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=Rc(e.r),this.g=Rc(e.g),this.b=Rc(e.b),this}copyLinearToSRGB(e){return this.r=jv(e.r),this.g=jv(e.g),this.b=jv(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Qn){return on.fromWorkingColorSpace(Ei.copy(this),e),Math.round(Dn(Ei.r*255,0,255))*65536+Math.round(Dn(Ei.g*255,0,255))*256+Math.round(Dn(Ei.b*255,0,255))}getHexString(e=Qn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=on.workingColorSpace){on.fromWorkingColorSpace(Ei.copy(this),t);const i=Ei.r,r=Ei.g,s=Ei.b,o=Math.max(i,r,s),a=Math.min(i,r,s);let l,h;const f=(a+o)/2;if(a===o)l=0,h=0;else{const d=o-a;switch(h=f<=.5?d/(o+a):d/(2-o-a),o){case i:l=(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!==Ya&&(i.blending=this.blending),this.side!==Rs&&(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!==xm&&(i.blendSrc=this.blendSrc),this.blendDst!==Am&&(i.blendDst=this.blendDst),this.blendEquation!==Do&&(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!==Fh&&(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!==Ry&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==La&&(i.stencilFail=this.stencilFail),this.stencilZFail!==La&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==La&&(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 l=s[a];delete l.metadata,o.push(l)}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 fr extends Jn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ne(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rf,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 Ys=uD();function uD(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const h=l-127;h<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):h<-14?(i[l]=1024>>-h-14,i[l|256]=1024>>-h-14|32768,r[l]=-h-1,r[l|256]=-h-1):h<=15?(i[l]=h+15<<10,i[l|256]=h+15<<10|32768,r[l]=13,r[l|256]=13):h<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,f=0;for(;!(h&8388608);)h<<=1,f-=8388608;h&=-8388609,f+=947912704,s[l]=h|f}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function Ki(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=Dn(n,-65504,65504),Ys.floatView[0]=n;const e=Ys.uint32View[0],t=e>>23&511;return Ys.baseTable[t]+((e&8388607)>>Ys.shiftTable[t])}function ih(n){const e=n>>10;return Ys.uint32View[0]=Ys.mantissaTable[Ys.offsetTable[e]+(n&1023)]+Ys.exponentTable[e],Ys.floatView[0]}const Ga={toHalfFloat:Ki,fromHalfFloat:ih},Gn=new k,Nd=new Se;class Yt{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=Vh,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=di,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 l=this.parameters;for(const h in l)l[h]!==void 0&&(e[h]=l[h]);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 l in i){const h=i[l];e.data.attributes[l]=h.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],f=[];for(let d=0,p=h.length;d0&&(r[l]=f,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 h in r){const f=r[h];this.setAttribute(h,f.clone(t))}const s=e.morphAttributes;for(const h in s){const f=[],d=s[h];for(let p=0,g=d.length;p0){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))&&(VM.copy(s).invert(),xa.copy(e.ray).applyMatrix4(VM),!(i.boundingBox!==null&&xa.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,xa)))}_computeIntersections(e,t,i){let r;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,h=s.attributes.uv,f=s.attributes.uv1,d=s.attributes.normal,p=s.groups,g=s.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,S=p.length;_t.far?null:{distance:h,point:Xd.clone(),object:n}}function Jd(n,e,t,i,r,s,o,a,l,h){n.getVertexPosition(a,Ol),n.getVertexPosition(l,Nl),n.getVertexPosition(h,kl);const f=yD(n,e,t,i,Ol,Nl,kl,Wd);if(f){r&&(Hd.fromBufferAttribute(r,a),Gd.fromBufferAttribute(r,l),Vd.fromBufferAttribute(r,h),f.uv=Qi.getInterpolation(Wd,Ol,Nl,kl,Hd,Gd,Vd,new Se)),s&&(Hd.fromBufferAttribute(s,a),Gd.fromBufferAttribute(s,l),Vd.fromBufferAttribute(s,h),f.uv1=Qi.getInterpolation(Wd,Ol,Nl,kl,Hd,Gd,Vd,new Se),f.uv2=f.uv1),o&&(XM.fromBufferAttribute(o,a),JM.fromBufferAttribute(o,l),YM.fromBufferAttribute(o,h),f.normal=Qi.getInterpolation(Wd,Ol,Nl,kl,XM,JM,YM,new k),f.normal.dot(i.direction)>0&&f.normal.multiplyScalar(-1));const d={a,b:l,c:h,normal:new k,materialIndex:0};Qi.getNormal(Ol,Nl,kl,d.normal),f.face=d}return f}class ul extends Tt{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 l=[],h=[],f=[],d=[];let p=0,g=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(l),this.setAttribute("position",new tt(h,3)),this.setAttribute("normal",new tt(f,3)),this.setAttribute("uv",new tt(d,2));function _(S,y,m,x,A,M,C,T,R,D,b){const I=M/R,O=C/D,j=M/2,ae=C/2,W=T/2,$=R+1,ie=D+1;let fe=0,H=0;const Q=new k;for(let Y=0;Y0?1:-1,f.push(Q.x,Q.y,Q.z),d.push(ue/R),d.push(1-Y/D),fe+=1}}for(let Y=0;Y0&&(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 af extends Jt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new lt,this.projectionMatrix=new lt,this.projectionMatrixInverse=new lt,this.coordinateSystem=ts}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 jn extends af{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=Hc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ka*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Hc*2*Math.atan(Math.tan(Ka*.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(Ka*.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 l=o.fullWidth,h=o.fullHeight;s+=o.offsetX*r/l,t-=o.offsetY*i/h,r*=o.width/l,i*=o.height/h}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 zl=-90,Hl=1;class tb extends Jt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new jn(zl,Hl,e,t);r.layers=this.layers,this.add(r);const s=new jn(zl,Hl,e,t);s.layers=this.layers,this.add(s);const o=new jn(zl,Hl,e,t);o.layers=this.layers,this.add(o);const a=new jn(zl,Hl,e,t);a.layers=this.layers,this.add(a);const l=new jn(zl,Hl,e,t);l.layers=this.layers,this.add(l);const h=new jn(zl,Hl,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,o,a,l]=t;for(const h of t)this.remove(h);if(e===ts)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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===zc)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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.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,l,h,f]=this.children,d=e.getRenderTarget(),p=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const S=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,l),e.setRenderTarget(i,4,r),e.render(t,h),i.texture.generateMipmaps=S,e.setRenderTarget(i,5,r),e.render(t,f),e.setRenderTarget(d,p,g),e.xr.enabled=_,i.texture.needsPMREMUpdate=!0}}class lf extends _n{constructor(e,t,i,r,s,o,a,l,h,f){e=e!==void 0?e:[],t=t!==void 0?t:bs,super(e,t,i,r,s,o,a,l,h,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class aA extends ki{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&&(mh("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Ko?Qn:ur),this.texture=new lf(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:cn}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 ul(5,5,5),s=new nr({name:"CubemapFromEquirect",uniforms:Gc(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ni,blending:eo});s.uniforms.tEquirect.value=t;const o=new Un(r,s),a=t.minFilter;return t.minFilter===Bs&&(t.minFilter=cn),new tb(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 f0=new k,ED=new k,MD=new Ft;class Bo{constructor(e=new k(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=f0.subVectors(i,t).cross(ED.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(f0),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||MD.getNormalMatrix(e),r=this.coplanarPoint(f0).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 Aa=new ei,Yd=new k;class cf{constructor(e=new Bo,t=new Bo,i=new Bo,r=new Bo,s=new Bo,o=new Bo){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=ts){const i=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],l=r[3],h=r[4],f=r[5],d=r[6],p=r[7],g=r[8],_=r[9],S=r[10],y=r[11],m=r[12],x=r[13],A=r[14],M=r[15];if(i[0].setComponents(l-s,p-h,y-g,M-m).normalize(),i[1].setComponents(l+s,p+h,y+g,M+m).normalize(),i[2].setComponents(l+o,p+f,y+_,M+x).normalize(),i[3].setComponents(l-o,p-f,y-_,M-x).normalize(),i[4].setComponents(l-a,p-d,y-S,M-A).normalize(),t===ts)i[5].setComponents(l+a,p+d,y+S,M+A).normalize();else if(t===zc)i[5].setComponents(a,d,S,A).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(),Aa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Aa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Aa)}intersectsSprite(e){return Aa.center.set(0,0,0),Aa.radius=.7071067811865476,Aa.applyMatrix4(e.matrixWorld),this.intersectsSphere(Aa)}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,Yd.y=r.normal.y>0?e.max.y:e.min.y,Yd.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Yd)<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 nb(){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 wD(n,e){const t=e.isWebGL2,i=new WeakMap;function r(h,f){const d=h.array,p=h.usage,g=d.byteLength,_=n.createBuffer();n.bindBuffer(f,_),n.bufferData(f,d,p),h.onUploadCallback();let S;if(d instanceof Float32Array)S=n.FLOAT;else if(d instanceof Uint16Array)if(h.isFloat16BufferAttribute)if(t)S=n.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else S=n.UNSIGNED_SHORT;else if(d instanceof Int16Array)S=n.SHORT;else if(d instanceof Uint32Array)S=n.UNSIGNED_INT;else if(d instanceof Int32Array)S=n.INT;else if(d instanceof Int8Array)S=n.BYTE;else if(d instanceof Uint8Array)S=n.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)S=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:_,type:S,bytesPerElement:d.BYTES_PER_ELEMENT,version:h.version,size:g}}function s(h,f,d){const p=f.array,g=f._updateRange,_=f.updateRanges;if(n.bindBuffer(d,h),g.count===-1&&_.length===0&&n.bufferSubData(d,0,p),_.length!==0){for(let S=0,y=_.length;S 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`,GD=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,VD=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,WD=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,XD=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,JD=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,YD=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,KD=`#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`,ZD=`#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`,QD=`#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`,jD=`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`,qD=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,$D=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,eU=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,tU=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,nU="gl_FragColor = linearToOutputTexel( gl_FragColor );",iU=` 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 ); }`,rU=`#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`,sU=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,oU=`#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`,aU=`#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`,lU=`#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`,cU=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,uU=`#ifdef USE_FOG varying float vFogDepth; #endif`,hU=`#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`,fU=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,dU=`#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 }`,pU=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,mU=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,gU=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,vU=`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`,_U=`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`,yU=`#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`,xU=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,AU=`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`,SU=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,EU=`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`,MU=`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`,wU=`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 ); }`,TU=` 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`,CU=`#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`,RU=`#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`,bU=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,BU=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,PU=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,IU=`#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`,LU=`#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`,DU=`#ifdef USE_MAP uniform sampler2D map; #endif`,UU=`#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`,FU=`#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`,OU=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,NU=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,kU=`#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`,zU=`#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`,HU=`#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`,GU=`#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`,VU=`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;`,WU=`#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`,XU=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,JU=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,YU=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,KU=`#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`,ZU=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,QU=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,jU=`#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`,qU=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,$U=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,e3=`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 ); }`,t3=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,n3=`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;`,i3=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,r3=`#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`,s3=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,o3=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,a3=`#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`,l3=`#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`,c3=`#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`,u3=`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; }`,h3=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,f3=`#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`,d3=`#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`,p3=`#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`,m3=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,g3=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,v3=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,_3=`#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; }`,y3=`#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`,x3=`#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`,A3=`#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`,S3=`#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`,E3=`#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`,M3=`#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 w3=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,T3=`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 }`,C3=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,R3=`#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 }`,b3=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,B3=`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 }`,P3=`#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; }`,I3=`#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 }`,L3=`#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; }`,D3=`#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 ); }`,U3=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,F3=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,O3=`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 }`,N3=`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 }`,k3=`#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 }`,z3=`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 }`,H3=`#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 }`,G3=`#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 }`,V3=`#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; }`,W3=`#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 }`,X3=`#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 }`,J3=`#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 }`,Y3=`#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 }`,K3=`#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 }`,Z3=`#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 }`,Q3=`#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 }`,j3=`#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 }`,q3=`#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 }`,$3=`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 }`,eF=`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 }`,tF=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,nF=`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 }`,iF=`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 }`,rF=`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 }`,Lt={alphahash_fragment:TD,alphahash_pars_fragment:CD,alphamap_fragment:RD,alphamap_pars_fragment:bD,alphatest_fragment:BD,alphatest_pars_fragment:PD,aomap_fragment:ID,aomap_pars_fragment:LD,batching_pars_vertex:DD,batching_vertex:UD,begin_vertex:FD,beginnormal_vertex:OD,bsdfs:ND,iridescence_fragment:kD,bumpmap_pars_fragment:zD,clipping_planes_fragment:HD,clipping_planes_pars_fragment:GD,clipping_planes_pars_vertex:VD,clipping_planes_vertex:WD,color_fragment:XD,color_pars_fragment:JD,color_pars_vertex:YD,color_vertex:KD,common:ZD,cube_uv_reflection_fragment:QD,defaultnormal_vertex:jD,displacementmap_pars_vertex:qD,displacementmap_vertex:$D,emissivemap_fragment:eU,emissivemap_pars_fragment:tU,colorspace_fragment:nU,colorspace_pars_fragment:iU,envmap_fragment:rU,envmap_common_pars_fragment:sU,envmap_pars_fragment:oU,envmap_pars_vertex:aU,envmap_physical_pars_fragment:yU,envmap_vertex:lU,fog_vertex:cU,fog_pars_vertex:uU,fog_fragment:hU,fog_pars_fragment:fU,gradientmap_pars_fragment:dU,lightmap_fragment:pU,lightmap_pars_fragment:mU,lights_lambert_fragment:gU,lights_lambert_pars_fragment:vU,lights_pars_begin:_U,lights_toon_fragment:xU,lights_toon_pars_fragment:AU,lights_phong_fragment:SU,lights_phong_pars_fragment:EU,lights_physical_fragment:MU,lights_physical_pars_fragment:wU,lights_fragment_begin:TU,lights_fragment_maps:CU,lights_fragment_end:RU,logdepthbuf_fragment:bU,logdepthbuf_pars_fragment:BU,logdepthbuf_pars_vertex:PU,logdepthbuf_vertex:IU,map_fragment:LU,map_pars_fragment:DU,map_particle_fragment:UU,map_particle_pars_fragment:FU,metalnessmap_fragment:OU,metalnessmap_pars_fragment:NU,morphcolor_vertex:kU,morphnormal_vertex:zU,morphtarget_pars_vertex:HU,morphtarget_vertex:GU,normal_fragment_begin:VU,normal_fragment_maps:WU,normal_pars_fragment:XU,normal_pars_vertex:JU,normal_vertex:YU,normalmap_pars_fragment:KU,clearcoat_normal_fragment_begin:ZU,clearcoat_normal_fragment_maps:QU,clearcoat_pars_fragment:jU,iridescence_pars_fragment:qU,opaque_fragment:$U,packing:e3,premultiplied_alpha_fragment:t3,project_vertex:n3,dithering_fragment:i3,dithering_pars_fragment:r3,roughnessmap_fragment:s3,roughnessmap_pars_fragment:o3,shadowmap_pars_fragment:a3,shadowmap_pars_vertex:l3,shadowmap_vertex:c3,shadowmask_pars_fragment:u3,skinbase_vertex:h3,skinning_pars_vertex:f3,skinning_vertex:d3,skinnormal_vertex:p3,specularmap_fragment:m3,specularmap_pars_fragment:g3,tonemapping_fragment:v3,tonemapping_pars_fragment:_3,transmission_fragment:y3,transmission_pars_fragment:x3,uv_pars_fragment:A3,uv_pars_vertex:S3,uv_vertex:E3,worldpos_vertex:M3,background_vert:w3,background_frag:T3,backgroundCube_vert:C3,backgroundCube_frag:R3,cube_vert:b3,cube_frag:B3,depth_vert:P3,depth_frag:I3,distanceRGBA_vert:L3,distanceRGBA_frag:D3,equirect_vert:U3,equirect_frag:F3,linedashed_vert:O3,linedashed_frag:N3,meshbasic_vert:k3,meshbasic_frag:z3,meshlambert_vert:H3,meshlambert_frag:G3,meshmatcap_vert:V3,meshmatcap_frag:W3,meshnormal_vert:X3,meshnormal_frag:J3,meshphong_vert:Y3,meshphong_frag:K3,meshphysical_vert:Z3,meshphysical_frag:Q3,meshtoon_vert:j3,meshtoon_frag:q3,points_vert:$3,points_frag:eF,shadow_vert:tF,shadow_frag:nF,sprite_vert:iF,sprite_frag:rF},Oe={common:{diffuse:{value:new Ne(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ft},alphaMap:{value:null},alphaMapTransform:{value:new Ft},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ft}},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 Ft}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ft}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ft},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ft},normalScale:{value:new Se(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ft},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ft}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ft}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ft}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ne(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{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 Ne(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ft},alphaTest:{value:0},uvTransform:{value:new Ft}},sprite:{diffuse:{value:new Ne(16777215)},opacity:{value:1},center:{value:new Se(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ft},alphaMap:{value:null},alphaMapTransform:{value:new Ft},alphaTest:{value:0}}},es={basic:{uniforms:Ui([Oe.common,Oe.specularmap,Oe.envmap,Oe.aomap,Oe.lightmap,Oe.fog]),vertexShader:Lt.meshbasic_vert,fragmentShader:Lt.meshbasic_frag},lambert:{uniforms:Ui([Oe.common,Oe.specularmap,Oe.envmap,Oe.aomap,Oe.lightmap,Oe.emissivemap,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.fog,Oe.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Lt.meshlambert_vert,fragmentShader:Lt.meshlambert_frag},phong:{uniforms:Ui([Oe.common,Oe.specularmap,Oe.envmap,Oe.aomap,Oe.lightmap,Oe.emissivemap,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.fog,Oe.lights,{emissive:{value:new Ne(0)},specular:{value:new Ne(1118481)},shininess:{value:30}}]),vertexShader:Lt.meshphong_vert,fragmentShader:Lt.meshphong_frag},standard:{uniforms:Ui([Oe.common,Oe.envmap,Oe.aomap,Oe.lightmap,Oe.emissivemap,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.roughnessmap,Oe.metalnessmap,Oe.fog,Oe.lights,{emissive:{value:new Ne(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Lt.meshphysical_vert,fragmentShader:Lt.meshphysical_frag},toon:{uniforms:Ui([Oe.common,Oe.aomap,Oe.lightmap,Oe.emissivemap,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.gradientmap,Oe.fog,Oe.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Lt.meshtoon_vert,fragmentShader:Lt.meshtoon_frag},matcap:{uniforms:Ui([Oe.common,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.fog,{matcap:{value:null}}]),vertexShader:Lt.meshmatcap_vert,fragmentShader:Lt.meshmatcap_frag},points:{uniforms:Ui([Oe.points,Oe.fog]),vertexShader:Lt.points_vert,fragmentShader:Lt.points_frag},dashed:{uniforms:Ui([Oe.common,Oe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Lt.linedashed_vert,fragmentShader:Lt.linedashed_frag},depth:{uniforms:Ui([Oe.common,Oe.displacementmap]),vertexShader:Lt.depth_vert,fragmentShader:Lt.depth_frag},normal:{uniforms:Ui([Oe.common,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,{opacity:{value:1}}]),vertexShader:Lt.meshnormal_vert,fragmentShader:Lt.meshnormal_frag},sprite:{uniforms:Ui([Oe.sprite,Oe.fog]),vertexShader:Lt.sprite_vert,fragmentShader:Lt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ft},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Lt.background_vert,fragmentShader:Lt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Lt.backgroundCube_vert,fragmentShader:Lt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Lt.cube_vert,fragmentShader:Lt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Lt.equirect_vert,fragmentShader:Lt.equirect_frag},distanceRGBA:{uniforms:Ui([Oe.common,Oe.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Lt.distanceRGBA_vert,fragmentShader:Lt.distanceRGBA_frag},shadow:{uniforms:Ui([Oe.lights,Oe.fog,{color:{value:new Ne(0)},opacity:{value:1}}]),vertexShader:Lt.shadow_vert,fragmentShader:Lt.shadow_frag}};es.physical={uniforms:Ui([es.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ft},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ft},clearcoatNormalScale:{value:new Se(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ft},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ft},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ft},sheen:{value:0},sheenColor:{value:new Ne(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ft},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ft},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ft},transmissionSamplerSize:{value:new Se},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ft},attenuationDistance:{value:0},attenuationColor:{value:new Ne(0)},specularColor:{value:new Ne(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ft},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ft},anisotropyVector:{value:new Se},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ft}}]),vertexShader:Lt.meshphysical_vert,fragmentShader:Lt.meshphysical_frag};const Kd={r:0,b:0,g:0};function sF(n,e,t,i,r,s,o){const a=new Ne(0);let l=s===!0?0:1,h,f,d=null,p=0,g=null;function _(y,m){let x=!1,A=m.isScene===!0?m.background:null;A&&A.isTexture&&(A=(m.backgroundBlurriness>0?t:e).get(A)),A===null?S(a,l):A&&A.isColor&&(S(A,1),x=!0);const M=n.xr.getEnvironmentBlendMode();M==="additive"?i.buffers.color.setClear(0,0,0,1,o):M==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,o),(n.autoClear||x)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),A&&(A.isCubeTexture||A.mapping===jc)?(f===void 0&&(f=new Un(new ul(1,1,1),new nr({name:"BackgroundCubeMaterial",uniforms:Gc(es.backgroundCube.uniforms),vertexShader:es.backgroundCube.vertexShader,fragmentShader:es.backgroundCube.fragmentShader,side:Ni,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),f.geometry.deleteAttribute("uv"),f.onBeforeRender=function(C,T,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(f.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(f)),f.material.uniforms.envMap.value=A,f.material.uniforms.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,f.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,f.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,f.material.toneMapped=on.getTransfer(A.colorSpace)!==fn,(d!==A||p!==A.version||g!==n.toneMapping)&&(f.material.needsUpdate=!0,d=A,p=A.version,g=n.toneMapping),f.layers.enableAll(),y.unshift(f,f.geometry,f.material,0,0,null)):A&&A.isTexture&&(h===void 0&&(h=new Un(new $c(2,2),new nr({name:"BackgroundMaterial",uniforms:Gc(es.background.uniforms),vertexShader:es.background.vertexShader,fragmentShader:es.background.fragmentShader,side:Rs,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=A,h.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,h.material.toneMapped=on.getTransfer(A.colorSpace)!==fn,A.matrixAutoUpdate===!0&&A.updateMatrix(),h.material.uniforms.uvTransform.value.copy(A.matrix),(d!==A||p!==A.version||g!==n.toneMapping)&&(h.material.needsUpdate=!0,d=A,p=A.version,g=n.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null))}function S(y,m){y.getRGB(Kd,eb(n)),i.buffers.color.setClear(Kd.r,Kd.g,Kd.b,m,o)}return{getClearColor:function(){return a},setClearColor:function(y,m=1){a.set(y),l=m,S(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,S(a,l)},render:_}}function oF(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={},l=y(null);let h=l,f=!1;function d(W,$,ie,fe,H){let Q=!1;if(o){const Y=S(fe,ie,$);h!==Y&&(h=Y,g(h.object)),Q=m(W,fe,ie,H),Q&&x(W,fe,ie,H)}else{const Y=$.wireframe===!0;(h.geometry!==fe.id||h.program!==ie.id||h.wireframe!==Y)&&(h.geometry=fe.id,h.program=ie.id,h.wireframe=Y,Q=!0)}H!==null&&t.update(H,n.ELEMENT_ARRAY_BUFFER),(Q||f)&&(f=!1,D(W,$,ie,fe),H!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.get(H).buffer))}function p(){return i.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function g(W){return i.isWebGL2?n.bindVertexArray(W):s.bindVertexArrayOES(W)}function _(W){return i.isWebGL2?n.deleteVertexArray(W):s.deleteVertexArrayOES(W)}function S(W,$,ie){const fe=ie.wireframe===!0;let H=a[W.id];H===void 0&&(H={},a[W.id]=H);let Q=H[$.id];Q===void 0&&(Q={},H[$.id]=Q);let Y=Q[fe];return Y===void 0&&(Y=y(p()),Q[fe]=Y),Y}function y(W){const $=[],ie=[],fe=[];for(let H=0;H=0){const _e=H[ue];let Pe=Q[ue];if(Pe===void 0&&(ue==="instanceMatrix"&&W.instanceMatrix&&(Pe=W.instanceMatrix),ue==="instanceColor"&&W.instanceColor&&(Pe=W.instanceColor)),_e===void 0||_e.attribute!==Pe||Pe&&_e.data!==Pe.data)return!0;Y++}return h.attributesNum!==Y||h.index!==fe}function x(W,$,ie,fe){const H={},Q=$.attributes;let Y=0;const re=ie.getAttributes();for(const ue in re)if(re[ue].location>=0){let _e=Q[ue];_e===void 0&&(ue==="instanceMatrix"&&W.instanceMatrix&&(_e=W.instanceMatrix),ue==="instanceColor"&&W.instanceColor&&(_e=W.instanceColor));const Pe={};Pe.attribute=_e,_e&&_e.data&&(Pe.data=_e.data),H[ue]=Pe,Y++}h.attributes=H,h.attributesNum=Y,h.index=fe}function A(){const W=h.newAttributes;for(let $=0,ie=W.length;$=0){let se=H[re];if(se===void 0&&(re==="instanceMatrix"&&W.instanceMatrix&&(se=W.instanceMatrix),re==="instanceColor"&&W.instanceColor&&(se=W.instanceColor)),se!==void 0){const _e=se.normalized,Pe=se.itemSize,Me=t.get(se);if(Me===void 0)continue;const Ue=Me.buffer,nt=Me.type,_t=Me.bytesPerElement,et=i.isWebGL2===!0&&(nt===n.INT||nt===n.UNSIGNED_INT||se.gpuType===Vx);if(se.isInterleavedBufferAttribute){const it=se.data,K=it.stride,Be=se.offset;if(it.isInstancedInterleavedBuffer){for(let xe=0;xe0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="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 l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const h=o||e.has("WEBGL_draw_buffers"),f=t.logarithmicDepthBuffer===!0,d=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_TEXTURE_SIZE),_=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),S=n.getParameter(n.MAX_VERTEX_ATTRIBS),y=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),m=n.getParameter(n.MAX_VARYING_VECTORS),x=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=p>0,M=o||e.has("OES_texture_float"),C=A&&M,T=o?n.getParameter(n.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:h,getMaxAnisotropy:r,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:f,maxTextures:d,maxVertexTextures:p,maxTextureSize:g,maxCubemapSize:_,maxAttributes:S,maxVertexUniforms:y,maxVaryings:m,maxFragmentUniforms:x,vertexTextures:A,floatFragmentTextures:M,floatVertexTextures:C,maxSamples:T}}function cF(n){const e=this;let t=null,i=0,r=!1,s=!1;const o=new Bo,a=new Ft,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,p){const g=d.length!==0||p||i!==0||r;return r=p,i=d.length,g},this.beginShadows=function(){s=!0,f(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,p){t=f(d,p,0)},this.setState=function(d,p,g){const _=d.clippingPlanes,S=d.clipIntersection,y=d.clipShadows,m=n.get(d);if(!r||_===null||_.length===0||s&&!y)s?f(null):h();else{const x=s?0:i,A=x*4;let M=m.clippingState||null;l.value=M,M=f(_,p,A,g);for(let C=0;C!==A;++C)M[C]=t[C];m.clippingState=M,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=x}};function h(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function f(d,p,g,_){const S=d!==null?d.length:0;let y=null;if(S!==0){if(y=l.value,_!==!0||y===null){const m=g+S*4,x=p.matrixWorldInverse;a.getNormalMatrix(x),(y===null||y.length0){const h=new aA(l.height/2);return h.fromEquirectangularTexture(n,o),e.set(o,h),o.addEventListener("dispose",r),t(h.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class eu extends af{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,l=r-t;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=h*this.view.offsetX,o=s+h*this.view.width,a-=f*this.view.offsetY,l=a-f*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,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 vc=4,KM=[.125,.215,.35,.446,.526,.582],Ua=20,d0=new eu,ZM=new Ne;let p0=null,m0=0,g0=0;const Da=(1+Math.sqrt(5))/2,Gl=1/Da,QM=[new k(1,1,1),new k(-1,1,1),new k(1,1,-1),new k(-1,1,-1),new k(0,Da,Gl),new k(0,Da,-Gl),new k(Gl,0,Da),new k(-Gl,0,Da),new k(Da,Gl,0),new k(-Da,Gl,0)];class Py{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){p0=this._renderer.getRenderTarget(),m0=this._renderer.getActiveCubeFace(),g0=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=$M(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=qM(),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?A:0,A,A),f.setRenderTarget(r),S&&f.render(_,a),f.render(e,a)}_.geometry.dispose(),_.material.dispose(),f.toneMapping=p,f.autoClear=d,e.background=y}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===bs||e.mapping===jo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=$M()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=qM());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new Un(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Zd(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(o,d0)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;rUa&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Ua}`);const m=[];let x=0;for(let R=0;RA-vc?r-A+vc:0),T=4*(this._cubeSize-M);Zd(t,C,T,3*M,2*M),l.setRenderTarget(t),l.render(d,d0)}}function hF(n){const e=[],t=[],i=[];let r=n;const s=n-vc+1+KM.length;for(let o=0;on-vc?l=KM[o-n+vc-1]:o===0&&(l=0),i.push(l);const h=1/(a-2),f=-h,d=1+h,p=[f,f,d,f,d,d,f,f,d,d,f,d],g=6,_=6,S=3,y=2,m=1,x=new Float32Array(S*_*g),A=new Float32Array(y*_*g),M=new Float32Array(m*_*g);for(let T=0;T2?0:-1,b=[R,D,0,R+2/3,D,0,R+2/3,D+1,0,R,D,0,R+2/3,D+1,0,R,D+1,0];x.set(b,S*_*T),A.set(p,y*_*T);const I=[T,T,T,T,T,T];M.set(I,m*_*T)}const C=new Tt;C.setAttribute("position",new Yt(x,S)),C.setAttribute("uv",new Yt(A,y)),C.setAttribute("faceIndex",new Yt(M,m)),e.push(C),r>vc&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function jM(n,e,t){const i=new ki(n,e,t);return i.texture.mapping=jc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Zd(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function fF(n,e,t){const i=new Float32Array(Ua),r=new k(0,1,0);return new nr({name:"SphericalGaussianBlur",defines:{n:Ua,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:lA(),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:eo,depthTest:!1,depthWrite:!1})}function qM(){return new nr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:lA(),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:eo,depthTest:!1,depthWrite:!1})}function $M(){return new nr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:lA(),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:eo,depthTest:!1,depthWrite:!1})}function lA(){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 dF(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const l=a.mapping,h=l===Oc||l===Oh,f=l===bs||l===jo;if(h||f)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let d=e.get(a);return t===null&&(t=new Py(n)),d=h?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(h&&d&&d.height>0||f&&d&&r(d)){t===null&&(t=new Py(n));const p=h?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,p),a.addEventListener("dispose",s),p.texture}else return null}}}return a}function r(a){let l=0;const h=6;for(let f=0;fe.maxTextureSize&&(O=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const j=new Float32Array(I*O*4*S),ae=new Zm(j,I,O,S);ae.type=di,ae.needsUpdate=!0;const W=b*4;for(let ie=0;ie0)return n;const r=e*t;let s=e1[r];if(s===void 0&&(s=new Float32Array(r),e1[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 ti(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t":" "} ${a}: ${t[o]}`)}return i.join(` `)}function mO(n){const e=on.getPrimaries(on.workingColorSpace),t=on.getPrimaries(n);let i;switch(e===t?i="":e===Gh&&t===Hh?i="LinearDisplayP3ToLinearSRGB":e===Hh&&t===Gh&&(i="LinearSRGBToLinearDisplayP3"),n){case Ps:case sf:return[i,"LinearTransferOETF"];case Qn:case Km:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function a1(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+` `+pO(n.getShaderSource(e),o)}else return r}function gO(n,e){const t=mO(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function vO(n,e){let t;switch(e){case ER:t="Linear";break;case MR:t="Reinhard";break;case wR:t="OptimizedCineon";break;case Gx:t="ACESFilmic";break;case CR:t="AgX";break;case TR:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function _O(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(_c).join(` `)}function yO(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(_c).join(` `)}function xO(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function AO(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function Iy(n){return n.replace(SO,MO)}const EO=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function MO(n,e){let t=Lt[e];if(t===void 0){const i=EO.get(e);if(i!==void 0)t=Lt[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 Iy(t)}const wO=/#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 u1(n){return n.replace(wO,TO)}function TO(n,e,t,i){let r="";for(let s=parseInt(e);s0&&(m+=` `),x=[g,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,S].filter(_c).join(` `),x.length>0&&(x+=` `)):(m=[h1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,S,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 "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.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 "+l:"",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(_c).join(` `),x=[g,h1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,S,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 "+h:"",t.envMap?"#define "+f:"",t.envMap?"#define "+d:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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 "+l:"",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!==Ms?"#define TONE_MAPPING":"",t.toneMapping!==Ms?Lt.tonemapping_pars_fragment:"",t.toneMapping!==Ms?vO("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Lt.colorspace_pars_fragment,gO("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(_c).join(` `)),o=Iy(o),o=l1(o,t),o=c1(o,t),a=Iy(a),a=l1(a,t),a=c1(a,t),o=u1(o),a=u1(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(A=`#version 300 es `,m=[_,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+m,x=["precision mediump sampler2DArray;","#define varying in",t.glslVersion===by?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===by?"":"#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 M=A+m+o,C=A+x+a,T=o1(r,r.VERTEX_SHADER,M),R=o1(r,r.FRAGMENT_SHADER,C);r.attachShader(y,T),r.attachShader(y,R),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function D(j){if(n.debug.checkShaderErrors){const ae=r.getProgramInfoLog(y).trim(),W=r.getShaderInfoLog(T).trim(),$=r.getShaderInfoLog(R).trim();let ie=!0,fe=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(ie=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,T,R);else{const H=a1(r,T,"vertex"),Q=a1(r,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+` Program Info Log: `+ae+` `+H+` `+Q)}else ae!==""?console.warn("THREE.WebGLProgram: Program Info Log:",ae):(W===""||$==="")&&(fe=!1);fe&&(j.diagnostics={runnable:ie,programLog:ae,vertexShader:{log:W,prefix:m},fragmentShader:{log:$,prefix:x}})}r.deleteShader(T),r.deleteShader(R),b=new Yp(r,y),I=AO(r,y)}let b;this.getUniforms=function(){return b===void 0&&D(this),b};let I;this.getAttributes=function(){return I===void 0&&D(this),I};let O=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return O===!1&&(O=r.getProgramParameter(y,fO)),O},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=dO++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=R,this}let LO=0;class DO{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 UO(e),t.set(e,i)),i}}class UO{constructor(e){this.id=LO++,this.code=e,this.usedTimes=0}}function FO(n,e,t,i,r,s,o){const a=new Qa,l=new DO,h=[],f=r.isWebGL2,d=r.logarithmicDepthBuffer,p=r.vertexTextures;let g=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 S(b){return b===0?"uv":`uv${b}`}function y(b,I,O,j,ae){const W=j.fog,$=ae.geometry,ie=b.isMeshStandardMaterial?j.environment:null,fe=(b.isMeshStandardMaterial?t:e).get(b.envMap||ie),H=fe&&fe.mapping===jc?fe.image.height:null,Q=_[b.type];b.precision!==null&&(g=r.getMaxPrecision(b.precision),g!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",g,"instead."));const Y=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,re=Y!==void 0?Y.length:0;let ue=0;$.morphAttributes.position!==void 0&&(ue=1),$.morphAttributes.normal!==void 0&&(ue=2),$.morphAttributes.color!==void 0&&(ue=3);let se,_e,Pe,Me;if(Q){const kn=es[Q];se=kn.vertexShader,_e=kn.fragmentShader}else se=b.vertexShader,_e=b.fragmentShader,l.update(b),Pe=l.getVertexShaderID(b),Me=l.getFragmentShaderID(b);const Ue=n.getRenderTarget(),nt=ae.isInstancedMesh===!0,_t=ae.isBatchedMesh===!0,et=!!b.map,it=!!b.matcap,K=!!fe,Be=!!b.aoMap,xe=!!b.lightMap,Le=!!b.bumpMap,Ae=!!b.normalMap,rt=!!b.displacementMap,Ve=!!b.emissiveMap,N=!!b.metalnessMap,U=!!b.roughnessMap,oe=b.anisotropy>0,Re=b.clearcoat>0,Te=b.iridescence>0,Ee=b.sheen>0,$e=b.transmission>0,ke=oe&&!!b.anisotropyMap,Ye=Re&&!!b.clearcoatMap,ct=Re&&!!b.clearcoatNormalMap,yt=Re&&!!b.clearcoatRoughnessMap,Ce=Te&&!!b.iridescenceMap,Gt=Te&&!!b.iridescenceThicknessMap,Bt=Ee&&!!b.sheenColorMap,dt=Ee&&!!b.sheenRoughnessMap,Ke=!!b.specularMap,Ze=!!b.specularColorMap,gt=!!b.specularIntensityMap,St=$e&&!!b.transmissionMap,Pt=$e&&!!b.thicknessMap,Ct=!!b.gradientMap,he=!!b.alphaMap,q=b.alphaTest>0,ze=!!b.alphaHash,He=!!b.extensions,pt=!!$.attributes.uv1,ut=!!$.attributes.uv2,en=!!$.attributes.uv3;let $t=Ms;return b.toneMapped&&(Ue===null||Ue.isXRRenderTarget===!0)&&($t=n.toneMapping),{isWebGL2:f,shaderID:Q,shaderType:b.type,shaderName:b.name,vertexShader:se,fragmentShader:_e,defines:b.defines,customVertexShaderID:Pe,customFragmentShaderID:Me,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:g,batching:_t,instancing:nt,instancingColor:nt&&ae.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:Ue===null?n.outputColorSpace:Ue.isXRRenderTarget===!0?Ue.texture.colorSpace:Ps,map:et,matcap:it,envMap:K,envMapMode:K&&fe.mapping,envMapCubeUVHeight:H,aoMap:Be,lightMap:xe,bumpMap:Le,normalMap:Ae,displacementMap:p&&rt,emissiveMap:Ve,normalMapObjectSpace:Ae&&b.normalMapType===GR,normalMapTangentSpace:Ae&&b.normalMapType===ra,metalnessMap:N,roughnessMap:U,anisotropy:oe,anisotropyMap:ke,clearcoat:Re,clearcoatMap:Ye,clearcoatNormalMap:ct,clearcoatRoughnessMap:yt,iridescence:Te,iridescenceMap:Ce,iridescenceThicknessMap:Gt,sheen:Ee,sheenColorMap:Bt,sheenRoughnessMap:dt,specularMap:Ke,specularColorMap:Ze,specularIntensityMap:gt,transmission:$e,transmissionMap:St,thicknessMap:Pt,gradientMap:Ct,opaque:b.transparent===!1&&b.blending===Ya,alphaMap:he,alphaTest:q,alphaHash:ze,combine:b.combine,mapUv:et&&S(b.map.channel),aoMapUv:Be&&S(b.aoMap.channel),lightMapUv:xe&&S(b.lightMap.channel),bumpMapUv:Le&&S(b.bumpMap.channel),normalMapUv:Ae&&S(b.normalMap.channel),displacementMapUv:rt&&S(b.displacementMap.channel),emissiveMapUv:Ve&&S(b.emissiveMap.channel),metalnessMapUv:N&&S(b.metalnessMap.channel),roughnessMapUv:U&&S(b.roughnessMap.channel),anisotropyMapUv:ke&&S(b.anisotropyMap.channel),clearcoatMapUv:Ye&&S(b.clearcoatMap.channel),clearcoatNormalMapUv:ct&&S(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:yt&&S(b.clearcoatRoughnessMap.channel),iridescenceMapUv:Ce&&S(b.iridescenceMap.channel),iridescenceThicknessMapUv:Gt&&S(b.iridescenceThicknessMap.channel),sheenColorMapUv:Bt&&S(b.sheenColorMap.channel),sheenRoughnessMapUv:dt&&S(b.sheenRoughnessMap.channel),specularMapUv:Ke&&S(b.specularMap.channel),specularColorMapUv:Ze&&S(b.specularColorMap.channel),specularIntensityMapUv:gt&&S(b.specularIntensityMap.channel),transmissionMapUv:St&&S(b.transmissionMap.channel),thicknessMapUv:Pt&&S(b.thicknessMap.channel),alphaMapUv:he&&S(b.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(Ae||oe),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,vertexUv1s:pt,vertexUv2s:ut,vertexUv3s:en,pointsUvs:ae.isPoints===!0&&!!$.attributes.uv&&(et||he),fog:!!W,useFog:b.fog===!0,fogExp2:W&&W.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:ae.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:re,morphTextureStride:ue,numDirLights:I.directional.length,numPointLights:I.point.length,numSpotLights:I.spot.length,numSpotLightMaps:I.spotLightMap.length,numRectAreaLights:I.rectArea.length,numHemiLights:I.hemi.length,numDirLightShadows:I.directionalShadowMap.length,numPointLightShadows:I.pointShadowMap.length,numSpotLightShadows:I.spotShadowMap.length,numSpotLightShadowsWithMaps:I.numSpotLightShadowsWithMaps,numLightProbes:I.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&O.length>0,shadowMapType:n.shadowMap.type,toneMapping:$t,useLegacyLights:n._useLegacyLights,decodeVideoTexture:et&&b.map.isVideoTexture===!0&&on.getTransfer(b.map.colorSpace)===fn,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Fr,flipSided:b.side===Ni,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionDerivatives:He&&b.extensions.derivatives===!0,extensionFragDepth:He&&b.extensions.fragDepth===!0,extensionDrawBuffers:He&&b.extensions.drawBuffers===!0,extensionShaderTextureLOD:He&&b.extensions.shaderTextureLOD===!0,extensionClipCullDistance:He&&b.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:f||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:f||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:f||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()}}function m(b){const I=[];if(b.shaderID?I.push(b.shaderID):(I.push(b.customVertexShaderID),I.push(b.customFragmentShaderID)),b.defines!==void 0)for(const O in b.defines)I.push(O),I.push(b.defines[O]);return b.isRawShaderMaterial===!1&&(x(I,b),A(I,b),I.push(n.outputColorSpace)),I.push(b.customProgramCacheKey),I.join()}function x(b,I){b.push(I.precision),b.push(I.outputColorSpace),b.push(I.envMapMode),b.push(I.envMapCubeUVHeight),b.push(I.mapUv),b.push(I.alphaMapUv),b.push(I.lightMapUv),b.push(I.aoMapUv),b.push(I.bumpMapUv),b.push(I.normalMapUv),b.push(I.displacementMapUv),b.push(I.emissiveMapUv),b.push(I.metalnessMapUv),b.push(I.roughnessMapUv),b.push(I.anisotropyMapUv),b.push(I.clearcoatMapUv),b.push(I.clearcoatNormalMapUv),b.push(I.clearcoatRoughnessMapUv),b.push(I.iridescenceMapUv),b.push(I.iridescenceThicknessMapUv),b.push(I.sheenColorMapUv),b.push(I.sheenRoughnessMapUv),b.push(I.specularMapUv),b.push(I.specularColorMapUv),b.push(I.specularIntensityMapUv),b.push(I.transmissionMapUv),b.push(I.thicknessMapUv),b.push(I.combine),b.push(I.fogExp2),b.push(I.sizeAttenuation),b.push(I.morphTargetsCount),b.push(I.morphAttributeCount),b.push(I.numDirLights),b.push(I.numPointLights),b.push(I.numSpotLights),b.push(I.numSpotLightMaps),b.push(I.numHemiLights),b.push(I.numRectAreaLights),b.push(I.numDirLightShadows),b.push(I.numPointLightShadows),b.push(I.numSpotLightShadows),b.push(I.numSpotLightShadowsWithMaps),b.push(I.numLightProbes),b.push(I.shadowMapType),b.push(I.toneMapping),b.push(I.numClippingPlanes),b.push(I.numClipIntersection),b.push(I.depthPacking)}function A(b,I){a.disableAll(),I.isWebGL2&&a.enable(0),I.supportsVertexTextures&&a.enable(1),I.instancing&&a.enable(2),I.instancingColor&&a.enable(3),I.matcap&&a.enable(4),I.envMap&&a.enable(5),I.normalMapObjectSpace&&a.enable(6),I.normalMapTangentSpace&&a.enable(7),I.clearcoat&&a.enable(8),I.iridescence&&a.enable(9),I.alphaTest&&a.enable(10),I.vertexColors&&a.enable(11),I.vertexAlphas&&a.enable(12),I.vertexUv1s&&a.enable(13),I.vertexUv2s&&a.enable(14),I.vertexUv3s&&a.enable(15),I.vertexTangents&&a.enable(16),I.anisotropy&&a.enable(17),I.alphaHash&&a.enable(18),I.batching&&a.enable(19),b.push(a.mask),a.disableAll(),I.fog&&a.enable(0),I.useFog&&a.enable(1),I.flatShading&&a.enable(2),I.logarithmicDepthBuffer&&a.enable(3),I.skinning&&a.enable(4),I.morphTargets&&a.enable(5),I.morphNormals&&a.enable(6),I.morphColors&&a.enable(7),I.premultipliedAlpha&&a.enable(8),I.shadowMapEnabled&&a.enable(9),I.useLegacyLights&&a.enable(10),I.doubleSided&&a.enable(11),I.flipSided&&a.enable(12),I.useDepthPacking&&a.enable(13),I.dithering&&a.enable(14),I.transmission&&a.enable(15),I.sheen&&a.enable(16),I.opaque&&a.enable(17),I.pointsUvs&&a.enable(18),I.decodeVideoTexture&&a.enable(19),b.push(a.mask)}function M(b){const I=_[b.type];let O;if(I){const j=es[I];O=oA.clone(j.uniforms)}else O=b.uniforms;return O}function C(b,I){let O;for(let j=0,ae=h.length;j0?i.push(m):g.transparent===!0?r.push(m):t.push(m)}function l(d,p,g,_,S,y){const m=o(d,p,g,_,S,y);g.transmission>0?i.unshift(m):g.transparent===!0?r.unshift(m):t.unshift(m)}function h(d,p){t.length>1&&t.sort(d||NO),i.length>1&&i.sort(p||f1),r.length>1&&r.sort(p||f1)}function f(){for(let d=e,p=n.length;d=s.length?(o=new d1,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function zO(){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 k,color:new Ne};break;case"SpotLight":t={position:new k,direction:new k,color:new Ne,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new Ne,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new Ne,groundColor:new Ne};break;case"RectAreaLight":t={color:new Ne,position:new k,halfWidth:new k,halfHeight:new k};break}return n[e.id]=t,t}}}function HO(){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 Se};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Se};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Se,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let GO=0;function VO(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function WO(n,e){const t=new zO,i=HO(),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 f=0;f<9;f++)r.probe.push(new k);const s=new k,o=new lt,a=new lt;function l(f,d){let p=0,g=0,_=0;for(let j=0;j<9;j++)r.probe[j].set(0,0,0);let S=0,y=0,m=0,x=0,A=0,M=0,C=0,T=0,R=0,D=0,b=0;f.sort(VO);const I=d===!0?Math.PI:1;for(let j=0,ae=f.length;j0&&(e.isWebGL2?n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Oe.LTC_FLOAT_1,r.rectAreaLTC2=Oe.LTC_FLOAT_2):(r.rectAreaLTC1=Oe.LTC_HALF_1,r.rectAreaLTC2=Oe.LTC_HALF_2):n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Oe.LTC_FLOAT_1,r.rectAreaLTC2=Oe.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=Oe.LTC_HALF_1,r.rectAreaLTC2=Oe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=p,r.ambient[1]=g,r.ambient[2]=_;const O=r.hash;(O.directionalLength!==S||O.pointLength!==y||O.spotLength!==m||O.rectAreaLength!==x||O.hemiLength!==A||O.numDirectionalShadows!==M||O.numPointShadows!==C||O.numSpotShadows!==T||O.numSpotMaps!==R||O.numLightProbes!==b)&&(r.directional.length=S,r.spot.length=m,r.rectArea.length=x,r.point.length=y,r.hemi.length=A,r.directionalShadow.length=M,r.directionalShadowMap.length=M,r.pointShadow.length=C,r.pointShadowMap.length=C,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=M,r.pointShadowMatrix.length=C,r.spotLightMatrix.length=T+R-D,r.spotLightMap.length=R,r.numSpotLightShadowsWithMaps=D,r.numLightProbes=b,O.directionalLength=S,O.pointLength=y,O.spotLength=m,O.rectAreaLength=x,O.hemiLength=A,O.numDirectionalShadows=M,O.numPointShadows=C,O.numSpotShadows=T,O.numSpotMaps=R,O.numLightProbes=b,r.version=GO++)}function h(f,d){let p=0,g=0,_=0,S=0,y=0;const m=d.matrixWorldInverse;for(let x=0,A=f.length;x=a.length?(l=new p1(n,e),a.push(l)):l=a[o],l}function r(){t=new WeakMap}return{get:i,dispose:r}}class jm extends Jn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=zR,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 uA extends Jn{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 JO=`void main() { gl_Position = vec4( position, 1.0 ); }`,YO=`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 KO(n,e,t){let i=new cf;const r=new Se,s=new Se,o=new rn,a=new jm({depthPacking:HR}),l=new uA,h={},f=t.maxTextureSize,d={[Rs]:Ni,[Ni]:Rs,[Fr]:Fr},p=new nr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Se},radius:{value:4}},vertexShader:JO,fragmentShader:YO}),g=p.clone();g.defines.HORIZONTAL_PASS=1;const _=new Tt;_.setAttribute("position",new Yt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Un(_,p),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Vm;let m=this.type;this.render=function(T,R,D){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||T.length===0)return;const b=n.getRenderTarget(),I=n.getActiveCubeFace(),O=n.getActiveMipmapLevel(),j=n.state;j.setBlending(eo),j.buffers.color.setClear(1,1,1,1),j.buffers.depth.setTest(!0),j.setScissorTest(!1);const ae=m!==jr&&this.type===jr,W=m===jr&&this.type!==jr;for(let $=0,ie=T.length;$f||r.y>f)&&(r.x>f&&(s.x=Math.floor(f/Q.x),r.x=s.x*Q.x,H.mapSize.x=s.x),r.y>f&&(s.y=Math.floor(f/Q.y),r.y=s.y*Q.y,H.mapSize.y=s.y)),H.map===null||ae===!0||W===!0){const re=this.type!==jr?{minFilter:An,magFilter:An}:{};H.map!==null&&H.map.dispose(),H.map=new ki(r.x,r.y,re),H.map.texture.name=fe.name+".shadowMap",H.camera.updateProjectionMatrix()}n.setRenderTarget(H.map),n.clear();const Y=H.getViewportCount();for(let re=0;re0||R.map&&R.alphaTest>0){const j=I.uuid,ae=R.uuid;let W=h[j];W===void 0&&(W={},h[j]=W);let $=W[ae];$===void 0&&($=I.clone(),W[ae]=$,R.addEventListener("dispose",C)),I=$}if(I.visible=R.visible,I.wireframe=R.wireframe,b===jr?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:d[R.side],I.alphaMap=R.alphaMap,I.alphaTest=R.alphaTest,I.map=R.map,I.clipShadows=R.clipShadows,I.clippingPlanes=R.clippingPlanes,I.clipIntersection=R.clipIntersection,I.displacementMap=R.displacementMap,I.displacementScale=R.displacementScale,I.displacementBias=R.displacementBias,I.wireframeLinewidth=R.wireframeLinewidth,I.linewidth=R.linewidth,D.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const j=n.properties.get(I);j.light=D}return I}function M(T,R,D,b,I){if(T.visible===!1)return;if(T.layers.test(R.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&I===jr)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,T.matrixWorld);const ae=e.update(T),W=T.material;if(Array.isArray(W)){const $=ae.groups;for(let ie=0,fe=$.length;ie=1):Y.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),H=Q>=2);let re=null,ue={};const se=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),Pe=new rn().fromArray(se),Me=new rn().fromArray(_e);function Ue(q,ze,He,pt){const ut=new Uint8Array(4),en=n.createTexture();n.bindTexture(q,en),n.texParameteri(q,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(q,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let $t=0;$t"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap;let d;const p=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(N,U){return g?new OffscreenCanvas(N,U):Wh("canvas")}function S(N,U,oe,Re){let Te=1;if((N.width>Re||N.height>Re)&&(Te=Re/Math.max(N.width,N.height)),Te<1||U===!0)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap){const Ee=U?Mm:Math.floor,$e=Ee(Te*N.width),ke=Ee(Te*N.height);d===void 0&&(d=_($e,ke));const Ye=oe?_($e,ke):d;return Ye.width=$e,Ye.height=ke,Ye.getContext("2d").drawImage(N,0,0,$e,ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+N.width+"x"+N.height+") to ("+$e+"x"+ke+")."),Ye}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+N.width+"x"+N.height+")."),N;return N}function y(N){return By(N.width)&&By(N.height)}function m(N){return a?!1:N.wrapS!==fi||N.wrapT!==fi||N.minFilter!==An&&N.minFilter!==cn}function x(N,U){return N.generateMipmaps&&U&&N.minFilter!==An&&N.minFilter!==cn}function A(N){n.generateMipmap(N)}function M(N,U,oe,Re,Te=!1){if(a===!1)return U;if(N!==null){if(n[N]!==void 0)return n[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let Ee=U;if(U===n.RED&&(oe===n.FLOAT&&(Ee=n.R32F),oe===n.HALF_FLOAT&&(Ee=n.R16F),oe===n.UNSIGNED_BYTE&&(Ee=n.R8)),U===n.RED_INTEGER&&(oe===n.UNSIGNED_BYTE&&(Ee=n.R8UI),oe===n.UNSIGNED_SHORT&&(Ee=n.R16UI),oe===n.UNSIGNED_INT&&(Ee=n.R32UI),oe===n.BYTE&&(Ee=n.R8I),oe===n.SHORT&&(Ee=n.R16I),oe===n.INT&&(Ee=n.R32I)),U===n.RG&&(oe===n.FLOAT&&(Ee=n.RG32F),oe===n.HALF_FLOAT&&(Ee=n.RG16F),oe===n.UNSIGNED_BYTE&&(Ee=n.RG8)),U===n.RGBA){const $e=Te?zh:on.getTransfer(Re);oe===n.FLOAT&&(Ee=n.RGBA32F),oe===n.HALF_FLOAT&&(Ee=n.RGBA16F),oe===n.UNSIGNED_BYTE&&(Ee=$e===fn?n.SRGB8_ALPHA8:n.RGBA8),oe===n.UNSIGNED_SHORT_4_4_4_4&&(Ee=n.RGBA4),oe===n.UNSIGNED_SHORT_5_5_5_1&&(Ee=n.RGB5_A1)}return(Ee===n.R16F||Ee===n.R32F||Ee===n.RG16F||Ee===n.RG32F||Ee===n.RGBA16F||Ee===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Ee}function C(N,U,oe){return x(N,oe)===!0||N.isFramebufferTexture&&N.minFilter!==An&&N.minFilter!==cn?Math.log2(Math.max(U.width,U.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?U.mipmaps.length:1}function T(N){return N===An||N===Nh||N===Cc?n.NEAREST:n.LINEAR}function R(N){const U=N.target;U.removeEventListener("dispose",R),b(U),U.isVideoTexture&&f.delete(U)}function D(N){const U=N.target;U.removeEventListener("dispose",D),O(U)}function b(N){const U=i.get(N);if(U.__webglInit===void 0)return;const oe=N.source,Re=p.get(oe);if(Re){const Te=Re[U.__cacheKey];Te.usedTimes--,Te.usedTimes===0&&I(N),Object.keys(Re).length===0&&p.delete(oe)}i.remove(N)}function I(N){const U=i.get(N);n.deleteTexture(U.__webglTexture);const oe=N.source,Re=p.get(oe);delete Re[U.__cacheKey],o.memory.textures--}function O(N){const U=N.texture,oe=i.get(N),Re=i.get(U);if(Re.__webglTexture!==void 0&&(n.deleteTexture(Re.__webglTexture),o.memory.textures--),N.depthTexture&&N.depthTexture.dispose(),N.isWebGLCubeRenderTarget)for(let Te=0;Te<6;Te++){if(Array.isArray(oe.__webglFramebuffer[Te]))for(let Ee=0;Ee=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+r.maxTextures),j+=1,N}function $(N){const U=[];return U.push(N.wrapS),U.push(N.wrapT),U.push(N.wrapR||0),U.push(N.magFilter),U.push(N.minFilter),U.push(N.anisotropy),U.push(N.internalFormat),U.push(N.format),U.push(N.type),U.push(N.generateMipmaps),U.push(N.premultiplyAlpha),U.push(N.flipY),U.push(N.unpackAlignment),U.push(N.colorSpace),U.join()}function ie(N,U){const oe=i.get(N);if(N.isVideoTexture&&rt(N),N.isRenderTargetTexture===!1&&N.version>0&&oe.__version!==N.version){const Re=N.image;if(Re===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Re.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(oe,N,U);return}}t.bindTexture(n.TEXTURE_2D,oe.__webglTexture,n.TEXTURE0+U)}function fe(N,U){const oe=i.get(N);if(N.version>0&&oe.__version!==N.version){Pe(oe,N,U);return}t.bindTexture(n.TEXTURE_2D_ARRAY,oe.__webglTexture,n.TEXTURE0+U)}function H(N,U){const oe=i.get(N);if(N.version>0&&oe.__version!==N.version){Pe(oe,N,U);return}t.bindTexture(n.TEXTURE_3D,oe.__webglTexture,n.TEXTURE0+U)}function Q(N,U){const oe=i.get(N);if(N.version>0&&oe.__version!==N.version){Me(oe,N,U);return}t.bindTexture(n.TEXTURE_CUBE_MAP,oe.__webglTexture,n.TEXTURE0+U)}const Y={[qo]:n.REPEAT,[fi]:n.CLAMP_TO_EDGE,[Nc]:n.MIRRORED_REPEAT},re={[An]:n.NEAREST,[Nh]:n.NEAREST_MIPMAP_NEAREST,[Cc]:n.NEAREST_MIPMAP_LINEAR,[cn]:n.LINEAR,[Xm]:n.LINEAR_MIPMAP_NEAREST,[Bs]:n.LINEAR_MIPMAP_LINEAR},ue={[VR]:n.NEVER,[ZR]:n.ALWAYS,[WR]:n.LESS,[eA]:n.LEQUAL,[XR]:n.EQUAL,[KR]:n.GEQUAL,[JR]:n.GREATER,[YR]:n.NOTEQUAL};function se(N,U,oe){if(oe?(n.texParameteri(N,n.TEXTURE_WRAP_S,Y[U.wrapS]),n.texParameteri(N,n.TEXTURE_WRAP_T,Y[U.wrapT]),(N===n.TEXTURE_3D||N===n.TEXTURE_2D_ARRAY)&&n.texParameteri(N,n.TEXTURE_WRAP_R,Y[U.wrapR]),n.texParameteri(N,n.TEXTURE_MAG_FILTER,re[U.magFilter]),n.texParameteri(N,n.TEXTURE_MIN_FILTER,re[U.minFilter])):(n.texParameteri(N,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(N,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),(N===n.TEXTURE_3D||N===n.TEXTURE_2D_ARRAY)&&n.texParameteri(N,n.TEXTURE_WRAP_R,n.CLAMP_TO_EDGE),(U.wrapS!==fi||U.wrapT!==fi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(N,n.TEXTURE_MAG_FILTER,T(U.magFilter)),n.texParameteri(N,n.TEXTURE_MIN_FILTER,T(U.minFilter)),U.minFilter!==An&&U.minFilter!==cn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),U.compareFunction&&(n.texParameteri(N,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(N,n.TEXTURE_COMPARE_FUNC,ue[U.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const Re=e.get("EXT_texture_filter_anisotropic");if(U.magFilter===An||U.minFilter!==Cc&&U.minFilter!==Bs||U.type===di&&e.has("OES_texture_float_linear")===!1||a===!1&&U.type===Ci&&e.has("OES_texture_half_float_linear")===!1)return;(U.anisotropy>1||i.get(U).__currentAnisotropy)&&(n.texParameterf(N,Re.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(U.anisotropy,r.getMaxAnisotropy())),i.get(U).__currentAnisotropy=U.anisotropy)}}function _e(N,U){let oe=!1;N.__webglInit===void 0&&(N.__webglInit=!0,U.addEventListener("dispose",R));const Re=U.source;let Te=p.get(Re);Te===void 0&&(Te={},p.set(Re,Te));const Ee=$(U);if(Ee!==N.__cacheKey){Te[Ee]===void 0&&(Te[Ee]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,oe=!0),Te[Ee].usedTimes++;const $e=Te[N.__cacheKey];$e!==void 0&&(Te[N.__cacheKey].usedTimes--,$e.usedTimes===0&&I(U)),N.__cacheKey=Ee,N.__webglTexture=Te[Ee].texture}return oe}function Pe(N,U,oe){let Re=n.TEXTURE_2D;(U.isDataArrayTexture||U.isCompressedArrayTexture)&&(Re=n.TEXTURE_2D_ARRAY),U.isData3DTexture&&(Re=n.TEXTURE_3D);const Te=_e(N,U),Ee=U.source;t.bindTexture(Re,N.__webglTexture,n.TEXTURE0+oe);const $e=i.get(Ee);if(Ee.version!==$e.__version||Te===!0){t.activeTexture(n.TEXTURE0+oe);const ke=on.getPrimaries(on.workingColorSpace),Ye=U.colorSpace===ur?null:on.getPrimaries(U.colorSpace),ct=U.colorSpace===ur||ke===Ye?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,U.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,U.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,ct);const yt=m(U)&&y(U.image)===!1;let Ce=S(U.image,yt,!1,r.maxTextureSize);Ce=Ve(U,Ce);const Gt=y(Ce)||a,Bt=s.convert(U.format,U.colorSpace);let dt=s.convert(U.type),Ke=M(U.internalFormat,Bt,dt,U.colorSpace,U.isVideoTexture);se(Re,U,Gt);let Ze;const gt=U.mipmaps,St=a&&U.isVideoTexture!==!0&&Ke!==Qx,Pt=$e.__version===void 0||Te===!0,Ct=C(U,Ce,Gt);if(U.isDepthTexture)Ke=n.DEPTH_COMPONENT,a?U.type===di?Ke=n.DEPTH_COMPONENT32F:U.type===Qs?Ke=n.DEPTH_COMPONENT24:U.type===Jo?Ke=n.DEPTH24_STENCIL8:Ke=n.DEPTH_COMPONENT16:U.type===di&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),U.format===Yo&&Ke===n.DEPTH_COMPONENT&&U.type!==Jm&&U.type!==Qs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),U.type=Qs,dt=s.convert(U.type)),U.format===rl&&Ke===n.DEPTH_COMPONENT&&(Ke=n.DEPTH_STENCIL,U.type!==Jo&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),U.type=Jo,dt=s.convert(U.type))),Pt&&(St?t.texStorage2D(n.TEXTURE_2D,1,Ke,Ce.width,Ce.height):t.texImage2D(n.TEXTURE_2D,0,Ke,Ce.width,Ce.height,0,Bt,dt,null));else if(U.isDataTexture)if(gt.length>0&&Gt){St&&Pt&&t.texStorage2D(n.TEXTURE_2D,Ct,Ke,gt[0].width,gt[0].height);for(let he=0,q=gt.length;he>=1,q>>=1}}else if(gt.length>0&&Gt){St&&Pt&&t.texStorage2D(n.TEXTURE_2D,Ct,Ke,gt[0].width,gt[0].height);for(let he=0,q=gt.length;he0&&Pt++,t.texStorage2D(n.TEXTURE_CUBE_MAP,Pt,Ze,Ce[0].width,Ce[0].height));for(let he=0;he<6;he++)if(yt){gt?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,0,0,Ce[he].width,Ce[he].height,dt,Ke,Ce[he].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,Ze,Ce[he].width,Ce[he].height,0,dt,Ke,Ce[he].data);for(let q=0;q>Ee),Ce=Math.max(1,U.height>>Ee);Te===n.TEXTURE_3D||Te===n.TEXTURE_2D_ARRAY?t.texImage3D(Te,Ee,Ye,yt,Ce,U.depth,0,$e,ke,null):t.texImage2D(Te,Ee,Ye,yt,Ce,0,$e,ke,null)}t.bindFramebuffer(n.FRAMEBUFFER,N),Ae(U)?l.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Re,Te,i.get(oe).__webglTexture,0,Le(U)):(Te===n.TEXTURE_2D||Te>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Te<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Re,Te,i.get(oe).__webglTexture,Ee),t.bindFramebuffer(n.FRAMEBUFFER,null)}function nt(N,U,oe){if(n.bindRenderbuffer(n.RENDERBUFFER,N),U.depthBuffer&&!U.stencilBuffer){let Re=a===!0?n.DEPTH_COMPONENT24:n.DEPTH_COMPONENT16;if(oe||Ae(U)){const Te=U.depthTexture;Te&&Te.isDepthTexture&&(Te.type===di?Re=n.DEPTH_COMPONENT32F:Te.type===Qs&&(Re=n.DEPTH_COMPONENT24));const Ee=Le(U);Ae(U)?l.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ee,Re,U.width,U.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,Re,U.width,U.height)}else n.renderbufferStorage(n.RENDERBUFFER,Re,U.width,U.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,N)}else if(U.depthBuffer&&U.stencilBuffer){const Re=Le(U);oe&&Ae(U)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Re,n.DEPTH24_STENCIL8,U.width,U.height):Ae(U)?l.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Re,n.DEPTH24_STENCIL8,U.width,U.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,U.width,U.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,N)}else{const Re=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let Te=0;Te0){oe.__webglFramebuffer[ke]=[];for(let Ye=0;Ye0){oe.__webglFramebuffer=[];for(let ke=0;ke0&&Ae(N)===!1){const ke=Ee?U:[U];oe.__webglMultisampledFramebuffer=n.createFramebuffer(),oe.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,oe.__webglMultisampledFramebuffer);for(let Ye=0;Ye0)for(let Ye=0;Ye0)for(let Ye=0;Ye0&&Ae(N)===!1){const U=N.isWebGLMultipleRenderTargets?N.texture:[N.texture],oe=N.width,Re=N.height;let Te=n.COLOR_BUFFER_BIT;const Ee=[],$e=N.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ke=i.get(N),Ye=N.isWebGLMultipleRenderTargets===!0;if(Ye)for(let ct=0;ct0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&U.__useRenderToTexture!==!1}function rt(N){const U=o.render.frame;f.get(N)!==U&&(f.set(N,U),N.update())}function Ve(N,U){const oe=N.colorSpace,Re=N.format,Te=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||N.format===Em||oe!==Ps&&oe!==ur&&(on.getTransfer(oe)===fn?a===!1?e.has("EXT_sRGB")===!0&&Re===Ti?(N.format=Em,N.minFilter=cn,N.generateMipmaps=!1):U=nA.sRGBToLinear(U):(Re!==Ti||Te!==ws)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",oe)),U}this.allocateTextureUnit=W,this.resetTextureUnits=ae,this.setTexture2D=ie,this.setTexture2DArray=fe,this.setTexture3D=H,this.setTextureCube=Q,this.rebindTextures=it,this.setupRenderTarget=K,this.updateRenderTargetMipmap=Be,this.updateMultisampleRenderTarget=xe,this.setupDepthRenderbuffer=et,this.setupFrameBufferTexture=Ue,this.useMultisampledRTT=Ae}function lb(n,e,t){const i=t.isWebGL2;function r(s,o=ur){let a;const l=on.getTransfer(o);if(s===ws)return n.UNSIGNED_BYTE;if(s===Wx)return n.UNSIGNED_SHORT_4_4_4_4;if(s===Xx)return n.UNSIGNED_SHORT_5_5_5_1;if(s===bR)return n.BYTE;if(s===BR)return n.SHORT;if(s===Jm)return n.UNSIGNED_SHORT;if(s===Vx)return n.INT;if(s===Qs)return n.UNSIGNED_INT;if(s===di)return n.FLOAT;if(s===Ci)return i?n.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===PR)return n.ALPHA;if(s===Ti)return n.RGBA;if(s===IR)return n.LUMINANCE;if(s===LR)return n.LUMINANCE_ALPHA;if(s===Yo)return n.DEPTH_COMPONENT;if(s===rl)return n.DEPTH_STENCIL;if(s===Em)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Jx)return n.RED;if(s===Yx)return n.RED_INTEGER;if(s===DR)return n.RG;if(s===Kx)return n.RG_INTEGER;if(s===Zx)return n.RGBA_INTEGER;if(s===Hp||s===Gp||s===Vp||s===Wp)if(l===fn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Hp)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Gp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Vp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Wp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Hp)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Gp)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Vp)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Wp)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===iy||s===ry||s===sy||s===oy)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===iy)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===ry)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===sy)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===oy)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Qx)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===ay||s===ly)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===ay)return l===fn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===ly)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===cy||s===uy||s===hy||s===fy||s===dy||s===py||s===my||s===gy||s===vy||s===_y||s===yy||s===xy||s===Ay||s===Sy)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===cy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===uy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===hy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===fy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===dy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===py)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===my)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===gy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===vy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===_y)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===yy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===xy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Ay)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Sy)return l===fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Xp||s===Ey||s===My)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Xp)return l===fn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Ey)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===My)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===UR||s===wy||s===Ty||s===Cy)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===Xp)return a.COMPRESSED_RED_RGTC1_EXT;if(s===wy)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Ty)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Cy)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Jo?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 cb extends jn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class js extends Jt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const jO={type:"move"};class _0{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new js,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 js,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new js,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k),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,l=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){o=!0;for(const S of e.hand.values()){const y=t.getJointPose(S,i),m=this._getHandJoint(h,S);y!==null&&(m.matrix.fromArray(y.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=y.radius),m.visible=y!==null}const f=h.joints["index-finger-tip"],d=h.joints["thumb-tip"],p=f.position.distanceTo(d.position),g=.02,_=.005;h.inputState.pinching&&p>g+_?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&p<=g-_&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));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(jO)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),h!==null&&(h.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new js;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class qO extends ao{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",l=1,h=null,f=null,d=null,p=null,g=null,_=null;const S=t.getContextAttributes();let y=null,m=null;const x=[],A=[],M=new Se;let C=null;const T=new jn;T.layers.enable(1),T.viewport=new rn;const R=new jn;R.layers.enable(2),R.viewport=new rn;const D=[T,R],b=new cb;b.layers.enable(1),b.layers.enable(2);let I=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(se){let _e=x[se];return _e===void 0&&(_e=new _0,x[se]=_e),_e.getTargetRaySpace()},this.getControllerGrip=function(se){let _e=x[se];return _e===void 0&&(_e=new _0,x[se]=_e),_e.getGripSpace()},this.getHand=function(se){let _e=x[se];return _e===void 0&&(_e=new _0,x[se]=_e),_e.getHandSpace()};function j(se){const _e=A.indexOf(se.inputSource);if(_e===-1)return;const Pe=x[_e];Pe!==void 0&&(Pe.update(se.inputSource,se.frame,h||o),Pe.dispatchEvent({type:se.type,data:se.inputSource}))}function ae(){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",ae),r.removeEventListener("inputsourceschange",W);for(let se=0;se=0&&(A[Me]=null,x[Me].disconnect(Pe))}for(let _e=0;_e=A.length){A.push(Pe),Me=nt;break}else if(A[nt]===null){A[nt]=Pe,Me=nt;break}if(Me===-1)break}const Ue=x[Me];Ue&&Ue.connect(Pe)}}const $=new k,ie=new k;function fe(se,_e,Pe){$.setFromMatrixPosition(_e.matrixWorld),ie.setFromMatrixPosition(Pe.matrixWorld);const Me=$.distanceTo(ie),Ue=_e.projectionMatrix.elements,nt=Pe.projectionMatrix.elements,_t=Ue[14]/(Ue[10]-1),et=Ue[14]/(Ue[10]+1),it=(Ue[9]+1)/Ue[5],K=(Ue[9]-1)/Ue[5],Be=(Ue[8]-1)/Ue[0],xe=(nt[8]+1)/nt[0],Le=_t*Be,Ae=_t*xe,rt=Me/(-Be+xe),Ve=rt*-Be;_e.matrixWorld.decompose(se.position,se.quaternion,se.scale),se.translateX(Ve),se.translateZ(rt),se.matrixWorld.compose(se.position,se.quaternion,se.scale),se.matrixWorldInverse.copy(se.matrixWorld).invert();const N=_t+rt,U=et+rt,oe=Le-Ve,Re=Ae+(Me-Ve),Te=it*et/U*N,Ee=K*et/U*N;se.projectionMatrix.makePerspective(oe,Re,Te,Ee,N,U),se.projectionMatrixInverse.copy(se.projectionMatrix).invert()}function H(se,_e){_e===null?se.matrixWorld.copy(se.matrix):se.matrixWorld.multiplyMatrices(_e.matrixWorld,se.matrix),se.matrixWorldInverse.copy(se.matrixWorld).invert()}this.updateCamera=function(se){if(r===null)return;b.near=R.near=T.near=se.near,b.far=R.far=T.far=se.far,(I!==b.near||O!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),I=b.near,O=b.far);const _e=se.parent,Pe=b.cameras;H(b,_e);for(let Me=0;Me0&&(y.alphaTest.value=m.alphaTest);const x=e.get(m).envMap;if(x&&(y.envMap.value=x,y.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=m.reflectivity,y.ior.value=m.ior,y.refractionRatio.value=m.refractionRatio),m.lightMap){y.lightMap.value=m.lightMap;const A=n._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=m.lightMapIntensity*A,t(m.lightMap,y.lightMapTransform)}m.aoMap&&(y.aoMap.value=m.aoMap,y.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,y.aoMapTransform))}function o(y,m){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,m.map&&(y.map.value=m.map,t(m.map,y.mapTransform))}function a(y,m){y.dashSize.value=m.dashSize,y.totalSize.value=m.dashSize+m.gapSize,y.scale.value=m.scale}function l(y,m,x,A){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,y.size.value=m.size*x,y.scale.value=A*.5,m.map&&(y.map.value=m.map,t(m.map,y.uvTransform)),m.alphaMap&&(y.alphaMap.value=m.alphaMap,t(m.alphaMap,y.alphaMapTransform)),m.alphaTest>0&&(y.alphaTest.value=m.alphaTest)}function h(y,m){y.diffuse.value.copy(m.color),y.opacity.value=m.opacity,y.rotation.value=m.rotation,m.map&&(y.map.value=m.map,t(m.map,y.mapTransform)),m.alphaMap&&(y.alphaMap.value=m.alphaMap,t(m.alphaMap,y.alphaMapTransform)),m.alphaTest>0&&(y.alphaTest.value=m.alphaTest)}function f(y,m){y.specular.value.copy(m.specular),y.shininess.value=Math.max(m.shininess,1e-4)}function d(y,m){m.gradientMap&&(y.gradientMap.value=m.gradientMap)}function p(y,m){y.metalness.value=m.metalness,m.metalnessMap&&(y.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,y.metalnessMapTransform)),y.roughness.value=m.roughness,m.roughnessMap&&(y.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,y.roughnessMapTransform)),e.get(m).envMap&&(y.envMapIntensity.value=m.envMapIntensity)}function g(y,m,x){y.ior.value=m.ior,m.sheen>0&&(y.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),y.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(y.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,y.sheenColorMapTransform)),m.sheenRoughnessMap&&(y.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,y.sheenRoughnessMapTransform))),m.clearcoat>0&&(y.clearcoat.value=m.clearcoat,y.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(y.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,y.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(y.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Ni&&y.clearcoatNormalScale.value.negate())),m.iridescence>0&&(y.iridescence.value=m.iridescence,y.iridescenceIOR.value=m.iridescenceIOR,y.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(y.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,y.iridescenceMapTransform)),m.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),m.transmission>0&&(y.transmission.value=m.transmission,y.transmissionSamplerMap.value=x.texture,y.transmissionSamplerSize.value.set(x.width,x.height),m.transmissionMap&&(y.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,y.transmissionMapTransform)),y.thickness.value=m.thickness,m.thicknessMap&&(y.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=m.attenuationDistance,y.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(y.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(y.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=m.specularIntensity,y.specularColor.value.copy(m.specularColor),m.specularColorMap&&(y.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,y.specularColorMapTransform)),m.specularIntensityMap&&(y.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,y.specularIntensityMapTransform))}function _(y,m){m.matcap&&(y.matcap.value=m.matcap)}function S(y,m){const x=e.get(m).light;y.referencePosition.value.setFromMatrixPosition(x.matrixWorld),y.nearDistance.value=x.shadow.camera.near,y.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function eN(n,e,t,i){let r={},s={},o=[];const a=t.isWebGL2?n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,A){const M=A.program;i.uniformBlockBinding(x,M)}function h(x,A){let M=r[x.id];M===void 0&&(_(x),M=f(x),r[x.id]=M,x.addEventListener("dispose",y));const C=A.program;i.updateUBOMapping(x,C);const T=e.render.frame;s[x.id]!==T&&(p(x),s[x.id]=T)}function f(x){const A=d();x.__bindingPointIndex=A;const M=n.createBuffer(),C=x.__size,T=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,M),n.bufferData(n.UNIFORM_BUFFER,C,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,M),M}function d(){for(let x=0;x0&&(M+=C-T),x.__size=M,x.__cache={},this}function S(x){const A={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(A.boundary=4,A.storage=4):x.isVector2?(A.boundary=8,A.storage=8):x.isVector3||x.isColor?(A.boundary=16,A.storage=12):x.isVector4?(A.boundary=16,A.storage=16):x.isMatrix3?(A.boundary=48,A.storage=48):x.isMatrix4?(A.boundary=64,A.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),A}function y(x){const A=x.target;A.removeEventListener("dispose",y);const M=o.indexOf(A.__bindingPointIndex);o.splice(M,1),n.deleteBuffer(r[A.id]),delete r[A.id],delete s[A.id]}function m(){for(const x in r)n.deleteBuffer(r[x]);o=[],r={},s={}}return{bind:l,update:h,dispose:m}}class hA{constructor(e={}){const{canvas:t=jR(),context:i=null,depth:r=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let p;i!==null?p=i.getContextAttributes().alpha:p=o;const g=new Uint32Array(4),_=new Int32Array(4);let S=null,y=null;const m=[],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=Qn,this._useLegacyLights=!1,this.toneMapping=Ms,this.toneMappingExposure=1;const A=this;let M=!1,C=0,T=0,R=null,D=-1,b=null;const I=new rn,O=new rn;let j=null;const ae=new Ne(0);let W=0,$=t.width,ie=t.height,fe=1,H=null,Q=null;const Y=new rn(0,0,$,ie),re=new rn(0,0,$,ie);let ue=!1;const se=new cf;let _e=!1,Pe=!1,Me=null;const Ue=new lt,nt=new Se,_t=new k,et={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function it(){return R===null?fe:1}let K=i;function Be(P,z){for(let G=0;G{function ce(){if(J.forEach(function(de){Ve.get(de).currentProgram.isReady()&&J.delete(de)}),J.size===0){X(P);return}setTimeout(ce,10)}xe.get("KHR_parallel_shader_compile")!==null?ce():setTimeout(ce,10)})};let $t=null;function En(P){$t&&$t(P)}function kn(){Yn.stop()}function tn(){Yn.start()}const Yn=new nb;Yn.setAnimationLoop(En),typeof self<"u"&&Yn.setContext(self),this.setAnimationLoop=function(P){$t=P,Ct.setAnimationLoop(P),P===null?Yn.stop():Yn.start()},Ct.addEventListener("sessionstart",kn),Ct.addEventListener("sessionend",tn),this.render=function(P,z){if(z!==void 0&&z.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),z.parent===null&&z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),Ct.enabled===!0&&Ct.isPresenting===!0&&(Ct.cameraAutoUpdate===!0&&Ct.updateCamera(z),z=Ct.getCamera()),P.isScene===!0&&P.onBeforeRender(A,P,z,R),y=ct.get(P,x.length),y.init(),x.push(y),Ue.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),se.setFromProjectionMatrix(Ue),Pe=this.localClippingEnabled,_e=yt.init(this.clippingPlanes,Pe),S=Ye.get(P,m.length),S.init(),m.push(S),Gi(P,z,0,A.sortObjects),S.finish(),A.sortObjects===!0&&S.sort(H,Q),this.info.render.frame++,_e===!0&&yt.beginShadows();const G=y.state.shadowsArray;if(Ce.render(G,P,z),_e===!0&&yt.endShadows(),this.info.autoReset===!0&&this.info.reset(),Gt.render(S,P),y.setupLights(A._useLegacyLights),z.isArrayCamera){const J=z.cameras;for(let X=0,ce=J.length;X0?y=x[x.length-1]:y=null,m.pop(),m.length>0?S=m[m.length-1]:S=null};function Gi(P,z,G,J){if(P.visible===!1)return;if(P.layers.test(z.layers)){if(P.isGroup)G=P.renderOrder;else if(P.isLOD)P.autoUpdate===!0&&P.update(z);else if(P.isLight)y.pushLight(P),P.castShadow&&y.pushShadow(P);else if(P.isSprite){if(!P.frustumCulled||se.intersectsSprite(P)){J&&_t.setFromMatrixPosition(P.matrixWorld).applyMatrix4(Ue);const de=Ee.update(P),ge=P.material;ge.visible&&S.push(P,de,ge,G,_t.z,null)}}else if((P.isMesh||P.isLine||P.isPoints)&&(!P.frustumCulled||se.intersectsObject(P))){const de=Ee.update(P),ge=P.material;if(J&&(P.boundingSphere!==void 0?(P.boundingSphere===null&&P.computeBoundingSphere(),_t.copy(P.boundingSphere.center)):(de.boundingSphere===null&&de.computeBoundingSphere(),_t.copy(de.boundingSphere.center)),_t.applyMatrix4(P.matrixWorld).applyMatrix4(Ue)),Array.isArray(ge)){const me=de.groups;for(let Xe=0,we=me.length;Xe0&&aa(X,ce,z,G),J&&Ae.viewport(I.copy(J)),X.length>0&&xr(X,z,G),ce.length>0&&xr(ce,z,G),de.length>0&&xr(de,z,G),Ae.buffers.depth.setTest(!0),Ae.buffers.depth.setMask(!0),Ae.buffers.color.setMask(!0),Ae.setPolygonOffset(!1)}function aa(P,z,G,J){if((G.isScene===!0?G.overrideMaterial:null)!==null)return;const ce=Le.isWebGL2;Me===null&&(Me=new ki(1,1,{generateMipmaps:!0,type:xe.has("EXT_color_buffer_half_float")?Ci:ws,minFilter:Bs,samples:ce?4:0})),A.getDrawingBufferSize(nt),ce?Me.setSize(nt.x,nt.y):Me.setSize(Mm(nt.x),Mm(nt.y));const de=A.getRenderTarget();A.setRenderTarget(Me),A.getClearColor(ae),W=A.getClearAlpha(),W<1&&A.setClearColor(16777215,.5),A.clear();const ge=A.toneMapping;A.toneMapping=Ms,xr(P,G,J),N.updateMultisampleRenderTarget(Me),N.updateRenderTargetMipmap(Me);let me=!1;for(let Xe=0,we=z.length;Xe0),be=!!G.morphAttributes.position,Qe=!!G.morphAttributes.normal,at=!!G.morphAttributes.color;let ht=Ms;J.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(ht=A.toneMapping);const Et=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Je=Et!==void 0?Et.length:0,Fe=Ve.get(J),Ot=y.state.lights;if(_e===!0&&(Pe===!0||P!==b)){const bt=P===b&&J.id===D;yt.setState(J,P,bt)}let mt=!1;J.version===Fe.__version?(Fe.needsLights&&Fe.lightsStateVersion!==Ot.state.version||Fe.outputColorSpace!==ge||X.isBatchedMesh&&Fe.batching===!1||!X.isBatchedMesh&&Fe.batching===!0||X.isInstancedMesh&&Fe.instancing===!1||!X.isInstancedMesh&&Fe.instancing===!0||X.isSkinnedMesh&&Fe.skinning===!1||!X.isSkinnedMesh&&Fe.skinning===!0||X.isInstancedMesh&&Fe.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&Fe.instancingColor===!1&&X.instanceColor!==null||Fe.envMap!==me||J.fog===!0&&Fe.fog!==ce||Fe.numClippingPlanes!==void 0&&(Fe.numClippingPlanes!==yt.numPlanes||Fe.numIntersection!==yt.numIntersection)||Fe.vertexAlphas!==Xe||Fe.vertexTangents!==we||Fe.morphTargets!==be||Fe.morphNormals!==Qe||Fe.morphColors!==at||Fe.toneMapping!==ht||Le.isWebGL2===!0&&Fe.morphTargetsCount!==Je)&&(mt=!0):(mt=!0,Fe.__version=J.version);let xt=Fe.currentProgram;mt===!0&&(xt=Rt(J,z,X));let sn=!1,Bn=!1,yn=!1;const Wt=xt.getUniforms(),kt=Fe.uniforms;if(Ae.useProgram(xt.program)&&(sn=!0,Bn=!0,yn=!0),J.id!==D&&(D=J.id,Bn=!0),sn||b!==P){Wt.setValue(K,"projectionMatrix",P.projectionMatrix),Wt.setValue(K,"viewMatrix",P.matrixWorldInverse);const bt=Wt.map.cameraPosition;bt!==void 0&&bt.setValue(K,_t.setFromMatrixPosition(P.matrixWorld)),Le.logarithmicDepthBuffer&&Wt.setValue(K,"logDepthBufFC",2/(Math.log(P.far+1)/Math.LN2)),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Wt.setValue(K,"isOrthographic",P.isOrthographicCamera===!0),b!==P&&(b=P,Bn=!0,yn=!0)}if(X.isSkinnedMesh){Wt.setOptional(K,X,"bindMatrix"),Wt.setOptional(K,X,"bindMatrixInverse");const bt=X.skeleton;bt&&(Le.floatVertexTextures?(bt.boneTexture===null&&bt.computeBoneTexture(),Wt.setValue(K,"boneTexture",bt.boneTexture,N)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}X.isBatchedMesh&&(Wt.setOptional(K,X,"batchingTexture"),Wt.setValue(K,"batchingTexture",X._matricesTexture,N));const Mn=G.morphAttributes;if((Mn.position!==void 0||Mn.normal!==void 0||Mn.color!==void 0&&Le.isWebGL2===!0)&&Bt.update(X,G,xt),(Bn||Fe.receiveShadow!==X.receiveShadow)&&(Fe.receiveShadow=X.receiveShadow,Wt.setValue(K,"receiveShadow",X.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(kt.envMap.value=me,kt.flipEnvMap.value=me.isCubeTexture&&me.isRenderTargetTexture===!1?-1:1),Bn&&(Wt.setValue(K,"toneMappingExposure",A.toneMappingExposure),Fe.needsLights&&F(kt,yn),ce&&J.fog===!0&&ke.refreshFogUniforms(kt,ce),ke.refreshMaterialUniforms(kt,J,fe,ie,Me),Yp.upload(K,la(Fe),kt,N)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(Yp.upload(K,la(Fe),kt,N),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Wt.setValue(K,"center",X.center),Wt.setValue(K,"modelViewMatrix",X.modelViewMatrix),Wt.setValue(K,"normalMatrix",X.normalMatrix),Wt.setValue(K,"modelMatrix",X.matrixWorld),J.isShaderMaterial||J.isRawShaderMaterial){const bt=J.uniformsGroups;for(let zt=0,un=bt.length;zt0&&N.useMultisampledRTT(P)===!1?X=Ve.get(P).__webglMultisampledFramebuffer:Array.isArray(we)?X=we[G]:X=we,I.copy(P.viewport),O.copy(P.scissor),j=P.scissorTest}else I.copy(Y).multiplyScalar(fe).floor(),O.copy(re).multiplyScalar(fe).floor(),j=ue;if(Ae.bindFramebuffer(K.FRAMEBUFFER,X)&&Le.drawBuffers&&J&&Ae.drawBuffers(P,X),Ae.viewport(I),Ae.scissor(O),Ae.setScissorTest(j),ce){const me=Ve.get(P.texture);K.framebufferTexture2D(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,K.TEXTURE_CUBE_MAP_POSITIVE_X+z,me.__webglTexture,G)}else if(de){const me=Ve.get(P.texture),Xe=z||0;K.framebufferTextureLayer(K.FRAMEBUFFER,K.COLOR_ATTACHMENT0,me.__webglTexture,G||0,Xe)}D=-1},this.readRenderTargetPixels=function(P,z,G,J,X,ce,de){if(!(P&&P.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=Ve.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&de!==void 0&&(ge=ge[de]),ge){Ae.bindFramebuffer(K.FRAMEBUFFER,ge);try{const me=P.texture,Xe=me.format,we=me.type;if(Xe!==Ti&&Ze.convert(Xe)!==K.getParameter(K.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const be=we===Ci&&(xe.has("EXT_color_buffer_half_float")||Le.isWebGL2&&xe.has("EXT_color_buffer_float"));if(we!==ws&&Ze.convert(we)!==K.getParameter(K.IMPLEMENTATION_COLOR_READ_TYPE)&&!(we===di&&(Le.isWebGL2||xe.has("OES_texture_float")||xe.has("WEBGL_color_buffer_float")))&&!be){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}z>=0&&z<=P.width-J&&G>=0&&G<=P.height-X&&K.readPixels(z,G,J,X,Ze.convert(Xe),Ze.convert(we),ce)}finally{const me=R!==null?Ve.get(R).__webglFramebuffer:null;Ae.bindFramebuffer(K.FRAMEBUFFER,me)}}},this.copyFramebufferToTexture=function(P,z,G=0){const J=Math.pow(2,-G),X=Math.floor(z.image.width*J),ce=Math.floor(z.image.height*J);N.setTexture2D(z,0),K.copyTexSubImage2D(K.TEXTURE_2D,G,0,0,P.x,P.y,X,ce),Ae.unbindTexture()},this.copyTextureToTexture=function(P,z,G,J=0){const X=z.image.width,ce=z.image.height,de=Ze.convert(G.format),ge=Ze.convert(G.type);N.setTexture2D(G,0),K.pixelStorei(K.UNPACK_FLIP_Y_WEBGL,G.flipY),K.pixelStorei(K.UNPACK_PREMULTIPLY_ALPHA_WEBGL,G.premultiplyAlpha),K.pixelStorei(K.UNPACK_ALIGNMENT,G.unpackAlignment),z.isDataTexture?K.texSubImage2D(K.TEXTURE_2D,J,P.x,P.y,X,ce,de,ge,z.image.data):z.isCompressedTexture?K.compressedTexSubImage2D(K.TEXTURE_2D,J,P.x,P.y,z.mipmaps[0].width,z.mipmaps[0].height,de,z.mipmaps[0].data):K.texSubImage2D(K.TEXTURE_2D,J,P.x,P.y,de,ge,z.image),J===0&&G.generateMipmaps&&K.generateMipmap(K.TEXTURE_2D),Ae.unbindTexture()},this.copyTextureToTexture3D=function(P,z,G,J,X=0){if(A.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const ce=P.max.x-P.min.x+1,de=P.max.y-P.min.y+1,ge=P.max.z-P.min.z+1,me=Ze.convert(J.format),Xe=Ze.convert(J.type);let we;if(J.isData3DTexture)N.setTexture3D(J,0),we=K.TEXTURE_3D;else if(J.isDataArrayTexture||J.isCompressedArrayTexture)N.setTexture2DArray(J,0),we=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,J.flipY),K.pixelStorei(K.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),K.pixelStorei(K.UNPACK_ALIGNMENT,J.unpackAlignment);const be=K.getParameter(K.UNPACK_ROW_LENGTH),Qe=K.getParameter(K.UNPACK_IMAGE_HEIGHT),at=K.getParameter(K.UNPACK_SKIP_PIXELS),ht=K.getParameter(K.UNPACK_SKIP_ROWS),Et=K.getParameter(K.UNPACK_SKIP_IMAGES),Je=G.isCompressedTexture?G.mipmaps[X]:G.image;K.pixelStorei(K.UNPACK_ROW_LENGTH,Je.width),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,Je.height),K.pixelStorei(K.UNPACK_SKIP_PIXELS,P.min.x),K.pixelStorei(K.UNPACK_SKIP_ROWS,P.min.y),K.pixelStorei(K.UNPACK_SKIP_IMAGES,P.min.z),G.isDataTexture||G.isData3DTexture?K.texSubImage3D(we,X,z.x,z.y,z.z,ce,de,ge,me,Xe,Je.data):G.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),K.compressedTexSubImage3D(we,X,z.x,z.y,z.z,ce,de,ge,me,Je.data)):K.texSubImage3D(we,X,z.x,z.y,z.z,ce,de,ge,me,Xe,Je),K.pixelStorei(K.UNPACK_ROW_LENGTH,be),K.pixelStorei(K.UNPACK_IMAGE_HEIGHT,Qe),K.pixelStorei(K.UNPACK_SKIP_PIXELS,at),K.pixelStorei(K.UNPACK_SKIP_ROWS,ht),K.pixelStorei(K.UNPACK_SKIP_IMAGES,Et),X===0&&J.generateMipmaps&&K.generateMipmap(we),Ae.unbindTexture()},this.initTexture=function(P){P.isCubeTexture?N.setTextureCube(P,0):P.isData3DTexture?N.setTexture3D(P,0):P.isDataArrayTexture||P.isCompressedArrayTexture?N.setTexture2DArray(P,0):N.setTexture2D(P,0),Ae.unbindTexture()},this.resetState=function(){C=0,T=0,R=null,Ae.reset(),gt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ts}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Km?"display-p3":"srgb",t.unpackColorSpace=on.workingColorSpace===sf?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Qn?Ko:$x}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ko?Qn:Ps}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 ub extends hA{}ub.prototype.isWebGL1Renderer=!0;class qm{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ne(e),this.density=t}clone(){return new qm(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class $m{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ne(e),this.near=t,this.far=i}clone(){return new $m(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}let Xh=class extends Jt{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 uf{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Vh,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=mr()}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:l,point:Ou.clone(),uv:Qi.getInterpolation(Ou,Qd,ku,jd,m1,y0,g1,new Se),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 qd(n,e,t,i,r,s){Jl.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Nu.x=s*Jl.x-r*Jl.y,Nu.y=r*Jl.x+s*Jl.y):Nu.copy(Jl),n.copy(e),n.x+=Nu.x,n.y+=Nu.y,n.applyMatrix4(hb)}const $d=new k,v1=new k;class db extends Jt{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){$d.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo($d);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){$d.setFromMatrixPosition(e.matrixWorld),v1.setFromMatrixPosition(this.matrixWorld);const i=$d.distanceTo(v1)/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 Kl="batchId",Eo=new lt,T1=new lt,aN=new lt,C1=new lt,S0=new cf,np=new $n,Sa=new ei,Gu=new k,E0=new oN,Mi=new Un,ip=[];function lN(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 Yt(a,1))}const o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(Kl,new Yt(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Kl))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Kl}"`);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===Kl)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 $n);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,l=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 h=e.getIndex(),f=h!==null;if(f&&(i===-1?r.indexCount=h.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,p=this._active,g=this._matricesTexture,_=this._matricesTexture.image.data;d.push(!0),p.push(!0);const S=this._geometryCount;this._geometryCount++,aN.toArray(_,S*16),g.needsUpdate=!0,o.push(r),a.push({start:f?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new $n,sphereInitialized:!1,sphere:new ei});const y=this.geometry.getAttribute(Kl);for(let m=0;m=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 l=a.vertexStart,h=a.vertexCount;for(const g in i.attributes){if(g===Kl)continue;const _=t.getAttribute(g),S=i.getAttribute(g);lN(_,S,l);const y=_.itemSize;for(let m=_.count,x=h;m=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,l=o.attributes.position,h=this._drawRanges[e];for(let f=h.start,d=h.start+h.count;f=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,l=this.geometry;Mi.material=this.material,Mi.geometry.index=l.index,Mi.geometry.attributes=l.attributes,Mi.geometry.boundingBox===null&&(Mi.geometry.boundingBox=new $n),Mi.geometry.boundingSphere===null&&(Mi.geometry.boundingSphere=new ei);for(let h=0;h({...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,l=this._visibility,h=this._multiDrawStarts,f=this._multiDrawCounts,d=this._drawRanges,p=this.perObjectFrustumCulled;p&&(C1.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),S0.setFromProjectionMatrix(C1,e.isWebGPURenderer?zc:ts));let g=0;if(this.sortObjects){T1.copy(this.matrixWorld).invert(),Gu.setFromMatrixPosition(i.matrixWorld).applyMatrix4(T1);for(let y=0,m=l.length;yl)continue;p.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(p);De.far||t.push({distance:D,point:d.clone().applyMatrix4(this.matrixWorld),index:A,face:null,faceIndex:null,object:this})}}else{const m=Math.max(0,o.start),x=Math.min(y.count,o.start+o.count);for(let A=m,M=x-1;Al)continue;p.applyMatrix4(this.matrixWorld);const T=e.ray.origin.distanceTo(p);Te.far||t.push({distance:T,point:d.clone().applyMatrix4(this.matrixWorld),index:A,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:h,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class cN extends _n{constructor(e,t,i,r,s,o,a,l,h){super(e,t,i,r,s,o,a,l,h),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:cn,this.magFilter=s!==void 0?s:cn,this.generateMipmaps=!1;const f=this;function d(){f.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 uN extends _n{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=An,this.minFilter=An,this.generateMipmaps=!1,this.needsUpdate=!0}}class ng extends _n{constructor(e,t,i,r,s,o,a,l,h,f,d,p){super(null,o,a,l,h,f,r,s,d,p),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class hN extends ng{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=fi}}class fN extends ng{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,bs),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class dN extends _n{constructor(e,t,i,r,s,o,a,l,h){super(e,t,i,r,s,o,a,l,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class os{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,l=s-1,h;for(;a<=l;)if(r=Math.floor(a+(l-a)/2),h=i[r]-o,h<0)a=r+1;else if(h>0)l=r-1;else{l=r;break}if(r=l,i[r]===o)return r/(s-1);const f=i[r],p=i[r+1]-f,g=(o-f)/p;return(r+g)/(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),l=t||(o.isVector2?new Se:new k);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new k,r=[],s=[],o=[],a=new k,l=new lt;for(let g=0;g<=e;g++){const _=g/e;r[g]=this.getTangentAt(_,new k)}s[0]=new k,o[0]=new k;let h=Number.MAX_VALUE;const f=Math.abs(r[0].x),d=Math.abs(r[0].y),p=Math.abs(r[0].z);f<=h&&(h=f,i.set(1,0,0)),d<=h&&(h=d,i.set(0,1,0)),p<=h&&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 g=1;g<=e;g++){if(s[g]=s[g-1].clone(),o[g]=o[g-1].clone(),a.crossVectors(r[g-1],r[g]),a.length()>Number.EPSILON){a.normalize();const _=Math.acos(Dn(r[g-1].dot(r[g]),-1,1));s[g].applyMatrix4(l.makeRotationAxis(a,_))}o[g].crossVectors(r[g],s[g])}if(t===!0){let g=Math.acos(Dn(s[0].dot(s[e]),-1,1));g/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(g=-g);for(let _=1;_<=e;_++)s[_].applyMatrix4(l.makeRotationAxis(r[_],g*_)),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 ig extends os{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,l=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=l}getPoint(e,t){const i=t||new Se,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:l===0&&a===s-1&&(a=s-2,l=1);let h,f;this.closed||a>0?h=r[(a-1)%s]:(ap.subVectors(r[0],r[1]).add(r[0]),h=ap);const d=r[a%s],p=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(U1(a,l.x,h.x,f.x,d.x),U1(a,l.y,h.y,f.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],l=a.getLength(),h=l===0?0:1-o/l;return a.getPointAt(h,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=h.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(h);const f=h.getPoint(1);return this.currentPoint.copy(f),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 ff extends Tt{constructor(e=[new Se(0,-.5),new Se(.5,0),new Se(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=[],l=[],h=[],f=1/t,d=new k,p=new Se,g=new k,_=new k,S=new k;let y=0,m=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:y=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,g.x=m*1,g.y=-y,g.z=m*0,S.copy(g),g.normalize(),l.push(g.x,g.y,g.z);break;case e.length-1:l.push(S.x,S.y,S.z);break;default:y=e[x+1].x-e[x].x,m=e[x+1].y-e[x].y,g.x=m*1,g.y=-y,g.z=m*0,_.copy(g),g.x+=S.x,g.y+=S.y,g.z+=S.z,g.normalize(),l.push(g.x,g.y,g.z),S.copy(_)}for(let x=0;x<=t;x++){const A=i+x*f*r,M=Math.sin(A),C=Math.cos(A);for(let T=0;T<=e.length-1;T++){d.x=e[T].x*M,d.y=e[T].y,d.z=e[T].x*C,o.push(d.x,d.y,d.z),p.x=x/t,p.y=T/(e.length-1),a.push(p.x,p.y);const R=l[3*T+0]*M,D=l[3*T+1],b=l[3*T+0]*C;h.push(R,D,b)}}for(let x=0;x0&&A(!0),t>0&&A(!1)),this.setIndex(f),this.setAttribute("position",new tt(d,3)),this.setAttribute("normal",new tt(p,3)),this.setAttribute("uv",new tt(g,2));function x(){const M=new k,C=new k;let T=0;const R=(t-e)/i;for(let D=0;D<=s;D++){const b=[],I=D/s,O=I*(t-e)+e;for(let j=0;j<=r;j++){const ae=j/r,W=ae*l+a,$=Math.sin(W),ie=Math.cos(W);C.x=O*$,C.y=-I*i+y,C.z=O*ie,d.push(C.x,C.y,C.z),M.set($,R,ie).normalize(),p.push(M.x,M.y,M.z),g.push(ae,1-I),b.push(_++)}S.push(b)}for(let D=0;D.9&&R<.1&&(A<.2&&(o[x+0]+=1),M<.2&&(o[x+2]+=1),C<.2&&(o[x+4]+=1))}}function p(x){s.push(x.x,x.y,x.z)}function g(x,A){const M=x*3;A.x=e[M+0],A.y=e[M+1],A.z=e[M+2]}function _(){const x=new k,A=new k,M=new k,C=new k,T=new Se,R=new Se,D=new Se;for(let b=0,I=0;b80*t){a=h=n[0],l=f=n[1];for(let _=t;_h&&(h=d),p>f&&(f=p);g=Math.max(h-a,f-l),g=g!==0?32767/g:0}return Yh(s,o,t,a,l,g,0),o}};function Ab(n,e,t,i,r){let s,o;if(r===ON(n,e,t,i)>0)for(s=e;s=e;s-=i)o=F1(s,n[s],n[s+1],o);return o&&lg(o,o.next)&&(Zh(o),o=o.next),o}function ol(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(lg(t,t.next)||Cn(t.prev,t,t.next)===0)){if(Zh(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Yh(n,e,t,i,r,s,o){if(!n)return;!o&&s&&PN(n,i,r,s);let a=n,l,h;for(;n.prev!==n.next;){if(l=n.prev,h=n.next,s?EN(n,i,r,s):SN(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(h.i/t|0),Zh(n),n=h.next,a=h.next;continue}if(n=h,n===a){o?o===1?(n=MN(ol(n),e,t),Yh(n,e,t,i,r,s,2)):o===2&&wN(n,e,t,i,r,s):Yh(ol(n),e,t,i,r,s,1);break}}}function SN(n){const e=n.prev,t=n,i=n.next;if(Cn(e,t,i)>=0)return!1;const r=e.x,s=t.x,o=i.x,a=e.y,l=t.y,h=i.y,f=rs?r>o?r:o:s>o?s:o,g=a>l?a>h?a:h:l>h?l:h;let _=i.next;for(;_!==e;){if(_.x>=f&&_.x<=p&&_.y>=d&&_.y<=g&&yc(r,a,s,l,o,h,_.x,_.y)&&Cn(_.prev,_,_.next)>=0)return!1;_=_.next}return!0}function EN(n,e,t,i){const r=n.prev,s=n,o=n.next;if(Cn(r,s,o)>=0)return!1;const a=r.x,l=s.x,h=o.x,f=r.y,d=s.y,p=o.y,g=al?a>h?a:h:l>h?l:h,y=f>d?f>p?f:p:d>p?d:p,m=Dy(g,_,e,t,i),x=Dy(S,y,e,t,i);let A=n.prevZ,M=n.nextZ;for(;A&&A.z>=m&&M&&M.z<=x;){if(A.x>=g&&A.x<=S&&A.y>=_&&A.y<=y&&A!==r&&A!==o&&yc(a,f,l,d,h,p,A.x,A.y)&&Cn(A.prev,A,A.next)>=0||(A=A.prevZ,M.x>=g&&M.x<=S&&M.y>=_&&M.y<=y&&M!==r&&M!==o&&yc(a,f,l,d,h,p,M.x,M.y)&&Cn(M.prev,M,M.next)>=0))return!1;M=M.nextZ}for(;A&&A.z>=m;){if(A.x>=g&&A.x<=S&&A.y>=_&&A.y<=y&&A!==r&&A!==o&&yc(a,f,l,d,h,p,A.x,A.y)&&Cn(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;M&&M.z<=x;){if(M.x>=g&&M.x<=S&&M.y>=_&&M.y<=y&&M!==r&&M!==o&&yc(a,f,l,d,h,p,M.x,M.y)&&Cn(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function MN(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!lg(r,s)&&Sb(r,i,i.next,s)&&Kh(r,s)&&Kh(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Zh(i),Zh(i.next),i=n=s),i=i.next}while(i!==n);return ol(i)}function wN(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&DN(o,a)){let l=Eb(o,a);o=ol(o,o.next),l=ol(l,l.next),Yh(o,e,t,i,r,s,0),Yh(l,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function TN(n,e,t,i){const r=[];let s,o,a,l,h;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){const p=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(p<=s&&p>i&&(i=p,r=t.x=t.x&&t.x>=l&&s!==t.x&&yc(or.x||t.x===r.x&&BN(r,t)))&&(r=t,f=d)),t=t.next;while(t!==a);return r}function BN(n,e){return Cn(n.prev,n,e.prev)<0&&Cn(e.next,n,n.next)<0}function PN(n,e,t,i){let r=n;do r.z===0&&(r.z=Dy(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,IN(r)}function IN(n){let e,t,i,r,s,o,a,l,h=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,h*=2}while(o>1);return n}function Dy(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 LN(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 DN(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!UN(n,e)&&(Kh(n,e)&&Kh(e,n)&&FN(n,e)&&(Cn(n.prev,n,e.prev)||Cn(n,e.prev,e))||lg(n,e)&&Cn(n.prev,n,n.next)>0&&Cn(e.prev,e,e.next)>0)}function Cn(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function lg(n,e){return n.x===e.x&&n.y===e.y}function Sb(n,e,t,i){const r=fp(Cn(n,e,t)),s=fp(Cn(n,e,i)),o=fp(Cn(t,i,n)),a=fp(Cn(t,i,e));return!!(r!==s&&o!==a||r===0&&hp(n,t,e)||s===0&&hp(n,i,e)||o===0&&hp(t,n,i)||a===0&&hp(t,e,i))}function hp(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 fp(n){return n>0?1:n<0?-1:0}function UN(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&&Sb(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Kh(n,e){return Cn(n.prev,n,n.next)<0?Cn(n,e,n.next)>=0&&Cn(n,n.prev,e)>=0:Cn(n,e,n.prev)<0||Cn(n,n.next,e)<0}function FN(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 Eb(n,e){const t=new Uy(n.i,n.x,n.y),i=new Uy(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 F1(n,e,t,i){const r=new Uy(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 Zh(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 Uy(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 ON(n,e,t,i){let r=0;for(let s=e,o=t-i;s2&&n[e-1].equals(n[0])&&n.pop()}function N1(n,e){for(let t=0;tNumber.EPSILON){const Ee=Math.sqrt(Re),$e=Math.sqrt(U*U+oe*oe),ke=Be.x-N/Ee,Ye=Be.y+Ve/Ee,ct=xe.x-oe/$e,yt=xe.y+U/$e,Ce=((ct-ke)*oe-(yt-Ye)*U)/(Ve*oe-N*U);Le=ke+Ve*Ce-K.x,Ae=Ye+N*Ce-K.y;const Gt=Le*Le+Ae*Ae;if(Gt<=2)return new Se(Le,Ae);rt=Math.sqrt(Gt/2)}else{let Ee=!1;Ve>Number.EPSILON?U>Number.EPSILON&&(Ee=!0):Ve<-Number.EPSILON?U<-Number.EPSILON&&(Ee=!0):Math.sign(N)===Math.sign(oe)&&(Ee=!0),Ee?(Le=-N,Ae=Ve,rt=Math.sqrt(Re)):(Le=Ve,Ae=N,rt=Math.sqrt(Re/2))}return new Se(Le/rt,Ae/rt)}const Q=[];for(let K=0,Be=W.length,xe=Be-1,Le=K+1;K=0;K--){const Be=K/y,xe=g*Math.cos(Be*Math.PI/2),Le=_*Math.sin(Be*Math.PI/2)+S;for(let Ae=0,rt=W.length;Ae=0;){const Le=xe;let Ae=xe-1;Ae<0&&(Ae=K.length-1);for(let rt=0,Ve=f+y*2;rt0)&&g.push(A,M,T),(m!==i-1||l0!=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 Cb extends Jn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ne(16777215),this.specular=new Ne(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ra,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rf,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 Rb extends Jn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ne(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ra,this.normalScale=new Se(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 bb extends Jn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ra,this.normalScale=new Se(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 EA extends Jn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ne(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ra,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rf,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 Bb extends Jn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ne(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ra,this.normalScale=new Se(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 Pb extends bi{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 Va(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 Ib(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Lb(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 Fy(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 l=0;l!==e;++l)r[o++]=n[a+l]}return r}function MA(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 HN(n,e,t,i,r=30){const s=n.clone();s.name=e;const o=[];for(let l=0;l=i)){d.push(h.times[g]);for(let S=0;Ss.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l=a.times[_]){const m=_*d+f,x=m+d-f;S=a.values.slice(m,x)}else{const m=a.createInterpolant(),x=f,A=d-f;m.evaluate(s),S=m.resultBuffer.slice(x,A)}l==="quaternion"&&new Xn().fromArray(S).normalize().conjugate().toArray(S);const y=h.times.length;for(let m=0;m=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 l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&Ib(r))for(let a=0,l=r.length;a!==l;++a){const h=r[a];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,h),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Jp,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*i,l=o*i,h=0;h!==i;++h)t[l+h]=t[a+h];++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}}as.prototype.TimeBufferType=Float32Array;as.prototype.ValueBufferType=Float32Array;as.prototype.DefaultInterpolation=sl;class hl extends as{}hl.prototype.ValueTypeName="bool";hl.prototype.ValueBufferType=Array;hl.prototype.DefaultInterpolation=kc;hl.prototype.InterpolantFactoryMethodLinear=void 0;hl.prototype.InterpolantFactoryMethodSmooth=void 0;class TA extends as{}TA.prototype.ValueTypeName="color";class Wc extends as{}Wc.prototype.ValueTypeName="number";class Ob extends iu{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,l=(i-t)/(r-t);let h=e*a;for(let f=h+a;h!==f;h+=4)Xn.slerpFlat(s,0,o,h-a,o,h,l);return s}}class ea extends as{InterpolantFactoryMethodLinear(e){return new Ob(this.times,this.values,this.getValueSize(),e)}}ea.prototype.ValueTypeName="quaternion";ea.prototype.DefaultInterpolation=sl;ea.prototype.InterpolantFactoryMethodSmooth=void 0;class fl extends as{}fl.prototype.ValueTypeName="string";fl.prototype.ValueBufferType=Array;fl.prototype.DefaultInterpolation=kc;fl.prototype.InterpolantFactoryMethodLinear=void 0;fl.prototype.InterpolantFactoryMethodSmooth=void 0;class Xc extends as{}Xc.prototype.ValueTypeName="vector";class Jc{constructor(e,t=-1,i,r=Ym){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=mr(),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(WN(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(as.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let a=0;a1){const d=f[1];let p=r[d];p||(r[d]=p=[]),p.push(h)}}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,p,g,_,S){if(g.length!==0){const y=[],m=[];MA(g,y,m,_),y.length!==0&&S.push(new d(p,y,m))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const h=e.hierarchy||[];for(let d=0;d{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ws[e]!==void 0){Ws[e].push({onLoad:t,onProgress:i,onError:r});return}Ws[e]=[],Ws[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,l=this.responseType;fetch(o).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const f=Ws[e],d=h.body.getReader(),p=h.headers.get("Content-Length")||h.headers.get("X-File-Size"),g=p?parseInt(p):0,_=g!==0;let S=0;const y=new ReadableStream({start(m){x();function x(){d.read().then(({done:A,value:M})=>{if(A)m.close();else{S+=M.byteLength;const C=new ProgressEvent("progress",{lengthComputable:_,loaded:S,total:g});for(let T=0,R=f.length;T{switch(l){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(f=>new DOMParser().parseFromString(f,a));case"json":return h.json();default:if(a===void 0)return h.text();{const d=/charset="?([^;"\s]*)"?/i.exec(a),p=d&&d[1]?d[1].toLowerCase():void 0,g=new TextDecoder(p);return h.arrayBuffer().then(_=>g.decode(_))}}}).then(h=>{qs.add(e,h);const f=Ws[e];delete Ws[e];for(let d=0,p=f.length;d{const f=Ws[e];if(f===void 0)throw this.manager.itemError(e),h;delete Ws[e];for(let d=0,p=f.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 JN extends Bi{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new vr(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(l){r?r(l):console.error(l),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 Ne().setHex(o.value);break;case"v2":r.uniforms[s].value=new Se().fromArray(o.value);break;case"v3":r.uniforms[s].value=new k().fromArray(o.value);break;case"v4":r.uniforms[s].value=new rn().fromArray(o.value);break;case"m3":r.uniforms[s].value=new Ft().fromArray(o.value);break;case"m4":r.uniforms[s].value=new lt().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 Se().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 Se().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:wb,SpriteMaterial:fA,RawShaderMaterial:Tb,ShaderMaterial:nr,PointsMaterial:tg,MeshPhysicalMaterial:Is,MeshStandardMaterial:gf,MeshPhongMaterial:Cb,MeshToonMaterial:Rb,MeshNormalMaterial:bb,MeshLambertMaterial:EA,MeshDepthMaterial:jm,MeshDistanceMaterial:uA,MeshBasicMaterial:fr,MeshMatcapMaterial:Bb,LineDashedMaterial:Pb,LineBasicMaterial:bi,Material:Jn};return new t[e]}}class Cs{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i0){const l=new CA(t);s=new Qh(l),s.setCrossOrigin(this.crossOrigin);for(let h=0,f=e.length;h0){r=new Qh(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o{const y=new $n;y.min.fromArray(S.boxMin),y.max.fromArray(S.boxMax);const m=new ei;return m.radius=S.sphereRadius,m.center.fromArray(S.sphereCenter),{boxInitialized:S.boxInitialized,box:y,sphereInitialized:S.sphereInitialized,sphere:m}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=h(e.matricesTexture.uuid);break;case"LOD":o=new db;break;case"Line":o=new so(a(e.geometry),l(e.material));break;case"LineLoop":o=new mA(a(e.geometry),l(e.material));break;case"LineSegments":o=new ss(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new gA(a(e.geometry),l(e.material));break;case"Sprite":o=new fb(l(e.material));break;case"Group":o=new js;break;case"Bone":o=new eg;break;default:o=new Jt}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 p=e.children;for(let g=0;g"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=qs.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(h=>{t&&t(h),s.manager.itemEnd(e)}).catch(h=>{r&&r(h)});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 l=fetch(e,a).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(h){return qs.add(e,h),t&&t(h),s.manager.itemEnd(e),h}).catch(function(h){r&&r(h),qs.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});qs.add(e,l),s.manager.itemStart(e)}}let dp;class LA{static getContext(){return dp===void 0&&(dp=new(window.AudioContext||window.webkitAudioContext)),dp}static setContext(e){dp=e}}class $N extends Bi{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new vr(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const h=l.slice(0);LA.getContext().decodeAudioData(h,function(d){t(d)}).catch(a)}catch(h){a(h)}},i,r);function a(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const J1=new lt,Y1=new lt,Ea=new lt;class ek{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new jn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new jn,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,Ea.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(Ka*t.fov*.5)/t.zoom;let a,l;Y1.elements[12]=-r,J1.elements[12]=r,a=-o*t.aspect+s,l=o*t.aspect+s,Ea.elements[0]=2*t.near/(l-a),Ea.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Ea),a=-o*t.aspect-s,l=o*t.aspect-s,Ea.elements[0]=2*t.near/(l-a),Ea.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Ea)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Y1),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(J1)}}class DA{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=K1(),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=K1();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function K1(){return(typeof performance>"u"?Date:performance).now()}const Ma=new k,Z1=new Xn,tk=new k,wa=new k;class nk extends Jt{constructor(){super(),this.type="AudioListener",this.context=LA.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new DA}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(Ma,Z1,tk),wa.set(0,0,-1).applyQuaternion(Z1),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ma.x,r),t.positionY.linearRampToValueAtTime(Ma.y,r),t.positionZ.linearRampToValueAtTime(Ma.z,r),t.forwardX.linearRampToValueAtTime(wa.x,r),t.forwardY.linearRampToValueAtTime(wa.y,r),t.forwardZ.linearRampToValueAtTime(wa.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(Ma.x,Ma.y,Ma.z),t.setOrientation(wa.x,wa.y,wa.z,i.x,i.y,i.z)}}class Zb extends Jt{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 l=t,h=t+t;l!==h;++l)if(i[l]!==i[l+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){Xn.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const o=this._workIndex*s;Xn.multiplyQuaternionsFlat(e,o,e,t,e,i),Xn.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 l=t+a;e[l]=e[l]*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 UA="\\[\\]\\.:\\/",ok=new RegExp("["+UA+"]","g"),FA="[^"+UA+"]",ak="[^"+UA.replace("\\.","")+"]",lk=/((?:WC+[\/:])*)/.source.replace("WC",FA),ck=/(WCOD+)?/.source.replace("WCOD",ak),uk=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",FA),hk=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",FA),fk=new RegExp("^"+lk+ck+uk+hk+"$"),dk=["material","materials","bones","map"];class pk{constructor(e,t,i){const r=i||Xt.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 Xt{constructor(e,t,i){this.path=t,this.parsedPath=i||Xt.parseTrackName(t),this.node=Xt.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 Xt.Composite(e,t,i):new Xt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ok,"")}static parseTrackName(e){const t=fk.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);dk.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++,p=e[d];t[p.uuid]=f,e[f]=p,t[h]=d,e[d]=l;for(let g=0,_=r;g!==_;++g){const S=i[g],y=S[d],m=S[f];S[f]=y,S[d]=m}}}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,l=arguments.length;a!==l;++a){const h=arguments[a],f=h.uuid,d=t[f];if(d!==void 0)if(delete t[f],d0&&(t[g.uuid]=d),e[d]=g,e.pop();for(let _=0,S=r;_!==S;++_){const y=i[_];y[d]=y[p],y.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,l=this._objects,h=l.length,f=this.nCachedObjects_,d=new Array(h);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let p=f,g=l.length;p!==g;++p){const _=l[p];d[p]=new Xt(_,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,l=o[a],h=e[a];t[h]=i,o[i]=l,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}}class jb{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),l={endingStart:ka,endingEnd:ka};for(let h=0;h!==o;++h){const f=s[h].createInterpolant(null);a[h]=f,f.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=OR,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 l=a.parameterPositions,h=a.sampleValues;return l[0]=s,l[1]=s+i,h[0]=e/o,h[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 l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case jx:for(let f=0,d=l.length;f!==d;++f)l[f].evaluate(o),h[f].accumulateAdditive(a);break;case Ym:default:for(let f=0,d=l.length;f!==d;++f)l[f].evaluate(o),h[f].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===NR;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===FR){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 l=this.repetitions-s;if(l<=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(l===1){const h=e<0;this._setEndings(h,!h,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=za,r.endingEnd=za):(e?r.endingStart=this.zeroSlopeAtStart?za:ka:r.endingStart=kh,t?r.endingEnd=this.zeroSlopeAtEnd?za:ka:r.endingEnd=kh)}_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,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=i,this}}const gk=new Float32Array(1);class qb extends ao{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,l=i.uuid,h=this._bindingsByRootAndName;let f=h[l];f===void 0&&(f={},h[l]=f);for(let d=0;d!==s;++d){const p=r[d],g=p.name;let _=f[g];if(_!==void 0)++_.referenceCount,o[d]=_;else{if(_=o[d],_!==void 0){_._cacheIndex===null&&(++_.referenceCount,this._addInactiveBinding(_,l,g));continue}const S=t&&t._propertyBindings[d].binding.parsedPath;_=new Qb(Xt.create(i,g,S),p.ValueTypeName,p.getValueSize()),++_.referenceCount,this._addInactiveBinding(_,l,g),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 h=0;h!==i;++h)t[h]._update(r,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let h=0;h!==l;++h)a[h].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,q1).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 $1=new k,pp=new k;class Ek{constructor(e=new k,t=new k){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){$1.subVectors(e,this.start),pp.subVectors(this.end,this.start);const i=pp.dot(pp);let s=pp.dot($1)/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 ew=new k;class Mk extends Jt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Tt,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,l=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{sw.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(sw,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 Ok extends ss{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 Tt;r.setAttribute("position",new tt(t,3)),r.setAttribute("color",new tt(i,3));const s=new bi({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new Ne,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 Nk{constructor(){this.type="ShapePath",this.color=new Ne,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Jh,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(m){const x=[];for(let A=0,M=m.length;ANumber.EPSILON){if(I<0&&(R=x[T],b=-b,D=x[C],I=-I),m.yD.y)continue;if(m.y===R.y){if(m.x===R.x)return!0}else{const O=I*(m.x-R.x)-b*(m.y-R.y);if(O===0)return!0;if(O<0)continue;M=!M}}else{if(m.y!==R.y)continue;if(D.x<=m.x&&m.x<=R.x||R.x<=m.x&&m.x<=D.x)return!0}}return M}const r=Ts.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const h=[];if(s.length===1)return a=s[0],l=new qa,l.curves=a.curves,h.push(l),h;let f=!r(s[0].getPoints());f=e?!f:f;const d=[],p=[];let g=[],_=0,S;p[_]=void 0,g[_]=[];for(let m=0,x=s.length;m1){let m=!1,x=0;for(let A=0,M=p.length;A0&&m===!1&&(g=d)}let y;for(let m=0,x=p.length;m{const d=typeof h=="function"?h(e):h;if(d!==e){const p=e;e=f?d:Object.assign({},e,d),t.forEach(g=>g(e,p))}},r=()=>e,s=(h,f=r,d=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let p=f(e);function g(){const _=f(e);if(!d(p,_)){const S=p;h(p=_,S)}}return t.add(g),()=>t.delete(g)},l={setState:i,getState:r,subscribe:(h,f,d)=>f||d?s(h,f,d):(t.add(h),()=>t.delete(h)),destroy:()=>t.clear()};return e=n(i,r,l),l}const Hk=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),ow=Hk?ee.useEffect:ee.useLayoutEffect;function nB(n){const e=typeof n=="function"?zk(n):n,t=(i=e.getState,r=Object.is)=>{const[,s]=ee.useReducer(y=>y+1,0),o=e.getState(),a=ee.useRef(o),l=ee.useRef(i),h=ee.useRef(r),f=ee.useRef(!1),d=ee.useRef();d.current===void 0&&(d.current=i(o));let p,g=!1;(a.current!==o||l.current!==i||h.current!==r||f.current)&&(p=i(o),g=!r(d.current,p)),ow(()=>{g&&(d.current=p),a.current=o,l.current=i,h.current=r,f.current=!1});const _=ee.useRef(o);ow(()=>{const y=()=>{try{const x=e.getState(),A=l.current(x);h.current(d.current,A)||(a.current=x,d.current=A,s())}catch{f.current=!0,s()}},m=e.subscribe(y);return e.getState()!==_.current&&y(),m},[]);const S=g?p:d.current;return ee.useDebugValue(S),S};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 iB={exports:{}},rB={exports:{}},sB={};/** * @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(H,Q){var Y=H.length;H.push(Q);e:for(;0>>1,ue=H[re];if(0>>1;rer(Pe,Y))Mer(Ue,Pe)?(H[re]=Ue,H[Me]=Y,re=Me):(H[re]=Pe,H[_e]=Y,re=_e);else if(Mer(Ue,Y))H[re]=Ue,H[Me]=Y,re=Me;else break e}}return Q}function r(H,Q){var Y=H.sortIndex-Q.sortIndex;return Y!==0?Y:H.id-Q.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 l=[],h=[],f=1,d=null,p=3,g=!1,_=!1,S=!1,y=typeof setTimeout=="function"?setTimeout:null,m=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 A(H){for(var Q=t(h);Q!==null;){if(Q.callback===null)i(h);else if(Q.startTime<=H)i(h),Q.sortIndex=Q.expirationTime,e(l,Q);else break;Q=t(h)}}function M(H){if(S=!1,A(H),!_)if(t(l)!==null)_=!0,ie(C);else{var Q=t(h);Q!==null&&fe(M,Q.startTime-H)}}function C(H,Q){_=!1,S&&(S=!1,m(D),D=-1),g=!0;var Y=p;try{for(A(Q),d=t(l);d!==null&&(!(d.expirationTime>Q)||H&&!O());){var re=d.callback;if(typeof re=="function"){d.callback=null,p=d.priorityLevel;var ue=re(d.expirationTime<=Q);Q=n.unstable_now(),typeof ue=="function"?d.callback=ue:d===t(l)&&i(l),A(Q)}else i(l);d=t(l)}if(d!==null)var se=!0;else{var _e=t(h);_e!==null&&fe(M,_e.startTime-Q),se=!1}return se}finally{d=null,p=Y,g=!1}}var T=!1,R=null,D=-1,b=5,I=-1;function O(){return!(n.unstable_now()-IH||125re?(H.sortIndex=Y,e(h,H),t(l)===null&&H===t(h)&&(S?(m(D),D=-1):S=!0,fe(M,Y-re))):(H.sortIndex=ue,e(l,H),_||g||(_=!0,ie(C))),H},n.unstable_shouldYield=O,n.unstable_wrapCallback=function(H){var Q=p;return function(){var Y=p;p=Q;try{return H.apply(this,arguments)}finally{p=Y}}}})(sB);rB.exports=sB;var Ny=rB.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 Gk=function(e){var t={},i=ee,r=Ny,s=Object.assign;function o(c){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+c,v=1;vte||w[V]!==B[te]){var ve=` `+w[V].replace(" at new "," at ");return c.displayName&&ve.includes("")&&(ve=ve.replace("",c.displayName)),ve}while(1<=V&&0<=te);break}}}finally{we=!1,Error.prepareStackTrace=v}return(c=c?c.displayName||c.name:"")?Xe(c):""}var Qe=Object.prototype.hasOwnProperty,at=[],ht=-1;function Et(c){return{current:c}}function Je(c){0>ht||(c.current=at[ht],at[ht]=null,ht--)}function Fe(c,u){ht++,at[ht]=c.current,c.current=u}var Ot={},mt=Et(Ot),xt=Et(!1),sn=Ot;function Bn(c,u){var v=c.type.contextTypes;if(!v)return Ot;var E=c.stateNode;if(E&&E.__reactInternalMemoizedUnmaskedChildContext===u)return E.__reactInternalMemoizedMaskedChildContext;var w={},B;for(B in v)w[B]=u[B];return E&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=u,c.__reactInternalMemoizedMaskedChildContext=w),w}function yn(c){return c=c.childContextTypes,c!=null}function Wt(){Je(xt),Je(mt)}function kt(c,u,v){if(mt.current!==Ot)throw Error(o(168));Fe(mt,u),Fe(xt,v)}function Mn(c,u,v){var E=c.stateNode;if(u=u.childContextTypes,typeof E.getChildContext!="function")return v;E=E.getChildContext();for(var w in E)if(!(w in u))throw Error(o(108,D(c)||"Unknown",w));return s({},v,E)}function bt(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||Ot,sn=mt.current,Fe(mt,c),Fe(xt,xt.current),!0}function zt(c,u,v){var E=c.stateNode;if(!E)throw Error(o(169));v?(c=Mn(c,u,sn),E.__reactInternalMemoizedMergedChildContext=c,Je(xt),Je(mt),Fe(mt,c)):Je(xt),Fe(xt,v)}var un=Math.clz32?Math.clz32:cs,Ar=Math.log,Pi=Math.LN2;function cs(c){return c>>>=0,c===0?32:31-(Ar(c)/Pi|0)|0}var yf=64,xf=4194304;function ou(c){switch(c&-c){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 c&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return c&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return c}}function Af(c,u){var v=c.pendingLanes;if(v===0)return 0;var E=0,w=c.suspendedLanes,B=c.pingedLanes,V=v&268435455;if(V!==0){var te=V&~w;te!==0?E=ou(te):(B&=V,B!==0&&(E=ou(B)))}else V=v&~w,V!==0?E=ou(V):B!==0&&(E=ou(B));if(E===0)return 0;if(u!==0&&u!==E&&!(u&w)&&(w=E&-E,B=u&-u,w>=B||w===16&&(B&4194240)!==0))return u;if(E&4&&(E|=v&16),u=c.entangledLanes,u!==0)for(c=c.entanglements,u&=E;0v;v++)u.push(c);return u}function au(c,u,v){c.pendingLanes|=u,u!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,u=31-un(u),c[u]=v}function JB(c,u){var v=c.pendingLanes&~u;c.pendingLanes=u,c.suspendedLanes=0,c.pingedLanes=0,c.expiredLanes&=u,c.mutableReadLanes&=u,c.entangledLanes&=u,u=c.entanglements;var E=c.eventTimes;for(c=c.expirationTimes;0>=V,w-=V,Us=1<<32-un(u)+w|v<Qt?(si=wt,wt=null):si=wt.sibling;var jt=ft(le,wt,pe[Qt],We);if(jt===null){wt===null&&(wt=si);break}c&&wt&&jt.alternate===null&&u(le,wt),ne=B(jt,ne,Qt),Ut===null?st=jt:Ut.sibling=jt,Ut=jt,wt=si}if(Qt===pe.length)return v(le,wt),xn&&ua(le,Qt),st;if(wt===null){for(;QtQt?(si=wt,wt=null):si=wt.sibling;var go=ft(le,wt,jt.value,We);if(go===null){wt===null&&(wt=si);break}c&&wt&&go.alternate===null&&u(le,wt),ne=B(go,ne,Qt),Ut===null?st=go:Ut.sibling=go,Ut=go,wt=si}if(jt.done)return v(le,wt),xn&&ua(le,Qt),st;if(wt===null){for(;!jt.done;Qt++,jt=pe.next())jt=Mt(le,jt.value,We),jt!==null&&(ne=B(jt,ne,Qt),Ut===null?st=jt:Ut.sibling=jt,Ut=jt);return xn&&ua(le,Qt),st}for(wt=E(le,wt);!jt.done;Qt++,jt=pe.next())jt=ln(wt,le,Qt,jt.value,We),jt!==null&&(c&&jt.alternate!==null&&wt.delete(jt.key===null?Qt:jt.key),ne=B(jt,ne,Qt),Ut===null?st=jt:Ut.sibling=jt,Ut=jt);return c&&wt.forEach(function(PP){return u(le,PP)}),xn&&ua(le,Qt),st}function br(le,ne,pe,We){if(typeof pe=="object"&&pe!==null&&pe.type===f&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case l:e:{for(var st=pe.key,Ut=ne;Ut!==null;){if(Ut.key===st){if(st=pe.type,st===f){if(Ut.tag===7){v(le,Ut.sibling),ne=w(Ut,pe.props.children),ne.return=le,le=ne;break e}}else if(Ut.elementType===st||typeof st=="object"&&st!==null&&st.$$typeof===A&&oS(st)===Ut.type){v(le,Ut.sibling),ne=w(Ut,pe.props),ne.ref=uu(le,Ut,pe),ne.return=le,le=ne;break e}v(le,Ut);break}else u(le,Ut);Ut=Ut.sibling}pe.type===f?(ne=va(pe.props.children,le.mode,We,pe.key),ne.return=le,le=ne):(We=cd(pe.type,pe.key,pe.props,null,le.mode,We),We.ref=uu(le,ne,pe),We.return=le,le=We)}return V(le);case h:e:{for(Ut=pe.key;ne!==null;){if(ne.key===Ut)if(ne.tag===4&&ne.stateNode.containerInfo===pe.containerInfo&&ne.stateNode.implementation===pe.implementation){v(le,ne.sibling),ne=w(ne,pe.children||[]),ne.return=le,le=ne;break e}else{v(le,ne);break}else u(le,ne);ne=ne.sibling}ne=Sv(pe,le.mode,We),ne.return=le,le=ne}return V(le);case A:return Ut=pe._init,br(le,ne,Ut(pe._payload),We)}if($(pe))return ot(le,ne,pe,We);if(T(pe))return yi(le,ne,pe,We);If(le,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"?(pe=""+pe,ne!==null&&ne.tag===6?(v(le,ne.sibling),ne=w(ne,pe),ne.return=le,le=ne):(v(le,ne),ne=Av(pe,le.mode,We),ne.return=le,le=ne),V(le)):v(le,ne)}return br}var xl=aS(!0),lS=aS(!1),hu={},wr=Et(hu),fu=Et(hu),Al=Et(hu);function ps(c){if(c===hu)throw Error(o(174));return c}function kg(c,u){Fe(Al,u),Fe(fu,c),Fe(wr,hu),c=fe(u),Je(wr),Fe(wr,c)}function Sl(){Je(wr),Je(fu),Je(Al)}function cS(c){var u=ps(Al.current),v=ps(wr.current);u=H(v,c.type,u),v!==u&&(Fe(fu,c),Fe(wr,u))}function zg(c){fu.current===c&&(Je(wr),Je(fu))}var wn=Et(0);function Lf(c){for(var u=c;u!==null;){if(u.tag===13){var v=u.memoizedState;if(v!==null&&(v=v.dehydrated,v===null||ls(v)||aa(v)))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===c)break;for(;u.sibling===null;){if(u.return===null||u.return===c)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var Hg=[];function Gg(){for(var c=0;cv?v:4,c(!0);var E=Tr.transition;Tr.transition={};try{c(!1),u()}finally{Zt=v,Tr.transition=E}}function ES(){return ms().memoizedState}function rP(c,u,v){var E=fo(c);v={lane:E,action:v,hasEagerState:!1,eagerState:null,next:null},MS(c)?wS(u,v):(TS(c,u,v),v=Li(),c=Cr(c,E,v),c!==null&&CS(c,u,E))}function sP(c,u,v){var E=fo(c),w={lane:E,action:v,hasEagerState:!1,eagerState:null,next:null};if(MS(c))wS(u,w);else{TS(c,u,w);var B=c.alternate;if(c.lanes===0&&(B===null||B.lanes===0)&&(B=u.lastRenderedReducer,B!==null))try{var V=u.lastRenderedState,te=B(V,v);if(w.hasEagerState=!0,w.eagerState=te,hs(te,V))return}catch{}finally{}v=Li(),c=Cr(c,E,v),c!==null&&CS(c,u,E)}}function MS(c){var u=c.alternate;return c===Pn||u!==null&&u===Pn}function wS(c,u){du=Uf=!0;var v=c.pending;v===null?u.next=u:(u.next=v.next,v.next=u),c.pending=u}function TS(c,u,v){zn!==null&&c.mode&1&&!(Nt&2)?(c=u.interleaved,c===null?(v.next=v,ds===null?ds=[u]:ds.push(u)):(v.next=c.next,c.next=v),u.interleaved=v):(c=u.pending,c===null?v.next=v:(v.next=c.next,c.next=v),u.pending=v)}function CS(c,u,v){if(v&4194240){var E=u.lanes;E&=c.pendingLanes,v|=E,u.lanes=v,Sg(c,v)}}var zf={readContext:Sr,useCallback:vi,useContext:vi,useEffect:vi,useImperativeHandle:vi,useInsertionEffect:vi,useLayoutEffect:vi,useMemo:vi,useReducer:vi,useRef:vi,useState:vi,useDebugValue:vi,useDeferredValue:vi,useTransition:vi,useMutableSource:vi,useSyncExternalStore:vi,useId:vi,unstable_isNewReconciler:!1},oP={readContext:Sr,useCallback:function(c,u){return Os().memoizedState=[c,u===void 0?null:u],c},useContext:Sr,useEffect:Yg,useImperativeHandle:function(c,u,v){return v=v!=null?v.concat([c]):null,Nf(4194308,4,yS.bind(null,u,c),v)},useLayoutEffect:function(c,u){return Nf(4194308,4,c,u)},useInsertionEffect:function(c,u){return Nf(4,2,c,u)},useMemo:function(c,u){var v=Os();return u=u===void 0?null:u,c=c(),v.memoizedState=[c,u],c},useReducer:function(c,u,v){var E=Os();return u=v!==void 0?v(u):u,E.memoizedState=E.baseState=u,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:u},E.queue=c,c=c.dispatch=rP.bind(null,Pn,c),[E.memoizedState,c]},useRef:function(c){var u=Os();return c={current:c},u.memoizedState=c},useState:Jg,useDebugValue:Kg,useDeferredValue:function(c){var u=Jg(c),v=u[0],E=u[1];return Yg(function(){var w=Tr.transition;Tr.transition={};try{E(c)}finally{Tr.transition=w}},[c]),v},useTransition:function(){var c=Jg(!1),u=c[0];return c=iP.bind(null,c[1]),Os().memoizedState=c,[u,c]},useMutableSource:function(){},useSyncExternalStore:function(c,u,v){var E=Pn,w=Os();if(xn){if(v===void 0)throw Error(o(407));v=v()}else{if(v=u(),zn===null)throw Error(o(349));El&30||fS(E,u,v)}w.memoizedState=v;var B={value:v,getSnapshot:u};return w.queue=B,Yg(pS.bind(null,E,B,c),[c]),E.flags|=2048,mu(9,dS.bind(null,E,B,v,u),void 0,null),v},useId:function(){var c=Os(),u=zn.identifierPrefix;if(xn){var v=Fs,E=Us;v=(E&~(1<<32-un(E)-1)).toString(32)+v,u=":"+u+"R"+v,v=pu++,0dv&&(u.flags|=128,E=!0,yu(w,!1),u.lanes=4194304)}else{if(!E)if(c=Lf(B),c!==null){if(u.flags|=128,E=!0,c=c.updateQueue,c!==null&&(u.updateQueue=c,u.flags|=4),yu(w,!0),w.tail===null&&w.tailMode==="hidden"&&!B.alternate&&!xn)return _i(u),null}else 2*ii()-w.renderingStartTime>dv&&v!==1073741824&&(u.flags|=128,E=!0,yu(w,!1),u.lanes=4194304);w.isBackwards?(B.sibling=u.child,u.child=B):(c=w.last,c!==null?c.sibling=B:u.child=B,w.last=B)}return w.tail!==null?(u=w.tail,w.rendering=u,w.tail=u.sibling,w.renderingStartTime=ii(),u.sibling=null,c=wn.current,Fe(wn,E?c&1|2:c&1),u):(_i(u),null);case 22:case 23:return _v(),E=u.memoizedState!==null,c!==null&&c.memoizedState!==null!==E&&(u.flags|=8192),E&&u.mode&1?or&1073741824&&(_i(u),it&&u.subtreeFlags&6&&(u.flags|=8192)):_i(u),null;case 24:return null;case 25:return null}throw Error(o(156,u.tag))}var hP=a.ReactCurrentOwner,sr=!1;function Ii(c,u,v,E){u.child=c===null?lS(u,null,v,E):xl(u,c.child,v,E)}function US(c,u,v,E,w){v=v.render;var B=u.ref;return gl(u,w),E=Wg(c,u,v,E,B,w),v=Xg(),c!==null&&!sr?(u.updateQueue=c.updateQueue,u.flags&=-2053,c.lanes&=~w,Ns(c,u,w)):(xn&&v&&Dg(u),u.flags|=1,Ii(c,u,E,w),u.child)}function FS(c,u,v,E,w){if(c===null){var B=v.type;return typeof B=="function"&&!xv(B)&&B.defaultProps===void 0&&v.compare===null&&v.defaultProps===void 0?(u.tag=15,u.type=B,OS(c,u,B,E,w)):(c=cd(v.type,null,E,u,u.mode,w),c.ref=u.ref,c.return=u,u.child=c)}if(B=c.child,!(c.lanes&w)){var V=B.memoizedProps;if(v=v.compare,v=v!==null?v:Mf,v(V,E)&&c.ref===u.ref)return Ns(c,u,w)}return u.flags|=1,c=mo(B,E),c.ref=u.ref,c.return=u,u.child=c}function OS(c,u,v,E,w){if(c!==null&&Mf(c.memoizedProps,E)&&c.ref===u.ref)if(sr=!1,(c.lanes&w)!==0)c.flags&131072&&(sr=!0);else return u.lanes=c.lanes,Ns(c,u,w);return jg(c,u,v,E,w)}function NS(c,u,v){var E=u.pendingProps,w=E.children,B=c!==null?c.memoizedState:null;if(E.mode==="hidden")if(!(u.mode&1))u.memoizedState={baseLanes:0,cachePool:null},Fe(Ml,or),or|=v;else if(v&1073741824)u.memoizedState={baseLanes:0,cachePool:null},E=B!==null?B.baseLanes:v,Fe(Ml,or),or|=E;else return c=B!==null?B.baseLanes|v:v,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:c,cachePool:null},u.updateQueue=null,Fe(Ml,or),or|=c,null;else B!==null?(E=B.baseLanes|v,u.memoizedState=null):E=v,Fe(Ml,or),or|=E;return Ii(c,u,w,v),u.child}function kS(c,u){var v=u.ref;(c===null&&v!==null||c!==null&&c.ref!==v)&&(u.flags|=512,u.flags|=2097152)}function jg(c,u,v,E,w){var B=yn(v)?sn:mt.current;return B=Bn(u,B),gl(u,w),v=Wg(c,u,v,E,B,w),E=Xg(),c!==null&&!sr?(u.updateQueue=c.updateQueue,u.flags&=-2053,c.lanes&=~w,Ns(c,u,w)):(xn&&E&&Dg(u),u.flags|=1,Ii(c,u,v,w),u.child)}function zS(c,u,v,E,w){if(yn(v)){var B=!0;bt(u)}else B=!1;if(gl(u,w),u.stateNode===null)c!==null&&(c.alternate=null,u.alternate=null,u.flags|=2),eS(u,v,E),Lg(u,v,E,w),E=!0;else if(c===null){var V=u.stateNode,te=u.memoizedProps;V.props=te;var ve=V.context,De=v.contextType;typeof De=="object"&&De!==null?De=Sr(De):(De=yn(v)?sn:mt.current,De=Bn(u,De));var qe=v.getDerivedStateFromProps,Mt=typeof qe=="function"||typeof V.getSnapshotBeforeUpdate=="function";Mt||typeof V.UNSAFE_componentWillReceiveProps!="function"&&typeof V.componentWillReceiveProps!="function"||(te!==E||ve!==De)&&tS(u,V,E,De),lo=!1;var ft=u.memoizedState;V.state=ft,Rf(u,E,V,w),ve=u.memoizedState,te!==E||ft!==ve||xt.current||lo?(typeof qe=="function"&&(Ig(u,v,qe,E),ve=u.memoizedState),(te=lo||$A(u,v,te,E,ft,ve,De))?(Mt||typeof V.UNSAFE_componentWillMount!="function"&&typeof V.componentWillMount!="function"||(typeof V.componentWillMount=="function"&&V.componentWillMount(),typeof V.UNSAFE_componentWillMount=="function"&&V.UNSAFE_componentWillMount()),typeof V.componentDidMount=="function"&&(u.flags|=4194308)):(typeof V.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=E,u.memoizedState=ve),V.props=E,V.state=ve,V.context=De,E=te):(typeof V.componentDidMount=="function"&&(u.flags|=4194308),E=!1)}else{V=u.stateNode,ZA(c,u),te=u.memoizedProps,De=u.type===u.elementType?te:Gr(u.type,te),V.props=De,Mt=u.pendingProps,ft=V.context,ve=v.contextType,typeof ve=="object"&&ve!==null?ve=Sr(ve):(ve=yn(v)?sn:mt.current,ve=Bn(u,ve));var ln=v.getDerivedStateFromProps;(qe=typeof ln=="function"||typeof V.getSnapshotBeforeUpdate=="function")||typeof V.UNSAFE_componentWillReceiveProps!="function"&&typeof V.componentWillReceiveProps!="function"||(te!==Mt||ft!==ve)&&tS(u,V,E,ve),lo=!1,ft=u.memoizedState,V.state=ft,Rf(u,E,V,w);var ot=u.memoizedState;te!==Mt||ft!==ot||xt.current||lo?(typeof ln=="function"&&(Ig(u,v,ln,E),ot=u.memoizedState),(De=lo||$A(u,v,De,E,ft,ot,ve)||!1)?(qe||typeof V.UNSAFE_componentWillUpdate!="function"&&typeof V.componentWillUpdate!="function"||(typeof V.componentWillUpdate=="function"&&V.componentWillUpdate(E,ot,ve),typeof V.UNSAFE_componentWillUpdate=="function"&&V.UNSAFE_componentWillUpdate(E,ot,ve)),typeof V.componentDidUpdate=="function"&&(u.flags|=4),typeof V.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof V.componentDidUpdate!="function"||te===c.memoizedProps&&ft===c.memoizedState||(u.flags|=4),typeof V.getSnapshotBeforeUpdate!="function"||te===c.memoizedProps&&ft===c.memoizedState||(u.flags|=1024),u.memoizedProps=E,u.memoizedState=ot),V.props=E,V.state=ot,V.context=ve,E=De):(typeof V.componentDidUpdate!="function"||te===c.memoizedProps&&ft===c.memoizedState||(u.flags|=4),typeof V.getSnapshotBeforeUpdate!="function"||te===c.memoizedProps&&ft===c.memoizedState||(u.flags|=1024),E=!1)}return qg(c,u,v,E,B,w)}function qg(c,u,v,E,w,B){kS(c,u);var V=(u.flags&128)!==0;if(!E&&!V)return w&&zt(u,v,!1),Ns(c,u,B);E=u.stateNode,hP.current=u;var te=V&&typeof v.getDerivedStateFromError!="function"?null:E.render();return u.flags|=1,c!==null&&V?(u.child=xl(u,c.child,null,B),u.child=xl(u,null,te,B)):Ii(c,u,te,B),u.memoizedState=E.state,w&&zt(u,v,!0),u.child}function HS(c){var u=c.stateNode;u.pendingContext?kt(c,u.pendingContext,u.pendingContext!==u.context):u.context&&kt(c,u.context,!1),kg(c,u.containerInfo)}function GS(c,u,v,E,w){return yl(),Ng(w),u.flags|=256,Ii(c,u,v,E),u.child}var Vf={dehydrated:null,treeContext:null,retryLane:0};function Wf(c){return{baseLanes:c,cachePool:null}}function VS(c,u,v){var E=u.pendingProps,w=wn.current,B=!1,V=(u.flags&128)!==0,te;if((te=V)||(te=c!==null&&c.memoizedState===null?!1:(w&2)!==0),te?(B=!0,u.flags&=-129):(c===null||c.memoizedState!==null)&&(w|=1),Fe(wn,w&1),c===null)return Og(u),c=u.memoizedState,c!==null&&(c=c.dehydrated,c!==null)?(u.mode&1?aa(c)?u.lanes=8:u.lanes=1073741824:u.lanes=1,null):(w=E.children,c=E.fallback,B?(E=u.mode,B=u.child,w={mode:"hidden",children:w},!(E&1)&&B!==null?(B.childLanes=0,B.pendingProps=w):B=ud(w,E,0,null),c=va(c,E,v,null),B.return=u,c.return=u,B.sibling=c,u.child=B,u.child.memoizedState=Wf(v),u.memoizedState=Vf,c):$g(u,w));if(w=c.memoizedState,w!==null){if(te=w.dehydrated,te!==null){if(V)return u.flags&256?(u.flags&=-257,Xf(c,u,v,Error(o(422)))):u.memoizedState!==null?(u.child=c.child,u.flags|=128,null):(B=E.fallback,w=u.mode,E=ud({mode:"visible",children:E.children},w,0,null),B=va(B,w,v,null),B.flags|=2,E.return=u,B.return=u,E.sibling=B,u.child=E,u.mode&1&&xl(u,c.child,null,v),u.child.memoizedState=Wf(v),u.memoizedState=Vf,B);if(!(u.mode&1))u=Xf(c,u,v,null);else if(aa(te))u=Xf(c,u,v,Error(o(419)));else if(E=(v&c.childLanes)!==0,sr||E){if(E=zn,E!==null){switch(v&-v){case 4:B=2;break;case 16:B=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:B=32;break;case 536870912:B=268435456;break;default:B=0}E=B&(E.suspendedLanes|v)?0:B,E!==0&&E!==w.retryLane&&(w.retryLane=E,Cr(c,E,-1))}yv(),u=Xf(c,u,v,Error(o(421)))}else ls(te)?(u.flags|=128,u.child=c.child,u=MP.bind(null,c),xr(te,u),u=null):(v=w.treeContext,Be&&(rr=pl(te),ir=u,xn=!0,Vr=null,lu=!1,v!==null&&(Er[Mr++]=Us,Er[Mr++]=Fs,Er[Mr++]=ca,Us=v.id,Fs=v.overflow,ca=u)),u=$g(u,u.pendingProps.children),u.flags|=4096);return u}return B?(E=XS(c,u,E.children,E.fallback,v),B=u.child,w=c.child.memoizedState,B.memoizedState=w===null?Wf(v):{baseLanes:w.baseLanes|v,cachePool:null},B.childLanes=c.childLanes&~v,u.memoizedState=Vf,E):(v=WS(c,u,E.children,v),u.memoizedState=null,v)}return B?(E=XS(c,u,E.children,E.fallback,v),B=u.child,w=c.child.memoizedState,B.memoizedState=w===null?Wf(v):{baseLanes:w.baseLanes|v,cachePool:null},B.childLanes=c.childLanes&~v,u.memoizedState=Vf,E):(v=WS(c,u,E.children,v),u.memoizedState=null,v)}function $g(c,u){return u=ud({mode:"visible",children:u},c.mode,0,null),u.return=c,c.child=u}function WS(c,u,v,E){var w=c.child;return c=w.sibling,v=mo(w,{mode:"visible",children:v}),!(u.mode&1)&&(v.lanes=E),v.return=u,v.sibling=null,c!==null&&(E=u.deletions,E===null?(u.deletions=[c],u.flags|=16):E.push(c)),u.child=v}function XS(c,u,v,E,w){var B=u.mode;c=c.child;var V=c.sibling,te={mode:"hidden",children:v};return!(B&1)&&u.child!==c?(v=u.child,v.childLanes=0,v.pendingProps=te,u.deletions=null):(v=mo(c,te),v.subtreeFlags=c.subtreeFlags&14680064),V!==null?E=mo(V,E):(E=va(E,B,w,null),E.flags|=2),E.return=u,v.return=u,v.sibling=E,u.child=v,E}function Xf(c,u,v,E){return E!==null&&Ng(E),xl(u,c.child,null,v),c=$g(u,u.pendingProps.children),c.flags|=2,u.memoizedState=null,c}function JS(c,u,v){c.lanes|=u;var E=c.alternate;E!==null&&(E.lanes|=u),Bg(c.return,u,v)}function ev(c,u,v,E,w){var B=c.memoizedState;B===null?c.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:E,tail:v,tailMode:w}:(B.isBackwards=u,B.rendering=null,B.renderingStartTime=0,B.last=E,B.tail=v,B.tailMode=w)}function YS(c,u,v){var E=u.pendingProps,w=E.revealOrder,B=E.tail;if(Ii(c,u,E.children,v),E=wn.current,E&2)E=E&1|2,u.flags|=128;else{if(c!==null&&c.flags&128)e:for(c=u.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&JS(c,v,u);else if(c.tag===19)JS(c,v,u);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===u)break e;for(;c.sibling===null;){if(c.return===null||c.return===u)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}E&=1}if(Fe(wn,E),!(u.mode&1))u.memoizedState=null;else switch(w){case"forwards":for(v=u.child,w=null;v!==null;)c=v.alternate,c!==null&&Lf(c)===null&&(w=v),v=v.sibling;v=w,v===null?(w=u.child,u.child=null):(w=v.sibling,v.sibling=null),ev(u,!1,w,v,B);break;case"backwards":for(v=null,w=u.child,u.child=null;w!==null;){if(c=w.alternate,c!==null&&Lf(c)===null){u.child=w;break}c=w.sibling,w.sibling=v,v=w,w=c}ev(u,!0,v,null,B);break;case"together":ev(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function Ns(c,u,v){if(c!==null&&(u.dependencies=c.dependencies),wl|=u.lanes,!(v&u.childLanes))return null;if(c!==null&&u.child!==c.child)throw Error(o(153));if(u.child!==null){for(c=u.child,v=mo(c,c.pendingProps),u.child=v,v.return=u;c.sibling!==null;)c=c.sibling,v=v.sibling=mo(c,c.pendingProps),v.return=u;v.sibling=null}return u.child}function fP(c,u,v){switch(u.tag){case 3:HS(u),yl();break;case 5:cS(u);break;case 1:yn(u.type)&&bt(u);break;case 4:kg(u,u.stateNode.containerInfo);break;case 10:KA(u,u.type._context,u.memoizedProps.value);break;case 13:var E=u.memoizedState;if(E!==null)return E.dehydrated!==null?(Fe(wn,wn.current&1),u.flags|=128,null):v&u.child.childLanes?VS(c,u,v):(Fe(wn,wn.current&1),c=Ns(c,u,v),c!==null?c.sibling:null);Fe(wn,wn.current&1);break;case 19:if(E=(v&u.childLanes)!==0,c.flags&128){if(E)return YS(c,u,v);u.flags|=128}var w=u.memoizedState;if(w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),Fe(wn,wn.current),E)break;return null;case 22:case 23:return u.lanes=0,NS(c,u,v)}return Ns(c,u,v)}function dP(c,u){switch(Ug(u),u.tag){case 1:return yn(u.type)&&Wt(),c=u.flags,c&65536?(u.flags=c&-65537|128,u):null;case 3:return Sl(),Je(xt),Je(mt),Gg(),c=u.flags,c&65536&&!(c&128)?(u.flags=c&-65537|128,u):null;case 5:return zg(u),null;case 13:if(Je(wn),c=u.memoizedState,c!==null&&c.dehydrated!==null){if(u.alternate===null)throw Error(o(340));yl()}return c=u.flags,c&65536?(u.flags=c&-65537|128,u):null;case 19:return Je(wn),null;case 4:return Sl(),null;case 10:return bg(u.type._context),null;case 22:case 23:return _v(),null;case 24:return null;default:return null}}var Jf=!1,fa=!1,pP=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function Yf(c,u){var v=c.ref;if(v!==null)if(typeof v=="function")try{v(null)}catch(E){Ji(c,u,E)}else v.current=null}function tv(c,u,v){try{v()}catch(E){Ji(c,u,E)}}var KS=!1;function mP(c,u){for(Q(c.containerInfo),Ge=u;Ge!==null;)if(c=Ge,u=c.child,(c.subtreeFlags&1028)!==0&&u!==null)u.return=c,Ge=u;else for(;Ge!==null;){c=Ge;try{var v=c.alternate;if(c.flags&1024)switch(c.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var E=v.memoizedProps,w=v.memoizedState,B=c.stateNode,V=B.getSnapshotBeforeUpdate(c.elementType===c.type?E:Gr(c.type,E),w);B.__reactInternalSnapshotBeforeUpdate=V}break;case 3:it&&ze(c.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(te){Ji(c,c.return,te)}if(u=c.sibling,u!==null){u.return=c.return,Ge=u;break}Ge=c.return}return v=KS,KS=!1,v}function da(c,u,v){var E=u.updateQueue;if(E=E!==null?E.lastEffect:null,E!==null){var w=E=E.next;do{if((w.tag&c)===c){var B=w.destroy;w.destroy=void 0,B!==void 0&&tv(u,v,B)}w=w.next}while(w!==E)}}function xu(c,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var v=u=u.next;do{if((v.tag&c)===c){var E=v.create;v.destroy=E()}v=v.next}while(v!==u)}}function nv(c){var u=c.ref;if(u!==null){var v=c.stateNode;switch(c.tag){case 5:c=ie(v);break;default:c=v}typeof u=="function"?u(c):u.current=c}}function ZS(c,u,v){if(us&&typeof us.onCommitFiberUnmount=="function")try{us.onCommitFiberUnmount(Sf,u)}catch{}switch(u.tag){case 0:case 11:case 14:case 15:if(c=u.updateQueue,c!==null&&(c=c.lastEffect,c!==null)){var E=c=c.next;do{var w=E,B=w.destroy;w=w.tag,B!==void 0&&(w&2||w&4)&&tv(u,v,B),E=E.next}while(E!==c)}break;case 1:if(Yf(u,v),c=u.stateNode,typeof c.componentWillUnmount=="function")try{c.props=u.memoizedProps,c.state=u.memoizedState,c.componentWillUnmount()}catch(V){Ji(u,v,V)}break;case 5:Yf(u,v);break;case 4:it?tE(c,u,v):K&&K&&(u=u.stateNode.containerInfo,v=pt(u),$t(u,v))}}function QS(c,u,v){for(var E=u;;)if(ZS(c,E,v),E.child===null||it&&E.tag===4){if(E===u)break;for(;E.sibling===null;){if(E.return===null||E.return===u)return;E=E.return}E.sibling.return=E.return,E=E.sibling}else E.child.return=E,E=E.child}function jS(c){var u=c.alternate;u!==null&&(c.alternate=null,jS(u)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(u=c.stateNode,u!==null&&rt(u)),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function qS(c){return c.tag===5||c.tag===3||c.tag===4}function $S(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||qS(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function eE(c){if(it){e:{for(var u=c.return;u!==null;){if(qS(u))break e;u=u.return}throw Error(o(160))}var v=u;switch(v.tag){case 5:u=v.stateNode,v.flags&32&&(St(u),v.flags&=-33),v=$S(c),rv(c,v,u);break;case 3:case 4:u=v.stateNode.containerInfo,v=$S(c),iv(c,v,u);break;default:throw Error(o(161))}}}function iv(c,u,v){var E=c.tag;if(E===5||E===6)c=c.stateNode,u?Ke(v,c,u):yt(v,c);else if(E!==4&&(c=c.child,c!==null))for(iv(c,u,v),c=c.sibling;c!==null;)iv(c,u,v),c=c.sibling}function rv(c,u,v){var E=c.tag;if(E===5||E===6)c=c.stateNode,u?dt(v,c,u):ct(v,c);else if(E!==4&&(c=c.child,c!==null))for(rv(c,u,v),c=c.sibling;c!==null;)rv(c,u,v),c=c.sibling}function tE(c,u,v){for(var E=u,w=!1,B,V;;){if(!w){w=E.return;e:for(;;){if(w===null)throw Error(o(160));switch(B=w.stateNode,w.tag){case 5:V=!1;break e;case 3:B=B.containerInfo,V=!0;break e;case 4:B=B.containerInfo,V=!0;break e}w=w.return}w=!0}if(E.tag===5||E.tag===6)QS(c,E,v),V?gt(B,E.stateNode):Ze(B,E.stateNode);else if(E.tag===18)V?X(B,E.stateNode):J(B,E.stateNode);else if(E.tag===4){if(E.child!==null){B=E.stateNode.containerInfo,V=!0,E.child.return=E,E=E.child;continue}}else if(ZS(c,E,v),E.child!==null){E.child.return=E,E=E.child;continue}if(E===u)break;for(;E.sibling===null;){if(E.return===null||E.return===u)return;E=E.return,E.tag===4&&(w=!1)}E.sibling.return=E.return,E=E.sibling}}function sv(c,u){if(it){switch(u.tag){case 0:case 11:case 14:case 15:da(3,u,u.return),xu(3,u),da(5,u,u.return);return;case 1:return;case 5:var v=u.stateNode;if(v!=null){var E=u.memoizedProps;c=c!==null?c.memoizedProps:E;var w=u.type,B=u.updateQueue;u.updateQueue=null,B!==null&&Bt(v,B,w,c,E,u)}return;case 6:if(u.stateNode===null)throw Error(o(162));v=u.memoizedProps,Ce(u.stateNode,c!==null?c.memoizedProps:v,v);return;case 3:Be&&c!==null&&c.memoizedState.isDehydrated&&z(u.stateNode.containerInfo);return;case 12:return;case 13:Kf(u);return;case 19:Kf(u);return;case 17:return}throw Error(o(163))}switch(u.tag){case 0:case 11:case 14:case 15:da(3,u,u.return),xu(3,u),da(5,u,u.return);return;case 12:return;case 13:Kf(u);return;case 19:Kf(u);return;case 3:Be&&c!==null&&c.memoizedState.isDehydrated&&z(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,$t(u.containerInfo,u.pendingChildren);break e}throw Error(o(163))}}function Kf(c){var u=c.updateQueue;if(u!==null){c.updateQueue=null;var v=c.stateNode;v===null&&(v=c.stateNode=new pP),u.forEach(function(E){var w=wP.bind(null,c,E);v.has(E)||(v.add(E),E.then(w,w))})}}function gP(c,u){for(Ge=u;Ge!==null;){u=Ge;var v=u.deletions;if(v!==null)for(var E=0;E";case Qf:return":has("+(lv(c)||"")+")";case jf:return'[role="'+c.value+'"]';case $f:return'"'+c.value+'"';case qf:return'[data-testname="'+c.value+'"]';default:throw Error(o(365))}}function oE(c,u){var v=[];c=[c,0];for(var E=0;Ew&&(w=V),E&=~B}if(E=w,E=ii()-E,E=(120>E?120:480>E?480:1080>E?1080:1920>E?1920:3e3>E?3e3:4320>E?4320:1960*_P(E/1960))-E,10c?16:c,ho===null)var E=!1;else{if(c=ho,ho=null,rd=0,Nt&6)throw Error(o(331));var w=Nt;for(Nt|=4,Ge=c.current;Ge!==null;){var B=Ge,V=B.child;if(Ge.flags&16){var te=B.deletions;if(te!==null){for(var ve=0;veii()-fv?pa(c,0):hv|=v),Xi(c,u)}function mE(c,u){u===0&&(c.mode&1?(u=xf,xf<<=1,!(xf&130023424)&&(xf=4194304)):u=1);var v=Li();c=ad(c,u),c!==null&&(au(c,u,v),Xi(c,v))}function MP(c){var u=c.memoizedState,v=0;u!==null&&(v=u.retryLane),mE(c,v)}function wP(c,u){var v=0;switch(c.tag){case 13:var E=c.stateNode,w=c.memoizedState;w!==null&&(v=w.retryLane);break;case 19:E=c.stateNode;break;default:throw Error(o(314))}E!==null&&E.delete(u),mE(c,v)}var gE;gE=function(c,u,v){if(c!==null)if(c.memoizedProps!==u.pendingProps||xt.current)sr=!0;else{if(!(c.lanes&v)&&!(u.flags&128))return sr=!1,fP(c,u,v);sr=!!(c.flags&131072)}else sr=!1,xn&&u.flags&1048576&&nS(u,Pf,u.index);switch(u.lanes=0,u.tag){case 2:var E=u.type;c!==null&&(c.alternate=null,u.alternate=null,u.flags|=2),c=u.pendingProps;var w=Bn(u,mt.current);gl(u,v),w=Wg(null,u,E,c,w,v);var B=Xg();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,yn(E)?(B=!0,bt(u)):B=!1,u.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,Pg(u),w.updater=bf,u.stateNode=w,w._reactInternals=u,Lg(u,E,c,v),u=qg(null,u,E,!0,B,v)):(u.tag=0,xn&&B&&Dg(u),Ii(null,u,w,v),u=u.child),u;case 16:E=u.elementType;e:{switch(c!==null&&(c.alternate=null,u.alternate=null,u.flags|=2),c=u.pendingProps,w=E._init,E=w(E._payload),u.type=E,w=u.tag=CP(E),c=Gr(E,c),w){case 0:u=jg(null,u,E,c,v);break e;case 1:u=zS(null,u,E,c,v);break e;case 11:u=US(null,u,E,c,v);break e;case 14:u=FS(null,u,E,Gr(E.type,c),v);break e}throw Error(o(306,E,""))}return u;case 0:return E=u.type,w=u.pendingProps,w=u.elementType===E?w:Gr(E,w),jg(c,u,E,w,v);case 1:return E=u.type,w=u.pendingProps,w=u.elementType===E?w:Gr(E,w),zS(c,u,E,w,v);case 3:e:{if(HS(u),c===null)throw Error(o(387));E=u.pendingProps,B=u.memoizedState,w=B.element,ZA(c,u),Rf(u,E,null,v);var V=u.memoizedState;if(E=V.element,Be&&B.isDehydrated)if(B={element:E,isDehydrated:!1,cache:V.cache,transitions:V.transitions},u.updateQueue.baseState=B,u.memoizedState=B,u.flags&256){w=Error(o(423)),u=GS(c,u,E,v,w);break e}else if(E!==w){w=Error(o(424)),u=GS(c,u,E,v,w);break e}else for(Be&&(rr=la(u.stateNode.containerInfo),ir=u,xn=!0,Vr=null,lu=!1),v=lS(u,null,E,v),u.child=v;v;)v.flags=v.flags&-3|4096,v=v.sibling;else{if(yl(),E===w){u=Ns(c,u,v);break e}Ii(c,u,E,v)}u=u.child}return u;case 5:return cS(u),c===null&&Og(u),E=u.type,w=u.pendingProps,B=c!==null?c.memoizedProps:null,V=w.children,Pe(E,w)?V=null:B!==null&&Pe(E,B)&&(u.flags|=32),kS(c,u),Ii(c,u,V,v),u.child;case 6:return c===null&&Og(u),null;case 13:return VS(c,u,v);case 4:return kg(u,u.stateNode.containerInfo),E=u.pendingProps,c===null?u.child=xl(u,null,E,v):Ii(c,u,E,v),u.child;case 11:return E=u.type,w=u.pendingProps,w=u.elementType===E?w:Gr(E,w),US(c,u,E,w,v);case 7:return Ii(c,u,u.pendingProps,v),u.child;case 8:return Ii(c,u,u.pendingProps.children,v),u.child;case 12:return Ii(c,u,u.pendingProps.children,v),u.child;case 10:e:{if(E=u.type._context,w=u.pendingProps,B=u.memoizedProps,V=w.value,KA(u,E,V),B!==null)if(hs(B.value,V)){if(B.children===w.children&&!xt.current){u=Ns(c,u,v);break e}}else for(B=u.child,B!==null&&(B.return=u);B!==null;){var te=B.dependencies;if(te!==null){V=B.child;for(var ve=te.firstContext;ve!==null;){if(ve.context===E){if(B.tag===1){ve=Ds(-1,v&-v),ve.tag=2;var De=B.updateQueue;if(De!==null){De=De.shared;var qe=De.pending;qe===null?ve.next=ve:(ve.next=qe.next,qe.next=ve),De.pending=ve}}B.lanes|=v,ve=B.alternate,ve!==null&&(ve.lanes|=v),Bg(B.return,v,u),te.lanes|=v;break}ve=ve.next}}else if(B.tag===10)V=B.type===u.type?null:B.child;else if(B.tag===18){if(V=B.return,V===null)throw Error(o(341));V.lanes|=v,te=V.alternate,te!==null&&(te.lanes|=v),Bg(V,v,u),V=B.sibling}else V=B.child;if(V!==null)V.return=B;else for(V=B;V!==null;){if(V===u){V=null;break}if(B=V.sibling,B!==null){B.return=V.return,V=B;break}V=V.return}B=V}Ii(c,u,w.children,v),u=u.child}return u;case 9:return w=u.type,E=u.pendingProps.children,gl(u,v),w=Sr(w),E=E(w),u.flags|=1,Ii(c,u,E,v),u.child;case 14:return E=u.type,w=Gr(E,u.pendingProps),w=Gr(E.type,w),FS(c,u,E,w,v);case 15:return OS(c,u,u.type,u.pendingProps,v);case 17:return E=u.type,w=u.pendingProps,w=u.elementType===E?w:Gr(E,w),c!==null&&(c.alternate=null,u.alternate=null,u.flags|=2),u.tag=1,yn(E)?(c=!0,bt(u)):c=!1,gl(u,v),eS(u,E,w),Lg(u,E,w,v),qg(null,u,E,!0,c,v);case 19:return YS(c,u,v);case 22:return NS(c,u,v)}throw Error(o(156,u.tag))};function vE(c,u){return Eg(c,u)}function TP(c,u,v,E){this.tag=c,this.key=v,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=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Rr(c,u,v,E){return new TP(c,u,v,E)}function xv(c){return c=c.prototype,!(!c||!c.isReactComponent)}function CP(c){if(typeof c=="function")return xv(c)?1:0;if(c!=null){if(c=c.$$typeof,c===S)return 11;if(c===x)return 14}return 2}function mo(c,u){var v=c.alternate;return v===null?(v=Rr(c.tag,u,c.key,c.mode),v.elementType=c.elementType,v.type=c.type,v.stateNode=c.stateNode,v.alternate=c,c.alternate=v):(v.pendingProps=u,v.type=c.type,v.flags=0,v.subtreeFlags=0,v.deletions=null),v.flags=c.flags&14680064,v.childLanes=c.childLanes,v.lanes=c.lanes,v.child=c.child,v.memoizedProps=c.memoizedProps,v.memoizedState=c.memoizedState,v.updateQueue=c.updateQueue,u=c.dependencies,v.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},v.sibling=c.sibling,v.index=c.index,v.ref=c.ref,v}function cd(c,u,v,E,w,B){var V=2;if(E=c,typeof c=="function")xv(c)&&(V=1);else if(typeof c=="string")V=5;else e:switch(c){case f:return va(v.children,w,B,u);case d:V=8,w|=8;break;case p:return c=Rr(12,v,u,w|2),c.elementType=p,c.lanes=B,c;case y:return c=Rr(13,v,u,w),c.elementType=y,c.lanes=B,c;case m:return c=Rr(19,v,u,w),c.elementType=m,c.lanes=B,c;case M:return ud(v,w,B,u);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case g:V=10;break e;case _:V=9;break e;case S:V=11;break e;case x:V=14;break e;case A:V=16,E=null;break e}throw Error(o(130,c==null?c:typeof c,""))}return u=Rr(V,v,u,w),u.elementType=c,u.type=E,u.lanes=B,u}function va(c,u,v,E){return c=Rr(7,c,E,u),c.lanes=v,c}function ud(c,u,v,E){return c=Rr(22,c,E,u),c.elementType=M,c.lanes=v,c.stateNode={},c}function Av(c,u,v){return c=Rr(6,c,null,u),c.lanes=v,c}function Sv(c,u,v){return u=Rr(4,c.children!==null?c.children:[],c.key,u),u.lanes=v,u.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},u}function RP(c,u,v,E,w){this.tag=u,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=_t,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ag(0),this.expirationTimes=Ag(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ag(0),this.identifierPrefix=E,this.onRecoverableError=w,Be&&(this.mutableSourceEagerHydrationData=null)}function _E(c,u,v,E,w,B,V,te,ve){return c=new RP(c,u,v,te,ve),u===1?(u=1,B===!0&&(u|=8)):u=0,B=Rr(3,null,null,u),c.current=B,B.stateNode=c,B.memoizedState={element:E,isDehydrated:v,cache:null,transitions:null},Pg(B),c}function yE(c){if(!c)return Ot;c=c._reactInternals;e:{if(b(c)!==c||c.tag!==1)throw Error(o(170));var u=c;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(yn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(o(171))}if(c.tag===1){var v=c.type;if(yn(v))return Mn(c,v,u)}return u}function xE(c){var u=c._reactInternals;if(u===void 0)throw typeof c.render=="function"?Error(o(188)):(c=Object.keys(c).join(","),Error(o(268,c)));return c=j(u),c===null?null:c.stateNode}function AE(c,u){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var v=c.retryLane;c.retryLane=v!==0&&v=De&&B>=Mt&&w<=qe&&V<=ft){c.splice(u,1);break}else if(E!==De||v.width!==ve.width||ftV){if(!(B!==Mt||v.height!==ve.height||qew)){De>E&&(ve.width+=De-E,ve.x=E),qeB&&(ve.height+=Mt-B,ve.y=B),ftv&&(v=V)),V ")+` No matching component was found for: `)+c.join(" > ")}return null},t.getPublicRootInstance=function(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 5:return ie(c.child.stateNode);default:return c.child.stateNode}},t.injectIntoDevTools=function(c){if(c={bundleType:c.bundleType,version:c.version,rendererPackageName:c.rendererPackageName,rendererConfig:c.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:a.ReactCurrentDispatcher,findHostInstanceByFiber:bP,findFiberByHostInstance:c.findFiberByHostInstance||BP,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")c=!1;else{var u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(u.isDisabled||!u.supportsFiber)c=!0;else{try{Sf=u.inject(c),us=u}catch{}c=!!u.checkDCE}}return c},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(c,u,v,E){if(!U)throw Error(o(363));c=cv(c,u);var w=Ye(c,v,E).disconnect;return{disconnect:function(){w()}}},t.registerMutableSourceForHydration=function(c,u){var v=u._getVersion;v=v(u._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[u,v]:c.mutableSourceEagerHydrationData.push(u,v)},t.runWithPriority=function(c,u){var v=Zt;try{return Zt=c,u()}finally{Zt=v}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(c,u,v,E){var w=u.current,B=Li(),V=fo(w);return v=yE(v),u.context===null?u.context=v:u.pendingContext=v,u=Ds(B,V),u.payload={element:c},E=E===void 0?null:E,E!==null&&(u.callback=E),co(w,u),c=Cr(w,V,B),c!==null&&Cf(c,w,V),V},t};iB.exports=Gk;var Vk=iB.exports;const Wk=Yy(Vk),Xk=n=>typeof n=="object"&&typeof n.then=="function",Wa=[];function oB(n,e,t=(i,r)=>i===r){if(n===e)return!0;if(!n||!e)return!1;const i=n.length;if(e.length!==i)return!1;for(let r=0;r0&&(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(s.remove,i.lifespan)),s.response;if(!t)throw s.promise}const r={keys:e,equal:i.equal,remove:()=>{const s=Wa.indexOf(r);s!==-1&&Wa.splice(s,1)},promise:(Xk(n)?n:n(...e)).then(s=>{r.response=s,i.lifespan&&i.lifespan>0&&(r.timeout=setTimeout(r.remove,i.lifespan))}).catch(s=>r.error=s)};if(Wa.push(r),!t)throw r.promise}const Jk=(n,e,t)=>aB(n,e,!1,t),Yk=(n,e,t)=>void aB(n,e,!0,t),Kk=n=>{if(n===void 0||n.length===0)Wa.splice(0,Wa.length);else{const e=Wa.find(t=>oB(n,t.keys,t.equal));e&&e.remove()}},NA={},_g=n=>void Object.assign(NA,n);function Zk(n,e){function t(f,{args:d=[],attach:p,...g},_){let S=`${f[0].toUpperCase()}${f.slice(1)}`,y;if(f==="primitive"){if(g.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const m=g.object;y=nc(m,{type:f,root:_,attach:p,primitive:!0})}else{const m=NA[S];if(!m)throw new Error(`R3F: ${S} 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!");y=nc(new m(...d),{type:f,root:_,attach:p,memoizedProps:{args:d}})}return y.__r3f.attach===void 0&&(y instanceof Tt?y.__r3f.attach="geometry":y instanceof Jn&&(y.__r3f.attach="material")),S!=="inject"&&U0(y,g),y}function i(f,d){let p=!1;if(d){var g,_;(g=d.__r3f)!=null&&g.attach?D0(f,d,d.__r3f.attach):d.isObject3D&&f.isObject3D&&(f.add(d),p=!0),p||(_=f.__r3f)==null||_.objects.push(d),d.__r3f||nc(d,{}),d.__r3f.parent=f,zy(d),ic(d)}}function r(f,d,p){let g=!1;if(d){var _,S;if((_=d.__r3f)!=null&&_.attach)D0(f,d,d.__r3f.attach);else if(d.isObject3D&&f.isObject3D){d.parent=f,d.dispatchEvent({type:"added"});const y=f.children.filter(x=>x!==d),m=y.indexOf(p);f.children=[...y.slice(0,m),d,...y.slice(m)],g=!0}g||(S=f.__r3f)==null||S.objects.push(d),d.__r3f||nc(d,{}),d.__r3f.parent=f,zy(d),ic(d)}}function s(f,d,p=!1){f&&[...f].forEach(g=>o(d,g,p))}function o(f,d,p){if(d){var g,_,S;if(d.__r3f&&(d.__r3f.parent=null),(g=f.__r3f)!=null&&g.objects&&(f.__r3f.objects=f.__r3f.objects.filter(M=>M!==d)),(_=d.__r3f)!=null&&_.attach)hw(f,d,d.__r3f.attach);else if(d.isObject3D&&f.isObject3D){var y;f.remove(d),(y=d.__r3f)!=null&&y.root&&iz(Kp(d),d)}const x=(S=d.__r3f)==null?void 0:S.primitive,A=!x&&(p===void 0?d.dispose!==null:p);if(!x){var m;s((m=d.__r3f)==null?void 0:m.objects,d,A),s(d.children,d,A)}if(delete d.__r3f,A&&d.dispose&&d.type!=="Scene"){const M=()=>{try{d.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?Ny.unstable_scheduleCallback(Ny.unstable_IdlePriority,M):M()}ic(f)}}function a(f,d,p,g){var _;const S=(_=f.__r3f)==null?void 0:_.parent;if(!S)return;const y=t(d,p,f.__r3f.root);if(f.children){for(const m of f.children)m.__r3f&&i(y,m);f.children=f.children.filter(m=>!m.__r3f)}f.__r3f.objects.forEach(m=>i(y,m)),f.__r3f.objects=[],f.__r3f.autoRemovedBeforeAppend||o(S,f),y.parent&&(y.__r3f.autoRemovedBeforeAppend=!0),i(S,y),y.raycast&&y.__r3f.eventCount&&Kp(y).getState().internal.interaction.push(y),[g,g.alternate].forEach(m=>{m!==null&&(m.stateNode=y,m.ref&&(typeof m.ref=="function"?m.ref(y):m.ref.current=y))})}const l=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:Wk({createInstance:t,removeChild:o,appendChild:i,appendInitialChild:i,insertBefore:r,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(f,d)=>{if(!d)return;const p=f.getState().scene;p.__r3f&&(p.__r3f.root=f,i(p,d))},removeChildFromContainer:(f,d)=>{d&&o(f.getState().scene,d)},insertInContainerBefore:(f,d,p)=>{if(!d||!p)return;const g=f.getState().scene;g.__r3f&&r(g,d,p)},getRootHostContext:()=>null,getChildHostContext:f=>f,finalizeInitialChildren(f){var d;return!!((d=f==null?void 0:f.__r3f)!=null?d:{}).handlers},prepareUpdate(f,d,p,g){var _;if(((_=f==null?void 0:f.__r3f)!=null?_:{}).primitive&&g.object&&g.object!==f)return[!0];{const{args:y=[],children:m,...x}=g,{args:A=[],children:M,...C}=p;if(!Array.isArray(y))throw new Error("R3F: the args prop must be an array!");if(y.some((R,D)=>R!==A[D]))return[!0];const T=pB(f,x,C,!0);return T.changes.length?[!1,T]:null}},commitUpdate(f,[d,p],g,_,S,y){d?a(f,g,S,y):U0(f,p)},commitMount(f,d,p,g){var _;const S=(_=f.__r3f)!=null?_:{};f.raycast&&S.handlers&&S.eventCount&&Kp(f).getState().internal.interaction.push(f)},getPublicInstance:f=>f,prepareForCommit:()=>null,preparePortalMount:f=>nc(f.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(f){var d;const{attach:p,parent:g}=(d=f.__r3f)!=null?d:{};p&&g&&hw(g,f,p),f.isObject3D&&(f.visible=!1),ic(f)},unhideInstance(f,d){var p;const{attach:g,parent:_}=(p=f.__r3f)!=null?p:{};g&&_&&D0(_,f,g),(f.isObject3D&&d.visible==null||d.visible)&&(f.visible=!0),ic(f)},createTextInstance:l,hideTextInstance:l,unhideTextInstance:l,getCurrentEventPriority:()=>e?e():xc.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&mn.fun(performance.now)?performance.now:mn.fun(Date.now)?Date.now:()=>0,scheduleTimeout:mn.fun(setTimeout)?setTimeout:void 0,cancelTimeout:mn.fun(clearTimeout)?clearTimeout:void 0}),applyProps:U0}}var aw,lw;const L0=n=>"colorSpace"in n||"outputColorSpace"in n,lB=()=>{var n;return(n=NA.ColorManagement)!=null?n:null},cB=n=>n&&n.isOrthographicCamera,Qk=n=>n&&n.hasOwnProperty("current"),vf=typeof window<"u"&&((aw=window.document)!=null&&aw.createElement||((lw=window.navigator)==null?void 0:lw.product)==="ReactNative")?ee.useLayoutEffect:ee.useEffect;function uB(n){const e=ee.useRef(n);return vf(()=>void(e.current=n),[n]),e}function jk({set:n}){return vf(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}class hB extends ee.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}hB.getDerivedStateFromError=()=>({error:!0});const fB="__default",cw=new Map,qk=n=>n&&!!n.memoized&&!!n.changes;function dB(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 Wu=n=>{var e;return(e=n.__r3f)==null?void 0:e.root.getState()};function Kp(n){let e=n.__r3f.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const mn={obj:n=>n===Object(n)&&!mn.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(mn.str(n)||mn.num(n))return n===e;const s=mn.obj(n);if(s&&i==="reference")return n===e;const o=mn.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(!mn.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(mn.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 $k(n){const e={nodes:{},materials:{}};return n&&n.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material)}),e}function ez(n){n.dispose&&n.type!=="Scene"&&n.dispose();for(const e in n)e.dispose==null||e.dispose(),delete n[e]}function nc(n,e){const t=n;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},n}function ky(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 uw=/-\d+$/;function D0(n,e,t){if(mn.str(t)){if(uw.test(t)){const s=t.replace(uw,""),{target:o,key:a}=ky(n,s);Array.isArray(o[a])||(o[a]=[])}const{target:i,key:r}=ky(n,t);e.__r3f.previousAttach=i[r],i[r]=e}else e.__r3f.previousAttach=t(n,e)}function hw(n,e,t){var i,r;if(mn.str(t)){const{target:s,key:o}=ky(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 pB(n,{children:e,key:t,ref:i,...r},{children:s,key:o,ref:a,...l}={},h=!1){var f;const d=(f=n==null?void 0:n.__r3f)!=null?f:{},p=Object.entries(r),g=[];if(h){const S=Object.keys(l);for(let y=0;y{var m;if((m=n.__r3f)!=null&&m.primitive&&S==="object"||mn.equ(y,l[S]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(S))return g.push([S,y,!0,[]]);let x=[];S.includes("-")&&(x=S.split("-")),g.push([S,y,!1,x]);for(const A in r){const M=r[A];A.startsWith(`${S}-`)&&g.push([A,M,!1,A.split("-")])}});const _={...r};return d.memoizedProps&&d.memoizedProps.args&&(_.args=d.memoizedProps.args),d.memoizedProps&&d.memoizedProps.attach&&(_.attach=d.memoizedProps.attach),{memoized:_,changes:g}}const tz=typeof process<"u"&&!1;function U0(n,e){var t,i,r;const s=(t=n.__r3f)!=null?t:{},o=s.root,a=(i=o==null||o.getState==null?void 0:o.getState())!=null?i:{},{memoized:l,changes:h}=qk(e)?e:pB(n,e),f=s.eventCount;n.__r3f&&(n.__r3f.memoizedProps=l);for(let p=0;pA[M],n),!(x&&x.set))){const[A,...M]=y.reverse();m=M.reverse().reduce((C,T)=>C[T],n),g=A}if(_===fB+"remove")if(m.constructor){let A=cw.get(m.constructor);A||(A=new m.constructor,cw.set(m.constructor,A)),_=A[g]}else _=0;if(S)_?s.handlers[g]=_:delete s.handlers[g],s.eventCount=Object.keys(s.handlers).length;else if(x&&x.set&&(x.copy||x instanceof Qa)){if(Array.isArray(_))x.fromArray?x.fromArray(_):x.set(..._);else if(x.copy&&_&&_.constructor&&(tz?x.constructor.name===_.constructor.name:x.constructor===_.constructor))x.copy(_);else if(_!==void 0){const A=x instanceof Ne;!A&&x.setScalar?x.setScalar(_):x instanceof Qa&&_ instanceof Qa?x.mask=_.mask:x.set(_),!lB()&&!a.linear&&A&&x.convertSRGBToLinear()}}else if(m[g]=_,m[g]instanceof _n&&m[g].format===Ti&&m[g].type===ws){const A=m[g];L0(A)&&L0(a.gl)?A.colorSpace=a.gl.outputColorSpace:A.encoding=a.gl.outputEncoding}ic(n)}if(s.parent&&n.raycast&&f!==s.eventCount){const p=Kp(n).getState().internal,g=p.interaction.indexOf(n);g>-1&&p.interaction.splice(g,1),s.eventCount&&p.interaction.push(n)}return!(h.length===1&&h[0][0]==="onUpdate")&&h.length&&(r=n.__r3f)!=null&&r.parent&&zy(n),n}function ic(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 zy(n){n.onUpdate==null||n.onUpdate(n)}function mB(n,e){n.manual||(cB(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 xp(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function nz(){var n;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return xc.DefaultEventPriority;switch((n=e.event)==null?void 0:n.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return xc.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return xc.ContinuousEventPriority;default:return xc.DefaultEventPriority}}function gB(n,e,t,i){const r=t.get(e);r&&(t.delete(e),t.size===0&&(n.delete(i),r.target.releasePointerCapture(i)))}function iz(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)=>{gB(t.capturedMap,e,i,r)})}function rz(n){function e(l){const{internal:h}=n.getState(),f=l.offsetX-h.initialClick[0],d=l.offsetY-h.initialClick[1];return Math.round(Math.sqrt(f*f+d*d))}function t(l){return l.filter(h=>["Move","Over","Enter","Out","Leave"].some(f=>{var d;return(d=h.__r3f)==null?void 0:d.handlers["onPointer"+f]}))}function i(l,h){const f=n.getState(),d=new Set,p=[],g=h?h(f.internal.interaction):f.internal.interaction;for(let m=0;m{const A=Wu(m.object),M=Wu(x.object);return!A||!M?m.distance-x.distance:M.events.priority-A.events.priority||m.distance-x.distance}).filter(m=>{const x=xp(m);return d.has(x)?!1:(d.add(x),!0)});f.events.filter&&(S=f.events.filter(S,f));for(const m of S){let x=m.object;for(;x;){var y;(y=x.__r3f)!=null&&y.eventCount&&p.push({...m,eventObject:x}),x=x.parent}}if("pointerId"in l&&f.internal.capturedMap.has(l.pointerId))for(let m of f.internal.capturedMap.get(l.pointerId).values())d.has(xp(m.intersection))||p.push(m.intersection);return p}function r(l,h,f,d){const p=n.getState();if(l.length){const g={stopped:!1};for(const _ of l){const S=Wu(_.object)||p,{raycaster:y,pointer:m,camera:x,internal:A}=S,M=new k(m.x,m.y,0).unproject(x),C=I=>{var O,j;return(O=(j=A.capturedMap.get(I))==null?void 0:j.has(_.eventObject))!=null?O:!1},T=I=>{const O={intersection:_,target:h.target};A.capturedMap.has(I)?A.capturedMap.get(I).set(_.eventObject,O):A.capturedMap.set(I,new Map([[_.eventObject,O]])),h.target.setPointerCapture(I)},R=I=>{const O=A.capturedMap.get(I);O&&gB(A.capturedMap,_.eventObject,O,I)};let D={};for(let I in h){let O=h[I];typeof O!="function"&&(D[I]=O)}let b={..._,...D,pointer:m,intersections:l,stopped:g.stopped,delta:f,unprojectedPoint:M,ray:y.ray,camera:x,stopPropagation(){const I="pointerId"in h&&A.capturedMap.get(h.pointerId);if((!I||I.has(_.eventObject))&&(b.stopped=g.stopped=!0,A.hovered.size&&Array.from(A.hovered.values()).find(O=>O.eventObject===_.eventObject))){const O=l.slice(0,l.indexOf(_));s([...O,_])}},target:{hasPointerCapture:C,setPointerCapture:T,releasePointerCapture:R},currentTarget:{hasPointerCapture:C,setPointerCapture:T,releasePointerCapture:R},nativeEvent:h};if(d(b),g.stopped===!0)break}}return l}function s(l){const{internal:h}=n.getState();for(const f of h.hovered.values())if(!l.length||!l.find(d=>d.object===f.object&&d.index===f.index&&d.instanceId===f.instanceId)){const p=f.eventObject.__r3f,g=p==null?void 0:p.handlers;if(h.hovered.delete(xp(f)),p!=null&&p.eventCount){const _={...f,intersections:l};g.onPointerOut==null||g.onPointerOut(_),g.onPointerLeave==null||g.onPointerLeave(_)}}}function o(l,h){for(let f=0;fs([]);case"onLostPointerCapture":return h=>{const{internal:f}=n.getState();"pointerId"in h&&f.capturedMap.has(h.pointerId)&&requestAnimationFrame(()=>{f.capturedMap.has(h.pointerId)&&(f.capturedMap.delete(h.pointerId),s([]))})}}return function(f){const{onPointerMissed:d,internal:p}=n.getState();p.lastEvent.current=f;const g=l==="onPointerMove",_=l==="onClick"||l==="onContextMenu"||l==="onDoubleClick",y=i(f,g?t:void 0),m=_?e(f):0;l==="onPointerDown"&&(p.initialClick=[f.offsetX,f.offsetY],p.initialHits=y.map(A=>A.eventObject)),_&&!y.length&&m<=2&&(o(f,p.interaction),d&&d(f)),g&&s(y);function x(A){const M=A.eventObject,C=M.__r3f,T=C==null?void 0:C.handlers;if(C!=null&&C.eventCount)if(g){if(T.onPointerOver||T.onPointerEnter||T.onPointerOut||T.onPointerLeave){const R=xp(A),D=p.hovered.get(R);D?D.stopped&&A.stopPropagation():(p.hovered.set(R,A),T.onPointerOver==null||T.onPointerOver(A),T.onPointerEnter==null||T.onPointerEnter(A))}T.onPointerMove==null||T.onPointerMove(A)}else{const R=T[l];R?(!_||p.initialHits.includes(M))&&(o(f,p.interaction.filter(D=>!p.initialHits.includes(D))),R(A)):_&&p.initialHits.includes(M)&&o(f,p.interaction.filter(D=>!p.initialHits.includes(D)))}}r(y,f,m,x)}}return{handlePointer:a}}const sz=["set","get","setSize","setFrameloop","setDpr","events","invalidate","advance","size","viewport"],vB=n=>!!(n!=null&&n.render),kA=ee.createContext(null),oz=(n,e)=>{const t=nB((a,l)=>{const h=new k,f=new k,d=new k;function p(m=l().camera,x=f,A=l().size){const{width:M,height:C,top:T,left:R}=A,D=M/C;x instanceof k?d.copy(x):d.set(...x);const b=m.getWorldPosition(h).distanceTo(d);if(cB(m))return{width:M/m.zoom,height:C/m.zoom,top:T,left:R,factor:1,distance:b,aspect:D};{const I=m.fov*Math.PI/180,O=2*Math.tan(I/2)*b,j=O*(M/C);return{width:j,height:O,top:T,left:R,factor:M/j,distance:b,aspect:D}}}let g;const _=m=>a(x=>({performance:{...x.performance,current:m}})),S=new Se;return{set:a,get:l,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(m=1)=>n(l(),m),advance:(m,x)=>e(m,x,l()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new DA,pointer:S,mouse:S,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const m=l();g&&clearTimeout(g),m.performance.current!==m.performance.min&&_(m.performance.min),g=setTimeout(()=>_(l().performance.max),m.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:p},setEvents:m=>a(x=>({...x,events:{...x.events,...m}})),setSize:(m,x,A,M,C)=>{const T=l().camera,R={width:m,height:x,top:M||0,left:C||0,updateStyle:A};a(D=>({size:R,viewport:{...D.viewport,...p(T,f,R)}}))},setDpr:m=>a(x=>{const A=dB(m);return{viewport:{...x.viewport,dpr:A,initialDpr:x.viewport.initialDpr||A}}}),setFrameloop:(m="always")=>{const x=l().clock;x.stop(),x.elapsedTime=0,m!=="never"&&(x.start(),x.elapsedTime=0),a(()=>({frameloop:m}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:ee.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(m,x,A)=>{const M=l().internal;return M.priority=M.priority+(x>0?1:0),M.subscribers.push({ref:m,priority:x,store:A}),M.subscribers=M.subscribers.sort((C,T)=>C.priority-T.priority),()=>{const C=l().internal;C!=null&&C.subscribers&&(C.priority=C.priority-(x>0?1:0),C.subscribers=C.subscribers.filter(T=>T.ref!==m))}}}}}),i=t.getState();let r=i.size,s=i.viewport.dpr,o=i.camera;return t.subscribe(()=>{const{camera:a,size:l,viewport:h,gl:f,set:d}=t.getState();if(l.width!==r.width||l.height!==r.height||h.dpr!==s){var p;r=l,s=h.dpr,mB(a,l),f.setPixelRatio(h.dpr);const g=(p=l.updateStyle)!=null?p:typeof HTMLCanvasElement<"u"&&f.domElement instanceof HTMLCanvasElement;f.setSize(l.width,l.height,g)}a!==o&&(o=a,d(g=>({viewport:{...g.viewport,...g.viewport.getCurrentViewport(a)}})))}),t.subscribe(a=>n(a)),t};let Ap,az=new Set,lz=new Set,cz=new Set;function F0(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function Xu(n,e){switch(n){case"before":return F0(az,e);case"after":return F0(lz,e);case"tail":return F0(cz,e)}}let O0,N0;function k0(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),O0=e.internal.subscribers,Ap=0;Ap0)&&!((h=r.gl.xr)!=null&&h.isPresenting)&&(t+=k0(l,r))}if(Xu("after",l),t===0)return Xu("tail",l),e=!1,cancelAnimationFrame(i)}function o(l,h=1){var f;if(!l)return n.forEach(d=>o(d.store.getState()),h);(f=l.gl.xr)!=null&&f.isPresenting||!l.internal.active||l.frameloop==="never"||(l.internal.frames=Math.min(60,l.internal.frames+h),e||(e=!0,requestAnimationFrame(s)))}function a(l,h=!0,f,d){if(h&&Xu("before",l),f)k0(l,f,d);else for(const p of n.values())k0(l,p.store.getState());h&&Xu("after",l)}return{loop:s,invalidate:o,advance:a}}function zA(){const n=ee.useContext(kA);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function Vn(n=t=>t,e){return zA()(n,e)}function ru(n,e=0){const t=zA(),i=t.getState().internal.subscribe,r=uB(n);return vf(()=>i(r,e,t),[e,i,t]),null}const fw=new WeakMap;function _B(n,e){return function(t,...i){let r=fw.get(t);return r||(r=new t,fw.set(t,r)),n&&n(r),Promise.all(i.map(s=>new Promise((o,a)=>r.load(s,l=>{l.scene&&Object.assign(l,$k(l.scene)),o(l)},e,l=>a(new Error(`Could not load ${s}: ${l==null?void 0:l.message}`)))))).finally(()=>r.dispose==null?void 0:r.dispose())}}function su(n,e,t,i){const r=Array.isArray(e)?e:[e],s=Jk(_B(t,i),[n,...r],{equal:mn.equ});return Array.isArray(e)?s:s[0]}su.preload=function(n,e,t){const i=Array.isArray(e)?e:[e];return Yk(_B(t),[n,...i])};su.clear=function(n,e){const t=Array.isArray(e)?e:[e];return Kk([n,...t])};const Yc=new Map,{invalidate:dw,advance:pw}=uz(Yc),{reconciler:jh,applyProps:Zl}=Zk(Yc,nz),Ql={objects:"shallow",strict:!1},hz=(n,e)=>{const t=typeof n=="function"?n(e):n;return vB(t)?t:new hA({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...n})};function fz(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 dz(n){const e=Yc.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||oz(dw,pw),o=t||jh.createContainer(s,xc.ConcurrentRoot,null,!1,null,"",r,null);e||Yc.set(n,{fiber:o,store:s});let a,l=!1,h;return{configure(f={}){let{gl:d,size:p,scene:g,events:_,onCreated:S,shadows:y=!1,linear:m=!1,flat:x=!1,legacy:A=!1,orthographic:M=!1,frameloop:C="always",dpr:T=[1,2],performance:R,raycaster:D,camera:b,onPointerMissed:I}=f,O=s.getState(),j=O.gl;O.gl||O.set({gl:j=hz(d,n)});let ae=O.raycaster;ae||O.set({raycaster:ae=new vg});const{params:W,...$}=D||{};if(mn.equ($,ae,Ql)||Zl(ae,{...$}),mn.equ(W,ae.params,Ql)||Zl(ae,{params:{...ae.params,...W}}),!O.camera||O.camera===h&&!mn.equ(h,b,Ql)){h=b;const Y=b instanceof af,re=Y?b:M?new eu(0,0,0,0,.1,1e3):new jn(75,0,.1,1e3);Y||(re.position.z=5,b&&Zl(re,b),!O.camera&&!(b!=null&&b.rotation)&&re.lookAt(0,0,0)),O.set({camera:re}),ae.camera=re}if(!O.scene){let Y;g instanceof Xh?Y=g:(Y=new Xh,g&&Zl(Y,g)),O.set({scene:nc(Y)})}if(!O.xr){var ie;const Y=(se,_e)=>{const Pe=s.getState();Pe.frameloop!=="never"&&pw(se,!0,Pe,_e)},re=()=>{const se=s.getState();se.gl.xr.enabled=se.gl.xr.isPresenting,se.gl.xr.setAnimationLoop(se.gl.xr.isPresenting?Y:null),se.gl.xr.isPresenting||dw(se)},ue={connect(){const se=s.getState().gl;se.xr.addEventListener("sessionstart",re),se.xr.addEventListener("sessionend",re)},disconnect(){const se=s.getState().gl;se.xr.removeEventListener("sessionstart",re),se.xr.removeEventListener("sessionend",re)}};typeof((ie=j.xr)==null?void 0:ie.addEventListener)=="function"&&ue.connect(),O.set({xr:ue})}if(j.shadowMap){const Y=j.shadowMap.enabled,re=j.shadowMap.type;if(j.shadowMap.enabled=!!y,mn.boo(y))j.shadowMap.type=dh;else if(mn.str(y)){var fe;const ue={basic:jC,percentage:Vm,soft:dh,variance:jr};j.shadowMap.type=(fe=ue[y])!=null?fe:dh}else mn.obj(y)&&Object.assign(j.shadowMap,y);(Y!==j.shadowMap.enabled||re!==j.shadowMap.type)&&(j.shadowMap.needsUpdate=!0)}const H=lB();H&&("enabled"in H?H.enabled=!A:"legacyMode"in H&&(H.legacyMode=A)),l||Zl(j,{outputEncoding:m?3e3:3001,toneMapping:x?Ms:Gx}),O.legacy!==A&&O.set(()=>({legacy:A})),O.linear!==m&&O.set(()=>({linear:m})),O.flat!==x&&O.set(()=>({flat:x})),d&&!mn.fun(d)&&!vB(d)&&!mn.equ(d,j,Ql)&&Zl(j,d),_&&!O.events.handlers&&O.set({events:_(s)});const Q=fz(n,p);return mn.equ(Q,O.size,Ql)||O.setSize(Q.width,Q.height,Q.updateStyle,Q.top,Q.left),T&&O.viewport.dpr!==dB(T)&&O.setDpr(T),O.frameloop!==C&&O.setFrameloop(C),O.onPointerMissed||O.set({onPointerMissed:I}),R&&!mn.equ(R,O.performance,Ql)&&O.set(Y=>({performance:{...Y.performance,...R}})),a=S,l=!0,this},render(f){return l||this.configure(),jh.updateContainer(ee.createElement(pz,{store:s,children:f,onCreated:a,rootElement:n}),o,null,()=>{}),s},unmount(){yB(n)}}}function pz({store:n,children:e,onCreated:t,rootElement:i}){return vf(()=>{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)},[]),ee.createElement(kA.Provider,{value:n},e)}function yB(n,e){const t=Yc.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),jh.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{var s,o,a,l;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(),(l=r.gl)!=null&&l.xr&&r.xr.disconnect(),ez(r),Yc.delete(n),e&&e(n)}catch{}},500)})}}function mz(n,e,t){return ee.createElement(gz,{key:e.uuid,children:n,container:e,state:t})}function gz({state:n={},children:e,container:t}){const{events:i,size:r,...s}=n,o=zA(),[a]=ee.useState(()=>new vg),[l]=ee.useState(()=>new Se),h=ee.useCallback((d,p)=>{const g={...d};Object.keys(d).forEach(S=>{(sz.includes(S)||d[S]!==p[S]&&p[S])&&delete g[S]});let _;if(p&&r){const S=p.camera;_=d.viewport.getCurrentViewport(S,new k,r),S!==d.camera&&mB(S,r)}return{...g,scene:t,raycaster:a,pointer:l,mouse:l,previousRoot:o,events:{...d.events,...p==null?void 0:p.events,...i},size:{...d.size,...r},viewport:{...d.viewport,..._},...s}},[n]),[f]=ee.useState(()=>{const d=o.getState();return nB((g,_)=>({...d,scene:t,raycaster:a,pointer:l,mouse:l,previousRoot:o,events:{...d.events,...i},size:{...d.size,...r},...s,set:g,get:_,setEvents:S=>g(y=>({...y,events:{...y.events,...S}}))}))});return ee.useEffect(()=>{const d=o.subscribe(p=>f.setState(g=>h(p,g)));return()=>{d(),f.destroy()}},[]),ee.useEffect(()=>{f.setState(d=>h(o.getState(),d))},[h]),ee.createElement(ee.Fragment,null,jh.createPortal(ee.createElement(kA.Provider,{value:f},e),f,null))}jh.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:ee.version});function dr(){return dr=Object.assign?Object.assign.bind():function(n){for(var e=1;e=0?i=setTimeout(l,e-f):(i=null,t||(a=n.apply(s,r),s=r=null))}var h=function(){s=this,r=arguments,o=Date.now();var f=t&&!i;return i||(i=setTimeout(l,e)),f&&(a=n.apply(s,r),s=r=null),a};return h.clear=function(){i&&(clearTimeout(i),i=null)},h.flush=function(){i&&(a=n.apply(s,r),s=r=null,clearTimeout(i),i=null)},h}Hy.debounce=Hy;var vz=Hy;const mw=Yy(vz);function _z(n){let{debounce:e,scroll:t,polyfill:i,offsetSize:r}=n===void 0?{debounce:0,scroll:!1,offsetSize:!1}:n;const s=i||(typeof window>"u"?class{}:window.ResizeObserver);if(!s)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[o,a]=ee.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),l=ee.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),h=e?typeof e=="number"?e:e.scroll:null,f=e?typeof e=="number"?e:e.resize:null,d=ee.useRef(!1);ee.useEffect(()=>(d.current=!0,()=>void(d.current=!1)));const[p,g,_]=ee.useMemo(()=>{const x=()=>{if(!l.current.element)return;const{left:A,top:M,width:C,height:T,bottom:R,right:D,x:b,y:I}=l.current.element.getBoundingClientRect(),O={left:A,top:M,width:C,height:T,bottom:R,right:D,x:b,y:I};l.current.element instanceof HTMLElement&&r&&(O.height=l.current.element.offsetHeight,O.width=l.current.element.offsetWidth),Object.freeze(O),d.current&&!Sz(l.current.lastBounds,O)&&a(l.current.lastBounds=O)};return[x,f?mw(x,f):x,h?mw(x,h):x]},[a,r,h,f]);function S(){l.current.scrollContainers&&(l.current.scrollContainers.forEach(x=>x.removeEventListener("scroll",_,!0)),l.current.scrollContainers=null),l.current.resizeObserver&&(l.current.resizeObserver.disconnect(),l.current.resizeObserver=null)}function y(){l.current.element&&(l.current.resizeObserver=new s(_),l.current.resizeObserver.observe(l.current.element),t&&l.current.scrollContainers&&l.current.scrollContainers.forEach(x=>x.addEventListener("scroll",_,{capture:!0,passive:!0})))}const m=x=>{!x||x===l.current.element||(S(),l.current.element=x,l.current.scrollContainers=xB(x),y())};return xz(_,!!t),yz(g),ee.useEffect(()=>{S(),y()},[t,_,g]),ee.useEffect(()=>S,[]),[m,o,p]}function yz(n){ee.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[n])}function xz(n,e){ee.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[n,e])}function xB(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,...xB(n.parentElement)]}const Az=["x","y","top","bottom","left","right","width","height"],Sz=(n,e)=>Az.every(t=>n[t]===e[t]);var Ez=Object.defineProperty,Mz=Object.defineProperties,wz=Object.getOwnPropertyDescriptors,gw=Object.getOwnPropertySymbols,Tz=Object.prototype.hasOwnProperty,Cz=Object.prototype.propertyIsEnumerable,vw=(n,e,t)=>e in n?Ez(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_w=(n,e)=>{for(var t in e||(e={}))Tz.call(e,t)&&vw(n,t,e[t]);if(gw)for(var t of gw(e))Cz.call(e,t)&&vw(n,t,e[t]);return n},Rz=(n,e)=>Mz(n,wz(e));function AB(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=e?n.return:n.child;for(;i;){const r=AB(i,e,t);if(r)return r;i=e?null:i.sibling}}function SB(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const HA=SB(ee.createContext(null));class EB extends ee.Component{render(){return ee.createElement(HA.Provider,{value:this._reactInternals},this.props.children)}}const{ReactCurrentOwner:yw,ReactCurrentDispatcher:xw}=ee.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function bz(){const n=ee.useContext(HA);if(n===null)throw new Error("its-fine: useFiber must be called within a !");const e=ee.useId();return ee.useMemo(()=>{for(const i of[yw==null?void 0:yw.current,n,n==null?void 0:n.alternate]){if(!i)continue;const r=AB(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 Bz(){var n,e;const t=bz(),[i]=ee.useState(()=>new Map);i.clear();let r=t;for(;r;){const s=(n=r.type)==null?void 0:n._context;s&&s!==HA&&!i.has(s)&&i.set(s,(e=xw==null?void 0:xw.current)==null?void 0:e.readContext(SB(s))),r=r.return}return i}function Pz(){const n=Bz();return ee.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>ee.createElement(e,null,ee.createElement(t.Provider,Rz(_w({},i),{value:n.get(t)}))),e=>ee.createElement(EB,_w({},e))),[n])}const z0={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 Iz(n){const{handlePointer:e}=rz(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(z0).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[l,h]=z0[o];t.addEventListener(l,a,{passive:h})})},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]=z0[s];i.connected.removeEventListener(a,o)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}const Lz=ee.forwardRef(function({children:e,fallback:t,resize:i,style:r,gl:s,events:o=Iz,eventSource:a,eventPrefix:l,shadows:h,linear:f,flat:d,legacy:p,orthographic:g,frameloop:_,dpr:S,performance:y,raycaster:m,camera:x,scene:A,onPointerMissed:M,onCreated:C,...T},R){ee.useMemo(()=>_g(kk),[]);const D=Pz(),[b,I]=_z({scroll:!0,debounce:{scroll:50,resize:0},...i}),O=ee.useRef(null),j=ee.useRef(null);ee.useImperativeHandle(R,()=>O.current);const ae=uB(M),[W,$]=ee.useState(!1),[ie,fe]=ee.useState(!1);if(W)throw W;if(ie)throw ie;const H=ee.useRef(null);vf(()=>{const Y=O.current;I.width>0&&I.height>0&&Y&&(H.current||(H.current=dz(Y)),H.current.configure({gl:s,events:o,shadows:h,linear:f,flat:d,legacy:p,orthographic:g,frameloop:_,dpr:S,performance:y,raycaster:m,camera:x,scene:A,size:I,onPointerMissed:(...re)=>ae.current==null?void 0:ae.current(...re),onCreated:re=>{re.events.connect==null||re.events.connect(a?Qk(a)?a.current:a:j.current),l&&re.setEvents({compute:(ue,se)=>{const _e=ue[l+"X"],Pe=ue[l+"Y"];se.pointer.set(_e/se.size.width*2-1,-(Pe/se.size.height)*2+1),se.raycaster.setFromCamera(se.pointer,se.camera)}}),C==null||C(re)}}),H.current.render(ee.createElement(D,null,ee.createElement(hB,{set:fe},ee.createElement(ee.Suspense,{fallback:ee.createElement(jk,{set:$})},e)))))}),ee.useEffect(()=>{const Y=O.current;if(Y)return()=>yB(Y)},[]);const Q=a?"none":"auto";return ee.createElement("div",dr({ref:j,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:Q,...r}},T),ee.createElement("div",{ref:b,style:{width:"100%",height:"100%"}},ee.createElement("canvas",{ref:O,style:{display:"block"}},t)))}),Dz=ee.forwardRef(function(e,t){return ee.createElement(EB,null,ee.createElement(Lz,dr({},e,{ref:t})))});function Aw(n,e){if(e===kR)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===Sm||e===qx){let t=n.getIndex();if(t===null){const o=[],a=n.getAttribute("position");if(a!==void 0){for(let l=0;l>>1|(gn&21845)<<1;wo=(wo&52428)>>>2|(wo&13107)<<2,wo=(wo&61680)>>>4|(wo&3855)<<4,Vy[gn]=((wo&65280)>>>8|(wo&255)<<8)>>>1}var _h=function(n,e,t){for(var i=n.length,r=0,s=new Oo(e);r>>l]=h}else for(a=new Oo(i),r=0;r>>15-n[r]);return a},_f=new Or(288);for(var gn=0;gn<144;++gn)_f[gn]=8;for(var gn=144;gn<256;++gn)_f[gn]=9;for(var gn=256;gn<280;++gn)_f[gn]=7;for(var gn=280;gn<288;++gn)_f[gn]=8;var bB=new Or(32);for(var gn=0;gn<32;++gn)bB[gn]=5;var zz=_h(_f,9,1),Hz=_h(bB,5,1),H0=function(n){for(var e=n[0],t=1;te&&(e=n[t]);return e},Kr=function(n,e,t){var i=e/8|0;return(n[i]|n[i+1]<<8)>>(e&7)&t},G0=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},Gz=function(n){return(n/8|0)+(n&7&&1)},Vz=function(n,e,t){(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length);var i=new(n instanceof Oo?Oo:n instanceof Gy?Gy:Or)(t-e);return i.set(n.subarray(e,t)),i},Wz=function(n,e,t){var i=n.length;if(!i||t&&!t.l&&i<5)return e||new Or(0);var r=!e||t,s=!t||t.i;t||(t={}),e||(e=new Or(i*3));var o=function(Me){var Ue=e.length;if(Me>Ue){var nt=new Or(Math.max(Ue*2,Me));nt.set(e),e=nt}},a=t.f||0,l=t.p||0,h=t.b||0,f=t.l,d=t.d,p=t.m,g=t.n,_=i*8;do{if(!f){t.f=a=Kr(n,l,1);var S=Kr(n,l+1,3);if(l+=3,S)if(S==1)f=zz,d=Hz,p=9,g=5;else if(S==2){var A=Kr(n,l,31)+257,M=Kr(n,l+10,15)+4,C=A+Kr(n,l+5,31)+1;l+=14;for(var T=new Or(C),R=new Or(19),D=0;D>>4;if(y<16)T[D++]=y;else{var ae=0,W=0;for(y==16?(W=3+Kr(n,l,3),l+=2,ae=T[D-1]):y==17?(W=3+Kr(n,l,7),l+=3):y==18&&(W=11+Kr(n,l,127),l+=7);W--;)T[D++]=ae}}var $=T.subarray(0,A),ie=T.subarray(A);p=H0($),g=H0(ie),f=_h($,p,1),d=_h(ie,g,1)}else throw"invalid block type";else{var y=Gz(l)+4,m=n[y-4]|n[y-3]<<8,x=y+m;if(x>i){if(s)throw"unexpected EOF";break}r&&o(h+m),e.set(n.subarray(y,x),h),t.b=h+=m,t.p=l=x*8;continue}if(l>_){if(s)throw"unexpected EOF";break}}r&&o(h+131072);for(var fe=(1<>>4;if(l+=ae&15,l>_){if(s)throw"unexpected EOF";break}if(!ae)throw"invalid length/literal";if(Y<256)e[h++]=Y;else if(Y==256){Q=l,f=null;break}else{var re=Y-254;if(Y>264){var D=Y-257,ue=MB[D];re=Kr(n,l,(1<>>4;if(!se)throw"invalid distance";l+=se&15;var ie=kz[_e];if(_e>3){var ue=wB[_e];ie+=G0(n,l)&(1<_){if(s)throw"unexpected EOF";break}r&&o(h+131072);for(var Pe=h+re;h>>4>7||(n[0]<<8|n[1])%31)throw"invalid zlib data";if(n[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Sp(n,e){return Wz((Jz(n),n.subarray(2,-4)),e)}var Yz=typeof TextDecoder<"u"&&new TextDecoder,Kz=0;try{Yz.decode(Xz,{stream:!0}),Kz=1}catch{}const Zz=n=>n&&n.isCubeTexture;class Qz extends Un{constructor(e,t){var i,r;const s=Zz(e),a=((r=s?(i=e.image[0])==null?void 0:i.width:e.image.width)!=null?r:1024)/4,l=Math.floor(Math.log2(a)),h=Math.pow(2,l),f=3*Math.max(h,16*7),d=4*h,p=[s?"#define ENVMAP_TYPE_CUBE":"",`#define CUBEUV_TEXEL_WIDTH ${1/f}`,`#define CUBEUV_TEXEL_HEIGHT ${1/d}`,`#define CUBEUV_MAX_MIP ${l}.0`],g=` varying vec3 vWorldPosition; void main() { vec4 worldPosition = ( modelMatrix * vec4( position, 1.0 ) ); vWorldPosition = worldPosition.xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); } `,_=p.join(` `)+` #define ENVMAP_TYPE_CUBE_UV varying vec3 vWorldPosition; uniform float radius; uniform float height; uniform float angle; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube map; #else uniform sampler2D map; #endif // From: https://www.shadertoy.com/view/4tsBD7 float diskIntersectWithBackFaceCulling( vec3 ro, vec3 rd, vec3 c, vec3 n, float r ) { float d = dot ( rd, n ); if( d > 0.0 ) { return 1e6; } vec3 o = ro - c; float t = - dot( n, o ) / d; vec3 q = o + rd * t; return ( dot( q, q ) < r * r ) ? t : 1e6; } // From: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm float sphereIntersect( vec3 ro, vec3 rd, vec3 ce, float ra ) { vec3 oc = ro - ce; float b = dot( oc, rd ); float c = dot( oc, oc ) - ra * ra; float h = b * b - c; if( h < 0.0 ) { return -1.0; } h = sqrt( h ); return - b + h; } vec3 project() { vec3 p = normalize( vWorldPosition ); vec3 camPos = cameraPosition; camPos.y -= height; float intersection = sphereIntersect( camPos, p, vec3( 0.0 ), radius ); if( intersection > 0.0 ) { vec3 h = vec3( 0.0, - height, 0.0 ); float intersection2 = diskIntersectWithBackFaceCulling( camPos, p, h, vec3( 0.0, 1.0, 0.0 ), radius ); p = ( camPos + min( intersection, intersection2 ) * p ) / radius; } else { p = vec3( 0.0, 1.0, 0.0 ); } return p; } #include #include void main() { vec3 projectedWorldPosition = project(); #ifdef ENVMAP_TYPE_CUBE vec3 outcolor = textureCube( map, projectedWorldPosition ).rgb; #else vec3 direction = normalize( projectedWorldPosition ); vec2 uv = equirectUv( direction ); vec3 outcolor = texture2D( map, uv ).rgb; #endif gl_FragColor = vec4( outcolor, 1.0 ); #include #include <${parseInt(cl.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}> } `,S={map:{value:e},height:{value:(t==null?void 0:t.height)||15},radius:{value:(t==null?void 0:t.radius)||100}},y=new df(1,16),m=new nr({uniforms:S,fragmentShader:_,vertexShader:g,side:Fr});super(y,m)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}class GA extends Bi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new tH(t)}),this.register(function(t){return new cH(t)}),this.register(function(t){return new uH(t)}),this.register(function(t){return new hH(t)}),this.register(function(t){return new iH(t)}),this.register(function(t){return new rH(t)}),this.register(function(t){return new sH(t)}),this.register(function(t){return new oH(t)}),this.register(function(t){return new eH(t)}),this.register(function(t){return new aH(t)}),this.register(function(t){return new nH(t)}),this.register(function(t){return new lH(t)}),this.register(function(t){return new qz(t)}),this.register(function(t){return new fH(t)}),this.register(function(t){return new dH(t)})}load(e,t,i,r){const s=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=Cs.extractUrlBase(e),this.manager.itemStart(e);const a=function(h){r?r(h):console.error(h),s.manager.itemError(e),s.manager.itemEnd(e)},l=new vr(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{s.parse(h,o,function(f){t(f),s.manager.itemEnd(e)},a)}catch(f){a(f)}},i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let s;const o={},a={};if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(Cs.decodeText(new Uint8Array(e.slice(0,4)))===BB){try{o[Vt.KHR_BINARY_GLTF]=new pH(e)}catch(f){r&&r(f);return}s=JSON.parse(o[Vt.KHR_BINARY_GLTF].content)}else s=JSON.parse(Cs.decodeText(new Uint8Array(e)));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new CH(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,s){i.parse(e,t,r,s)})}}function jz(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const Vt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class qz{constructor(e){this.parser=e,this.name=Vt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class uH{constructor(e){this.parser=e,this.name=Vt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=r.images[o.source];let l=i.textureLoader;if(a.uri){const h=i.options.manager.getHandler(a.uri);h!==null&&(l=h)}return this.detectSupport().then(function(h){if(h)return i.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class hH{constructor(e){this.parser=e,this.name=Vt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=r.images[o.source];let l=i.textureLoader;if(a.uri){const h=i.options.manager.getHandler(a.uri);h!==null&&(l=h)}return this.detectSupport().then(function(h){if(h)return i.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class fH{constructor(e){this.name=Vt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=r.byteOffset||0,h=r.byteLength||0,f=r.count,d=r.byteStride,p=new Uint8Array(a,l,h);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(f,d,p,r.mode,r.filter).then(function(g){return g.buffer}):o.ready.then(function(){const g=new ArrayBuffer(f*d);return o.decodeGltfBuffer(new Uint8Array(g),f,d,p,r.mode,r.filter),g})})}else return null}}class dH{constructor(e){this.name=Vt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const h of r.primitives)if(h.mode!==Lr.TRIANGLES&&h.mode!==Lr.TRIANGLE_STRIP&&h.mode!==Lr.TRIANGLE_FAN&&h.mode!==void 0)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const h in o)a.push(this.parser.getDependency("accessor",o[h]).then(f=>(l[h]=f,l[h])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(h=>{const f=h.pop(),d=f.isGroup?f.children:[f],p=h[0].count,g=[];for(const _ of d){const S=new lt,y=new k,m=new Xn,x=new k(1,1,1),A=new pA(_.geometry,_.material,p);for(let M=0;M=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},To={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},xH={CUBICSPLINE:void 0,LINEAR:sl,STEP:kc},W0={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function AH(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new gf({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Rs})),n.DefaultMaterial}function Ra(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function Po(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function SH(n,e,t){let i=!1,r=!1,s=!1;for(let h=0,f=e.length;h0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const TH=new lt;class CH{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new jz,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=!1,s=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||r&&s<98?this.textureLoader=new zb(this.options.manager):this.textureLoader=new Kb(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new vr(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};Ra(s,a,r),Po(a,r),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,s=t.length;r{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[h,f]of o.children.entries())s(f,a.children[h])};return s(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i=2&&y.setY(b,T[R*l+1]),l>=3&&y.setZ(b,T[R*l+2]),l>=4&&y.setW(b,T[R*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const t=this.json,i=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=i.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,i){const r=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const h=this.loadImageSource(t,i).then(function(f){f.flipY=!1,f.name=o.name||a.name||"",f.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(f.name=a.uri);const p=(s.samplers||{})[o.sampler]||{};return f.magFilter=Ew[p.magFilter]||cn,f.minFilter=Ew[p.minFilter]||Bs,f.wrapS=Mw[p.wrapS]||qo,f.wrapT=Mw[p.wrapT]||qo,r.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[l]=h,h}loadImageSource(e,t){const i=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=r.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",h=!1;if(o.bufferView!==void 0)l=i.getDependency("bufferView",o.bufferView).then(function(d){h=!0;const p=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(p),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(l).then(function(d){return new Promise(function(p,g){let _=p;t.isImageBitmapLoader===!0&&(_=function(S){const y=new _n(S);y.needsUpdate=!0,p(y)}),t.load(Cs.resolveURL(d,s.path),_,void 0,g)})}).then(function(d){return h===!0&&a.revokeObjectURL(l),d.userData.mimeType=o.mimeType||wH(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=f,f}assignTexture(e,t,i,r){const s=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),s.extensions[Vt.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[Vt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[Vt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return r!==void 0&&("colorSpace"in o?o.colorSpace=r===3001?"srgb":"srgb-linear":o.encoding=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new tg,Jn.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(a,l)),i=l}else if(e.isLine){const a="LineBasicMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new bi,Jn.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(a,l)),i=l}if(r||s||o){let a="ClonedMaterial:"+i.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=i.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return gf}loadMaterial(e){const t=this,i=this.json,r=this.extensions,s=i.materials[e];let o;const a={},l=s.extensions||{},h=[];if(l[Vt.KHR_MATERIALS_UNLIT]){const d=r[Vt.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),h.push(d.extendParams(a,s,t))}else{const d=s.pbrMetallicRoughness||{};if(a.color=new Ne(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;a.color.fromArray(p),a.opacity=p[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",d.baseColorTexture,3001)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Fr);const f=s.alphaMode||W0.OPAQUE;if(f===W0.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,f===W0.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==fr&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Se(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;a.normalScale.set(d,d)}return s.occlusionTexture!==void 0&&o!==fr&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==fr&&(a.emissive=new Ne().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&o!==fr&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,3001)),Promise.all(h).then(function(){const d=new o(a);return s.name&&(d.name=s.name),Po(d,s),t.associations.set(d,{materials:e}),s.extensions&&Ra(r,d,s),d})}createUniqueName(e){const t=Xt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function s(a){return i[Vt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return ww(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&EH(m,s),m.name=t.createUniqueName(s.name||"mesh_"+e),Po(m,s),y.extensions&&Ra(r,m,y),t.assignFinalMaterial(m),d.push(m)}for(let g=0,_=d.length;g<_;g++)t.associations.set(d[g],{meshes:e,primitives:g});if(d.length===1)return s.extensions&&Ra(r,d[0],s),d[0];const p=new js;s.extensions&&Ra(r,p,s),t.associations.set(p,{meshes:e});for(let g=0,_=d.length;g<_;g++)p.add(d[g]);return p})}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new jn(Za.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new eu(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Po(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,s=t.joints.length;r1?f=new js:h.length===1?f=h[0]:f=new Jt,f!==h[0])for(let d=0,p=h.length;d{const d=new Map;for(const[p,g]of r.associations)(p instanceof Jn||p instanceof _n)&&d.set(p,g);return f.traverse(p=>{const g=r.associations.get(p);g!=null&&d.set(p,g)}),d};return r.associations=h(s),s})}}function RH(n,e,t){const i=e.attributes,r=new $n;if(i.POSITION!==void 0){const a=t.json.accessors[i.POSITION],l=a.min,h=a.max;if(l!==void 0&&h!==void 0){if(r.set(new k(l[0],l[1],l[2]),new k(h[0],h[1],h[2])),a.normalized){const f=Xy(bc[a.componentType]);r.min.multiplyScalar(f),r.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new k,l=new k;for(let h=0,f=s.length;h(D=O.indexOf(d))&&b=A.byteLength||!(I=p(A)))return a(1,"no header found");if(!(O=I.match(M)))return a(3,"bad initial token");for(b.valid|=1,b.programtype=O[1],b.string+=I+` `;I=p(A),I!==!1;){if(b.string+=I+` `,I.charAt(0)==="#"){b.comments+=I+` `;continue}if((O=I.match(C))&&(b.gamma=parseFloat(O[1])),(O=I.match(T))&&(b.exposure=parseFloat(O[1])),(O=I.match(R))&&(b.valid|=2,b.format=O[1]),(O=I.match(D))&&(b.valid|=4,b.height=parseInt(O[1],10),b.width=parseInt(O[2],10)),b.valid&2&&b.valid&4)break}return b.valid&2?b.valid&4?b:a(3,"missing image size specifier"):a(3,"missing format specifier")},_=function(A,M,C){const T=M;if(T<8||T>32767||A[0]!==2||A[1]!==2||A[2]&128)return new Uint8Array(A);if(T!==(A[2]<<8|A[3]))return a(3,"wrong scanline width");const R=new Uint8Array(4*M*C);if(!R.length)return a(4,"unable to allocate buffer space");let D=0,b=0;const I=4*T,O=new Uint8Array(4),j=new Uint8Array(I);let ae=C;for(;ae>0&&bA.byteLength)return a(1);if(O[0]=A[b++],O[1]=A[b++],O[2]=A[b++],O[3]=A[b++],O[0]!=2||O[1]!=2||(O[2]<<8|O[3])!=T)return a(3,"bad rgbe scanline format");let W=0,$;for(;W128;if(fe&&($-=128),$===0||W+$>I)return a(3,"bad scanline data");if(fe){const H=A[b++];for(let Q=0;Q<$;Q++)j[W++]=H}else j.set(A.subarray(b,b+$),W),W+=$,b+=$}const ie=T;for(let fe=0;fe>3]&1<<(P&7))&&(F[Z++]=P);for(var z=Z-1;Z<65536;)F[Z++]=0;return z}function O(L){for(var F=0;F<16384;F++)L[F]={},L[F].len=0,L[F].lit=0,L[F].p=null}const j={l:0,c:0,lc:0};function ae(L,F,Z,P,z){for(;Z>Z&(1<0;--F){var P=Z+W[F]>>1;W[F]=Z,Z=P}for(var F=0;F<65537;++F){var z=L[F];z>0&&(L[F]=z|W[z]++<<6)}}function ie(L,F,Z,P,z,G,J){for(var X=Z,ce=0,de=0;z<=G;z++){if(X.value-Z.value>P)return!1;ae(6,ce,de,L,X);var ge=j.l;if(ce=j.c,de=j.lc,J[z]=ge,ge==63){if(X.value-Z.value>P)throw"Something wrong with hufUnpackEncTable";ae(8,ce,de,L,X);var me=j.l+6;if(ce=j.c,de=j.lc,z+me>G+1)throw"Something wrong with hufUnpackEncTable";for(;me--;)J[z++]=0;z--}else if(ge>=59){var me=ge-59+2;if(z+me>G+1)throw"Something wrong with hufUnpackEncTable";for(;me--;)J[z++]=0;z--}}$(J)}function fe(L){return L&63}function H(L){return L>>6}function Q(L,F,Z,P){for(;F<=Z;F++){var z=H(L[F]),G=fe(L[F]);if(z>>G)throw"Invalid table entry";if(G>14){var J=P[z>>G-14];if(J.len)throw"Invalid table entry";if(J.lit++,J.p){var X=J.p;J.p=new Array(J.lit);for(var ce=0;ce0;ce--){var J=P[(z<<14-G)+de];if(J.len||J.p)throw"Invalid table entry";J.len=G,J.lit=F,de++}}return!0}const Y={c:0,lc:0};function re(L,F,Z,P){L=L<<8|Ze(Z,P),F+=8,Y.c=L,Y.lc=F}const ue={c:0,lc:0};function se(L,F,Z,P,z,G,J,X,ce,de){if(L==F){P<8&&(re(Z,P,z,J),Z=Y.c,P=Y.lc),P-=8;var ge=Z>>P,ge=new Uint8Array([ge])[0];if(ce.value+ge>de)return!1;for(var me=X[ce.value-1];ge-- >0;)X[ce.value++]=me}else if(ce.value32767?F-65536:F}const Me={a:0,b:0};function Ue(L,F){var Z=Pe(L),P=Pe(F),z=P,G=Z+(z&1)+(z>>1),J=G,X=G-z;Me.a=J,Me.b=X}function nt(L,F){var Z=_e(L),P=_e(F),z=Z-(P>>1)&65535,G=P+z-32768&65535;Me.a=G,Me.b=z}function _t(L,F,Z,P,z,G,J){for(var X=J<16384,ce=Z>z?z:Z,de=1,ge;de<=ce;)de<<=1;for(de>>=1,ge=de,de>>=1;de>=1;){for(var me=0,Xe=me+G*(z-ge),we=G*de,be=G*ge,Qe=P*de,at=P*ge,ht,Et,Je,Fe;me<=Xe;me+=be){for(var Ot=me,mt=me+P*(Z-ge);Ot<=mt;Ot+=at){var xt=Ot+Qe,sn=Ot+we,Bn=sn+Qe;X?(Ue(L[Ot+F],L[sn+F]),ht=Me.a,Je=Me.b,Ue(L[xt+F],L[Bn+F]),Et=Me.a,Fe=Me.b,Ue(ht,Et),L[Ot+F]=Me.a,L[xt+F]=Me.b,Ue(Je,Fe),L[sn+F]=Me.a,L[Bn+F]=Me.b):(nt(L[Ot+F],L[sn+F]),ht=Me.a,Je=Me.b,nt(L[xt+F],L[Bn+F]),Et=Me.a,Fe=Me.b,nt(ht,Et),L[Ot+F]=Me.a,L[xt+F]=Me.b,nt(Je,Fe),L[sn+F]=Me.a,L[Bn+F]=Me.b)}if(Z&de){var sn=Ot+we;X?Ue(L[Ot+F],L[sn+F]):nt(L[Ot+F],L[sn+F]),ht=Me.a,L[sn+F]=Me.b,L[Ot+F]=ht}}if(z&de)for(var Ot=me,mt=me+P*(Z-ge);Ot<=mt;Ot+=at){var xt=Ot+Qe;X?Ue(L[Ot+F],L[xt+F]):nt(L[Ot+F],L[xt+F]),ht=Me.a,L[xt+F]=Me.b,L[Ot+F]=ht}ge=de,de>>=1}return me}function et(L,F,Z,P,z,G,J,X,ce,de){for(var ge=0,me=0,Xe=X,we=Math.trunc(z.value+(G+7)/8);z.value=14;){var be=ge>>me-14&16383,Qe=F[be];if(Qe.len)me-=Qe.len,se(Qe.lit,J,ge,me,Z,P,z,ce,de,Xe),ge=ue.c,me=ue.lc;else{if(!Qe.p)throw"hufDecode issues";var at;for(at=0;at=ht&&H(L[Qe.p[at]])==(ge>>me-ht&(1<>=Et,me-=Et;me>0;){var Qe=F[ge<<14-me&16383];if(Qe.len)me-=Qe.len,se(Qe.lit,J,ge,me,Z,P,z,ce,de,Xe),ge=ue.c,me=ue.lc;else throw"hufDecode issues"}return!0}function it(L,F,Z,P,z,G){var J={value:0},X=Z.value,ce=Ke(F,Z),de=Ke(F,Z);Z.value+=4;var ge=Ke(F,Z);if(Z.value+=4,ce<0||ce>=65537||de<0||de>=65537)throw"Something wrong with HUF_ENCSIZE";var me=new Array(65537),Xe=new Array(16384);O(Xe);var we=P-(Z.value-X);if(ie(L,F,Z,we,ce,de,me),ge>8*(P-(Z.value-X)))throw"Something wrong with hufUncompress";Q(me,ce,de,Xe),et(me,Xe,L,F,Z,ge,de,G,z,J)}function K(L,F,Z){for(var P=0;PG||(F[z++]=L[Z++],z>G));)F[z++]=L[P++]}function Le(L){for(var F=L.byteLength,Z=new Array,P=0,z=new DataView(L);F>0;){var G=z.getInt8(P++);if(G<0){var J=-G;F-=J+1;for(var X=0;X>8==255?z+=P&255:(Z[z]=P,z++),L.value++}function Ve(L,F){F[0]=he(L[0]),F[1]=he(L[1]),F[2]=he(L[5]),F[3]=he(L[6]),F[4]=he(L[14]),F[5]=he(L[15]),F[6]=he(L[27]),F[7]=he(L[28]),F[8]=he(L[2]),F[9]=he(L[4]),F[10]=he(L[7]),F[11]=he(L[13]),F[12]=he(L[16]),F[13]=he(L[26]),F[14]=he(L[29]),F[15]=he(L[42]),F[16]=he(L[3]),F[17]=he(L[8]),F[18]=he(L[12]),F[19]=he(L[17]),F[20]=he(L[25]),F[21]=he(L[30]),F[22]=he(L[41]),F[23]=he(L[43]),F[24]=he(L[9]),F[25]=he(L[11]),F[26]=he(L[18]),F[27]=he(L[24]),F[28]=he(L[31]),F[29]=he(L[40]),F[30]=he(L[44]),F[31]=he(L[53]),F[32]=he(L[10]),F[33]=he(L[19]),F[34]=he(L[23]),F[35]=he(L[32]),F[36]=he(L[39]),F[37]=he(L[45]),F[38]=he(L[52]),F[39]=he(L[54]),F[40]=he(L[20]),F[41]=he(L[22]),F[42]=he(L[33]),F[43]=he(L[38]),F[44]=he(L[46]),F[45]=he(L[51]),F[46]=he(L[55]),F[47]=he(L[60]),F[48]=he(L[21]),F[49]=he(L[34]),F[50]=he(L[37]),F[51]=he(L[47]),F[52]=he(L[50]),F[53]=he(L[56]),F[54]=he(L[59]),F[55]=he(L[61]),F[56]=he(L[35]),F[57]=he(L[36]),F[58]=he(L[48]),F[59]=he(L[49]),F[60]=he(L[57]),F[61]=he(L[58]),F[62]=he(L[62]),F[63]=he(L[63])}function N(L){const F=.5*Math.cos(.7853975),Z=.5*Math.cos(3.14159/16),P=.5*Math.cos(3.14159/8),z=.5*Math.cos(3*3.14159/16),G=.5*Math.cos(5*3.14159/16),J=.5*Math.cos(3*3.14159/8),X=.5*Math.cos(7*3.14159/16);for(var ce=new Array(4),de=new Array(4),ge=new Array(4),me=new Array(4),Xe=0;Xe<8;++Xe){var we=Xe*8;ce[0]=P*L[we+2],ce[1]=J*L[we+2],ce[2]=P*L[we+6],ce[3]=J*L[we+6],de[0]=Z*L[we+1]+z*L[we+3]+G*L[we+5]+X*L[we+7],de[1]=z*L[we+1]-X*L[we+3]-Z*L[we+5]-G*L[we+7],de[2]=G*L[we+1]-Z*L[we+3]+X*L[we+5]+z*L[we+7],de[3]=X*L[we+1]-G*L[we+3]+z*L[we+5]-Z*L[we+7],ge[0]=F*(L[we+0]+L[we+4]),ge[3]=F*(L[we+0]-L[we+4]),ge[1]=ce[0]+ce[3],ge[2]=ce[1]-ce[2],me[0]=ge[0]+ge[1],me[1]=ge[3]+ge[2],me[2]=ge[3]-ge[2],me[3]=ge[0]-ge[1],L[we+0]=me[0]+de[0],L[we+1]=me[1]+de[1],L[we+2]=me[2]+de[2],L[we+3]=me[3]+de[3],L[we+4]=me[3]-de[3],L[we+5]=me[2]-de[2],L[we+6]=me[1]-de[1],L[we+7]=me[0]-de[0]}for(var be=0;be<8;++be)ce[0]=P*L[16+be],ce[1]=J*L[16+be],ce[2]=P*L[48+be],ce[3]=J*L[48+be],de[0]=Z*L[8+be]+z*L[24+be]+G*L[40+be]+X*L[56+be],de[1]=z*L[8+be]-X*L[24+be]-Z*L[40+be]-G*L[56+be],de[2]=G*L[8+be]-Z*L[24+be]+X*L[40+be]+z*L[56+be],de[3]=X*L[8+be]-G*L[24+be]+z*L[40+be]-Z*L[56+be],ge[0]=F*(L[be]+L[32+be]),ge[3]=F*(L[be]-L[32+be]),ge[1]=ce[0]+ce[3],ge[2]=ce[1]-ce[2],me[0]=ge[0]+ge[1],me[1]=ge[3]+ge[2],me[2]=ge[3]-ge[2],me[3]=ge[0]-ge[1],L[0+be]=me[0]+de[0],L[8+be]=me[1]+de[1],L[16+be]=me[2]+de[2],L[24+be]=me[3]+de[3],L[32+be]=me[3]-de[3],L[40+be]=me[2]-de[2],L[48+be]=me[1]-de[1],L[56+be]=me[0]-de[0]}function U(L){for(var F=0;F<64;++F){var Z=L[0][F],P=L[1][F],z=L[2][F];L[0][F]=Z+1.5747*z,L[1][F]=Z-.1873*P-.4682*z,L[2][F]=Z+1.8556*P}}function oe(L,F,Z){for(var P=0;P<64;++P)F[Z+P]=Ga.toHalfFloat(Re(L[P]))}function Re(L){return L<=1?Math.sign(L)*Math.pow(Math.abs(L),2.2):Math.sign(L)*Math.pow(b,Math.abs(L)-1)}function Te(L){return new DataView(L.array.buffer,L.offset.value,L.size)}function Ee(L){var F=L.viewer.buffer.slice(L.offset.value,L.offset.value+L.size),Z=new Uint8Array(Le(F)),P=new Uint8Array(Z.length);return Be(Z),xe(Z,P),new DataView(P.buffer)}function $e(L){var F=L.array.slice(L.offset.value,L.offset.value+L.size),Z=Sp(F),P=new Uint8Array(Z.length);return Be(Z),xe(Z,P),new DataView(P.buffer)}function ke(L){for(var F=L.viewer,Z={value:L.offset.value},P=new Uint16Array(L.width*L.scanlineBlockSize*(L.channels*L.type)),z=new Uint8Array(8192),G=0,J=new Array(L.channels),X=0;X=8192)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(ce<=de)for(var X=0;X0;){var X=yt(F.buffer,Z),ce=gt(F,Z),de=ce>>2&3,ge=(ce>>4)-1,me=new Int8Array([ge])[0],Xe=gt(F,Z);G.push({name:X,index:me,type:Xe,compression:de}),J-=X.length+3}for(var we=Vi.channels,be=new Array(L.channels),Qe=0;Qe=0&&(Et.idx[Fe.index]=Je),at.offset=Je)}if(z.acCompressedSize>0)switch(z.acCompression){case 0:var xt=new Uint16Array(z.totalAcUncompressedCount);it(L.array,F,Z,z.acCompressedSize,xt,z.totalAcUncompressedCount);break;case 1:var Ot=L.array.slice(Z.value,Z.value+z.totalAcUncompressedCount),mt=Sp(Ot),xt=new Uint16Array(mt.buffer);Z.value+=z.totalAcUncompressedCount;break}if(z.dcCompressedSize>0){var sn={array:L.array,offset:Z,size:z.dcCompressedSize},Bn=new Uint16Array($e(sn).buffer);Z.value+=z.dcCompressedSize}if(z.rleRawSize>0){var Ot=L.array.slice(Z.value,Z.value+z.rleCompressedSize),mt=Sp(Ot),yn=Le(mt.buffer);Z.value+=z.rleCompressedSize}for(var Wt=0,kt=new Array(be.length),Qe=0;Qe>10,Z=L&1023;return(L>>15?-1:1)*(F?F===31?Z?NaN:1/0:Math.pow(2,F-15)*(1+Z/1024):6103515625e-14*(Z/1024))}function q(L,F){var Z=L.getUint16(F.value,!0);return F.value+=2,Z}function ze(L,F){return he(q(L,F))}function He(L,F,Z,P){for(var z=Z.value,G=[];Z.valueRt.height?Rt.height-F:Rt.scanlineBlockSize;const P=Rt.size=Rt.height)break;for(let J=0;J{const a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){const s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const l in t.attributeTypes){const h=t.attributeTypes[l];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=h.name)}const i=JSON.stringify(t);if(J0.has(e)){const l=J0.get(e);if(l.key===i)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(r=l,new Promise((h,f)=>{r._callbacks[s]={resolve:h,reject:f},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),J0.set(e,{key:i,promise:a}),a}_createGeometry(e){const t=new Tt;e.index&&t.setIndex(new Yt(e.index.array,1));for(let i=0;i{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const s=DH.toString(),o=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(` `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengths._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const d=f.draco,p=new d.Decoder,g=new d.DecoderBuffer;g.Init(new Int8Array(l),l.byteLength);try{const _=t(d,p,g,h),S=_.attributes.map(y=>y.array.buffer);_.index&&S.push(_.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:_},S)}catch(_){console.error(_),self.postMessage({type:"error",id:a.id,error:_.message})}finally{d.destroy(g),d.destroy(p)}});break}};function t(o,a,l,h){const f=h.attributeIDs,d=h.attributeTypes;let p,g;const _=a.GetEncodedGeometryType(l);if(_===o.TRIANGULAR_MESH)p=new o.Mesh,g=a.DecodeBufferToMesh(l,p);else if(_===o.POINT_CLOUD)p=new o.PointCloud,g=a.DecodeBufferToPointCloud(l,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!g.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());const S={index:null,attributes:[]};for(const y in f){const m=self[d[y]];let x,A;if(h.useUniqueIDs)A=f[y],x=a.GetAttributeByUniqueId(p,A);else{if(A=a.GetAttributeId(p,o[f[y]]),A===-1)continue;x=a.GetAttribute(p,A)}S.attributes.push(r(o,a,p,y,m,x))}return _===o.TRIANGULAR_MESH&&(S.index=i(o,a,p)),o.destroy(p),S}function i(o,a,l){const f=l.num_faces()*3,d=f*4,p=o._malloc(d);a.GetTrianglesUInt32Array(l,d,p);const g=new Uint32Array(o.HEAPF32.buffer,p,f).slice();return o._free(p),{array:g,itemSize:1}}function r(o,a,l,h,f,d){const p=d.num_components(),_=l.num_points()*p,S=_*f.BYTES_PER_ELEMENT,y=s(o,f),m=o._malloc(S);a.GetAttributeDataArrayForAllPoints(l,d,y,S,m);const x=new f(o.HEAPF32.buffer,m,_).slice();return o._free(m),{name:h,array:x,itemSize:p}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}let Ep;const Y0=()=>{if(Ep)return Ep;const n="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",e="B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if(typeof WebAssembly!="object")return{supported:!1};let r=n;WebAssembly.validate(t)&&(r=e);let s;const o=WebAssembly.instantiate(a(r),{}).then(d=>{s=d.instance,s.exports.__wasm_call_ctors()});function a(d){const p=new Uint8Array(d.length);for(let _=0;_96?S-71:S>64?S-65:S>47?S+4:S>46?63:62}let g=0;for(let _=0;_{const d=oA.clone({[h]:{value:f}});return{...l,...d}},{}),vertexShader:e,fragmentShader:t}),this.key="",a.forEach(([l])=>Object.defineProperty(this,l,{get:()=>this.uniforms[l].value,set:h=>this.uniforms[l].value=h})),Object.assign(this,o),i&&i(this)}};return r.key=Za.generateUUID(),r}const UH=()=>parseInt(cl.replace(/\D+/g,"")),LB=UH();let Mp=null,DB="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function UB(n,e,t){return i=>{t&&t(i),n&&(Mp||(Mp=new LH),Mp.setDecoderPath(typeof n=="string"?n:DB),i.setDRACOLoader(Mp)),e&&i.setMeshoptDecoder(typeof Y0=="function"?Y0():Y0)}}function yg(n,e=!0,t=!0,i){return su(GA,n,UB(e,t,i))}yg.preload=(n,e=!0,t=!0,i)=>su.preload(GA,n,UB(e,t,i));yg.clear=n=>su.clear(GA,n);yg.setDecoderPath=n=>{DB=n};/*! * camera-controls * https://github.com/yomotsu/camera-controls * (c) 2017 @yomotsu * Released under the MIT License. */const At={LEFT:1,RIGHT:2,MIDDLE:4},ye=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),jl={NONE:0,IN:1,OUT:-1};function ba(n){return n.isPerspectiveCamera}function Co(n){return n.isOrthographicCamera}const ql=Math.PI*2,Tw=Math.PI/2,FB=1e-5,Ku=Math.PI/180;function Zr(n,e,t){return Math.max(e,Math.min(t,n))}function hn(n,e=FB){return Math.abs(n)0==g>f&&(g=f,t.value=(g-f)/s),g}function Rw(n,e,t,i,r=1/0,s,o){i=Math.max(1e-4,i);const a=2/i,l=a*s,h=1/(1+l+.48*l*l+.235*l*l*l);let f=e.x,d=e.y,p=e.z,g=n.x-f,_=n.y-d,S=n.z-p;const y=f,m=d,x=p,A=r*i,M=A*A,C=g*g+_*_+S*S;if(C>M){const $=Math.sqrt(C);g=g/$*A,_=_/$*A,S=S/$*A}f=n.x-g,d=n.y-_,p=n.z-S;const T=(t.x+a*g)*s,R=(t.y+a*_)*s,D=(t.z+a*S)*s;t.x=(t.x-a*T)*h,t.y=(t.y-a*R)*h,t.z=(t.z-a*D)*h,o.x=f+(g+T)*h,o.y=d+(_+R)*h,o.z=p+(S+D)*h;const b=y-n.x,I=m-n.y,O=x-n.z,j=o.x-y,ae=o.y-m,W=o.z-x;return b*j+I*ae+O*W>0&&(o.x=y,o.y=m,o.z=x,t.x=(o.x-y)/s,t.y=(o.y-m)/s,t.z=(o.z-x)/s),o}function K0(n,e){e.set(0,0),n.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=n.length,e.y/=n.length}function Z0(n,e){return Co(n)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class FH{constructor(){this._listeners={}}addEventListener(e,t){const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){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{},this._enabled=!0,this._state=ye.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=jl.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new vt.Vector3,this._focalOffsetVelocity=new vt.Vector3,this._zoomVelocity={value:0},this._truckInternal=(M,C,T)=>{let R,D;if(ba(this._camera)){const b=It.copy(this._camera.position).sub(this._target),I=this._camera.getEffectiveFOV()*Ku,O=b.length()*Math.tan(I*.5);R=this.truckSpeed*M*O/this._elementRect.height,D=this.truckSpeed*C*O/this._elementRect.height}else if(Co(this._camera)){const b=this._camera;R=M*(b.right-b.left)/b.zoom/this._elementRect.width,D=C*(b.top-b.bottom)/b.zoom/this._elementRect.height}else return;this.verticalDragToForward?(T?this.setFocalOffset(this._focalOffsetEnd.x+R,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(R,0,!0),this.forward(-D,!0)):T?this.setFocalOffset(this._focalOffsetEnd.x+R,this._focalOffsetEnd.y+D,this._focalOffsetEnd.z,!0):this.truck(R,D,!0)},this._rotateInternal=(M,C)=>{const T=ql*this.azimuthRotateSpeed*M/this._elementRect.height,R=ql*this.polarRotateSpeed*C/this._elementRect.height;this.rotate(T,R,!0)},this._dollyInternal=(M,C,T)=>{const R=Math.pow(.95,-M*this.dollySpeed),D=this._sphericalEnd.radius,b=this._sphericalEnd.radius*R,I=Zr(b,this.minDistance,this.maxDistance),O=I-b;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(b,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(O,!0),this._dollyToNoClamp(I,!0)):this._dollyToNoClamp(I,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?b:I)-D,this._dollyControlCoord.set(C,T)),this._lastDollyDirection=Math.sign(-M)},this._zoomInternal=(M,C,T)=>{const R=Math.pow(.95,M*this.dollySpeed),D=this._zoom,b=this._zoom*R;this.zoomTo(b,!0),this.dollyToCursor&&(this._changedZoom+=b-D,this._dollyControlCoord.set(C,T))},typeof vt>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new vt.Quaternion().setFromUnitVectors(this._camera.up,Cp),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=ye.NONE,this._target=new vt.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new vt.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new vt.Spherical().setFromVector3(It.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new vt.Vector3,new vt.Vector3,new vt.Vector3,new vt.Vector3],this._updateNearPlaneCorners(),this._boundary=new vt.Box3(new vt.Vector3(-1/0,-1/0,-1/0),new vt.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new vt.Vector2,this.mouseButtons={left:ye.ROTATE,middle:ye.DOLLY,right:ye.TRUCK,wheel:ba(this._camera)?ye.DOLLY:Co(this._camera)?ye.ZOOM:ye.NONE},this.touches={one:ye.TOUCH_ROTATE,two:ba(this._camera)?ye.TOUCH_DOLLY_TRUCK:Co(this._camera)?ye.TOUCH_ZOOM_TRUCK:ye.NONE,three:ye.TOUCH_TRUCK};const i=new vt.Vector2,r=new vt.Vector2,s=new vt.Vector2,o=M=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const R=this._domElement.getBoundingClientRect(),D=M.clientX/R.width,b=M.clientY/R.height;if(Dthis._interactiveArea.right||bthis._interactiveArea.bottom)return}const C=M.pointerType!=="mouse"?null:(M.buttons&At.LEFT)===At.LEFT?At.LEFT:(M.buttons&At.MIDDLE)===At.MIDDLE?At.MIDDLE:(M.buttons&At.RIGHT)===At.RIGHT?At.RIGHT:null;if(C!==null){const R=this._findPointerByMouseButton(C);R&&this._disposePointer(R)}if((M.buttons&At.LEFT)===At.LEFT&&this._lockedPointer)return;const T={pointerId:M.pointerId,clientX:M.clientX,clientY:M.clientY,deltaX:0,deltaY:0,mouseButton:C};this._activePointers.push(T),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",f),this._isDragging=!0,S(M)},a=M=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const R=this._domElement.getBoundingClientRect(),D=M.clientX/R.width,b=M.clientY/R.height;if(Dthis._interactiveArea.right||bthis._interactiveArea.bottom)return}const C=(M.buttons&At.LEFT)===At.LEFT?At.LEFT:(M.buttons&At.MIDDLE)===At.MIDDLE?At.MIDDLE:(M.buttons&At.RIGHT)===At.RIGHT?At.RIGHT:null;if(C!==null){const R=this._findPointerByMouseButton(C);R&&this._disposePointer(R)}const T={pointerId:1,clientX:M.clientX,clientY:M.clientY,deltaX:0,deltaY:0,mouseButton:(M.buttons&At.LEFT)===At.LEFT?At.LEFT:(M.buttons&At.MIDDLE)===At.LEFT?At.MIDDLE:(M.buttons&At.RIGHT)===At.LEFT?At.RIGHT:null};this._activePointers.push(T),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.addEventListener("mousemove",h),this._domElement.ownerDocument.addEventListener("mouseup",d),this._isDragging=!0,S(M)},l=M=>{M.cancelable&&M.preventDefault();const C=M.pointerId,T=this._lockedPointer||this._findPointerById(C);if(T){if(T.clientX=M.clientX,T.clientY=M.clientY,T.deltaX=M.movementX,T.deltaY=M.movementY,this._state=0,M.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(M.buttons&At.LEFT)===At.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(M.buttons&At.MIDDLE)===At.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(M.buttons&At.RIGHT)===At.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},h=M=>{const C=this._lockedPointer||this._findPointerById(1);C&&(C.clientX=M.clientX,C.clientY=M.clientY,C.deltaX=M.movementX,C.deltaY=M.movementY,this._state=0,(this._lockedPointer||(M.buttons&At.LEFT)===At.LEFT)&&(this._state=this._state|this.mouseButtons.left),(M.buttons&At.MIDDLE)===At.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(M.buttons&At.RIGHT)===At.RIGHT&&(this._state=this._state|this.mouseButtons.right),y())},f=M=>{const C=this._findPointerById(M.pointerId);if(!(C&&C===this._lockedPointer)){if(C&&this._disposePointer(C),M.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=ye.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=ye.NONE;m()}},d=()=>{const M=this._findPointerById(1);M&&M===this._lockedPointer||(M&&this._disposePointer(M),this._state=ye.NONE,m())};let p=-1;const g=M=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===ye.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const b=this._domElement.getBoundingClientRect(),I=M.clientX/b.width,O=M.clientY/b.height;if(Ithis._interactiveArea.right||Othis._interactiveArea.bottom)return}if(M.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===ye.ROTATE||this.mouseButtons.wheel===ye.TRUCK){const b=performance.now();p-b<1e3&&this._getClientRect(this._elementRect),p=b}const C=NH?-1:-3,T=M.deltaMode===1?M.deltaY/C:M.deltaY/(C*10),R=this.dollyToCursor?(M.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,D=this.dollyToCursor?(M.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case ye.ROTATE:{this._rotateInternal(M.deltaX,M.deltaY),this._isUserControllingRotate=!0;break}case ye.TRUCK:{this._truckInternal(M.deltaX,M.deltaY,!1),this._isUserControllingTruck=!0;break}case ye.OFFSET:{this._truckInternal(M.deltaX,M.deltaY,!0),this._isUserControllingOffset=!0;break}case ye.DOLLY:{this._dollyInternal(-T,R,D),this._isUserControllingDolly=!0;break}case ye.ZOOM:{this._zoomInternal(-T,R,D),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},_=M=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Jy.ACTION.NONE){const C=M instanceof PointerEvent?M.pointerId:(M instanceof MouseEvent,0),T=this._findPointerById(C);T&&this._disposePointer(T),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",d);return}M.preventDefault()}},S=M=>{if(!this._enabled)return;if(K0(this._activePointers,Yi),this._getClientRect(this._elementRect),i.copy(Yi),r.copy(Yi),this._activePointers.length>=2){const T=Yi.x-this._activePointers[1].clientX,R=Yi.y-this._activePointers[1].clientY,D=Math.sqrt(T*T+R*R);s.set(0,D);const b=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,I=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;r.set(b,I)}if(this._state=0,!M)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in M&&M.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(M.buttons&At.LEFT)===At.LEFT&&(this._state=this._state|this.mouseButtons.left),(M.buttons&At.MIDDLE)===At.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(M.buttons&At.RIGHT)===At.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&ye.ROTATE)===ye.ROTATE||(this._state&ye.TOUCH_ROTATE)===ye.TOUCH_ROTATE||(this._state&ye.TOUCH_DOLLY_ROTATE)===ye.TOUCH_DOLLY_ROTATE||(this._state&ye.TOUCH_ZOOM_ROTATE)===ye.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&ye.TRUCK)===ye.TRUCK||(this._state&ye.TOUCH_TRUCK)===ye.TOUCH_TRUCK||(this._state&ye.TOUCH_DOLLY_TRUCK)===ye.TOUCH_DOLLY_TRUCK||(this._state&ye.TOUCH_ZOOM_TRUCK)===ye.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&ye.DOLLY)===ye.DOLLY||(this._state&ye.TOUCH_DOLLY)===ye.TOUCH_DOLLY||(this._state&ye.TOUCH_DOLLY_TRUCK)===ye.TOUCH_DOLLY_TRUCK||(this._state&ye.TOUCH_DOLLY_OFFSET)===ye.TOUCH_DOLLY_OFFSET||(this._state&ye.TOUCH_DOLLY_ROTATE)===ye.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&ye.ZOOM)===ye.ZOOM||(this._state&ye.TOUCH_ZOOM)===ye.TOUCH_ZOOM||(this._state&ye.TOUCH_ZOOM_TRUCK)===ye.TOUCH_ZOOM_TRUCK||(this._state&ye.TOUCH_ZOOM_OFFSET)===ye.TOUCH_ZOOM_OFFSET||(this._state&ye.TOUCH_ZOOM_ROTATE)===ye.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&ye.OFFSET)===ye.OFFSET||(this._state&ye.TOUCH_OFFSET)===ye.TOUCH_OFFSET||(this._state&ye.TOUCH_DOLLY_OFFSET)===ye.TOUCH_DOLLY_OFFSET||(this._state&ye.TOUCH_ZOOM_OFFSET)===ye.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},y=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,K0(this._activePointers,Yi);const C=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,T=C?-C.deltaX:r.x-Yi.x,R=C?-C.deltaY:r.y-Yi.y;if(r.copy(Yi),((this._state&ye.ROTATE)===ye.ROTATE||(this._state&ye.TOUCH_ROTATE)===ye.TOUCH_ROTATE||(this._state&ye.TOUCH_DOLLY_ROTATE)===ye.TOUCH_DOLLY_ROTATE||(this._state&ye.TOUCH_ZOOM_ROTATE)===ye.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(T,R),this._isUserControllingRotate=!0),(this._state&ye.DOLLY)===ye.DOLLY||(this._state&ye.ZOOM)===ye.ZOOM){const D=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,b=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,I=this.dollyDragInverted?-1:1;(this._state&ye.DOLLY)===ye.DOLLY?(this._dollyInternal(I*R*Tp,D,b),this._isUserControllingDolly=!0):(this._zoomInternal(I*R*Tp,D,b),this._isUserControllingZoom=!0)}if((this._state&ye.TOUCH_DOLLY)===ye.TOUCH_DOLLY||(this._state&ye.TOUCH_ZOOM)===ye.TOUCH_ZOOM||(this._state&ye.TOUCH_DOLLY_TRUCK)===ye.TOUCH_DOLLY_TRUCK||(this._state&ye.TOUCH_ZOOM_TRUCK)===ye.TOUCH_ZOOM_TRUCK||(this._state&ye.TOUCH_DOLLY_OFFSET)===ye.TOUCH_DOLLY_OFFSET||(this._state&ye.TOUCH_ZOOM_OFFSET)===ye.TOUCH_ZOOM_OFFSET||(this._state&ye.TOUCH_DOLLY_ROTATE)===ye.TOUCH_DOLLY_ROTATE||(this._state&ye.TOUCH_ZOOM_ROTATE)===ye.TOUCH_ZOOM_ROTATE){const D=Yi.x-this._activePointers[1].clientX,b=Yi.y-this._activePointers[1].clientY,I=Math.sqrt(D*D+b*b),O=s.y-I;s.set(0,I);const j=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,ae=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&ye.TOUCH_DOLLY)===ye.TOUCH_DOLLY||(this._state&ye.TOUCH_DOLLY_ROTATE)===ye.TOUCH_DOLLY_ROTATE||(this._state&ye.TOUCH_DOLLY_TRUCK)===ye.TOUCH_DOLLY_TRUCK||(this._state&ye.TOUCH_DOLLY_OFFSET)===ye.TOUCH_DOLLY_OFFSET?(this._dollyInternal(O*Tp,j,ae),this._isUserControllingDolly=!0):(this._zoomInternal(O*Tp,j,ae),this._isUserControllingZoom=!0)}((this._state&ye.TRUCK)===ye.TRUCK||(this._state&ye.TOUCH_TRUCK)===ye.TOUCH_TRUCK||(this._state&ye.TOUCH_DOLLY_TRUCK)===ye.TOUCH_DOLLY_TRUCK||(this._state&ye.TOUCH_ZOOM_TRUCK)===ye.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(T,R,!1),this._isUserControllingTruck=!0),((this._state&ye.OFFSET)===ye.OFFSET||(this._state&ye.TOUCH_OFFSET)===ye.TOUCH_OFFSET||(this._state&ye.TOUCH_DOLLY_OFFSET)===ye.TOUCH_DOLLY_OFFSET||(this._state&ye.TOUCH_ZOOM_OFFSET)===ye.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(T,R,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},m=()=>{K0(this._activePointers,Yi),r.copy(Yi),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.ownerDocument.removeEventListener("mouseup",d),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",x),this._domElement.ownerDocument.addEventListener("pointerlockerror",A),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",f),S())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",x),this._domElement.ownerDocument.removeEventListener("pointerlockerror",A))};const x=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},A=()=>{this.unlockPointer()};this._addAllEventListeners=M=>{this._domElement=M,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),kH&&this._domElement.addEventListener("mousedown",a),this._domElement.addEventListener("pointercancel",f),this._domElement.addEventListener("wheel",g,{passive:!1}),this._domElement.addEventListener("contextmenu",_)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("mousedown",a),this._domElement.removeEventListener("pointercancel",f),this._domElement.removeEventListener("wheel",g,{passive:!1}),this._domElement.removeEventListener("contextmenu",_),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.removeEventListener("pointerlockchange",x),this._domElement.ownerDocument.removeEventListener("pointerlockerror",A))},this.cancel=()=>{this._state!==ye.NONE&&(this._state=ye.NONE,this._activePointers.length=0,m())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Zr(e.width,0,1),this._interactiveArea.height=Zr(e.height,0,1),this._interactiveArea.x=Zr(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Zr(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,i=!1){this._isUserControllingRotate=!1;const r=Zr(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=Zr(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=s,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!i||nn(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&nn(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=jl.NONE,this._changedDolly=0,this._dollyToNoClamp(Zr(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),a=nn(o,this._spherical.radius);if(!(i>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const s=!t||nn(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(ju).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||nn(this._target.x,this._targetEnd.x,this.restThreshold)&&nn(this._target.y,this._targetEnd.y,this.restThreshold)&&nn(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Zr(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||nn(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),_s.setFromMatrixColumn(this._camera.matrix,0),ys.setFromMatrixColumn(this._camera.matrix,1),_s.multiplyScalar(e),ys.multiplyScalar(-t);const r=It.copy(_s).add(ys),s=qt.copy(this._targetEnd).add(r);return this.moveTo(s.x,s.y,s.z,i)}forward(e,t=!1){It.setFromMatrixColumn(this._camera.matrix,0),It.crossVectors(this._camera.up,It),It.multiplyScalar(e);const i=qt.copy(this._targetEnd).add(It);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return It.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+It.x,this._targetEnd.y+It.y,this._targetEnd.z+It.z,t)}moveTo(e,t,i,r=!1){this._isUserControllingTruck=!1;const s=It.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,s,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);const o=!r||nn(this._target.x,this._targetEnd.x,this.restThreshold)&&nn(this._target.y,this._targetEnd.y,this.restThreshold)&&nn(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,i,r=!1){const a=It.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(a.x,a.y,a.z,r)}fitToBox(e,t,{cover:i=!1,paddingLeft:r=0,paddingRight:s=0,paddingBottom:o=0,paddingTop:a=0}={}){const l=[],h=e.isBox3?ec.copy(e):ec.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const f=Cw(this._sphericalEnd.theta,Tw),d=Cw(this._sphericalEnd.phi,Tw);l.push(this.rotateTo(f,d,t));const p=It.setFromSpherical(this._sphericalEnd).normalize(),g=Lw.setFromUnitVectors(p,Q0),_=nn(Math.abs(p.y),1);_&&g.multiply(q0.setFromAxisAngle(Cp,f)),g.multiply(this._yAxisUpSpaceInverse);const S=Iw.makeEmpty();qt.copy(h.min).applyQuaternion(g),S.expandByPoint(qt),qt.copy(h.min).setX(h.max.x).applyQuaternion(g),S.expandByPoint(qt),qt.copy(h.min).setY(h.max.y).applyQuaternion(g),S.expandByPoint(qt),qt.copy(h.max).setZ(h.min.z).applyQuaternion(g),S.expandByPoint(qt),qt.copy(h.min).setZ(h.max.z).applyQuaternion(g),S.expandByPoint(qt),qt.copy(h.max).setY(h.min.y).applyQuaternion(g),S.expandByPoint(qt),qt.copy(h.max).setX(h.min.x).applyQuaternion(g),S.expandByPoint(qt),qt.copy(h.max).applyQuaternion(g),S.expandByPoint(qt),S.min.x-=r,S.min.y-=o,S.max.x+=s,S.max.y+=a,g.setFromUnitVectors(Q0,p),_&&g.premultiply(q0.invert()),g.premultiply(this._yAxisUpSpace);const y=S.getSize(It),m=S.getCenter(qt).applyQuaternion(g);if(ba(this._camera)){const x=this.getDistanceToFitBox(y.x,y.y,y.z,i);l.push(this.moveTo(m.x,m.y,m.z,t)),l.push(this.dollyTo(x,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(Co(this._camera)){const x=this._camera,A=x.right-x.left,M=x.top-x.bottom,C=i?Math.max(A/y.x,M/y.y):Math.min(A/y.x,M/y.y);l.push(this.moveTo(m.x,m.y,m.z,t)),l.push(this.zoomTo(C,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const i=[],s=e instanceof vt.Sphere?j0.copy(e):Jy.createBoundingSphere(e,j0);if(i.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),ba(this._camera)){const o=this.getDistanceToFitSphere(s.radius);i.push(this.dollyTo(o,t))}else if(Co(this._camera)){const o=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*s.radius,h=Math.min(o/l,a/l);i.push(this.zoomTo(h,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,r,s,o,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=jl.NONE,this._changedDolly=0;const l=qt.set(r,s,o),h=It.set(e,t,i);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(h.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const f=!a||nn(this._target.x,this._targetEnd.x,this.restThreshold)&&nn(this._target.y,this._targetEnd.y,this.restThreshold)&&nn(this._target.z,this._targetEnd.z,this.restThreshold)&&nn(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&nn(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&nn(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(f)}lerpLookAt(e,t,i,r,s,o,a,l,h,f,d,p,g,_=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=jl.NONE,this._changedDolly=0;const S=It.set(r,s,o),y=qt.set(e,t,i);Pr.setFromVector3(y.sub(S).applyQuaternion(this._yAxisUpSpace));const m=$l.set(f,d,p),x=qt.set(a,l,h);qu.setFromVector3(x.sub(m).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(S.lerp(m,g));const A=qu.theta-Pr.theta,M=qu.phi-Pr.phi,C=qu.radius-Pr.radius;this._sphericalEnd.set(Pr.radius+C*g,Pr.phi+M*g,Pr.theta+A*g),this.normalizeRotations(),this._needsUpdate=!0,_||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!_||nn(this._target.x,this._targetEnd.x,this.restThreshold)&&nn(this._target.y,this._targetEnd.y,this.restThreshold)&&nn(this._target.z,this._targetEnd.z,this.restThreshold)&&nn(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&nn(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&nn(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}setPosition(e,t,i,r=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(e,t,i,r=!1){const s=this.getPosition(It),o=this.setLookAt(s.x,s.y,s.z,e,t,i,r);return this._sphericalEnd.phi=Zr(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,i,r=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd);const s=!r||nn(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&nn(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&nn(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),_s.setFromMatrixColumn(this._camera.matrixWorldInverse,0),ys.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Ba.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const r=It.set(e,t,i),s=r.distanceTo(this._camera.position),o=r.sub(this._camera.position);_s.multiplyScalar(o.x),ys.multiplyScalar(o.y),Ba.multiplyScalar(o.z),It.copy(_s).add(ys).add(Ba),It.z=It.z+s,this.dollyTo(s,!1),this.setFocalOffset(-It.x,It.y,-It.z,!1),this.moveTo(e,t,i,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,i,r){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new vt.Vector4,typeof e=="number"?this._viewport.set(e,t,i,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,i,r=!1){if(Z0(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,o=this._camera.getEffectiveFOV()*Ku,a=this._camera.aspect;return((r?s>a:st.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,i){const r=t.lengthSq();if(r===0)return e;const s=qt.copy(t).add(e),a=this._boundary.clampPoint(s,$l).sub(s),l=a.lengthSq();if(l===0)return e.add(t);if(l===r)return e;if(i===0)return e.add(t).add(a);{const h=1+i*l/t.dot(a);return e.add(qt.copy(t).multiplyScalar(h)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(ba(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*Ku,r=Math.tan(i*.5)*t,s=r*e.aspect;this._nearPlaneCorners[0].set(-s,-r,0),this._nearPlaneCorners[1].set(s,-r,0),this._nearPlaneCorners[2].set(s,r,0),this._nearPlaneCorners[3].set(-s,r,0)}else if(Co(this._camera)){const e=this._camera,t=1/e.zoom,i=e.left*t,r=e.right*t,s=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(i,s,0),this._nearPlaneCorners[1].set(r,s,0),this._nearPlaneCorners[2].set(r,o,0),this._nearPlaneCorners[3].set(i,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Z0(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(ju);$0.lookAt(bw,i,this._camera.up);for(let r=0;r<4;r++){const s=qt.copy(this._nearPlaneCorners[r]);s.applyMatrix4($0);const o=$l.addVectors(this._target,s);Rp.set(o,i),Rp.far=this._spherical.radius+1;const a=Rp.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance{const i=()=>{this.removeEventListener("rest",i),t()};this.addEventListener("rest",i)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new vt.Sphere){const i=t,r=i.center;ec.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&ec.expandByObject(o)}),ec.getCenter(r);let s=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const a=o,l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const f=l.attributes.position;for(let d=0,p=f.count;d{ee.useMemo(()=>{const C={Box3:$n,MathUtils:{clamp:Za.clamp},Matrix4:lt,Quaternion:Xn,Raycaster:vg,Sphere:ei,Spherical:$b,Vector2:Se,Vector3:k,Vector4:rn};e_.install({THREE:C}),_g({CameraControlsImpl:e_})},[]);const{camera:t,domElement:i,makeDefault:r,onStart:s,onEnd:o,onChange:a,regress:l,...h}=n,f=Vn(C=>C.camera),d=Vn(C=>C.gl),p=Vn(C=>C.invalidate),g=Vn(C=>C.events),_=Vn(C=>C.setEvents),S=Vn(C=>C.set),y=Vn(C=>C.get),m=Vn(C=>C.performance),x=t||f,A=i||g.connected||d.domElement,M=ee.useMemo(()=>new e_(x),[x]);return ru((C,T)=>{M.enabled&&M.update(T)},-1),ee.useEffect(()=>(M.connect(A),()=>void M.disconnect()),[A,M]),ee.useEffect(()=>{const C=D=>{p(),l&&m.regress(),a&&a(D)},T=D=>{s&&s(D)},R=D=>{o&&o(D)};return M.addEventListener("update",C),M.addEventListener("controlstart",T),M.addEventListener("controlend",R),M.addEventListener("control",C),M.addEventListener("transitionstart",C),M.addEventListener("wake",C),()=>{M.removeEventListener("update",C),M.removeEventListener("controlstart",T),M.removeEventListener("controlend",R),M.removeEventListener("control",C),M.removeEventListener("transitionstart",C),M.removeEventListener("wake",C)}},[M,s,o,p,_,l,a]),ee.useEffect(()=>{if(r){const C=y().controls;return S({controls:M}),()=>S({controls:C})}},[r,M]),ee.createElement("primitive",dr({ref:e,object:M},h))}),NB=ee.forwardRef(function({children:e,disable:t,disableX:i,disableY:r,disableZ:s,left:o,right:a,top:l,bottom:h,front:f,back:d,onCentered:p,precise:g=!0,cacheKey:_=0,...S},y){const m=ee.useRef(null),x=ee.useRef(null),A=ee.useRef(null);return ee.useLayoutEffect(()=>{x.current.matrixWorld.identity();const M=new $n().setFromObject(A.current,g),C=new k,T=new ei,R=M.max.x-M.min.x,D=M.max.y-M.min.y,b=M.max.z-M.min.z;M.getCenter(C),M.getBoundingSphere(T);const I=l?D/2:h?-D/2:0,O=o?-R/2:a?R/2:0,j=f?b/2:d?-b/2:0;x.current.position.set(t||i?0:-C.x+O,t||r?0:-C.y+I,t||s?0:-C.z+j),typeof p<"u"&&p({parent:m.current.parent,container:m.current,width:R,height:D,depth:b,boundingBox:M,boundingSphere:T,center:C,verticalAlignment:I,horizontalAlignment:O,depthAlignment:j})},[_,p,l,o,f,t,i,r,s,g,a,h,d]),ee.useImperativeHandle(y,()=>m.current,[]),ee.createElement("group",dr({ref:m},S),ee.createElement("group",{ref:x},ee.createElement("group",{ref:A},e)))}),HH=IB({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");var Ir=function(n){return n[n.NONE=0]="NONE",n[n.START=1]="START",n[n.ACTIVE=2]="ACTIVE",n}(Ir||{});const tc=n=>n&&n.isOrthographicCamera,GH=n=>n&&n.isBox3,VH=n=>1-Math.exp(-5*n)+.007*n,kB=ee.createContext(null);function WH({children:n,maxDuration:e=1,margin:t=1.2,observe:i,fit:r,clip:s,interpolateFunc:o=VH,onFit:a}){const l=ee.useRef(null),{camera:h,size:f,invalidate:d}=Vn(),p=Vn(C=>C.controls),g=ee.useRef(a);g.current=a;const _=ee.useRef({camPos:new k,camRot:new Xn,camZoom:1}),S=ee.useRef({camPos:void 0,camRot:void 0,camZoom:void 0,camUp:void 0,target:void 0}),y=ee.useRef(Ir.NONE),m=ee.useRef(0),[x]=ee.useState(()=>new $n),A=ee.useMemo(()=>{function C(){const T=x.getSize(new k),R=x.getCenter(new k),D=Math.max(T.x,T.y,T.z),b=tc(h)?D*4:D/(2*Math.atan(Math.PI*h.fov/360)),I=tc(h)?D*4:b/h.aspect,O=t*Math.max(b,I);return{box:x,size:T,center:R,distance:O}}return{getSize:C,refresh(T){if(GH(T))x.copy(T);else{const R=T||l.current;if(!R)return this;R.updateWorldMatrix(!0,!0),x.setFromObject(R)}if(x.isEmpty()){const R=h.position.length()||10;x.setFromCenterAndSize(new k,new k(R,R,R))}return _.current.camPos.copy(h.position),_.current.camRot.copy(h.quaternion),tc(h)&&(_.current.camZoom=h.zoom),S.current.camPos=void 0,S.current.camRot=void 0,S.current.camZoom=void 0,S.current.camUp=void 0,S.current.target=void 0,this},reset(){const{center:T,distance:R}=C(),D=h.position.clone().sub(T).normalize();S.current.camPos=T.clone().addScaledVector(D,R),S.current.target=T.clone();const b=new lt().lookAt(S.current.camPos,S.current.target,h.up);return S.current.camRot=new Xn().setFromRotationMatrix(b),y.current=Ir.START,m.current=0,this},moveTo(T){return S.current.camPos=Array.isArray(T)?new k(...T):T.clone(),y.current=Ir.START,m.current=0,this},lookAt({target:T,up:R}){S.current.target=Array.isArray(T)?new k(...T):T.clone(),R?S.current.camUp=Array.isArray(R)?new k(...R):R.clone():S.current.camUp=h.up.clone();const D=new lt().lookAt(S.current.camPos||h.position,S.current.target,S.current.camUp);return S.current.camRot=new Xn().setFromRotationMatrix(D),y.current=Ir.START,m.current=0,this},to({position:T,target:R}){return this.moveTo(T).lookAt({target:R})},fit(){if(!tc(h))return this.reset();let T=0,R=0;const D=[new k(x.min.x,x.min.y,x.min.z),new k(x.min.x,x.max.y,x.min.z),new k(x.min.x,x.min.y,x.max.z),new k(x.min.x,x.max.y,x.max.z),new k(x.max.x,x.max.y,x.max.z),new k(x.max.x,x.max.y,x.min.z),new k(x.max.x,x.min.y,x.max.z),new k(x.max.x,x.min.y,x.min.z)],b=S.current.camPos||h.position,I=S.current.target||(p==null?void 0:p.target),O=S.current.camUp||h.up,j=I?new lt().lookAt(b,I,O).setPosition(b).invert():h.matrixWorldInverse;for(const $ of D)$.applyMatrix4(j),T=Math.max(T,Math.abs($.y)),R=Math.max(R,Math.abs($.x));T*=2,R*=2;const ae=(h.top-h.bottom)/T,W=(h.right-h.left)/R;return S.current.camZoom=Math.min(ae,W)/t,y.current=Ir.START,m.current=0,g.current&&g.current(this.getSize()),this},clip(){const{distance:T}=C();return h.near=T/100,h.far=T*100,h.updateProjectionMatrix(),p&&(p.maxDistance=T*10,p.update()),d(),this}}},[x,h,p,t,d]);ee.useLayoutEffect(()=>{if(p){const C=()=>{if(p&&S.current.target&&y.current!==Ir.NONE){const T=new k().setFromMatrixColumn(h.matrix,2),R=_.current.camPos.distanceTo(p.target),D=(S.current.camPos||_.current.camPos).distanceTo(S.current.target),b=(1-m.current)*R+m.current*D;p.target.copy(h.position).addScaledVector(T,-b),p.update()}y.current=Ir.NONE};return p.addEventListener("start",C),()=>p.removeEventListener("start",C)}},[p]);const M=ee.useRef(0);return ee.useLayoutEffect(()=>{(i||M.current++===0)&&(A.refresh(),r&&A.reset().fit(),s&&A.clip())},[f,s,r,i,h,p]),ru((C,T)=>{if(y.current===Ir.START)y.current=Ir.ACTIVE,d();else if(y.current===Ir.ACTIVE){if(m.current+=T/e,m.current>=1)S.current.camPos&&h.position.copy(S.current.camPos),S.current.camRot&&h.quaternion.copy(S.current.camRot),S.current.camUp&&h.up.copy(S.current.camUp),S.current.camZoom&&tc(h)&&(h.zoom=S.current.camZoom),h.updateMatrixWorld(),h.updateProjectionMatrix(),p&&S.current.target&&(p.target.copy(S.current.target),p.update()),y.current=Ir.NONE;else{const R=o(m.current);S.current.camPos&&h.position.lerpVectors(_.current.camPos,S.current.camPos,R),S.current.camRot&&h.quaternion.slerpQuaternions(_.current.camRot,S.current.camRot,R),S.current.camUp&&h.up.set(0,1,0).applyQuaternion(h.quaternion),S.current.camZoom&&tc(h)&&(h.zoom=(1-R)*_.current.camZoom+R*S.current.camZoom),h.updateMatrixWorld(),h.updateProjectionMatrix()}d()}}),ee.createElement("group",{ref:l},ee.createElement(kB.Provider,{value:A},n))}function XH(){return ee.useContext(kB)}const t_={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"},JH="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",Dw=n=>Array.isArray(n);function zB({files:n=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],path:e="",preset:t=void 0,encoding:i=void 0,extensions:r}={}){var s;let o=null,a=!1,l;if(t){if(!(t in t_))throw new Error("Preset must be one of: "+Object.keys(t_).join(", "));n=t_[t],e=JH}if(a=Dw(n),l=Dw(n)?"cube":n.startsWith("data:application/exr")?"exr":n.startsWith("data:application/hdr")?"hdr":(s=n.split(".").pop())==null||(s=s.split("?"))==null||(s=s.shift())==null?void 0:s.toLowerCase(),o=a?kb:l==="hdr"?PH:l==="exr"?IH:null,!o)throw new Error("useEnvironment: Unrecognized file extension: "+n);const h=su(o,a?[n]:n,g=>{g.setPath==null||g.setPath(e),r&&r(g)}),f=a?h[0]:h;f.mapping=a?bs:Oc;const d=3001,p=3e3;return"colorSpace"in f?f.colorSpace=i??a?"srgb":"srgb-linear":f.encoding=i??a?d:p,f}const YH=n=>n.current&&n.current.isScene,KH=n=>YH(n)?n.current:n;function VA(n,e,t,i,r=0){const s=KH(e||t),o=s.background,a=s.environment,l=s.backgroundBlurriness||0;return n!=="only"&&(s.environment=i),n&&(s.background=i),n&&s.backgroundBlurriness!==void 0&&(s.backgroundBlurriness=r),()=>{n!=="only"&&(s.environment=a),n&&(s.background=o),n&&s.backgroundBlurriness!==void 0&&(s.backgroundBlurriness=l)}}function WA({scene:n,background:e=!1,blur:t,map:i}){const r=Vn(s=>s.scene);return ee.useLayoutEffect(()=>{if(i)return VA(e,n,r,i,t)},[r,n,i,e,t]),null}function HB({background:n=!1,scene:e,blur:t,...i}){const r=zB(i),s=Vn(o=>o.scene);return ee.useLayoutEffect(()=>VA(n,e,s,r,t),[r,n,e,s,t]),null}function ZH({children:n,near:e=1,far:t=1e3,resolution:i=256,frames:r=1,map:s,background:o=!1,blur:a,scene:l,files:h,path:f,preset:d=void 0,extensions:p}){const g=Vn(A=>A.gl),_=Vn(A=>A.scene),S=ee.useRef(null),[y]=ee.useState(()=>new Xh),m=ee.useMemo(()=>{const A=new aA(i);return A.texture.type=Ci,A},[i]);ee.useLayoutEffect(()=>(r===1&&S.current.update(g,y),VA(o,l,_,m.texture,a)),[n,y,m.texture,l,_,o,r,g]);let x=1;return ru(()=>{(r===1/0||x_g({GroundProjectedEnvImpl:Qz}),[]);const a=ee.useMemo(()=>[o],[o]),l=(e=n.ground)==null?void 0:e.height,h=(t=n.ground)==null?void 0:t.radius,f=(i=(r=n.ground)==null?void 0:r.scale)!==null&&i!==void 0?i:1e3;return ee.createElement(ee.Fragment,null,ee.createElement(WA,dr({},n,{map:o})),ee.createElement("groundProjectedEnvImpl",{args:a,scale:f,height:l,radius:h}))}function jH(n){return n.ground?ee.createElement(QH,n):n.map?ee.createElement(WA,n):n.children?ee.createElement(ZH,n):ee.createElement(HB,n)}const qH=ee.forwardRef(({scale:n=10,frames:e=1/0,opacity:t=1,width:i=1,height:r=1,blur:s=1,near:o=0,far:a=10,resolution:l=512,smooth:h=!0,color:f="#000000",depthWrite:d=!1,renderOrder:p,...g},_)=>{const S=ee.useRef(null),y=Vn(W=>W.scene),m=Vn(W=>W.gl),x=ee.useRef(null);i=i*(Array.isArray(n)?n[0]:n||1),r=r*(Array.isArray(n)?n[1]:n||1);const[A,M,C,T,R,D,b]=ee.useMemo(()=>{const W=new ki(l,l),$=new ki(l,l);$.texture.generateMipmaps=W.texture.generateMipmaps=!1;const ie=new $c(i,r).rotateX(Math.PI/2),fe=new Un(ie),H=new jm;H.depthTest=H.depthWrite=!1,H.onBeforeCompile=re=>{re.uniforms={...re.uniforms,ucolor:{value:new Ne(f)}},re.fragmentShader=re.fragmentShader.replace("void main() {",`uniform vec3 ucolor; void main() { `),re.fragmentShader=re.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")};const Q=new nr(bH),Y=new nr(BH);return Y.depthTest=Q.depthTest=!1,[W,ie,H,fe,Q,Y,$]},[l,i,r,n,f]),I=W=>{T.visible=!0,T.material=R,R.uniforms.tDiffuse.value=A.texture,R.uniforms.h.value=W*1/256,m.setRenderTarget(b),m.render(T,x.current),T.material=D,D.uniforms.tDiffuse.value=b.texture,D.uniforms.v.value=W*1/256,m.setRenderTarget(A),m.render(T,x.current),T.visible=!1};let O=0,j,ae;return ru(()=>{x.current&&(e===1/0||OS.current,[]),ee.createElement("group",dr({"rotation-x":Math.PI/2},g,{ref:S}),ee.createElement("mesh",{renderOrder:p,geometry:M,scale:[1,-1,1],rotation:[-Math.PI/2,0,0]},ee.createElement("meshBasicMaterial",{transparent:!0,map:A.texture,opacity:t,depthWrite:d})),ee.createElement("orthographicCamera",{ref:x,args:[-i/2,i/2,r/2,-r/2,o,a]}))});function $H(n){return n.isLight}function eG(n){return!!n.geometry}const GB=ee.createContext(null),tG=IB({color:new Ne,blend:2,alphaTest:.75,opacity:0,map:null},`varying vec2 vUv; void main() { gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.); vUv = uv; }`,`varying vec2 vUv; uniform sampler2D map; uniform vec3 color; uniform float opacity; uniform float alphaTest; uniform float blend; void main() { vec4 sampledDiffuseColor = texture2D(map, vUv); gl_FragColor = vec4(color * sampledDiffuseColor.r * blend, max(0.0, (1.0 - (sampledDiffuseColor.r + sampledDiffuseColor.g + sampledDiffuseColor.b) / alphaTest)) * opacity); #include #include <${LB>=154?"colorspace_fragment":"encodings_fragment"}> }`),nG=ee.forwardRef(({children:n,temporal:e,frames:t=40,limit:i=1/0,blend:r=20,scale:s=10,opacity:o=1,alphaTest:a=.75,color:l="black",colorBlend:h=2,resolution:f=1024,toneMapped:d=!0,...p},g)=>{_g({SoftShadowMaterial:tG});const _=Vn(T=>T.gl),S=Vn(T=>T.scene),y=Vn(T=>T.camera),m=Vn(T=>T.invalidate),x=ee.useRef(null),A=ee.useRef(null),[M]=ee.useState(()=>new rG(_,S,f));ee.useLayoutEffect(()=>{M.configure(x.current)},[]);const C=ee.useMemo(()=>({lights:new Map,temporal:!!e,frames:Math.max(2,t),blend:Math.max(2,t===1/0?r:t),count:0,getMesh:()=>x.current,reset:()=>{M.clear();const T=x.current.material;T.opacity=0,T.alphaTest=0,C.count=0},update:(T=1)=>{const R=x.current.material;C.temporal?(R.opacity=Math.min(o,R.opacity+o/C.blend),R.alphaTest=Math.min(a,R.alphaTest+a/C.blend)):(R.opacity=o,R.alphaTest=a),A.current.visible=!0,M.prepare();for(let D=0;Db.update()),M.update(y,C.blend);A.current.visible=!1,M.finish()}}),[M,y,S,e,t,r,o,a]);return ee.useLayoutEffect(()=>{C.reset(),!C.temporal&&C.frames!==1/0&&C.update(C.blend)}),ee.useImperativeHandle(g,()=>C,[C]),ru(()=>{(C.temporal||C.frames===1/0)&&C.countnull,ref:A},ee.createElement(GB.Provider,{value:C},n)),ee.createElement("mesh",{receiveShadow:!0,ref:x,scale:s,rotation:[-Math.PI/2,0,0]},ee.createElement("planeGeometry",null),ee.createElement("softShadowMaterial",{transparent:!0,depthWrite:!1,toneMapped:d,color:l,blend:h,map:M.progressiveLightMap2.texture})))}),iG=ee.forwardRef(({castShadow:n=!0,bias:e=.001,mapSize:t=512,size:i=5,near:r=.5,far:s=500,frames:o=1,position:a=[0,0,0],radius:l=1,amount:h=8,intensity:f=LB>=155?Math.PI:1,ambient:d=.5,...p},g)=>{const _=ee.useRef(null),S=new k(...a).length(),y=ee.useContext(GB),m=ee.useCallback(()=>{let A;if(_.current)for(let M=0;M<_.current.children.length;M++)if(A=_.current.children[M],Math.random()>d)A.position.set(a[0]+Za.randFloatSpread(l),a[1]+Za.randFloatSpread(l),a[2]+Za.randFloatSpread(l));else{let C=Math.acos(2*Math.random()-1)-Math.PI/2,T=2*Math.PI*Math.random();A.position.set(Math.cos(C)*Math.cos(T)*S,Math.abs(Math.cos(C)*Math.sin(T)*S),Math.sin(C)*S)}},[l,d,S,...a]),x=ee.useMemo(()=>({update:m}),[m]);return ee.useImperativeHandle(g,()=>x,[x]),ee.useLayoutEffect(()=>{var A;const M=_.current;return y&&((A=y.lights)==null||A.set(M.uuid,x)),()=>{var C;return void(y==null||(C=y.lights)==null?void 0:C.delete(M.uuid))}},[y,x]),ee.createElement("group",dr({ref:_},p),Array.from({length:h},(A,M)=>ee.createElement("directionalLight",{key:M,castShadow:n,"shadow-bias":e,"shadow-mapSize":[t,t],intensity:f/h},ee.createElement("orthographicCamera",{attach:"shadow-camera",args:[-i,i,i,-i,r,s]}))))});class rG{constructor(e,t,i=1024){this.renderer=e,this.res=i,this.scene=t,this.buffer1Active=!1,this.lights=[],this.meshes=[],this.object=null,this.clearColor=new Ne,this.clearAlpha=0;const r={type:Ci,magFilter:An,minFilter:An};this.progressiveLightMap1=new ki(this.res,this.res,r),this.progressiveLightMap2=new ki(this.res,this.res,r),this.discardMat=new HH,this.targetMat=new EA({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:100},this.targetMat.onBeforeCompile=s=>{s.vertexShader=`varying vec2 vUv; `+s.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const o=s.fragmentShader.indexOf("void main() {");s.fragmentShader=`varying vec2 vUv; `+s.fragmentShader.slice(0,o)+`uniform sampler2D previousShadowMap; uniform float averagingWindow; `+s.fragmentShader.slice(o-1,-1)+` vec3 texelOld = texture2D(previousShadowMap, vUv).rgb; gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow); }`,s.uniforms.previousShadowMap=this.previousShadowMap,s.uniforms.averagingWindow=this.averagingWindow}}clear(){this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.lights=[],this.meshes=[],this.scene.traverse(e=>{eG(e)?this.meshes.push({object:e,material:e.material}):$H(e)&&this.lights.push({object:e,intensity:e.intensity})})}prepare(){this.lights.forEach(e=>e.object.intensity=0),this.meshes.forEach(e=>e.object.material=this.discardMat)}finish(){this.lights.forEach(e=>e.object.intensity=e.intensity),this.meshes.forEach(e=>e.object.material=e.material)}configure(e){this.object=e}update(e,t=100){if(!this.object)return;this.averagingWindow.value=t,this.object.material=this.targetMat;const i=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,r=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1,s=this.scene.background;this.scene.background=null,this.renderer.setRenderTarget(i),this.previousShadowMap.value=r.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,e),this.renderer.setRenderTarget(null),this.scene.background=s}}const sG={rembrandt:{main:[1,2,1],fill:[-2,-.5,-2]},portrait:{main:[-1,2,.5],fill:[-1,.5,-1.5]},upfront:{main:[0,2,1],fill:[-1,.5,-1.5]},soft:{main:[-2,4,4],fill:[-1,.5,-1.5]}};function oG({radius:n,adjustCamera:e}){const t=XH();return ee.useEffect(()=>{e&&t.refresh().clip().fit()},[n,e]),null}function aG({children:n,center:e,adjustCamera:t=!0,intensity:i=.5,shadows:r="contact",environment:s="city",preset:o="rembrandt",...a}){var l,h,f,d,p,g,_,S;const y=typeof o=="string"?sG[o]:o,[{radius:m,height:x},A]=ee.useState({radius:0,width:0,height:0,depth:0}),M=(l=r==null?void 0:r.bias)!==null&&l!==void 0?l:-1e-4,C=(h=r==null?void 0:r.normalBias)!==null&&h!==void 0?h:0,T=(f=r==null?void 0:r.size)!==null&&f!==void 0?f:1024,R=(d=r==null?void 0:r.offset)!==null&&d!==void 0?d:0,D=r==="contact"||(r==null?void 0:r.type)==="contact",b=r==="accumulative"||(r==null?void 0:r.type)==="accumulative",I={...typeof r=="object"?r:{}},O=s?typeof s=="string"?{preset:s}:s:null,j=ee.useCallback(ae=>{const{width:W,height:$,depth:ie,boundingSphere:fe}=ae;A({radius:fe.radius,width:W,height:$,depth:ie}),e!=null&&e.onCentered&&e.onCentered(ae)},[]);return ee.createElement(ee.Fragment,null,ee.createElement("ambientLight",{intensity:i/3}),ee.createElement("spotLight",{penumbra:1,position:[y.main[0]*m,y.main[1]*m,y.main[2]*m],intensity:i*2,castShadow:!!r,"shadow-bias":M,"shadow-normalBias":C,"shadow-mapSize":T}),ee.createElement("pointLight",{position:[y.fill[0]*m,y.fill[1]*m,y.fill[2]*m],intensity:i}),ee.createElement(WH,dr({fit:!!t,clip:!!t,margin:Number(t),observe:!0},a),ee.createElement(oG,{radius:m,adjustCamera:t}),ee.createElement(NB,dr({},e,{position:[0,R/2,0],onCentered:j}),n)),ee.createElement("group",{position:[0,-x/2-R/2,0]},D&&ee.createElement(qH,dr({scale:m*4,far:m,blur:2},I)),b&&ee.createElement(nG,dr({temporal:!0,frames:100,alphaTest:.9,toneMapped:!0,scale:m*4},I),ee.createElement(iG,{amount:(p=I.amount)!==null&&p!==void 0?p:8,radius:(g=I.radius)!==null&&g!==void 0?g:m,ambient:(_=I.ambient)!==null&&_!==void 0?_:.5,intensity:(S=I.intensity)!==null&&S!==void 0?S:1,position:[y.main[0]*m,y.main[1]*m,y.main[2]*m],size:m*4,bias:-M,mapSize:T}))),s&&ee.createElement(jH,O))}const lG=document.querySelector("#animation-root").dataset.modelUrl??"/animation-model/aeromine_pilot_015_animated.glb",Uw=1.8,Tm=[{name:"animation_0",copy:"Wind passes through airfoils creating low pressure",frames:{start:0,end:99},camera:{position:[-6,1,-6]}},{name:"animation_1",copy:"Low pressure pulls air up through intake",frames:{start:100,end:199},camera:{position:[-6,1,6]}},{name:"animation_1",copy:"Turbine drives internal generator creating power",frames:{start:200,end:299},camera:{position:[7,0,3]}}],VB=1,n_=Tm[VB].camera.position,cG=()=>li.jsx("div",{className:"loading-spinner"}),uG=()=>li.jsx("div",{className:"loading-screen",children:li.jsx(cG,{})}),hG=({index:n})=>{const{scene:e,animations:t,materials:i}=yg(lG),r=ee.useRef();ee.useEffect(()=>{Object.keys(i).forEach(l=>{const h=i[l];h.transparent=!0})},[i]);const{mixer:s,actions:o}=ee.useMemo(()=>{if(!e)return[];const l=new qb(e),h=t[0],f=[];return Tm.forEach(({name:d,frames:p})=>{const g=Db.subclip(h,d,p.start,p.end),_=l.clipAction(g);f.push(_)}),{mixer:l,actions:f}},[t]);ee.useEffect(()=>{o&&o.forEach((l,h)=>{h===n?l.play():l.stop()})},[n]),ee.useEffect(()=>{var h,f;const{camera:l}=Tm[n];(h=r.current)==null||h.setLookAt(l.position[0],l.position[1],l.position[2],0,0,0,!0),(f=r.current)==null||f.zoomTo(Uw,!0)},[n]),ee.useEffect(()=>{var l,h;(l=r.current)==null||l.setLookAt(n_[0],n_[1],n_[2],0,0,0,!1),(h=r.current)==null||h.zoomTo(Uw,!1)},[]),ru((l,h)=>{s&&s.update(h)});const a=ee.useCallback(l=>{console.log("scene",e),console.log("animations",t),console.log("mixer",s),console.log("actions",o),console.log("controls",r.current),l.object.traverse(h=>{console.log("obj",h)})},[]);return li.jsxs(aG,{adjustCamera:0,intensity:5,shadows:!1,environment:"sunset",children:[li.jsx(zH,{ref:r,makeDefault:!0,minDistance:5,maxDistance:15,truckSpeed:0}),li.jsx("group",{children:li.jsx(NB,{children:li.jsx("primitive",{object:e,onClick:l=>a(l)})})})]})};function fG({index:n,setIndex:e=t=>{}}){const[t,i]=Zp.useState(!1);return ee.useEffect(()=>{setTimeout(()=>i(!0),100)},[]),li.jsx("div",{id:"animation-controls",children:t&&Zp.Children.toArray(Tm.map(({copy:r},s)=>li.jsx("div",{children:r})))})}function dG(){const[n,e]=Zp.useState(VB);return li.jsx(ee.Suspense,{fallback:li.jsx(uG,{}),children:li.jsxs("div",{id:"animation-container",children:[li.jsx(Dz,{children:li.jsx(hG,{index:n})}),li.jsx(fG,{index:n,setIndex:e})]})})}i_.createRoot(document.getElementById("animation-root")).render(li.jsx(Zp.StrictMode,{children:li.jsx(dG,{})}));