(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)}})();var Qs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rC(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var d0={},MM={exports:{}},Fi={},Te={exports:{}},Mt={};/** * @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 Wc=Symbol.for("react.element"),sC=Symbol.for("react.portal"),oC=Symbol.for("react.fragment"),aC=Symbol.for("react.strict_mode"),lC=Symbol.for("react.profiler"),uC=Symbol.for("react.provider"),cC=Symbol.for("react.context"),fC=Symbol.for("react.forward_ref"),hC=Symbol.for("react.suspense"),dC=Symbol.for("react.memo"),pC=Symbol.for("react.lazy"),S1=Symbol.iterator;function mC(n){return n===null||typeof n!="object"?null:(n=S1&&n[S1]||n["@@iterator"],typeof n=="function"?n:null)}var EM={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},TM=Object.assign,AM={};function Gl(n,e,t){this.props=n,this.context=e,this.refs=AM,this.updater=t||EM}Gl.prototype.isReactComponent={};Gl.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")};Gl.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function CM(){}CM.prototype=Gl.prototype;function Qv(n,e,t){this.props=n,this.context=e,this.refs=AM,this.updater=t||EM}var Jv=Qv.prototype=new CM;Jv.constructor=Qv;TM(Jv,Gl.prototype);Jv.isPureReactComponent=!0;var w1=Array.isArray,bM=Object.prototype.hasOwnProperty,Kv={current:null},PM={key:!0,ref:!0,__self:!0,__source:!0};function LM(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)bM.call(e,i)&&!PM.hasOwnProperty(i)&&(r[i]=e[i]);var a=arguments.length-2;if(a===1)r.children=t;else if(1>>1,Y=D[J];if(0>>1;Jr(ye,B))per(Q,ye)?(D[J]=Q,D[pe]=B,J=pe):(D[J]=ye,D[z]=B,J=z);else if(per(Q,B))D[J]=Q,D[pe]=B,J=pe;else break e}}return V}function r(D,V){var B=D.sortIndex-V.sortIndex;return B!==0?B:D.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var c=[],f=[],h=1,d=null,m=3,v=!1,_=!1,E=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(D){for(var V=t(f);V!==null;){if(V.callback===null)i(f);else if(V.startTime<=D)i(f),V.sortIndex=V.expirationTime,e(c,V);else break;V=t(f)}}function T(D){if(E=!1,w(D),!_)if(t(c)!==null)_=!0,oe(C);else{var V=t(f);V!==null&&ue(T,V.startTime-D)}}function C(D,V){_=!1,E&&(E=!1,g(I),I=-1),v=!0;var B=m;try{for(w(V),d=t(c);d!==null&&(!(d.expirationTime>V)||D&&!H());){var J=d.callback;if(typeof J=="function"){d.callback=null,m=d.priorityLevel;var Y=J(d.expirationTime<=V);V=n.unstable_now(),typeof Y=="function"?d.callback=Y:d===t(c)&&i(c),w(V)}else i(c);d=t(c)}if(d!==null)var K=!0;else{var z=t(f);z!==null&&ue(T,z.startTime-V),K=!1}return K}finally{d=null,m=B,v=!1}}var P=!1,R=null,I=-1,b=5,L=-1;function H(){return!(n.unstable_now()-LD||125J?(D.sortIndex=B,e(f,D),t(c)===null&&D===t(f)&&(E?(g(I),I=-1):E=!0,ue(T,B-J))):(D.sortIndex=Y,e(c,D),_||v||(_=!0,oe(C))),D},n.unstable_shouldYield=H,n.unstable_wrapCallback=function(D){var V=m;return function(){var B=m;m=V;try{return D.apply(this,arguments)}finally{m=B}}}})(IM);(function(n){n.exports=IM})(RM);/** * @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 DM=Te.exports,Oi=RM.exports;function we(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"),p0=Object.prototype.hasOwnProperty,xC=/^[: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]*$/,E1={},T1={};function SC(n){return p0.call(T1,n)?!0:p0.call(E1,n)?!1:xC.test(n)?T1[n]=!0:(E1[n]=!0,!1)}function wC(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 MC(n,e,t,i){if(e===null||typeof e>"u"||wC(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 ci(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 Fn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){Fn[n]=new ci(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];Fn[e]=new ci(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){Fn[n]=new ci(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){Fn[n]=new ci(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){Fn[n]=new ci(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){Fn[n]=new ci(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){Fn[n]=new ci(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){Fn[n]=new ci(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){Fn[n]=new ci(n,5,!1,n.toLowerCase(),null,!1,!1)});var ey=/[\-:]([a-z])/g;function ty(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(ey,ty);Fn[e]=new ci(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(ey,ty);Fn[e]=new ci(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(ey,ty);Fn[e]=new ci(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){Fn[n]=new ci(n,1,!1,n.toLowerCase(),null,!1,!1)});Fn.xlinkHref=new ci("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){Fn[n]=new ci(n,1,!1,n.toLowerCase(),null,!0,!0)});function ny(n,e,t,i){var r=Fn.hasOwnProperty(e)?Fn[e]:null;(r!==null?r.type!==0:i||!(2a||r[o]!==s[a]){var c=` `+r[o].replace(" at new "," at ");return n.displayName&&c.includes("")&&(c=c.replace("",n.displayName)),c}while(1<=o&&0<=a);break}}}finally{ng=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Hu(n):""}function EC(n){switch(n.tag){case 5:return Hu(n.type);case 16:return Hu("Lazy");case 13:return Hu("Suspense");case 19:return Hu("SuspenseList");case 0:case 2:case 15:return n=ig(n.type,!1),n;case 11:return n=ig(n.type.render,!1),n;case 1:return n=ig(n.type,!0),n;default:return""}}function y0(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 ll:return"Fragment";case al:return"Portal";case m0:return"Profiler";case iy:return"StrictMode";case g0:return"Suspense";case v0:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case zM:return(n.displayName||"Context")+".Consumer";case kM:return(n._context.displayName||"Context")+".Provider";case ry:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case sy:return e=n.displayName||null,e!==null?e:y0(n.type)||"Memo";case Xs:e=n._payload,n=n._init;try{return y0(n(e))}catch{}}return null}function TC(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 y0(e);case 8:return e===iy?"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 uo(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function OM(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function AC(n){var e=OM(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 hh(n){n._valueTracker||(n._valueTracker=AC(n))}function FM(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),i="";return n&&(i=OM(n)?n.checked?"true":"false":n.value),n=i,n!==t?(e.setValue(n),!0):!1}function zd(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 _0(n,e){var t=e.checked;return rn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t!=null?t:n._wrapperState.initialChecked})}function C1(n,e){var t=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;t=uo(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 BM(n,e){e=e.checked,e!=null&&ny(n,"checked",e,!1)}function x0(n,e){BM(n,e);var t=uo(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")?S0(n,e.type,t):e.hasOwnProperty("defaultValue")&&S0(n,e.type,uo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function b1(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 S0(n,e,t){(e!=="number"||zd(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Gu=Array.isArray;function Ml(n,e,t,i){if(n=n.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=dh.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function uc(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var qu={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},CC=["Webkit","ms","Moz","O"];Object.keys(qu).forEach(function(n){CC.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),qu[e]=qu[n]})});function WM(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||qu.hasOwnProperty(n)&&qu[n]?(""+e).trim():e+"px"}function XM(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var i=t.indexOf("--")===0,r=WM(t,e[t],i);t==="float"&&(t="cssFloat"),i?n.setProperty(t,r):n[t]=r}}var bC=rn({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 E0(n,e){if(e){if(bC[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(we(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(we(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(we(61))}if(e.style!=null&&typeof e.style!="object")throw Error(we(62))}}function T0(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var A0=null;function oy(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var C0=null,El=null,Tl=null;function R1(n){if(n=Yc(n)){if(typeof C0!="function")throw Error(we(280));var e=n.stateNode;e&&(e=gp(e),C0(n.stateNode,n.type,e))}}function jM(n){El?Tl?Tl.push(n):Tl=[n]:El=n}function YM(){if(El){var n=El,e=Tl;if(Tl=El=null,R1(n),e)for(n=0;n>>=0,n===0?32:31-(FC(n)/BC|0)|0}var ph=64,mh=4194304;function Wu(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 Bd(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=Wu(a):(s&=o,s!==0&&(i=Wu(s)))}else o=t&~r,o!==0?i=Wu(o):s!==0&&(i=Wu(s));if(i===0)return 0;if(e!==0&&e!==i&&(e&r)===0&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if((i&4)!==0&&(i|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=i;0t;t++)e.push(n);return e}function Xc(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-Er(e),n[e]=t}function WC(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=Qu),B1=String.fromCharCode(32),V1=!1;function dE(n,e){switch(n){case"keyup":return yb.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pE(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ul=!1;function xb(n,e){switch(n){case"compositionend":return pE(e);case"keypress":return e.which!==32?null:(V1=!0,B1);case"textInput":return n=e.data,n===B1&&V1?null:n;default:return null}}function Sb(n,e){if(ul)return n==="compositionend"||!py&&dE(n,e)?(n=fE(),_d=fy=Js=null,ul=!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=X1(t)}}function yE(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?yE(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function _E(){for(var n=window,e=zd();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=zd(n.document)}return e}function my(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 Lb(n){var e=_E(),t=n.focusedElem,i=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&yE(t.ownerDocument.documentElement,t)){if(i!==null&&my(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=j1(t,s);var o=j1(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,cl=null,D0=null,Ku=null,N0=!1;function Y1(n,e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;N0||cl==null||cl!==zd(i)||(i=cl,"selectionStart"in i&&my(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}),Ku&&mc(Ku,i)||(Ku=i,i=Gd(D0,"onSelect"),0dl||(n.current=B0[dl],B0[dl]=null,dl--)}function Wt(n,e){dl++,B0[dl]=n.current,n.current=e}var co={},Kn=go(co),Si=go(!1),sa=co;function Il(n,e){var t=n.type.contextTypes;if(!t)return co;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 wi(n){return n=n.childContextTypes,n!=null}function Xd(){jt(Si),jt(Kn)}function eS(n,e,t){if(Kn.current!==co)throw Error(we(168));Wt(Kn,e),Wt(Si,t)}function bE(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(we(108,TC(n)||"Unknown",r));return rn({},t,i)}function jd(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||co,sa=Kn.current,Wt(Kn,n),Wt(Si,Si.current),!0}function tS(n,e,t){var i=n.stateNode;if(!i)throw Error(we(169));t?(n=bE(n,e,sa),i.__reactInternalMemoizedMergedChildContext=n,jt(Si),jt(Kn),Wt(Kn,n)):jt(Si),Wt(Si,t)}var hs=null,vp=!1,vg=!1;function PE(n){hs===null?hs=[n]:hs.push(n)}function Hb(n){vp=!0,PE(n)}function vo(){if(!vg&&hs!==null){vg=!0;var n=0,e=kt;try{var t=hs;for(kt=1;n>=o,r-=o,ps=1<<32-Er(e)+r|t<I?(b=R,R=null):b=R.sibling;var L=m(g,R,w[I],T);if(L===null){R===null&&(R=b);break}n&&R&&L.alternate===null&&e(g,R),x=s(L,x,I),P===null?C=L:P.sibling=L,P=L,R=b}if(I===w.length)return t(g,R),Qt&&Oo(g,I),C;if(R===null){for(;II?(b=R,R=null):b=R.sibling;var H=m(g,R,L.value,T);if(H===null){R===null&&(R=b);break}n&&R&&H.alternate===null&&e(g,R),x=s(H,x,I),P===null?C=H:P.sibling=H,P=H,R=b}if(L.done)return t(g,R),Qt&&Oo(g,I),C;if(R===null){for(;!L.done;I++,L=w.next())L=d(g,L.value,T),L!==null&&(x=s(L,x,I),P===null?C=L:P.sibling=L,P=L);return Qt&&Oo(g,I),C}for(R=i(g,R);!L.done;I++,L=w.next())L=v(R,g,I,L.value,T),L!==null&&(n&&L.alternate!==null&&R.delete(L.key===null?I:L.key),x=s(L,x,I),P===null?C=L:P.sibling=L,P=L);return n&&R.forEach(function(q){return e(g,q)}),Qt&&Oo(g,I),C}function S(g,x,w,T){if(typeof w=="object"&&w!==null&&w.type===ll&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case fh:e:{for(var C=w.key,P=x;P!==null;){if(P.key===C){if(C=w.type,C===ll){if(P.tag===7){t(g,P.sibling),x=r(P,w.props.children),x.return=g,g=x;break e}}else if(P.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xs&&lS(C)===P.type){t(g,P.sibling),x=r(P,w.props),x.ref=Tu(g,P,w),x.return=g,g=x;break e}t(g,P);break}else e(g,P);P=P.sibling}w.type===ll?(x=$o(w.props.children,g.mode,T,w.key),x.return=g,g=x):(T=Cd(w.type,w.key,w.props,null,g.mode,T),T.ref=Tu(g,x,w),T.return=g,g=T)}return o(g);case al:e:{for(P=w.key;x!==null;){if(x.key===P)if(x.tag===4&&x.stateNode.containerInfo===w.containerInfo&&x.stateNode.implementation===w.implementation){t(g,x.sibling),x=r(x,w.children||[]),x.return=g,g=x;break e}else{t(g,x);break}else e(g,x);x=x.sibling}x=Tg(w,g.mode,T),x.return=g,g=x}return o(g);case Xs:return P=w._init,S(g,x,P(w._payload),T)}if(Gu(w))return _(g,x,w,T);if(xu(w))return E(g,x,w,T);wh(g,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,x!==null&&x.tag===6?(t(g,x.sibling),x=r(x,w),x.return=g,g=x):(t(g,x),x=Eg(w,g.mode,T),x.return=g,g=x),o(g)):t(g,x)}return S}var Nl=UE(!0),OE=UE(!1),qc={},Wr=go(qc),_c=go(qc),xc=go(qc);function Xo(n){if(n===qc)throw Error(we(174));return n}function Ey(n,e){switch(Wt(xc,e),Wt(_c,n),Wt(Wr,qc),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:M0(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=M0(e,n)}jt(Wr),Wt(Wr,e)}function kl(){jt(Wr),jt(_c),jt(xc)}function FE(n){Xo(xc.current);var e=Xo(Wr.current),t=M0(e,n.type);e!==t&&(Wt(_c,n),Wt(Wr,t))}function Ty(n){_c.current===n&&(jt(Wr),jt(_c))}var $t=go(0);function Kd(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)!==0)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 yg=[];function Ay(){for(var n=0;nt?t:4,n(!0);var i=_g.transition;_g.transition={};try{n(!1),e()}finally{kt=t,_g.transition=i}}function tT(){return or().memoizedState}function jb(n,e,t){var i=oo(n);if(t={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null},nT(n))iT(e,t);else if(t=DE(n,e,t,i),t!==null){var r=ai();Tr(t,n,i,r),rT(t,e,i)}}function Yb(n,e,t){var i=oo(n),r={lane:i,action:t,hasEagerState:!1,eagerState:null,next:null};if(nT(n))iT(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,Cr(a,o)){var c=e.interleaved;c===null?(r.next=r,wy(e)):(r.next=c.next,c.next=r),e.interleaved=r;return}}catch{}finally{}t=DE(n,e,r,i),t!==null&&(r=ai(),Tr(t,n,i,r),rT(t,e,i))}}function nT(n){var e=n.alternate;return n===nn||e!==null&&e===nn}function iT(n,e){$u=$d=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function rT(n,e,t){if((t&4194240)!==0){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,ly(n,t)}}var ep={readContext:sr,useCallback:jn,useContext:jn,useEffect:jn,useImperativeHandle:jn,useInsertionEffect:jn,useLayoutEffect:jn,useMemo:jn,useReducer:jn,useRef:jn,useState:jn,useDebugValue:jn,useDeferredValue:jn,useTransition:jn,useMutableSource:jn,useSyncExternalStore:jn,useId:jn,unstable_isNewReconciler:!1},qb={readContext:sr,useCallback:function(n,e){return Fr().memoizedState=[n,e===void 0?null:e],n},useContext:sr,useEffect:cS,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,Md(4194308,4,QE.bind(null,e,n),t)},useLayoutEffect:function(n,e){return Md(4194308,4,n,e)},useInsertionEffect:function(n,e){return Md(4,2,n,e)},useMemo:function(n,e){var t=Fr();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var i=Fr();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=jb.bind(null,nn,n),[i.memoizedState,n]},useRef:function(n){var e=Fr();return n={current:n},e.memoizedState=n},useState:uS,useDebugValue:Ry,useDeferredValue:function(n){return Fr().memoizedState=n},useTransition:function(){var n=uS(!1),e=n[0];return n=Xb.bind(null,n[1]),Fr().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var i=nn,r=Fr();if(Qt){if(t===void 0)throw Error(we(407));t=t()}else{if(t=e(),Dn===null)throw Error(we(349));(aa&30)!==0||HE(i,e,t)}r.memoizedState=t;var s={value:t,getSnapshot:e};return r.queue=s,cS(WE.bind(null,i,s,n),[n]),i.flags|=2048,Mc(9,GE.bind(null,i,s,t,e),void 0,null),t},useId:function(){var n=Fr(),e=Dn.identifierPrefix;if(Qt){var t=ms,i=ps;t=(i&~(1<<32-Er(i)-1)).toString(32)+t,e=":"+e+"R"+t,t=Sc++,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[Vr]=e,n[yc]=i,dT(n,e,!1,!1),e.stateNode=n;e:{switch(o=T0(t,i),t){case"dialog":Xt("cancel",n),Xt("close",n),r=i;break;case"iframe":case"object":case"embed":Xt("load",n),r=i;break;case"video":case"audio":for(r=0;rUl&&(e.flags|=128,i=!0,Au(s,!1),e.lanes=4194304)}else{if(!i)if(n=Kd(o),n!==null){if(e.flags|=128,i=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Au(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Qt)return Yn(e),null}else 2*dn()-s.renderingStartTime>Ul&&t!==1073741824&&(e.flags|=128,i=!0,Au(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=dn(),e.sibling=null,t=$t.current,Wt($t,i?t&1|2:t&1),e):(Yn(e),null);case 22:case 23:return Uy(),i=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==i&&(e.flags|=8192),i&&(e.mode&1)!==0?(Ri&1073741824)!==0&&(Yn(e),e.subtreeFlags&6&&(e.flags|=8192)):Yn(e),null;case 24:return null;case 25:return null}throw Error(we(156,e.tag))}function nP(n,e){switch(vy(e),e.tag){case 1:return wi(e.type)&&Xd(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return kl(),jt(Si),jt(Kn),Ay(),n=e.flags,(n&65536)!==0&&(n&128)===0?(e.flags=n&-65537|128,e):null;case 5:return Ty(e),null;case 13:if(jt($t),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(we(340));Dl()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return jt($t),null;case 4:return kl(),null;case 10:return Sy(e.type._context),null;case 22:case 23:return Uy(),null;case 24:return null;default:return null}}var Eh=!1,Qn=!1,iP=typeof WeakSet=="function"?WeakSet:Set,ze=null;function vl(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(i){an(n,e,i)}else t.current=null}function K0(n,e,t){try{t()}catch(i){an(n,e,i)}}var _S=!1;function rP(n,e){if(k0=Vd,n=_E(),my(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var i=t.getSelection&&t.getSelection();if(i&&i.rangeCount!==0){t=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var o=0,a=-1,c=-1,f=0,h=0,d=n,m=null;t:for(;;){for(var v;d!==t||r!==0&&d.nodeType!==3||(a=o+r),d!==s||i!==0&&d.nodeType!==3||(c=o+i),d.nodeType===3&&(o+=d.nodeValue.length),(v=d.firstChild)!==null;)m=d,d=v;for(;;){if(d===n)break t;if(m===t&&++f===r&&(a=o),m===s&&++h===i&&(c=o),(v=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=v}t=a===-1||c===-1?null:{start:a,end:c}}else t=null}t=t||{start:0,end:0}}else t=null;for(z0={focusedElem:n,selectionRange:t},Vd=!1,ze=e;ze!==null;)if(e=ze,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,ze=n;else for(;ze!==null;){e=ze;try{var _=e.alternate;if((e.flags&1024)!==0)switch(e.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var E=_.memoizedProps,S=_.memoizedState,g=e.stateNode,x=g.getSnapshotBeforeUpdate(e.elementType===e.type?E:_r(e.type,E),S);g.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(we(163))}}catch(T){an(e,e.return,T)}if(n=e.sibling,n!==null){n.return=e.return,ze=n;break}ze=e.return}return _=_S,_S=!1,_}function ec(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&&K0(e,t,s)}r=r.next}while(r!==i)}}function xp(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 $0(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 gT(n){var e=n.alternate;e!==null&&(n.alternate=null,gT(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Vr],delete e[yc],delete e[F0],delete e[Bb],delete e[Vb])),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 vT(n){return n.tag===5||n.tag===3||n.tag===4}function xS(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||vT(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 ev(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=Wd));else if(i!==4&&(n=n.child,n!==null))for(ev(n,e,t),n=n.sibling;n!==null;)ev(n,e,t),n=n.sibling}function tv(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(tv(n,e,t),n=n.sibling;n!==null;)tv(n,e,t),n=n.sibling}var Un=null,xr=!1;function Fs(n,e,t){for(t=t.child;t!==null;)yT(n,e,t),t=t.sibling}function yT(n,e,t){if(Gr&&typeof Gr.onCommitFiberUnmount=="function")try{Gr.onCommitFiberUnmount(hp,t)}catch{}switch(t.tag){case 5:Qn||vl(t,e);case 6:var i=Un,r=xr;Un=null,Fs(n,e,t),Un=i,xr=r,Un!==null&&(xr?(n=Un,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):Un.removeChild(t.stateNode));break;case 18:Un!==null&&(xr?(n=Un,t=t.stateNode,n.nodeType===8?gg(n.parentNode,t):n.nodeType===1&&gg(n,t),dc(n)):gg(Un,t.stateNode));break;case 4:i=Un,r=xr,Un=t.stateNode.containerInfo,xr=!0,Fs(n,e,t),Un=i,xr=r;break;case 0:case 11:case 14:case 15:if(!Qn&&(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)!==0||(s&4)!==0)&&K0(t,e,o),r=r.next}while(r!==i)}Fs(n,e,t);break;case 1:if(!Qn&&(vl(t,e),i=t.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=t.memoizedProps,i.state=t.memoizedState,i.componentWillUnmount()}catch(a){an(t,e,a)}Fs(n,e,t);break;case 21:Fs(n,e,t);break;case 22:t.mode&1?(Qn=(i=Qn)||t.memoizedState!==null,Fs(n,e,t),Qn=i):Fs(n,e,t);break;default:Fs(n,e,t)}}function SS(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new iP),e.forEach(function(i){var r=dP.bind(null,n,i);t.has(i)||(t.add(i),i.then(r,r))})}}function mr(n,e){var t=e.deletions;if(t!==null)for(var i=0;ir&&(r=o),i&=~s}if(i=r,i=dn()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*oP(i/1960))-i,10n?16:n,Ks===null)var i=!1;else{if(n=Ks,Ks=null,ip=0,(At&6)!==0)throw Error(we(331));var r=At;for(At|=4,ze=n.current;ze!==null;){var s=ze,o=s.child;if((ze.flags&16)!==0){var a=s.deletions;if(a!==null){for(var c=0;cdn()-ky?Ko(n,0):Ny|=t),Mi(n,e)}function AT(n,e){e===0&&((n.mode&1)===0?e=1:(e=mh,mh<<=1,(mh&130023424)===0&&(mh=4194304)));var t=ai();n=Ss(n,e),n!==null&&(Xc(n,e,t),Mi(n,t))}function hP(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),AT(n,t)}function dP(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(we(314))}i!==null&&i.delete(e),AT(n,t)}var CT;CT=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Si.current)xi=!0;else{if((n.lanes&t)===0&&(e.flags&128)===0)return xi=!1,eP(n,e,t);xi=(n.flags&131072)!==0}else xi=!1,Qt&&(e.flags&1048576)!==0&&LE(e,qd,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;Ed(n,e),n=e.pendingProps;var r=Il(e,Kn.current);Cl(e,t),r=by(null,e,i,n,r,t);var s=Py();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,wi(i)?(s=!0,jd(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,My(e),r.updater=yp,e.stateNode=r,r._reactInternals=e,X0(e,i,n,t),e=q0(null,e,i,!0,s,t)):(e.tag=0,Qt&&s&&gy(e),si(null,e,r,t),e=e.child),e;case 16:i=e.elementType;e:{switch(Ed(n,e),n=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=mP(i),n=_r(i,n),r){case 0:e=Y0(null,e,i,n,t);break e;case 1:e=gS(null,e,i,n,t);break e;case 11:e=pS(null,e,i,n,t);break e;case 14:e=mS(null,e,i,_r(i.type,n),t);break e}throw Error(we(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:_r(i,r),Y0(n,e,i,r,t);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:_r(i,r),gS(n,e,i,r,t);case 3:e:{if(cT(e),n===null)throw Error(we(387));i=e.pendingProps,s=e.memoizedState,r=s.element,NE(n,e),Jd(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=zl(Error(we(423)),e),e=vS(n,e,i,t,r);break e}else if(i!==r){r=zl(Error(we(424)),e),e=vS(n,e,i,t,r);break e}else for(Ni=io(e.stateNode.containerInfo.firstChild),zi=e,Qt=!0,wr=null,t=OE(e,null,i,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(Dl(),i===r){e=ws(n,e,t);break e}si(n,e,i,t)}e=e.child}return e;case 5:return FE(e),n===null&&H0(e),i=e.type,r=e.pendingProps,s=n!==null?n.memoizedProps:null,o=r.children,U0(i,r)?o=null:s!==null&&U0(i,s)&&(e.flags|=32),uT(n,e),si(n,e,o,t),e.child;case 6:return n===null&&H0(e),null;case 13:return fT(n,e,t);case 4:return Ey(e,e.stateNode.containerInfo),i=e.pendingProps,n===null?e.child=Nl(e,null,i,t):si(n,e,i,t),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:_r(i,r),pS(n,e,i,r,t);case 7:return si(n,e,e.pendingProps,t),e.child;case 8:return si(n,e,e.pendingProps.children,t),e.child;case 12:return si(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,Wt(Zd,i._currentValue),i._currentValue=o,s!==null)if(Cr(s.value,o)){if(s.children===r.children&&!Si.current){e=ws(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var c=a.firstContext;c!==null;){if(c.context===i){if(s.tag===1){c=vs(-1,t&-t),c.tag=2;var f=s.updateQueue;if(f!==null){f=f.shared;var h=f.pending;h===null?c.next=c:(c.next=h.next,h.next=c),f.pending=c}}s.lanes|=t,c=s.alternate,c!==null&&(c.lanes|=t),G0(s.return,t,e),a.lanes|=t;break}c=c.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(we(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),G0(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}si(n,e,r.children,t),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,Cl(e,t),r=sr(r),i=i(r),e.flags|=1,si(n,e,i,t),e.child;case 14:return i=e.type,r=_r(i,e.pendingProps),r=_r(i.type,r),mS(n,e,i,r,t);case 15:return aT(n,e,e.type,e.pendingProps,t);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:_r(i,r),Ed(n,e),e.tag=1,wi(i)?(n=!0,jd(e)):n=!1,Cl(e,t),zE(e,i,r),X0(e,i,r,t),q0(null,e,i,!0,n,t);case 19:return hT(n,e,t);case 22:return lT(n,e,t)}throw Error(we(156,e.tag))};function bT(n,e){return eE(n,e)}function pP(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 ir(n,e,t,i){return new pP(n,e,t,i)}function Fy(n){return n=n.prototype,!(!n||!n.isReactComponent)}function mP(n){if(typeof n=="function")return Fy(n)?1:0;if(n!=null){if(n=n.$$typeof,n===ry)return 11;if(n===sy)return 14}return 2}function ao(n,e){var t=n.alternate;return t===null?(t=ir(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 Cd(n,e,t,i,r,s){var o=2;if(i=n,typeof n=="function")Fy(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case ll:return $o(t.children,r,s,e);case iy:o=8,r|=8;break;case m0:return n=ir(12,t,e,r|2),n.elementType=m0,n.lanes=s,n;case g0:return n=ir(13,t,e,r),n.elementType=g0,n.lanes=s,n;case v0:return n=ir(19,t,e,r),n.elementType=v0,n.lanes=s,n;case UM:return wp(t,r,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case kM:o=10;break e;case zM:o=9;break e;case ry:o=11;break e;case sy:o=14;break e;case Xs:o=16,i=null;break e}throw Error(we(130,n==null?n:typeof n,""))}return e=ir(o,t,e,r),e.elementType=n,e.type=i,e.lanes=s,e}function $o(n,e,t,i){return n=ir(7,n,i,e),n.lanes=t,n}function wp(n,e,t,i){return n=ir(22,n,i,e),n.elementType=UM,n.lanes=t,n.stateNode={isHidden:!1},n}function Eg(n,e,t){return n=ir(6,n,null,e),n.lanes=t,n}function Tg(n,e,t){return e=ir(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function gP(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=sg(0),this.expirationTimes=sg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sg(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function By(n,e,t,i,r,s,o,a,c){return n=new gP(n,e,t,a,c),e===1?(e=1,s===!0&&(e|=8)):e=0,s=ir(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:i,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},My(s),n}function vP(n,e,t){var i=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}e(),n.exports=Fi})(MM);var PS=MM.exports;d0.createRoot=PS.createRoot,d0.hydrateRoot=PS.hydrateRoot;/** * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT */const Cp="151",wP={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},MP={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},IT=0,ov=1,DT=2,EP=3,NT=0,bp=1,ic=2,jo=3,Ms=0,li=1,nr=2,TP=2,ys=0,ea=1,av=2,lv=3,uv=4,kT=5,Vo=100,zT=101,UT=102,cv=103,fv=104,OT=200,FT=201,BT=202,VT=203,Wy=204,Xy=205,HT=206,GT=207,WT=208,XT=209,jT=210,YT=0,qT=1,ZT=2,op=3,QT=4,JT=5,KT=6,$T=7,Zc=0,e2=1,t2=2,Ar=0,n2=1,i2=2,r2=3,jy=4,s2=5,Pp=300,fo=301,ho=302,Tc=303,Ac=304,jl=306,Cc=1e3,Jn=1001,bc=1002,hn=1003,ap=1004,AP=1004,rc=1005,CP=1005,en=1006,Yy=1007,bP=1007,po=1008,PP=1008,Es=1009,o2=1010,a2=1011,qy=1012,l2=1013,$s=1014,Hr=1015,ca=1016,u2=1017,c2=1018,ta=1020,f2=1021,_i=1023,h2=1024,d2=1025,lo=1026,fa=1027,p2=1028,m2=1029,g2=1030,v2=1031,y2=1033,bd=33776,Pd=33777,Ld=33778,Rd=33779,hv=35840,dv=35841,pv=35842,mv=35843,_2=36196,gv=37492,vv=37496,yv=37808,_v=37809,xv=37810,Sv=37811,wv=37812,Mv=37813,Ev=37814,Tv=37815,Av=37816,Cv=37817,bv=37818,Pv=37819,Lv=37820,Rv=37821,Id=36492,x2=36283,Iv=36284,Dv=36285,Nv=36286,S2=2200,w2=2201,M2=2202,Pc=2300,Lc=2301,Dd=2302,Yo=2400,qo=2401,Rc=2402,Lp=2500,Zy=2501,LP=0,RP=1,IP=2,Ts=3e3,Ot=3001,E2=3200,T2=3201,yo=0,A2=1,DP="",Sr="srgb",Ol="srgb-linear",Qy="display-p3",NP=0,Nd=7680,kP=7681,zP=7682,UP=7683,OP=34055,FP=34056,BP=5386,VP=512,HP=513,GP=514,WP=515,XP=516,jP=517,YP=518,C2=519,Ic=35044,qP=35048,ZP=35040,QP=35045,JP=35049,KP=35041,$P=35046,eL=35050,tL=35042,nL="100",kv="300 es",lp=1035;class bs{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]+qn[n>>16&255]+qn[n>>24&255]+"-"+qn[e&255]+qn[e>>8&255]+"-"+qn[e>>16&15|64]+qn[e>>24&255]+"-"+qn[t&63|128]+qn[t>>8&255]+"-"+qn[t>>16&255]+qn[t>>24&255]+qn[i&255]+qn[i>>8&255]+qn[i>>16&255]+qn[i>>24&255]).toLowerCase()}function ln(n,e,t){return Math.max(e,Math.min(t,n))}function Jy(n,e){return(n%e+e)%e}function iL(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function rL(n,e,t){return n!==e?(t-n)/(e-n):0}function sc(n,e,t){return(1-t)*n+t*e}function sL(n,e,t,i){return sc(n,e,1-Math.exp(-t*i))}function oL(n,e=1){return e-Math.abs(Jy(n,e*2)-e)}function aL(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function lL(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function uL(n,e){return n+Math.floor(Math.random()*(e-n+1))}function cL(n,e){return n+Math.random()*(e-n)}function fL(n){return n*(.5-Math.random())}function hL(n){n!==void 0&&(LS=n);let e=LS+=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 dL(n){return n*na}function pL(n){return n*Fl}function zv(n){return(n&n-1)===0&&n!==0}function b2(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function P2(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function mL(n,e,t,i,r){const s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),f=s((e+i)/2),h=o((e+i)/2),d=s((e-i)/2),m=o((e-i)/2),v=s((i-e)/2),_=o((i-e)/2);switch(r){case"XYX":n.set(a*h,c*d,c*m,a*f);break;case"YZY":n.set(c*m,a*h,c*d,a*f);break;case"ZXZ":n.set(c*d,c*m,a*h,a*f);break;case"XZX":n.set(a*h,c*_,c*v,a*f);break;case"YXY":n.set(c*v,a*h,c*_,a*f);break;case"ZYZ":n.set(c*_,c*v,a*h,a*f);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ki(n,e){switch(e.constructor){case Float32Array:return n;case Uint16Array:return n/65535;case Uint8Array:return n/255;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 Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const Br={DEG2RAD:na,RAD2DEG:Fl,generateUUID:Ui,clamp:ln,euclideanModulo:Jy,mapLinear:iL,inverseLerp:rL,lerp:sc,damp:sL,pingpong:oL,smoothstep:aL,smootherstep:lL,randInt:uL,randFloat:cL,randFloatSpread:fL,seededRandom:hL,degToRad:dL,radToDeg:pL,isPowerOfTwo:zv,ceilPowerOfTwo:b2,floorPowerOfTwo:P2,setQuaternionFromProperEuler:mL,normalize:dt,denormalize:ki};class ge{constructor(e=0,t=0){ge.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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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(ln(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*i-o*r+e.x,this.y=s*r+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class xt{constructor(){xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,i,r,s,o,a,c,f){const h=this.elements;return h[0]=e,h[1]=r,h[2]=a,h[3]=t,h[4]=s,h[5]=c,h[6]=i,h[7]=o,h[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[3],c=i[6],f=i[1],h=i[4],d=i[7],m=i[2],v=i[5],_=i[8],E=r[0],S=r[3],g=r[6],x=r[1],w=r[4],T=r[7],C=r[2],P=r[5],R=r[8];return s[0]=o*E+a*x+c*C,s[3]=o*S+a*w+c*P,s[6]=o*g+a*T+c*R,s[1]=f*E+h*x+d*C,s[4]=f*S+h*w+d*P,s[7]=f*g+h*T+d*R,s[2]=m*E+v*x+_*C,s[5]=m*S+v*w+_*P,s[8]=m*g+v*T+_*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],c=e[6],f=e[7],h=e[8];return t*o*h-t*a*f-i*s*h+i*a*c+r*s*f-r*o*c}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],f=e[7],h=e[8],d=h*o-a*f,m=a*c-h*s,v=f*s-o*c,_=t*d+i*m+r*v;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const E=1/_;return e[0]=d*E,e[1]=(r*f-h*i)*E,e[2]=(a*i-r*o)*E,e[3]=m*E,e[4]=(h*t-r*c)*E,e[5]=(r*s-a*t)*E,e[6]=v*E,e[7]=(i*c-f*t)*E,e[8]=(o*t-i*s)*E,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,o,a){const c=Math.cos(s),f=Math.sin(s);return this.set(i*c,i*f,-i*(c*o+f*a)+o+e,-r*f,r*c,-r*(-f*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Ag.makeScale(e,t)),this}rotate(e){return this.premultiply(Ag.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ag.makeTranslation(e,t)),this}makeTranslation(e,t){return 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 Ag=new xt;function L2(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const gL={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function _l(n,e){return new gL[n](e)}function Dc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function Pl(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Cg(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}const vL=new xt().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),yL=new xt().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function _L(n){return n.convertSRGBToLinear().applyMatrix3(yL)}function xL(n){return n.applyMatrix3(vL).convertLinearToSRGB()}const SL={[Ol]:n=>n,[Sr]:n=>n.convertSRGBToLinear(),[Qy]:_L},wL={[Ol]:n=>n,[Sr]:n=>n.convertLinearToSRGB(),[Qy]:xL},mi={enabled:!1,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(n){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!n},get workingColorSpace(){return Ol},set workingColorSpace(n){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=SL[e],r=wL[t];if(i===void 0||r===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);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)}};let za;class Ky{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{za===void 0&&(za=Dc("canvas")),za.width=e.width,za.height=e.height;const i=za.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=za}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=Dc("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!==Pp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Cc:e.x=e.x-Math.floor(e.x);break;case Jn:e.x=e.x<0?0:1;break;case bc: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 Cc:e.y=e.y-Math.floor(e.y);break;case Jn:e.y=e.y<0?0:1;break;case bc: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)}}un.DEFAULT_IMAGE=null;un.DEFAULT_MAPPING=Pp;un.DEFAULT_ANISOTROPY=1;class Nt{constructor(e=0,t=0,i=0,r=1){Nt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,s;const c=e.elements,f=c[0],h=c[4],d=c[8],m=c[1],v=c[5],_=c[9],E=c[2],S=c[6],g=c[10];if(Math.abs(h-m)<.01&&Math.abs(d-E)<.01&&Math.abs(_-S)<.01){if(Math.abs(h+m)<.1&&Math.abs(d+E)<.1&&Math.abs(_+S)<.1&&Math.abs(f+v+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(f+1)/2,T=(v+1)/2,C=(g+1)/2,P=(h+m)/4,R=(d+E)/4,I=(_+S)/4;return w>T&&w>C?w<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(w),r=P/i,s=R/i):T>C?T<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(T),i=P/r,s=I/r):C<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(C),i=R/s,r=I/s),this.set(i,r,s,t),this}let x=Math.sqrt((S-_)*(S-_)+(d-E)*(d-E)+(m-h)*(m-h));return Math.abs(x)<.001&&(x=1),this.x=(S-_)/x,this.y=(d-E)/x,this.z=(m-h)/x,this.w=Math.acos((f+v+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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 ar extends bs{constructor(e=1,t=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Nt(0,0,e,t),this.scissorTest=!1,this.viewport=new Nt(0,0,e,t);const r={width:e,height:t,depth:1};this.texture=new un(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps!==void 0?i.generateMipmaps:!1,this.texture.internalFormat=i.internalFormat!==void 0?i.internalFormat:null,this.texture.minFilter=i.minFilter!==void 0?i.minFilter:en,this.depthBuffer=i.depthBuffer!==void 0?i.depthBuffer:!0,this.stencilBuffer=i.stencilBuffer!==void 0?i.stencilBuffer:!1,this.depthTexture=i.depthTexture!==void 0?i.depthTexture:null,this.samples=i.samples!==void 0?i.samples:0}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.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 Zo(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 Rp extends un{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=hn,this.minFilter=hn,this.wrapR=Jn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class EL extends ar{constructor(e=1,t=1,i=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Rp(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class $y extends un{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=hn,this.minFilter=hn,this.wrapR=Jn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class TL extends ar{constructor(e=1,t=1,i=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new $y(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class AL extends ar{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,w=1-g*g;if(w>Number.EPSILON){const C=Math.sqrt(w),P=Math.atan2(C,g*x);S=Math.sin(S*P)/C,a=Math.sin(a*P)/C}const T=a*x;if(c=c*S+m*T,f=f*S+v*T,h=h*S+_*T,d=d*S+E*T,S===1-a){const C=1/Math.sqrt(c*c+f*f+h*h+d*d);c*=C,f*=C,h*=C,d*=C}}e[t]=c,e[t+1]=f,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,s,o){const a=i[r],c=i[r+1],f=i[r+2],h=i[r+3],d=s[o],m=s[o+1],v=s[o+2],_=s[o+3];return e[t]=a*_+h*d+c*v-f*m,e[t+1]=c*_+h*m+f*d-a*v,e[t+2]=f*_+h*v+a*m-c*d,e[t+3]=h*_-a*d-c*m-f*v,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const i=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,f=a(i/2),h=a(r/2),d=a(s/2),m=c(i/2),v=c(r/2),_=c(s/2);switch(o){case"XYZ":this._x=m*h*d+f*v*_,this._y=f*v*d-m*h*_,this._z=f*h*_+m*v*d,this._w=f*h*d-m*v*_;break;case"YXZ":this._x=m*h*d+f*v*_,this._y=f*v*d-m*h*_,this._z=f*h*_-m*v*d,this._w=f*h*d+m*v*_;break;case"ZXY":this._x=m*h*d-f*v*_,this._y=f*v*d+m*h*_,this._z=f*h*_+m*v*d,this._w=f*h*d-m*v*_;break;case"ZYX":this._x=m*h*d-f*v*_,this._y=f*v*d+m*h*_,this._z=f*h*_-m*v*d,this._w=f*h*d+m*v*_;break;case"YZX":this._x=m*h*d+f*v*_,this._y=f*v*d+m*h*_,this._z=f*h*_-m*v*d,this._w=f*h*d-m*v*_;break;case"XZY":this._x=m*h*d-f*v*_,this._y=f*v*d-m*h*_,this._z=f*h*_+m*v*d,this._w=f*h*d+m*v*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],f=t[2],h=t[6],d=t[10],m=i+a+d;if(m>0){const v=.5/Math.sqrt(m+1);this._w=.25/v,this._x=(h-c)*v,this._y=(s-f)*v,this._z=(o-r)*v}else if(i>a&&i>d){const v=2*Math.sqrt(1+i-a-d);this._w=(h-c)/v,this._x=.25*v,this._y=(r+o)/v,this._z=(s+f)/v}else if(a>d){const v=2*Math.sqrt(1+a-i-d);this._w=(s-f)/v,this._x=(r+o)/v,this._y=.25*v,this._z=(c+h)/v}else{const v=2*Math.sqrt(1+d-i-a);this._w=(o-r)/v,this._x=(s+f)/v,this._y=(c+h)/v,this._z=.25*v}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ln(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,f=t._z,h=t._w;return this._x=i*h+o*a+r*f-s*c,this._y=r*h+o*c+s*a-i*f,this._z=s*h+o*f+i*c-r*a,this._w=o*h-i*a-r*c-s*f,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,s=this._z,o=this._w;let a=o*e._w+i*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const v=1-t;return this._w=v*o+t*this._w,this._x=v*i+t*this._x,this._y=v*r+t*this._y,this._z=v*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const f=Math.sqrt(c),h=Math.atan2(f,a),d=Math.sin((1-t)*h)/f,m=Math.sin(t*h)/f;return this._w=o*d+this._w*m,this._x=i*d+this._x*m,this._y=r*d+this._y*m,this._z=s*d+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(s),i*Math.cos(s),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}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 N{constructor(e=0,t=0,i=0){N.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(RS.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(RS.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,f=c*t+o*r-a*i,h=c*i+a*t-s*r,d=c*r+s*i-o*t,m=-s*t-o*i-a*r;return this.x=f*c+m*-s+h*-a-d*-o,this.y=h*c+m*-o+d*-s-f*-a,this.z=d*c+m*-a+f*-o-h*-s,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Pg.copy(this).projectOnVector(e),this.sub(Pg)}reflect(e){return this.sub(Pg.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(ln(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 Pg=new N,RS=new It;class Yr{constructor(e=new N(1/0,1/0,1/0),t=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,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,ss),ss.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(bu),Ch.subVectors(this.max,bu),Oa.subVectors(e.a,bu),Fa.subVectors(e.b,bu),Ba.subVectors(e.c,bu),Bs.subVectors(Fa,Oa),Vs.subVectors(Ba,Fa),Lo.subVectors(Oa,Ba);let t=[0,-Bs.z,Bs.y,0,-Vs.z,Vs.y,0,-Lo.z,Lo.y,Bs.z,0,-Bs.x,Vs.z,0,-Vs.x,Lo.z,0,-Lo.x,-Bs.y,Bs.x,0,-Vs.y,Vs.x,0,-Lo.y,Lo.x,0];return!Lg(t,Oa,Fa,Ba,Ch)||(t=[1,0,0,0,1,0,0,0,1],!Lg(t,Oa,Fa,Ba,Ch))?!1:(bh.crossVectors(Bs,Vs),t=[bh.x,bh.y,bh.z],Lg(t,Oa,Fa,Ba,Ch))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ss).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ss).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:(rs[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),rs[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),rs[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),rs[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),rs[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),rs[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),rs[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),rs[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(rs),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 rs=[new N,new N,new N,new N,new N,new N,new N,new N],ss=new N,Ua=new Yr,Oa=new N,Fa=new N,Ba=new N,Bs=new N,Vs=new N,Lo=new N,bu=new N,Ch=new N,bh=new N,Ro=new N;function Lg(n,e,t,i,r){for(let s=0,o=n.length-3;s<=o;s+=3){Ro.fromArray(n,s);const a=r.x*Math.abs(Ro.x)+r.y*Math.abs(Ro.y)+r.z*Math.abs(Ro.z),c=e.dot(Ro),f=t.dot(Ro),h=i.dot(Ro);if(Math.max(-Math.max(c,f,h),Math.min(c,f,h))>a)return!1}return!0}const CL=new Yr,Pu=new N,Rg=new N;class qr{constructor(e=new N,t=-1){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):CL.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;Pu.subVectors(e,this.center);const t=Pu.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Pu,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):(Rg.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Pu.copy(e.center).add(Rg)),this.expandByPoint(Pu.copy(e.center).sub(Rg))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const os=new N,Ig=new N,Ph=new N,Hs=new N,Dg=new N,Lh=new N,Ng=new N;class Qc{constructor(e=new N,t=new N(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,os)),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=os.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(os.copy(this.origin).addScaledVector(this.direction,t),os.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Ig.copy(e).add(t).multiplyScalar(.5),Ph.copy(t).sub(e).normalize(),Hs.copy(this.origin).sub(Ig);const s=e.distanceTo(t)*.5,o=-this.direction.dot(Ph),a=Hs.dot(this.direction),c=-Hs.dot(Ph),f=Hs.lengthSq(),h=Math.abs(1-o*o);let d,m,v,_;if(h>0)if(d=o*c-a,m=o*a-c,_=s*h,d>=0)if(m>=-_)if(m<=_){const E=1/h;d*=E,m*=E,v=d*(d+o*m+2*a)+m*(o*d+m+2*c)+f}else m=s,d=Math.max(0,-(o*m+a)),v=-d*d+m*(m+2*c)+f;else m=-s,d=Math.max(0,-(o*m+a)),v=-d*d+m*(m+2*c)+f;else m<=-_?(d=Math.max(0,-(-o*s+a)),m=d>0?-s:Math.min(Math.max(-s,-c),s),v=-d*d+m*(m+2*c)+f):m<=_?(d=0,m=Math.min(Math.max(-s,-c),s),v=m*(m+2*c)+f):(d=Math.max(0,-(o*s+a)),m=d>0?s:Math.min(Math.max(-s,-c),s),v=-d*d+m*(m+2*c)+f);else m=o>0?-s:s,d=Math.max(0,-(o*m+a)),v=-d*d+m*(m+2*c)+f;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Ig).addScaledVector(Ph,m),v}intersectSphere(e,t){os.subVectors(e.center,this.origin);const i=os.dot(this.direction),r=os.dot(os)-i*i,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,o,a,c;const f=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,m=this.origin;return f>=0?(i=(e.min.x-m.x)*f,r=(e.max.x-m.x)*f):(i=(e.max.x-m.x)*f,r=(e.min.x-m.x)*f),h>=0?(s=(e.min.y-m.y)*h,o=(e.max.y-m.y)*h):(s=(e.max.y-m.y)*h,o=(e.min.y-m.y)*h),i>o||s>r||((s>i||isNaN(i))&&(i=s),(o=0?(a=(e.min.z-m.z)*d,c=(e.max.z-m.z)*d):(a=(e.max.z-m.z)*d,c=(e.min.z-m.z)*d),i>c||a>r)||((a>i||i!==i)&&(i=a),(c=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,os)!==null}intersectTriangle(e,t,i,r,s){Dg.subVectors(t,e),Lh.subVectors(i,e),Ng.crossVectors(Dg,Lh);let o=this.direction.dot(Ng),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Hs.subVectors(this.origin,e);const c=a*this.direction.dot(Lh.crossVectors(Hs,Lh));if(c<0)return null;const f=a*this.direction.dot(Dg.cross(Hs));if(f<0||c+f>o)return null;const h=-a*Hs.dot(Ng);return h<0?null:this.at(h/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class st{constructor(){st.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,i,r,s,o,a,c,f,h,d,m,v,_,E,S){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=s,g[5]=o,g[9]=a,g[13]=c,g[2]=f,g[6]=h,g[10]=d,g[14]=m,g[3]=v,g[7]=_,g[11]=E,g[15]=S,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 st().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/Va.setFromMatrixColumn(e,0).length(),s=1/Va.setFromMatrixColumn(e,1).length(),o=1/Va.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(r),f=Math.sin(r),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const m=o*h,v=o*d,_=a*h,E=a*d;t[0]=c*h,t[4]=-c*d,t[8]=f,t[1]=v+_*f,t[5]=m-E*f,t[9]=-a*c,t[2]=E-m*f,t[6]=_+v*f,t[10]=o*c}else if(e.order==="YXZ"){const m=c*h,v=c*d,_=f*h,E=f*d;t[0]=m+E*a,t[4]=_*a-v,t[8]=o*f,t[1]=o*d,t[5]=o*h,t[9]=-a,t[2]=v*a-_,t[6]=E+m*a,t[10]=o*c}else if(e.order==="ZXY"){const m=c*h,v=c*d,_=f*h,E=f*d;t[0]=m-E*a,t[4]=-o*d,t[8]=_+v*a,t[1]=v+_*a,t[5]=o*h,t[9]=E-m*a,t[2]=-o*f,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const m=o*h,v=o*d,_=a*h,E=a*d;t[0]=c*h,t[4]=_*f-v,t[8]=m*f+E,t[1]=c*d,t[5]=E*f+m,t[9]=v*f-_,t[2]=-f,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const m=o*c,v=o*f,_=a*c,E=a*f;t[0]=c*h,t[4]=E-m*d,t[8]=_*d+v,t[1]=d,t[5]=o*h,t[9]=-a*h,t[2]=-f*h,t[6]=v*d+_,t[10]=m-E*d}else if(e.order==="XZY"){const m=o*c,v=o*f,_=a*c,E=a*f;t[0]=c*h,t[4]=-d,t[8]=f*h,t[1]=m*d+E,t[5]=o*h,t[9]=v*d-_,t[2]=_*d-v,t[6]=a*h,t[10]=E*d+m}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(bL,e,PL)}lookAt(e,t,i){const r=this.elements;return Pi.subVectors(e,t),Pi.lengthSq()===0&&(Pi.z=1),Pi.normalize(),Gs.crossVectors(i,Pi),Gs.lengthSq()===0&&(Math.abs(i.z)===1?Pi.x+=1e-4:Pi.z+=1e-4,Pi.normalize(),Gs.crossVectors(i,Pi)),Gs.normalize(),Rh.crossVectors(Pi,Gs),r[0]=Gs.x,r[4]=Rh.x,r[8]=Pi.x,r[1]=Gs.y,r[5]=Rh.y,r[9]=Pi.y,r[2]=Gs.z,r[6]=Rh.z,r[10]=Pi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,o=i[0],a=i[4],c=i[8],f=i[12],h=i[1],d=i[5],m=i[9],v=i[13],_=i[2],E=i[6],S=i[10],g=i[14],x=i[3],w=i[7],T=i[11],C=i[15],P=r[0],R=r[4],I=r[8],b=r[12],L=r[1],H=r[5],q=r[9],G=r[13],W=r[2],ee=r[6],oe=r[10],ue=r[14],D=r[3],V=r[7],B=r[11],J=r[15];return s[0]=o*P+a*L+c*W+f*D,s[4]=o*R+a*H+c*ee+f*V,s[8]=o*I+a*q+c*oe+f*B,s[12]=o*b+a*G+c*ue+f*J,s[1]=h*P+d*L+m*W+v*D,s[5]=h*R+d*H+m*ee+v*V,s[9]=h*I+d*q+m*oe+v*B,s[13]=h*b+d*G+m*ue+v*J,s[2]=_*P+E*L+S*W+g*D,s[6]=_*R+E*H+S*ee+g*V,s[10]=_*I+E*q+S*oe+g*B,s[14]=_*b+E*G+S*ue+g*J,s[3]=x*P+w*L+T*W+C*D,s[7]=x*R+w*H+T*ee+C*V,s[11]=x*I+w*q+T*oe+C*B,s[15]=x*b+w*G+T*ue+C*J,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],s=e[12],o=e[1],a=e[5],c=e[9],f=e[13],h=e[2],d=e[6],m=e[10],v=e[14],_=e[3],E=e[7],S=e[11],g=e[15];return _*(+s*c*d-r*f*d-s*a*m+i*f*m+r*a*v-i*c*v)+E*(+t*c*v-t*f*m+s*o*m-r*o*v+r*f*h-s*c*h)+S*(+t*f*d-t*a*v-s*o*d+i*o*v+s*a*h-i*f*h)+g*(-r*a*h-t*c*d+t*a*m+r*o*d-i*o*m+i*c*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],f=e[7],h=e[8],d=e[9],m=e[10],v=e[11],_=e[12],E=e[13],S=e[14],g=e[15],x=d*S*f-E*m*f+E*c*v-a*S*v-d*c*g+a*m*g,w=_*m*f-h*S*f-_*c*v+o*S*v+h*c*g-o*m*g,T=h*E*f-_*d*f+_*a*v-o*E*v-h*a*g+o*d*g,C=_*d*c-h*E*c-_*a*m+o*E*m+h*a*S-o*d*S,P=t*x+i*w+r*T+s*C;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/P;return e[0]=x*R,e[1]=(E*m*s-d*S*s-E*r*v+i*S*v+d*r*g-i*m*g)*R,e[2]=(a*S*s-E*c*s+E*r*f-i*S*f-a*r*g+i*c*g)*R,e[3]=(d*c*s-a*m*s-d*r*f+i*m*f+a*r*v-i*c*v)*R,e[4]=w*R,e[5]=(h*S*s-_*m*s+_*r*v-t*S*v-h*r*g+t*m*g)*R,e[6]=(_*c*s-o*S*s-_*r*f+t*S*f+o*r*g-t*c*g)*R,e[7]=(o*m*s-h*c*s+h*r*f-t*m*f-o*r*v+t*c*v)*R,e[8]=T*R,e[9]=(_*d*s-h*E*s-_*i*v+t*E*v+h*i*g-t*d*g)*R,e[10]=(o*E*s-_*a*s+_*i*f-t*E*f-o*i*g+t*a*g)*R,e[11]=(h*a*s-o*d*s-h*i*f+t*d*f+o*i*v-t*a*v)*R,e[12]=C*R,e[13]=(h*E*r-_*d*r+_*i*m-t*E*m-h*i*S+t*d*S)*R,e[14]=(_*a*r-o*E*r-_*i*c+t*E*c+o*i*S-t*a*S)*R,e[15]=(o*d*r-h*a*r+h*i*c-t*d*c-o*i*m+t*a*m)*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 this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,o=e.x,a=e.y,c=e.z,f=s*o,h=s*a;return this.set(f*o+i,f*a-r*c,f*c+r*a,0,f*a+r*c,h*a+i,h*c-r*o,0,f*c-r*a,h*c+r*o,s*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,o){return this.set(1,i,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,f=s+s,h=o+o,d=a+a,m=s*f,v=s*h,_=s*d,E=o*h,S=o*d,g=a*d,x=c*f,w=c*h,T=c*d,C=i.x,P=i.y,R=i.z;return r[0]=(1-(E+g))*C,r[1]=(v+T)*C,r[2]=(_-w)*C,r[3]=0,r[4]=(v-T)*P,r[5]=(1-(m+g))*P,r[6]=(S+x)*P,r[7]=0,r[8]=(_+w)*R,r[9]=(S-x)*R,r[10]=(1-(m+E))*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=Va.set(r[0],r[1],r[2]).length();const o=Va.set(r[4],r[5],r[6]).length(),a=Va.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],gr.copy(this);const f=1/s,h=1/o,d=1/a;return gr.elements[0]*=f,gr.elements[1]*=f,gr.elements[2]*=f,gr.elements[4]*=h,gr.elements[5]*=h,gr.elements[6]*=h,gr.elements[8]*=d,gr.elements[9]*=d,gr.elements[10]*=d,t.setFromRotationMatrix(gr),i.x=s,i.y=o,i.z=a,this}makePerspective(e,t,i,r,s,o){const a=this.elements,c=2*s/(t-e),f=2*s/(i-r),h=(t+e)/(t-e),d=(i+r)/(i-r),m=-(o+s)/(o-s),v=-2*o*s/(o-s);return a[0]=c,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=f,a[9]=d,a[13]=0,a[2]=0,a[6]=0,a[10]=m,a[14]=v,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,i,r,s,o){const a=this.elements,c=1/(t-e),f=1/(i-r),h=1/(o-s),d=(t+e)*c,m=(i+r)*f,v=(o+s)*h;return a[0]=2*c,a[4]=0,a[8]=0,a[12]=-d,a[1]=0,a[5]=2*f,a[9]=0,a[13]=-m,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-v,a[3]=0,a[7]=0,a[11]=0,a[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 Va=new N,gr=new st,bL=new N(0,0,0),PL=new N(1,1,1),Gs=new N,Rh=new N,Pi=new N,IS=new st,DS=new It;class Yl{constructor(e=0,t=0,i=0,r=Yl.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,s=r[0],o=r[4],a=r[8],c=r[1],f=r[5],h=r[9],d=r[2],m=r[6],v=r[10];switch(t){case"XYZ":this._y=Math.asin(ln(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,v),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(m,f),this._z=0);break;case"YXZ":this._x=Math.asin(-ln(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,v),this._z=Math.atan2(c,f)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(ln(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-d,v),this._z=Math.atan2(-o,f)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-ln(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(m,v),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,f));break;case"YZX":this._z=Math.asin(ln(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,f),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(a,v));break;case"XZY":this._z=Math.asin(-ln(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,f),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,v),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return IS.makeRotationFromQuaternion(e),this.setFromRotationMatrix(IS,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return DS.setFromEuler(this),this.setFromQuaternion(DS,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}}Yl.DEFAULT_ORDER="XYZ";class ia{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&&(i=i.concat(o))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lu,e,RL),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lu,IL,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,r=t.length;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()));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let f=0,h=c.length;f0){r.children=[];for(let a=0;a0){r.animations=[];for(let a=0;a0&&(i.geometries=a),c.length>0&&(i.materials=c),f.length>0&&(i.textures=f),h.length>0&&(i.images=h),d.length>0&&(i.shapes=d),m.length>0&&(i.skeletons=m),v.length>0&&(i.animations=v),_.length>0&&(i.nodes=_)}return i.object=r,i;function o(a){const c=[];for(const f in a){const h=a[f];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.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){vr.subVectors(r,t),ls.subVectors(i,t),kg.subVectors(e,t);const o=vr.dot(vr),a=vr.dot(ls),c=vr.dot(kg),f=ls.dot(ls),h=ls.dot(kg),d=o*f-a*a;if(d===0)return s.set(-2,-1,-1);const m=1/d,v=(f*c-a*h)*m,_=(o*h-a*c)*m;return s.set(1-v-_,_,v)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,us),us.x>=0&&us.y>=0&&us.x+us.y<=1}static getUV(e,t,i,r,s,o,a,c){return Dh===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Dh=!0),this.getInterpolation(e,t,i,r,s,o,a,c)}static getInterpolation(e,t,i,r,s,o,a,c){return this.getBarycoord(e,t,i,r,us),c.setScalar(0),c.addScaledVector(s,us.x),c.addScaledVector(o,us.y),c.addScaledVector(a,us.z),c}static isFrontFacing(e,t,i,r){return vr.subVectors(i,t),ls.subVectors(e,t),vr.cross(ls).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 vr.subVectors(this.c,this.b),ls.subVectors(this.a,this.b),vr.cross(ls).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yi.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,s){return Dh===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Dh=!0),yi.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}getInterpolation(e,t,i,r,s){return yi.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return yi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yi.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;Ga.subVectors(r,i),Wa.subVectors(s,i),zg.subVectors(e,i);const c=Ga.dot(zg),f=Wa.dot(zg);if(c<=0&&f<=0)return t.copy(i);Ug.subVectors(e,r);const h=Ga.dot(Ug),d=Wa.dot(Ug);if(h>=0&&d<=h)return t.copy(r);const m=c*d-h*f;if(m<=0&&c>=0&&h<=0)return o=c/(c-h),t.copy(i).addScaledVector(Ga,o);Og.subVectors(e,s);const v=Ga.dot(Og),_=Wa.dot(Og);if(_>=0&&v<=_)return t.copy(s);const E=v*f-c*_;if(E<=0&&f>=0&&_<=0)return a=f/(f-_),t.copy(i).addScaledVector(Wa,a);const S=h*_-v*d;if(S<=0&&d-h>=0&&v-_>=0)return FS.subVectors(s,r),a=(d-h)/(d-h+(v-_)),t.copy(r).addScaledVector(FS,a);const g=1/(S+E+m);return o=E*g,a=m*g,t.copy(i).addScaledVector(Ga,o).addScaledVector(Wa,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let NL=0;class Bn extends bs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:NL++}),this.uuid=Ui(),this.name="",this.type="Material",this.blending=ea,this.side=Ms,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Wy,this.blendDst=Xy,this.blendEquation=Vo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=op,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=C2,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Nd,this.stencilZFail=Nd,this.stencilZPass=Nd,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=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.5,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.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!==ea&&(i.blending=this.blending),this.side!==Ms&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,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.alphaToCoverage===!0&&(i.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(i.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(i.wireframe=this.wireframe),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=this.flatShading),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(s){const o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.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.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++}}const R2={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},yr={h:0,s:0,l:0},Nh={h:0,s:0,l:0};function Fg(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 Re{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&i===void 0?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Sr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mi.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=mi.workingColorSpace){return this.r=e,this.g=t,this.b=i,mi.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=mi.workingColorSpace){if(e=Jy(e,1),t=ln(t,0,1),i=ln(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=Fg(o,s,e+1/3),this.g=Fg(o,s,e),this.b=Fg(o,s,e-1/3)}return mi.toWorkingColorSpace(this,r),this}setStyle(e,t=Sr){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 this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,mi.toWorkingColorSpace(this,t),i(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,mi.toWorkingColorSpace(this,t),i(s[4]),this;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)){const c=parseFloat(s[1])/360,f=parseFloat(s[2])/100,h=parseFloat(s[3])/100;return i(s[4]),this.setHSL(c,f,h,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=Sr){const i=R2[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=Pl(e.r),this.g=Pl(e.g),this.b=Pl(e.b),this}copyLinearToSRGB(e){return this.r=Cg(e.r),this.g=Cg(e.g),this.b=Cg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Sr){return mi.fromWorkingColorSpace(Zn.copy(this),e),ln(Zn.r*255,0,255)<<16^ln(Zn.g*255,0,255)<<8^ln(Zn.b*255,0,255)<<0}getHexString(e=Sr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mi.workingColorSpace){mi.fromWorkingColorSpace(Zn.copy(this),t);const i=Zn.r,r=Zn.g,s=Zn.b,o=Math.max(i,r,s),a=Math.min(i,r,s);let c,f;const h=(a+o)/2;if(a===o)c=0,f=0;else{const d=o-a;switch(f=h<=.5?d/(o+a):d/(2-o-a),o){case i:c=(r-s)/d+(r>-f-14,i[c|256]=1024>>-f-14|32768,r[c]=-f-1,r[c|256]=-f-1):f<=15?(i[c]=f+15<<10,i[c|256]=f+15<<10|32768,r[c]=13,r[c|256]=13):f<128?(i[c]=31744,i[c|256]=64512,r[c]=24,r[c|256]=24):(i[c]=31744,i[c|256]=64512,r[c]=13,r[c|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let f=c<<13,h=0;for(;(f&8388608)===0;)f<<=1,h-=8388608;f&=-8388609,h+=947912704,s[c]=f|h}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function gi(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=ln(n,-65504,65504),ds.floatView[0]=n;const e=ds.uint32View[0],t=e>>23&511;return ds.baseTable[t]+((e&8388607)>>ds.shiftTable[t])}function ju(n){const e=n>>10;return ds.uint32View[0]=ds.mantissaTable[ds.offsetTable[e]+(n&1023)]+ds.exponentTable[e],ds.floatView[0]}const zL={toHalfFloat:gi,fromHalfFloat:ju},yn=new N,kh=new ge;class Bt{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=Ic,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const f in c)c[f]!==void 0&&(e[f]=c[f]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const c in i){const f=i[c];e.data.attributes[c]=f.toJSON(e.data)}const r={};let s=!1;for(const c in this.morphAttributes){const f=this.morphAttributes[c],h=[];for(let d=0,m=f.length;d0&&(r[c]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const f in r){const h=r[f];this.setAttribute(f,h.clone(t))}const s=e.morphAttributes;for(const f in s){const h=[],d=s[f];for(let m=0,v=d.length;m0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s(e.far-e.near)**2))||(BS.copy(s).invert(),Or.copy(e.ray).applyMatrix4(BS),i.boundingBox!==null&&Or.intersectsBox(i.boundingBox)===!1))return;let o;const a=i.index,c=i.attributes.position,f=i.attributes.uv,h=i.attributes.uv2,d=i.attributes.normal,m=i.groups,v=i.drawRange;if(a!==null)if(Array.isArray(r))for(let _=0,E=m.length;_t.far?null:{distance:f,point:Hh.clone(),object:n}}function Gh(n,e,t,i,r,s,o,a,c,f){n.getVertexPosition(a,ja),n.getVertexPosition(c,Ya),n.getVertexPosition(f,qa);const h=XL(n,e,t,i,ja,Ya,qa,Vh);if(h){r&&(Oh.fromBufferAttribute(r,a),Fh.fromBufferAttribute(r,c),Bh.fromBufferAttribute(r,f),h.uv=yi.getInterpolation(Vh,ja,Ya,qa,Oh,Fh,Bh,new ge)),s&&(Oh.fromBufferAttribute(s,a),Fh.fromBufferAttribute(s,c),Bh.fromBufferAttribute(s,f),h.uv2=yi.getInterpolation(Vh,ja,Ya,qa,Oh,Fh,Bh,new ge)),o&&(HS.fromBufferAttribute(o,a),GS.fromBufferAttribute(o,c),WS.fromBufferAttribute(o,f),h.normal=yi.getInterpolation(Vh,ja,Ya,qa,HS,GS,WS,new N),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a,b:c,c:f,normal:new N,materialIndex:0};yi.getNormal(ja,Ya,qa,d.normal),h.face=d}return h}class oi extends lt{constructor(e=1,t=1,i=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const c=[],f=[],h=[],d=[];let m=0,v=0;_("z","y","x",-1,-1,i,t,e,o,s,0),_("z","y","x",1,-1,i,t,-e,o,s,1),_("x","z","y",1,1,e,i,t,r,o,2),_("x","z","y",1,-1,e,i,-t,r,o,3),_("x","y","z",1,-1,e,t,i,r,s,4),_("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(c),this.setAttribute("position",new Be(f,3)),this.setAttribute("normal",new Be(h,3)),this.setAttribute("uv",new Be(d,2));function _(E,S,g,x,w,T,C,P,R,I,b){const L=T/R,H=C/I,q=T/2,G=C/2,W=P/2,ee=R+1,oe=I+1;let ue=0,D=0;const V=new N;for(let B=0;B0?1:-1,h.push(V.x,V.y,V.z),d.push(Y/R),d.push(1-B/I),ue+=1}}for(let B=0;B0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;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 Jc extends St{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new st,this.projectionMatrix=new st,this.projectionMatrixInverse=new st}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}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 In extends Jc{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=Fl*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(na*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Fl*2*Math.atan(Math.tan(na*.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(na*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,f=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*i/f,r*=o.width/c,i*=o.height/f}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,e,this.far),this.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 Za=-90,Qa=1;class N2 extends St{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i;const r=new In(Za,Qa,e,t);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(1,0,0),this.add(r);const s=new In(Za,Qa,e,t);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);const o=new In(Za,Qa,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(0,1,0),this.add(o);const a=new In(Za,Qa,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);const c=new In(Za,Qa,e,t);c.layers=this.layers,c.up.set(0,1,0),c.lookAt(0,0,1),this.add(c);const f=new In(Za,Qa,e,t);f.layers=this.layers,f.up.set(0,1,0),f.lookAt(0,0,-1),this.add(f)}update(e,t){this.parent===null&&this.updateMatrixWorld();const i=this.renderTarget,[r,s,o,a,c,f]=this.children,h=e.getRenderTarget(),d=e.toneMapping,m=e.xr.enabled;e.toneMapping=Ar,e.xr.enabled=!1;const v=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,s),e.setRenderTarget(i,2),e.render(t,o),e.setRenderTarget(i,3),e.render(t,a),e.setRenderTarget(i,4),e.render(t,c),i.texture.generateMipmaps=v,e.setRenderTarget(i,5),e.render(t,f),e.setRenderTarget(h),e.toneMapping=d,e.xr.enabled=m,i.texture.needsPMREMUpdate=!0}}class Kc extends un{constructor(e,t,i,r,s,o,a,c,f,h){e=e!==void 0?e:[],t=t!==void 0?t:fo,super(e,t,i,r,s,o,a,c,f,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class k2 extends ar{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];this.texture=new Kc(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:en}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,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 oi(5,5,5),s=new jr({name:"CubemapFromEquirect",uniforms:Bl(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:li,blending:ys});s.uniforms.tEquirect.value=t;const o=new Ne(r,s),a=t.minFilter;return t.minFilter===po&&(t.minFilter=en),new N2(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 Hg=new N,ZL=new N,QL=new xt;class Ys{constructor(e=new N(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,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=Hg.subVectors(i,t).cross(ZL.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(Hg),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||QL.getNormalMatrix(e),r=this.coplanarPoint(Hg).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 Io=new qr,Wh=new N;class Ip{constructor(e=new Ys,t=new Ys,i=new Ys,r=new Ys,s=new Ys,o=new Ys){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){const t=this.planes,i=e.elements,r=i[0],s=i[1],o=i[2],a=i[3],c=i[4],f=i[5],h=i[6],d=i[7],m=i[8],v=i[9],_=i[10],E=i[11],S=i[12],g=i[13],x=i[14],w=i[15];return t[0].setComponents(a-r,d-c,E-m,w-S).normalize(),t[1].setComponents(a+r,d+c,E+m,w+S).normalize(),t[2].setComponents(a+s,d+f,E+v,w+g).normalize(),t[3].setComponents(a-s,d-f,E-v,w-g).normalize(),t[4].setComponents(a-o,d-h,E-_,w-x).normalize(),t[5].setComponents(a+o,d+h,E+_,w+x).normalize(),this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Io.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Io.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Io)}intersectsSprite(e){return Io.center.set(0,0,0),Io.radius=.7071067811865476,Io.applyMatrix4(e.matrixWorld),this.intersectsSphere(Io)}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,Wh.y=r.normal.y>0?e.max.y:e.min.y,Wh.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Wh)<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 z2(){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 JL(n,e){const t=e.isWebGL2,i=new WeakMap;function r(f,h){const d=f.array,m=f.usage,v=n.createBuffer();n.bindBuffer(h,v),n.bufferData(h,d,m),f.onUploadCallback();let _;if(d instanceof Float32Array)_=5126;else if(d instanceof Uint16Array)if(f.isFloat16BufferAttribute)if(t)_=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else _=5123;else if(d instanceof Int16Array)_=5122;else if(d instanceof Uint32Array)_=5125;else if(d instanceof Int32Array)_=5124;else if(d instanceof Int8Array)_=5120;else if(d instanceof Uint8Array)_=5121;else if(d instanceof Uint8ClampedArray)_=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:v,type:_,bytesPerElement:d.BYTES_PER_ELEMENT,version:f.version}}function s(f,h,d){const m=h.array,v=h.updateRange;n.bindBuffer(d,f),v.count===-1?n.bufferSubData(d,0,m):(t?n.bufferSubData(d,v.offset*m.BYTES_PER_ELEMENT,m,v.offset,v.count):n.bufferSubData(d,v.offset*m.BYTES_PER_ELEMENT,m.subarray(v.offset,v.offset+v.count)),v.count=-1),h.onUploadCallback()}function o(f){return f.isInterleavedBufferAttribute&&(f=f.data),i.get(f)}function a(f){f.isInterleavedBufferAttribute&&(f=f.data);const h=i.get(f);h&&(n.deleteBuffer(h.buffer),i.delete(f))}function c(f,h){if(f.isGLBufferAttribute){const m=i.get(f);(!m||m.version 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`,cR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,fR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,hR=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,dR=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,pR=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,mR=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,gR=`#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`,vR=`#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; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef USE_CLEARCOAT vec3 clearcoatNormal; #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`,yR=`#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_v0 0.339 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #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`,_R=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,xR=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,SR=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,wR=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,MR=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,ER="gl_FragColor = linearToOutputTexel( gl_FragColor );",TR=`vec4 LinearToLinear( in vec4 value ) { return value; } vec4 LinearTosRGB( 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 ); }`,AR=`#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`,CR=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,bR=`#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`,PR=`#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`,LR=`#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`,RR=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,IR=`#ifdef USE_FOG varying float vFogDepth; #endif`,DR=`#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`,NR=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,kR=`#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 }`,zR=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,UR=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,OR=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,FR=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, 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`,BR=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; 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, const in GeometricContext geometry, 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 GeometricContext geometry, out IncidentLight light ) { vec3 lVector = pointLight.position - geometry.position; 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 GeometricContext geometry, out IncidentLight light ) { vec3 lVector = spotLight.position - geometry.position; 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`,VR=`#if defined( USE_ENVMAP ) vec3 getIBLIrradiance( const in vec3 normal ) { #if defined( 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 ) { #if defined( 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 } #endif`,HR=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,GR=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, 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`,WR=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,XR=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, 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`,jR=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); 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`,YR=`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 }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = 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_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 float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometry.normal, geometry.viewDir, 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 ); }`,qR=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometry.viewDir ) ); 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, geometry, 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, geometry, 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, geometry, 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, geometry, 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, geometry, 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, geometry, 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, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,ZR=`#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( geometry.normal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif #endif`,QR=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,JR=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,KR=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,$R=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,eI=`#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`,tI=`#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`,nI=`#ifdef USE_MAP uniform sampler2D map; #endif`,iI=`#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`,rI=`#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`,sI=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,oI=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,aI=`#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`,lI=`#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`,uI=`#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`,cI=`#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`,fI=`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 #ifdef USE_NORMALMAP_TANGENTSPACE #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, vNormalMapUv ); #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 geometryNormal = normal;`,hI=`#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`,dI=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,pI=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,mI=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,gI=`#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 ) ) 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`,vI=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,yI=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,_I=`#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`,xI=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,SI=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha + 0.1; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,wI=`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 ); }`,MI=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,EI=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,TI=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,AI=`#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`,CI=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,bI=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,PI=`#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`,LI=`#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`,RI=`#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`,II=`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; }`,DI=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,NI=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #endif`,kI=`#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`,zI=`#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`,UI=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,OI=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,FI=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,BI=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return 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 ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,VI=`#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 transmission = 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, transmission.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); #endif`,HI=`#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, vec2 fullSize, 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; vec2 lodFudge = pow( 1.95, lod ) / fullSize; 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; vec2 fullSize = vec2( textureSize( sampler, 0 ) ); vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), fullSize, floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), fullSize, 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 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return radiance; } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; } } 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 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); } #endif`,GI=`#ifdef USE_UV 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_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`,WI=`#ifdef USE_UV varying vec2 vUv; #endif #ifdef USE_UV2 attribute vec2 uv2; #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_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`,XI=`#ifdef USE_UV 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_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`,jI=`#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_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const YI=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,qI=`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 }`,ZI=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,QI=`#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 }`,JI=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,KI=`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 }`,$I=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,eD=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #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 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 }`,tD=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,nD=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,iD=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,rD=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,sD=`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 }`,oD=`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 }`,aD=`#include #include #include #include #include #include #include #include #include void main() { #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 }`,lD=`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 void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #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 }`,uD=`#define LAMBERT 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 vViewPosition = - mvPosition.xyz; #include #include #include #include }`,cD=`#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 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 #include }`,fD=`#define MATCAP varying vec3 vViewPosition; #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; }`,hD=`#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 void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #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 }`,dD=`#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 void main() { #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 }`,pD=`#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 }`,mD=`#define PHONG 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 vViewPosition = - mvPosition.xyz; #include #include #include #include }`,gD=`#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 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 + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,vD=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #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 vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,yD=`#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 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 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 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 + sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif #include #include #include #include #include #include }`,_D=`#define TOON 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 vViewPosition = - mvPosition.xyz; #include #include #include }`,xD=`#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 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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,SD=`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 }`,wD=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,MD=`#include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include }`,ED=`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 }`,TD=`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 }`,AD=`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 outgoingLight = diffuseColor.rgb; #include #include #include #include }`,ht={alphamap_fragment:KL,alphamap_pars_fragment:$L,alphatest_fragment:eR,alphatest_pars_fragment:tR,aomap_fragment:nR,aomap_pars_fragment:iR,begin_vertex:rR,beginnormal_vertex:sR,bsdfs:oR,iridescence_fragment:aR,bumpmap_pars_fragment:lR,clipping_planes_fragment:uR,clipping_planes_pars_fragment:cR,clipping_planes_pars_vertex:fR,clipping_planes_vertex:hR,color_fragment:dR,color_pars_fragment:pR,color_pars_vertex:mR,color_vertex:gR,common:vR,cube_uv_reflection_fragment:yR,defaultnormal_vertex:_R,displacementmap_pars_vertex:xR,displacementmap_vertex:SR,emissivemap_fragment:wR,emissivemap_pars_fragment:MR,encodings_fragment:ER,encodings_pars_fragment:TR,envmap_fragment:AR,envmap_common_pars_fragment:CR,envmap_pars_fragment:bR,envmap_pars_vertex:PR,envmap_physical_pars_fragment:VR,envmap_vertex:LR,fog_vertex:RR,fog_pars_vertex:IR,fog_fragment:DR,fog_pars_fragment:NR,gradientmap_pars_fragment:kR,lightmap_fragment:zR,lightmap_pars_fragment:UR,lights_lambert_fragment:OR,lights_lambert_pars_fragment:FR,lights_pars_begin:BR,lights_toon_fragment:HR,lights_toon_pars_fragment:GR,lights_phong_fragment:WR,lights_phong_pars_fragment:XR,lights_physical_fragment:jR,lights_physical_pars_fragment:YR,lights_fragment_begin:qR,lights_fragment_maps:ZR,lights_fragment_end:QR,logdepthbuf_fragment:JR,logdepthbuf_pars_fragment:KR,logdepthbuf_pars_vertex:$R,logdepthbuf_vertex:eI,map_fragment:tI,map_pars_fragment:nI,map_particle_fragment:iI,map_particle_pars_fragment:rI,metalnessmap_fragment:sI,metalnessmap_pars_fragment:oI,morphcolor_vertex:aI,morphnormal_vertex:lI,morphtarget_pars_vertex:uI,morphtarget_vertex:cI,normal_fragment_begin:fI,normal_fragment_maps:hI,normal_pars_fragment:dI,normal_pars_vertex:pI,normal_vertex:mI,normalmap_pars_fragment:gI,clearcoat_normal_fragment_begin:vI,clearcoat_normal_fragment_maps:yI,clearcoat_pars_fragment:_I,iridescence_pars_fragment:xI,output_fragment:SI,packing:wI,premultiplied_alpha_fragment:MI,project_vertex:EI,dithering_fragment:TI,dithering_pars_fragment:AI,roughnessmap_fragment:CI,roughnessmap_pars_fragment:bI,shadowmap_pars_fragment:PI,shadowmap_pars_vertex:LI,shadowmap_vertex:RI,shadowmask_pars_fragment:II,skinbase_vertex:DI,skinning_pars_vertex:NI,skinning_vertex:kI,skinnormal_vertex:zI,specularmap_fragment:UI,specularmap_pars_fragment:OI,tonemapping_fragment:FI,tonemapping_pars_fragment:BI,transmission_fragment:VI,transmission_pars_fragment:HI,uv_pars_fragment:GI,uv_pars_vertex:WI,uv_vertex:XI,worldpos_vertex:jI,background_vert:YI,background_frag:qI,backgroundCube_vert:ZI,backgroundCube_frag:QI,cube_vert:JI,cube_frag:KI,depth_vert:$I,depth_frag:eD,distanceRGBA_vert:tD,distanceRGBA_frag:nD,equirect_vert:iD,equirect_frag:rD,linedashed_vert:sD,linedashed_frag:oD,meshbasic_vert:aD,meshbasic_frag:lD,meshlambert_vert:uD,meshlambert_frag:cD,meshmatcap_vert:fD,meshmatcap_frag:hD,meshnormal_vert:dD,meshnormal_frag:pD,meshphong_vert:mD,meshphong_frag:gD,meshphysical_vert:vD,meshphysical_frag:yD,meshtoon_vert:_D,meshtoon_frag:xD,points_vert:SD,points_frag:wD,shadow_vert:MD,shadow_frag:ED,sprite_vert:TD,sprite_frag:AD},Ae={common:{diffuse:{value:new Re(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xt}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xt},normalScale:{value:new ge(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Re(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 Re(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new xt}},sprite:{diffuse:{value:new Re(16777215)},opacity:{value:1},center:{value:new ge(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaTest:{value:0}}},Mr={basic:{uniforms:ri([Ae.common,Ae.specularmap,Ae.envmap,Ae.aomap,Ae.lightmap,Ae.fog]),vertexShader:ht.meshbasic_vert,fragmentShader:ht.meshbasic_frag},lambert:{uniforms:ri([Ae.common,Ae.specularmap,Ae.envmap,Ae.aomap,Ae.lightmap,Ae.emissivemap,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.fog,Ae.lights,{emissive:{value:new Re(0)}}]),vertexShader:ht.meshlambert_vert,fragmentShader:ht.meshlambert_frag},phong:{uniforms:ri([Ae.common,Ae.specularmap,Ae.envmap,Ae.aomap,Ae.lightmap,Ae.emissivemap,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.fog,Ae.lights,{emissive:{value:new Re(0)},specular:{value:new Re(1118481)},shininess:{value:30}}]),vertexShader:ht.meshphong_vert,fragmentShader:ht.meshphong_frag},standard:{uniforms:ri([Ae.common,Ae.envmap,Ae.aomap,Ae.lightmap,Ae.emissivemap,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.roughnessmap,Ae.metalnessmap,Ae.fog,Ae.lights,{emissive:{value:new Re(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ht.meshphysical_vert,fragmentShader:ht.meshphysical_frag},toon:{uniforms:ri([Ae.common,Ae.aomap,Ae.lightmap,Ae.emissivemap,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.gradientmap,Ae.fog,Ae.lights,{emissive:{value:new Re(0)}}]),vertexShader:ht.meshtoon_vert,fragmentShader:ht.meshtoon_frag},matcap:{uniforms:ri([Ae.common,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,Ae.fog,{matcap:{value:null}}]),vertexShader:ht.meshmatcap_vert,fragmentShader:ht.meshmatcap_frag},points:{uniforms:ri([Ae.points,Ae.fog]),vertexShader:ht.points_vert,fragmentShader:ht.points_frag},dashed:{uniforms:ri([Ae.common,Ae.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ht.linedashed_vert,fragmentShader:ht.linedashed_frag},depth:{uniforms:ri([Ae.common,Ae.displacementmap]),vertexShader:ht.depth_vert,fragmentShader:ht.depth_frag},normal:{uniforms:ri([Ae.common,Ae.bumpmap,Ae.normalmap,Ae.displacementmap,{opacity:{value:1}}]),vertexShader:ht.meshnormal_vert,fragmentShader:ht.meshnormal_frag},sprite:{uniforms:ri([Ae.sprite,Ae.fog]),vertexShader:ht.sprite_vert,fragmentShader:ht.sprite_frag},background:{uniforms:{uvTransform:{value:new xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ht.background_vert,fragmentShader:ht.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ht.backgroundCube_vert,fragmentShader:ht.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ht.cube_vert,fragmentShader:ht.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ht.equirect_vert,fragmentShader:ht.equirect_frag},distanceRGBA:{uniforms:ri([Ae.common,Ae.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ht.distanceRGBA_vert,fragmentShader:ht.distanceRGBA_frag},shadow:{uniforms:ri([Ae.lights,Ae.fog,{color:{value:new Re(0)},opacity:{value:1}}]),vertexShader:ht.shadow_vert,fragmentShader:ht.shadow_frag}};Mr.physical={uniforms:ri([Mr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xt},clearcoatNormalScale:{value:new ge(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xt},sheen:{value:0},sheenColor:{value:new Re(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xt},transmissionSamplerSize:{value:new ge},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xt},attenuationDistance:{value:0},attenuationColor:{value:new Re(0)},specularColor:{value:new Re(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xt}}]),vertexShader:ht.meshphysical_vert,fragmentShader:ht.meshphysical_frag};const Xh={r:0,b:0,g:0};function CD(n,e,t,i,r,s,o){const a=new Re(0);let c=s===!0?0:1,f,h,d=null,m=0,v=null;function _(S,g){let x=!1,w=g.isScene===!0?g.background:null;w&&w.isTexture&&(w=(g.backgroundBlurriness>0?t:e).get(w));const T=n.xr,C=T.getSession&&T.getSession();C&&C.environmentBlendMode==="additive"&&(w=null),w===null?E(a,c):w&&w.isColor&&(E(w,1),x=!0),(n.autoClear||x)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),w&&(w.isCubeTexture||w.mapping===jl)?(h===void 0&&(h=new Ne(new oi(1,1,1),new jr({name:"BackgroundCubeMaterial",uniforms:Bl(Mr.backgroundCube.uniforms),vertexShader:Mr.backgroundCube.vertexShader,fragmentShader:Mr.backgroundCube.fragmentShader,side:li,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(P,R,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),h.material.uniforms.envMap.value=w,h.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,h.material.toneMapped=w.encoding!==Ot,(d!==w||m!==w.version||v!==n.toneMapping)&&(h.material.needsUpdate=!0,d=w,m=w.version,v=n.toneMapping),h.layers.enableAll(),S.unshift(h,h.geometry,h.material,0,0,null)):w&&w.isTexture&&(f===void 0&&(f=new Ne(new Di(2,2),new jr({name:"BackgroundMaterial",uniforms:Bl(Mr.background.uniforms),vertexShader:Mr.background.vertexShader,fragmentShader:Mr.background.fragmentShader,side:Ms,depthTest:!1,depthWrite:!1,fog:!1})),f.geometry.deleteAttribute("normal"),Object.defineProperty(f.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(f)),f.material.uniforms.t2D.value=w,f.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,f.material.toneMapped=w.encoding!==Ot,w.matrixAutoUpdate===!0&&w.updateMatrix(),f.material.uniforms.uvTransform.value.copy(w.matrix),(d!==w||m!==w.version||v!==n.toneMapping)&&(f.material.needsUpdate=!0,d=w,m=w.version,v=n.toneMapping),f.layers.enableAll(),S.unshift(f,f.geometry,f.material,0,0,null))}function E(S,g){S.getRGB(Xh,I2(n)),i.buffers.color.setClear(Xh.r,Xh.g,Xh.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(S,g=1){a.set(S),c=g,E(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(S){c=S,E(a,c)},render:_}}function bD(n,e,t,i){const r=n.getParameter(34921),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||s!==null,a={},c=S(null);let f=c,h=!1;function d(W,ee,oe,ue,D){let V=!1;if(o){const B=E(ue,oe,ee);f!==B&&(f=B,v(f.object)),V=g(W,ue,oe,D),V&&x(W,ue,oe,D)}else{const B=ee.wireframe===!0;(f.geometry!==ue.id||f.program!==oe.id||f.wireframe!==B)&&(f.geometry=ue.id,f.program=oe.id,f.wireframe=B,V=!0)}D!==null&&t.update(D,34963),(V||h)&&(h=!1,I(W,ee,oe,ue),D!==null&&n.bindBuffer(34963,t.get(D).buffer))}function m(){return i.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function v(W){return i.isWebGL2?n.bindVertexArray(W):s.bindVertexArrayOES(W)}function _(W){return i.isWebGL2?n.deleteVertexArray(W):s.deleteVertexArrayOES(W)}function E(W,ee,oe){const ue=oe.wireframe===!0;let D=a[W.id];D===void 0&&(D={},a[W.id]=D);let V=D[ee.id];V===void 0&&(V={},D[ee.id]=V);let B=V[ue];return B===void 0&&(B=S(m()),V[ue]=B),B}function S(W){const ee=[],oe=[],ue=[];for(let D=0;D=0){const z=D[Y];let ye=V[Y];if(ye===void 0&&(Y==="instanceMatrix"&&W.instanceMatrix&&(ye=W.instanceMatrix),Y==="instanceColor"&&W.instanceColor&&(ye=W.instanceColor)),z===void 0||z.attribute!==ye||ye&&z.data!==ye.data)return!0;B++}return f.attributesNum!==B||f.index!==ue}function x(W,ee,oe,ue){const D={},V=ee.attributes;let B=0;const J=oe.getAttributes();for(const Y in J)if(J[Y].location>=0){let z=V[Y];z===void 0&&(Y==="instanceMatrix"&&W.instanceMatrix&&(z=W.instanceMatrix),Y==="instanceColor"&&W.instanceColor&&(z=W.instanceColor));const ye={};ye.attribute=z,z&&z.data&&(ye.data=z.data),D[Y]=ye,B++}f.attributes=D,f.attributesNum=B,f.index=ue}function w(){const W=f.newAttributes;for(let ee=0,oe=W.length;ee=0){let K=D[J];if(K===void 0&&(J==="instanceMatrix"&&W.instanceMatrix&&(K=W.instanceMatrix),J==="instanceColor"&&W.instanceColor&&(K=W.instanceColor)),K!==void 0){const z=K.normalized,ye=K.itemSize,pe=t.get(K);if(pe===void 0)continue;const Q=pe.buffer,Qe=pe.type,je=pe.bytesPerElement;if(K.isInterleavedBufferAttribute){const Me=K.data,De=Me.stride,me=K.offset;if(Me.isInstancedInterleavedBuffer){for(let se=0;se0&&n.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";R="mediump"}return R==="mediump"&&n.getShaderPrecisionFormat(35633,36337).precision>0&&n.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&n.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const c=s(a);c!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",c,"instead."),a=c);const f=o||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,d=n.getParameter(34930),m=n.getParameter(35660),v=n.getParameter(3379),_=n.getParameter(34076),E=n.getParameter(34921),S=n.getParameter(36347),g=n.getParameter(36348),x=n.getParameter(36349),w=m>0,T=o||e.has("OES_texture_float"),C=w&&T,P=o?n.getParameter(36183):0;return{isWebGL2:o,drawBuffers:f,getMaxAnisotropy:r,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:m,maxTextureSize:v,maxCubemapSize:_,maxAttributes:E,maxVertexUniforms:S,maxVaryings:g,maxFragmentUniforms:x,vertexTextures:w,floatFragmentTextures:T,floatVertexTextures:C,maxSamples:P}}function RD(n){const e=this;let t=null,i=0,r=!1,s=!1;const o=new Ys,a=new xt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,m){const v=d.length!==0||m||i!==0||r;return r=m,i=d.length,v},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,m){t=h(d,m,0)},this.setState=function(d,m,v){const _=d.clippingPlanes,E=d.clipIntersection,S=d.clipShadows,g=n.get(d);if(!r||_===null||_.length===0||s&&!S)s?h(null):f();else{const x=s?0:i,w=x*4;let T=g.clippingState||null;c.value=T,T=h(_,m,w,v);for(let C=0;C!==w;++C)T[C]=t[C];g.clippingState=T,this.numIntersection=E?this.numPlanes:0,this.numPlanes+=x}};function f(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(d,m,v,_){const E=d!==null?d.length:0;let S=null;if(E!==0){if(S=c.value,_!==!0||S===null){const g=v+E*4,x=m.matrixWorldInverse;a.getNormalMatrix(x),(S===null||S.length0){const f=new k2(c.height/2);return f.fromEquirectangularTexture(n,o),e.set(o,f),o.addEventListener("dispose",r),t(f.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}class $c extends Jc{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,o=i+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){const f=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=f*this.view.offsetX,o=s+f*this.view.width,a-=h*this.view.offsetY,c=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far),this.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 xl=4,XS=[.125,.215,.35,.446,.526,.582],Ho=20,Gg=new $c,jS=new Re;let Wg=null;const Bo=(1+Math.sqrt(5))/2,Ja=1/Bo,YS=[new N(1,1,1),new N(-1,1,1),new N(1,1,-1),new N(-1,1,-1),new N(0,Bo,Ja),new N(0,Bo,-Ja),new N(Ja,0,Bo),new N(-Ja,0,Bo),new N(Bo,Ja,0),new N(-Bo,Ja,0)];class Uv{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){Wg=this._renderer.getRenderTarget(),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=QS(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ZS(),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?w:0,w,w),h.setRenderTarget(r),E&&h.render(_,a),h.render(e,a)}_.geometry.dispose(),_.material.dispose(),h.toneMapping=m,h.autoClear=d,e.background=S}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===fo||e.mapping===ho;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=QS()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ZS());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new Ne(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const c=this._cubeSize;jh(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(o,Gg)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;rHo&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${Ho}`);const g=[];let x=0;for(let R=0;Rw-xl?r-w+xl:0),P=4*(this._cubeSize-T);jh(t,C,P,3*T,2*T),c.setRenderTarget(t),c.render(d,Gg)}}function DD(n){const e=[],t=[],i=[];let r=n;const s=n-xl+1+XS.length;for(let o=0;on-xl?c=XS[o-n+xl-1]:o===0&&(c=0),i.push(c);const f=1/(a-2),h=-f,d=1+f,m=[h,h,d,h,d,d,h,h,d,d,h,d],v=6,_=6,E=3,S=2,g=1,x=new Float32Array(E*_*v),w=new Float32Array(S*_*v),T=new Float32Array(g*_*v);for(let P=0;P2?0:-1,b=[R,I,0,R+2/3,I,0,R+2/3,I+1,0,R,I,0,R+2/3,I+1,0,R,I+1,0];x.set(b,E*_*P),w.set(m,S*_*P);const L=[P,P,P,P,P,P];T.set(L,g*_*P)}const C=new lt;C.setAttribute("position",new Bt(x,E)),C.setAttribute("uv",new Bt(w,S)),C.setAttribute("faceIndex",new Bt(T,g)),e.push(C),r>xl&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function qS(n,e,t){const i=new ar(n,e,t);return i.texture.mapping=jl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function jh(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function ND(n,e,t){const i=new Float32Array(Ho),r=new N(0,1,0);return new jr({name:"SphericalGaussianBlur",defines:{n:Ho,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:n_(),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:ys,depthTest:!1,depthWrite:!1})}function ZS(){return new jr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:n_(),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:ys,depthTest:!1,depthWrite:!1})}function QS(){return new jr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:n_(),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:ys,depthTest:!1,depthWrite:!1})}function n_(){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 kD(n){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){const c=a.mapping,f=c===Tc||c===Ac,h=c===fo||c===ho;if(f||h)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let d=e.get(a);return t===null&&(t=new Uv(n)),d=f?t.fromEquirectangular(a,d):t.fromCubemap(a,d),e.set(a,d),d.texture}else{if(e.has(a))return e.get(a).texture;{const d=a.image;if(f&&d&&d.height>0||h&&d&&r(d)){t===null&&(t=new Uv(n));const m=f?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,m),a.addEventListener("dispose",s),m.texture}else return null}}}return a}function r(a){let c=0;const f=6;for(let h=0;he.maxTextureSize&&(H=Math.ceil(L/e.maxTextureSize),L=e.maxTextureSize);const q=new Float32Array(L*H*4*E),G=new Rp(q,L,H,E);G.type=Hr,G.needsUpdate=!0;const W=b*4;for(let oe=0;oe0)return n;const r=e*t;let s=JS[r];if(s===void 0&&(s=new Float32Array(r),JS[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 Mn(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t":" "} ${a}: ${t[o]}`)}return i.join(` `)}function zN(n){switch(n){case Ts:return["Linear","( value )"];case Ot:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",n),["Linear","( value )"]}}function rw(n,e,t){const i=n.getShaderParameter(e,35713),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+` `+kN(n.getShaderSource(e),o)}else return r}function UN(n,e){const t=zN(e);return"vec4 "+n+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function ON(n,e){let t;switch(e){case n2:t="Linear";break;case i2:t="Reinhard";break;case r2:t="OptimizedCineon";break;case jy:t="ACESFilmic";break;case s2:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function FN(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(Yu).join(` `)}function BN(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function VN(n,e){const t={},i=n.getProgramParameter(e,35721);for(let r=0;r/gm;function Ov(n){return n.replace(HN,GN)}function GN(n,e){const t=ht[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return Ov(t)}const WN=/#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 aw(n){return n.replace(WN,XN)}function XN(n,e,t,i){let r="";for(let s=parseInt(e);s0&&(S+=` `),g=[v,_].filter(Yu).join(` `),g.length>0&&(g+=` `)):(S=[lw(t),"#define SHADER_NAME "+t.shaderName,_,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.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.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.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?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs2?"#define USE_UV2":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.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_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(Yu).join(` `),g=[v,lw(t),"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.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.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.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs2?"#define USE_UV2":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ar?"#define TONE_MAPPING":"",t.toneMapping!==Ar?ht.tonemapping_pars_fragment:"",t.toneMapping!==Ar?ON("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ht.encodings_pars_fragment,UN("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Yu).join(` `)),o=Ov(o),o=sw(o,t),o=ow(o,t),a=Ov(a),a=sw(a,t),a=ow(a,t),o=aw(o),a=aw(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(x=`#version 300 es `,S=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+S,g=["#define varying in",t.glslVersion===kv?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===kv?"":"#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(` `)+` `+g);const w=x+S+o,T=x+g+a,C=iw(r,35633,w),P=iw(r,35632,T);if(r.attachShader(E,C),r.attachShader(E,P),t.index0AttributeName!==void 0?r.bindAttribLocation(E,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(E,0,"position"),r.linkProgram(E),n.debug.checkShaderErrors){const b=r.getProgramInfoLog(E).trim(),L=r.getShaderInfoLog(C).trim(),H=r.getShaderInfoLog(P).trim();let q=!0,G=!0;if(r.getProgramParameter(E,35714)===!1)if(q=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,E,C,P);else{const W=rw(r,C,"vertex"),ee=rw(r,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(E,35715)+` Program Info Log: `+b+` `+W+` `+ee)}else b!==""?console.warn("THREE.WebGLProgram: Program Info Log:",b):(L===""||H==="")&&(G=!1);G&&(this.diagnostics={runnable:q,programLog:b,vertexShader:{log:L,prefix:S},fragmentShader:{log:H,prefix:g}})}r.deleteShader(C),r.deleteShader(P);let R;this.getUniforms=function(){return R===void 0&&(R=new kd(r,E)),R};let I;return this.getAttributes=function(){return I===void 0&&(I=VN(r,E)),I},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(E),this.program=void 0},this.name=t.shaderName,this.id=NN++,this.cacheKey=e,this.usedTimes=1,this.program=E,this.vertexShader=C,this.fragmentShader=P,this}let KN=0;class $N{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 ek(e),t.set(e,i)),i}}class ek{constructor(e){this.id=KN++,this.code=e,this.usedTimes=0}}function tk(n,e,t,i,r,s,o){const a=new ia,c=new $N,f=[],h=r.isWebGL2,d=r.logarithmicDepthBuffer,m=r.vertexTextures;let v=r.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function E(b){return b===1?"uv2":"uv"}function S(b,L,H,q,G){const W=q.fog,ee=G.geometry,oe=b.isMeshStandardMaterial?q.environment:null,ue=(b.isMeshStandardMaterial?t:e).get(b.envMap||oe),D=!!ue&&ue.mapping===jl?ue.image.height:null,V=_[b.type];b.precision!==null&&(v=r.getMaxPrecision(b.precision),v!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",v,"instead."));const B=ee.morphAttributes.position||ee.morphAttributes.normal||ee.morphAttributes.color,J=B!==void 0?B.length:0;let Y=0;ee.morphAttributes.position!==void 0&&(Y=1),ee.morphAttributes.normal!==void 0&&(Y=2),ee.morphAttributes.color!==void 0&&(Y=3);let K,z,ye,pe;if(V){const Ie=Mr[V];K=Ie.vertexShader,z=Ie.fragmentShader}else K=b.vertexShader,z=b.fragmentShader,c.update(b),ye=c.getVertexShaderID(b),pe=c.getFragmentShaderID(b);const Q=n.getRenderTarget(),Qe=G.isInstancedMesh===!0,je=!!b.map,Me=!!b.matcap,De=!!ue,me=!!b.aoMap,se=!!b.lightMap,ve=!!b.bumpMap,Ue=!!b.normalMap,Ce=!!b.displacementMap,Ke=!!b.emissiveMap,$e=!!b.metalnessMap,Ye=!!b.roughnessMap,rt=b.clearcoat>0,Et=b.iridescence>0,F=b.sheen>0,k=b.transmission>0,ie=rt&&!!b.clearcoatMap,_e=rt&&!!b.clearcoatNormalMap,Se=rt&&!!b.clearcoatRoughnessMap,be=Et&&!!b.iridescenceMap,tt=Et&&!!b.iridescenceThicknessMap,ke=F&&!!b.sheenColorMap,he=F&&!!b.sheenRoughnessMap,Ve=!!b.specularMap,qe=!!b.specularColorMap,et=!!b.specularIntensityMap,Oe=k&&!!b.transmissionMap,Ge=k&&!!b.thicknessMap,wt=!!b.gradientMap,Lt=!!b.alphaMap,Jt=b.alphaTest>0,X=!!b.extensions,fe=!!ee.attributes.uv2;return{isWebGL2:h,shaderID:V,shaderName:b.type,vertexShader:K,fragmentShader:z,defines:b.defines,customVertexShaderID:ye,customFragmentShaderID:pe,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:v,instancing:Qe,instancingColor:Qe&&G.instanceColor!==null,supportsVertexTextures:m,outputEncoding:Q===null?n.outputEncoding:Q.isXRRenderTarget===!0?Q.texture.encoding:Ts,map:je,matcap:Me,envMap:De,envMapMode:De&&ue.mapping,envMapCubeUVHeight:D,aoMap:me,lightMap:se,bumpMap:ve,normalMap:Ue,displacementMap:m&&Ce,emissiveMap:Ke,normalMapObjectSpace:Ue&&b.normalMapType===A2,normalMapTangentSpace:Ue&&b.normalMapType===yo,decodeVideoTexture:je&&b.map.isVideoTexture===!0&&b.map.encoding===Ot,metalnessMap:$e,roughnessMap:Ye,clearcoat:rt,clearcoatMap:ie,clearcoatNormalMap:_e,clearcoatRoughnessMap:Se,iridescence:Et,iridescenceMap:be,iridescenceThicknessMap:tt,sheen:F,sheenColorMap:ke,sheenRoughnessMap:he,specularMap:Ve,specularColorMap:qe,specularIntensityMap:et,transmission:k,transmissionMap:Oe,thicknessMap:Ge,gradientMap:wt,opaque:b.transparent===!1&&b.blending===ea,alphaMap:Lt,alphaTest:Jt,combine:b.combine,mapUv:je&&E(b.map.channel),aoMapUv:me&&E(b.aoMap.channel),lightMapUv:se&&E(b.lightMap.channel),bumpMapUv:ve&&E(b.bumpMap.channel),normalMapUv:Ue&&E(b.normalMap.channel),displacementMapUv:Ce&&E(b.displacementMap.channel),emissiveMapUv:Ke&&E(b.emissiveMap.channel),metalnessMapUv:$e&&E(b.metalnessMap.channel),roughnessMapUv:Ye&&E(b.roughnessMap.channel),clearcoatMapUv:ie&&E(b.clearcoatMap.channel),clearcoatNormalMapUv:_e&&E(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Se&&E(b.clearcoatRoughnessMap.channel),iridescenceMapUv:be&&E(b.iridescenceMap.channel),iridescenceThicknessMapUv:tt&&E(b.iridescenceThicknessMap.channel),sheenColorMapUv:ke&&E(b.sheenColorMap.channel),sheenRoughnessMapUv:he&&E(b.sheenRoughnessMap.channel),specularMapUv:Ve&&E(b.specularMap.channel),specularColorMapUv:qe&&E(b.specularColorMap.channel),specularIntensityMapUv:et&&E(b.specularIntensityMap.channel),transmissionMapUv:Oe&&E(b.transmissionMap.channel),thicknessMapUv:Ge&&E(b.thicknessMap.channel),alphaMapUv:Lt&&E(b.alphaMap.channel),vertexTangents:Ue&&!!ee.attributes.tangent,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!ee.attributes.color&&ee.attributes.color.itemSize===4,vertexUvs2:fe,pointsUvs:G.isPoints===!0&&!!ee.attributes.uv&&(je||Lt),fog:!!W,useFog:b.fog===!0,fogExp2:W&&W.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:G.isSkinnedMesh===!0,morphTargets:ee.morphAttributes.position!==void 0,morphNormals:ee.morphAttributes.normal!==void 0,morphColors:ee.morphAttributes.color!==void 0,morphTargetsCount:J,morphTextureStride:Y,numDirLights:L.directional.length,numPointLights:L.point.length,numSpotLights:L.spot.length,numSpotLightMaps:L.spotLightMap.length,numRectAreaLights:L.rectArea.length,numHemiLights:L.hemi.length,numDirLightShadows:L.directionalShadowMap.length,numPointLightShadows:L.pointShadowMap.length,numSpotLightShadows:L.spotShadowMap.length,numSpotLightShadowsWithMaps:L.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&H.length>0,shadowMapType:n.shadowMap.type,toneMapping:b.toneMapped?n.toneMapping:Ar,useLegacyLights:n.useLegacyLights,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===nr,flipSided:b.side===li,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionDerivatives:X&&b.extensions.derivatives===!0,extensionFragDepth:X&&b.extensions.fragDepth===!0,extensionDrawBuffers:X&&b.extensions.drawBuffers===!0,extensionShaderTextureLOD:X&&b.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),customProgramCacheKey:b.customProgramCacheKey()}}function g(b){const L=[];if(b.shaderID?L.push(b.shaderID):(L.push(b.customVertexShaderID),L.push(b.customFragmentShaderID)),b.defines!==void 0)for(const H in b.defines)L.push(H),L.push(b.defines[H]);return b.isRawShaderMaterial===!1&&(x(L,b),w(L,b),L.push(n.outputEncoding)),L.push(b.customProgramCacheKey),L.join()}function x(b,L){b.push(L.precision),b.push(L.outputEncoding),b.push(L.envMapMode),b.push(L.envMapCubeUVHeight),b.push(L.mapUv),b.push(L.alphaMapUv),b.push(L.lightMapUv),b.push(L.aoMapUv),b.push(L.bumpMapUv),b.push(L.normalMapUv),b.push(L.displacementMapUv),b.push(L.emissiveMapUv),b.push(L.metalnessMapUv),b.push(L.roughnessMapUv),b.push(L.clearcoatMapUv),b.push(L.clearcoatNormalMapUv),b.push(L.clearcoatRoughnessMapUv),b.push(L.iridescenceMapUv),b.push(L.iridescenceThicknessMapUv),b.push(L.sheenColorMapUv),b.push(L.sheenRoughnessMapUv),b.push(L.specularMapUv),b.push(L.specularColorMapUv),b.push(L.specularIntensityMapUv),b.push(L.transmissionMapUv),b.push(L.thicknessMapUv),b.push(L.combine),b.push(L.fogExp2),b.push(L.sizeAttenuation),b.push(L.morphTargetsCount),b.push(L.morphAttributeCount),b.push(L.numDirLights),b.push(L.numPointLights),b.push(L.numSpotLights),b.push(L.numSpotLightMaps),b.push(L.numHemiLights),b.push(L.numRectAreaLights),b.push(L.numDirLightShadows),b.push(L.numPointLightShadows),b.push(L.numSpotLightShadows),b.push(L.numSpotLightShadowsWithMaps),b.push(L.shadowMapType),b.push(L.toneMapping),b.push(L.numClippingPlanes),b.push(L.numClipIntersection),b.push(L.depthPacking)}function w(b,L){a.disableAll(),L.isWebGL2&&a.enable(0),L.supportsVertexTextures&&a.enable(1),L.instancing&&a.enable(2),L.instancingColor&&a.enable(3),L.matcap&&a.enable(4),L.envMap&&a.enable(5),L.normalMapObjectSpace&&a.enable(6),L.normalMapTangentSpace&&a.enable(7),L.clearcoat&&a.enable(8),L.iridescence&&a.enable(9),L.alphaTest&&a.enable(10),L.vertexColors&&a.enable(11),L.vertexAlphas&&a.enable(12),L.vertexUvs2&&a.enable(13),L.vertexTangents&&a.enable(14),b.push(a.mask),a.disableAll(),L.fog&&a.enable(0),L.useFog&&a.enable(1),L.flatShading&&a.enable(2),L.logarithmicDepthBuffer&&a.enable(3),L.skinning&&a.enable(4),L.morphTargets&&a.enable(5),L.morphNormals&&a.enable(6),L.morphColors&&a.enable(7),L.premultipliedAlpha&&a.enable(8),L.shadowMapEnabled&&a.enable(9),L.useLegacyLights&&a.enable(10),L.doubleSided&&a.enable(11),L.flipSided&&a.enable(12),L.useDepthPacking&&a.enable(13),L.dithering&&a.enable(14),L.transmission&&a.enable(15),L.sheen&&a.enable(16),L.decodeVideoTexture&&a.enable(17),L.opaque&&a.enable(18),L.pointsUvs&&a.enable(19),b.push(a.mask)}function T(b){const L=_[b.type];let H;if(L){const q=Mr[L];H=D2.clone(q.uniforms)}else H=b.uniforms;return H}function C(b,L){let H;for(let q=0,G=f.length;q0?i.push(g):v.transparent===!0?r.push(g):t.push(g)}function c(d,m,v,_,E,S){const g=o(d,m,v,_,E,S);v.transmission>0?i.unshift(g):v.transparent===!0?r.unshift(g):t.unshift(g)}function f(d,m){t.length>1&&t.sort(d||ik),i.length>1&&i.sort(m||uw),r.length>1&&r.sort(m||uw)}function h(){for(let d=e,m=n.length;d=s.length?(o=new cw,s.push(o)):o=s[r],o}function t(){n=new WeakMap}return{get:e,dispose:t}}function sk(){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 N,color:new Re};break;case"SpotLight":t={position:new N,direction:new N,color:new Re,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new Re,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new Re,groundColor:new Re};break;case"RectAreaLight":t={color:new Re,position:new N,halfWidth:new N,halfHeight:new N};break}return n[e.id]=t,t}}}function ok(){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 ge};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ge};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ge,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let ak=0;function lk(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function uk(n,e){const t=new sk,i=ok(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let h=0;h<9;h++)r.probe.push(new N);const s=new N,o=new st,a=new st;function c(h,d){let m=0,v=0,_=0;for(let H=0;H<9;H++)r.probe[H].set(0,0,0);let E=0,S=0,g=0,x=0,w=0,T=0,C=0,P=0,R=0,I=0;h.sort(lk);const b=d===!0?Math.PI:1;for(let H=0,q=h.length;H0&&(e.isWebGL2||n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ae.LTC_FLOAT_1,r.rectAreaLTC2=Ae.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=Ae.LTC_HALF_1,r.rectAreaLTC2=Ae.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=m,r.ambient[1]=v,r.ambient[2]=_;const L=r.hash;(L.directionalLength!==E||L.pointLength!==S||L.spotLength!==g||L.rectAreaLength!==x||L.hemiLength!==w||L.numDirectionalShadows!==T||L.numPointShadows!==C||L.numSpotShadows!==P||L.numSpotMaps!==R)&&(r.directional.length=E,r.spot.length=g,r.rectArea.length=x,r.point.length=S,r.hemi.length=w,r.directionalShadow.length=T,r.directionalShadowMap.length=T,r.pointShadow.length=C,r.pointShadowMap.length=C,r.spotShadow.length=P,r.spotShadowMap.length=P,r.directionalShadowMatrix.length=T,r.pointShadowMatrix.length=C,r.spotLightMatrix.length=P+R-I,r.spotLightMap.length=R,r.numSpotLightShadowsWithMaps=I,L.directionalLength=E,L.pointLength=S,L.spotLength=g,L.rectAreaLength=x,L.hemiLength=w,L.numDirectionalShadows=T,L.numPointShadows=C,L.numSpotShadows=P,L.numSpotMaps=R,r.version=ak++)}function f(h,d){let m=0,v=0,_=0,E=0,S=0;const g=d.matrixWorldInverse;for(let x=0,w=h.length;x=a.length?(c=new fw(n,e),a.push(c)):c=a[o],c}function r(){t=new WeakMap}return{get:i,dispose:r}}class i_ extends Bn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=E2,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 r_ extends Bn{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 fk=`void main() { gl_Position = vec4( position, 1.0 ); }`,hk=`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 dk(n,e,t){let i=new Ip;const r=new ge,s=new ge,o=new Nt,a=new i_({depthPacking:T2}),c=new r_,f={},h=t.maxTextureSize,d={[Ms]:li,[li]:Ms,[nr]:nr},m=new jr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ge},radius:{value:4}},vertexShader:fk,fragmentShader:hk}),v=m.clone();v.defines.HORIZONTAL_PASS=1;const _=new lt;_.setAttribute("position",new Bt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const E=new Ne(_,m),S=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bp,this.render=function(T,C,P){if(S.enabled===!1||S.autoUpdate===!1&&S.needsUpdate===!1||T.length===0)return;const R=n.getRenderTarget(),I=n.getActiveCubeFace(),b=n.getActiveMipmapLevel(),L=n.state;L.setBlending(ys),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);for(let H=0,q=T.length;Hh||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/ee.x),r.x=s.x*ee.x,W.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/ee.y),r.y=s.y*ee.y,W.mapSize.y=s.y)),W.map===null){const ue=this.type!==jo?{minFilter:hn,magFilter:hn}:{};W.map=new ar(r.x,r.y,ue),W.map.texture.name=G.name+".shadowMap",W.camera.updateProjectionMatrix()}n.setRenderTarget(W.map),n.clear();const oe=W.getViewportCount();for(let ue=0;ue0||C.map&&C.alphaTest>0){const L=I.uuid,H=C.uuid;let q=f[L];q===void 0&&(q={},f[L]=q);let G=q[H];G===void 0&&(G=I.clone(),q[H]=G),I=G}if(I.visible=C.visible,I.wireframe=C.wireframe,R===jo?I.side=C.shadowSide!==null?C.shadowSide:C.side:I.side=C.shadowSide!==null?C.shadowSide:d[C.side],I.alphaMap=C.alphaMap,I.alphaTest=C.alphaTest,I.map=C.map,I.clipShadows=C.clipShadows,I.clippingPlanes=C.clippingPlanes,I.clipIntersection=C.clipIntersection,I.displacementMap=C.displacementMap,I.displacementScale=C.displacementScale,I.displacementBias=C.displacementBias,I.wireframeLinewidth=C.wireframeLinewidth,I.linewidth=C.linewidth,P.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const L=n.properties.get(I);L.light=P}return I}function w(T,C,P,R,I){if(T.visible===!1)return;if(T.layers.test(C.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&I===jo)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,T.matrixWorld);const H=e.update(T),q=T.material;if(Array.isArray(q)){const G=H.groups;for(let W=0,ee=G.length;W=1):D.indexOf("OpenGL ES")!==-1&&(ue=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),oe=ue>=2);let V=null,B={};const J=n.getParameter(3088),Y=n.getParameter(2978),K=new Nt().fromArray(J),z=new Nt().fromArray(Y);function ye(X,fe,xe){const Ie=new Uint8Array(4),We=n.createTexture();n.bindTexture(X,We),n.texParameteri(X,10241,9728),n.texParameteri(X,10240,9728);for(let zt=0;zt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),_=new WeakMap;let E;const S=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(F,k){return g?new OffscreenCanvas(F,k):Dc("canvas")}function w(F,k,ie,_e){let Se=1;if((F.width>_e||F.height>_e)&&(Se=_e/Math.max(F.width,F.height)),Se<1||k===!0)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap){const be=k?P2:Math.floor,tt=be(Se*F.width),ke=be(Se*F.height);E===void 0&&(E=x(tt,ke));const he=ie?x(tt,ke):E;return he.width=tt,he.height=ke,he.getContext("2d").drawImage(F,0,0,tt,ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+F.width+"x"+F.height+") to ("+tt+"x"+ke+")."),he}else return"data"in F&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+F.width+"x"+F.height+")."),F;return F}function T(F){return zv(F.width)&&zv(F.height)}function C(F){return a?!1:F.wrapS!==Jn||F.wrapT!==Jn||F.minFilter!==hn&&F.minFilter!==en}function P(F,k){return F.generateMipmaps&&k&&F.minFilter!==hn&&F.minFilter!==en}function R(F){n.generateMipmap(F)}function I(F,k,ie,_e,Se=!1){if(a===!1)return k;if(F!==null){if(n[F]!==void 0)return n[F];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let be=k;return k===6403&&(ie===5126&&(be=33326),ie===5131&&(be=33325),ie===5121&&(be=33321)),k===33319&&(ie===5126&&(be=33328),ie===5131&&(be=33327),ie===5121&&(be=33323)),k===6408&&(ie===5126&&(be=34836),ie===5131&&(be=34842),ie===5121&&(be=_e===Ot&&Se===!1?35907:32856),ie===32819&&(be=32854),ie===32820&&(be=32855)),(be===33325||be===33326||be===33327||be===33328||be===34842||be===34836)&&e.get("EXT_color_buffer_float"),be}function b(F,k,ie){return P(F,ie)===!0||F.isFramebufferTexture&&F.minFilter!==hn&&F.minFilter!==en?Math.log2(Math.max(k.width,k.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?k.mipmaps.length:1}function L(F){return F===hn||F===ap||F===rc?9728:9729}function H(F){const k=F.target;k.removeEventListener("dispose",H),G(k),k.isVideoTexture&&_.delete(k)}function q(F){const k=F.target;k.removeEventListener("dispose",q),ee(k)}function G(F){const k=i.get(F);if(k.__webglInit===void 0)return;const ie=F.source,_e=S.get(ie);if(_e){const Se=_e[k.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&W(F),Object.keys(_e).length===0&&S.delete(ie)}i.remove(F)}function W(F){const k=i.get(F);n.deleteTexture(k.__webglTexture);const ie=F.source,_e=S.get(ie);delete _e[k.__cacheKey],o.memory.textures--}function ee(F){const k=F.texture,ie=i.get(F),_e=i.get(k);if(_e.__webglTexture!==void 0&&(n.deleteTexture(_e.__webglTexture),o.memory.textures--),F.depthTexture&&F.depthTexture.dispose(),F.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++)n.deleteFramebuffer(ie.__webglFramebuffer[Se]),ie.__webglDepthbuffer&&n.deleteRenderbuffer(ie.__webglDepthbuffer[Se]);else{if(n.deleteFramebuffer(ie.__webglFramebuffer),ie.__webglDepthbuffer&&n.deleteRenderbuffer(ie.__webglDepthbuffer),ie.__webglMultisampledFramebuffer&&n.deleteFramebuffer(ie.__webglMultisampledFramebuffer),ie.__webglColorRenderbuffer)for(let Se=0;Se=c&&console.warn("THREE.WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+c),oe+=1,F}function V(F){const k=[];return k.push(F.wrapS),k.push(F.wrapT),k.push(F.wrapR||0),k.push(F.magFilter),k.push(F.minFilter),k.push(F.anisotropy),k.push(F.internalFormat),k.push(F.format),k.push(F.type),k.push(F.generateMipmaps),k.push(F.premultiplyAlpha),k.push(F.flipY),k.push(F.unpackAlignment),k.push(F.encoding),k.join()}function B(F,k){const ie=i.get(F);if(F.isVideoTexture&&rt(F),F.isRenderTargetTexture===!1&&F.version>0&&ie.__version!==F.version){const _e=F.image;if(_e===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(_e.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Qe(ie,F,k);return}}t.bindTexture(3553,ie.__webglTexture,33984+k)}function J(F,k){const ie=i.get(F);if(F.version>0&&ie.__version!==F.version){Qe(ie,F,k);return}t.bindTexture(35866,ie.__webglTexture,33984+k)}function Y(F,k){const ie=i.get(F);if(F.version>0&&ie.__version!==F.version){Qe(ie,F,k);return}t.bindTexture(32879,ie.__webglTexture,33984+k)}function K(F,k){const ie=i.get(F);if(F.version>0&&ie.__version!==F.version){je(ie,F,k);return}t.bindTexture(34067,ie.__webglTexture,33984+k)}const z={[Cc]:10497,[Jn]:33071,[bc]:33648},ye={[hn]:9728,[ap]:9984,[rc]:9986,[en]:9729,[Yy]:9985,[po]:9987};function pe(F,k,ie){if(ie?(n.texParameteri(F,10242,z[k.wrapS]),n.texParameteri(F,10243,z[k.wrapT]),(F===32879||F===35866)&&n.texParameteri(F,32882,z[k.wrapR]),n.texParameteri(F,10240,ye[k.magFilter]),n.texParameteri(F,10241,ye[k.minFilter])):(n.texParameteri(F,10242,33071),n.texParameteri(F,10243,33071),(F===32879||F===35866)&&n.texParameteri(F,32882,33071),(k.wrapS!==Jn||k.wrapT!==Jn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(F,10240,L(k.magFilter)),n.texParameteri(F,10241,L(k.minFilter)),k.minFilter!==hn&&k.minFilter!==en&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const _e=e.get("EXT_texture_filter_anisotropic");if(k.magFilter===hn||k.minFilter!==rc&&k.minFilter!==po||k.type===Hr&&e.has("OES_texture_float_linear")===!1||a===!1&&k.type===ca&&e.has("OES_texture_half_float_linear")===!1)return;(k.anisotropy>1||i.get(k).__currentAnisotropy)&&(n.texParameterf(F,_e.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),i.get(k).__currentAnisotropy=k.anisotropy)}}function Q(F,k){let ie=!1;F.__webglInit===void 0&&(F.__webglInit=!0,k.addEventListener("dispose",H));const _e=k.source;let Se=S.get(_e);Se===void 0&&(Se={},S.set(_e,Se));const be=V(k);if(be!==F.__cacheKey){Se[be]===void 0&&(Se[be]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,ie=!0),Se[be].usedTimes++;const tt=Se[F.__cacheKey];tt!==void 0&&(Se[F.__cacheKey].usedTimes--,tt.usedTimes===0&&W(k)),F.__cacheKey=be,F.__webglTexture=Se[be].texture}return ie}function Qe(F,k,ie){let _e=3553;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(_e=35866),k.isData3DTexture&&(_e=32879);const Se=Q(F,k),be=k.source;t.bindTexture(_e,F.__webglTexture,33984+ie);const tt=i.get(be);if(be.version!==tt.__version||Se===!0){t.activeTexture(33984+ie),n.pixelStorei(37440,k.flipY),n.pixelStorei(37441,k.premultiplyAlpha),n.pixelStorei(3317,k.unpackAlignment),n.pixelStorei(37443,0);const ke=C(k)&&T(k.image)===!1;let he=w(k.image,ke,!1,h);he=Et(k,he);const Ve=T(he)||a,qe=s.convert(k.format,k.encoding);let et=s.convert(k.type),Oe=I(k.internalFormat,qe,et,k.encoding,k.isVideoTexture);pe(_e,k,Ve);let Ge;const wt=k.mipmaps,Lt=a&&k.isVideoTexture!==!0,Jt=tt.__version===void 0||Se===!0,X=b(k,he,Ve);if(k.isDepthTexture)Oe=6402,a?k.type===Hr?Oe=36012:k.type===$s?Oe=33190:k.type===ta?Oe=35056:Oe=33189:k.type===Hr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),k.format===lo&&Oe===6402&&k.type!==qy&&k.type!==$s&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),k.type=$s,et=s.convert(k.type)),k.format===fa&&Oe===6402&&(Oe=34041,k.type!==ta&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),k.type=ta,et=s.convert(k.type))),Jt&&(Lt?t.texStorage2D(3553,1,Oe,he.width,he.height):t.texImage2D(3553,0,Oe,he.width,he.height,0,qe,et,null));else if(k.isDataTexture)if(wt.length>0&&Ve){Lt&&Jt&&t.texStorage2D(3553,X,Oe,wt[0].width,wt[0].height);for(let fe=0,xe=wt.length;fe>=1,xe>>=1}}else if(wt.length>0&&Ve){Lt&&Jt&&t.texStorage2D(3553,X,Oe,wt[0].width,wt[0].height);for(let fe=0,xe=wt.length;fe0&&Jt++,t.texStorage2D(34067,Jt,Ge,he[0].width,he[0].height));for(let fe=0;fe<6;fe++)if(ke){wt?t.texSubImage2D(34069+fe,0,0,0,he[fe].width,he[fe].height,et,Oe,he[fe].data):t.texImage2D(34069+fe,0,Ge,he[fe].width,he[fe].height,0,et,Oe,he[fe].data);for(let xe=0;xe=34069&&Se<=34074)&&n.framebufferTexture2D(36160,_e,Se,i.get(ie).__webglTexture,0),t.bindFramebuffer(36160,null)}function De(F,k,ie){if(n.bindRenderbuffer(36161,F),k.depthBuffer&&!k.stencilBuffer){let _e=33189;if(ie||Ye(k)){const Se=k.depthTexture;Se&&Se.isDepthTexture&&(Se.type===Hr?_e=36012:Se.type===$s&&(_e=33190));const be=$e(k);Ye(k)?m.renderbufferStorageMultisampleEXT(36161,be,_e,k.width,k.height):n.renderbufferStorageMultisample(36161,be,_e,k.width,k.height)}else n.renderbufferStorage(36161,_e,k.width,k.height);n.framebufferRenderbuffer(36160,36096,36161,F)}else if(k.depthBuffer&&k.stencilBuffer){const _e=$e(k);ie&&Ye(k)===!1?n.renderbufferStorageMultisample(36161,_e,35056,k.width,k.height):Ye(k)?m.renderbufferStorageMultisampleEXT(36161,_e,35056,k.width,k.height):n.renderbufferStorage(36161,34041,k.width,k.height),n.framebufferRenderbuffer(36160,33306,36161,F)}else{const _e=k.isWebGLMultipleRenderTargets===!0?k.texture:[k.texture];for(let Se=0;Se<_e.length;Se++){const be=_e[Se],tt=s.convert(be.format,be.encoding),ke=s.convert(be.type),he=I(be.internalFormat,tt,ke,be.encoding),Ve=$e(k);ie&&Ye(k)===!1?n.renderbufferStorageMultisample(36161,Ve,he,k.width,k.height):Ye(k)?m.renderbufferStorageMultisampleEXT(36161,Ve,he,k.width,k.height):n.renderbufferStorage(36161,he,k.width,k.height)}}n.bindRenderbuffer(36161,null)}function me(F,k){if(k&&k.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,F),!(k.depthTexture&&k.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(k.depthTexture).__webglTexture||k.depthTexture.image.width!==k.width||k.depthTexture.image.height!==k.height)&&(k.depthTexture.image.width=k.width,k.depthTexture.image.height=k.height,k.depthTexture.needsUpdate=!0),B(k.depthTexture,0);const _e=i.get(k.depthTexture).__webglTexture,Se=$e(k);if(k.depthTexture.format===lo)Ye(k)?m.framebufferTexture2DMultisampleEXT(36160,36096,3553,_e,0,Se):n.framebufferTexture2D(36160,36096,3553,_e,0);else if(k.depthTexture.format===fa)Ye(k)?m.framebufferTexture2DMultisampleEXT(36160,33306,3553,_e,0,Se):n.framebufferTexture2D(36160,33306,3553,_e,0);else throw new Error("Unknown depthTexture format")}function se(F){const k=i.get(F),ie=F.isWebGLCubeRenderTarget===!0;if(F.depthTexture&&!k.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");me(k.__webglFramebuffer,F)}else if(ie){k.__webglDepthbuffer=[];for(let _e=0;_e<6;_e++)t.bindFramebuffer(36160,k.__webglFramebuffer[_e]),k.__webglDepthbuffer[_e]=n.createRenderbuffer(),De(k.__webglDepthbuffer[_e],F,!1)}else t.bindFramebuffer(36160,k.__webglFramebuffer),k.__webglDepthbuffer=n.createRenderbuffer(),De(k.__webglDepthbuffer,F,!1);t.bindFramebuffer(36160,null)}function ve(F,k,ie){const _e=i.get(F);k!==void 0&&Me(_e.__webglFramebuffer,F,F.texture,36064,3553),ie!==void 0&&se(F)}function Ue(F){const k=F.texture,ie=i.get(F),_e=i.get(k);F.addEventListener("dispose",q),F.isWebGLMultipleRenderTargets!==!0&&(_e.__webglTexture===void 0&&(_e.__webglTexture=n.createTexture()),_e.__version=k.version,o.memory.textures++);const Se=F.isWebGLCubeRenderTarget===!0,be=F.isWebGLMultipleRenderTargets===!0,tt=T(F)||a;if(Se){ie.__webglFramebuffer=[];for(let ke=0;ke<6;ke++)ie.__webglFramebuffer[ke]=n.createFramebuffer()}else{if(ie.__webglFramebuffer=n.createFramebuffer(),be)if(r.drawBuffers){const ke=F.texture;for(let he=0,Ve=ke.length;he0&&Ye(F)===!1){const ke=be?k:[k];ie.__webglMultisampledFramebuffer=n.createFramebuffer(),ie.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,ie.__webglMultisampledFramebuffer);for(let he=0;he0&&Ye(F)===!1){const k=F.isWebGLMultipleRenderTargets?F.texture:[F.texture],ie=F.width,_e=F.height;let Se=16384;const be=[],tt=F.stencilBuffer?33306:36096,ke=i.get(F),he=F.isWebGLMultipleRenderTargets===!0;if(he)for(let Ve=0;Ve0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function rt(F){const k=o.render.frame;_.get(F)!==k&&(_.set(F,k),F.update())}function Et(F,k){const ie=F.encoding,_e=F.format,Se=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||F.format===lp||ie!==Ts&&(ie===Ot?a===!1?e.has("EXT_sRGB")===!0&&_e===_i?(F.format=lp,F.minFilter=en,F.generateMipmaps=!1):k=Ky.sRGBToLinear(k):(_e!==_i||Se!==Es)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ie)),k}this.allocateTextureUnit=D,this.resetTextureUnits=ue,this.setTexture2D=B,this.setTexture2DArray=J,this.setTexture3D=Y,this.setTextureCube=K,this.rebindTextures=ve,this.setupRenderTarget=Ue,this.updateRenderTargetMipmap=Ce,this.updateMultisampleRenderTarget=Ke,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=Me,this.useMultisampledRTT=Ye}function V2(n,e,t){const i=t.isWebGL2;function r(s,o=null){let a;if(s===Es)return 5121;if(s===u2)return 32819;if(s===c2)return 32820;if(s===o2)return 5120;if(s===a2)return 5122;if(s===qy)return 5123;if(s===l2)return 5124;if(s===$s)return 5125;if(s===Hr)return 5126;if(s===ca)return i?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===f2)return 6406;if(s===_i)return 6408;if(s===h2)return 6409;if(s===d2)return 6410;if(s===lo)return 6402;if(s===fa)return 34041;if(s===lp)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===p2)return 6403;if(s===m2)return 36244;if(s===g2)return 33319;if(s===v2)return 33320;if(s===y2)return 36249;if(s===bd||s===Pd||s===Ld||s===Rd)if(o===Ot)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===bd)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Pd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Ld)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Rd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===bd)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Pd)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Ld)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Rd)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===hv||s===dv||s===pv||s===mv)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===hv)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===dv)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===pv)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===mv)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===_2)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===gv||s===vv)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===gv)return o===Ot?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===vv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===yv||s===_v||s===xv||s===Sv||s===wv||s===Mv||s===Ev||s===Tv||s===Av||s===Cv||s===bv||s===Pv||s===Lv||s===Rv)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===yv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===_v)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===xv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Sv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===wv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Mv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Ev)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Tv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Av)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Cv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===bv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Pv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Lv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Rv)return o===Ot?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Id)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Id)return o===Ot?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===x2||s===Iv||s===Dv||s===Nv)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===Id)return a.COMPRESSED_RED_RGTC1_EXT;if(s===Iv)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Dv)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Nv)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===ta?i?34042:(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 H2 extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Sl extends St{constructor(){super(),this.isGroup=!0,this.type="Group"}}const gk={type:"move"};class jg{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Sl,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 Sl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Sl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null;const a=this._targetRay,c=this._grip,f=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(f&&e.hand){o=!0;for(const E of e.hand.values()){const S=t.getJointPose(E,i),g=this._getHandJoint(f,E);S!==null&&(g.matrix.fromArray(S.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=S.radius),g.visible=S!==null}const h=f.joints["index-finger-tip"],d=f.joints["thumb-tip"],m=h.position.distanceTo(d.position),v=.02,_=.005;f.inputState.pinching&&m>v+_?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!f.inputState.pinching&&m<=v-_&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),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(gk)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),f!==null&&(f.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Sl;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class s_ extends un{constructor(e,t,i,r,s,o,a,c,f,h){if(h=h!==void 0?h:lo,h!==lo&&h!==fa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===lo&&(i=$s),i===void 0&&h===fa&&(i=ta),super(null,r,s,o,a,c,h,i,f),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:hn,this.minFilter=c!==void 0?c:hn,this.flipY=!1,this.generateMipmaps=!1}}class vk extends bs{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",c=1,f=null,h=null,d=null,m=null,v=null,_=null;const E=t.getContextAttributes();let S=null,g=null;const x=[],w=[],T=new Set,C=new Map,P=new In;P.layers.enable(1),P.viewport=new Nt;const R=new In;R.layers.enable(2),R.viewport=new Nt;const I=[P,R],b=new H2;b.layers.enable(1),b.layers.enable(2);let L=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let z=x[K];return z===void 0&&(z=new jg,x[K]=z),z.getTargetRaySpace()},this.getControllerGrip=function(K){let z=x[K];return z===void 0&&(z=new jg,x[K]=z),z.getGripSpace()},this.getHand=function(K){let z=x[K];return z===void 0&&(z=new jg,x[K]=z),z.getHandSpace()};function q(K){const z=w.indexOf(K.inputSource);if(z===-1)return;const ye=x[z];ye!==void 0&&ye.dispatchEvent({type:K.type,data:K.inputSource})}function G(){r.removeEventListener("select",q),r.removeEventListener("selectstart",q),r.removeEventListener("selectend",q),r.removeEventListener("squeeze",q),r.removeEventListener("squeezestart",q),r.removeEventListener("squeezeend",q),r.removeEventListener("end",G),r.removeEventListener("inputsourceschange",W);for(let K=0;K=0&&(w[pe]=null,x[pe].disconnect(ye))}for(let z=0;z=w.length){w.push(ye),pe=Qe;break}else if(w[Qe]===null){w[Qe]=ye,pe=Qe;break}if(pe===-1)break}const Q=x[pe];Q&&Q.connect(ye)}}const ee=new N,oe=new N;function ue(K,z,ye){ee.setFromMatrixPosition(z.matrixWorld),oe.setFromMatrixPosition(ye.matrixWorld);const pe=ee.distanceTo(oe),Q=z.projectionMatrix.elements,Qe=ye.projectionMatrix.elements,je=Q[14]/(Q[10]-1),Me=Q[14]/(Q[10]+1),De=(Q[9]+1)/Q[5],me=(Q[9]-1)/Q[5],se=(Q[8]-1)/Q[0],ve=(Qe[8]+1)/Qe[0],Ue=je*se,Ce=je*ve,Ke=pe/(-se+ve),$e=Ke*-se;z.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX($e),K.translateZ(Ke),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert();const Ye=je+Ke,rt=Me+Ke,Et=Ue-$e,F=Ce+(pe-$e),k=De*Me/rt*Ye,ie=me*Me/rt*Ye;K.projectionMatrix.makePerspective(Et,F,k,ie,Ye,rt),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}function D(K,z){z===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(z.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(r===null)return;b.near=R.near=P.near=K.near,b.far=R.far=P.far=K.far,(L!==b.near||H!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),L=b.near,H=b.far);const z=K.parent,ye=b.cameras;D(b,z);for(let pe=0;peQ&&(C.set(pe,pe.lastChangedTime),i.dispatchEvent({type:"planechanged",data:pe}))}}_=null}const Y=new z2;Y.setAnimationLoop(J),this.setAnimationLoop=function(K){B=K},this.dispose=function(){}}}function yk(n,e){function t(S,g){S.matrixAutoUpdate===!0&&S.updateMatrix(),g.value.copy(S.matrix)}function i(S,g){g.color.getRGB(S.fogColor.value,I2(n)),g.isFog?(S.fogNear.value=g.near,S.fogFar.value=g.far):g.isFogExp2&&(S.fogDensity.value=g.density)}function r(S,g,x,w,T){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(S,g):g.isMeshToonMaterial?(s(S,g),d(S,g)):g.isMeshPhongMaterial?(s(S,g),h(S,g)):g.isMeshStandardMaterial?(s(S,g),m(S,g),g.isMeshPhysicalMaterial&&v(S,g,T)):g.isMeshMatcapMaterial?(s(S,g),_(S,g)):g.isMeshDepthMaterial?s(S,g):g.isMeshDistanceMaterial?(s(S,g),E(S,g)):g.isMeshNormalMaterial?s(S,g):g.isLineBasicMaterial?(o(S,g),g.isLineDashedMaterial&&a(S,g)):g.isPointsMaterial?c(S,g,x,w):g.isSpriteMaterial?f(S,g):g.isShadowMaterial?(S.color.value.copy(g.color),S.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(S,g){S.opacity.value=g.opacity,g.color&&S.diffuse.value.copy(g.color),g.emissive&&S.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(S.map.value=g.map,t(g.map,S.mapTransform)),g.alphaMap&&(S.alphaMap.value=g.alphaMap,t(g.alphaMap,S.alphaMapTransform)),g.bumpMap&&(S.bumpMap.value=g.bumpMap,t(g.bumpMap,S.bumpMapTransform),S.bumpScale.value=g.bumpScale,g.side===li&&(S.bumpScale.value*=-1)),g.normalMap&&(S.normalMap.value=g.normalMap,t(g.normalMap,S.normalMapTransform),S.normalScale.value.copy(g.normalScale),g.side===li&&S.normalScale.value.negate()),g.displacementMap&&(S.displacementMap.value=g.displacementMap,t(g.displacementMap,S.displacementMapTransform),S.displacementScale.value=g.displacementScale,S.displacementBias.value=g.displacementBias),g.emissiveMap&&(S.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,S.emissiveMapTransform)),g.specularMap&&(S.specularMap.value=g.specularMap,t(g.specularMap,S.specularMapTransform)),g.alphaTest>0&&(S.alphaTest.value=g.alphaTest);const x=e.get(g).envMap;if(x&&(S.envMap.value=x,S.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,S.reflectivity.value=g.reflectivity,S.ior.value=g.ior,S.refractionRatio.value=g.refractionRatio),g.lightMap){S.lightMap.value=g.lightMap;const w=n.useLegacyLights===!0?Math.PI:1;S.lightMapIntensity.value=g.lightMapIntensity*w,t(g.lightMap,S.lightMapTransform)}g.aoMap&&(S.aoMap.value=g.aoMap,S.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,S.aoMapTransform))}function o(S,g){S.diffuse.value.copy(g.color),S.opacity.value=g.opacity,g.map&&(S.map.value=g.map,t(g.map,S.mapTransform))}function a(S,g){S.dashSize.value=g.dashSize,S.totalSize.value=g.dashSize+g.gapSize,S.scale.value=g.scale}function c(S,g,x,w){S.diffuse.value.copy(g.color),S.opacity.value=g.opacity,S.size.value=g.size*x,S.scale.value=w*.5,g.map&&(S.map.value=g.map,t(g.map,S.uvTransform)),g.alphaMap&&(S.alphaMap.value=g.alphaMap),g.alphaTest>0&&(S.alphaTest.value=g.alphaTest)}function f(S,g){S.diffuse.value.copy(g.color),S.opacity.value=g.opacity,S.rotation.value=g.rotation,g.map&&(S.map.value=g.map,t(g.map,S.mapTransform)),g.alphaMap&&(S.alphaMap.value=g.alphaMap),g.alphaTest>0&&(S.alphaTest.value=g.alphaTest)}function h(S,g){S.specular.value.copy(g.specular),S.shininess.value=Math.max(g.shininess,1e-4)}function d(S,g){g.gradientMap&&(S.gradientMap.value=g.gradientMap)}function m(S,g){S.metalness.value=g.metalness,g.metalnessMap&&(S.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,S.metalnessMapTransform)),S.roughness.value=g.roughness,g.roughnessMap&&(S.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,S.roughnessMapTransform)),e.get(g).envMap&&(S.envMapIntensity.value=g.envMapIntensity)}function v(S,g,x){S.ior.value=g.ior,g.sheen>0&&(S.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),S.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(S.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,S.sheenColorMapTransform)),g.sheenRoughnessMap&&(S.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,S.sheenRoughnessMapTransform))),g.clearcoat>0&&(S.clearcoat.value=g.clearcoat,S.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(S.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,S.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(S.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,S.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(S.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,S.clearcoatNormalMapTransform),S.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===li&&S.clearcoatNormalScale.value.negate())),g.iridescence>0&&(S.iridescence.value=g.iridescence,S.iridescenceIOR.value=g.iridescenceIOR,S.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],S.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(S.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,S.iridescenceMapTransform)),g.iridescenceThicknessMap&&(S.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,S.iridescenceThicknessMapTransform))),g.transmission>0&&(S.transmission.value=g.transmission,S.transmissionSamplerMap.value=x.texture,S.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(S.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,S.transmissionMapTransform)),S.thickness.value=g.thickness,g.thicknessMap&&(S.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,S.thicknessMapTransform)),S.attenuationDistance.value=g.attenuationDistance,S.attenuationColor.value.copy(g.attenuationColor)),S.specularIntensity.value=g.specularIntensity,S.specularColor.value.copy(g.specularColor),g.specularColorMap&&(S.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,S.specularColorMapTransform)),g.specularIntensityMap&&(S.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,S.specularIntensityMapTransform))}function _(S,g){g.matcap&&(S.matcap.value=g.matcap)}function E(S,g){const x=e.get(g).light;S.referencePosition.value.setFromMatrixPosition(x.matrixWorld),S.nearDistance.value=x.shadow.camera.near,S.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function _k(n,e,t,i){let r={},s={},o=[];const a=t.isWebGL2?n.getParameter(35375):0;function c(x,w){const T=w.program;i.uniformBlockBinding(x,T)}function f(x,w){let T=r[x.id];T===void 0&&(_(x),T=h(x),r[x.id]=T,x.addEventListener("dispose",S));const C=w.program;i.updateUBOMapping(x,C);const P=e.render.frame;s[x.id]!==P&&(m(x),s[x.id]=P)}function h(x){const w=d();x.__bindingPointIndex=w;const T=n.createBuffer(),C=x.__size,P=x.usage;return n.bindBuffer(35345,T),n.bufferData(35345,C,P),n.bindBuffer(35345,null),n.bindBufferBase(35345,w,T),T}function d(){for(let x=0;x0){P=T%C;const q=C-P;P!==0&&q-L.boundary<0&&(T+=C-P,b.__offset=T)}T+=L.storage}return P=T%C,P>0&&(T+=C-P),x.__size=T,x.__cache={},this}function E(x){const w={boundary:0,storage:0};return typeof x=="number"?(w.boundary=4,w.storage=4):x.isVector2?(w.boundary=8,w.storage=8):x.isVector3||x.isColor?(w.boundary=16,w.storage=12):x.isVector4?(w.boundary=16,w.storage=16):x.isMatrix3?(w.boundary=48,w.storage=48):x.isMatrix4?(w.boundary=64,w.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),w}function S(x){const w=x.target;w.removeEventListener("dispose",S);const T=o.indexOf(w.__bindingPointIndex);o.splice(T,1),n.deleteBuffer(r[w.id]),delete r[w.id],delete s[w.id]}function g(){for(const x in r)n.deleteBuffer(r[x]);o=[],r={},s={}}return{bind:c,update:f,dispose:g}}function xk(){const n=Dc("canvas");return n.style.display="block",n}class o_{constructor(e={}){const{canvas:t=xk(),context:i=null,depth:r=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:f=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1}=e;this.isWebGLRenderer=!0;let m;i!==null?m=i.getContextAttributes().alpha:m=o;let v=null,_=null;const E=[],S=[];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.outputEncoding=Ts,this.useLegacyLights=!0,this.toneMapping=Ar,this.toneMappingExposure=1;const g=this;let x=!1,w=0,T=0,C=null,P=-1,R=null;const I=new Nt,b=new Nt;let L=null,H=t.width,q=t.height,G=1,W=null,ee=null;const oe=new Nt(0,0,H,q),ue=new Nt(0,0,H,q);let D=!1;const V=new Ip;let B=!1,J=!1,Y=null;const K=new st,z=new N,ye={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function pe(){return C===null?G:1}let Q=i;function Qe(U,ne){for(let ce=0;ce0?_=S[S.length-1]:_=null,E.pop(),E.length>0?v=E[E.length-1]:v=null};function Tn(U,ne,ce,$){if(U.visible===!1)return;if(U.layers.test(ne.layers)){if(U.isGroup)ce=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(ne);else if(U.isLight)_.pushLight(U),U.castShadow&&_.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||V.intersectsSprite(U)){$&&z.setFromMatrixPosition(U.matrixWorld).applyMatrix4(K);const nt=Ye.update(U),it=U.material;it.visible&&v.push(U,nt,it,ce,z.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(U.isSkinnedMesh&&U.skeleton.frame!==me.render.frame&&(U.skeleton.update(),U.skeleton.frame=me.render.frame),!U.frustumCulled||V.intersectsObject(U))){$&&z.setFromMatrixPosition(U.matrixWorld).applyMatrix4(K);const nt=Ye.update(U),it=U.material;if(Array.isArray(it)){const ut=nt.groups;for(let pt=0,mt=ut.length;pt0&&Yt(de,Ze,ne,ce),$&&De.viewport(I.copy($)),de.length>0&&ei(de,ne,ce),Ze.length>0&&ei(Ze,ne,ce),nt.length>0&&ei(nt,ne,ce),De.buffers.depth.setTest(!0),De.buffers.depth.setMask(!0),De.buffers.color.setMask(!0),De.setPolygonOffset(!1)}function Yt(U,ne,ce,$){if(Y===null){const it=Me.isWebGL2;Y=new ar(1024,1024,{generateMipmaps:!0,type:je.has("EXT_color_buffer_half_float")?ca:Es,minFilter:po,samples:it&&a===!0?4:0})}const de=g.getRenderTarget();g.setRenderTarget(Y),g.clear();const Ze=g.toneMapping;g.toneMapping=Ar,ei(U,ce,$),ve.updateMultisampleRenderTarget(Y),ve.updateRenderTargetMipmap(Y);let nt=!1;for(let it=0,ut=ne.length;it0&&ve.useMultisampledRTT(U)===!1?de=se.get(U).__webglMultisampledFramebuffer:de=mt,I.copy(U.viewport),b.copy(U.scissor),L=U.scissorTest}else I.copy(oe).multiplyScalar(G).floor(),b.copy(ue).multiplyScalar(G).floor(),L=D;if(De.bindFramebuffer(36160,de)&&Me.drawBuffers&&$&&De.drawBuffers(U,de),De.viewport(I),De.scissor(b),De.setScissorTest(L),Ze){const ut=se.get(U.texture);Q.framebufferTexture2D(36160,36064,34069+ne,ut.__webglTexture,ce)}else if(nt){const ut=se.get(U.texture),pt=ne||0;Q.framebufferTextureLayer(36160,36064,ut.__webglTexture,ce||0,pt)}P=-1},this.readRenderTargetPixels=function(U,ne,ce,$,de,Ze,nt){if(!(U&&U.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let it=se.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&nt!==void 0&&(it=it[nt]),it){De.bindFramebuffer(36160,it);try{const ut=U.texture,pt=ut.format,mt=ut.type;if(pt!==_i&&he.convert(pt)!==Q.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const yt=mt===ca&&(je.has("EXT_color_buffer_half_float")||Me.isWebGL2&&je.has("EXT_color_buffer_float"));if(mt!==Es&&he.convert(mt)!==Q.getParameter(35738)&&!(mt===Hr&&(Me.isWebGL2||je.has("OES_texture_float")||je.has("WEBGL_color_buffer_float")))&&!yt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ne>=0&&ne<=U.width-$&&ce>=0&&ce<=U.height-de&&Q.readPixels(ne,ce,$,de,he.convert(pt),he.convert(mt),Ze)}finally{const ut=C!==null?se.get(C).__webglFramebuffer:null;De.bindFramebuffer(36160,ut)}}},this.copyFramebufferToTexture=function(U,ne,ce=0){const $=Math.pow(2,-ce),de=Math.floor(ne.image.width*$),Ze=Math.floor(ne.image.height*$);ve.setTexture2D(ne,0),Q.copyTexSubImage2D(3553,ce,0,0,U.x,U.y,de,Ze),De.unbindTexture()},this.copyTextureToTexture=function(U,ne,ce,$=0){const de=ne.image.width,Ze=ne.image.height,nt=he.convert(ce.format),it=he.convert(ce.type);ve.setTexture2D(ce,0),Q.pixelStorei(37440,ce.flipY),Q.pixelStorei(37441,ce.premultiplyAlpha),Q.pixelStorei(3317,ce.unpackAlignment),ne.isDataTexture?Q.texSubImage2D(3553,$,U.x,U.y,de,Ze,nt,it,ne.image.data):ne.isCompressedTexture?Q.compressedTexSubImage2D(3553,$,U.x,U.y,ne.mipmaps[0].width,ne.mipmaps[0].height,nt,ne.mipmaps[0].data):Q.texSubImage2D(3553,$,U.x,U.y,nt,it,ne.image),$===0&&ce.generateMipmaps&&Q.generateMipmap(3553),De.unbindTexture()},this.copyTextureToTexture3D=function(U,ne,ce,$,de=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ze=U.max.x-U.min.x+1,nt=U.max.y-U.min.y+1,it=U.max.z-U.min.z+1,ut=he.convert($.format),pt=he.convert($.type);let mt;if($.isData3DTexture)ve.setTexture3D($,0),mt=32879;else if($.isDataArrayTexture)ve.setTexture2DArray($,0),mt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Q.pixelStorei(37440,$.flipY),Q.pixelStorei(37441,$.premultiplyAlpha),Q.pixelStorei(3317,$.unpackAlignment);const yt=Q.getParameter(3314),Rt=Q.getParameter(32878),Nn=Q.getParameter(3316),Ei=Q.getParameter(3315),ur=Q.getParameter(32877),Ht=ce.isCompressedTexture?ce.mipmaps[0]:ce.image;Q.pixelStorei(3314,Ht.width),Q.pixelStorei(32878,Ht.height),Q.pixelStorei(3316,U.min.x),Q.pixelStorei(3315,U.min.y),Q.pixelStorei(32877,U.min.z),ce.isDataTexture||ce.isData3DTexture?Q.texSubImage3D(mt,de,ne.x,ne.y,ne.z,Ze,nt,it,ut,pt,Ht.data):ce.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Q.compressedTexSubImage3D(mt,de,ne.x,ne.y,ne.z,Ze,nt,it,ut,Ht.data)):Q.texSubImage3D(mt,de,ne.x,ne.y,ne.z,Ze,nt,it,ut,pt,Ht),Q.pixelStorei(3314,yt),Q.pixelStorei(32878,Rt),Q.pixelStorei(3316,Nn),Q.pixelStorei(3315,Ei),Q.pixelStorei(32877,ur),de===0&&$.generateMipmaps&&Q.generateMipmap(mt),De.unbindTexture()},this.initTexture=function(U){U.isCubeTexture?ve.setTextureCube(U,0):U.isData3DTexture?ve.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?ve.setTexture2DArray(U,0):ve.setTexture2D(U,0),De.unbindTexture()},this.resetState=function(){w=0,T=0,C=null,De.reset(),Ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}}class G2 extends o_{}G2.prototype.isWebGL1Renderer=!0;class Np{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Re(e),this.density=t}clone(){return new Np(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class kp{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Re(e),this.near=t,this.far=i}clone(){return new kp(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class up extends St{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}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class zp{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ic,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ui()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;re.far||t.push({distance:c,point:Iu.clone(),uv:yi.getInterpolation(Iu,Yh,Nu,qh,hw,Yg,dw,new ge),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 Zh(n,e,t,i,r,s){tl.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Du.x=s*tl.x-r*tl.y,Du.y=r*tl.x+s*tl.y):Du.copy(tl),n.copy(e),n.x+=Du.x,n.y+=Du.y,n.applyMatrix4(W2)}const Qh=new N,pw=new N;class j2 extends St{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){Qh.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(Qh);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Qh.setFromMatrixPosition(e.matrixWorld),pw.setFromMatrixPosition(this.matrixWorld);const i=Qh.distanceTo(pw)/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;rc)continue;m.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(m);Ie.far||t.push({distance:I,point:d.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const g=Math.max(0,o.start),x=Math.min(S.count,o.start+o.count);for(let w=g,T=x-1;wc)continue;m.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(m);Pe.far||t.push({distance:P,point:d.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:f,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}class Ek extends un{constructor(e,t,i,r,s,o,a,c,f){super(e,t,i,r,s,o,a,c,f),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:en,this.magFilter=s!==void 0?s:en,this.generateMipmaps=!1;const h=this;function d(){h.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Tk extends un{constructor(e,t,i){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=i,this.magFilter=hn,this.minFilter=hn,this.generateMipmaps=!1,this.needsUpdate=!0}}class c_ extends un{constructor(e,t,i,r,s,o,a,c,f,h,d,m){super(null,o,a,c,f,h,r,s,d,m),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Ak extends c_{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Jn}}class Ck extends un{constructor(e,t,i,r,s,o,a,c,f){super(e,t,i,r,s,o,a,c,f),this.isCanvasTexture=!0,this.needsUpdate=!0}}class br{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let o;t?o=t:o=e*i[s-1];let a=0,c=s-1,f;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),f=i[r]-o,f<0)a=r+1;else if(f>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);const h=i[r],m=i[r+1]-h,v=(o-h)/m;return(r+v)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new ge:new N);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new N,r=[],s=[],o=[],a=new N,c=new st;for(let v=0;v<=e;v++){const _=v/e;r[v]=this.getTangentAt(_,new N)}s[0]=new N,o[0]=new N;let f=Number.MAX_VALUE;const h=Math.abs(r[0].x),d=Math.abs(r[0].y),m=Math.abs(r[0].z);h<=f&&(f=h,i.set(1,0,0)),d<=f&&(f=d,i.set(0,1,0)),m<=f&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let v=1;v<=e;v++){if(s[v]=s[v-1].clone(),o[v]=o[v-1].clone(),a.crossVectors(r[v-1],r[v]),a.length()>Number.EPSILON){a.normalize();const _=Math.acos(ln(r[v-1].dot(r[v]),-1,1));s[v].applyMatrix4(c.makeRotationAxis(a,_))}o[v].crossVectors(r[v],s[v])}if(t===!0){let v=Math.acos(ln(s[0].dot(s[e]),-1,1));v/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(v=-v);for(let _=1;_<=e;_++)s[_].applyMatrix4(c.makeRotationAxis(r[_],v*_)),o[_].crossVectors(r[_],s[_])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Op extends br{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t){const i=t||new ge,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let f,h;this.closed||a>0?f=r[(a-1)%s]:(td.subVectors(r[0],r[1]).add(r[0]),f=td);const d=r[a%s],m=r[(a+1)%s];if(this.closed||a+2r.length-2?r.length-1:o+1],d=r[o>r.length-3?r.length-1:o+2];return i.set(Pw(a,c.x,f.x,h.x,d.x),Pw(a,c.y,f.y,h.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const o=r[s]-i,a=this.curves[s],c=a.getLength(),f=c===0?0:1-o/c;return a.getPointAt(f,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=f.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(f);const h=f.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Zl extends lt{constructor(e=[new ge(0,-.5),new ge(.5,0),new ge(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=ln(r,0,Math.PI*2);const s=[],o=[],a=[],c=[],f=[],h=1/t,d=new N,m=new ge,v=new N,_=new N,E=new N;let S=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:S=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,v.x=g*1,v.y=-S,v.z=g*0,E.copy(v),v.normalize(),c.push(v.x,v.y,v.z);break;case e.length-1:c.push(E.x,E.y,E.z);break;default:S=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,v.x=g*1,v.y=-S,v.z=g*0,_.copy(v),v.x+=E.x,v.y+=E.y,v.z+=E.z,v.normalize(),c.push(v.x,v.y,v.z),E.copy(_)}for(let x=0;x<=t;x++){const w=i+x*h*r,T=Math.sin(w),C=Math.cos(w);for(let P=0;P<=e.length-1;P++){d.x=e[P].x*T,d.y=e[P].y,d.z=e[P].x*C,o.push(d.x,d.y,d.z),m.x=x/t,m.y=P/(e.length-1),a.push(m.x,m.y);const R=c[3*P+0]*T,I=c[3*P+1],b=c[3*P+0]*C;f.push(R,I,b)}}for(let x=0;x0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new Be(d,3)),this.setAttribute("normal",new Be(m,3)),this.setAttribute("uv",new Be(v,2));function x(){const T=new N,C=new N;let P=0;const R=(t-e)/i;for(let I=0;I<=s;I++){const b=[],L=I/s,H=L*(t-e)+e;for(let q=0;q<=r;q++){const G=q/r,W=G*c+a,ee=Math.sin(W),oe=Math.cos(W);C.x=H*ee,C.y=-L*i+S,C.z=H*oe,d.push(C.x,C.y,C.z),T.set(ee,R,oe).normalize(),m.push(T.x,T.y,T.z),v.push(G,1-L),b.push(_++)}E.push(b)}for(let I=0;I.9&&R<.1&&(w<.2&&(o[x+0]+=1),T<.2&&(o[x+2]+=1),C<.2&&(o[x+4]+=1))}}function m(x){s.push(x.x,x.y,x.z)}function v(x,w){const T=x*3;w.x=e[T+0],w.y=e[T+1],w.z=e[T+2]}function _(){const x=new N,w=new N,T=new N,C=new N,P=new ge,R=new ge,I=new ge;for(let b=0,L=0;b80*t){a=f=n[0],c=h=n[1];for(let _=t;_f&&(f=d),m>h&&(h=m);v=Math.max(f-a,h-c),v=v!==0?32767/v:0}return kc(s,o,t,a,c,v,0),o}};function i3(n,e,t,i,r){let s,o;if(r===Jk(n,e,t,i)>0)for(s=e;s=e;s-=i)o=Lw(s,n[s],n[s+1],o);return o&&Bp(o,o.next)&&(Uc(o),o=o.next),o}function da(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Bp(t,t.next)||tn(t.prev,t,t.next)===0)){if(Uc(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function kc(n,e,t,i,r,s,o){if(!n)return;!o&&s&&Xk(n,i,r,s);let a=n,c,f;for(;n.prev!==n.next;){if(c=n.prev,f=n.next,s?Uk(n,i,r,s):zk(n)){e.push(c.i/t|0),e.push(n.i/t|0),e.push(f.i/t|0),Uc(n),n=f.next,a=f.next;continue}if(n=f,n===a){o?o===1?(n=Ok(da(n),e,t),kc(n,e,t,i,r,s,2)):o===2&&Fk(n,e,t,i,r,s):kc(da(n),e,t,i,r,s,1);break}}}function zk(n){const e=n.prev,t=n,i=n.next;if(tn(e,t,i)>=0)return!1;const r=e.x,s=t.x,o=i.x,a=e.y,c=t.y,f=i.y,h=rs?r>o?r:o:s>o?s:o,v=a>c?a>f?a:f:c>f?c:f;let _=i.next;for(;_!==e;){if(_.x>=h&&_.x<=m&&_.y>=d&&_.y<=v&&wl(r,a,s,c,o,f,_.x,_.y)&&tn(_.prev,_,_.next)>=0)return!1;_=_.next}return!0}function Uk(n,e,t,i){const r=n.prev,s=n,o=n.next;if(tn(r,s,o)>=0)return!1;const a=r.x,c=s.x,f=o.x,h=r.y,d=s.y,m=o.y,v=ac?a>f?a:f:c>f?c:f,S=h>d?h>m?h:m:d>m?d:m,g=Bv(v,_,e,t,i),x=Bv(E,S,e,t,i);let w=n.prevZ,T=n.nextZ;for(;w&&w.z>=g&&T&&T.z<=x;){if(w.x>=v&&w.x<=E&&w.y>=_&&w.y<=S&&w!==r&&w!==o&&wl(a,h,c,d,f,m,w.x,w.y)&&tn(w.prev,w,w.next)>=0||(w=w.prevZ,T.x>=v&&T.x<=E&&T.y>=_&&T.y<=S&&T!==r&&T!==o&&wl(a,h,c,d,f,m,T.x,T.y)&&tn(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;w&&w.z>=g;){if(w.x>=v&&w.x<=E&&w.y>=_&&w.y<=S&&w!==r&&w!==o&&wl(a,h,c,d,f,m,w.x,w.y)&&tn(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;T&&T.z<=x;){if(T.x>=v&&T.x<=E&&T.y>=_&&T.y<=S&&T!==r&&T!==o&&wl(a,h,c,d,f,m,T.x,T.y)&&tn(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function Ok(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!Bp(r,s)&&r3(r,i,i.next,s)&&zc(r,s)&&zc(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),Uc(i),Uc(i.next),i=n=s),i=i.next}while(i!==n);return da(i)}function Fk(n,e,t,i,r,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&qk(o,a)){let c=s3(o,a);o=da(o,o.next),c=da(c,c.next),kc(o,e,t,i,r,s,0),kc(c,e,t,i,r,s,0);return}a=a.next}o=o.next}while(o!==n)}function Bk(n,e,t,i){const r=[];let s,o,a,c,f;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){const m=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(m<=s&&m>i&&(i=m,r=t.x=t.x&&t.x>=c&&s!==t.x&&wl(or.x||t.x===r.x&&Wk(r,t)))&&(r=t,h=d)),t=t.next;while(t!==a);return r}function Wk(n,e){return tn(n.prev,n,e.prev)<0&&tn(e.next,n,n.next)<0}function Xk(n,e,t,i){let r=n;do r.z===0&&(r.z=Bv(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,jk(r)}function jk(n){let e,t,i,r,s,o,a,c,f=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,a--):(r=i,i=i.nextZ,c--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,f*=2}while(o>1);return n}function Bv(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 Yk(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 qk(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Zk(n,e)&&(zc(n,e)&&zc(e,n)&&Qk(n,e)&&(tn(n.prev,n,e.prev)||tn(n,e.prev,e))||Bp(n,e)&&tn(n.prev,n,n.next)>0&&tn(e.prev,e,e.next)>0)}function tn(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Bp(n,e){return n.x===e.x&&n.y===e.y}function r3(n,e,t,i){const r=od(tn(n,e,t)),s=od(tn(n,e,i)),o=od(tn(t,i,n)),a=od(tn(t,i,e));return!!(r!==s&&o!==a||r===0&&sd(n,t,e)||s===0&&sd(n,i,e)||o===0&&sd(t,n,i)||a===0&&sd(t,e,i))}function sd(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 od(n){return n>0?1:n<0?-1:0}function Zk(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&&r3(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function zc(n,e){return tn(n.prev,n,n.next)<0?tn(n,e,n.next)>=0&&tn(n,n.prev,e)>=0:tn(n,e,n.prev)<0||tn(n,n.next,e)<0}function Qk(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 s3(n,e){const t=new Vv(n.i,n.x,n.y),i=new Vv(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 Lw(n,e,t,i){const r=new Vv(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 Uc(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 Vv(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 Jk(n,e,t,i){let r=0;for(let s=e,o=t-i;s2&&n[e-1].equals(n[0])&&n.pop()}function Iw(n,e){for(let t=0;tNumber.EPSILON){const ie=Math.sqrt(F),_e=Math.sqrt(rt*rt+Et*Et),Se=se.x-Ye/ie,be=se.y+$e/ie,tt=ve.x-Et/_e,ke=ve.y+rt/_e,he=((tt-Se)*Et-(ke-be)*rt)/($e*Et-Ye*rt);Ue=Se+$e*he-me.x,Ce=be+Ye*he-me.y;const Ve=Ue*Ue+Ce*Ce;if(Ve<=2)return new ge(Ue,Ce);Ke=Math.sqrt(Ve/2)}else{let ie=!1;$e>Number.EPSILON?rt>Number.EPSILON&&(ie=!0):$e<-Number.EPSILON?rt<-Number.EPSILON&&(ie=!0):Math.sign(Ye)===Math.sign(Et)&&(ie=!0),ie?(Ue=-Ye,Ce=$e,Ke=Math.sqrt(F)):(Ue=$e,Ce=Ye,Ke=Math.sqrt(F/2))}return new ge(Ue/Ke,Ce/Ke)}const V=[];for(let me=0,se=W.length,ve=se-1,Ue=me+1;me=0;me--){const se=me/S,ve=v*Math.cos(se*Math.PI/2),Ue=_*Math.sin(se*Math.PI/2)+E;for(let Ce=0,Ke=W.length;Ce=0;){const Ue=ve;let Ce=ve-1;Ce<0&&(Ce=me.length-1);for(let Ke=0,$e=h+S*2;Ke<$e;Ke++){const Ye=oe*Ke,rt=oe*(Ke+1),Et=se+Ue+Ye,F=se+Ce+Ye,k=se+Ce+rt,ie=se+Ue+rt;je(Et,F,k,ie)}}}function Q(me,se,ve){c.push(me),c.push(se),c.push(ve)}function Qe(me,se,ve){Me(me),Me(se),Me(ve);const Ue=r.length/3,Ce=x.generateTopUV(i,r,Ue-3,Ue-2,Ue-1);De(Ce[0]),De(Ce[1]),De(Ce[2])}function je(me,se,ve,Ue){Me(me),Me(se),Me(Ue),Me(se),Me(ve),Me(Ue);const Ce=r.length/3,Ke=x.generateSideWallUV(i,r,Ce-6,Ce-3,Ce-2,Ce-1);De(Ke[0]),De(Ke[1]),De(Ke[3]),De(Ke[1]),De(Ke[2]),De(Ke[3])}function Me(me){r.push(c[me*3+0]),r.push(c[me*3+1]),r.push(c[me*3+2])}function De(me){s.push(me.x),s.push(me.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return $k(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,o=e.shapes.length;s0)&&v.push(w,T,P),(g!==i-1||c0!=e>0&&this.version++,this._sheen=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 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.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 c3 extends Bn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Re(16777215),this.specular=new Re(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Re(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yo,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Zc,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 f3 extends Bn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Re(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Re(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yo,this.normalScale=new ge(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 h3 extends Bn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yo,this.normalScale=new ge(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 d3 extends Bn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Re(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Re(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yo,this.normalScale=new ge(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Zc,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 p3 extends Bn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Re(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yo,this.normalScale=new ge(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 m3 extends $n{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 Ki(n,e,t){return y_(n)?new n.constructor(n.subarray(e,t!==void 0?t:n.length)):n.slice(e,t)}function Qo(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 y_(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function g3(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 Hv(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=n[a+c]}return r}function __(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 tz(n,e,t,i,r=30){const s=n.clone();s.name=e;const o=[];for(let c=0;c=i)){d.push(f.times[v]);for(let E=0;Es.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c=a.times[_]){const g=_*d+h,x=g+d-h;E=Ki(a.values,g,x)}else{const g=a.createInterpolant(),x=h,w=d-h;g.evaluate(s),E=Ki(g.resultBuffer,x,w)}c==="quaternion"&&new It().fromArray(E).normalize().conjugate().toArray(E);const S=f.times.length;for(let g=0;g=s)){const a=t[1];e=s)break t}o=i,i=0;break n}break e}for(;i>>1;et;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=Ki(i,s,o),this.values=Ki(this.values,s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&y_(r))for(let a=0,c=r.length;a!==c;++a){const f=r[a];if(isNaN(f)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,f),e=!1;break}}return e}optimize(){const e=Ki(this.times),t=Ki(this.values),i=this.getValueSize(),r=this.getInterpolation()===Dd,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*i,c=o*i,f=0;f!==i;++f)t[c+f]=t[a+f];++o}return o!==e.length?(this.times=Ki(e,0,o),this.values=Ki(t,0,o*i)):(this.times=e,this.values=t),this}clone(){const e=Ki(this.times,0),t=Ki(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Pr.prototype.TimeBufferType=Float32Array;Pr.prototype.ValueBufferType=Float32Array;Pr.prototype.DefaultInterpolation=Lc;class _a extends Pr{}_a.prototype.ValueTypeName="bool";_a.prototype.ValueBufferType=Array;_a.prototype.DefaultInterpolation=Pc;_a.prototype.InterpolantFactoryMethodLinear=void 0;_a.prototype.InterpolantFactoryMethodSmooth=void 0;class S_ extends Pr{}S_.prototype.ValueTypeName="color";class Oc extends Pr{}Oc.prototype.ValueTypeName="number";class _3 extends hf{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(r-t);let f=e*a;for(let h=f+a;f!==h;f+=4)It.slerpFlat(s,0,o,f-a,o,f,c);return s}}class Ql extends Pr{InterpolantFactoryMethodLinear(e){return new _3(this.times,this.values,this.getValueSize(),e)}}Ql.prototype.ValueTypeName="quaternion";Ql.prototype.DefaultInterpolation=Lc;Ql.prototype.InterpolantFactoryMethodSmooth=void 0;class xa extends Pr{}xa.prototype.ValueTypeName="string";xa.prototype.ValueBufferType=Array;xa.prototype.DefaultInterpolation=Pc;xa.prototype.InterpolantFactoryMethodLinear=void 0;xa.prototype.InterpolantFactoryMethodSmooth=void 0;class Fc extends Pr{}Fc.prototype.ValueTypeName="vector";class Bc{constructor(e,t=-1,i,r=Lp){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Ui(),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(sz(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(Pr.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let a=0;a1){const d=h[1];let m=r[d];m||(r[d]=m=[]),m.push(f)}}const o=[];for(const a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(d,m,v,_,E){if(v.length!==0){const S=[],g=[];__(v,S,g,_),S.length!==0&&E.push(new d(m,S,g))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const f=e.hierarchy||[];for(let d=0;d{t&&t(s),this.manager.itemEnd(e)},0),s;if(cs[e]!==void 0){cs[e].push({onLoad:t,onProgress:i,onError:r});return}cs[e]=[],cs[e].push({onLoad:t,onProgress:i,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(f=>{if(f.status===200||f.status===0){if(f.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||f.body===void 0||f.body.getReader===void 0)return f;const h=cs[e],d=f.body.getReader(),m=f.headers.get("Content-Length")||f.headers.get("X-File-Size"),v=m?parseInt(m):0,_=v!==0;let E=0;const S=new ReadableStream({start(g){x();function x(){d.read().then(({done:w,value:T})=>{if(w)g.close();else{E+=T.byteLength;const C=new ProgressEvent("progress",{lengthComputable:_,loaded:E,total:v});for(let P=0,R=h.length;P{switch(c){case"arraybuffer":return f.arrayBuffer();case"blob":return f.blob();case"document":return f.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return f.json();default:if(a===void 0)return f.text();{const d=/charset="?([^;"\s]*)"?/i.exec(a),m=d&&d[1]?d[1].toLowerCase():void 0,v=new TextDecoder(m);return f.arrayBuffer().then(_=>v.decode(_))}}}).then(f=>{pa.add(e,f);const h=cs[e];delete cs[e];for(let d=0,m=h.length;d{const h=cs[e];if(h===void 0)throw this.manager.itemError(e),f;delete cs[e];for(let d=0,m=h.length;d{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class az extends Vi{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new As(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new Re().setHex(o.value);break;case"v2":r.uniforms[s].value=new ge().fromArray(o.value);break;case"v3":r.uniforms[s].value=new N().fromArray(o.value);break;case"v4":r.uniforms[s].value=new Nt().fromArray(o.value);break;case"m3":r.uniforms[s].value=new xt().fromArray(o.value);break;case"m4":r.uniforms[s].value=new st().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.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 ge().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 ge().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.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:a3,SpriteMaterial:a_,RawShaderMaterial:l3,ShaderMaterial:jr,PointsMaterial:u_,MeshPhysicalMaterial:u3,MeshStandardMaterial:v_,MeshPhongMaterial:c3,MeshToonMaterial:f3,MeshNormalMaterial:h3,MeshLambertMaterial:d3,MeshDepthMaterial:i_,MeshDistanceMaterial:r_,MeshBasicMaterial:Zr,MeshMatcapMaterial:p3,LineDashedMaterial:m3,LineBasicMaterial:$n,Material:Bn};return new t[e]}}class Gv{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i0){const c=new w_(t);s=new Vc(c),s.setCrossOrigin(this.crossOrigin);for(let f=0,h=e.length;f0){r=new Vc(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o"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=pa.get(e);if(o!==void 0)return s.manager.itemStart(e),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,fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){pa.add(e,c),t&&t(c),s.manager.itemEnd(e)}).catch(function(c){r&&r(c),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}let ad;class E_{static getContext(){return ad===void 0&&(ad=new(window.AudioContext||window.webkitAudioContext)),ad}static setContext(e){ad=e}}class yz extends Vi{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new As(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{const c=a.slice(0);E_.getContext().decodeAudioData(c,function(h){t(h)})}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}}class _z extends Vp{constructor(e,t,i=1){super(void 0,i),this.isHemisphereLightProbe=!0;const r=new Re().set(e),s=new Re().set(t),o=new N(r.r,r.g,r.b),a=new N(s.r,s.g,s.b),c=Math.sqrt(Math.PI),f=c*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(c),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(f)}}class xz extends Vp{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const i=new Re().set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const Bw=new st,Vw=new st,Do=new st;class Sz{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new In,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new In,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,Do.copy(e.projectionMatrix);const r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(na*t.fov*.5)/t.zoom;let a,c;Vw.elements[12]=-r,Bw.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,Do.elements[0]=2*t.near/(c-a),Do.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Do),a=-o*t.aspect-s,c=o*t.aspect-s,Do.elements[0]=2*t.near/(c-a),Do.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Do)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Vw),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Bw)}}class T_{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Hw(),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=Hw();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Hw(){return(typeof performance>"u"?Date:performance).now()}const No=new N,Gw=new It,wz=new N,ko=new N;class Mz extends St{constructor(){super(),this.type="AudioListener",this.context=E_.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new T_}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(No,Gw,wz),ko.set(0,0,-1).applyQuaternion(Gw),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(No.x,r),t.positionY.linearRampToValueAtTime(No.y,r),t.positionZ.linearRampToValueAtTime(No.z,r),t.forwardX.linearRampToValueAtTime(ko.x,r),t.forwardY.linearRampToValueAtTime(ko.y,r),t.forwardZ.linearRampToValueAtTime(ko.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(No.x,No.y,No.z),t.setOrientation(ko.x,ko.y,ko.z,i.x,i.y,i.z)}}class L3 extends St{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let c=t,f=t+t;c!==f;++c)if(i[c]!==i[c+t]){a.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){It.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const o=this._workIndex*s;It.multiplyQuaternionsFlat(e,o,e,t,e,i),It.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){const o=1-r;for(let a=0;a!==s;++a){const c=t+a;e[c]=e[c]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[i+o]*r}}}const A_="\\[\\]\\.:\\/",Cz=new RegExp("["+A_+"]","g"),C_="[^"+A_+"]",bz="[^"+A_.replace("\\.","")+"]",Pz=/((?:WC+[\/:])*)/.source.replace("WC",C_),Lz=/(WCOD+)?/.source.replace("WCOD",bz),Rz=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",C_),Iz=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",C_),Dz=new RegExp("^"+Pz+Lz+Rz+Iz+"$"),Nz=["material","materials","bones","map"];class kz{constructor(e,t,i){const r=i||Tt.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 Tt{constructor(e,t,i){this.path=t,this.parsedPath=i||Tt.parseTrackName(t),this.node=Tt.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 Tt.Composite(e,t,i):new Tt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Cz,"")}static parseTrackName(e){const t=Dz.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);Nz.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let o=0;o=s){const d=s++,m=e[d];t[m.uuid]=h,e[h]=m,t[f]=d,e[d]=c;for(let v=0,_=r;v!==_;++v){const E=i[v],S=E[d],g=E[h];E[h]=S,E[d]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){const f=arguments[a],h=f.uuid,d=t[h];if(d!==void 0)if(delete t[h],d0&&(t[v.uuid]=d),e[d]=v,e.pop();for(let _=0,E=r;_!==E;++_){const S=i[_];S[d]=S[m],S.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const o=this._paths,a=this._parsedPaths,c=this._objects,f=c.length,h=this.nCachedObjects_,d=new Array(f);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(d);for(let m=h,v=c.length;m!==v;++m){const _=c[m];d[m]=new Tt(_,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],f=e[a];t[f]=i,o[i]=c,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}}class I3{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Yo,endingEnd:Yo};for(let f=0;f!==o;++f){const h=s[f].createInterpolant(null);a[f]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=w2,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const c=a.parameterPositions,f=a.sampleValues;return c[0]=s,c[1]=s+i,f[0]=e/o,f[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const c=(e-s)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const c=this._interpolants,f=this._propertyBindings;switch(this.blendMode){case Zy:for(let h=0,d=c.length;h!==d;++h)c[h].evaluate(o),f[h].accumulateAdditive(a);break;case Lp:default:for(let h=0,d=c.length;h!==d;++h)c[h].evaluate(o),f[h].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const o=i===M2;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===S2){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){const a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const f=e<0;this._setEndings(f,!f,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=qo,r.endingEnd=qo):(e?r.endingStart=this.zeroSlopeAtStart?qo:Yo:r.endingStart=Rc,t?r.endingEnd=this.zeroSlopeAtEnd?qo:Yo:r.endingEnd=Rc)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=i,this}}const Uz=new Float32Array(1);class Oz extends bs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=i.uuid,f=this._bindingsByRootAndName;let h=f[c];h===void 0&&(h={},f[c]=h);for(let d=0;d!==s;++d){const m=r[d],v=m.name;let _=h[v];if(_!==void 0)++_.referenceCount,o[d]=_;else{if(_=o[d],_!==void 0){_._cacheIndex===null&&(++_.referenceCount,this._addInactiveBinding(_,c,v));continue}const E=t&&t._propertyBindings[d].binding.parsedPath;_=new R3(Tt.create(i,v,E),m.ValueTypeName,m.getValueSize()),++_.referenceCount,this._addInactiveBinding(_,c,v),o[d]=_}a[d].resultBuffer=_.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let f=0;f!==i;++f)t[f]._update(r,e,s,o);const a=this._bindings,c=this._nActiveBindings;for(let f=0;f!==c;++f)a[f].apply(o);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jw).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 Yw=new N,ld=new N;class jz{constructor(e=new N,t=new N){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){Yw.subVectors(e,this.start),ld.subVectors(this.end,this.start);const i=ld.dot(ld);let s=ld.dot(Yw)/i;return t&&(s=ln(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 qw=new N;class Yz extends St{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new lt,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o1)for(let d=0;d.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{$w.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle($w,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 oU extends Qr{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 lt;r.setAttribute("position",new Be(t,3)),r.setAttribute("color",new Be(i,3));const s=new $n({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new Re,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 aU{constructor(){this.type="ShapePath",this.color=new Re,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Nc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let w=0,T=g.length;wNumber.EPSILON){if(L<0&&(R=x[P],b=-b,I=x[C],L=-L),g.yI.y)continue;if(g.y===R.y){if(g.x===R.x)return!0}else{const H=L*(g.x-R.x)-b*(g.y-R.y);if(H===0)return!0;if(H<0)continue;T=!T}}else{if(g.y!==R.y)continue;if(I.x<=g.x&&g.x<=R.x||R.x<=g.x&&g.x<=I.x)return!0}}return T}const r=Xr.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c;const f=[];if(s.length===1)return a=s[0],c=new ra,c.curves=a.curves,f.push(c),f;let h=!r(s[0].getPoints());h=e?!h:h;const d=[],m=[];let v=[],_=0,E;m[_]=void 0,v[_]=[];for(let g=0,x=s.length;g1){let g=!1,x=0;for(let w=0,T=m.length;w0&&g===!1&&(v=d)}let S;for(let g=0,x=m.length;g{const d=typeof f=="function"?f(e):f;if(d!==e){const m=e;e=h?d:Object.assign({},e,d),t.forEach(v=>v(e,m))}},r=()=>e,s=(f,h=r,d=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let m=h(e);function v(){const _=h(e);if(!d(m,_)){const E=m;f(m=_,E)}}return t.add(v),()=>t.delete(v)},c={setState:i,getState:r,subscribe:(f,h,d)=>h||d?s(f,h,d):(t.add(f),()=>t.delete(f)),destroy:()=>t.clear()};return e=n(i,r,c),c}const PU=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),eM=PU?Te.exports.useEffect:Te.exports.useLayoutEffect;function LU(n){const e=typeof n=="function"?bU(n):n,t=(i=e.getState,r=Object.is)=>{const[,s]=Te.exports.useReducer(S=>S+1,0),o=e.getState(),a=Te.exports.useRef(o),c=Te.exports.useRef(i),f=Te.exports.useRef(r),h=Te.exports.useRef(!1),d=Te.exports.useRef();d.current===void 0&&(d.current=i(o));let m,v=!1;(a.current!==o||c.current!==i||f.current!==r||h.current)&&(m=i(o),v=!r(d.current,m)),eM(()=>{v&&(d.current=m),a.current=o,c.current=i,f.current=r,h.current=!1});const _=Te.exports.useRef(o);eM(()=>{const S=()=>{try{const x=e.getState(),w=c.current(x);f.current(d.current,w)||(a.current=x,d.current=w,s())}catch{h.current=!0,s()}},g=e.subscribe(S);return e.getState()!==_.current&&S(),g},[]);const E=v?m:d.current;return Te.exports.useDebugValue(E),E};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const i=[t,e];return{next(){const r=i.length<=0;return{value:i.shift(),done:r}}}},t}var N3={exports:{}},i0={exports:{}},r0={};/** * @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. */var tM;function RU(){return tM||(tM=1,function(n){function e(D,V){var B=D.length;D.push(V);e:for(;0>>1,Y=D[J];if(0>>1;Jr(ye,B))per(Q,ye)?(D[J]=Q,D[pe]=B,J=pe):(D[J]=ye,D[z]=B,J=z);else if(per(Q,B))D[J]=Q,D[pe]=B,J=pe;else break e}}return V}function r(D,V){var B=D.sortIndex-V.sortIndex;return B!==0?B:D.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var c=[],f=[],h=1,d=null,m=3,v=!1,_=!1,E=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(D){for(var V=t(f);V!==null;){if(V.callback===null)i(f);else if(V.startTime<=D)i(f),V.sortIndex=V.expirationTime,e(c,V);else break;V=t(f)}}function T(D){if(E=!1,w(D),!_)if(t(c)!==null)_=!0,oe(C);else{var V=t(f);V!==null&&ue(T,V.startTime-D)}}function C(D,V){_=!1,E&&(E=!1,g(I),I=-1),v=!0;var B=m;try{for(w(V),d=t(c);d!==null&&(!(d.expirationTime>V)||D&&!H());){var J=d.callback;if(typeof J=="function"){d.callback=null,m=d.priorityLevel;var Y=J(d.expirationTime<=V);V=n.unstable_now(),typeof Y=="function"?d.callback=Y:d===t(c)&&i(c),w(V)}else i(c);d=t(c)}if(d!==null)var K=!0;else{var z=t(f);z!==null&&ue(T,z.startTime-V),K=!1}return K}finally{d=null,m=B,v=!1}}var P=!1,R=null,I=-1,b=5,L=-1;function H(){return!(n.unstable_now()-LD||125J?(D.sortIndex=B,e(f,D),t(c)===null&&D===t(f)&&(E?(g(I),I=-1):E=!0,ue(T,B-J))):(D.sortIndex=Y,e(c,D),_||v||(_=!0,oe(C))),D},n.unstable_shouldYield=H,n.unstable_wrapCallback=function(D){var V=m;return function(){var B=m;m=V;try{return D.apply(this,arguments)}finally{m=B}}}}(r0)),r0}var nM;function IU(){return nM||(nM=1,function(n){n.exports=RU()}(i0)),i0.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 DU=function(e){var t={},i=Te.exports,r=IU(),s=Object.assign;function o(l){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+l,p=1;pj||M[O]!==A[j]){var ae=` `+M[O].replace(" at new "," at ");return l.displayName&&ae.includes("")&&(ae=ae.replace("",l.displayName)),ae}while(1<=O&&0<=j);break}}}finally{_t=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?Ht(l):""}var pn=Object.prototype.hasOwnProperty,cr=[],Jr=-1;function fi(l){return{current:l}}function Dt(l){0>Jr||(l.current=cr[Jr],cr[Jr]=null,Jr--)}function ct(l,u){Jr++,cr[Jr]=l.current,l.current=u}var Vn={},mn=fi(Vn),Ut=fi(!1),fr=Vn;function Ls(l,u){var p=l.type.contextTypes;if(!p)return Vn;var y=l.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===u)return y.__reactInternalMemoizedMaskedChildContext;var M={},A;for(A in p)M[A]=u[A];return y&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=u,l.__reactInternalMemoizedMaskedChildContext=M),M}function kn(l){return l=l.childContextTypes,l!=null}function gf(){Dt(Ut),Dt(mn)}function V_(l,u,p){if(mn.current!==Vn)throw Error(o(168));ct(mn,u),ct(Ut,p)}function H_(l,u,p){var y=l.stateNode;if(u=u.childContextTypes,typeof y.getChildContext!="function")return p;y=y.getChildContext();for(var M in y)if(!(M in u))throw Error(o(108,I(l)||"Unknown",M));return s({},p,y)}function vf(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Vn,fr=mn.current,ct(mn,l),ct(Ut,Ut.current),!0}function G_(l,u,p){var y=l.stateNode;if(!y)throw Error(o(169));p?(l=H_(l,u,fr),y.__reactInternalMemoizedMergedChildContext=l,Dt(Ut),Dt(mn),ct(mn,l)):Dt(Ut),ct(Ut,p)}var hr=Math.clz32?Math.clz32:mA,dA=Math.log,pA=Math.LN2;function mA(l){return l>>>=0,l===0?32:31-(dA(l)/pA|0)|0}var yf=64,_f=4194304;function tu(l){switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function xf(l,u){var p=l.pendingLanes;if(p===0)return 0;var y=0,M=l.suspendedLanes,A=l.pingedLanes,O=p&268435455;if(O!==0){var j=O&~M;j!==0?y=tu(j):(A&=O,A!==0&&(y=tu(A)))}else O=p&~M,O!==0?y=tu(O):A!==0&&(y=tu(A));if(y===0)return 0;if(u!==0&&u!==y&&(u&M)===0&&(M=y&-y,A=u&-u,M>=A||M===16&&(A&4194240)!==0))return u;if((y&4)!==0&&(y|=p&16),u=l.entangledLanes,u!==0)for(l=l.entanglements,u&=y;0p;p++)u.push(l);return u}function nu(l,u,p){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-hr(u),l[u]=p}function yA(l,u){var p=l.pendingLanes&~u;l.pendingLanes=u,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=u,l.mutableReadLanes&=u,l.entangledLanes&=u,u=l.entanglements;var y=l.eventTimes;for(l=l.expirationTimes;0>=O,M-=O,es=1<<32-hr(u)+M|p<bt?(bn=at,at=null):bn=at.sibling;var Pt=Je(te,at,re[bt],Le);if(Pt===null){at===null&&(at=bn);break}l&&at&&Pt.alternate===null&&u(te,at),Z=A(Pt,Z,bt),ft===null?He=Pt:ft.sibling=Pt,ft=Pt,at=bn}if(bt===re.length)return p(te,at),qt&&wo(te,bt),He;if(at===null){for(;btbt?(bn=at,at=null):bn=at.sibling;var Os=Je(te,at,Pt.value,Le);if(Os===null){at===null&&(at=bn);break}l&&at&&Os.alternate===null&&u(te,at),Z=A(Os,Z,bt),ft===null?He=Os:ft.sibling=Os,ft=Os,at=bn}if(Pt.done)return p(te,at),qt&&wo(te,bt),He;if(at===null){for(;!Pt.done;bt++,Pt=re.next())Pt=ot(te,Pt.value,Le),Pt!==null&&(Z=A(Pt,Z,bt),ft===null?He=Pt:ft.sibling=Pt,ft=Pt);return qt&&wo(te,bt),He}for(at=y(te,at);!Pt.done;bt++,Pt=re.next())Pt=Ft(at,te,bt,Pt.value,Le),Pt!==null&&(l&&Pt.alternate!==null&&at.delete(Pt.key===null?bt:Pt.key),Z=A(Pt,Z,bt),ft===null?He=Pt:ft.sibling=Pt,ft=Pt);return l&&at.forEach(function(iC){return u(te,iC)}),qt&&wo(te,bt),He}function Qi(te,Z,re,Le){if(typeof re=="object"&&re!==null&&re.type===h&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case c:e:{for(var He=re.key,ft=Z;ft!==null;){if(ft.key===He){if(He=re.type,He===h){if(ft.tag===7){p(te,ft.sibling),Z=M(ft,re.props.children),Z.return=te,te=Z;break e}}else if(ft.elementType===He||typeof He=="object"&&He!==null&&He.$$typeof===w&&sx(He)===ft.type){p(te,ft.sibling),Z=M(ft,re.props),Z.ref=su(te,ft,re),Z.return=te,te=Z;break e}p(te,ft);break}else u(te,ft);ft=ft.sibling}re.type===h?(Z=Po(re.props.children,te.mode,Le,re.key),Z.return=te,te=Z):(Le=lh(re.type,re.key,re.props,null,te.mode,Le),Le.ref=su(te,Z,re),Le.return=te,te=Le)}return O(te);case f:e:{for(ft=re.key;Z!==null;){if(Z.key===ft)if(Z.tag===4&&Z.stateNode.containerInfo===re.containerInfo&&Z.stateNode.implementation===re.implementation){p(te,Z.sibling),Z=M(Z,re.children||[]),Z.return=te,te=Z;break e}else{p(te,Z);break}else u(te,Z);Z=Z.sibling}Z=Km(re,te.mode,Le),Z.return=te,te=Z}return O(te);case w:return ft=re._init,Qi(te,Z,ft(re._payload),Le)}if(ee(re))return Xe(te,Z,re,Le);if(P(re))return Xn(te,Z,re,Le);Rf(te,re)}return typeof re=="string"&&re!==""||typeof re=="number"?(re=""+re,Z!==null&&Z.tag===6?(p(te,Z.sibling),Z=M(Z,re),Z.return=te,te=Z):(p(te,Z),Z=Jm(re,te.mode,Le),Z.return=te,te=Z),O(te)):p(te,Z)}return Qi}var ba=ox(!0),ax=ox(!1),ou={},ji=fi(ou),au=fi(ou),Pa=fi(ou);function Nr(l){if(l===ou)throw Error(o(174));return l}function mm(l,u){ct(Pa,u),ct(au,l),ct(ji,ou),l=ue(u),Dt(ji),ct(ji,l)}function La(){Dt(ji),Dt(au),Dt(Pa)}function lx(l){var u=Nr(Pa.current),p=Nr(ji.current);u=D(p,l.type,u),p!==u&&(ct(au,l),ct(ji,u))}function gm(l){au.current===l&&(Dt(ji),Dt(au))}var Kt=fi(0);function If(l){for(var u=l;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||mf(p)||eu(p)))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var vm=[];function ym(){for(var l=0;lp?p:4,l(!0);var y=Yi.transition;Yi.transition={};try{l(!1),u()}finally{Ct=p,Yi.transition=y}}function wx(){return kr().memoizedState}function LA(l,u,p){var y=ks(l);p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},Mx(l)?Ex(u,p):(Tx(l,u,p),p=ni(),l=qi(l,y,p),l!==null&&Ax(l,u,y))}function RA(l,u,p){var y=ks(l),M={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(Mx(l))Ex(u,M);else{Tx(l,u,M);var A=l.alternate;if(l.lanes===0&&(A===null||A.lanes===0)&&(A=u.lastRenderedReducer,A!==null))try{var O=u.lastRenderedState,j=A(O,p);if(M.hasEagerState=!0,M.eagerState=j,Rr(j,O))return}catch{}finally{}p=ni(),l=qi(l,y,p),l!==null&&Ax(l,u,y)}}function Mx(l){var u=l.alternate;return l===sn||u!==null&&u===sn}function Ex(l,u){lu=Nf=!0;var p=l.pending;p===null?u.next=u:(u.next=p.next,p.next=u),l.pending=u}function Tx(l,u,p){gn!==null&&(l.mode&1)!==0&&(gt&2)===0?(l=u.interleaved,l===null?(p.next=p,Dr===null?Dr=[u]:Dr.push(u)):(p.next=l.next,l.next=p),u.interleaved=p):(l=u.pending,l===null?p.next=p:(p.next=l.next,l.next=p),u.pending=p)}function Ax(l,u,p){if((p&4194240)!==0){var y=u.lanes;y&=l.pendingLanes,p|=y,u.lanes=p,Kp(l,p)}}var Ff={readContext:Gi,useCallback:Gn,useContext:Gn,useEffect:Gn,useImperativeHandle:Gn,useInsertionEffect:Gn,useLayoutEffect:Gn,useMemo:Gn,useReducer:Gn,useRef:Gn,useState:Gn,useDebugValue:Gn,useDeferredValue:Gn,useTransition:Gn,useMutableSource:Gn,useSyncExternalStore:Gn,useId:Gn,unstable_isNewReconciler:!1},IA={readContext:Gi,useCallback:function(l,u){return ns().memoizedState=[l,u===void 0?null:u],l},useContext:Gi,useEffect:Mm,useImperativeHandle:function(l,u,p){return p=p!=null?p.concat([l]):null,Uf(4194308,4,yx.bind(null,u,l),p)},useLayoutEffect:function(l,u){return Uf(4194308,4,l,u)},useInsertionEffect:function(l,u){return Uf(4,2,l,u)},useMemo:function(l,u){var p=ns();return u=u===void 0?null:u,l=l(),p.memoizedState=[l,u],l},useReducer:function(l,u,p){var y=ns();return u=p!==void 0?p(u):u,y.memoizedState=y.baseState=u,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:u},y.queue=l,l=l.dispatch=LA.bind(null,sn,l),[y.memoizedState,l]},useRef:function(l){var u=ns();return l={current:l},u.memoizedState=l},useState:wm,useDebugValue:Em,useDeferredValue:function(l){var u=wm(l),p=u[0],y=u[1];return Mm(function(){var M=Yi.transition;Yi.transition={};try{y(l)}finally{Yi.transition=M}},[l]),p},useTransition:function(){var l=wm(!1),u=l[0];return l=PA.bind(null,l[1]),ns().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,p){var y=sn,M=ns();if(qt){if(p===void 0)throw Error(o(407));p=p()}else{if(p=u(),gn===null)throw Error(o(349));(Ra&30)!==0||fx(y,u,p)}M.memoizedState=p;var A={value:p,getSnapshot:u};return M.queue=A,Mm(dx.bind(null,y,A,l),[l]),y.flags|=2048,cu(9,hx.bind(null,y,A,p,u),void 0,null),p},useId:function(){var l=ns(),u=gn.identifierPrefix;if(qt){var p=ts,y=es;p=(y&~(1<<32-hr(y)-1)).toString(32)+p,u=":"+u+"R"+p,p=uu++,0Gm&&(u.flags|=128,y=!0,pu(M,!1),u.lanes=4194304)}else{if(!y)if(l=If(A),l!==null){if(u.flags|=128,y=!0,l=l.updateQueue,l!==null&&(u.updateQueue=l,u.flags|=4),pu(M,!0),M.tail===null&&M.tailMode==="hidden"&&!A.alternate&&!qt)return Wn(u),null}else 2*An()-M.renderingStartTime>Gm&&p!==1073741824&&(u.flags|=128,y=!0,pu(M,!1),u.lanes=4194304);M.isBackwards?(A.sibling=u.child,u.child=A):(l=M.last,l!==null?l.sibling=A:u.child=A,M.last=A)}return M.tail!==null?(u=M.tail,M.rendering=u,M.tail=u.sibling,M.renderingStartTime=An(),u.sibling=null,l=Kt.current,ct(Kt,y?l&1|2:l&1),u):(Wn(u),null);case 22:case 23:return qm(),y=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==y&&(u.flags|=8192),y&&(u.mode&1)!==0?(bi&1073741824)!==0&&(Wn(u),De&&u.subtreeFlags&6&&(u.flags|=8192)):Wn(u),null;case 24:return null;case 25:return null}throw Error(o(156,u.tag))}var UA=a.ReactCurrentOwner,Ci=!1;function ti(l,u,p,y){u.child=l===null?ax(u,null,p,y):ba(u,l.child,p,y)}function Nx(l,u,p,y,M){p=p.render;var A=u.ref;return Ea(u,M),y=xm(l,u,p,y,A,M),p=Sm(),l!==null&&!Ci?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~M,is(l,u,M)):(qt&&p&&cm(u),u.flags|=1,ti(l,u,y,M),u.child)}function kx(l,u,p,y,M){if(l===null){var A=p.type;return typeof A=="function"&&!Qm(A)&&A.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(u.tag=15,u.type=A,zx(l,u,A,y,M)):(l=lh(p.type,null,y,u,u.mode,M),l.ref=u.ref,l.return=u,u.child=l)}if(A=l.child,(l.lanes&M)===0){var O=A.memoizedProps;if(p=p.compare,p=p!==null?p:Mf,p(O,y)&&l.ref===u.ref)return is(l,u,M)}return u.flags|=1,l=Us(A,y),l.ref=u.ref,l.return=u,u.child=l}function zx(l,u,p,y,M){if(l!==null&&Mf(l.memoizedProps,y)&&l.ref===u.ref)if(Ci=!1,(l.lanes&M)!==0)(l.flags&131072)!==0&&(Ci=!0);else return u.lanes=l.lanes,is(l,u,M);return Cm(l,u,p,y,M)}function Ux(l,u,p){var y=u.pendingProps,M=y.children,A=l!==null?l.memoizedState:null;if(y.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null},ct(Ia,bi),bi|=p;else if((p&1073741824)!==0)u.memoizedState={baseLanes:0,cachePool:null},y=A!==null?A.baseLanes:p,ct(Ia,bi),bi|=y;else return l=A!==null?A.baseLanes|p:p,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:l,cachePool:null},u.updateQueue=null,ct(Ia,bi),bi|=l,null;else A!==null?(y=A.baseLanes|p,u.memoizedState=null):y=p,ct(Ia,bi),bi|=y;return ti(l,u,M,p),u.child}function Ox(l,u){var p=u.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(u.flags|=512,u.flags|=2097152)}function Cm(l,u,p,y,M){var A=kn(p)?fr:mn.current;return A=Ls(u,A),Ea(u,M),p=xm(l,u,p,y,A,M),y=Sm(),l!==null&&!Ci?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~M,is(l,u,M)):(qt&&y&&cm(u),u.flags|=1,ti(l,u,p,M),u.child)}function Fx(l,u,p,y,M){if(kn(p)){var A=!0;vf(u)}else A=!1;if(Ea(u,M),u.stateNode===null)l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2),$_(u,p,y),um(u,p,y,M),y=!0;else if(l===null){var O=u.stateNode,j=u.memoizedProps;O.props=j;var ae=O.context,Ee=p.contextType;typeof Ee=="object"&&Ee!==null?Ee=Gi(Ee):(Ee=kn(p)?fr:mn.current,Ee=Ls(u,Ee));var Fe=p.getDerivedStateFromProps,ot=typeof Fe=="function"||typeof O.getSnapshotBeforeUpdate=="function";ot||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(j!==y||ae!==Ee)&&ex(u,O,y,Ee),Rs=!1;var Je=u.memoizedState;O.state=Je,Cf(u,y,O,M),ae=u.memoizedState,j!==y||Je!==ae||Ut.current||Rs?(typeof Fe=="function"&&(lm(u,p,Fe,y),ae=u.memoizedState),(j=Rs||K_(u,p,j,y,Je,ae,Ee))?(ot||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(u.flags|=4194308)):(typeof O.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=y,u.memoizedState=ae),O.props=y,O.state=ae,O.context=Ee,y=j):(typeof O.componentDidMount=="function"&&(u.flags|=4194308),y=!1)}else{O=u.stateNode,q_(l,u),j=u.memoizedProps,Ee=u.type===u.elementType?j:dr(u.type,j),O.props=Ee,ot=u.pendingProps,Je=O.context,ae=p.contextType,typeof ae=="object"&&ae!==null?ae=Gi(ae):(ae=kn(p)?fr:mn.current,ae=Ls(u,ae));var Ft=p.getDerivedStateFromProps;(Fe=typeof Ft=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(j!==ot||Je!==ae)&&ex(u,O,y,ae),Rs=!1,Je=u.memoizedState,O.state=Je,Cf(u,y,O,M);var Xe=u.memoizedState;j!==ot||Je!==Xe||Ut.current||Rs?(typeof Ft=="function"&&(lm(u,p,Ft,y),Xe=u.memoizedState),(Ee=Rs||K_(u,p,Ee,y,Je,Xe,ae)||!1)?(Fe||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(y,Xe,ae),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(y,Xe,ae)),typeof O.componentDidUpdate=="function"&&(u.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof O.componentDidUpdate!="function"||j===l.memoizedProps&&Je===l.memoizedState||(u.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||j===l.memoizedProps&&Je===l.memoizedState||(u.flags|=1024),u.memoizedProps=y,u.memoizedState=Xe),O.props=y,O.state=Xe,O.context=ae,y=Ee):(typeof O.componentDidUpdate!="function"||j===l.memoizedProps&&Je===l.memoizedState||(u.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||j===l.memoizedProps&&Je===l.memoizedState||(u.flags|=1024),y=!1)}return bm(l,u,p,y,A,M)}function bm(l,u,p,y,M,A){Ox(l,u);var O=(u.flags&128)!==0;if(!y&&!O)return M&&G_(u,p,!1),is(l,u,A);y=u.stateNode,UA.current=u;var j=O&&typeof p.getDerivedStateFromError!="function"?null:y.render();return u.flags|=1,l!==null&&O?(u.child=ba(u,l.child,null,A),u.child=ba(u,null,j,A)):ti(l,u,j,A),u.memoizedState=y.state,M&&G_(u,p,!0),u.child}function Bx(l){var u=l.stateNode;u.pendingContext?V_(l,u.pendingContext,u.pendingContext!==u.context):u.context&&V_(l,u.context,!1),mm(l,u.containerInfo)}function Vx(l,u,p,y,M){return Ca(),pm(M),u.flags|=256,ti(l,u,p,y),u.child}var Hf={dehydrated:null,treeContext:null,retryLane:0};function Gf(l){return{baseLanes:l,cachePool:null}}function Hx(l,u,p){var y=u.pendingProps,M=Kt.current,A=!1,O=(u.flags&128)!==0,j;if((j=O)||(j=l!==null&&l.memoizedState===null?!1:(M&2)!==0),j?(A=!0,u.flags&=-129):(l===null||l.memoizedState!==null)&&(M|=1),ct(Kt,M&1),l===null)return dm(u),l=u.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((u.mode&1)===0?u.lanes=1:eu(l)?u.lanes=8:u.lanes=1073741824,null):(M=y.children,l=y.fallback,A?(y=u.mode,A=u.child,M={mode:"hidden",children:M},(y&1)===0&&A!==null?(A.childLanes=0,A.pendingProps=M):A=uh(M,y,0,null),l=Po(l,y,p,null),A.return=u,l.return=u,A.sibling=l,u.child=A,u.child.memoizedState=Gf(p),u.memoizedState=Hf,l):Pm(u,M));if(M=l.memoizedState,M!==null){if(j=M.dehydrated,j!==null){if(O)return u.flags&256?(u.flags&=-257,Wf(l,u,p,Error(o(422)))):u.memoizedState!==null?(u.child=l.child,u.flags|=128,null):(A=y.fallback,M=u.mode,y=uh({mode:"visible",children:y.children},M,0,null),A=Po(A,M,p,null),A.flags|=2,y.return=u,A.return=u,y.sibling=A,u.child=y,(u.mode&1)!==0&&ba(u,l.child,null,p),u.child.memoizedState=Gf(p),u.memoizedState=Hf,A);if((u.mode&1)===0)u=Wf(l,u,p,null);else if(eu(j))u=Wf(l,u,p,Error(o(419)));else if(y=(p&l.childLanes)!==0,Ci||y){if(y=gn,y!==null){switch(p&-p){case 4:A=2;break;case 16:A=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:A=32;break;case 536870912:A=268435456;break;default:A=0}y=(A&(y.suspendedLanes|p))!==0?0:A,y!==0&&y!==M.retryLane&&(M.retryLane=y,qi(l,y,-1))}Zm(),u=Wf(l,u,p,Error(o(421)))}else mf(j)?(u.flags|=128,u.child=l.child,u=QA.bind(null,l),Zp(j,u),u=null):(p=M.treeContext,se&&(Ai=$(j),Ti=u,qt=!0,pr=null,iu=!1,p!==null&&(Wi[Xi++]=es,Wi[Xi++]=ts,Wi[Xi++]=So,es=p.id,ts=p.overflow,So=u)),u=Pm(u,u.pendingProps.children),u.flags|=4096);return u}return A?(y=Wx(l,u,y.children,y.fallback,p),A=u.child,M=l.child.memoizedState,A.memoizedState=M===null?Gf(p):{baseLanes:M.baseLanes|p,cachePool:null},A.childLanes=l.childLanes&~p,u.memoizedState=Hf,y):(p=Gx(l,u,y.children,p),u.memoizedState=null,p)}return A?(y=Wx(l,u,y.children,y.fallback,p),A=u.child,M=l.child.memoizedState,A.memoizedState=M===null?Gf(p):{baseLanes:M.baseLanes|p,cachePool:null},A.childLanes=l.childLanes&~p,u.memoizedState=Hf,y):(p=Gx(l,u,y.children,p),u.memoizedState=null,p)}function Pm(l,u){return u=uh({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function Gx(l,u,p,y){var M=l.child;return l=M.sibling,p=Us(M,{mode:"visible",children:p}),(u.mode&1)===0&&(p.lanes=y),p.return=u,p.sibling=null,l!==null&&(y=u.deletions,y===null?(u.deletions=[l],u.flags|=16):y.push(l)),u.child=p}function Wx(l,u,p,y,M){var A=u.mode;l=l.child;var O=l.sibling,j={mode:"hidden",children:p};return(A&1)===0&&u.child!==l?(p=u.child,p.childLanes=0,p.pendingProps=j,u.deletions=null):(p=Us(l,j),p.subtreeFlags=l.subtreeFlags&14680064),O!==null?y=Us(O,y):(y=Po(y,A,M,null),y.flags|=2),y.return=u,p.return=u,p.sibling=y,u.child=p,y}function Wf(l,u,p,y){return y!==null&&pm(y),ba(u,l.child,null,p),l=Pm(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function Xx(l,u,p){l.lanes|=u;var y=l.alternate;y!==null&&(y.lanes|=u),om(l.return,u,p)}function Lm(l,u,p,y,M){var A=l.memoizedState;A===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:M}:(A.isBackwards=u,A.rendering=null,A.renderingStartTime=0,A.last=y,A.tail=p,A.tailMode=M)}function jx(l,u,p){var y=u.pendingProps,M=y.revealOrder,A=y.tail;if(ti(l,u,y.children,p),y=Kt.current,(y&2)!==0)y=y&1|2,u.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&Xx(l,p,u);else if(l.tag===19)Xx(l,p,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}y&=1}if(ct(Kt,y),(u.mode&1)===0)u.memoizedState=null;else switch(M){case"forwards":for(p=u.child,M=null;p!==null;)l=p.alternate,l!==null&&If(l)===null&&(M=p),p=p.sibling;p=M,p===null?(M=u.child,u.child=null):(M=p.sibling,p.sibling=null),Lm(u,!1,M,p,A);break;case"backwards":for(p=null,M=u.child,u.child=null;M!==null;){if(l=M.alternate,l!==null&&If(l)===null){u.child=M;break}l=M.sibling,M.sibling=p,p=M,M=l}Lm(u,!0,p,null,A);break;case"together":Lm(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function is(l,u,p){if(l!==null&&(u.dependencies=l.dependencies),Da|=u.lanes,(p&u.childLanes)===0)return null;if(l!==null&&u.child!==l.child)throw Error(o(153));if(u.child!==null){for(l=u.child,p=Us(l,l.pendingProps),u.child=p,p.return=u;l.sibling!==null;)l=l.sibling,p=p.sibling=Us(l,l.pendingProps),p.return=u;p.sibling=null}return u.child}function OA(l,u,p){switch(u.tag){case 3:Bx(u),Ca();break;case 5:lx(u);break;case 1:kn(u.type)&&vf(u);break;case 4:mm(u,u.stateNode.containerInfo);break;case 10:Y_(u,u.type._context,u.memoizedProps.value);break;case 13:var y=u.memoizedState;if(y!==null)return y.dehydrated!==null?(ct(Kt,Kt.current&1),u.flags|=128,null):(p&u.child.childLanes)!==0?Hx(l,u,p):(ct(Kt,Kt.current&1),l=is(l,u,p),l!==null?l.sibling:null);ct(Kt,Kt.current&1);break;case 19:if(y=(p&u.childLanes)!==0,(l.flags&128)!==0){if(y)return jx(l,u,p);u.flags|=128}var M=u.memoizedState;if(M!==null&&(M.rendering=null,M.tail=null,M.lastEffect=null),ct(Kt,Kt.current),y)break;return null;case 22:case 23:return u.lanes=0,Ux(l,u,p)}return is(l,u,p)}function FA(l,u){switch(fm(u),u.tag){case 1:return kn(u.type)&&gf(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return La(),Dt(Ut),Dt(mn),ym(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 5:return gm(u),null;case 13:if(Dt(Kt),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(o(340));Ca()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return Dt(Kt),null;case 4:return La(),null;case 10:return sm(u.type._context),null;case 22:case 23:return qm(),null;case 24:return null;default:return null}}var Xf=!1,Eo=!1,BA=typeof WeakSet=="function"?WeakSet:Set,Pe=null;function jf(l,u){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){pi(l,u,y)}else p.current=null}function Rm(l,u,p){try{p()}catch(y){pi(l,u,y)}}var Yx=!1;function VA(l,u){for(V(l.containerInfo),Pe=u;Pe!==null;)if(l=Pe,u=l.child,(l.subtreeFlags&1028)!==0&&u!==null)u.return=l,Pe=u;else for(;Pe!==null;){l=Pe;try{var p=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var y=p.memoizedProps,M=p.memoizedState,A=l.stateNode,O=A.getSnapshotBeforeUpdate(l.elementType===l.type?y:dr(l.type,y),M);A.__reactInternalSnapshotBeforeUpdate=O}break;case 3:De&&Ie(l.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(j){pi(l,l.return,j)}if(u=l.sibling,u!==null){u.return=l.return,Pe=u;break}Pe=l.return}return p=Yx,Yx=!1,p}function To(l,u,p){var y=u.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var M=y=y.next;do{if((M.tag&l)===l){var A=M.destroy;M.destroy=void 0,A!==void 0&&Rm(u,p,A)}M=M.next}while(M!==y)}}function mu(l,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var p=u=u.next;do{if((p.tag&l)===l){var y=p.create;p.destroy=y()}p=p.next}while(p!==u)}}function Im(l){var u=l.ref;if(u!==null){var p=l.stateNode;switch(l.tag){case 5:l=oe(p);break;default:l=p}typeof u=="function"?u(l):u.current=l}}function qx(l,u,p){if(Lr&&typeof Lr.onCommitFiberUnmount=="function")try{Lr.onCommitFiberUnmount(Sf,u)}catch{}switch(u.tag){case 0:case 11:case 14:case 15:if(l=u.updateQueue,l!==null&&(l=l.lastEffect,l!==null)){var y=l=l.next;do{var M=y,A=M.destroy;M=M.tag,A!==void 0&&((M&2)!==0||(M&4)!==0)&&Rm(u,p,A),y=y.next}while(y!==l)}break;case 1:if(jf(u,p),l=u.stateNode,typeof l.componentWillUnmount=="function")try{l.props=u.memoizedProps,l.state=u.memoizedState,l.componentWillUnmount()}catch(O){pi(u,p,O)}break;case 5:jf(u,p);break;case 4:De?e1(l,u,p):me&&me&&(u=u.stateNode.containerInfo,p=zt(u),lr(u,p))}}function Zx(l,u,p){for(var y=u;;)if(qx(l,y,p),y.child===null||De&&y.tag===4){if(y===u)break;for(;y.sibling===null;){if(y.return===null||y.return===u)return;y=y.return}y.sibling.return=y.return,y=y.sibling}else y.child.return=y,y=y.child}function Qx(l){var u=l.alternate;u!==null&&(l.alternate=null,Qx(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&Ke(u)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function Jx(l){return l.tag===5||l.tag===3||l.tag===4}function Kx(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Jx(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function $x(l){if(De){e:{for(var u=l.return;u!==null;){if(Jx(u))break e;u=u.return}throw Error(o(160))}var p=u;switch(p.tag){case 5:u=p.stateNode,p.flags&32&&(Lt(u),p.flags&=-33),p=Kx(l),Nm(l,p,u);break;case 3:case 4:u=p.stateNode.containerInfo,p=Kx(l),Dm(l,p,u);break;default:throw Error(o(161))}}}function Dm(l,u,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,u?Oe(p,l,u):ke(p,l);else if(y!==4&&(l=l.child,l!==null))for(Dm(l,u,p),l=l.sibling;l!==null;)Dm(l,u,p),l=l.sibling}function Nm(l,u,p){var y=l.tag;if(y===5||y===6)l=l.stateNode,u?et(p,l,u):tt(p,l);else if(y!==4&&(l=l.child,l!==null))for(Nm(l,u,p),l=l.sibling;l!==null;)Nm(l,u,p),l=l.sibling}function e1(l,u,p){for(var y=u,M=!1,A,O;;){if(!M){M=y.return;e:for(;;){if(M===null)throw Error(o(160));switch(A=M.stateNode,M.tag){case 5:O=!1;break e;case 3:A=A.containerInfo,O=!0;break e;case 4:A=A.containerInfo,O=!0;break e}M=M.return}M=!0}if(y.tag===5||y.tag===6)Zx(l,y,p),O?wt(A,y.stateNode):Ge(A,y.stateNode);else if(y.tag===18)O?yt(A,y.stateNode):mt(A,y.stateNode);else if(y.tag===4){if(y.child!==null){A=y.stateNode.containerInfo,O=!0,y.child.return=y,y=y.child;continue}}else if(qx(l,y,p),y.child!==null){y.child.return=y,y=y.child;continue}if(y===u)break;for(;y.sibling===null;){if(y.return===null||y.return===u)return;y=y.return,y.tag===4&&(M=!1)}y.sibling.return=y.return,y=y.sibling}}function km(l,u){if(De){switch(u.tag){case 0:case 11:case 14:case 15:To(3,u,u.return),mu(3,u),To(5,u,u.return);return;case 1:return;case 5:var p=u.stateNode;if(p!=null){var y=u.memoizedProps;l=l!==null?l.memoizedProps:y;var M=u.type,A=u.updateQueue;u.updateQueue=null,A!==null&&qe(p,A,M,l,y,u)}return;case 6:if(u.stateNode===null)throw Error(o(162));p=u.memoizedProps,he(u.stateNode,l!==null?l.memoizedProps:p,p);return;case 3:se&&l!==null&&l.memoizedState.isDehydrated&&ut(u.stateNode.containerInfo);return;case 12:return;case 13:Yf(u);return;case 19:Yf(u);return;case 17:return}throw Error(o(163))}switch(u.tag){case 0:case 11:case 14:case 15:To(3,u,u.return),mu(3,u),To(5,u,u.return);return;case 12:return;case 13:Yf(u);return;case 19:Yf(u);return;case 3:se&&l!==null&&l.memoizedState.isDehydrated&&ut(u.stateNode.containerInfo);break;case 22:case 23:return}e:if(me){switch(u.tag){case 1:case 5:case 6:break e;case 3:case 4:u=u.stateNode,lr(u.containerInfo,u.pendingChildren);break e}throw Error(o(163))}}function Yf(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new BA),u.forEach(function(y){var M=JA.bind(null,l,y);p.has(y)||(p.add(y),y.then(M,M))})}}function HA(l,u){for(Pe=u;Pe!==null;){u=Pe;var p=u.deletions;if(p!==null)for(var y=0;y";case Zf:return":has("+(Om(l)||"")+")";case Qf:return'[role="'+l.value+'"]';case Kf:return'"'+l.value+'"';case Jf:return'[data-testname="'+l.value+'"]';default:throw Error(o(365))}}function s1(l,u){var p=[];l=[l,0];for(var y=0;yM&&(M=O),y&=~A}if(y=M,y=An()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*WA(y/1960))-y,10l?16:l,Ns===null)var y=!1;else{if(l=Ns,Ns=null,ih=0,(gt&6)!==0)throw Error(o(331));var M=gt;for(gt|=4,Pe=l.current;Pe!==null;){var A=Pe,O=A.child;if((Pe.flags&16)!==0){var j=A.deletions;if(j!==null){for(var ae=0;aeAn()-Hm?Ao(l,0):Vm|=p),di(l,u)}function p1(l,u){u===0&&((l.mode&1)===0?u=1:(u=_f,_f<<=1,(_f&130023424)===0&&(_f=4194304)));var p=ni();l=oh(l,u),l!==null&&(nu(l,u,p),di(l,p))}function QA(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),p1(l,p)}function JA(l,u){var p=0;switch(l.tag){case 13:var y=l.stateNode,M=l.memoizedState;M!==null&&(p=M.retryLane);break;case 19:y=l.stateNode;break;default:throw Error(o(314))}y!==null&&y.delete(u),p1(l,p)}var m1;m1=function(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps||Ut.current)Ci=!0;else{if((l.lanes&p)===0&&(u.flags&128)===0)return Ci=!1,OA(l,u,p);Ci=(l.flags&131072)!==0}else Ci=!1,qt&&(u.flags&1048576)!==0&&tx(u,Lf,u.index);switch(u.lanes=0,u.tag){case 2:var y=u.type;l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2),l=u.pendingProps;var M=Ls(u,mn.current);Ea(u,p),M=xm(null,u,y,l,M,p);var A=Sm();return u.flags|=1,typeof M=="object"&&M!==null&&typeof M.render=="function"&&M.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,kn(y)?(A=!0,vf(u)):A=!1,u.memoizedState=M.state!==null&&M.state!==void 0?M.state:null,am(u),M.updater=bf,u.stateNode=M,M._reactInternals=u,um(u,y,l,p),u=bm(null,u,y,!0,A,p)):(u.tag=0,qt&&A&&cm(u),ti(null,u,M,p),u=u.child),u;case 16:y=u.elementType;e:{switch(l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2),l=u.pendingProps,M=y._init,y=M(y._payload),u.type=y,M=u.tag=$A(y),l=dr(y,l),M){case 0:u=Cm(null,u,y,l,p);break e;case 1:u=Fx(null,u,y,l,p);break e;case 11:u=Nx(null,u,y,l,p);break e;case 14:u=kx(null,u,y,dr(y.type,l),p);break e}throw Error(o(306,y,""))}return u;case 0:return y=u.type,M=u.pendingProps,M=u.elementType===y?M:dr(y,M),Cm(l,u,y,M,p);case 1:return y=u.type,M=u.pendingProps,M=u.elementType===y?M:dr(y,M),Fx(l,u,y,M,p);case 3:e:{if(Bx(u),l===null)throw Error(o(387));y=u.pendingProps,A=u.memoizedState,M=A.element,q_(l,u),Cf(u,y,null,p);var O=u.memoizedState;if(y=O.element,se&&A.isDehydrated)if(A={element:y,isDehydrated:!1,cache:O.cache,transitions:O.transitions},u.updateQueue.baseState=A,u.memoizedState=A,u.flags&256){M=Error(o(423)),u=Vx(l,u,y,p,M);break e}else if(y!==M){M=Error(o(424)),u=Vx(l,u,y,p,M);break e}else for(se&&(Ai=ce(u.stateNode.containerInfo),Ti=u,qt=!0,pr=null,iu=!1),p=ax(u,null,y,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Ca(),y===M){u=is(l,u,p);break e}ti(l,u,y,p)}u=u.child}return u;case 5:return lx(u),l===null&&dm(u),y=u.type,M=u.pendingProps,A=l!==null?l.memoizedProps:null,O=M.children,ye(y,M)?O=null:A!==null&&ye(y,A)&&(u.flags|=32),Ox(l,u),ti(l,u,O,p),u.child;case 6:return l===null&&dm(u),null;case 13:return Hx(l,u,p);case 4:return mm(u,u.stateNode.containerInfo),y=u.pendingProps,l===null?u.child=ba(u,null,y,p):ti(l,u,y,p),u.child;case 11:return y=u.type,M=u.pendingProps,M=u.elementType===y?M:dr(y,M),Nx(l,u,y,M,p);case 7:return ti(l,u,u.pendingProps,p),u.child;case 8:return ti(l,u,u.pendingProps.children,p),u.child;case 12:return ti(l,u,u.pendingProps.children,p),u.child;case 10:e:{if(y=u.type._context,M=u.pendingProps,A=u.memoizedProps,O=M.value,Y_(u,y,O),A!==null)if(Rr(A.value,O)){if(A.children===M.children&&!Ut.current){u=is(l,u,p);break e}}else for(A=u.child,A!==null&&(A.return=u);A!==null;){var j=A.dependencies;if(j!==null){O=A.child;for(var ae=j.firstContext;ae!==null;){if(ae.context===y){if(A.tag===1){ae=$r(-1,p&-p),ae.tag=2;var Ee=A.updateQueue;if(Ee!==null){Ee=Ee.shared;var Fe=Ee.pending;Fe===null?ae.next=ae:(ae.next=Fe.next,Fe.next=ae),Ee.pending=ae}}A.lanes|=p,ae=A.alternate,ae!==null&&(ae.lanes|=p),om(A.return,p,u),j.lanes|=p;break}ae=ae.next}}else if(A.tag===10)O=A.type===u.type?null:A.child;else if(A.tag===18){if(O=A.return,O===null)throw Error(o(341));O.lanes|=p,j=O.alternate,j!==null&&(j.lanes|=p),om(O,p,u),O=A.sibling}else O=A.child;if(O!==null)O.return=A;else for(O=A;O!==null;){if(O===u){O=null;break}if(A=O.sibling,A!==null){A.return=O.return,O=A;break}O=O.return}A=O}ti(l,u,M.children,p),u=u.child}return u;case 9:return M=u.type,y=u.pendingProps.children,Ea(u,p),M=Gi(M),y=y(M),u.flags|=1,ti(l,u,y,p),u.child;case 14:return y=u.type,M=dr(y,u.pendingProps),M=dr(y.type,M),kx(l,u,y,M,p);case 15:return zx(l,u,u.type,u.pendingProps,p);case 17:return y=u.type,M=u.pendingProps,M=u.elementType===y?M:dr(y,M),l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2),u.tag=1,kn(y)?(l=!0,vf(u)):l=!1,Ea(u,p),$_(u,y,M),um(u,y,M,p),bm(null,u,y,!0,l,p);case 19:return jx(l,u,p);case 22:return Ux(l,u,p)}throw Error(o(156,u.tag))};function g1(l,u){return $p(l,u)}function KA(l,u,p,y){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zi(l,u,p,y){return new KA(l,u,p,y)}function Qm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function $A(l){if(typeof l=="function")return Qm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===E)return 11;if(l===x)return 14}return 2}function Us(l,u){var p=l.alternate;return p===null?(p=Zi(l.tag,u,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=u,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,u=l.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function lh(l,u,p,y,M,A){var O=2;if(y=l,typeof l=="function")Qm(l)&&(O=1);else if(typeof l=="string")O=5;else e:switch(l){case h:return Po(p.children,M,A,u);case d:O=8,M|=8;break;case m:return l=Zi(12,p,u,M|2),l.elementType=m,l.lanes=A,l;case S:return l=Zi(13,p,u,M),l.elementType=S,l.lanes=A,l;case g:return l=Zi(19,p,u,M),l.elementType=g,l.lanes=A,l;case T:return uh(p,M,A,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case v:O=10;break e;case _:O=9;break e;case E:O=11;break e;case x:O=14;break e;case w:O=16,y=null;break e}throw Error(o(130,l==null?l:typeof l,""))}return u=Zi(O,p,u,M),u.elementType=l,u.type=y,u.lanes=A,u}function Po(l,u,p,y){return l=Zi(7,l,y,u),l.lanes=p,l}function uh(l,u,p,y){return l=Zi(22,l,y,u),l.elementType=T,l.lanes=p,l.stateNode={},l}function Jm(l,u,p){return l=Zi(6,l,null,u),l.lanes=p,l}function Km(l,u,p){return u=Zi(4,l.children!==null?l.children:[],l.key,u),u.lanes=p,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function eC(l,u,p,y,M){this.tag=u,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=je,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Jp(0),this.expirationTimes=Jp(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Jp(0),this.identifierPrefix=y,this.onRecoverableError=M,se&&(this.mutableSourceEagerHydrationData=null)}function v1(l,u,p,y,M,A,O,j,ae){return l=new eC(l,u,p,j,ae),u===1?(u=1,A===!0&&(u|=8)):u=0,A=Zi(3,null,null,u),l.current=A,A.stateNode=l,A.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null},am(A),l}function y1(l){if(!l)return Vn;l=l._reactInternals;e:{if(b(l)!==l||l.tag!==1)throw Error(o(170));var u=l;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(kn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(o(171))}if(l.tag===1){var p=l.type;if(kn(p))return H_(l,p,u)}return u}function _1(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(o(188)):(l=Object.keys(l).join(","),Error(o(268,l)));return l=q(u),l===null?null:l.stateNode}function x1(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p=Ee&&A>=ot&&M<=Fe&&O<=Je){l.splice(u,1);break}else if(y!==Ee||p.width!==ae.width||JeO){if(!(A!==ot||p.height!==ae.height||FeM)){Ee>y&&(ae.width+=Ee-y,ae.x=y),FeA&&(ae.height+=ot-A,ae.y=A),Jep&&(p=O)),O ")+` No matching component was found for: `)+l.join(" > ")}return null},t.getPublicRootInstance=function(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return oe(l.child.stateNode);default:return l.child.stateNode}},t.injectIntoDevTools=function(l){if(l={bundleType:l.bundleType,version:l.version,rendererPackageName:l.rendererPackageName,rendererConfig:l.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:a.ReactCurrentDispatcher,findHostInstanceByFiber:tC,findFiberByHostInstance:l.findFiberByHostInstance||nC,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")l=!1;else{var u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(u.isDisabled||!u.supportsFiber)l=!0;else{try{Sf=u.inject(l),Lr=u}catch{}l=!!u.checkDCE}}return l},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(l,u,p,y){if(!rt)throw Error(o(363));l=Fm(l,u);var M=be(l,p,y).disconnect;return{disconnect:function(){M()}}},t.registerMutableSourceForHydration=function(l,u){var p=u._getVersion;p=p(u._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[u,p]:l.mutableSourceEagerHydrationData.push(u,p)},t.runWithPriority=function(l,u){var p=Ct;try{return Ct=l,u()}finally{Ct=p}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(l,u,p,y){var M=u.current,A=ni(),O=ks(M);return p=y1(p),u.context===null?u.context=p:u.pendingContext=p,u=$r(A,O),u.payload={element:l},y=y===void 0?null:y,y!==null&&(u.callback=y),Is(M,u),l=qi(M,O,A),l!==null&&Af(l,M,O),O},t};(function(n){n.exports=DU})(N3);const NU=rC(N3.exports);var Xv={exports:{}},k3={};/** * @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(D,V){var B=D.length;D.push(V);e:for(;0>>1,Y=D[J];if(0>>1;Jr(ye,B))per(Q,ye)?(D[J]=Q,D[pe]=B,J=pe):(D[J]=ye,D[z]=B,J=z);else if(per(Q,B))D[J]=Q,D[pe]=B,J=pe;else break e}}return V}function r(D,V){var B=D.sortIndex-V.sortIndex;return B!==0?B:D.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var c=[],f=[],h=1,d=null,m=3,v=!1,_=!1,E=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(D){for(var V=t(f);V!==null;){if(V.callback===null)i(f);else if(V.startTime<=D)i(f),V.sortIndex=V.expirationTime,e(c,V);else break;V=t(f)}}function T(D){if(E=!1,w(D),!_)if(t(c)!==null)_=!0,oe(C);else{var V=t(f);V!==null&&ue(T,V.startTime-D)}}function C(D,V){_=!1,E&&(E=!1,g(I),I=-1),v=!0;var B=m;try{for(w(V),d=t(c);d!==null&&(!(d.expirationTime>V)||D&&!H());){var J=d.callback;if(typeof J=="function"){d.callback=null,m=d.priorityLevel;var Y=J(d.expirationTime<=V);V=n.unstable_now(),typeof Y=="function"?d.callback=Y:d===t(c)&&i(c),w(V)}else i(c);d=t(c)}if(d!==null)var K=!0;else{var z=t(f);z!==null&&ue(T,z.startTime-V),K=!1}return K}finally{d=null,m=B,v=!1}}var P=!1,R=null,I=-1,b=5,L=-1;function H(){return!(n.unstable_now()-LD||125J?(D.sortIndex=B,e(f,D),t(c)===null&&D===t(f)&&(E?(g(I),I=-1):E=!0,ue(T,B-J))):(D.sortIndex=Y,e(c,D),_||v||(_=!0,oe(C))),D},n.unstable_shouldYield=H,n.unstable_wrapCallback=function(D){var V=m;return function(){var B=m;m=V;try{return D.apply(this,arguments)}finally{m=B}}}})(k3);(function(n){n.exports=k3})(Xv);var Gp={exports:{}},Wp={};/** * @license React * react-jsx-runtime.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 kU=Te.exports,zU=Symbol.for("react.element"),UU=Symbol.for("react.fragment"),OU=Object.prototype.hasOwnProperty,FU=kU.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,BU={key:!0,ref:!0,__self:!0,__source:!0};function z3(n,e,t){var i,r={},s=null,o=null;t!==void 0&&(s=""+t),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(i in e)OU.call(e,i)&&!BU.hasOwnProperty(i)&&(r[i]=e[i]);if(n&&n.defaultProps)for(i in e=n.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:zU,type:n,key:s,ref:o,props:r,_owner:FU.current}}Wp.Fragment=UU;Wp.jsx=z3;Wp.jsxs=z3;(function(n){n.exports=Wp})(Gp);const L_=Gp.exports.Fragment,Gt=Gp.exports.jsx,Xp=Gp.exports.jsxs,R_={},VU=n=>void Object.assign(R_,n);function HU(n,e){function t(h,{args:d=[],attach:m,...v},_){let E=`${h[0].toUpperCase()}${h.slice(1)}`,S;if(h==="primitive"){if(v.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const g=v.object;S=sl(g,{type:h,root:_,attach:m,primitive:!0})}else{const g=R_[E];if(!g)throw new Error(`R3F: ${E} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(d))throw new Error("R3F: The args prop must be an array!");S=sl(new g(...d),{type:h,root:_,attach:m,memoizedProps:{args:d}})}return S.__r3f.attach===void 0&&(S instanceof lt?S.__r3f.attach="geometry":S instanceof Bn&&(S.__r3f.attach="material")),E!=="inject"&&o0(S,v),S}function i(h,d){let m=!1;if(d){var v,_;(v=d.__r3f)!=null&&v.attach?s0(h,d,d.__r3f.attach):d.isObject3D&&h.isObject3D&&(h.add(d),m=!0),m||(_=h.__r3f)==null||_.objects.push(d),d.__r3f||sl(d,{}),d.__r3f.parent=h,Yv(d),ol(d)}}function r(h,d,m){let v=!1;if(d){var _,E;if((_=d.__r3f)!=null&&_.attach)s0(h,d,d.__r3f.attach);else if(d.isObject3D&&h.isObject3D){d.parent=h,d.dispatchEvent({type:"added"});const S=h.children.filter(x=>x!==d),g=S.indexOf(m);h.children=[...S.slice(0,g),d,...S.slice(g)],v=!0}v||(E=h.__r3f)==null||E.objects.push(d),d.__r3f||sl(d,{}),d.__r3f.parent=h,Yv(d),ol(d)}}function s(h,d,m=!1){h&&[...h].forEach(v=>o(d,v,m))}function o(h,d,m){if(d){var v,_,E;if(d.__r3f&&(d.__r3f.parent=null),(v=h.__r3f)!=null&&v.objects&&(h.__r3f.objects=h.__r3f.objects.filter(T=>T!==d)),(_=d.__r3f)!=null&&_.attach)aM(h,d,d.__r3f.attach);else if(d.isObject3D&&h.isObject3D){var S;h.remove(d),(S=d.__r3f)!=null&&S.root&&ZU(d.__r3f.root,d)}const x=(E=d.__r3f)==null?void 0:E.primitive,w=m===void 0?d.dispose!==null&&!x:m;if(!x){var g;s((g=d.__r3f)==null?void 0:g.objects,d,w),s(d.children,d,w)}d.__r3f&&(delete d.__r3f.root,delete d.__r3f.objects,delete d.__r3f.handlers,delete d.__r3f.memoizedProps,x||delete d.__r3f),w&&d.dispose&&d.type!=="Scene"&&Xv.exports.unstable_scheduleCallback(Xv.exports.unstable_IdlePriority,()=>{try{d.dispose()}catch{}}),ol(h)}}function a(h,d,m,v){var _;const E=(_=h.__r3f)==null?void 0:_.parent;if(!E)return;const S=t(d,m,h.__r3f.root);if(h.children){for(const g of h.children)g.__r3f&&i(S,g);h.children=h.children.filter(g=>!g.__r3f)}h.__r3f.objects.forEach(g=>i(S,g)),h.__r3f.objects=[],h.__r3f.autoRemovedBeforeAppend||o(E,h),S.parent&&(S.__r3f.autoRemovedBeforeAppend=!0),i(E,S),S.raycast&&S.__r3f.eventCount&&S.__r3f.root.getState().internal.interaction.push(S),[v,v.alternate].forEach(g=>{g!==null&&(g.stateNode=S,g.ref&&(typeof g.ref=="function"?g.ref(S):g.ref.current=S))})}const c=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:NU({createInstance:t,removeChild:o,appendChild:i,appendInitialChild:i,insertBefore:r,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(h,d)=>{if(!d)return;const m=h.getState().scene;!m.__r3f||(m.__r3f.root=h,i(m,d))},removeChildFromContainer:(h,d)=>{!d||o(h.getState().scene,d)},insertInContainerBefore:(h,d,m)=>{if(!d||!m)return;const v=h.getState().scene;!v.__r3f||r(v,d,m)},getRootHostContext:()=>null,getChildHostContext:h=>h,finalizeInitialChildren(h){var d;const m=(d=h==null?void 0:h.__r3f)!=null?d:{};return Boolean(m.handlers)},prepareUpdate(h,d,m,v){if(h.__r3f.primitive&&v.object&&v.object!==h)return[!0];{const{args:_=[],children:E,...S}=v,{args:g=[],children:x,...w}=m;if(!Array.isArray(_))throw new Error("R3F: the args prop must be an array!");if(_.some((C,P)=>C!==g[P]))return[!0];const T=G3(h,S,w,!0);return T.changes.length?[!1,T]:null}},commitUpdate(h,[d,m],v,_,E,S){d?a(h,v,E,S):o0(h,m)},commitMount(h,d,m,v){var _;const E=(_=h.__r3f)!=null?_:{};h.raycast&&E.handlers&&E.eventCount&&h.__r3f.root.getState().internal.interaction.push(h)},getPublicInstance:h=>h,prepareForCommit:()=>null,preparePortalMount:h=>sl(h.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(h){var d;const{attach:m,parent:v}=(d=h.__r3f)!=null?d:{};m&&v&&aM(v,h,m),h.isObject3D&&(h.visible=!1),ol(h)},unhideInstance(h,d){var m;const{attach:v,parent:_}=(m=h.__r3f)!=null?m:{};v&&_&&s0(_,h,v),(h.isObject3D&&d.visible==null||d.visible)&&(h.visible=!0),ol(h)},createTextInstance:c,hideTextInstance:c,unhideTextInstance:c,getCurrentEventPriority:()=>e?e():Jo.exports.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&Zt.fun(performance.now)?performance.now:Zt.fun(Date.now)?Date.now:()=>0,scheduleTimeout:Zt.fun(setTimeout)?setTimeout:void 0,cancelTimeout:Zt.fun(clearTimeout)?clearTimeout:void 0}),applyProps:o0}}var iM,rM;const U3=()=>{var n;return(n=R_.ColorManagement)!=null?n:null},O3=n=>n&&n.isOrthographicCamera,GU=n=>n&&n.hasOwnProperty("current"),df=typeof window<"u"&&((iM=window.document)!=null&&iM.createElement||((rM=window.navigator)==null?void 0:rM.product)==="ReactNative")?Te.exports.useLayoutEffect:Te.exports.useEffect;function F3(n){const e=Te.exports.useRef(n);return df(()=>void(e.current=n),[n]),e}function WU({set:n}){return df(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}class B3 extends Te.exports.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}B3.getDerivedStateFromError=()=>({error:!0});const V3="__default",sM=new Map,XU=n=>n&&!!n.memoized&&!!n.changes;function H3(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 Ou=n=>{var e;return(e=n.__r3f)==null?void 0:e.root.getState()},Zt={obj:n=>n===Object(n)&&!Zt.arr(n)&&typeof n!="function",fun:n=>typeof n=="function",str:n=>typeof n=="string",num:n=>typeof n=="number",boo:n=>typeof n=="boolean",und:n=>n===void 0,arr:n=>Array.isArray(n),equ(n,e,{arrays:t="shallow",objects:i="reference",strict:r=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(Zt.str(n)||Zt.num(n))return n===e;const s=Zt.obj(n);if(s&&i==="reference")return n===e;const o=Zt.arr(n);if(o&&t==="reference")return n===e;if((o||s)&&n===e)return!0;let a;for(a in n)if(!(a in e))return!1;if(s&&t==="shallow"&&i==="shallow"){for(a in r?e:n)if(!Zt.equ(n[a],e[a],{strict:r,objects:"reference"}))return!1}else for(a in r?e:n)if(n[a]!==e[a])return!1;if(Zt.und(a)){if(o&&n.length===0&&e.length===0||s&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function jU(n){n.dispose&&n.type!=="Scene"&&n.dispose();for(const e in n)e.dispose==null||e.dispose(),delete n[e]}function sl(n,e){const t=n;return(e!=null&&e.primitive||!t.__r3f)&&(t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e}),n}function jv(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 oM=/-\d+$/;function s0(n,e,t){if(Zt.str(t)){if(oM.test(t)){const s=t.replace(oM,""),{target:o,key:a}=jv(n,s);Array.isArray(o[a])||(o[a]=[])}const{target:i,key:r}=jv(n,t);e.__r3f.previousAttach=i[r],i[r]=e}else e.__r3f.previousAttach=t(n,e)}function aM(n,e,t){var i,r;if(Zt.str(t)){const{target:s,key:o}=jv(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 G3(n,{children:e,key:t,ref:i,...r},{children:s,key:o,ref:a,...c}={},f=!1){var h;const d=(h=n==null?void 0:n.__r3f)!=null?h:{},m=Object.entries(r),v=[];if(f){const E=Object.keys(c);for(let S=0;S{var g;if((g=n.__r3f)!=null&&g.primitive&&E==="object"||Zt.equ(S,c[E]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(E))return v.push([E,S,!0,[]]);let x=[];E.includes("-")&&(x=E.split("-")),v.push([E,S,!1,x]);for(const w in r){const T=r[w];w.startsWith(`${E}-`)&&v.push([w,T,!1,w.split("-")])}});const _={...r};return d.memoizedProps&&d.memoizedProps.args&&(_.args=d.memoizedProps.args),d.memoizedProps&&d.memoizedProps.attach&&(_.attach=d.memoizedProps.attach),{memoized:_,changes:v}}function o0(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:c,changes:f}=XU(e)?e:G3(n,e),h=s.eventCount;n.__r3f&&(n.__r3f.memoizedProps=c);for(let m=0;mw[T],n),!(x&&x.set))){const[w,...T]=S.reverse();g=T.reverse().reduce((C,P)=>C[P],n),v=w}if(_===V3+"remove")if(g.constructor){let w=sM.get(g.constructor);w||(w=new g.constructor,sM.set(g.constructor,w)),_=w[v]}else _=0;if(E)_?s.handlers[v]=_:delete s.handlers[v],s.eventCount=Object.keys(s.handlers).length;else if(x&&x.set&&(x.copy||x instanceof ia)){if(Array.isArray(_))x.fromArray?x.fromArray(_):x.set(..._);else if(x.copy&&_&&_.constructor&&x.constructor===_.constructor)x.copy(_);else if(_!==void 0){const w=x instanceof Re;!w&&x.setScalar?x.setScalar(_):x instanceof ia&&_ instanceof ia?x.mask=_.mask:x.set(_),!U3()&&!a.linear&&w&&x.convertSRGBToLinear()}}else g[v]=_,!a.linear&&g[v]instanceof un&&g[v].format===_i&&g[v].type===Es&&(g[v].encoding=Ot);ol(n)}if(s.parent&&a.internal&&n.raycast&&h!==s.eventCount){const m=a.internal.interaction.indexOf(n);m>-1&&a.internal.interaction.splice(m,1),s.eventCount&&a.internal.interaction.push(n)}return!(f.length===1&&f[0][0]==="onUpdate")&&f.length&&(r=n.__r3f)!=null&&r.parent&&Yv(n),n}function ol(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 Yv(n){n.onUpdate==null||n.onUpdate(n)}function YU(n,e){n.manual||(O3(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 pd(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function qU(){var n;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return Jo.exports.DefaultEventPriority;switch((n=e.event)==null?void 0:n.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Jo.exports.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Jo.exports.ContinuousEventPriority;default:return Jo.exports.DefaultEventPriority}}function W3(n,e,t,i){const r=t.get(e);r&&(t.delete(e),t.size===0&&(n.delete(i),r.target.releasePointerCapture(i)))}function ZU(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)=>{W3(t.capturedMap,e,i,r)})}function QU(n){function e(c){const{internal:f}=n.getState(),h=c.offsetX-f.initialClick[0],d=c.offsetY-f.initialClick[1];return Math.round(Math.sqrt(h*h+d*d))}function t(c){return c.filter(f=>["Move","Over","Enter","Out","Leave"].some(h=>{var d;return(d=f.__r3f)==null?void 0:d.handlers["onPointer"+h]}))}function i(c,f){const h=n.getState(),d=new Set,m=[],v=f?f(h.internal.interaction):h.internal.interaction;for(let g=0;g{const w=Ou(g.object),T=Ou(x.object);return!w||!T?g.distance-x.distance:T.events.priority-w.events.priority||g.distance-x.distance}).filter(g=>{const x=pd(g);return d.has(x)?!1:(d.add(x),!0)});h.events.filter&&(E=h.events.filter(E,h));for(const g of E){let x=g.object;for(;x;){var S;(S=x.__r3f)!=null&&S.eventCount&&m.push({...g,eventObject:x}),x=x.parent}}if("pointerId"in c&&h.internal.capturedMap.has(c.pointerId))for(let g of h.internal.capturedMap.get(c.pointerId).values())d.has(pd(g.intersection))||m.push(g.intersection);return m}function r(c,f,h,d){const m=n.getState();if(c.length){const v={stopped:!1};for(const _ of c){const E=Ou(_.object)||m,{raycaster:S,pointer:g,camera:x,internal:w}=E,T=new N(g.x,g.y,0).unproject(x),C=L=>{var H,q;return(H=(q=w.capturedMap.get(L))==null?void 0:q.has(_.eventObject))!=null?H:!1},P=L=>{const H={intersection:_,target:f.target};w.capturedMap.has(L)?w.capturedMap.get(L).set(_.eventObject,H):w.capturedMap.set(L,new Map([[_.eventObject,H]])),f.target.setPointerCapture(L)},R=L=>{const H=w.capturedMap.get(L);H&&W3(w.capturedMap,_.eventObject,H,L)};let I={};for(let L in f){let H=f[L];typeof H!="function"&&(I[L]=H)}let b={..._,...I,pointer:g,intersections:c,stopped:v.stopped,delta:h,unprojectedPoint:T,ray:S.ray,camera:x,stopPropagation(){const L="pointerId"in f&&w.capturedMap.get(f.pointerId);if((!L||L.has(_.eventObject))&&(b.stopped=v.stopped=!0,w.hovered.size&&Array.from(w.hovered.values()).find(H=>H.eventObject===_.eventObject))){const H=c.slice(0,c.indexOf(_));s([...H,_])}},target:{hasPointerCapture:C,setPointerCapture:P,releasePointerCapture:R},currentTarget:{hasPointerCapture:C,setPointerCapture:P,releasePointerCapture:R},nativeEvent:f};if(d(b),v.stopped===!0)break}}return c}function s(c){const{internal:f}=n.getState();for(const h of f.hovered.values())if(!c.length||!c.find(d=>d.object===h.object&&d.index===h.index&&d.instanceId===h.instanceId)){const m=h.eventObject.__r3f,v=m==null?void 0:m.handlers;if(f.hovered.delete(pd(h)),m!=null&&m.eventCount){const _={...h,intersections:c};v.onPointerOut==null||v.onPointerOut(_),v.onPointerLeave==null||v.onPointerLeave(_)}}}function o(c,f){for(let h=0;hs([]);case"onLostPointerCapture":return f=>{const{internal:h}=n.getState();"pointerId"in f&&h.capturedMap.has(f.pointerId)&&requestAnimationFrame(()=>{h.capturedMap.has(f.pointerId)&&(h.capturedMap.delete(f.pointerId),s([]))})}}return function(h){const{onPointerMissed:d,internal:m}=n.getState();m.lastEvent.current=h;const v=c==="onPointerMove",_=c==="onClick"||c==="onContextMenu"||c==="onDoubleClick",S=i(h,v?t:void 0),g=_?e(h):0;c==="onPointerDown"&&(m.initialClick=[h.offsetX,h.offsetY],m.initialHits=S.map(w=>w.eventObject)),_&&!S.length&&g<=2&&(o(h,m.interaction),d&&d(h)),v&&s(S);function x(w){const T=w.eventObject,C=T.__r3f,P=C==null?void 0:C.handlers;if(!!(C!=null&&C.eventCount))if(v){if(P.onPointerOver||P.onPointerEnter||P.onPointerOut||P.onPointerLeave){const R=pd(w),I=m.hovered.get(R);I?I.stopped&&w.stopPropagation():(m.hovered.set(R,w),P.onPointerOver==null||P.onPointerOver(w),P.onPointerEnter==null||P.onPointerEnter(w))}P.onPointerMove==null||P.onPointerMove(w)}else{const R=P[c];R?(!_||m.initialHits.includes(T))&&(o(h,m.interaction.filter(I=>!m.initialHits.includes(I))),R(w)):_&&m.initialHits.includes(T)&&o(h,m.interaction.filter(I=>!m.initialHits.includes(I)))}}r(S,h,g,x)}}return{handlePointer:a}}const X3=n=>!!(n!=null&&n.render),j3=Te.exports.createContext(null),JU=(n,e)=>{const t=LU((a,c)=>{const f=new N,h=new N,d=new N;function m(g=c().camera,x=h,w=c().size){const{width:T,height:C,top:P,left:R}=w,I=T/C;x instanceof N?d.copy(x):d.set(...x);const b=g.getWorldPosition(f).distanceTo(d);if(O3(g))return{width:T/g.zoom,height:C/g.zoom,top:P,left:R,factor:1,distance:b,aspect:I};{const L=g.fov*Math.PI/180,H=2*Math.tan(L/2)*b,q=H*(T/C);return{width:q,height:H,top:P,left:R,factor:T/q,distance:b,aspect:I}}}let v;const _=g=>a(x=>({performance:{...x.performance,current:g}})),E=new ge;return{set:a,get:c,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(g=1)=>n(c(),g),advance:(g,x)=>e(g,x,c()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new T_,pointer:E,mouse:E,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const g=c();v&&clearTimeout(v),g.performance.current!==g.performance.min&&_(g.performance.min),v=setTimeout(()=>_(c().performance.max),g.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:m},setEvents:g=>a(x=>({...x,events:{...x.events,...g}})),setSize:(g,x,w,T,C)=>{const P=c().camera,R={width:g,height:x,top:T||0,left:C||0,updateStyle:w};a(I=>({size:R,viewport:{...I.viewport,...m(P,h,R)}}))},setDpr:g=>a(x=>{const w=H3(g);return{viewport:{...x.viewport,dpr:w,initialDpr:x.viewport.initialDpr||w}}}),setFrameloop:(g="always")=>{const x=c().clock;x.stop(),x.elapsedTime=0,g!=="never"&&(x.start(),x.elapsedTime=0),a(()=>({frameloop:g}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:Te.exports.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(g,x,w)=>{const T=c().internal;return T.priority=T.priority+(x>0?1:0),T.subscribers.push({ref:g,priority:x,store:w}),T.subscribers=T.subscribers.sort((C,P)=>C.priority-P.priority),()=>{const C=c().internal;C!=null&&C.subscribers&&(C.priority=C.priority-(x>0?1:0),C.subscribers=C.subscribers.filter(P=>P.ref!==g))}}}}}),i=t.getState();let r=i.size,s=i.viewport.dpr,o=i.camera;return t.subscribe(()=>{const{camera:a,size:c,viewport:f,gl:h,set:d}=t.getState();if(c!==r||f.dpr!==s){var m;r=c,s=f.dpr,YU(a,c),h.setPixelRatio(f.dpr);const v=(m=c.updateStyle)!=null?m:typeof HTMLCanvasElement<"u"&&h.domElement instanceof HTMLCanvasElement;h.setSize(c.width,c.height,v)}a!==o&&(o=a,d(v=>({viewport:{...v.viewport,...v.viewport.getCurrentViewport(a)}})))}),t.subscribe(a=>n(a)),t};let md,KU=new Set,$U=new Set,e4=new Set;function a0(n,e){if(!!n.size)for(const{callback:t}of n.values())t(e)}function Fu(n,e){switch(n){case"before":return a0(KU,e);case"after":return a0($U,e);case"tail":return a0(e4,e)}}let l0,u0;function c0(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),l0=e.internal.subscribers,md=0;md0)&&!((f=r.gl.xr)!=null&&f.isPresenting)&&(t+=c0(c,r))}if(Fu("after",c),t===0)return Fu("tail",c),e=!1,cancelAnimationFrame(i)}function o(c,f=1){var h;if(!c)return n.forEach(d=>o(d.store.getState()),f);(h=c.gl.xr)!=null&&h.isPresenting||!c.internal.active||c.frameloop==="never"||(c.internal.frames=Math.min(60,c.internal.frames+f),e||(e=!0,requestAnimationFrame(s)))}function a(c,f=!0,h,d){if(f&&Fu("before",c),h)c0(c,h,d);else for(const m of n.values())c0(c,m.store.getState());f&&Fu("after",c)}return{loop:s,invalidate:o,advance:a}}function Y3(){const n=Te.exports.useContext(j3);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function $i(n=t=>t,e){return Y3()(n,e)}function n4(n,e=0){const t=Y3(),i=t.getState().internal.subscribe,r=F3(n);return df(()=>i(r,e,t),[e,i,t]),null}const Hl=new Map,{invalidate:lM,advance:uM}=t4(Hl),{reconciler:cp,applyProps:Bu}=HU(Hl,qU),rl={objects:"shallow",strict:!1},i4=(n,e)=>{const t=typeof n=="function"?n(e):n;return X3(t)?t:new o_({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...n})};function r4(n,e){if(e)return e;if(typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:t,height:i,top:r,left:s}=n.parentElement.getBoundingClientRect();return{width:t,height:i,top:r,left:s}}else if(typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height,top:0,left:0};return{width:0,height:0,top:0,left:0}}function s4(n){const e=Hl.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||JU(lM,uM),o=t||cp.createContainer(s,Jo.exports.ConcurrentRoot,null,!1,null,"",r,null);e||Hl.set(n,{fiber:o,store:s});let a,c=!1,f;return{configure(h={}){let{gl:d,size:m,scene:v,events:_,onCreated:E,shadows:S=!1,linear:g=!1,flat:x=!1,legacy:w=!1,orthographic:T=!1,frameloop:C="always",dpr:P=[1,2],performance:R,raycaster:I,camera:b,onPointerMissed:L}=h,H=s.getState(),q=H.gl;H.gl||H.set({gl:q=i4(d,n)});let G=H.raycaster;G||H.set({raycaster:G=new P_});const{params:W,...ee}=I||{};if(Zt.equ(ee,G,rl)||Bu(G,{...ee}),Zt.equ(W,G.params,rl)||Bu(G,{params:{...G.params,...W}}),!H.camera||H.camera===f&&!Zt.equ(f,b,rl)){f=b;const J=b instanceof Jc,Y=J?b:T?new $c(0,0,0,0,.1,1e3):new In(75,0,.1,1e3);J||(Y.position.z=5,b&&Bu(Y,b),!H.camera&&!(b!=null&&b.rotation)&&Y.lookAt(0,0,0)),H.set({camera:Y})}if(!H.scene){let J;v instanceof up?J=v:(J=new up,v&&Bu(J,v)),H.set({scene:sl(J)})}if(!H.xr){const J=(z,ye)=>{const pe=s.getState();pe.frameloop!=="never"&&uM(z,!0,pe,ye)},Y=()=>{const z=s.getState();z.gl.xr.enabled=z.gl.xr.isPresenting,z.gl.xr.setAnimationLoop(z.gl.xr.isPresenting?J:null),z.gl.xr.isPresenting||lM(z)},K={connect(){const z=s.getState().gl;z.xr.addEventListener("sessionstart",Y),z.xr.addEventListener("sessionend",Y)},disconnect(){const z=s.getState().gl;z.xr.removeEventListener("sessionstart",Y),z.xr.removeEventListener("sessionend",Y)}};q.xr&&K.connect(),H.set({xr:K})}if(q.shadowMap){const J=q.shadowMap.enabled,Y=q.shadowMap.type;if(q.shadowMap.enabled=!!S,Zt.boo(S))q.shadowMap.type=ic;else if(Zt.str(S)){var oe;const K={basic:NT,percentage:bp,soft:ic,variance:jo};q.shadowMap.type=(oe=K[S])!=null?oe:ic}else Zt.obj(S)&&Object.assign(q.shadowMap,S);(J!==q.shadowMap.enabled||Y!==q.shadowMap.type)&&(q.shadowMap.needsUpdate=!0)}const ue=U3();ue&&("enabled"in ue?ue.enabled=!w:"legacyMode"in ue&&(ue.legacyMode=w));const D=g?Ts:Ot,V=x?Ar:jy;q.outputEncoding!==D&&(q.outputEncoding=D),q.toneMapping!==V&&(q.toneMapping=V),H.legacy!==w&&H.set(()=>({legacy:w})),H.linear!==g&&H.set(()=>({linear:g})),H.flat!==x&&H.set(()=>({flat:x})),d&&!Zt.fun(d)&&!X3(d)&&!Zt.equ(d,q,rl)&&Bu(q,d),_&&!H.events.handlers&&H.set({events:_(s)});const B=r4(n,m);return Zt.equ(B,H.size,rl)||H.setSize(B.width,B.height,B.updateStyle,B.top,B.left),P&&H.viewport.dpr!==H3(P)&&H.setDpr(P),H.frameloop!==C&&H.setFrameloop(C),H.onPointerMissed||H.set({onPointerMissed:L}),R&&!Zt.equ(R,H.performance,rl)&&H.set(J=>({performance:{...J.performance,...R}})),a=E,c=!0,this},render(h){return c||this.configure(),cp.updateContainer(Gt(o4,{store:s,children:h,onCreated:a,rootElement:n}),o,null,()=>{}),s},unmount(){q3(n)}}}function o4({store:n,children:e,onCreated:t,rootElement:i}){return df(()=>{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)},[]),Te.exports.createElement(j3.Provider,{value:n},e)}function q3(n,e){const t=Hl.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),cp.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{var s,o,a,c;r.events.disconnect==null||r.events.disconnect(),(s=r.gl)==null||(o=s.renderLists)==null||o.dispose==null||o.dispose(),(a=r.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(c=r.gl)!=null&&c.xr&&r.xr.disconnect(),jU(r),Hl.delete(n),e&&e(n)}catch{}},500)})}}cp.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:Te.exports.version});function qv(n,e,t){var i,r,s,o,a;e==null&&(e=100);function c(){var h=Date.now()-o;h=0?i=setTimeout(c,e-h):(i=null,t||(a=n.apply(s,r),s=r=null))}var f=function(){s=this,r=arguments,o=Date.now();var h=t&&!i;return i||(i=setTimeout(c,e)),h&&(a=n.apply(s,r),s=r=null),a};return f.clear=function(){i&&(clearTimeout(i),i=null)},f.flush=function(){i&&(a=n.apply(s,r),s=r=null,clearTimeout(i),i=null)},f}qv.debounce=qv;var cM=qv;function a4(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]=Te.exports.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),c=Te.exports.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:o}),f=e?typeof e=="number"?e:e.scroll:null,h=e?typeof e=="number"?e:e.resize:null,d=Te.exports.useRef(!1);Te.exports.useEffect(()=>(d.current=!0,()=>void(d.current=!1)));const[m,v,_]=Te.exports.useMemo(()=>{const x=()=>{if(!c.current.element)return;const{left:w,top:T,width:C,height:P,bottom:R,right:I,x:b,y:L}=c.current.element.getBoundingClientRect(),H={left:w,top:T,width:C,height:P,bottom:R,right:I,x:b,y:L};c.current.element instanceof HTMLElement&&r&&(H.height=c.current.element.offsetHeight,H.width=c.current.element.offsetWidth),Object.freeze(H),d.current&&!f4(c.current.lastBounds,H)&&a(c.current.lastBounds=H)};return[x,h?cM(x,h):x,f?cM(x,f):x]},[a,r,f,h]);function E(){c.current.scrollContainers&&(c.current.scrollContainers.forEach(x=>x.removeEventListener("scroll",_,!0)),c.current.scrollContainers=null),c.current.resizeObserver&&(c.current.resizeObserver.disconnect(),c.current.resizeObserver=null)}function S(){!c.current.element||(c.current.resizeObserver=new s(_),c.current.resizeObserver.observe(c.current.element),t&&c.current.scrollContainers&&c.current.scrollContainers.forEach(x=>x.addEventListener("scroll",_,{capture:!0,passive:!0})))}const g=x=>{!x||x===c.current.element||(E(),c.current.element=x,c.current.scrollContainers=Z3(x),S())};return u4(_,Boolean(t)),l4(v),Te.exports.useEffect(()=>{E(),S()},[t,_,v]),Te.exports.useEffect(()=>E,[]),[g,o,m]}function l4(n){Te.exports.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[n])}function u4(n,e){Te.exports.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[n,e])}function Z3(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,...Z3(n.parentElement)]}const c4=["x","y","top","bottom","left","right","width","height"],f4=(n,e)=>c4.every(t=>n[t]===e[t]);var h4=Object.defineProperty,d4=Object.defineProperties,p4=Object.getOwnPropertyDescriptors,fM=Object.getOwnPropertySymbols,m4=Object.prototype.hasOwnProperty,g4=Object.prototype.propertyIsEnumerable,hM=(n,e,t)=>e in n?h4(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,dM=(n,e)=>{for(var t in e||(e={}))m4.call(e,t)&&hM(n,t,e[t]);if(fM)for(var t of fM(e))g4.call(e,t)&&hM(n,t,e[t]);return n},v4=(n,e)=>d4(n,p4(e));function Q3(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=e?n.return:n.child;for(;i;){const r=Q3(i,e,t);if(r)return r;i=e?null:i.sibling}}function J3(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const I_=J3(Te.exports.createContext(null));class K3 extends Te.exports.Component{render(){return Gt(I_.Provider,{value:this._reactInternals,children:this.props.children})}}const{ReactCurrentOwner:pM,ReactCurrentDispatcher:mM}=Te.exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y4(){const n=Te.exports.useContext(I_);if(n===null)throw new Error("its-fine: useFiber must be called within a !");const e=Te.exports.useId();return Te.exports.useMemo(()=>{var i;return(i=pM==null?void 0:pM.current)!=null?i:Q3(n,!1,r=>{let s=r.memoizedState;for(;s;){if(s.memoizedState===e)return!0;s=s.next}})},[n,e])}function _4(){var n,e;const t=y4(),[i]=Te.exports.useState(()=>new Map);i.clear();let r=t;for(;r;){const s=(n=r.type)==null?void 0:n._context;s&&s!==I_&&!i.has(s)&&i.set(s,(e=mM==null?void 0:mM.current)==null?void 0:e.readContext(J3(s))),r=r.return}return i}function x4(){const n=_4();return Te.exports.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>Te.exports.createElement(e,null,Te.exports.createElement(t.Provider,v4(dM({},i),{value:n.get(t)}))),e=>Gt(K3,{...dM({},e)})),[n])}const f0={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 S4(n){const{handlePointer:e}=QU(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(f0).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:r}=n.getState();(t=r.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{var i;const{set:r,events:s}=n.getState();s.disconnect==null||s.disconnect(),r(o=>({events:{...o.events,connected:t}})),Object.entries((i=s.handlers)!=null?i:[]).forEach(([o,a])=>{const[c,f]=f0[o];t.addEventListener(c,a,{passive:f})})},disconnect:()=>{const{set:t,events:i}=n.getState();if(i.connected){var r;Object.entries((r=i.handlers)!=null?r:[]).forEach(([s,o])=>{if(i&&i.connected instanceof HTMLElement){const[a]=f0[s];i.connected.removeEventListener(a,o)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}const w4=Te.exports.forwardRef(function({children:e,fallback:t,resize:i,style:r,gl:s,events:o=S4,eventSource:a,eventPrefix:c,shadows:f,linear:h,flat:d,legacy:m,orthographic:v,frameloop:_,dpr:E,performance:S,raycaster:g,camera:x,onPointerMissed:w,onCreated:T,...C},P){Te.exports.useMemo(()=>VU(CU),[]);const R=x4(),[I,b]=a4({scroll:!0,debounce:{scroll:50,resize:0},...i}),L=Te.exports.useRef(null),H=Te.exports.useRef(null);Te.exports.useImperativeHandle(P,()=>L.current);const q=F3(w),[G,W]=Te.exports.useState(!1),[ee,oe]=Te.exports.useState(!1);if(G)throw G;if(ee)throw ee;const ue=Te.exports.useRef(null);return df(()=>{const V=L.current;b.width>0&&b.height>0&&V&&(ue.current||(ue.current=s4(V)),ue.current.configure({gl:s,events:o,shadows:f,linear:h,flat:d,legacy:m,orthographic:v,frameloop:_,dpr:E,performance:S,raycaster:g,camera:x,size:b,onPointerMissed:(...B)=>q.current==null?void 0:q.current(...B),onCreated:B=>{B.events.connect==null||B.events.connect(a?GU(a)?a.current:a:H.current),c&&B.setEvents({compute:(J,Y)=>{const K=J[c+"X"],z=J[c+"Y"];Y.pointer.set(K/Y.size.width*2-1,-(z/Y.size.height)*2+1),Y.raycaster.setFromCamera(Y.pointer,Y.camera)}}),T==null||T(B)}}),ue.current.render(Gt(R,{children:Gt(B3,{set:oe,children:Gt(Te.exports.Suspense,{fallback:Gt(WU,{set:W}),children:e})})})))}),Te.exports.useEffect(()=>{const V=L.current;if(V)return()=>q3(V)},[]),Gt("div",{ref:H,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:a?"none":"auto",...r},...C,children:Gt("div",{ref:I,style:{width:"100%",height:"100%"},children:Gt("canvas",{ref:L,style:{display:"block"},children:t})})})}),M4=Te.exports.forwardRef(function(e,t){return Gt(K3,{children:Gt(w4,{...e,ref:t})})});function E4(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}function Hc(n){return Hc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hc(n)}function T4(n,e){if(Hc(n)!=="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e||"default");if(Hc(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function A4(n){var e=T4(n,"string");return Hc(e)==="symbol"?e:String(e)}function le(n,e,t){return e=A4(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}class C4 extends St{constructor(e,t){super(),le(this,"isTransformControls",!0),le(this,"visible",!1),le(this,"domElement",void 0),le(this,"raycaster",new P_),le(this,"gizmo",void 0),le(this,"plane",void 0),le(this,"tempVector",new N),le(this,"tempVector2",new N),le(this,"tempQuaternion",new It),le(this,"unit",{X:new N(1,0,0),Y:new N(0,1,0),Z:new N(0,0,1)}),le(this,"pointStart",new N),le(this,"pointEnd",new N),le(this,"offset",new N),le(this,"rotationAxis",new N),le(this,"startNorm",new N),le(this,"endNorm",new N),le(this,"rotationAngle",0),le(this,"cameraPosition",new N),le(this,"cameraQuaternion",new It),le(this,"cameraScale",new N),le(this,"parentPosition",new N),le(this,"parentQuaternion",new It),le(this,"parentQuaternionInv",new It),le(this,"parentScale",new N),le(this,"worldPositionStart",new N),le(this,"worldQuaternionStart",new It),le(this,"worldScaleStart",new N),le(this,"worldPosition",new N),le(this,"worldQuaternion",new It),le(this,"worldQuaternionInv",new It),le(this,"worldScale",new N),le(this,"eye",new N),le(this,"positionStart",new N),le(this,"quaternionStart",new It),le(this,"scaleStart",new N),le(this,"camera",void 0),le(this,"object",void 0),le(this,"enabled",!0),le(this,"axis",null),le(this,"mode","translate"),le(this,"translationSnap",null),le(this,"rotationSnap",null),le(this,"scaleSnap",null),le(this,"space","world"),le(this,"size",1),le(this,"dragging",!1),le(this,"showX",!0),le(this,"showY",!0),le(this,"showZ",!0),le(this,"changeEvent",{type:"change"}),le(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),le(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),le(this,"objectChangeEvent",{type:"objectChange"}),le(this,"intersectObjectWithRay",(r,s,o)=>{const a=s.intersectObject(r,!0);for(let c=0;c(this.object=r,this.visible=!0,this)),le(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),le(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),le(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),le(this,"pointerHover",r=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(r,this.camera);const s=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);s?this.axis=s.object.name:this.axis=null}),le(this,"pointerDown",r=>{if(!(this.object===void 0||this.dragging===!0||r.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(r,this.camera);const s=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(s){let o=this.space;if(this.mode==="scale"?o="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(o="world"),o==="local"&&this.mode==="rotate"){const a=this.rotationSnap;this.axis==="X"&&a&&(this.object.rotation.x=Math.round(this.object.rotation.x/a)*a),this.axis==="Y"&&a&&(this.object.rotation.y=Math.round(this.object.rotation.y/a)*a),this.axis==="Z"&&a&&(this.object.rotation.z=Math.round(this.object.rotation.z/a)*a)}this.object.updateMatrixWorld(),this.object.parent&&this.object.parent.updateMatrixWorld(),this.positionStart.copy(this.object.position),this.quaternionStart.copy(this.object.quaternion),this.scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.worldScaleStart),this.pointStart.copy(s.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),le(this,"pointerMove",r=>{const s=this.axis,o=this.mode,a=this.object;let c=this.space;if(o==="scale"?c="local":(s==="E"||s==="XYZE"||s==="XYZ")&&(c="world"),a===void 0||s===null||this.dragging===!1||r.button!==-1)return;this.raycaster.setFromCamera(r,this.camera);const f=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(!!f){if(this.pointEnd.copy(f.point).sub(this.worldPositionStart),o==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),c==="local"&&s!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),s.indexOf("X")===-1&&(this.offset.x=0),s.indexOf("Y")===-1&&(this.offset.y=0),s.indexOf("Z")===-1&&(this.offset.z=0),c==="local"&&s!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),a.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(c==="local"&&(a.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),s.search("X")!==-1&&(a.position.x=Math.round(a.position.x/this.translationSnap)*this.translationSnap),s.search("Y")!==-1&&(a.position.y=Math.round(a.position.y/this.translationSnap)*this.translationSnap),s.search("Z")!==-1&&(a.position.z=Math.round(a.position.z/this.translationSnap)*this.translationSnap),a.position.applyQuaternion(this.quaternionStart)),c==="world"&&(a.parent&&a.position.add(this.tempVector.setFromMatrixPosition(a.parent.matrixWorld)),s.search("X")!==-1&&(a.position.x=Math.round(a.position.x/this.translationSnap)*this.translationSnap),s.search("Y")!==-1&&(a.position.y=Math.round(a.position.y/this.translationSnap)*this.translationSnap),s.search("Z")!==-1&&(a.position.z=Math.round(a.position.z/this.translationSnap)*this.translationSnap),a.parent&&a.position.sub(this.tempVector.setFromMatrixPosition(a.parent.matrixWorld))));else if(o==="scale"){if(s.search("XYZ")!==-1){let h=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(h*=-1),this.tempVector2.set(h,h,h)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),s.search("X")===-1&&(this.tempVector2.x=1),s.search("Y")===-1&&(this.tempVector2.y=1),s.search("Z")===-1&&(this.tempVector2.z=1);a.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(s.search("X")!==-1&&(this.object.scale.x=Math.round(a.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),s.search("Y")!==-1&&(a.scale.y=Math.round(a.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),s.search("Z")!==-1&&(a.scale.z=Math.round(a.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(o==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const h=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));s==="E"?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.startNorm.copy(this.pointStart).normalize(),this.endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this.endNorm.cross(this.startNorm).dot(this.eye)<0?1:-1):s==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*h):(s==="X"||s==="Y"||s==="Z")&&(this.rotationAxis.copy(this.unit[s]),this.tempVector.copy(this.unit[s]),c==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*h),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),c==="local"&&s!=="E"&&s!=="XYZE"?(a.quaternion.copy(this.quaternionStart),a.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),a.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),a.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),le(this,"pointerUp",r=>{r.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),le(this,"getPointer",r=>{var s;if(this.domElement&&(s=this.domElement.ownerDocument)!==null&&s!==void 0&&s.pointerLockElement)return{x:0,y:0,button:r.button};{var o;const a=r.changedTouches?r.changedTouches[0]:r,c=(o=this.domElement)===null||o===void 0?void 0:o.getBoundingClientRect();return{x:(a.clientX-c.left)/c.width*2-1,y:-(a.clientY-c.top)/c.height*2+1,button:r.button}}}),le(this,"onPointerHover",r=>{if(!!this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(r));break}}),le(this,"onPointerDown",r=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(r)),this.pointerDown(this.getPointer(r)))}),le(this,"onPointerMove",r=>{!this.enabled||this.pointerMove(this.getPointer(r))}),le(this,"onPointerUp",r=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(r)))}),le(this,"getMode",()=>this.mode),le(this,"setMode",r=>{this.mode=r}),le(this,"setTranslationSnap",r=>{this.translationSnap=r}),le(this,"setRotationSnap",r=>{this.rotationSnap=r}),le(this,"setScaleSnap",r=>{this.scaleSnap=r}),le(this,"setSize",r=>{this.size=r}),le(this,"setSpace",r=>{this.space=r}),le(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),le(this,"connect",r=>{r===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=r,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),le(this,"dispose",()=>{var r,s,o,a,c,f;(r=this.domElement)===null||r===void 0||r.removeEventListener("pointerdown",this.onPointerDown),(s=this.domElement)===null||s===void 0||s.removeEventListener("pointermove",this.onPointerHover),(o=this.domElement)===null||o===void 0||(a=o.ownerDocument)===null||a===void 0||a.removeEventListener("pointermove",this.onPointerMove),(c=this.domElement)===null||c===void 0||(f=c.ownerDocument)===null||f===void 0||f.removeEventListener("pointerup",this.onPointerUp),this.traverse(h=>{const d=h;d.geometry&&d.geometry.dispose(),d.material&&d.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new b4,this.add(this.gizmo),this.plane=new P4,this.add(this.plane);const i=(r,s)=>{let o=s;Object.defineProperty(this,r,{get:function(){return o!==void 0?o:s},set:function(a){o!==a&&(o=a,this.plane[r]=a,this.gizmo[r]=a,this.dispatchEvent({type:r+"-changed",value:a}),this.dispatchEvent(this.changeEvent))}}),this[r]=s,this.plane[r]=s,this.gizmo[r]=s};i("camera",this.camera),i("object",this.object),i("enabled",this.enabled),i("axis",this.axis),i("mode",this.mode),i("translationSnap",this.translationSnap),i("rotationSnap",this.rotationSnap),i("scaleSnap",this.scaleSnap),i("space",this.space),i("size",this.size),i("dragging",this.dragging),i("showX",this.showX),i("showY",this.showY),i("showZ",this.showZ),i("worldPosition",this.worldPosition),i("worldPositionStart",this.worldPositionStart),i("worldQuaternion",this.worldQuaternion),i("worldQuaternionStart",this.worldQuaternionStart),i("cameraPosition",this.cameraPosition),i("cameraQuaternion",this.cameraQuaternion),i("pointStart",this.pointStart),i("pointEnd",this.pointEnd),i("rotationAxis",this.rotationAxis),i("rotationAngle",this.rotationAngle),i("eye",this.eye),t!==void 0&&this.connect(t)}}class b4 extends St{constructor(){super(),le(this,"isTransformControlsGizmo",!0),le(this,"type","TransformControlsGizmo"),le(this,"tempVector",new N(0,0,0)),le(this,"tempEuler",new Yl),le(this,"alignVector",new N(0,1,0)),le(this,"zeroVector",new N(0,0,0)),le(this,"lookAtMatrix",new st),le(this,"tempQuaternion",new It),le(this,"tempQuaternion2",new It),le(this,"identityQuaternion",new It),le(this,"unitX",new N(1,0,0)),le(this,"unitY",new N(0,1,0)),le(this,"unitZ",new N(0,0,1)),le(this,"gizmo",void 0),le(this,"picker",void 0),le(this,"helper",void 0),le(this,"rotationAxis",new N),le(this,"cameraPosition",new N),le(this,"worldPositionStart",new N),le(this,"worldQuaternionStart",new It),le(this,"worldPosition",new N),le(this,"worldQuaternion",new It),le(this,"eye",new N),le(this,"camera",null),le(this,"enabled",!0),le(this,"axis",null),le(this,"mode","translate"),le(this,"space","world"),le(this,"size",1),le(this,"dragging",!1),le(this,"showX",!0),le(this,"showY",!0),le(this,"showZ",!0),le(this,"updateMatrixWorld",()=>{let B=this.space;this.mode==="scale"&&(B="local");const J=B==="local"?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let Y=[];Y=Y.concat(this.picker[this.mode].children),Y=Y.concat(this.gizmo[this.mode].children),Y=Y.concat(this.helper[this.mode].children);for(let K=0;K.9&&(z.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),z.quaternion.copy(J).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(J).dot(this.eye))>.9&&(z.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),z.quaternion.copy(J).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(J).dot(this.eye))>.9&&(z.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),z.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),z.quaternion.multiply(this.tempQuaternion),z.visible=this.dragging),this.axis==="E"&&(z.visible=!1)):z.name==="START"?(z.position.copy(this.worldPositionStart),z.visible=this.dragging):z.name==="END"?(z.position.copy(this.worldPosition),z.visible=this.dragging):z.name==="DELTA"?(z.position.copy(this.worldPositionStart),z.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),z.scale.copy(this.tempVector),z.visible=this.dragging):(z.quaternion.copy(J),this.dragging?z.position.copy(this.worldPositionStart):z.position.copy(this.worldPosition),this.axis&&(z.visible=this.axis.search(z.name)!==-1));continue}z.quaternion.copy(J),this.mode==="translate"||this.mode==="scale"?((z.name==="X"||z.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(J).dot(this.eye))>.99&&(z.scale.set(1e-10,1e-10,1e-10),z.visible=!1),(z.name==="Y"||z.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(J).dot(this.eye))>.99&&(z.scale.set(1e-10,1e-10,1e-10),z.visible=!1),(z.name==="Z"||z.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(J).dot(this.eye))>.99&&(z.scale.set(1e-10,1e-10,1e-10),z.visible=!1),z.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(J).dot(this.eye))<.2&&(z.scale.set(1e-10,1e-10,1e-10),z.visible=!1),z.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(J).dot(this.eye))<.2&&(z.scale.set(1e-10,1e-10,1e-10),z.visible=!1),z.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(J).dot(this.eye))<.2&&(z.scale.set(1e-10,1e-10,1e-10),z.visible=!1),z.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(J).dot(this.eye)<0?z.tag==="fwd"?z.visible=!1:z.scale.x*=-1:z.tag==="bwd"&&(z.visible=!1)),z.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(J).dot(this.eye)<0?z.tag==="fwd"?z.visible=!1:z.scale.y*=-1:z.tag==="bwd"&&(z.visible=!1)),z.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(J).dot(this.eye)<0?z.tag==="fwd"?z.visible=!1:z.scale.z*=-1:z.tag==="bwd"&&(z.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(J),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(J).invert()),z.name.search("E")!==-1&&z.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),z.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),z.quaternion.copy(this.tempQuaternion)),z.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),z.quaternion.copy(this.tempQuaternion)),z.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),z.quaternion.copy(this.tempQuaternion))),z.visible=z.visible&&(z.name.indexOf("X")===-1||this.showX),z.visible=z.visible&&(z.name.indexOf("Y")===-1||this.showY),z.visible=z.visible&&(z.name.indexOf("Z")===-1||this.showZ),z.visible=z.visible&&(z.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),z.material.tempOpacity=z.material.tempOpacity||z.material.opacity,z.material.tempColor=z.material.tempColor||z.material.color.clone(),z.material.color.copy(z.material.tempColor),z.material.opacity=z.material.tempOpacity,this.enabled?this.axis&&(z.name===this.axis?(z.material.opacity=1,z.material.color.lerp(new Re(1,1,1),.5)):this.axis.split("").some(function(pe){return z.name===pe})?(z.material.opacity=1,z.material.color.lerp(new Re(1,1,1),.5)):(z.material.opacity*=.25,z.material.color.lerp(new Re(1,1,1),.5))):(z.material.opacity*=.5,z.material.color.lerp(new Re(1,1,1),.5))}super.updateMatrixWorld()});const e=new Zr({depthTest:!1,depthWrite:!1,transparent:!0,side:nr,fog:!1,toneMapped:!1}),t=new $n({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),i=e.clone();i.opacity=.15;const r=e.clone();r.opacity=.33;const s=e.clone();s.color.set(16711680);const o=e.clone();o.color.set(65280);const a=e.clone();a.color.set(255);const c=e.clone();c.opacity=.25;const f=c.clone();f.color.set(16776960);const h=c.clone();h.color.set(65535);const d=c.clone();d.color.set(16711935),e.clone().color.set(16776960);const v=t.clone();v.color.set(16711680);const _=t.clone();_.color.set(65280);const E=t.clone();E.color.set(255);const S=t.clone();S.color.set(65535);const g=t.clone();g.color.set(16711935);const x=t.clone();x.color.set(16776960);const w=t.clone();w.color.set(7895160);const T=x.clone();T.opacity=.25;const C=new Ln(0,.05,.2,12,1,!1),P=new oi(.125,.125,.125),R=new lt;R.setAttribute("position",new Be([0,0,0,1,0,0],3));const I=(B,J)=>{const Y=new lt,K=[];for(let z=0;z<=64*J;++z)K.push(0,Math.cos(z/32*Math.PI)*B,Math.sin(z/32*Math.PI)*B);return Y.setAttribute("position",new Be(K,3)),Y},b=()=>{const B=new lt;return B.setAttribute("position",new Be([0,0,0,1,1,1],3)),B},L={X:[[new Ne(C,s),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new Ne(C,s),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new vt(R,v)]],Y:[[new Ne(C,o),[0,1,0],null,null,"fwd"],[new Ne(C,o),[0,1,0],[Math.PI,0,0],null,"bwd"],[new vt(R,_),null,[0,0,Math.PI/2]]],Z:[[new Ne(C,a),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new Ne(C,a),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new vt(R,E),null,[0,-Math.PI/2,0]]],XYZ:[[new Ne(new Ii(.1,0),c.clone()),[0,0,0],[0,0,0]]],XY:[[new Ne(new Di(.295,.295),f.clone()),[.15,.15,0]],[new vt(R,x),[.18,.3,0],null,[.125,1,1]],[new vt(R,x),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new Ne(new Di(.295,.295),h.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new vt(R,S),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new vt(R,S),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new Ne(new Di(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new vt(R,g),[.18,0,.3],null,[.125,1,1]],[new vt(R,g),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},H={X:[[new Ne(new Ln(.2,0,1,4,1,!1),i),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new Ne(new Ln(.2,0,1,4,1,!1),i),[0,.6,0]]],Z:[[new Ne(new Ln(.2,0,1,4,1,!1),i),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new Ne(new Ii(.2,0),i)]],XY:[[new Ne(new Di(.4,.4),i),[.2,.2,0]]],YZ:[[new Ne(new Di(.4,.4),i),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new Ne(new Di(.4,.4),i),[.2,0,.2],[-Math.PI/2,0,0]]]},q={START:[[new Ne(new Ii(.01,2),r),null,null,null,"helper"]],END:[[new Ne(new Ii(.01,2),r),null,null,null,"helper"]],DELTA:[[new vt(b(),r),null,null,null,"helper"]],X:[[new vt(R,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new vt(R,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new vt(R,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},G={X:[[new vt(I(1,.5),v)],[new Ne(new Ii(.04,0),s),[0,0,.99],null,[1,3,1]]],Y:[[new vt(I(1,.5),_),null,[0,0,-Math.PI/2]],[new Ne(new Ii(.04,0),o),[0,0,.99],null,[3,1,1]]],Z:[[new vt(I(1,.5),E),null,[0,Math.PI/2,0]],[new Ne(new Ii(.04,0),a),[.99,0,0],null,[1,3,1]]],E:[[new vt(I(1.25,1),T),null,[0,Math.PI/2,0]],[new Ne(new Ln(.03,0,.15,4,1,!1),T),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new Ne(new Ln(.03,0,.15,4,1,!1),T),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new Ne(new Ln(.03,0,.15,4,1,!1),T),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new Ne(new Ln(.03,0,.15,4,1,!1),T),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new vt(I(1,1),w),null,[0,Math.PI/2,0]]]},W={AXIS:[[new vt(R,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},ee={X:[[new Ne(new gs(1,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Ne(new gs(1,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Ne(new gs(1,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Ne(new gs(1.25,.1,2,24),i)]],XYZE:[[new Ne(new ya(.7,10,8),i)]]},oe={X:[[new Ne(P,s),[.8,0,0],[0,0,-Math.PI/2]],[new vt(R,v),null,null,[.8,1,1]]],Y:[[new Ne(P,o),[0,.8,0]],[new vt(R,_),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new Ne(P,a),[0,0,.8],[Math.PI/2,0,0]],[new vt(R,E),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new Ne(P,f),[.85,.85,0],null,[2,2,.2]],[new vt(R,x),[.855,.98,0],null,[.125,1,1]],[new vt(R,x),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new Ne(P,h),[0,.85,.85],null,[.2,2,2]],[new vt(R,S),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new vt(R,S),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new Ne(P,d),[.85,0,.85],null,[2,.2,2]],[new vt(R,g),[.855,0,.98],null,[.125,1,1]],[new vt(R,g),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new Ne(new oi(.125,.125,.125),c.clone()),[1.1,0,0]]],XYZY:[[new Ne(new oi(.125,.125,.125),c.clone()),[0,1.1,0]]],XYZZ:[[new Ne(new oi(.125,.125,.125),c.clone()),[0,0,1.1]]]},ue={X:[[new Ne(new Ln(.2,0,.8,4,1,!1),i),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new Ne(new Ln(.2,0,.8,4,1,!1),i),[0,.5,0]]],Z:[[new Ne(new Ln(.2,0,.8,4,1,!1),i),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new Ne(P,i),[.85,.85,0],null,[3,3,.2]]],YZ:[[new Ne(P,i),[0,.85,.85],null,[.2,3,3]]],XZ:[[new Ne(P,i),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new Ne(new oi(.2,.2,.2),i),[1.1,0,0]]],XYZY:[[new Ne(new oi(.2,.2,.2),i),[0,1.1,0]]],XYZZ:[[new Ne(new oi(.2,.2,.2),i),[0,0,1.1]]]},D={X:[[new vt(R,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new vt(R,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new vt(R,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},V=B=>{const J=new St;for(let Y in B)for(let K=B[Y].length;K--;){const z=B[Y][K][0].clone(),ye=B[Y][K][1],pe=B[Y][K][2],Q=B[Y][K][3],Qe=B[Y][K][4];z.name=Y,z.tag=Qe,ye&&z.position.set(ye[0],ye[1],ye[2]),pe&&z.rotation.set(pe[0],pe[1],pe[2]),Q&&z.scale.set(Q[0],Q[1],Q[2]),z.updateMatrix();const je=z.geometry.clone();je.applyMatrix4(z.matrix),z.geometry=je,z.renderOrder=1/0,z.position.set(0,0,0),z.rotation.set(0,0,0),z.scale.set(1,1,1),J.add(z)}return J};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=V(L)),this.add(this.gizmo.rotate=V(G)),this.add(this.gizmo.scale=V(oe)),this.add(this.picker.translate=V(H)),this.add(this.picker.rotate=V(ee)),this.add(this.picker.scale=V(ue)),this.add(this.helper.translate=V(q)),this.add(this.helper.rotate=V(W)),this.add(this.helper.scale=V(D)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class P4 extends Ne{constructor(){super(new Di(1e5,1e5,2,2),new Zr({visible:!1,wireframe:!0,side:nr,transparent:!0,opacity:.1,toneMapped:!1})),le(this,"isTransformControlsPlane",!0),le(this,"type","TransformControlsPlane"),le(this,"unitX",new N(1,0,0)),le(this,"unitY",new N(0,1,0)),le(this,"unitZ",new N(0,0,1)),le(this,"tempVector",new N),le(this,"dirVector",new N),le(this,"alignVector",new N),le(this,"tempMatrix",new st),le(this,"identityQuaternion",new It),le(this,"cameraQuaternion",new It),le(this,"worldPosition",new N),le(this,"worldQuaternion",new It),le(this,"eye",new N),le(this,"axis",null),le(this,"mode","translate"),le(this,"space","world"),le(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var L4=1/0,R4=9007199254740991,I4="[object Arguments]",D4="[object Function]",N4="[object GeneratorFunction]",k4="[object Symbol]",z4=typeof Qs=="object"&&Qs&&Qs.Object===Object&&Qs,U4=typeof self=="object"&&self&&self.Object===Object&&self,O4=z4||U4||Function("return this")();function F4(n,e,t){switch(t.length){case 0:return n.call(e);case 1:return n.call(e,t[0]);case 2:return n.call(e,t[0],t[1]);case 3:return n.call(e,t[0],t[1],t[2])}return n.apply(e,t)}function B4(n,e){for(var t=-1,i=n?n.length:0,r=Array(i);++t0&&t(a)?e>1?$3(a,e-1,t,i,r):V4(r,a):i||(r[r.length]=a)}return r}function W4(n,e){return n=Object(n),X4(n,e,function(t,i){return i in n})}function X4(n,e,t){for(var i=-1,r=e.length,s={};++i-1&&n%1==0&&n<=R4}function tO(n){var e=typeof n;return!!n&&(e=="object"||e=="function")}function eA(n){return!!n&&typeof n=="object"}function nO(n){return typeof n=="symbol"||eA(n)&&N_.call(n)==k4}var iO=j4(function(n,e){return n==null?{}:W4(n,B4($3(e,1),q4))}),rO=iO;function sO(n,e,t){const{gl:i,size:r,viewport:s}=$i(),o=typeof n=="number"?n:r.width*s.dpr,a=typeof e=="number"?e:r.height*s.dpr,c=(typeof n=="number"?t:n)||{},{samples:f=0,depth:h,...d}=c,m=Te.exports.useMemo(()=>{let v;return v=new ar(o,a,{minFilter:en,magFilter:en,encoding:i.outputEncoding,type:ca,...d}),h&&(v.depthTexture=new s_(o,a,Hr)),v.samples=f,v},[]);return Te.exports.useLayoutEffect(()=>{m.setSize(o,a),f&&(m.samples=f)},[f,m,o,a]),Te.exports.useEffect(()=>()=>m.dispose(),[]),m}const oO=n=>typeof n=="function",aO=Te.exports.forwardRef(({envMap:n,resolution:e=256,frames:t=1/0,makeDefault:i,children:r,...s},o)=>{const a=$i(({set:S})=>S),c=$i(({camera:S})=>S),f=$i(({size:S})=>S),h=Te.exports.useRef(null),d=Te.exports.useRef(null),m=sO(e);Te.exports.useLayoutEffect(()=>{s.manual||(h.current.aspect=f.width/f.height)},[f,s]),Te.exports.useLayoutEffect(()=>{h.current.updateProjectionMatrix()});let v=0,_=null;const E=oO(r);return n4(S=>{E&&(t===1/0||v{if(i){const S=c;return a(()=>({camera:h.current})),()=>a(()=>({camera:S}))}},[h,i,a]),Xp(L_,{children:[Gt("perspectiveCamera",{ref:E4([h,o]),...s,children:!E&&r}),Gt("group",{ref:d,children:E&&r(m.texture)})]})});var lO=200,k_="__lodash_hash_undefined__",uO=1/0,tA=9007199254740991,cO="[object Arguments]",fO="[object Function]",hO="[object GeneratorFunction]",dO="[object Symbol]",pO=/[\\^$.*+?()[\]{}|]/g,mO=/^\[object .+?Constructor\]$/,gO=/^(?:0|[1-9]\d*)$/,vO=typeof Qs=="object"&&Qs&&Qs.Object===Object&&Qs,yO=typeof self=="object"&&self&&self.Object===Object&&self,z_=vO||yO||Function("return this")();function _O(n,e,t){switch(t.length){case 0:return n.call(e);case 1:return n.call(e,t[0]);case 2:return n.call(e,t[0],t[1]);case 3:return n.call(e,t[0],t[1],t[2])}return n.apply(e,t)}function xO(n,e){var t=n?n.length:0;return!!t&&MO(n,e,0)>-1}function SO(n,e,t){for(var i=-1,r=n?n.length:0;++i-1}function jO(n,e){var t=this.__data__,i=Yp(t,n);return i<0?t.push([n,e]):t[i][1]=e,this}Kl.prototype.clear=HO;Kl.prototype.delete=GO;Kl.prototype.get=WO;Kl.prototype.has=XO;Kl.prototype.set=jO;function $l(n){var e=-1,t=n?n.length:0;for(this.clear();++e=lO&&(s=CO,o=!1,e=new fp(e));e:for(;++r0&&t(a)?e>1?sA(a,e-1,t,i,r):U_(r,a):i||(r[r.length]=a)}return r}function nF(n,e,t){var i=e(n);return F_(n)?i:U_(i,t(n))}function iF(n){if(!B_(n)||pF(n))return!1;var e=uA(n)||PO(n)?IO:mO;return e.test(yF(n))}function rF(n){if(!B_(n))return gF(n);var e=mF(n),t=[];for(var i in n)i=="constructor"&&(e||!Jl.call(n,i))||t.push(i);return t}function sF(n,e){return n=Object(n),oF(n,e,function(t,i){return i in n})}function oF(n,e,t){for(var i=-1,r=e.length,s={};++i-1&&n%1==0&&n-1&&n%1==0&&n<=tA}function B_(n){var e=typeof n;return!!n&&(e=="object"||e=="function")}function cA(n){return!!n&&typeof n=="object"}function wF(n){return typeof n=="symbol"||cA(n)&&O_.call(n)==dO}function MF(n){return lA(n)?eF(n,!0):rF(n)}var EF=aF(function(n,e){return n==null?{}:(e=nA(sA(e,1),vF),sF(n,tF(lF(n),e)))});function fA(){return[]}var TF=EF;const AF=Te.exports.forwardRef(({children:n,domElement:e,onChange:t,onMouseDown:i,onMouseUp:r,onObjectChange:s,object:o,makeDefault:a,...c},f)=>{const h=["enabled","axis","mode","translationSnap","rotationSnap","scaleSnap","space","size","showX","showY","showZ"],{camera:d,...m}=c,v=rO(m,h),_=TF(m,h),E=$i(W=>W.controls),S=$i(W=>W.gl),g=$i(W=>W.events),x=$i(W=>W.camera),w=$i(W=>W.invalidate),T=$i(W=>W.get),C=$i(W=>W.set),P=d||x,R=e||g.connected||S.domElement,I=Te.exports.useMemo(()=>new C4(P,R),[P,R]),b=Te.exports.useRef();Te.exports.useLayoutEffect(()=>(o?I.attach(o instanceof St?o:o.current):b.current instanceof St&&I.attach(b.current),()=>void I.detach()),[o,n,I]),Te.exports.useEffect(()=>{if(E){const W=ee=>E.enabled=!ee.value;return I.addEventListener("dragging-changed",W),()=>I.removeEventListener("dragging-changed",W)}},[I,E]);const L=Te.exports.useRef(),H=Te.exports.useRef(),q=Te.exports.useRef(),G=Te.exports.useRef();return Te.exports.useLayoutEffect(()=>void(L.current=t),[t]),Te.exports.useLayoutEffect(()=>void(H.current=i),[i]),Te.exports.useLayoutEffect(()=>void(q.current=r),[r]),Te.exports.useLayoutEffect(()=>void(G.current=s),[s]),Te.exports.useEffect(()=>{const W=D=>{w(),L.current==null||L.current(D)},ee=D=>H.current==null?void 0:H.current(D),oe=D=>q.current==null?void 0:q.current(D),ue=D=>G.current==null?void 0:G.current(D);return I.addEventListener("change",W),I.addEventListener("mouseDown",ee),I.addEventListener("mouseUp",oe),I.addEventListener("objectChange",ue),()=>{I.removeEventListener("change",W),I.removeEventListener("mouseDown",ee),I.removeEventListener("mouseUp",oe),I.removeEventListener("objectChange",ue)}},[w,I]),Te.exports.useEffect(()=>{if(a){const W=T().controls;return C({controls:I}),()=>C({controls:W})}},[a,I]),I?Xp(L_,{children:[Gt("primitive",{ref:f,object:I,...v}),Gt("group",{ref:b,..._,children:n})]}):null}),CF=()=>!window.invokeNative,hA=(n,e)=>{const t=Te.exports.useRef(()=>{});Te.exports.useEffect(()=>{t.current=e},[e]),Te.exports.useEffect(()=>{const i=r=>{const{action:s,data:o}=r.data;t.current&&s===n&&t.current(o)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[n])};async function Vu(n,e,t){const i={method:"post",headers:{"Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify(e)};if(CF()&&t)return t;const r=window.GetParentResourceName?window.GetParentResourceName():"nui-frame-app";return await(await fetch(`https://${r}/${n}`,i)).json()}const bF=()=>{const{camera:n}=$i(),e=(t,i)=>t>0&&t<90?i:t>-180&&t<-90||t>0?-i:i;return hA("setCameraPosition",({position:t,rotation:i})=>{n.position.set(t.x,t.z,-t.y),n.rotation.order="YZX",i&&n.rotation.set(Br.degToRad(i.x),Br.degToRad(e(i.x,i.z)),Br.degToRad(i.y)),n.updateProjectionMatrix()}),Gt(aO,{position:[0,0,10],makeDefault:!0,onUpdate:t=>t.updateProjectionMatrix()})},PF=()=>{const n=Te.exports.useRef(null),[e,t]=Te.exports.useState(),[i,r]=Te.exports.useState("translate"),s=()=>{const o={handle:e,position:{x:n.current.position.x,y:-n.current.position.z,z:n.current.position.y},rotation:{x:Br.radToDeg(n.current.rotation.x),y:Br.radToDeg(-n.current.rotation.z),z:Br.radToDeg(n.current.rotation.y)}};Vu("moveEntity",o)};return hA("setGizmoEntity",o=>{t(o.handle),o.handle&&(n.current.position.set(o.position.x,o.position.z,-o.position.y),n.current.rotation.order="YZX",n.current.rotation.set(Br.degToRad(o.rotation.x),Br.degToRad(o.rotation.z),Br.degToRad(o.rotation.y)))}),Te.exports.useEffect(()=>{const o=a=>{switch(a.code){case"KeyR":if(i=="rotate")return;r("rotate"),Vu("swapMode",{mode:"Rotate"});break;case"KeyW":if(i=="translate")return;r("translate"),Vu("swapMode",{mode:"Translate"});break;case"Escape":Vu("finishEdit");break;case"KeyQ":Vu("cam");break}};return window.addEventListener("keyup",o),()=>window.removeEventListener("keyup",o)}),Gt(L_,{children:Xp(Te.exports.Suspense,{fallback:Gt("p",{children:"Loading Gizmo"}),children:[e!=null&&Gt(AF,{size:.5,object:n,mode:i,onObjectChange:s}),Gt("mesh",{ref:n})]})})},LF=()=>Xp(M4,{style:{zIndex:1},children:[Gt(bF,{}),Gt(PF,{})]});function RF(){return Gt("div",{style:{width:"100vw",height:"100vh"},children:Gt(LF,{})})}d0.createRoot(document.getElementById("root")).render(Gt(RF,{}));